feat: initial voiceovers integration
This commit is contained in:
parent
544cf245cc
commit
b93172f7d9
3 changed files with 83 additions and 5 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -57,8 +57,8 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
|||
|
||||
[[package]]
|
||||
name = "anime-game-core"
|
||||
version = "1.16.1"
|
||||
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.16.1#5864e5f00219c3355fc3f4cc2ac3a730a5397391"
|
||||
version = "1.17.0"
|
||||
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.17.0#e2cd6d91ef80d9fba72e0abe2e71b802d558dd75"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bzip2",
|
||||
|
@ -82,8 +82,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-launcher-sdk"
|
||||
version = "1.11.4"
|
||||
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.11.4#ea5a501a0f4dec6dee0cc33d5b2d6757503764cb"
|
||||
version = "1.12.0"
|
||||
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.12.0#eaa6db3a68c6c73120589185e78c707945d7723f"
|
||||
dependencies = [
|
||||
"anime-game-core",
|
||||
"anyhow",
|
||||
|
|
|
@ -19,7 +19,7 @@ glib-build-tools = "0.18"
|
|||
|
||||
[dependencies.anime-launcher-sdk]
|
||||
git = "https://github.com/an-anime-team/anime-launcher-sdk"
|
||||
tag = "1.11.4"
|
||||
tag = "1.12.0"
|
||||
features = ["all", "star-rail", "star-rail-patch"]
|
||||
|
||||
# path = "../anime-launcher-sdk" # ! for dev purposes only
|
||||
|
|
|
@ -123,6 +123,13 @@ pub enum GeneralAppMsg {
|
|||
/// was retrieved from remote repos
|
||||
SetMainPatch(Option<(Version, JadeitePatchStatusVariant)>),
|
||||
|
||||
// If one ever wish to change it to accept VoiceLocale
|
||||
// I'd recommend to use clone!(@strong self.locale as locale => move |_| { .. })
|
||||
// in the VoicePackage component
|
||||
AddVoicePackage(DynamicIndex),
|
||||
RemoveVoicePackage(DynamicIndex),
|
||||
SetVoicePackageSensitivity(DynamicIndex, bool),
|
||||
|
||||
UpdateDownloadedWine,
|
||||
UpdateDownloadedDxvk,
|
||||
|
||||
|
@ -296,6 +303,12 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
}
|
||||
},
|
||||
|
||||
#[local_ref]
|
||||
voice_packages -> adw::ExpanderRow {
|
||||
set_title: &tr!("game-voiceovers"),
|
||||
set_subtitle: &tr!("game-voiceovers-description")
|
||||
},
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_spacing: 8,
|
||||
|
@ -550,6 +563,14 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
languages: SUPPORTED_LANGUAGES.iter().map(|lang| tr!(format_lang(lang).as_str())).collect()
|
||||
};
|
||||
|
||||
for package in VoiceLocale::list() {
|
||||
model.voice_packages.guard().push_back((
|
||||
*package,
|
||||
CONFIG.game.voices.iter().any(|voice| VoiceLocale::from_str(voice) == Some(*package))
|
||||
));
|
||||
}
|
||||
|
||||
let voice_packages = model.voice_packages.widget();
|
||||
let components_page = model.components_page.widget();
|
||||
|
||||
let widgets = view_output!();
|
||||
|
@ -569,6 +590,63 @@ impl SimpleAsyncComponent for GeneralApp {
|
|||
self.main_patch = patch;
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
GeneralAppMsg::AddVoicePackage(index) => {
|
||||
if let Some(package) = self.voice_packages.get(index.current_index()) {
|
||||
if let Ok(mut config) = Config::get() {
|
||||
if !config.game.voices.iter().any(|voice| VoiceLocale::from_str(voice) == Some(package.locale)) {
|
||||
config.game.voices.push(package.locale.to_code().to_string());
|
||||
|
||||
Config::update(config);
|
||||
|
||||
sender.output(PreferencesAppMsg::UpdateLauncherState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
GeneralAppMsg::RemoveVoicePackage(index) => {
|
||||
if let Some(package) = self.voice_packages.guard().get_mut(index.current_index()) {
|
||||
if let Ok(mut config) = Config::get() {
|
||||
package.sensitive = false;
|
||||
|
||||
config.game.voices.retain(|voice| VoiceLocale::from_str(voice) != Some(package.locale));
|
||||
|
||||
Config::update(config.clone());
|
||||
|
||||
let package = VoicePackage::with_locale(package.locale, config.launcher.edition).unwrap();
|
||||
let game_path = config.game.path.for_edition(config.launcher.edition).to_path_buf();
|
||||
|
||||
if package.is_installed_in(&game_path) {
|
||||
std::thread::spawn(move || {
|
||||
if let Err(err) = package.delete_in(game_path) {
|
||||
tracing::error!("Failed to delete voice package: {:?}", package.locale());
|
||||
|
||||
sender.input(GeneralAppMsg::Toast {
|
||||
title: tr!("voice-package-deletion-error"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
}
|
||||
|
||||
sender.input(GeneralAppMsg::SetVoicePackageSensitivity(index, true));
|
||||
sender.output(PreferencesAppMsg::UpdateLauncherState);
|
||||
});
|
||||
}
|
||||
|
||||
else {
|
||||
sender.input(GeneralAppMsg::SetVoicePackageSensitivity(index, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeneralAppMsg::SetVoicePackageSensitivity(index, sensitive) => {
|
||||
if let Some(package) = self.voice_packages.guard().get_mut(index.current_index()) {
|
||||
package.sensitive = sensitive;
|
||||
}
|
||||
}
|
||||
|
||||
GeneralAppMsg::UpdateDownloadedWine => {
|
||||
self.components_page.sender()
|
||||
.send(ComponentsPageMsg::UpdateDownloadedWine)
|
||||
|
|
Loading…
Reference in a new issue