mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2026-03-21 21:58:52 +00:00
fix: game state was not updated
This commit is contained in:
parent
80836f32ec
commit
c70feada75
@ -39,14 +39,16 @@ pub async fn get_proton() -> Proton {
|
|||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run_game() {
|
pub async fn run_game() -> anyhow::Result<()> {
|
||||||
let proton = get_proton().await;
|
let proton = get_proton().await;
|
||||||
let game_dir = GameConfig::get_game_dir().await;
|
let game_dir = GameConfig::get_config().await.game_dir;
|
||||||
if game_dir.is_none() {
|
if game_dir.is_none() {
|
||||||
error!("Failed to start game, the game directory was not found")
|
anyhow::bail!("Failed to start game, the game directory was not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
GameManager::start_game(&proton, game_dir.unwrap(), None, false).await;
|
GameManager::start_game(&proton, game_dir.unwrap(), None, false).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -77,7 +79,12 @@ impl Worker for HandleGameProcess {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async {
|
.block_on(async {
|
||||||
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(true));
|
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(true));
|
||||||
run_game().await;
|
if let Err(error) = run_game().await {
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Unable to start game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(false));
|
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(false));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,6 +138,7 @@ impl Worker for HandleGameInstallation {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sender.output(pages::game::GamePageMsg::SetIsDownloading(false));
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(false));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
HandleGameInstallationMsg::StartPatch => {
|
HandleGameInstallationMsg::StartPatch => {
|
||||||
@ -155,6 +163,7 @@ impl Worker for HandleGameInstallation {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sender.output(pages::game::GamePageMsg::SetIsPatching(false));
|
sender.output(pages::game::GamePageMsg::SetIsPatching(false));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
HandleGameInstallationMsg::StartUpdate(progress_bar) => {
|
HandleGameInstallationMsg::StartUpdate(progress_bar) => {
|
||||||
@ -187,6 +196,7 @@ impl Worker for HandleGameInstallation {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sender.output(pages::game::GamePageMsg::SetIsDownloading(true));
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(true));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||||||
set_hexpand: false,
|
set_hexpand: false,
|
||||||
set_width_request: 200,
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
set_visible: model.game_state == GameState::GameNotInstalled,
|
set_visible: model.game_state == GameState::GameNotInstalled,
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
@ -96,6 +97,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||||||
set_hexpand: false,
|
set_hexpand: false,
|
||||||
set_width_request: 200,
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
set_visible: model.game_state == GameState::GameNotPatched,
|
set_visible: model.game_state == GameState::GameNotPatched,
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
@ -112,6 +114,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||||||
set_hexpand: false,
|
set_hexpand: false,
|
||||||
set_width_request: 200,
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
set_visible: model.game_state == GameState::GameInstalled,
|
set_visible: model.game_state == GameState::GameInstalled,
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
@ -189,6 +192,7 @@ impl SimpleAsyncComponent for GamePage {
|
|||||||
|
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
set_orientation: gtk::Orientation::Horizontal,
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
|
||||||
gtk::Label {
|
gtk::Label {
|
||||||
set_label: "Patching game",
|
set_label: "Patching game",
|
||||||
|
|||||||
@ -153,8 +153,8 @@ impl GameManager {
|
|||||||
game_dir: PathBuf,
|
game_dir: PathBuf,
|
||||||
options: Option<String>,
|
options: Option<String>,
|
||||||
show_logs: bool,
|
show_logs: bool,
|
||||||
) {
|
) -> anyhow::Result<()> {
|
||||||
let proton_version = proton.wine().version().unwrap();
|
let proton_version = proton.wine().version()?;
|
||||||
let binary_path = game_dir
|
let binary_path = game_dir
|
||||||
.join(get_game_name())
|
.join(get_game_name())
|
||||||
.join(get_game_name_with_executable());
|
.join(get_game_name_with_executable());
|
||||||
@ -162,16 +162,12 @@ impl GameManager {
|
|||||||
debug!("Wine version : {:?}", proton_version);
|
debug!("Wine version : {:?}", proton_version);
|
||||||
|
|
||||||
let mut child = if let Some(custom_command) = options {
|
let mut child = if let Some(custom_command) = options {
|
||||||
Self::run(proton, binary_path, Some(custom_command))
|
Self::run(proton, binary_path, Some(custom_command)).await?
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
} else {
|
} else {
|
||||||
if let Some(custom_command) = GameConfig::get_launch_options().await.unwrap() {
|
if let Some(custom_command) = GameConfig::get_launch_options().await.unwrap() {
|
||||||
Self::run(proton, binary_path, Some(custom_command))
|
Self::run(proton, binary_path, Some(custom_command)).await?
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
} else {
|
} else {
|
||||||
Self::run(proton, binary_path, None).await.unwrap()
|
Self::run(proton, binary_path, None).await?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -274,6 +270,8 @@ impl GameManager {
|
|||||||
.write_all(to_write)
|
.write_all(to_write)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to write the output to the log file");
|
.expect("Failed to write the output to the log file");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run(
|
async fn run(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user