mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-22 04:46:08 +03:00
0.4.0
- added "Settings" option for main window menu - added working default paths selection in first run window From previous commits: - added subfolders support for blueprint compiler; moved first_run and preferences pages to subfolders - added 2 first run pages: + when you don't have some required components + to select default folders paths
This commit is contained in:
parent
dcf2a7821a
commit
4c5a38dfc2
5 changed files with 48 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "anime-game-launcher"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
description = "Anime Game launcher"
|
||||
authors = ["Nikita Podvirnyy <suimin.tu.mu.ga.mi@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -125,5 +125,6 @@ Gtk.AboutDialog about {
|
|||
|
||||
menu app_menu {
|
||||
item ("Check for updates")
|
||||
item ("Settings", "open-settings.open-settings")
|
||||
item ("About", "show-about-dialog.show-about-dialog")
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ pub struct AppWidgets {
|
|||
pub window: adw::ApplicationWindow,
|
||||
pub carousel: adw::Carousel,
|
||||
|
||||
// TODO: use names instead of numbers
|
||||
pub page_1: page_1::Page,
|
||||
pub page_2: page_2::Page,
|
||||
pub page_3: page_3::Page,
|
||||
|
@ -192,6 +193,8 @@ impl App {
|
|||
}
|
||||
|
||||
Actions::FourthPageContinue => {
|
||||
config::update_raw(this.widgets.page_4.update_config(config::get().unwrap())).unwrap();
|
||||
|
||||
this.widgets.carousel.scroll_to(&this.widgets.page_5.page, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ pub fn choose_dir<T: IsA<gtk::Window>>(current_folder: String, parent: &T) -> Aw
|
|||
|
||||
dialogue.connect_response(move |dialogue, response| {
|
||||
if response == gtk::ResponseType::Accept {
|
||||
sender.send(dialogue.current_folder().unwrap().to_string()).unwrap();
|
||||
sender.send(dialogue.current_folder().unwrap().path().unwrap().to_str().unwrap().to_string()).unwrap();
|
||||
}
|
||||
|
||||
dialogue.close();
|
||||
});
|
||||
|
||||
dialogue.show();
|
||||
|
@ -72,6 +74,7 @@ impl Page {
|
|||
Err(err) => return Err(err.to_string())
|
||||
};
|
||||
|
||||
// Add paths to subtitles
|
||||
result.runners_folder.set_subtitle(&config.game.wine.builds);
|
||||
result.dxvk_folder.set_subtitle(&config.game.dxvk.builds);
|
||||
result.prefix_folder.set_subtitle(&config.game.wine.prefix);
|
||||
|
@ -81,10 +84,41 @@ impl Page {
|
|||
None => String::from("/tmp")
|
||||
});
|
||||
|
||||
result.runners_folder.connect_activated(clone!(@strong result.window as window => move |row| {
|
||||
choose_dir(row.subtitle().unwrap().to_string(), &window);
|
||||
}));
|
||||
// Connect path selection events
|
||||
result.connect_activated(&result.runners_folder);
|
||||
result.connect_activated(&result.dxvk_folder);
|
||||
result.connect_activated(&result.prefix_folder);
|
||||
result.connect_activated(&result.game_folder);
|
||||
result.connect_activated(&result.temp_folder);
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn connect_activated(&self, row: &adw::ActionRow) {
|
||||
row.connect_activated(clone!(@strong self.window as window => move |row| {
|
||||
let (sender, receiver) = glib::MainContext::channel::<String>(glib::PRIORITY_DEFAULT);
|
||||
|
||||
choose_dir(row.subtitle().unwrap().to_string(), &window).then(move |path| {
|
||||
sender.send(path.clone()).unwrap();
|
||||
});
|
||||
|
||||
let row = row.clone();
|
||||
|
||||
receiver.attach(None, move |path| {
|
||||
row.set_subtitle(&path);
|
||||
|
||||
glib::Continue(false)
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
pub fn update_config(&self, mut config: config::Config) -> config::Config {
|
||||
config.game.wine.builds = self.runners_folder.subtitle().unwrap().to_string();
|
||||
config.game.dxvk.builds = self.dxvk_folder.subtitle().unwrap().to_string();
|
||||
config.game.wine.prefix = self.prefix_folder.subtitle().unwrap().to_string();
|
||||
config.game.path = self.game_folder.subtitle().unwrap().to_string();
|
||||
config.launcher.temp = Some(self.temp_folder.subtitle().unwrap().to_string());
|
||||
|
||||
config
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,10 +192,15 @@ impl App {
|
|||
|
||||
/// Add default events and values to the widgets
|
||||
fn init_events(self) -> Self {
|
||||
// Add menu actions
|
||||
add_action(&self.widgets.menu, "show-about-dialog", clone!(@strong self.widgets.about as about => move || {
|
||||
about.show();
|
||||
}));
|
||||
|
||||
add_action(&self.widgets.menu, "open-settings", clone!(@strong self as this => move || {
|
||||
this.update(Actions::OpenPreferencesPage).unwrap();
|
||||
}));
|
||||
|
||||
// Open preferences page
|
||||
self.widgets.open_preferences.connect_clicked(Actions::OpenPreferencesPage.into_fn(&self));
|
||||
|
||||
|
|
Loading…
Reference in a new issue