diff --git a/anime-game-core b/anime-game-core index 8a0dd62..659ffce 160000 --- a/anime-game-core +++ b/anime-game-core @@ -1 +1 @@ -Subproject commit 8a0dd62b38a0e1c0847a2665fe49961d4ed2a25d +Subproject commit 659ffce54f88c40af8cbef4100fbd68c754b4b44 diff --git a/src/lib/launcher/states.rs b/src/lib/launcher/states.rs index 630ba7c..1da0389 100644 --- a/src/lib/launcher/states.rs +++ b/src/lib/launcher/states.rs @@ -1,6 +1,8 @@ use gtk4::{self as gtk, prelude::*}; use libadwaita::{self as adw, prelude::*}; +use std::io::{Error, ErrorKind}; + use anime_game_core::prelude::*; use crate::lib::config; @@ -52,11 +54,25 @@ impl LauncherState { status_page.set_description(Some("Updating voice info...")); } - for voice_package in game.get_voice_packages()? { + for voice_package in &config.game.voices { + let mut voice_package = VoicePackage::with_locale(match VoiceLocale::from_str(voice_package) { + Some(locale) => locale, + None => return Err(Error::new(ErrorKind::Other, format!("Incorrect voice locale \"{}\" specified in the config", voice_package))) + })?; + if let Some(status_page) = &status_page { status_page.set_description(Some(format!("Updating voice info ({})...", voice_package.locale().to_name()).as_str())); } + // Replace voice package struct with the one constructed in the game's folder + // so it'll properly calculate its difference instead of saying "not installed" + if voice_package.is_installed_in(&config.game.path) { + voice_package = match VoicePackage::new(get_voice_package_path(&config.game.path, voice_package.locale())) { + Some(locale) => locale, + None => return Err(Error::new(ErrorKind::Other, format!("Failed to load {} voice package", voice_package.locale().to_name()))) + }; + } + let diff = voice_package.try_get_diff()?; match diff { diff --git a/src/ui/main.rs b/src/ui/main.rs index eb21098..c9034a2 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -143,7 +143,11 @@ impl App { result.widgets.status_page.set_visible(false); result.widgets.launcher_content.set_visible(true); }, - Err(err) => result.toast_error("Failed to get initial launcher state", err) + Err(err) => { + glib::MainContext::default().invoke(move || { + result.toast_error("Failed to get initial launcher state", err); + }); + } } }));