implements PLN-0157

This commit is contained in:
2026-07-05 01:07:54 +01:00
parent 0ffb3467b1
commit dcd3479b1d
6 changed files with 103 additions and 37 deletions
@@ -52,45 +52,53 @@ impl HubHomeStep {
ctx.os.windows().set_focus(id);
return Some(FirmwareState::ShellRunning(ShellRunningStep::new(task_id)));
}
Some(SystemProfileAction::LaunchGame { path }) => match CartridgeLoader::load(&path) {
Ok(cartridge) => {
if cartridge.app_mode == AppMode::Game
&& let Some(resident_task_id) = ctx.os.lifecycle().resident_game_task()
{
let resident_app_id = ctx
.os
.sessions()
.vm_session_for_task(resident_task_id)
.map(|session| session.app_id)
.unwrap_or(0);
Some(SystemProfileAction::LaunchGame { target }) => {
match CartridgeLoader::load(&target.path) {
Ok(cartridge) => {
if cartridge.app_mode == AppMode::Game
&& let Some(resident_task_id) = ctx.os.lifecycle().resident_game_task()
{
let resident_app_id = ctx
.os
.sessions()
.vm_session_for_task(resident_task_id)
.map(|session| session.app_id)
.unwrap_or(0);
if resident_app_id == cartridge.app_id {
return Some(FirmwareState::ResumeResidentGame);
if resident_app_id == cartridge.app_id {
return Some(FirmwareState::ResumeResidentGame);
}
ctx.os.log(
LogLevel::Warn,
LogSource::Hub,
0,
format!(
"Cannot launch Home game {} while resident game app_id {} is active",
cartridge.title, resident_app_id
),
);
return None;
}
return Some(FirmwareState::LoadCartridge(LoadCartridgeStep::new(
cartridge,
)));
}
Err(error) => {
ctx.os.log(
LogLevel::Warn,
LogLevel::Error,
LogSource::Hub,
0,
format!(
"Cannot launch Home game {} while resident game app_id {} is active",
cartridge.title, resident_app_id
"Failed to launch Home game {}: {:?}",
target.path.display(),
error
),
);
return None;
}
return Some(FirmwareState::LoadCartridge(LoadCartridgeStep::new(cartridge)));
}
Err(error) => {
ctx.os.log(
LogLevel::Error,
LogSource::Hub,
0,
format!("Failed to launch Home game {}: {:?}", path.display(), error),
);
}
},
}
Some(SystemProfileAction::CloseShell) | None => {}
}