use super::*;
impl ShowcasePage {
#[must_use]
pub fn new(route: &'static str, state: ShowcaseState, tokens: ThemeTokens) -> Self {
Self {
route,
state,
tokens,
}
}
}
#[component(retention = Freeze)]
impl ShowcasePage {
fn on_mount(&self, _node: NodeId) {
let route: &str = self.get_route();
let node_style: &ShowcaseState = self.get_state();
let _: bool = {
if let Some(mut updated_value) = (node_style.get_lifecycle_mounts()).try_get_untracked()
{
{
let char_item: &mut u32 = &mut updated_value;
*char_item += 1;
}
(node_style.get_lifecycle_mounts()).set(updated_value)
} else {
false
}
};
let _: bool = node_style
.get_lifecycle_last_event()
.set_if_changed(format!("MOUNT {route} (PageRetention::Freeze)"));
if !node_style.get_bg_frozen().get_untracked() {
if route == ROUTE_GAME {
node_style.get_game_host().set_paused(false);
} else if route == ROUTE_GAME_3D {
node_style.get_game3d_host().set_paused(false);
} else if route == ROUTE_WATER {
node_style.get_water_host().set_paused(false);
}
}
}
fn on_activate(&self, _node: NodeId) {
let route: &str = self.get_route();
let node_style: &ShowcaseState = self.get_state();
if !node_style.get_bg_frozen().get_untracked() {
if route == ROUTE_GAME {
node_style.get_game_host().set_paused(false);
} else if route == ROUTE_GAME_3D {
node_style.get_game3d_host().set_paused(false);
} else if route == ROUTE_WATER {
node_style.get_water_host().set_paused(false);
}
}
}
fn on_freeze(&self, _node: NodeId) {
let route: &str = self.get_route();
let node_style: &ShowcaseState = self.get_state();
let _: bool = {
if let Some(mut updated_value) =
(node_style.get_lifecycle_freezes()).try_get_untracked()
{
{
let char_item: &mut u32 = &mut updated_value;
*char_item += 1;
}
(node_style.get_lifecycle_freezes()).set(updated_value)
} else {
false
}
};
let _: bool = node_style
.get_lifecycle_last_event()
.set_if_changed(format!("FREEZE {route} (effects & engines suspended)"));
if route == ROUTE_GAME {
node_style.get_game_host().set_paused(true);
} else if route == ROUTE_GAME_3D {
node_style.get_game3d_host().set_paused(true);
} else if route == ROUTE_WATER {
node_style.get_water_host().set_paused(true);
}
}
fn on_resume(&self, _node: NodeId) {
let route: &str = self.get_route();
let node_style: &ShowcaseState = self.get_state();
let _: bool = {
if let Some(mut updated_value) =
(node_style.get_lifecycle_resumes()).try_get_untracked()
{
{
let char_item: &mut u32 = &mut updated_value;
*char_item += 1;
}
(node_style.get_lifecycle_resumes()).set(updated_value)
} else {
false
}
};
let _: bool = node_style
.get_lifecycle_last_event()
.set_if_changed(format!("RESUME {route} (coalesced state synced)"));
if !node_style.get_bg_frozen().get_untracked() {
if route == ROUTE_GAME {
node_style.get_game_host().set_paused(false);
} else if route == ROUTE_GAME_3D {
node_style.get_game3d_host().set_paused(false);
} else if route == ROUTE_WATER {
node_style.get_water_host().set_paused(false);
}
}
}
fn on_destroy(&self) {
let route: &str = self.get_route();
let node_style: &ShowcaseState = self.get_state();
let _: bool = {
if let Some(mut updated_value) =
(node_style.get_lifecycle_destroys()).try_get_untracked()
{
{
let char_item: &mut u32 = &mut updated_value;
*char_item += 1;
}
(node_style.get_lifecycle_destroys()).set(updated_value)
} else {
false
}
};
if route == ROUTE_GAME {
node_style.get_game_host().set_paused(true);
} else if route == ROUTE_GAME_3D {
node_style.get_game3d_host().set_paused(true);
} else if route == ROUTE_WATER {
node_style.get_water_host().set_paused(true);
}
}
fn render(&self) -> NodeId {
mount_route_by_name(self.get_route(), self.get_state(), self.get_tokens())
}
}