mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 14:38:29 +03:00
Initial setup changes
- renamed "page_*" to some actual pages names - added voice packages selection page - made "Advanced" button working. It shows default paths selection page
This commit is contained in:
parent
116b31fbdb
commit
82691f70f9
16 changed files with 235 additions and 81 deletions
|
@ -9,12 +9,13 @@
|
|||
<file preprocess="xml-stripblanks" compressed="true" alias="preferences.ui">ui/.dist/preferences.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/app/ui/first_run">
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_1.ui">ui/.dist/first_run/page_1.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_2.ui">ui/.dist/first_run/page_2.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_3.ui">ui/.dist/first_run/page_3.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_4.ui">ui/.dist/first_run/page_4.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_5.ui">ui/.dist/first_run/page_5.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="page_6.ui">ui/.dist/first_run/page_6.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="welcome.ui">ui/.dist/first_run/welcome.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="dependencies.ui">ui/.dist/first_run/dependencies.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="tos_warning.ui">ui/.dist/first_run/tos_warning.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="default_paths.ui">ui/.dist/first_run/default_paths.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="voice_packages.ui">ui/.dist/first_run/voice_packages.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="download_components.ui">ui/.dist/first_run/download_components.ui</file>
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="finish.ui">ui/.dist/first_run/finish.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/app/ui/preferences">
|
||||
<file preprocess="xml-stripblanks" compressed="true" alias="general.ui">ui/.dist/preferences/general.ui</file>
|
||||
|
|
44
assets/ui/first_run/voice_packages.blp
Normal file
44
assets/ui/first_run/voice_packages.blp
Normal file
|
@ -0,0 +1,44 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
Gtk.Box page {
|
||||
orientation: vertical;
|
||||
hexpand: true;
|
||||
|
||||
Adw.PreferencesPage {
|
||||
Adw.PreferencesGroup {
|
||||
Gtk.Label {
|
||||
label: "Select voice packages";
|
||||
margin-top: 16;
|
||||
|
||||
styles ["title-1"]
|
||||
}
|
||||
}
|
||||
|
||||
Adw.PreferencesGroup voice_packages_group {
|
||||
vexpand: true;
|
||||
valign: center;
|
||||
}
|
||||
|
||||
Adw.PreferencesGroup {
|
||||
vexpand: true;
|
||||
valign: center;
|
||||
|
||||
Gtk.Box {
|
||||
orientation: horizontal;
|
||||
spacing: 8;
|
||||
halign: center;
|
||||
|
||||
Gtk.Button continue_button {
|
||||
label: "Continue";
|
||||
|
||||
styles ["suggested-action"]
|
||||
}
|
||||
|
||||
Gtk.Button exit_button {
|
||||
label: "Exit";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,10 +45,9 @@ Gtk.Box page {
|
|||
styles ["suggested-action"]
|
||||
}
|
||||
|
||||
Gtk.Button {
|
||||
Gtk.Button advanced_button {
|
||||
label: "Advanced";
|
||||
sensitive: false;
|
||||
tooltip-text: "Work in progress";
|
||||
tooltip-text: "You can choose default folders paths";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ pub struct Page {
|
|||
|
||||
impl Page {
|
||||
pub fn new(window: gtk::Window) -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_4.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/default_paths.ui");
|
||||
|
||||
let result = Self {
|
||||
window,
|
|
@ -18,7 +18,7 @@ pub struct Page {
|
|||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_2.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/dependencies.ui");
|
||||
|
||||
let result = Self {
|
||||
page: get_object(&builder, "page")?,
|
|
@ -25,7 +25,7 @@ pub struct Page {
|
|||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_5.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/download_components.ui");
|
||||
|
||||
let mut result = Self {
|
||||
page: get_object(&builder, "page")?,
|
|
@ -11,7 +11,7 @@ pub struct Page {
|
|||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_6.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/finish.ui");
|
||||
|
||||
Ok(Self {
|
||||
page: get_object(&builder, "page")?,
|
|
@ -10,12 +10,13 @@ use std::process::Command;
|
|||
|
||||
use anime_game_core::prelude::*;
|
||||
|
||||
mod page_1;
|
||||
mod page_2;
|
||||
mod page_3;
|
||||
mod page_4;
|
||||
mod page_5;
|
||||
mod page_6;
|
||||
mod welcome;
|
||||
mod dependencies;
|
||||
mod tos_warning;
|
||||
mod default_paths;
|
||||
mod voice_packages;
|
||||
mod download_components;
|
||||
mod finish;
|
||||
|
||||
use crate::ui::*;
|
||||
use crate::ui::components::progress_bar::*;
|
||||
|
@ -34,13 +35,13 @@ 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,
|
||||
pub page_4: page_4::Page,
|
||||
pub page_5: page_5::Page,
|
||||
pub page_6: page_6::Page
|
||||
pub welcome: welcome::Page,
|
||||
pub dependencies: dependencies::Page,
|
||||
pub tos_warning: tos_warning::Page,
|
||||
pub default_paths: default_paths::Page,
|
||||
pub voice_packages: voice_packages::Page,
|
||||
pub download_components: download_components::Page,
|
||||
pub finish: finish::Page
|
||||
}
|
||||
|
||||
impl AppWidgets {
|
||||
|
@ -51,21 +52,23 @@ impl AppWidgets {
|
|||
window: get_object(&builder, "window")?,
|
||||
carousel: get_object(&builder, "carousel")?,
|
||||
|
||||
page_1: page_1::Page::new()?,
|
||||
page_2: page_2::Page::new()?,
|
||||
page_3: page_3::Page::new()?,
|
||||
page_4: page_4::Page::new(get_object(&builder, "window")?)?,
|
||||
page_5: page_5::Page::new()?,
|
||||
page_6: page_6::Page::new()?
|
||||
welcome: welcome::Page::new()?,
|
||||
dependencies: dependencies::Page::new()?,
|
||||
tos_warning: tos_warning::Page::new()?,
|
||||
default_paths: default_paths::Page::new(get_object(&builder, "window")?)?,
|
||||
voice_packages: voice_packages::Page::new()?,
|
||||
download_components: download_components::Page::new()?,
|
||||
finish: finish::Page::new()?
|
||||
};
|
||||
|
||||
// Add pages to carousel
|
||||
result.carousel.append(&result.page_1.page);
|
||||
result.carousel.append(&result.page_2.page);
|
||||
result.carousel.append(&result.page_3.page);
|
||||
result.carousel.append(&result.page_4.page);
|
||||
result.carousel.append(&result.page_5.page);
|
||||
result.carousel.append(&result.page_6.page);
|
||||
result.carousel.append(&result.welcome.page);
|
||||
result.carousel.append(&result.dependencies.page);
|
||||
result.carousel.append(&result.tos_warning.page);
|
||||
result.carousel.append(&result.default_paths.page);
|
||||
result.carousel.append(&result.voice_packages.page);
|
||||
result.carousel.append(&result.download_components.page);
|
||||
result.carousel.append(&result.finish.page);
|
||||
|
||||
// Set devel style to ApplicationWindow if it's debug mode
|
||||
if crate::APP_DEBUG {
|
||||
|
@ -83,12 +86,14 @@ impl AppWidgets {
|
|||
/// Has to implement glib::Downgrade` trait
|
||||
#[derive(Debug, glib::Downgrade)]
|
||||
pub enum Actions {
|
||||
FirstPageContinue,
|
||||
SecondPageCheck,
|
||||
ThirdPageContinue,
|
||||
FourthPageContinue,
|
||||
FifthPageDownload,
|
||||
FifthPageContinue,
|
||||
WelcomeContinue,
|
||||
WelcomeAdvanced,
|
||||
DependenciesContinue,
|
||||
TosWarningContinue,
|
||||
DefaultPathsContinue,
|
||||
VoicePackagesContinue,
|
||||
DownloadComponents,
|
||||
DownloadComponentsContinue,
|
||||
Restart,
|
||||
Exit
|
||||
}
|
||||
|
@ -115,7 +120,8 @@ impl Actions {
|
|||
#[derive(Clone)]
|
||||
pub struct App {
|
||||
widgets: AppWidgets,
|
||||
actions: Rc<Cell<Option<glib::Sender<Actions>>>>
|
||||
actions: Rc<Cell<Option<glib::Sender<Actions>>>>,
|
||||
advanced: Rc<Cell<bool>>
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
@ -124,7 +130,8 @@ impl App {
|
|||
// Get default widgets from ui file and add events to them
|
||||
let result = Self {
|
||||
widgets: AppWidgets::try_get()?,
|
||||
actions: Default::default()
|
||||
actions: Default::default(),
|
||||
advanced: Default::default()
|
||||
}.init_events().init_actions();
|
||||
|
||||
// Bind app to the window
|
||||
|
@ -135,20 +142,23 @@ impl App {
|
|||
|
||||
/// Add default events and values to the widgets
|
||||
fn init_events(self) -> Self {
|
||||
self.widgets.page_1.continue_button.connect_clicked(Actions::FirstPageContinue.into_fn(&self));
|
||||
self.widgets.page_3.continue_button.connect_clicked(Actions::ThirdPageContinue.into_fn(&self));
|
||||
self.widgets.page_4.continue_button.connect_clicked(Actions::FourthPageContinue.into_fn(&self));
|
||||
self.widgets.welcome.continue_button.connect_clicked(Actions::WelcomeContinue.into_fn(&self));
|
||||
self.widgets.tos_warning.continue_button.connect_clicked(Actions::TosWarningContinue.into_fn(&self));
|
||||
self.widgets.default_paths.continue_button.connect_clicked(Actions::DefaultPathsContinue.into_fn(&self));
|
||||
self.widgets.dependencies.check_button.connect_clicked(Actions::DependenciesContinue.into_fn(&self));
|
||||
self.widgets.voice_packages.continue_button.connect_clicked(Actions::VoicePackagesContinue.into_fn(&self));
|
||||
|
||||
self.widgets.page_2.check_button.connect_clicked(Actions::SecondPageCheck.into_fn(&self));
|
||||
self.widgets.page_5.download_button.connect_clicked(Actions::FifthPageDownload.into_fn(&self));
|
||||
self.widgets.welcome.advanced_button.connect_clicked(Actions::WelcomeAdvanced.into_fn(&self));
|
||||
self.widgets.download_components.download_button.connect_clicked(Actions::DownloadComponents.into_fn(&self));
|
||||
|
||||
self.widgets.page_6.restart_button.connect_clicked(Actions::Restart.into_fn(&self));
|
||||
self.widgets.dependencies.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.tos_warning.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.default_paths.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.voice_packages.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.download_components.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.finish.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
|
||||
self.widgets.page_2.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.page_3.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.page_4.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.page_5.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.page_6.exit_button.connect_clicked(Actions::Exit.into_fn(&self));
|
||||
self.widgets.finish.restart_button.connect_clicked(Actions::Restart.into_fn(&self));
|
||||
|
||||
self
|
||||
}
|
||||
|
@ -166,44 +176,62 @@ impl App {
|
|||
println!("[update] action: {:?}", &action);
|
||||
|
||||
match action {
|
||||
Actions::FirstPageContinue => {
|
||||
Actions::WelcomeContinue => {
|
||||
this.widgets.carousel.scroll_to({
|
||||
if lib::is_available("git") && lib::is_available("xdelta3") {
|
||||
&this.widgets.page_3.page
|
||||
&this.widgets.tos_warning.page
|
||||
} else {
|
||||
&this.widgets.page_2.page
|
||||
&this.widgets.dependencies.page
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
Actions::SecondPageCheck => {
|
||||
Actions::WelcomeAdvanced => {
|
||||
this.advanced.set(true);
|
||||
|
||||
this.update(Actions::WelcomeContinue).unwrap();
|
||||
}
|
||||
|
||||
Actions::DependenciesContinue => {
|
||||
if lib::is_available("git") && lib::is_available("xdelta3") {
|
||||
this.widgets.carousel.scroll_to(&this.widgets.page_3.page, true);
|
||||
this.widgets.carousel.scroll_to(&this.widgets.tos_warning.page, true);
|
||||
}
|
||||
}
|
||||
|
||||
Actions::ThirdPageContinue => {
|
||||
this.widgets.carousel.scroll_to(&this.widgets.page_4.page, true);
|
||||
Actions::TosWarningContinue => {
|
||||
this.widgets.carousel.scroll_to({
|
||||
if this.advanced.get() {
|
||||
&this.widgets.default_paths.page
|
||||
} else {
|
||||
&this.widgets.voice_packages.page
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
Actions::FourthPageContinue => {
|
||||
config::update_raw(this.widgets.page_4.update_config(config::get().unwrap())).unwrap();
|
||||
Actions::DefaultPathsContinue => {
|
||||
config::update_raw(this.widgets.default_paths.update_config(config::get().unwrap())).unwrap();
|
||||
|
||||
this.widgets.carousel.scroll_to(&this.widgets.page_5.page, true);
|
||||
this.widgets.carousel.scroll_to(&this.widgets.voice_packages.page, true);
|
||||
}
|
||||
|
||||
Actions::FifthPageDownload => {
|
||||
this.widgets.page_5.wine_version.set_sensitive(false);
|
||||
this.widgets.page_5.dxvk_version.set_sensitive(false);
|
||||
Actions::VoicePackagesContinue => {
|
||||
config::update_raw(this.widgets.voice_packages.update_config(config::get().unwrap())).unwrap();
|
||||
|
||||
this.widgets.page_5.progress_bar.show();
|
||||
this.widgets.carousel.scroll_to(&this.widgets.download_components.page, true);
|
||||
}
|
||||
|
||||
Actions::DownloadComponents => {
|
||||
this.widgets.download_components.wine_version.set_sensitive(false);
|
||||
this.widgets.download_components.dxvk_version.set_sensitive(false);
|
||||
|
||||
this.widgets.download_components.progress_bar.show();
|
||||
|
||||
let (sender, receiver) = glib::MainContext::channel::<InstallerUpdate>(glib::PRIORITY_DEFAULT);
|
||||
|
||||
let progress_bar = this.widgets.page_5.progress_bar.clone();
|
||||
let progress_bar = this.widgets.download_components.progress_bar.clone();
|
||||
|
||||
let wine_version = this.widgets.page_5.get_wine_version().clone();
|
||||
let dxvk_version = this.widgets.page_5.get_dxvk_version().clone();
|
||||
let wine_version = this.widgets.download_components.get_wine_version().clone();
|
||||
let dxvk_version = this.widgets.download_components.get_dxvk_version().clone();
|
||||
|
||||
let wine_version_copy = wine_version.clone();
|
||||
|
||||
|
@ -276,7 +304,7 @@ impl App {
|
|||
std::fs::remove_file(format!("{}/.first-run", launcher_dir)).unwrap();
|
||||
|
||||
// Show next page
|
||||
this.update(Actions::FifthPageContinue).unwrap();
|
||||
this.update(Actions::DownloadComponentsContinue).unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -287,8 +315,8 @@ impl App {
|
|||
});
|
||||
}
|
||||
|
||||
Actions::FifthPageContinue => {
|
||||
this.widgets.carousel.scroll_to(&this.widgets.page_6.page, true);
|
||||
Actions::DownloadComponentsContinue => {
|
||||
this.widgets.carousel.scroll_to(&this.widgets.finish.page, true);
|
||||
}
|
||||
|
||||
Actions::Restart => {
|
||||
|
|
|
@ -11,7 +11,7 @@ pub struct Page {
|
|||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_3.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/tos_warning.ui");
|
||||
|
||||
Ok(Self {
|
||||
page: get_object(&builder, "page")?,
|
80
src/ui/first_run/voice_packages.rs
Normal file
80
src/ui/first_run/voice_packages.rs
Normal file
|
@ -0,0 +1,80 @@
|
|||
use gtk4 as gtk;
|
||||
use libadwaita::{self as adw, prelude::*};
|
||||
|
||||
use anime_game_core::voice_data::prelude::*;
|
||||
|
||||
use crate::lib::config;
|
||||
use crate::ui::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Page {
|
||||
pub page: gtk::Box,
|
||||
pub voice_packages_group: adw::PreferencesGroup,
|
||||
|
||||
pub continue_button: gtk::Button,
|
||||
pub exit_button: gtk::Button,
|
||||
|
||||
pub voice_packages: Vec<(VoiceLocale, adw::ActionRow, gtk::Switch)>
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/voice_packages.ui");
|
||||
|
||||
let mut result = Self {
|
||||
page: get_object(&builder, "page")?,
|
||||
voice_packages_group: get_object(&builder, "voice_packages_group")?,
|
||||
|
||||
continue_button: get_object(&builder, "continue_button")?,
|
||||
exit_button: get_object(&builder, "exit_button")?,
|
||||
|
||||
voice_packages: Vec::new()
|
||||
};
|
||||
|
||||
let mut packages = Vec::new();
|
||||
|
||||
for package in VoicePackage::list_latest().expect("Failed to list voice packages") {
|
||||
let row = adw::ActionRow::new();
|
||||
let switch = gtk::Switch::new();
|
||||
|
||||
row.set_title(package.locale().to_name());
|
||||
switch.set_valign(gtk::Align::Center);
|
||||
|
||||
row.add_suffix(&switch);
|
||||
|
||||
result.voice_packages_group.add(&row);
|
||||
|
||||
packages.push((package.locale(), row, switch));
|
||||
}
|
||||
|
||||
if let Ok(config) = config::get() {
|
||||
for voice in config.game.voices {
|
||||
if let Some(voice) = VoiceLocale::from_str(voice) {
|
||||
for (locale, _, switcher) in &packages {
|
||||
if voice == *locale {
|
||||
switcher.set_state(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.voice_packages = packages;
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn update_config(&self, mut config: config::Config) -> config::Config {
|
||||
let mut voices = Vec::new();
|
||||
|
||||
for (locale, _, switcher) in &self.voice_packages {
|
||||
if switcher.state() {
|
||||
voices.push(locale.to_code().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
config.game.voices = voices;
|
||||
|
||||
config
|
||||
}
|
||||
}
|
|
@ -5,16 +5,18 @@ use crate::ui::*;
|
|||
#[derive(Clone)]
|
||||
pub struct Page {
|
||||
pub page: gtk::Box,
|
||||
pub continue_button: gtk::Button
|
||||
pub continue_button: gtk::Button,
|
||||
pub advanced_button: gtk::Button
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub fn new() -> Result<Self, String> {
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/page_1.ui");
|
||||
let builder = gtk::Builder::from_resource("/org/app/ui/first_run/welcome.ui");
|
||||
|
||||
Ok(Self {
|
||||
page: get_object(&builder, "page")?,
|
||||
continue_button: get_object(&builder, "continue_button")?
|
||||
continue_button: get_object(&builder, "continue_button")?,
|
||||
advanced_button: get_object(&builder, "advanced_button")?
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue