mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-22 21:02:44 +03:00
feat(core): implemented SDK 0.4.0
This commit is contained in:
parent
afdf8f57cd
commit
ae990e996b
5 changed files with 81 additions and 38 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -76,10 +76,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anime-launcher-sdk"
|
name = "anime-launcher-sdk"
|
||||||
version = "0.3.6"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anime-game-core",
|
"anime-game-core",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"cached",
|
||||||
"dirs",
|
"dirs",
|
||||||
"discord-rich-presence",
|
"discord-rich-presence",
|
||||||
"enum-ordinalize",
|
"enum-ordinalize",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f6daddc4bc93e73384c4d6d6c9fc6f58598eba61
|
Subproject commit d64d15cf272a7235cca7e727faadf775ceef5278
|
|
@ -526,34 +526,44 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
let wine = self.selected_wine.clone().unwrap();
|
let wine = self.selected_wine.clone().unwrap();
|
||||||
let dxvk = self.selected_dxvk.clone().unwrap();
|
let dxvk = self.selected_dxvk.clone().unwrap();
|
||||||
|
|
||||||
let wine = wine
|
let group = wine.find_group(&config.components.path).unwrap().unwrap();
|
||||||
.to_wine(Some(config.game.wine.builds.join(&wine.name)))
|
|
||||||
.with_loader(WineLoader::Current)
|
|
||||||
.with_arch(WineArch::Win64)
|
|
||||||
.with_prefix(config.game.wine.prefix);
|
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
// Apply DXVK if we need it
|
||||||
let params = InstallParams {
|
if group.features.need_dxvk {
|
||||||
// We just created prefix so don't need to repair it
|
let wine = wine
|
||||||
repair_dlls: false,
|
.to_wine(Some(config.game.wine.builds.join(&wine.name)))
|
||||||
|
.with_loader(WineLoader::Current)
|
||||||
|
.with_arch(WineArch::Win64)
|
||||||
|
.with_prefix(config.game.wine.prefix);
|
||||||
|
|
||||||
..InstallParams::default()
|
std::thread::spawn(move || {
|
||||||
};
|
let params = InstallParams {
|
||||||
|
// We just created prefix so don't need to repair it
|
||||||
|
repair_dlls: false,
|
||||||
|
|
||||||
match wine.install_dxvk(config.game.dxvk.builds.join(&dxvk.name), params) {
|
..InstallParams::default()
|
||||||
// Go to next page
|
};
|
||||||
Ok(_) => sender.input(DownloadComponentsAppMsg::Continue),
|
|
||||||
|
|
||||||
Err(err) => {
|
match wine.install_dxvk(config.game.dxvk.builds.join(&dxvk.name), params) {
|
||||||
tracing::error!("Failed to apply DXVK: {err}");
|
// Go to next page
|
||||||
|
Ok(_) => sender.input(DownloadComponentsAppMsg::Continue),
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
Err(err) => {
|
||||||
title: tr("dxvk-apply-error"),
|
tracing::error!("Failed to apply DXVK: {err}");
|
||||||
description: Some(err.to_string())
|
|
||||||
});
|
sender.output(Self::Output::Toast {
|
||||||
|
title: tr("dxvk-apply-error"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Skip DXVK applying if we don't need it
|
||||||
|
else {
|
||||||
|
sender.input(DownloadComponentsAppMsg::Continue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_must_use)]
|
#[allow(unused_must_use)]
|
||||||
|
|
|
@ -1173,7 +1173,7 @@ impl SimpleComponent for App {
|
||||||
LauncherState::PrefixNotExists => {
|
LauncherState::PrefixNotExists => {
|
||||||
let config = config::get().unwrap();
|
let config = config::get().unwrap();
|
||||||
|
|
||||||
match config.try_get_selected_wine_info() {
|
match config.get_selected_wine() {
|
||||||
Ok(Some(wine)) => {
|
Ok(Some(wine)) => {
|
||||||
sender.input(AppMsg::DisableButtons(true));
|
sender.input(AppMsg::DisableButtons(true));
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,9 @@ pub struct GeneralApp {
|
||||||
|
|
||||||
languages: Vec<String>,
|
languages: Vec<String>,
|
||||||
|
|
||||||
downloaded_wine_versions: Vec<wine::Version>,
|
downloaded_wine_versions: Vec<(wine::Version, wine::Features)>,
|
||||||
downloaded_dxvk_versions: Vec<dxvk::Version>,
|
downloaded_dxvk_versions: Vec<dxvk::Version>,
|
||||||
|
allow_dxvk_selection: bool,
|
||||||
|
|
||||||
selected_wine_version: u32,
|
selected_wine_version: u32,
|
||||||
selected_dxvk_version: u32,
|
selected_dxvk_version: u32,
|
||||||
|
@ -434,7 +435,7 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
#[block_signal(wine_selected_notify)]
|
#[block_signal(wine_selected_notify)]
|
||||||
set_model: Some(>k::StringList::new(&model.downloaded_wine_versions.iter().map(|version| version.title.as_str()).collect::<Vec<&str>>())),
|
set_model: Some(>k::StringList::new(&model.downloaded_wine_versions.iter().map(|(version, _)| version.title.as_str()).collect::<Vec<&str>>())),
|
||||||
|
|
||||||
#[watch]
|
#[watch]
|
||||||
#[block_signal(wine_selected_notify)]
|
#[block_signal(wine_selected_notify)]
|
||||||
|
@ -483,6 +484,16 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
add = &adw::PreferencesGroup {
|
add = &adw::PreferencesGroup {
|
||||||
set_title: &tr("dxvk-version"),
|
set_title: &tr("dxvk-version"),
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_description: if !model.allow_dxvk_selection {
|
||||||
|
Some("DXVK selection is disabled by your wine group preferences")
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: model.allow_dxvk_selection,
|
||||||
|
|
||||||
adw::ComboRow {
|
adw::ComboRow {
|
||||||
set_title: &tr("selected-version"),
|
set_title: &tr("selected-version"),
|
||||||
|
|
||||||
|
@ -531,6 +542,9 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
},
|
},
|
||||||
|
|
||||||
add = &adw::PreferencesGroup {
|
add = &adw::PreferencesGroup {
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: model.allow_dxvk_selection,
|
||||||
|
|
||||||
add = model.dxvk_components.widget(),
|
add = model.dxvk_components.widget(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -608,6 +622,15 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
downloaded_wine_versions: vec![],
|
downloaded_wine_versions: vec![],
|
||||||
downloaded_dxvk_versions: vec![],
|
downloaded_dxvk_versions: vec![],
|
||||||
|
|
||||||
|
allow_dxvk_selection: match &CONFIG.game.wine.selected {
|
||||||
|
Some(version) => match wine::Group::find_in(&CONFIG.components.path, version) {
|
||||||
|
Ok(Some(group)) => group.features.need_dxvk,
|
||||||
|
_ => true
|
||||||
|
}
|
||||||
|
|
||||||
|
None => true
|
||||||
|
},
|
||||||
|
|
||||||
selected_wine_version: 0,
|
selected_wine_version: 0,
|
||||||
selected_dxvk_version: 0,
|
selected_dxvk_version: 0,
|
||||||
|
|
||||||
|
@ -739,19 +762,23 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralAppMsg::UpdateDownloadedWine => {
|
GeneralAppMsg::UpdateDownloadedWine => {
|
||||||
self.downloaded_wine_versions = wine::get_downloaded(&CONFIG.components.path, &CONFIG.game.wine.builds).unwrap_or_default();
|
self.downloaded_wine_versions = wine::get_downloaded(&CONFIG.components.path, &CONFIG.game.wine.builds)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(|group| group.versions.into_iter().map(move |version| (version, group.features.clone())))
|
||||||
|
.collect();
|
||||||
|
|
||||||
self.selected_wine_version = if let Some(selected) = &CONFIG.game.wine.selected {
|
self.selected_wine_version = if let Some(selected) = &CONFIG.game.wine.selected {
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
|
|
||||||
for (i, version) in self.downloaded_wine_versions.iter().enumerate() {
|
for (i, (version, _)) in self.downloaded_wine_versions.iter().enumerate() {
|
||||||
if &version.name == selected {
|
if &version.name == selected {
|
||||||
index = i;
|
index = i;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index as u32
|
index as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,9 +788,13 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralAppMsg::UpdateDownloadedDxvk => {
|
GeneralAppMsg::UpdateDownloadedDxvk => {
|
||||||
self.downloaded_dxvk_versions = dxvk::get_downloaded(&CONFIG.components.path, &CONFIG.game.dxvk.builds).unwrap_or_default();
|
self.downloaded_dxvk_versions = dxvk::get_downloaded(&CONFIG.components.path, &CONFIG.game.dxvk.builds)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(|group| group.versions)
|
||||||
|
.collect();
|
||||||
|
|
||||||
self.selected_dxvk_version = if let Ok(Some(selected)) = CONFIG.try_get_selected_dxvk_info() {
|
self.selected_dxvk_version = if let Ok(Some(selected)) = CONFIG.get_selected_dxvk() {
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
|
|
||||||
for (i, version) in self.downloaded_dxvk_versions.iter().enumerate() {
|
for (i, version) in self.downloaded_dxvk_versions.iter().enumerate() {
|
||||||
|
@ -784,9 +815,10 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
|
|
||||||
GeneralAppMsg::SelectWine(index) => {
|
GeneralAppMsg::SelectWine(index) => {
|
||||||
if let Ok(mut config) = config::get() {
|
if let Ok(mut config) = config::get() {
|
||||||
if let Some(version) = self.downloaded_wine_versions.get(index) {
|
if let Some((version, features)) = self.downloaded_wine_versions.get(index) {
|
||||||
if config.game.wine.selected.as_ref().unwrap_or(&String::new()) != &version.title {
|
if config.game.wine.selected.as_ref() != Some(&version.title) {
|
||||||
self.selecting_wine_version = true;
|
self.selecting_wine_version = true;
|
||||||
|
self.allow_dxvk_selection = features.need_dxvk;
|
||||||
|
|
||||||
let wine = version.to_wine(Some(config.game.wine.builds.join(&version.name)));
|
let wine = version.to_wine(Some(config.game.wine.builds.join(&version.name)));
|
||||||
let wine_name = version.name.to_string();
|
let wine_name = version.name.to_string();
|
||||||
|
@ -822,11 +854,11 @@ impl SimpleAsyncComponent for GeneralApp {
|
||||||
GeneralAppMsg::SelectDxvk(index) => {
|
GeneralAppMsg::SelectDxvk(index) => {
|
||||||
if let Ok(config) = config::get() {
|
if let Ok(config) = config::get() {
|
||||||
if let Some(version) = self.downloaded_dxvk_versions.get(index) {
|
if let Some(version) = self.downloaded_dxvk_versions.get(index) {
|
||||||
if let Ok(selected) = config.try_get_selected_dxvk_info() {
|
if let Ok(selected) = config.get_selected_dxvk() {
|
||||||
if selected.is_none() || selected.unwrap().name != version.name {
|
if selected.is_none() || selected.unwrap().name != version.name {
|
||||||
self.selecting_dxvk_version = true;
|
self.selecting_dxvk_version = true;
|
||||||
|
|
||||||
let mut wine = match config.try_get_selected_wine_info() {
|
let mut wine = match config.get_selected_wine() {
|
||||||
Ok(Some(version)) => version.to_wine(Some(config.game.wine.builds.join(&version.name))),
|
Ok(Some(version)) => version.to_wine(Some(config.game.wine.builds.join(&version.name))),
|
||||||
_ => Wine::default()
|
_ => Wine::default()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue