mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-21 20:36:01 +03:00
fix: fixed initial setup window panic
Before it couldn't get list of available wine/dxvk versions because on first run launcher obviously doesn't have `components` folder and it needs to be synced with one of remotes I've added here status page and heavy tasks system to the first run window as it works now on the main window, and now components are synced there behind status page As well was updated SDK with fixed `Installer::get_filename` method which will fix issue with stuff downloading closes https://github.com/an-anime-team/an-anime-game-launcher/issues/91
This commit is contained in:
parent
7f38c15c76
commit
032ca88a6e
4 changed files with 96 additions and 5 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -31,7 +31,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-game-core"
|
||||
version = "1.3.9"
|
||||
version = "1.3.10"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bzip2",
|
||||
|
@ -76,7 +76,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-launcher-sdk"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
dependencies = [
|
||||
"anime-game-core",
|
||||
"anyhow",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 219d0f7704e18d74a9205163ffbb7d1718291ea4
|
||||
Subproject commit 7bcfdbee8583f046c9df045577bd679ee4eb45c2
|
|
@ -61,6 +61,7 @@ pub struct DownloadComponentsApp {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DownloadComponentsAppMsg {
|
||||
UpdateVersionsLists,
|
||||
DownloadWine,
|
||||
CreatePrefix,
|
||||
DownloadDXVK,
|
||||
|
@ -265,8 +266,8 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
|||
dxvk_combo: adw::ComboRow::new(),
|
||||
|
||||
// FIXME: .filter(|version| version.recommended)
|
||||
wine_versions: wine::get_groups(&CONFIG.components.path).unwrap_or_default()[0].versions.clone().into_iter().collect(),
|
||||
dxvk_versions: dxvk::get_groups(&CONFIG.components.path).unwrap_or_default()[0].versions.clone().into_iter().collect(),
|
||||
wine_versions: vec![],
|
||||
dxvk_versions: vec![],
|
||||
|
||||
downloading_wine: None,
|
||||
creating_prefix: None,
|
||||
|
@ -288,6 +289,11 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
|||
|
||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||
match msg {
|
||||
DownloadComponentsAppMsg::UpdateVersionsLists => {
|
||||
self.wine_versions = wine::get_groups(&CONFIG.components.path).unwrap()[0].versions.clone().into_iter().collect();
|
||||
self.dxvk_versions = dxvk::get_groups(&CONFIG.components.path).unwrap()[0].versions.clone().into_iter().collect();
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
DownloadComponentsAppMsg::DownloadWine => {
|
||||
self.downloading = true;
|
||||
|
|
|
@ -4,7 +4,10 @@ use relm4::component::*;
|
|||
use gtk::prelude::*;
|
||||
use adw::prelude::*;
|
||||
|
||||
use anime_launcher_sdk::components::loader::ComponentsLoader;
|
||||
|
||||
use crate::i18n::tr;
|
||||
use crate::*;
|
||||
|
||||
use super::welcome::*;
|
||||
use super::tos_warning::*;
|
||||
|
@ -30,11 +33,14 @@ pub struct FirstRunApp {
|
|||
toast_overlay: adw::ToastOverlay,
|
||||
carousel: adw::Carousel,
|
||||
|
||||
loading: Option<Option<String>>,
|
||||
title: String
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum FirstRunAppMsg {
|
||||
SetLoadingStatus(Option<Option<String>>),
|
||||
|
||||
ScrollToTosWarning,
|
||||
ScrollToDependencies,
|
||||
ScrollToDefaultPaths,
|
||||
|
@ -70,8 +76,26 @@ impl SimpleComponent for FirstRunApp {
|
|||
add_css_class: "flat"
|
||||
},
|
||||
|
||||
adw::StatusPage {
|
||||
set_title: &tr("loading-data"),
|
||||
set_icon_name: Some(APP_ID),
|
||||
set_vexpand: true,
|
||||
|
||||
#[watch]
|
||||
set_description: match &model.loading {
|
||||
Some(Some(desc)) => Some(desc),
|
||||
Some(None) | None => None
|
||||
},
|
||||
|
||||
#[watch]
|
||||
set_visible: model.loading.is_some()
|
||||
},
|
||||
|
||||
#[local_ref]
|
||||
carousel -> adw::Carousel {
|
||||
#[watch]
|
||||
set_visible: model.loading.is_none(),
|
||||
|
||||
set_allow_mouse_drag: false,
|
||||
|
||||
append = model.welcome.widget(),
|
||||
|
@ -134,6 +158,7 @@ impl SimpleComponent for FirstRunApp {
|
|||
toast_overlay,
|
||||
carousel,
|
||||
|
||||
loading: Some(None),
|
||||
title: tr("welcome")
|
||||
};
|
||||
|
||||
|
@ -148,6 +173,62 @@ impl SimpleComponent for FirstRunApp {
|
|||
|
||||
tracing::info!("First run window initialized");
|
||||
|
||||
let components_sender = model.download_components.sender().clone();
|
||||
|
||||
// Initialize some heavy tasks
|
||||
#[allow(unused_must_use)]
|
||||
std::thread::spawn(move || {
|
||||
tracing::info!("Initializing heavy tasks");
|
||||
|
||||
// Update components index
|
||||
|
||||
sender.input(FirstRunAppMsg::SetLoadingStatus(Some(Some(tr("updating-components-index")))));
|
||||
|
||||
let components = ComponentsLoader::new(&CONFIG.components.path);
|
||||
|
||||
match components.is_sync(&CONFIG.components.servers) {
|
||||
Ok(true) => (),
|
||||
|
||||
Ok(false) => {
|
||||
for host in &CONFIG.components.servers {
|
||||
match components.sync(host) {
|
||||
Ok(true) => break,
|
||||
Ok(false) => continue,
|
||||
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to sync components index");
|
||||
|
||||
sender.input(FirstRunAppMsg::Toast {
|
||||
title: tr("components-index-sync-failed"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(err) => {
|
||||
tracing::error!("Failed to verify that components index synced");
|
||||
|
||||
sender.input(FirstRunAppMsg::Toast {
|
||||
title: tr("components-index-verify-failed"),
|
||||
description: Some(err.to_string())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update versions lists in download components page and hide status page
|
||||
components_sender.send(DownloadComponentsAppMsg::UpdateVersionsLists);
|
||||
sender.input(FirstRunAppMsg::SetLoadingStatus(None));
|
||||
|
||||
// Mark app as loaded
|
||||
unsafe {
|
||||
crate::READY = true;
|
||||
}
|
||||
|
||||
tracing::info!("App is ready");
|
||||
});
|
||||
|
||||
ComponentParts { model, widgets } // will return soon
|
||||
}
|
||||
|
||||
|
@ -155,6 +236,10 @@ impl SimpleComponent for FirstRunApp {
|
|||
tracing::debug!("Called first run window event: {:?}", msg);
|
||||
|
||||
match msg {
|
||||
FirstRunAppMsg::SetLoadingStatus(status) => {
|
||||
self.loading = status;
|
||||
}
|
||||
|
||||
FirstRunAppMsg::ScrollToTosWarning => {
|
||||
self.title = tr("tos-violation-warning");
|
||||
|
||||
|
|
Loading…
Reference in a new issue