From 9d5c0cc9ee0620462ee505f32e7e14bf99d4dc8a Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sat, 2 Jul 2022 18:03:32 +0200 Subject: [PATCH] Added game voiceover selection ui --- Cargo.toml | 1 + assets/ui/preferences_general.blp | 41 +++++++++++++++++++++++++++++++ src/main.rs | 5 ++-- src/ui/main.rs | 10 +++----- src/ui/preferences/mod.rs | 2 -- src/ui/toast_error.rs | 4 +-- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 484a3fb..0fefe37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,4 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" dirs = "4.0.0" +# tokio = { version = "1.19.2", features = ["rt", "rt-multi-thread", "macros"]} diff --git a/assets/ui/preferences_general.blp b/assets/ui/preferences_general.blp index 7bfad34..65837b3 100644 --- a/assets/ui/preferences_general.blp +++ b/assets/ui/preferences_general.blp @@ -18,6 +18,47 @@ Adw.PreferencesPage general_page { ] }; } + + Adw.ExpanderRow { + title: "Game voiceovers"; + subtitle: "Select voice packages used in game"; + + Adw.ActionRow { + title: "English"; + + Gtk.Button { + icon-name: "document-save-symbolic"; + valign: center; + } + } + + Adw.ActionRow { + title: "Japanese"; + + Gtk.Button { + icon-name: "user-trash-symbolic"; + valign: center; + } + } + + Adw.ActionRow { + title: "Korean"; + + Gtk.Button { + icon-name: "document-save-symbolic"; + valign: center; + } + } + + Adw.ActionRow { + title: "Chinese"; + + Gtk.Button { + icon-name: "document-save-symbolic"; + valign: center; + } + } + } } Adw.PreferencesGroup { diff --git a/src/main.rs b/src/main.rs index 28857c2..9cb1c28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ pub mod lib; use ui::*; +// #[tokio::main] fn main() { gtk::init().expect("GTK initialization failed"); adw::init(); @@ -23,9 +24,7 @@ fn main() { let app_copy = app.clone(); app.open_preferences.connect_clicked(move |_| { - if let Err(err) = app_copy.open_preferences_page() { - app_copy.toast_error("Failed to open settings page", err); - } + app_copy.open_preferences_page(); }); app.window.show(); diff --git a/src/ui/main.rs b/src/ui/main.rs index 874d22c..dbc8bb4 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -1,8 +1,6 @@ use gtk4::{self as gtk, prelude::*}; use libadwaita::{self as adw, prelude::*}; -use std::io::Error; - use super::get_object; use super::preferences::PreferencesStack; use super::ToastError; @@ -93,12 +91,12 @@ impl App { Ok(result) } - pub fn open_preferences_page(&self) -> Result<(), Error> { - self.preferences_stack.update()?; - + pub fn open_preferences_page(&self) { self.leaflet.set_visible_child_name("preferences_page"); - Ok(()) + if let Err(err) = self.preferences_stack.update() { + self.toast_error("Failed to update preferences", err); + } } pub fn update_state(&self, state: AppState) { diff --git a/src/ui/preferences/mod.rs b/src/ui/preferences/mod.rs index f662500..7ea62cb 100644 --- a/src/ui/preferences/mod.rs +++ b/src/ui/preferences/mod.rs @@ -73,8 +73,6 @@ impl PreferencesStack { self.status_page.set_visible(false); self.flap.set_visible(true); - self.toast_error("Aboba amogus", Error::last_os_error()); - Ok(()) } } diff --git a/src/ui/toast_error.rs b/src/ui/toast_error.rs index 9618c23..a45a07a 100644 --- a/src/ui/toast_error.rs +++ b/src/ui/toast_error.rs @@ -1,8 +1,6 @@ use gtk4::{self as gtk, prelude::*}; use libadwaita::{self as adw, prelude::*}; -use std::io::Error; - use super::add_action; pub trait ToastError { @@ -11,7 +9,7 @@ pub trait ToastError { /// Show toast with `toast` title and `See message` button /// /// This button will show message dialog with error message - fn toast_error(&self, toast: &str, err: Error) { + fn toast_error(&self, toast: &str, err: T) { let toast = adw::Toast::new(toast); toast.set_button_label(Some("See message"));