mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2026-03-21 21:58:52 +00:00
added some steps
This commit is contained in:
parent
9246d3a36f
commit
72fd11a2ac
@ -26,6 +26,8 @@ use libadwaita::OverlaySplitView;
|
|||||||
|
|
||||||
use crate::APP_RESOURCE_PATH;
|
use crate::APP_RESOURCE_PATH;
|
||||||
|
|
||||||
|
mod pages;
|
||||||
|
|
||||||
pub fn run(app: RelmApp<MainWindowMsg>) {
|
pub fn run(app: RelmApp<MainWindowMsg>) {
|
||||||
app.run_async::<MainWindow>(None);
|
app.run_async::<MainWindow>(None);
|
||||||
}
|
}
|
||||||
@ -39,6 +41,7 @@ pub enum MainWindowMsg {
|
|||||||
|
|
||||||
struct MainWindow {
|
struct MainWindow {
|
||||||
game_state: GameState,
|
game_state: GameState,
|
||||||
|
setup_page: AsyncController<pages::steps::SetupPage>,
|
||||||
game_handler: WorkerController<manager::HandleGameProcess>,
|
game_handler: WorkerController<manager::HandleGameProcess>,
|
||||||
is_game_running: bool,
|
is_game_running: bool,
|
||||||
is_menu_visible: bool,
|
is_menu_visible: bool,
|
||||||
@ -46,13 +49,20 @@ struct MainWindow {
|
|||||||
|
|
||||||
impl MainWindow {
|
impl MainWindow {
|
||||||
fn new(game_state: GameState, sender: &relm4::AsyncComponentSender<Self>) -> Self {
|
fn new(game_state: GameState, sender: &relm4::AsyncComponentSender<Self>) -> Self {
|
||||||
|
let setup_page = pages::steps::SetupPage::builder()
|
||||||
|
.launch(game_state.clone())
|
||||||
|
.forward(sender.input_sender(), identity);
|
||||||
|
|
||||||
|
let game_handler = manager::HandleGameProcess::builder()
|
||||||
|
.detach_worker(())
|
||||||
|
.forward(sender.input_sender(), identity);
|
||||||
|
|
||||||
MainWindow {
|
MainWindow {
|
||||||
game_state,
|
game_state,
|
||||||
|
setup_page,
|
||||||
|
game_handler,
|
||||||
is_menu_visible: false,
|
is_menu_visible: false,
|
||||||
is_game_running: false,
|
is_game_running: false,
|
||||||
game_handler: manager::HandleGameProcess::builder()
|
|
||||||
.detach_worker(())
|
|
||||||
.forward(sender.input_sender(), identity),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,6 +78,8 @@ impl SimpleAsyncComponent for MainWindow {
|
|||||||
view! {
|
view! {
|
||||||
#[root]
|
#[root]
|
||||||
adw::ApplicationWindow {
|
adw::ApplicationWindow {
|
||||||
|
set_default_size: (700, 560),
|
||||||
|
|
||||||
add_css_class?: IS_DEVEL.then_some("devel"),
|
add_css_class?: IS_DEVEL.then_some("devel"),
|
||||||
|
|
||||||
gtk::Box {
|
gtk::Box {
|
||||||
@ -85,6 +97,10 @@ impl SimpleAsyncComponent for MainWindow {
|
|||||||
adw::HeaderBar {
|
adw::HeaderBar {
|
||||||
pack_start = >k::Button {
|
pack_start = >k::Button {
|
||||||
set_icon_name: "open-menu-symbolic",
|
set_icon_name: "open-menu-symbolic",
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameInstalled,
|
||||||
|
|
||||||
connect_clicked => MainWindowMsg::ToggleMenuVisibility,
|
connect_clicked => MainWindowMsg::ToggleMenuVisibility,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -95,6 +111,9 @@ impl SimpleAsyncComponent for MainWindow {
|
|||||||
set_margin_horizontal: 50,
|
set_margin_horizontal: 50,
|
||||||
set_valign: gtk::Align::Center,
|
set_valign: gtk::Align::Center,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameInstalled,
|
||||||
|
|
||||||
adw::PreferencesPage {
|
adw::PreferencesPage {
|
||||||
add = &adw::PreferencesGroup {
|
add = &adw::PreferencesGroup {
|
||||||
gtk::Picture {
|
gtk::Picture {
|
||||||
@ -128,6 +147,14 @@ impl SimpleAsyncComponent for MainWindow {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
set_visible: model.game_state != GameState::GameInstalled,
|
||||||
|
|
||||||
|
model.setup_page.widget(),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
#[wrap(Some)]
|
#[wrap(Some)]
|
||||||
@ -168,19 +195,6 @@ impl SimpleAsyncComponent for MainWindow {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
//adw::Flap {
|
|
||||||
// #[watch]
|
|
||||||
// set_reveal_flap: model.is_menu_visible,
|
|
||||||
// set_margin_all: 0,
|
|
||||||
// set_fold_policy: adw::FlapFoldPolicy::Auto,
|
|
||||||
|
|
||||||
// #[wrap(Some)]
|
|
||||||
// set_flap =
|
|
||||||
|
|
||||||
// #[wrap(Some)]
|
|
||||||
// set_content =
|
|
||||||
//},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
babylonia-terminal-gui/src/ui/pages/mod.rs
Normal file
1
babylonia-terminal-gui/src/ui/pages/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod steps;
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
use libadwaita::prelude::{ButtonExt, PreferencesPageExt, PreferencesRowExt, WidgetExt};
|
||||||
|
use relm4::prelude::{AsyncComponentParts, SimpleAsyncComponent};
|
||||||
|
use relm4::{adw, gtk, AsyncComponentSender, RelmWidgetExt};
|
||||||
|
|
||||||
|
use crate::ui::MainWindowMsg;
|
||||||
|
|
||||||
|
use super::SetupPageMsg;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum DownloadComponentsMsg {
|
||||||
|
Next,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DownloadComponentsPage;
|
||||||
|
|
||||||
|
#[relm4::component(async, pub)]
|
||||||
|
impl SimpleAsyncComponent for DownloadComponentsPage {
|
||||||
|
type Input = DownloadComponentsMsg;
|
||||||
|
|
||||||
|
type Output = SetupPageMsg;
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_hexpand: true,
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Install components",
|
||||||
|
add_css_class: "title-1"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
adw::ComboRow {
|
||||||
|
set_title: "Proton version",
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::ComboRow {
|
||||||
|
set_title: "DXVK version",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_margin_vertical: 48,
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Next",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
connect_clicked => DownloadComponentsMsg::Next,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
init: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: AsyncComponentSender<Self>,
|
||||||
|
) -> AsyncComponentParts<Self> {
|
||||||
|
let model = DownloadComponentsPage;
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { widgets, model }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, sender: AsyncComponentSender<Self>) -> () {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
}
|
||||||
111
babylonia-terminal-gui/src/ui/pages/steps/mod.rs
Normal file
111
babylonia-terminal-gui/src/ui/pages/steps/mod.rs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
use std::convert::identity;
|
||||||
|
|
||||||
|
use babylonia_terminal_sdk::game_state::GameState;
|
||||||
|
use download_components::DownloadComponentsPage;
|
||||||
|
use libadwaita::prelude::{OrientableExt, WidgetExt};
|
||||||
|
use relm4::{
|
||||||
|
prelude::{
|
||||||
|
adw, gtk, AsyncComponent, AsyncComponentController, AsyncComponentParts, AsyncController,
|
||||||
|
SimpleAsyncComponent,
|
||||||
|
},
|
||||||
|
AsyncComponentSender, Component, ComponentController, Controller,
|
||||||
|
};
|
||||||
|
use welcome::WelcomePage;
|
||||||
|
|
||||||
|
use crate::ui::MainWindowMsg;
|
||||||
|
|
||||||
|
mod download_components;
|
||||||
|
mod welcome;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SetupPageMsg {
|
||||||
|
UpdateGameState,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SetupPage {
|
||||||
|
game_state: GameState,
|
||||||
|
welcome_page: Controller<welcome::WelcomePage>,
|
||||||
|
download_components_page: AsyncController<download_components::DownloadComponentsPage>,
|
||||||
|
|
||||||
|
carousel: adw::Carousel,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(async, pub)]
|
||||||
|
impl SimpleAsyncComponent for SetupPage {
|
||||||
|
type Input = SetupPageMsg;
|
||||||
|
|
||||||
|
type Output = MainWindowMsg;
|
||||||
|
|
||||||
|
type Init = GameState;
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
#[local_ref]
|
||||||
|
carousel -> adw::Carousel {
|
||||||
|
set_allow_mouse_drag: false,
|
||||||
|
set_allow_long_swipes: false,
|
||||||
|
set_allow_scroll_wheel: false,
|
||||||
|
|
||||||
|
append = model.welcome_page.widget(),
|
||||||
|
append = model.download_components_page.widget(),
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::CarouselIndicatorDots {
|
||||||
|
set_carousel: Some(&carousel),
|
||||||
|
set_height_request: 32,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
game_state: GameState,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: AsyncComponentSender<Self>,
|
||||||
|
) -> AsyncComponentParts<Self> {
|
||||||
|
let welcome_page = WelcomePage::builder()
|
||||||
|
.launch(())
|
||||||
|
.forward(sender.input_sender(), identity);
|
||||||
|
let download_components_page = DownloadComponentsPage::builder()
|
||||||
|
.launch(())
|
||||||
|
.forward(sender.input_sender(), identity);
|
||||||
|
|
||||||
|
let carousel = adw::Carousel::new();
|
||||||
|
|
||||||
|
carousel.scroll_to(welcome_page.widget(), true);
|
||||||
|
|
||||||
|
let model = SetupPage {
|
||||||
|
welcome_page,
|
||||||
|
download_components_page,
|
||||||
|
game_state,
|
||||||
|
carousel: carousel.clone(),
|
||||||
|
};
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { widgets, model }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
SetupPageMsg::UpdateGameState => {
|
||||||
|
self.game_state = GameState::get_current_state().await.unwrap()
|
||||||
|
} // TODO: delete this unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.game_state {
|
||||||
|
GameState::ProtonNotInstalled => {
|
||||||
|
self.carousel
|
||||||
|
.scroll_to(self.download_components_page.widget(), true);
|
||||||
|
}
|
||||||
|
GameState::DXVKNotInstalled => todo!(),
|
||||||
|
GameState::FontNotInstalled => todo!(),
|
||||||
|
GameState::DependecieNotInstalled => todo!(),
|
||||||
|
GameState::GameNotInstalled => todo!(),
|
||||||
|
GameState::GameNeedUpdate => todo!(),
|
||||||
|
GameState::GameNotPatched => todo!(),
|
||||||
|
GameState::GameInstalled => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
84
babylonia-terminal-gui/src/ui/pages/steps/welcome.rs
Normal file
84
babylonia-terminal-gui/src/ui/pages/steps/welcome.rs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
use libadwaita::prelude::{ButtonExt, PreferencesPageExt, WidgetExt};
|
||||||
|
use relm4::{adw, gtk, ComponentParts, ComponentSender, RelmWidgetExt, SimpleComponent};
|
||||||
|
|
||||||
|
use super::SetupPageMsg;
|
||||||
|
|
||||||
|
use crate::APP_RESOURCE_PATH;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum WelcomePageMsg {
|
||||||
|
Next,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WelcomePage;
|
||||||
|
|
||||||
|
#[relm4::component(pub)]
|
||||||
|
impl SimpleComponent for WelcomePage {
|
||||||
|
type Input = WelcomePageMsg;
|
||||||
|
|
||||||
|
type Output = SetupPageMsg;
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_hexpand: true,
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
gtk::Picture {
|
||||||
|
set_resource: Some(&format!("{APP_RESOURCE_PATH}/icons/hicolor/scalable/apps/icon.png")),
|
||||||
|
set_vexpand: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Babylonia Terminal",
|
||||||
|
set_margin_top: 24,
|
||||||
|
add_css_class: "title-1",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "We need to do some setup before to be able to play",
|
||||||
|
|
||||||
|
set_justify: gtk::Justification::Center,
|
||||||
|
set_wrap: true,
|
||||||
|
set_margin_top: 32
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_margin_vertical: 48,
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Next",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
connect_clicked => WelcomePageMsg::Next,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init(
|
||||||
|
init: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: ComponentSender<Self>,
|
||||||
|
) -> ComponentParts<Self> {
|
||||||
|
let model = WelcomePage {};
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
ComponentParts { widgets, model }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
WelcomePageMsg::Next => sender.output(SetupPageMsg::UpdateGameState).unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::{game_config::GameConfig, utils::kuro_prod_api::GameInfo};
|
use crate::{game_config::GameConfig, utils::kuro_prod_api::GameInfo};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum GameState {
|
pub enum GameState {
|
||||||
ProtonNotInstalled,
|
ProtonNotInstalled,
|
||||||
DXVKNotInstalled,
|
DXVKNotInstalled,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user