feat(ui): added initial installation migration window support

This commit is contained in:
Observer KRypt0n_ 2023-03-29 18:45:31 +02:00
parent 5a4eeb5636
commit 7e20abf991
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
6 changed files with 101 additions and 5 deletions

View file

@ -19,6 +19,8 @@ glib-build-tools = "0.17"
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "0.5.7"
# path = "../anime-launcher-sdk" # ! for dev purposes only
[dependencies]
relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] }
gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] }

View file

@ -17,7 +17,7 @@ use super::select_voiceovers::*;
use super::download_components::*;
use super::finish::*;
pub static mut MAIN_WINDOW: Option<adw::Window> = None;
pub static mut MAIN_WINDOW: Option<adw::ApplicationWindow> = None;
// TODO: add special page for launcher style selection
@ -61,7 +61,7 @@ impl SimpleComponent for FirstRunApp {
type Output = ();
view! {
window = adw::Window {
window = adw::ApplicationWindow {
set_default_size: (780, 560),
#[watch]

View file

@ -38,9 +38,9 @@ relm4::new_stateless_action!(WishUrl, WindowActionGroup, "wish_url");
relm4::new_stateless_action!(About, WindowActionGroup, "about");
static mut MAIN_WINDOW: Option<adw::ApplicationWindow> = None;
static mut PREFERENCES_WINDOW: Option<AsyncController<PreferencesApp>> = None;
static mut ABOUT_DIALOG: Option<Controller<AboutDialog>> = None;
pub static mut MAIN_WINDOW: Option<adw::ApplicationWindow> = None;
pub static mut PREFERENCES_WINDOW: Option<AsyncController<PreferencesApp>> = None;
pub static mut ABOUT_DIALOG: Option<Controller<AboutDialog>> = None;
pub struct App {
progress_bar: AsyncController<ProgressBar>,

View file

@ -0,0 +1,71 @@
use relm4::prelude::*;
use relm4::component::*;
use gtk::prelude::*;
use adw::prelude::*;
use crate::*;
use super::first_run::default_paths::DefaultPathsApp;
pub struct MigrateInstallationApp {
default_paths: AsyncController<DefaultPathsApp>,
}
#[derive(Debug)]
pub enum MigrateInstallationAppMsg {
Migrate
}
#[relm4::component(pub)]
impl SimpleComponent for MigrateInstallationApp {
type Init = ();
type Input = MigrateInstallationAppMsg;
type Output = ();
view! {
adw::Window {
set_default_size: (780, 560),
set_modal: true,
#[watch]
set_title: Some("Migrate installation"),
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
adw::HeaderBar {
add_css_class: "flat"
},
append = model.default_paths.widget(),
}
}
}
fn init(
_init: Self::Init,
root: &Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
tracing::info!("Initializing migration window");
let model = Self {
default_paths: DefaultPathsApp::builder()
.launch(())
.detach()
};
let widgets = view_output!();
ComponentParts { model, widgets }
}
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
match msg {
MigrateInstallationAppMsg::Migrate => {
todo!()
}
}
}
}

View file

@ -3,3 +3,4 @@ pub mod about;
pub mod preferences;
pub mod components;
pub mod first_run;
pub mod migrate_installation;

View file

@ -17,6 +17,7 @@ use anime_launcher_sdk::components::wine::WincompatlibWine;
use anime_launcher_sdk::wincompatlib::prelude::*;
use super::main::PreferencesAppMsg;
use crate::ui::migrate_installation::MigrateInstallationApp;
use crate::ui::components;
use crate::ui::components::*;
use crate::i18n::*;
@ -102,6 +103,7 @@ impl AsyncFactoryComponent for VoicePackageComponent {
pub struct GeneralApp {
voice_packages: AsyncFactoryVecDeque<VoicePackageComponent>,
migrate_installation: Controller<MigrateInstallationApp>,
wine_components: AsyncController<ComponentsList<GeneralAppMsg>>,
dxvk_components: AsyncController<ComponentsList<GeneralAppMsg>>,
@ -145,6 +147,7 @@ pub enum GeneralAppMsg {
RemoveVoicePackage(DynamicIndex),
SetVoicePackageSensitivity(DynamicIndex, bool),
OpenMigrateInstallation,
RepairGame,
UpdateLauncherStyle(LauncherStyle),
@ -307,6 +310,13 @@ impl SimpleAsyncComponent for GeneralApp {
set_spacing: 8,
set_margin_top: 16,
gtk::Button {
set_label: "Migrate installation",
set_tooltip_text: Some("Open special window where you can change your game installation folder"),
connect_clicked => GeneralAppMsg::OpenMigrateInstallation
},
gtk::Button {
set_label: &tr("repair-game"),
@ -674,6 +684,10 @@ impl SimpleAsyncComponent for GeneralApp {
let mut model = Self {
voice_packages: AsyncFactoryVecDeque::new(adw::ExpanderRow::new(), sender.input_sender()),
migrate_installation: MigrateInstallationApp::builder()
.launch(())
.detach(),
wine_components: ComponentsList::builder()
.launch(ComponentsListInit {
pattern: ComponentsListPattern {
@ -839,6 +853,14 @@ impl SimpleAsyncComponent for GeneralApp {
}
}
GeneralAppMsg::OpenMigrateInstallation => unsafe {
if let Some(window) = crate::ui::main::PREFERENCES_WINDOW.as_ref() {
self.migrate_installation.widget().set_transient_for(Some(window.widget()));
}
self.migrate_installation.widget().show();
}
#[allow(unused_must_use)]
GeneralAppMsg::RepairGame => {
sender.output(Self::Output::RepairGame);