implements PLN-0165
This commit is contained in:
@@ -8,7 +8,10 @@ pub use os::{
|
||||
DEFAULT_GAME_PAUSE_BUDGET_TICKS, GameLifecycleEvent, GameLifecycleEventKind, LifecycleError,
|
||||
LifecycleOperation, SessionError, SystemOS,
|
||||
};
|
||||
pub use programs::{NativeShellApp, PrometeuHub, SystemProfileAction, SystemProfileUpdate};
|
||||
pub use programs::{
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL, NativeShellApp, PrometeuHub, SystemProfileAction,
|
||||
SystemProfileUpdate,
|
||||
};
|
||||
pub use prometeu_hal::{RenderWorkerBackend, RenderWorkerFrameSink};
|
||||
pub use services::async_work::{
|
||||
AsyncWorkActiveJob, AsyncWorkCancelToken, AsyncWorkJobContext, AsyncWorkJobId,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
mod prometeu_hub;
|
||||
|
||||
pub use prometeu_hub::{NativeShellApp, PrometeuHub, SystemProfileAction, SystemProfileUpdate};
|
||||
pub use prometeu_hub::{
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL, NativeShellApp, PrometeuHub, SystemProfileAction,
|
||||
SystemProfileUpdate,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#[allow(clippy::module_inception)]
|
||||
mod prometeu_hub;
|
||||
|
||||
pub use prometeu_hub::{NativeShellApp, PrometeuHub, SystemProfileAction, SystemProfileUpdate};
|
||||
pub use prometeu_hub::{
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL, NativeShellApp, PrometeuHub, SystemProfileAction,
|
||||
SystemProfileUpdate,
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ const GAME_ROW_W: i32 = 336;
|
||||
const GAME_ROW_H: i32 = 22;
|
||||
const GAME_ROW_GAP: i32 = 6;
|
||||
const MAX_HOME_GAME_ROWS: usize = 3;
|
||||
const SUSPENDED_GAME_KILL_CONTROL: Rect = Rect { x: 288, y: 230, w: 168, h: 24 };
|
||||
pub const HUB_SUSPENDED_GAME_KILL_CONTROL: Rect = Rect { x: 288, y: 230, w: 168, h: 24 };
|
||||
#[cfg(test)]
|
||||
const SHELL_FRAME: Rect = Rect { x: 40, y: 20, w: 400, h: 220 };
|
||||
|
||||
@@ -255,7 +255,7 @@ fn action_for_click(
|
||||
return rect_contains(CLOSE_BUTTON, x, y).then_some(SystemProfileAction::CloseShell);
|
||||
}
|
||||
|
||||
if suspended_game.is_some() && rect_contains(SUSPENDED_GAME_KILL_CONTROL, x, y) {
|
||||
if suspended_game.is_some() && rect_contains(HUB_SUSPENDED_GAME_KILL_CONTROL, x, y) {
|
||||
return Some(SystemProfileAction::KillResidentGame);
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ fn render_home_packet(
|
||||
}
|
||||
|
||||
if let Some(suspended_game) = suspended_game {
|
||||
let hovered = rect_contains(SUSPENDED_GAME_KILL_CONTROL, pointer_x, pointer_y);
|
||||
let hovered = rect_contains(HUB_SUSPENDED_GAME_KILL_CONTROL, pointer_x, pointer_y);
|
||||
draw_suspended_game_kill_control(&mut commands, suspended_game, hovered);
|
||||
}
|
||||
|
||||
@@ -470,13 +470,13 @@ fn draw_suspended_game_kill_control(
|
||||
) {
|
||||
let fill = if hovered { COLOR_KILL_ACTIVE } else { COLOR_KILL };
|
||||
let border = if hovered { COLOR_HILITE } else { COLOR_BORDER };
|
||||
fill_rect(commands, SUSPENDED_GAME_KILL_CONTROL, fill);
|
||||
draw_rect(commands, SUSPENDED_GAME_KILL_CONTROL, border);
|
||||
fill_rect(commands, HUB_SUSPENDED_GAME_KILL_CONTROL, fill);
|
||||
draw_rect(commands, HUB_SUSPENDED_GAME_KILL_CONTROL, border);
|
||||
draw_buffer_text(
|
||||
commands,
|
||||
SUSPENDED_GAME_KILL_CONTROL.x + 8,
|
||||
SUSPENDED_GAME_KILL_CONTROL.y + 8,
|
||||
&fit_text_to_control(&suspended_game.title, SUSPENDED_GAME_KILL_CONTROL.w - 16),
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.x + 8,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.y + 8,
|
||||
&fit_text_to_control(&suspended_game.title, HUB_SUSPENDED_GAME_KILL_CONTROL.w - 16),
|
||||
COLOR_TEXT,
|
||||
);
|
||||
}
|
||||
@@ -695,8 +695,8 @@ mod tests {
|
||||
fn home_render_shows_suspended_game_kill_control_when_game_is_resident() {
|
||||
let suspended_game = SuspendedGameIndicator { title: "Stress Console".to_string() };
|
||||
let packet = render_home_packet(
|
||||
SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
&[],
|
||||
Some(&suspended_game),
|
||||
);
|
||||
@@ -705,15 +705,15 @@ mod tests {
|
||||
matches!(
|
||||
command,
|
||||
GfxUiCommand::FillRect { rect, color }
|
||||
if *rect == SUSPENDED_GAME_KILL_CONTROL && *color == COLOR_KILL_ACTIVE
|
||||
if *rect == HUB_SUSPENDED_GAME_KILL_CONTROL && *color == COLOR_KILL_ACTIVE
|
||||
)
|
||||
}));
|
||||
assert!(packet.commands.iter().any(|command| {
|
||||
matches!(
|
||||
command,
|
||||
GfxUiCommand::DrawText { x, y, text, .. }
|
||||
if *x == SUSPENDED_GAME_KILL_CONTROL.x + 8
|
||||
&& *y == SUSPENDED_GAME_KILL_CONTROL.y + 8
|
||||
if *x == HUB_SUSPENDED_GAME_KILL_CONTROL.x + 8
|
||||
&& *y == HUB_SUSPENDED_GAME_KILL_CONTROL.y + 8
|
||||
&& text == "Stress Console"
|
||||
)
|
||||
}));
|
||||
@@ -722,8 +722,8 @@ mod tests {
|
||||
#[test]
|
||||
fn home_render_omits_suspended_game_kill_control_without_resident_game() {
|
||||
let packet = render_home_packet(
|
||||
SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
&[],
|
||||
None,
|
||||
);
|
||||
@@ -732,7 +732,7 @@ mod tests {
|
||||
matches!(
|
||||
command,
|
||||
GfxUiCommand::FillRect { rect, color }
|
||||
if *rect == SUSPENDED_GAME_KILL_CONTROL
|
||||
if *rect == HUB_SUSPENDED_GAME_KILL_CONTROL
|
||||
&& (*color == COLOR_KILL || *color == COLOR_KILL_ACTIVE)
|
||||
)
|
||||
}));
|
||||
@@ -745,8 +745,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
action_for_click(
|
||||
false,
|
||||
SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
true,
|
||||
&[],
|
||||
Some(&suspended_game),
|
||||
@@ -756,8 +756,8 @@ mod tests {
|
||||
assert_eq!(
|
||||
action_for_click(
|
||||
false,
|
||||
SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.x,
|
||||
HUB_SUSPENDED_GAME_KILL_CONTROL.y,
|
||||
true,
|
||||
&[],
|
||||
None,
|
||||
@@ -776,8 +776,8 @@ mod tests {
|
||||
.iter()
|
||||
.find_map(|command| match command {
|
||||
GfxUiCommand::DrawText { x, y, text, .. }
|
||||
if *x == SUSPENDED_GAME_KILL_CONTROL.x + 8
|
||||
&& *y == SUSPENDED_GAME_KILL_CONTROL.y + 8 =>
|
||||
if *x == HUB_SUSPENDED_GAME_KILL_CONTROL.x + 8
|
||||
&& *y == HUB_SUSPENDED_GAME_KILL_CONTROL.y + 8 =>
|
||||
{
|
||||
Some(text)
|
||||
}
|
||||
@@ -786,7 +786,7 @@ mod tests {
|
||||
.expect("kill control text should render");
|
||||
|
||||
assert!(label.ends_with(".."));
|
||||
assert!(label.chars().count() <= ((SUSPENDED_GAME_KILL_CONTROL.w - 16) / 8) as usize);
|
||||
assert!(label.chars().count() <= ((HUB_SUSPENDED_GAME_KILL_CONTROL.w - 16) / 8) as usize);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user