mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2025-12-16 17:38:51 +00:00
Compare commits
101 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c34d05ff0 | ||
| 1f55e19924 | |||
| e239c1a3dd | |||
| 0f7fa5ba0d | |||
| 594f871fab | |||
| 0fbed904c6 | |||
| 7d2529588d | |||
| b4358afcec | |||
| ce7a89eeb2 | |||
| 8804bec06c | |||
| 6e1b7ac461 | |||
| 9a643b4866 | |||
|
|
908d4b8aec | ||
| 9059ce0cf1 | |||
| 2d9fac062a | |||
| cde2c99e2d | |||
| c70feada75 | |||
| 80836f32ec | |||
| 1a6bb86cb5 | |||
| ce50bf00e4 | |||
| c84520212c | |||
| f793b18b2c | |||
| 0a60f79daa | |||
| 23acb09ef3 | |||
|
|
fa242c1cca | ||
|
|
846b4291c6 | ||
|
|
baf66a4e13 | ||
|
|
72fd11a2ac | ||
|
|
9246d3a36f | ||
|
|
d2e8f5f818 | ||
|
|
c93454358f | ||
|
|
08364f8624 | ||
|
|
1b34ad7642 | ||
|
|
a2e0b6315f | ||
|
|
85bb1e2c59 | ||
|
|
f6247cee5a | ||
|
|
b1248fdb05 | ||
|
|
dfba16f675 | ||
|
|
f66922d813 | ||
|
|
80ea7ec2cf | ||
|
|
6ea0d7ac12 | ||
|
|
f0c9e4707a | ||
|
|
323ebaaf63 | ||
|
|
adc97cf5bc | ||
|
|
617b21f3ab | ||
|
|
0db2c88f83 | ||
|
|
fb4e47eac7 | ||
|
|
c48c52fb50 | ||
|
|
eeb4fd8f4d | ||
|
|
6af2f55927 | ||
|
|
5894a333dc | ||
|
|
96034a464e | ||
|
|
465f2a199f | ||
|
|
bd9bf517b4 | ||
|
|
10561ba542 | ||
|
|
2a5e7711c5 | ||
|
|
898cffe860 | ||
|
|
aeaef3208c | ||
|
|
43e6476c88 | ||
|
|
fa91430eab | ||
|
|
c69859644c | ||
|
|
1ce2464c41 | ||
|
|
b13f854dc7 | ||
|
|
434e37e3f2 | ||
|
|
4122d9f84f | ||
|
|
fbbc9e2225 | ||
|
|
40f164800a | ||
|
|
e6c5ce058b | ||
|
|
b09b135fa2 | ||
|
|
2d3dea45c3 | ||
|
|
c50d97e2ec | ||
|
|
9f9ecbb7e4 | ||
|
|
530a30eac7 | ||
|
|
2bbcc3e5af | ||
|
|
b0b76354fa | ||
|
|
175d6c6a9b | ||
|
|
bda3226d44 | ||
|
|
f82e98caff | ||
|
|
f9fa00cf05 | ||
|
|
821bec7b30 | ||
|
|
35d96c6c76 | ||
|
|
f048f2b50e | ||
|
|
f2aeef9aa4 | ||
|
|
f3898e6805 | ||
|
|
d7f10a16ff | ||
|
|
5890fce5f4 | ||
|
|
b4d4a6802b | ||
|
|
735ca25e08 | ||
|
|
dcf90310e3 | ||
|
|
5770878390 | ||
|
|
245e042560 | ||
|
|
f87289be54 | ||
|
|
2fe4496040 | ||
|
|
29d8f7dccd | ||
|
|
c7c613c261 | ||
|
|
6ff7766ab1 | ||
|
|
e2b0e14989 | ||
|
|
d68664141d | ||
|
|
fda9a3b1fc | ||
|
|
c6103be68d | ||
|
|
30a00db9f9 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
github: ALEZ-DEV
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,7 +1,5 @@
|
|||||||
set_github_env.sh
|
set_github_env.sh
|
||||||
|
|
||||||
babylonia-terminal-cli/TDData-data.db
|
babylonia-terminal-cli/TDData-data.db
|
||||||
|
|
||||||
babylonia-terminal-cli/backtrace.txt
|
babylonia-terminal-cli/backtrace.txt
|
||||||
|
target
|
||||||
*.lock
|
|
||||||
|
|||||||
4470
Cargo.lock
generated
Normal file
4470
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
members = [
|
||||||
|
"babylonia-terminal",
|
||||||
|
"babylonia-terminal-cli",
|
||||||
|
"babylonia-terminal-gui",
|
||||||
|
"babylonia-terminal-sdk",
|
||||||
|
]
|
||||||
|
|
||||||
|
[workspace.dependencies]
|
||||||
|
downloader = { git = "https://github.com/ALEZ-DEV/downloader" } # version = "0.2.7",
|
||||||
45
README.md
45
README.md
@ -6,36 +6,33 @@
|
|||||||
<h1>Babylonia Terminal</h1>
|
<h1>Babylonia Terminal</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
### This launcher download, install your favorite anime game and it's dependencies for you!
|
| Default | Official animated background |
|
||||||
|
|-|-|
|
||||||
|
|<img src="./docs/Screenshot1.png"/>|<img src="./docs/Screenshot2.png" alt="Screenshot 2"/>|
|
||||||
|
|
||||||
|
### This launcher downloads and installs your favorite anime game and its dependencies for you!
|
||||||
For now, there is only a cli version of the launcher, but a gui one is on my radar, so stay tuned!
|
For now, there is only a cli version of the launcher, but a gui one is on my radar, so stay tuned!
|
||||||
If you have any issue with the launcher, don't hesitate to open an [issue](https://github.com/ALEZ-DEV/Babylonia-terminal/issues)!
|
If you have any issues with the launcher, don't hesitate to open an [issue](https://github.com/ALEZ-DEV/Babylonia-terminal/issues)!
|
||||||
|
|
||||||
## GUI Version
|
|
||||||
|
|
||||||
The GUI version is now usable but not totally stable and lack of some functionnality, but you can try to [compile it](https://github.com/ALEZ-DEV/Babylonia-terminal/tree/master/babylonia_terminal_launcher) (A pre compiled binary will be soon distributed)
|
|
||||||
Be aware this version can have some bugs, don't hesitate to open an [issue](https://github.com/ALEZ-DEV/Babylonia-terminal/issues) if this happen!
|
|
||||||
|
|
||||||
## Requirement
|
|
||||||
|
|
||||||
Please install Rust from the [official website](https://www.rust-lang.org/fr/tools/install)
|
|
||||||
You need [python3](https://www.python.org/downloads/) installed on your system, but all major distro have it installed by default
|
|
||||||
You need Wintricks to be installed to install the fonts and the dependencies for the game, you can install it via your package manager or your store
|
|
||||||
You need Steam to be installed to run the game
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install the cli version of the launcher, just start this command :
|
> [!IMPORTANT]
|
||||||
|
> The Graphical version is in alpha, expect breaking changes and bugs as said [here](https://github.com/ALEZ-DEV/Babylonia-terminal#gui-version)
|
||||||
|
|
||||||
```
|
| CLI version | Graphical version |
|
||||||
cargo install --git https://github.com/ALEZ-DEV/Babylonia-terminal --bin
|
|-|-|
|
||||||
```
|
| [See installation instruction](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki/Installation#installing-cli-version) | [Flatpak](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki/Installation#installing-via-flatpak) |
|
||||||
|
|| [Compile it yourself](https://github.com/ALEZ-DEV/Babylonia-terminal/tree/master/babylonia_terminal_launcher) |
|
||||||
|
|
||||||
and you can just run it by doing :
|
## GUI Version
|
||||||
|
|
||||||
```
|
The GUI version is now usable but not totally stable lacks some functionality, but you can try to [compile it](https://github.com/ALEZ-DEV/Babylonia-terminal/tree/master/babylonia_terminal_launcher) or install it via [Flatpak](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki/Installation#installing-via-flatpak)
|
||||||
babylonia-terminal-cli
|
Be aware this version can have some bugs, don't hesitate to open an [issue](https://github.com/ALEZ-DEV/Babylonia-terminal/issues) if this happen!
|
||||||
```
|
|
||||||
|
|
||||||
## Special thank
|
## CLI Version
|
||||||
|
|
||||||
Thank to [krypt0nn](https://github.com/krypt0nn) to made the [wincompatlib](https://github.com/krypt0nn/wincompatlib) library!
|
To see how to use it, go to the [CLI specific](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki/CLI-Specific) section of the [wiki](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki)
|
||||||
|
|
||||||
|
## Special Thanks
|
||||||
|
|
||||||
|
Thanks to [krypt0nn](https://github.com/krypt0nn) who made the [wincompatlib](https://github.com/krypt0nn/wincompatlib) library!
|
||||||
|
|||||||
@ -1,23 +1,22 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "babylonia-terminal-cli"
|
name = "babylonia-terminal-cli"
|
||||||
version = "0.1.0"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["ALEZ-DEV <raidersfocus@gmail.com>"]
|
authors = ["ALEZ-DEV <raidersfocus@gmail.com>"]
|
||||||
description = "A launcher for a certain anime game "
|
description = "A launcher for a certain anime game on linux"
|
||||||
repository = "https://github.com/ALEZ-DEV/Babylonia-terminal"
|
repository = "https://github.com/ALEZ-DEV/Babylonia-terminal"
|
||||||
license = "LGPL-3.0-or-later"
|
license = "LGPL-3.0-or-later"
|
||||||
keywords = ["launcher", "game"]
|
keywords = ["launcher", "game"]
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "babylonia-terminal-cli"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.83"
|
anyhow = "1.0.83"
|
||||||
babylonia-terminal-sdk = { path = "./../babylonia-terminal-sdk" }
|
babylonia-terminal-sdk = { path = "./../babylonia-terminal-sdk" }
|
||||||
|
clap = { version = "4.5.7", features = ["derive"] }
|
||||||
|
derive = "1.0.0"
|
||||||
dialoguer = "0.11.0"
|
dialoguer = "0.11.0"
|
||||||
downloader = { git = "https://github.com/ALEZ-DEV/downloader" } # version = "0.2.7",
|
downloader = { workspace = true }
|
||||||
indicatif = "0.17.8"
|
indicatif = "0.17.8"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
simple_logger = "4.3.3"
|
simple_logger = "4.3.3"
|
||||||
|
|||||||
31
babylonia-terminal-cli/src/arguments.rs
Normal file
31
babylonia-terminal-cli/src/arguments.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
pub struct Args {
|
||||||
|
/// Pass launch options to tinker the behavior of the game, this parameter have priotiy over the
|
||||||
|
/// --set-options param
|
||||||
|
#[arg(long)]
|
||||||
|
pub options: Option<String>,
|
||||||
|
|
||||||
|
/// Set to the config launch options to tinker the behavior of the game, you need to run this
|
||||||
|
/// command one time to set your launch options to the configuration
|
||||||
|
#[arg(long)]
|
||||||
|
pub set_options: Option<String>,
|
||||||
|
|
||||||
|
/// Pass environment variables to tinker the behavior of the game
|
||||||
|
#[arg(long, value_name = "VALUE", action = clap::ArgAction::Append)]
|
||||||
|
pub add_env_var: Vec<String>,
|
||||||
|
|
||||||
|
/// Show the logs direcly to the stdout of your terminal
|
||||||
|
#[arg(long, default_value = "false")]
|
||||||
|
pub logs: bool,
|
||||||
|
|
||||||
|
/// Launch the GUI version
|
||||||
|
#[arg(long, default_value = "false")]
|
||||||
|
pub gui: bool,
|
||||||
|
|
||||||
|
/// Enable debug messages
|
||||||
|
#[arg(long, default_value = "false")]
|
||||||
|
pub debug: bool,
|
||||||
|
}
|
||||||
@ -5,35 +5,22 @@ use babylonia_terminal_sdk::{
|
|||||||
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
||||||
proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
||||||
},
|
},
|
||||||
game_manager::GameManager,
|
game_config::GameConfig,
|
||||||
|
game_manager::{EnvironmentVariable, GameManager},
|
||||||
game_state::GameState,
|
game_state::GameState,
|
||||||
};
|
};
|
||||||
use log::{debug, info, LevelFilter};
|
|
||||||
use simple_logger::SimpleLogger;
|
use log::{debug, info};
|
||||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||||
use wincompatlib::prelude::*;
|
use wincompatlib::prelude::*;
|
||||||
|
|
||||||
pub mod reporter;
|
use crate::{reporter::DownloadReporter, utils};
|
||||||
pub mod utils;
|
|
||||||
|
|
||||||
use crate::reporter::DownloadReporter;
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() {
|
|
||||||
let simple_logger = SimpleLogger::new()
|
|
||||||
.with_module_level("hyper", LevelFilter::Off)
|
|
||||||
.with_module_level("hyper_util", LevelFilter::Off)
|
|
||||||
.with_module_level("tracing", LevelFilter::Off)
|
|
||||||
.with_module_level("rustls", LevelFilter::Off)
|
|
||||||
.with_module_level("minreq", LevelFilter::Off)
|
|
||||||
.with_module_level("tokio_utils", LevelFilter::Off);
|
|
||||||
|
|
||||||
if cfg!(debug_assertions) {
|
|
||||||
simple_logger.init().unwrap();
|
|
||||||
} else {
|
|
||||||
simple_logger.with_level(LevelFilter::Info).init().unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pub async fn run(
|
||||||
|
launch_options: Option<String>,
|
||||||
|
env_vars: Vec<EnvironmentVariable>,
|
||||||
|
show_logs: bool,
|
||||||
|
) {
|
||||||
let mut proton_component: Option<ProtonComponent> = None;
|
let mut proton_component: Option<ProtonComponent> = None;
|
||||||
let mut proton: Option<Proton> = None;
|
let mut proton: Option<Proton> = None;
|
||||||
|
|
||||||
@ -46,7 +33,7 @@ async fn main() {
|
|||||||
let state = state_result.unwrap();
|
let state = state_result.unwrap();
|
||||||
|
|
||||||
if state != GameState::ProtonNotInstalled && proton == None {
|
if state != GameState::ProtonNotInstalled && proton == None {
|
||||||
let proton_component = ProtonComponent::new(GameState::get_config_directory().await);
|
let proton_component = ProtonComponent::new(GameConfig::get_config_directory().await);
|
||||||
match proton_component.init_proton() {
|
match proton_component.init_proton() {
|
||||||
Ok(p) => proton = Some(p),
|
Ok(p) => proton = Some(p),
|
||||||
Err(err) => panic!("{}", err),
|
Err(err) => panic!("{}", err),
|
||||||
@ -71,7 +58,7 @@ async fn main() {
|
|||||||
info!("Proton not installed, installing it...");
|
info!("Proton not installed, installing it...");
|
||||||
proton_component = Some(
|
proton_component = Some(
|
||||||
GameManager::install_wine(
|
GameManager::install_wine(
|
||||||
GameState::get_config_directory().await,
|
GameConfig::get_config_directory().await,
|
||||||
release,
|
release,
|
||||||
Some(DownloadReporter::create(false)),
|
Some(DownloadReporter::create(false)),
|
||||||
)
|
)
|
||||||
@ -100,7 +87,7 @@ async fn main() {
|
|||||||
debug!("{:?}", proton_component);
|
debug!("{:?}", proton_component);
|
||||||
GameManager::install_dxvk(
|
GameManager::install_dxvk(
|
||||||
&proton.clone().unwrap(),
|
&proton.clone().unwrap(),
|
||||||
GameState::get_config_directory().await,
|
GameConfig::get_config_directory().await,
|
||||||
release,
|
release,
|
||||||
Some(DownloadReporter::create(false)),
|
Some(DownloadReporter::create(false)),
|
||||||
)
|
)
|
||||||
@ -124,10 +111,10 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
GameState::GameNotInstalled => {
|
GameState::GameNotInstalled => {
|
||||||
info!("Game not installed, installing it...");
|
info!("Game not installed, installing it...");
|
||||||
if GameState::get_game_dir().await.is_none() {
|
if GameConfig::get_game_dir().await.is_none() {
|
||||||
info!(
|
info!(
|
||||||
"You can choose where to put your game directory, (default '{}')",
|
"You can choose where to put your game directory, (default '{}')",
|
||||||
GameState::get_config_directory().await.to_str().unwrap(),
|
GameConfig::get_config_directory().await.to_str().unwrap(),
|
||||||
);
|
);
|
||||||
info!("Please enter your wanted game directory : ");
|
info!("Please enter your wanted game directory : ");
|
||||||
let mut input = BufReader::new(tokio::io::stdin())
|
let mut input = BufReader::new(tokio::io::stdin())
|
||||||
@ -139,21 +126,21 @@ async fn main() {
|
|||||||
let dir;
|
let dir;
|
||||||
if let Some(i) = &mut input {
|
if let Some(i) = &mut input {
|
||||||
if i.is_empty() {
|
if i.is_empty() {
|
||||||
dir = GameState::get_config_directory().await;
|
dir = GameConfig::get_config_directory().await;
|
||||||
} else {
|
} else {
|
||||||
dir = PathBuf::from_str(i).expect("This is not a valid directory!\n Please restart the launcher and put a valid path.");
|
dir = PathBuf::from_str(i).expect("This is not a valid directory!\n Please restart the launcher and put a valid path.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir = GameState::get_config_directory().await;
|
dir = GameConfig::get_config_directory().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState::set_game_dir(Some(dir)).await.expect(
|
GameConfig::set_game_dir(Some(dir)).await.expect(
|
||||||
"Failed to save the game directory into the config file, please retry!",
|
"Failed to save the game directory into the config file, please retry!",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameManager::install_game(
|
GameManager::install_game(
|
||||||
GameState::get_game_dir().await.unwrap(),
|
GameConfig::get_game_dir().await.unwrap(),
|
||||||
DownloadReporter::create(false),
|
DownloadReporter::create(false),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@ -168,7 +155,7 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
GameState::GameNotPatched => {
|
GameState::GameNotPatched => {
|
||||||
info!("Patching game...");
|
info!("Patching game...");
|
||||||
GameManager::patch_game(GameState::get_game_dir().await.unwrap())
|
GameManager::patch_game(GameConfig::get_game_dir().await.unwrap())
|
||||||
.await
|
.await
|
||||||
.expect("Failed to patch the game");
|
.expect("Failed to patch the game");
|
||||||
info!("Game patched!");
|
info!("Game patched!");
|
||||||
@ -183,9 +170,12 @@ async fn main() {
|
|||||||
debug!("{:?}", proton);
|
debug!("{:?}", proton);
|
||||||
GameManager::start_game(
|
GameManager::start_game(
|
||||||
&proton.unwrap(),
|
&proton.unwrap(),
|
||||||
GameState::get_game_dir()
|
GameConfig::get_game_dir()
|
||||||
.await
|
.await
|
||||||
.expect("Failed to start game, the game directory was not found"),
|
.expect("Failed to start game, the game directory was not found"),
|
||||||
|
launch_options,
|
||||||
|
env_vars,
|
||||||
|
show_logs,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
35
babylonia-terminal-cli/src/lib.rs
Normal file
35
babylonia-terminal-cli/src/lib.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use arguments::Args;
|
||||||
|
use babylonia_terminal_sdk::{game_config::GameConfig, game_manager::EnvironmentVariable};
|
||||||
|
use clap::Parser;
|
||||||
|
use log::debug;
|
||||||
|
|
||||||
|
pub mod arguments;
|
||||||
|
pub mod game;
|
||||||
|
pub mod reporter;
|
||||||
|
pub mod utils;
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
let args = Args::parse();
|
||||||
|
|
||||||
|
debug!("Launch option -> {:?}", args.options);
|
||||||
|
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
if let Some(command) = args.set_options {
|
||||||
|
GameConfig::set_launch_options(Some(command))
|
||||||
|
.await
|
||||||
|
.expect("Failed to save launch options into the config file");
|
||||||
|
}
|
||||||
|
|
||||||
|
let vars = args
|
||||||
|
.add_env_var
|
||||||
|
.iter()
|
||||||
|
.map(|v| EnvironmentVariable::parse(v))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
game::run(args.options, vars, args.logs).await;
|
||||||
|
});
|
||||||
|
}
|
||||||
19
babylonia-terminal-gui/Cargo.toml
Normal file
19
babylonia-terminal-gui/Cargo.toml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[package]
|
||||||
|
name = "babylonia-terminal-gui"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
babylonia-terminal-sdk = { path = "./../babylonia-terminal-sdk" }
|
||||||
|
anyhow = "1.0.94"
|
||||||
|
log = "0.4.22"
|
||||||
|
relm4-components = "0.9.1"
|
||||||
|
wincompatlib = "0.7.5"
|
||||||
|
relm4 = { version = "0.9.1", features = ["libadwaita"] }
|
||||||
|
libadwaita = { version = "0.7.1", features = ["v1_4"] }
|
||||||
|
downloader = { workspace = true }
|
||||||
|
rfd = "0.15.2"
|
||||||
|
arboard = { version = "3.4.1", features = ["wayland-data-control"] }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
glib-build-tools = "0.20.0"
|
||||||
|
Before Width: | Height: | Size: 239 KiB After Width: | Height: | Size: 239 KiB |
7
babylonia-terminal-gui/assets/resources.xml
Normal file
7
babylonia-terminal-gui/assets/resources.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gresources>
|
||||||
|
<gresource prefix="/moe/celica/babylonia-terminal/icons/hicolor/scalable/apps">
|
||||||
|
<file alias="icon.png">icon.png</file>
|
||||||
|
</gresource>
|
||||||
|
</gresources>
|
||||||
5
babylonia-terminal-gui/build.rs
Normal file
5
babylonia-terminal-gui/build.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use glib_build_tools::compile_resources;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
compile_resources(&["assets"], "assets/resources.xml", "resources.gresource");
|
||||||
|
}
|
||||||
54
babylonia-terminal-gui/src/lib.rs
Normal file
54
babylonia-terminal-gui/src/lib.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
use log::debug;
|
||||||
|
use relm4::{
|
||||||
|
gtk::{self, gdk, gio},
|
||||||
|
RelmApp,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod manager;
|
||||||
|
mod ui;
|
||||||
|
|
||||||
|
pub const APP_RESOURCE_PATH: &str = "/moe/celica/babylonia-terminal";
|
||||||
|
pub const IS_DEVEL: bool = cfg!(debug_assertions);
|
||||||
|
|
||||||
|
pub fn run() {
|
||||||
|
debug!("Start GUI!");
|
||||||
|
let app = RelmApp::new("moe.celica.BabyloniaTerminal").with_args(vec![]);
|
||||||
|
|
||||||
|
gio::resources_register_include!("resources.gresource").unwrap();
|
||||||
|
|
||||||
|
let display = gdk::Display::default().unwrap();
|
||||||
|
let theme = gtk::IconTheme::for_display(&display);
|
||||||
|
theme.add_resource_path(&format!("{APP_RESOURCE_PATH}/icons"));
|
||||||
|
|
||||||
|
relm4::set_global_css(&format!(
|
||||||
|
"
|
||||||
|
progressbar > text {{
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}}
|
||||||
|
|
||||||
|
window.classic-style {{
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
}}
|
||||||
|
|
||||||
|
window.classic-style progressbar {{
|
||||||
|
background-color: #00000020;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
}}
|
||||||
|
|
||||||
|
window.classic-style progressbar:hover {{
|
||||||
|
background-color: #00000060;
|
||||||
|
color: #ffffff;
|
||||||
|
transition-duration: 0.5s;
|
||||||
|
transition-timing-function: linear;
|
||||||
|
}}
|
||||||
|
|
||||||
|
.round-bin {{
|
||||||
|
border-radius: 24px;
|
||||||
|
}}
|
||||||
|
"
|
||||||
|
));
|
||||||
|
|
||||||
|
ui::run(app);
|
||||||
|
}
|
||||||
330
babylonia-terminal-gui/src/manager.rs
Normal file
330
babylonia-terminal-gui/src/manager.rs
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
use std::{ops::Deref, sync::Arc};
|
||||||
|
|
||||||
|
use babylonia_terminal_sdk::{
|
||||||
|
components::proton_component::ProtonComponent, game_config::GameConfig,
|
||||||
|
game_manager::GameManager, utils::github_requester::GithubRelease,
|
||||||
|
};
|
||||||
|
use downloader::download;
|
||||||
|
use log::{debug, error};
|
||||||
|
use relm4::{
|
||||||
|
tokio::{self, sync::OnceCell},
|
||||||
|
Worker,
|
||||||
|
};
|
||||||
|
use wincompatlib::prelude::Proton;
|
||||||
|
|
||||||
|
use crate::ui::{
|
||||||
|
self,
|
||||||
|
pages::{
|
||||||
|
self,
|
||||||
|
steps::{
|
||||||
|
self,
|
||||||
|
download_components::{self, DownloadComponentsPageWidgets},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static PROTON: OnceCell<Proton> = OnceCell::const_new();
|
||||||
|
|
||||||
|
pub async fn get_proton() -> anyhow::Result<Proton> {
|
||||||
|
if !PROTON.initialized() {
|
||||||
|
let proton_component = ProtonComponent::new(GameConfig::get_config().await.config_dir);
|
||||||
|
let proton = proton_component.init_proton();
|
||||||
|
|
||||||
|
if let Err(ref e) = proton {
|
||||||
|
error!("Failed to initialize proton : {}", e);
|
||||||
|
anyhow::bail!("Failed to initialize proton : {}", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(PROTON
|
||||||
|
.get_or_init(|| async { proton.unwrap() })
|
||||||
|
.await
|
||||||
|
.clone())
|
||||||
|
} else {
|
||||||
|
Ok(PROTON.get().unwrap().clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn run_game() -> anyhow::Result<()> {
|
||||||
|
let proton = get_proton().await?;
|
||||||
|
let game_dir = GameConfig::get_config().await.game_dir;
|
||||||
|
if game_dir.is_none() {
|
||||||
|
error!("Failed to start game, the game directory was not found");
|
||||||
|
anyhow::bail!("Failed to start game, the game directory was not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
GameManager::start_game(&proton, game_dir.unwrap(), None, vec![], false).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum HandleGameProcessMsg {
|
||||||
|
RunGame,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HandleGameProcess;
|
||||||
|
|
||||||
|
impl Worker for HandleGameProcess {
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
type Input = HandleGameProcessMsg;
|
||||||
|
|
||||||
|
type Output = ui::pages::game::GamePageMsg;
|
||||||
|
|
||||||
|
fn init(_init: Self::Init, _sender: relm4::ComponentSender<Self>) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
HandleGameProcessMsg::RunGame => {
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(true));
|
||||||
|
if let Err(error) = run_game().await {
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Unable to start game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
sender.output(ui::pages::game::GamePageMsg::SetIsGameRunning(false));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum HandleGameInstallationMsg {
|
||||||
|
StartInstallation(Arc<pages::game::ProgressBarGameInstallationReporter>),
|
||||||
|
StartPatch,
|
||||||
|
StartUpdate(Arc<pages::game::ProgressBarGameInstallationReporter>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HandleGameInstallation;
|
||||||
|
|
||||||
|
impl Worker for HandleGameInstallation {
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
type Input = HandleGameInstallationMsg;
|
||||||
|
|
||||||
|
type Output = pages::game::GamePageMsg;
|
||||||
|
|
||||||
|
fn init(init: Self::Init, sender: relm4::ComponentSender<Self>) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
HandleGameInstallationMsg::StartInstallation(progress_bar) => {
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(true));
|
||||||
|
|
||||||
|
let game_dir = if let Some(dir) = GameConfig::get_config().await.game_dir {
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
GameConfig::get_config_directory().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_game(game_dir, progress_bar).await
|
||||||
|
{
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Error while downloading the game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(false));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
HandleGameInstallationMsg::StartPatch => {
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsPatching(true));
|
||||||
|
|
||||||
|
let game_dir = if let Some(dir) = GameConfig::get_config().await.game_dir {
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
GameConfig::get_config_directory().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::patch_game(game_dir).await {
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Error while patching the game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsPatching(false));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
HandleGameInstallationMsg::StartUpdate(progress_bar) => {
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(true));
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::update_game().await {
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Error while updating the game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
let game_dir = if let Some(dir) = GameConfig::get_config().await.game_dir {
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
GameConfig::get_config_directory().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_game(game_dir, progress_bar).await
|
||||||
|
{
|
||||||
|
sender.output(pages::game::GamePageMsg::ShowError(format!(
|
||||||
|
"Error while updating the game : {}",
|
||||||
|
error
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
|
||||||
|
sender.output(pages::game::GamePageMsg::SetIsDownloading(true));
|
||||||
|
sender.output(pages::game::GamePageMsg::UpdateGameState);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum HandleComponentInstallationMsg {
|
||||||
|
StartInstallation(
|
||||||
|
(
|
||||||
|
usize,
|
||||||
|
usize,
|
||||||
|
Arc<download_components::DownloadComponentProgressBarReporter>,
|
||||||
|
),
|
||||||
|
), // proton release and dxvk release
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HandleComponentInstallation;
|
||||||
|
|
||||||
|
impl Worker for HandleComponentInstallation {
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
type Input = HandleComponentInstallationMsg;
|
||||||
|
|
||||||
|
type Output = download_components::DownloadComponentsMsg;
|
||||||
|
|
||||||
|
fn init(_init: Self::Init, _sender: relm4::ComponentSender<Self>) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
HandleComponentInstallationMsg::StartInstallation((
|
||||||
|
proton_release,
|
||||||
|
dxvk_release,
|
||||||
|
progress_bar,
|
||||||
|
)) => {
|
||||||
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.block_on(async {
|
||||||
|
let _ = sender.output(
|
||||||
|
download_components::DownloadComponentsMsg::UpdateProgressBarMsg(
|
||||||
|
String::from("Starting download for proton"),
|
||||||
|
Some(String::from("Unpacking and initializing proton")),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let _ = sender.output(
|
||||||
|
download_components::DownloadComponentsMsg::UpdateCurrentlyInstalling(
|
||||||
|
download_components::CurrentlyInstalling::Proton,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let _ = sender.output(
|
||||||
|
download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(
|
||||||
|
String::from("proton"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
let game_dir = if let Some(dir) = GameConfig::get_config().await.game_dir {
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
GameConfig::get_config_directory().await
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_wine(game_dir.clone(), proton_release, Some(progress_bar.clone())).await {
|
||||||
|
sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install proton : {}", error))).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = sender
|
||||||
|
.output(download_components::DownloadComponentsMsg::UpdateProgressBarMsg(String::from("Starting download for DXVK"), Some(String::from("Installing DXVK"))));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateCurrentlyInstalling(download_components::CurrentlyInstalling::DXVK));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("DXVK")));
|
||||||
|
|
||||||
|
let proton = match get_proton().await {
|
||||||
|
Ok(p) => p,
|
||||||
|
Err(e) => {
|
||||||
|
sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to initialize proton : {:?}", e))).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_dxvk(&proton, game_dir, dxvk_release, Some(progress_bar.clone())).await {
|
||||||
|
sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install DXVK : {}", error))).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = sender
|
||||||
|
.output(download_components::DownloadComponentsMsg::UpdateProgressBarMsg(String::from("Downloading and installing fonts"), Some(String::from("Fonts installed"))));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateCurrentlyInstalling(download_components::CurrentlyInstalling::Fonts));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("fonts")));
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_font(&proton, Some(progress_bar.clone())).await {
|
||||||
|
sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install fonts : {}", error))).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = sender
|
||||||
|
.output(download_components::DownloadComponentsMsg::UpdateProgressBarMsg(String::from("Download and installing denpendecies"), None));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateCurrentlyInstalling(download_components::CurrentlyInstalling::Denpendecies));
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("denpendecies")));
|
||||||
|
|
||||||
|
if let Err(error) = GameManager::install_dependencies(&proton).await {
|
||||||
|
sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install dependencies : {}", error))).unwrap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("Finished to installing the components!");
|
||||||
|
|
||||||
|
let _ = sender.output(download_components::DownloadComponentsMsg::Finish);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
0
babylonia-terminal-gui/src/reporter.rs
Normal file
0
babylonia-terminal-gui/src/reporter.rs
Normal file
281
babylonia-terminal-gui/src/ui/mod.rs
Normal file
281
babylonia-terminal-gui/src/ui/mod.rs
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
use std::convert::identity;
|
||||||
|
|
||||||
|
use crate::{manager, IS_DEVEL};
|
||||||
|
use babylonia_terminal_sdk::game_state::GameState;
|
||||||
|
|
||||||
|
use log::debug;
|
||||||
|
use pages::game::GamePageMsg;
|
||||||
|
use relm4::{
|
||||||
|
self,
|
||||||
|
component::AsyncConnector,
|
||||||
|
gtk::{self, prelude::*, Widget},
|
||||||
|
loading_widgets::LoadingWidgets,
|
||||||
|
once_cell::sync::OnceCell,
|
||||||
|
prelude::*,
|
||||||
|
*,
|
||||||
|
};
|
||||||
|
|
||||||
|
use adw::prelude::*;
|
||||||
|
use libadwaita as adw;
|
||||||
|
|
||||||
|
use crate::APP_RESOURCE_PATH;
|
||||||
|
|
||||||
|
pub mod pages;
|
||||||
|
|
||||||
|
pub static mut MAIN_WINDOW: Option<adw::ApplicationWindow> = None;
|
||||||
|
|
||||||
|
pub fn run(app: RelmApp<MainWindowMsg>) {
|
||||||
|
app.run_async::<MainWindow>(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum MainWindowMsg {
|
||||||
|
ToggleMenuVisibility,
|
||||||
|
SelectPage(Pages),
|
||||||
|
UpdateGameState,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MainWindow {
|
||||||
|
game_state: GameState,
|
||||||
|
setup_page: AsyncController<pages::steps::SetupPage>,
|
||||||
|
game_page: AsyncController<pages::game::GamePage>,
|
||||||
|
settings_page: AsyncConnector<pages::settings::SettingsPage>,
|
||||||
|
about_page: AsyncConnector<pages::about::AboutPage>,
|
||||||
|
current_page: Pages,
|
||||||
|
is_menu_visible: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MainWindow {
|
||||||
|
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_page = pages::game::GamePage::builder()
|
||||||
|
.launch(game_state.clone())
|
||||||
|
.forward(sender.input_sender(), identity);
|
||||||
|
|
||||||
|
let about_page = pages::about::AboutPage::builder().launch(());
|
||||||
|
|
||||||
|
let settings_page = pages::settings::SettingsPage::builder().launch(());
|
||||||
|
|
||||||
|
MainWindow {
|
||||||
|
game_state,
|
||||||
|
setup_page,
|
||||||
|
game_page,
|
||||||
|
settings_page,
|
||||||
|
about_page,
|
||||||
|
current_page: Pages::GamePage,
|
||||||
|
is_menu_visible: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
enum Pages {
|
||||||
|
GamePage,
|
||||||
|
SettingsPage,
|
||||||
|
AboutPage,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(async)]
|
||||||
|
impl SimpleAsyncComponent for MainWindow {
|
||||||
|
type Input = MainWindowMsg;
|
||||||
|
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
type Init = Option<GameState>;
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
main_window = adw::ApplicationWindow {
|
||||||
|
set_default_size: (700, 560),
|
||||||
|
|
||||||
|
add_css_class?: IS_DEVEL.then_some("devel"),
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
adw::OverlaySplitView {
|
||||||
|
#[watch]
|
||||||
|
set_show_sidebar: model.is_menu_visible,
|
||||||
|
set_collapsed: true,
|
||||||
|
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_content = >k::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
adw::HeaderBar {
|
||||||
|
pack_start = >k::Button {
|
||||||
|
set_icon_name: "open-menu-symbolic",
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state.is_environment_ready(),
|
||||||
|
|
||||||
|
connect_clicked => MainWindowMsg::ToggleMenuVisibility,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_vexpand: true,
|
||||||
|
set_margin_horizontal: 50,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state.is_environment_ready(),
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.current_page == Pages::GamePage,
|
||||||
|
|
||||||
|
model.game_page.widget(),
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.current_page == Pages::SettingsPage,
|
||||||
|
|
||||||
|
model.settings_page.widget(),
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.current_page == Pages::AboutPage,
|
||||||
|
|
||||||
|
model.about_page.widget(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: !model.game_state.is_environment_ready(),
|
||||||
|
|
||||||
|
model.setup_page.widget(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
#[wrap(Some)]
|
||||||
|
set_sidebar = >k::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
set_width_request: 250,
|
||||||
|
set_margin_all: 10,
|
||||||
|
|
||||||
|
gtk::Picture {
|
||||||
|
set_resource: Some(&format!("{APP_RESOURCE_PATH}/icons/hicolor/scalable/apps/icon.png")),
|
||||||
|
set_hexpand: true,
|
||||||
|
set_margin_horizontal: 30,
|
||||||
|
set_margin_top: 30,
|
||||||
|
set_margin_bottom: 10,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Babylonia Terminal",
|
||||||
|
set_margin_top: 12,
|
||||||
|
add_css_class: "title-1",
|
||||||
|
set_margin_horizontal: 30,
|
||||||
|
set_margin_bottom: 10,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_margin_vertical: 5,
|
||||||
|
set_label: "Game",
|
||||||
|
|
||||||
|
connect_clicked => MainWindowMsg::SelectPage(Pages::GamePage),
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_margin_vertical: 5,
|
||||||
|
set_label: "Settings",
|
||||||
|
|
||||||
|
connect_clicked => MainWindowMsg::SelectPage(Pages::SettingsPage),
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_margin_vertical: 5,
|
||||||
|
set_label: "About",
|
||||||
|
|
||||||
|
connect_clicked => MainWindowMsg::SelectPage(Pages::AboutPage),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
game_state: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: relm4::AsyncComponentSender<Self>,
|
||||||
|
) -> AsyncComponentParts<Self> {
|
||||||
|
let model;
|
||||||
|
if game_state.is_none() {
|
||||||
|
model = MainWindow::new(
|
||||||
|
babylonia_terminal_sdk::game_state::GameState::get_current_state()
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
&sender,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
model = MainWindow::new(game_state.unwrap(), &sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
MAIN_WINDOW = Some(widgets.main_window.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("current GameState : {:?}", model.game_state);
|
||||||
|
|
||||||
|
AsyncComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
|
||||||
|
view! {
|
||||||
|
#[local]
|
||||||
|
root {
|
||||||
|
set_title: Some("Babylonia Terminal"),
|
||||||
|
set_default_width: 700,
|
||||||
|
set_default_height: 300,
|
||||||
|
|
||||||
|
#[name(spinner)]
|
||||||
|
gtk::Spinner {
|
||||||
|
start: (),
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(LoadingWidgets::new(root, spinner))
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, _sender: relm4::AsyncComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
MainWindowMsg::ToggleMenuVisibility => self.is_menu_visible = !self.is_menu_visible,
|
||||||
|
MainWindowMsg::SelectPage(page) => {
|
||||||
|
self.current_page = page;
|
||||||
|
self.is_menu_visible = false;
|
||||||
|
}
|
||||||
|
MainWindowMsg::UpdateGameState => {
|
||||||
|
self.game_state = GameState::get_current_state().await.unwrap();
|
||||||
|
self.game_page.sender().send(GamePageMsg::UpdateGameState);
|
||||||
|
debug!(
|
||||||
|
"is_environment_ready : {}",
|
||||||
|
self.game_state.is_environment_ready()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
736
babylonia-terminal-gui/src/ui/pages/about.rs
Normal file
736
babylonia-terminal-gui/src/ui/pages/about.rs
Normal file
@ -0,0 +1,736 @@
|
|||||||
|
use libadwaita::prelude::{PreferencesPageExt, PreferencesRowExt};
|
||||||
|
use relm4::{
|
||||||
|
gtk::prelude::{OrientableExt, WidgetExt},
|
||||||
|
prelude::{adw, gtk, AsyncComponentParts, SimpleAsyncComponent},
|
||||||
|
RelmWidgetExt,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::APP_RESOURCE_PATH;
|
||||||
|
|
||||||
|
pub struct AboutPage;
|
||||||
|
|
||||||
|
#[relm4::component(pub, async)]
|
||||||
|
impl SimpleAsyncComponent for AboutPage {
|
||||||
|
type Input = ();
|
||||||
|
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
adw::PreferencesPage {
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Babylonia Terminal",
|
||||||
|
set_margin_top: 24,
|
||||||
|
add_css_class: "title-1",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Made by ALEZ-DEV and the anime game community on Github",
|
||||||
|
set_margin_top: 24,
|
||||||
|
add_css_class: "title-3",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "This software was made under the GPL-3.0 license",
|
||||||
|
set_margin_vertical: 24,
|
||||||
|
add_css_class: "title-4",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_justify: gtk::Justification::Fill,
|
||||||
|
set_label: r#"Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>."#,
|
||||||
|
|
||||||
|
set_margin_top: 24,
|
||||||
|
set_css_classes: &["body", "monospace"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
_: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: relm4::AsyncComponentSender<Self>,
|
||||||
|
) -> relm4::prelude::AsyncComponentParts<Self> {
|
||||||
|
let model = AboutPage {};
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
}
|
||||||
339
babylonia-terminal-gui/src/ui/pages/game.rs
Normal file
339
babylonia-terminal-gui/src/ui/pages/game.rs
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
use std::{convert::identity, fmt::format};
|
||||||
|
|
||||||
|
use arboard::Clipboard;
|
||||||
|
use babylonia_terminal_sdk::game_state::GameState;
|
||||||
|
use libadwaita::prelude::{MessageDialogExt, PreferencesPageExt};
|
||||||
|
use log::error;
|
||||||
|
use relm4::{
|
||||||
|
adw,
|
||||||
|
gtk::{
|
||||||
|
self,
|
||||||
|
prelude::{ButtonExt, GtkWindowExt, OrientableExt, WidgetExt},
|
||||||
|
},
|
||||||
|
prelude::{AsyncComponentParts, SimpleAsyncComponent},
|
||||||
|
Component, RelmWidgetExt, WorkerController,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
manager,
|
||||||
|
ui::{MainWindowMsg, MAIN_WINDOW},
|
||||||
|
APP_RESOURCE_PATH,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct GamePage {
|
||||||
|
game_state: GameState,
|
||||||
|
game_handler: WorkerController<manager::HandleGameProcess>,
|
||||||
|
installation_handler: WorkerController<manager::HandleGameInstallation>,
|
||||||
|
is_game_running: bool,
|
||||||
|
is_downloading: bool,
|
||||||
|
is_patching: bool,
|
||||||
|
progress_bar_reporter: std::sync::Arc<ProgressBarGameInstallationReporter>,
|
||||||
|
progress_bar_message: String,
|
||||||
|
fraction: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum GamePageMsg {
|
||||||
|
SetIsGameRunning(bool),
|
||||||
|
SetIsDownloading(bool),
|
||||||
|
SetIsPatching(bool),
|
||||||
|
UpdateGameState,
|
||||||
|
UpdateProgressBar(u64, u64),
|
||||||
|
ShowError(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(pub, async)]
|
||||||
|
impl SimpleAsyncComponent for GamePage {
|
||||||
|
type Input = GamePageMsg;
|
||||||
|
|
||||||
|
type Output = MainWindowMsg;
|
||||||
|
|
||||||
|
type Init = GameState;
|
||||||
|
|
||||||
|
view! {
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
adw::PreferencesPage {
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
gtk::Picture {
|
||||||
|
set_resource: Some(&format!("{APP_RESOURCE_PATH}/icons/hicolor/scalable/apps/icon.png")),
|
||||||
|
set_vexpand: true,
|
||||||
|
set_width_request: 350,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Babylonia Terminal",
|
||||||
|
set_margin_top: 24,
|
||||||
|
add_css_class: "title-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_margin_vertical: 48,
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Install",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameNotInstalled,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: !model.is_downloading,
|
||||||
|
connect_clicked[sender = model.installation_handler.sender().clone(), progress_bar = model.progress_bar_reporter.clone()] => move |_| {
|
||||||
|
sender.send(manager::HandleGameInstallationMsg::StartInstallation(progress_bar.clone())).unwrap();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Apply patch",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameNotPatched,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: !model.is_patching,
|
||||||
|
connect_clicked[sender = model.installation_handler.sender().clone()] => move |_| {
|
||||||
|
sender.send(manager::HandleGameInstallationMsg::StartPatch).unwrap();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Start game",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameInstalled,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: !model.is_game_running,
|
||||||
|
connect_clicked[sender = model.game_handler.sender().clone()] => move |_| {
|
||||||
|
sender.send(manager::HandleGameProcessMsg::RunGame).unwrap();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Button {
|
||||||
|
set_css_classes: &["suggested-action", "pill"],
|
||||||
|
|
||||||
|
set_label: "Update",
|
||||||
|
set_hexpand: false,
|
||||||
|
set_width_request: 200,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameNeedUpdate,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_sensitive: !model.is_downloading,
|
||||||
|
connect_clicked[sender = model.installation_handler.sender().clone(), progress_bar = model.progress_bar_reporter.clone()] => move |_| {
|
||||||
|
sender.send(manager::HandleGameInstallationMsg::StartUpdate(progress_bar.clone())).unwrap();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::ProgressBar {
|
||||||
|
#[watch]
|
||||||
|
set_fraction: model.fraction,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: (model.game_state == GameState::GameNotInstalled || model.game_state == GameState::GameNeedUpdate) && model.is_downloading && model.fraction != 0.0,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_text: Some(&model.progress_bar_message),
|
||||||
|
set_show_text: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: (model.game_state == GameState::GameNotInstalled || model.game_state == GameState::GameNeedUpdate) && model.is_downloading && model.fraction == 0.0,
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
set_margin_bottom: 24,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Checking game files",
|
||||||
|
|
||||||
|
add_css_class: "title-2",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
set_margin_start: 24,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "This can take some time, please wait...",
|
||||||
|
|
||||||
|
add_css_class: "title-4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.game_state == GameState::GameNotPatched && model.is_patching,
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Patching game",
|
||||||
|
|
||||||
|
add_css_class: "title-2",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "This can take some time, please wait...",
|
||||||
|
|
||||||
|
add_css_class: "title-4",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
game_state: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: relm4::AsyncComponentSender<Self>,
|
||||||
|
) -> relm4::prelude::AsyncComponentParts<Self> {
|
||||||
|
let model = GamePage {
|
||||||
|
progress_bar_reporter: ProgressBarGameInstallationReporter::create(sender.clone()),
|
||||||
|
game_state,
|
||||||
|
game_handler: manager::HandleGameProcess::builder()
|
||||||
|
.detach_worker(())
|
||||||
|
.forward(sender.input_sender(), identity),
|
||||||
|
installation_handler: manager::HandleGameInstallation::builder()
|
||||||
|
.detach_worker(())
|
||||||
|
.forward(sender.input_sender(), identity),
|
||||||
|
is_game_running: false,
|
||||||
|
is_downloading: false,
|
||||||
|
is_patching: false,
|
||||||
|
fraction: 0.0,
|
||||||
|
progress_bar_message: String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, _: relm4::AsyncComponentSender<Self>) -> () {
|
||||||
|
match message {
|
||||||
|
GamePageMsg::SetIsGameRunning(value) => self.is_game_running = value,
|
||||||
|
GamePageMsg::SetIsDownloading(value) => self.is_downloading = value,
|
||||||
|
GamePageMsg::SetIsPatching(value) => self.is_patching = value,
|
||||||
|
GamePageMsg::UpdateGameState => {
|
||||||
|
self.game_state = GameState::get_current_state().await.unwrap()
|
||||||
|
} //TODO: remove unwrap()
|
||||||
|
GamePageMsg::UpdateProgressBar(current, max_progress) => {
|
||||||
|
self.fraction = if current == 0 {
|
||||||
|
0.0
|
||||||
|
} else {
|
||||||
|
current as f64 / max_progress as f64
|
||||||
|
};
|
||||||
|
|
||||||
|
//1024^3 = 1073741824
|
||||||
|
let current_gb = current as f64 / 1073741824 as f64;
|
||||||
|
let max_gb = max_progress as f64 / 1073741824 as f64;
|
||||||
|
|
||||||
|
self.progress_bar_message = format!(
|
||||||
|
"Downloading : {:.2}% ({:.2} / {:.2}GiB)",
|
||||||
|
self.fraction * 100 as f64,
|
||||||
|
current_gb,
|
||||||
|
max_gb,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
GamePageMsg::ShowError(message) => {
|
||||||
|
let dialog = unsafe {
|
||||||
|
adw::MessageDialog::new(
|
||||||
|
MAIN_WINDOW.as_ref(),
|
||||||
|
Some("Something went wrong"),
|
||||||
|
Some(&message),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
dialog.add_response("close", "Close");
|
||||||
|
dialog.add_response("copy", "Copy");
|
||||||
|
|
||||||
|
dialog.set_response_appearance("copy", adw::ResponseAppearance::Suggested);
|
||||||
|
|
||||||
|
dialog.connect_response(Some("copy"), move |_, _| {
|
||||||
|
if let Err(err) = Clipboard::new().unwrap().set_text(&message.clone()) {
|
||||||
|
error!("Failed to copy the error to the clipboard : {}", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.present();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct ProgressBarGameInstallationReporterPrivate {
|
||||||
|
max_progress: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ProgressBarGameInstallationReporter {
|
||||||
|
private: std::sync::Mutex<Option<ProgressBarGameInstallationReporterPrivate>>,
|
||||||
|
sender: relm4::AsyncComponentSender<GamePage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ProgressBarGameInstallationReporter {
|
||||||
|
fn create(page: relm4::AsyncComponentSender<GamePage>) -> std::sync::Arc<Self> {
|
||||||
|
std::sync::Arc::new(Self {
|
||||||
|
private: std::sync::Mutex::new(None),
|
||||||
|
sender: page,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl downloader::progress::Reporter for ProgressBarGameInstallationReporter {
|
||||||
|
fn setup(&self, max_progress: Option<u64>, message: &str) {
|
||||||
|
let private = ProgressBarGameInstallationReporterPrivate { max_progress };
|
||||||
|
|
||||||
|
let mut guard = self.private.lock().unwrap();
|
||||||
|
*guard = Some(private);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn progress(&self, current: u64) {
|
||||||
|
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
||||||
|
self.sender.input(GamePageMsg::UpdateProgressBar(
|
||||||
|
current,
|
||||||
|
p.max_progress.unwrap(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_message(&self, _: &str) {}
|
||||||
|
|
||||||
|
fn done(&self) {
|
||||||
|
let mut guard = self.private.lock().unwrap();
|
||||||
|
*guard = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
4
babylonia-terminal-gui/src/ui/pages/mod.rs
Normal file
4
babylonia-terminal-gui/src/ui/pages/mod.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub mod about;
|
||||||
|
pub mod game;
|
||||||
|
pub mod settings;
|
||||||
|
pub mod steps;
|
||||||
122
babylonia-terminal-gui/src/ui/pages/settings.rs
Normal file
122
babylonia-terminal-gui/src/ui/pages/settings.rs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
use arboard::Clipboard;
|
||||||
|
use babylonia_terminal_sdk::game_config::GameConfig;
|
||||||
|
use log::error;
|
||||||
|
use relm4::{
|
||||||
|
gtk::{
|
||||||
|
prelude::{EditableExt, GtkWindowExt, OrientableExt, WidgetExt},
|
||||||
|
InputHints,
|
||||||
|
},
|
||||||
|
prelude::{gtk, AsyncComponentParts, SimpleAsyncComponent},
|
||||||
|
};
|
||||||
|
|
||||||
|
use libadwaita::{
|
||||||
|
self as adw,
|
||||||
|
prelude::{
|
||||||
|
EntryRowExt, MessageDialogExt, PreferencesGroupExt, PreferencesPageExt, PreferencesRowExt,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::ui::MAIN_WINDOW;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SettingsPageMsg {
|
||||||
|
UpdateLaunchOption(Option<String>),
|
||||||
|
ShowError(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SettingsPage {
|
||||||
|
launch_option: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(pub, async)]
|
||||||
|
impl SimpleAsyncComponent for SettingsPage {
|
||||||
|
type Input = SettingsPageMsg;
|
||||||
|
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
gtk::Box {
|
||||||
|
set_orientation: gtk::Orientation::Vertical,
|
||||||
|
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_title: "General settings",
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_width_request: 500,
|
||||||
|
set_title: "Launch option",
|
||||||
|
set_description: Some("Pass launch options to tinker the behavior of the game"),
|
||||||
|
|
||||||
|
adw::EntryRow {
|
||||||
|
set_title: "%command%",
|
||||||
|
set_text: &model.launch_option,
|
||||||
|
|
||||||
|
connect_changed[sender] => move |entry| {
|
||||||
|
let command = entry.text().trim().to_string();
|
||||||
|
if command.is_empty() {
|
||||||
|
sender.input(SettingsPageMsg::UpdateLaunchOption(None))
|
||||||
|
} else {
|
||||||
|
sender.input(SettingsPageMsg::UpdateLaunchOption(Some(command)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
_: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: relm4::AsyncComponentSender<Self>,
|
||||||
|
) -> relm4::prelude::AsyncComponentParts<Self> {
|
||||||
|
let launch_option = match GameConfig::get_launch_options().await {
|
||||||
|
Err(e) => String::new(),
|
||||||
|
Ok(v) => match v {
|
||||||
|
None => String::new(),
|
||||||
|
Some(launch) => launch,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let model = SettingsPage { launch_option };
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { model, widgets }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, sender: relm4::AsyncComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
SettingsPageMsg::UpdateLaunchOption(new_launch_option) => {
|
||||||
|
if let Err(e) = GameConfig::set_launch_options(new_launch_option).await {
|
||||||
|
sender.input(SettingsPageMsg::ShowError(format!(
|
||||||
|
"Something went wrong when updated the launch options : {}",
|
||||||
|
e
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SettingsPageMsg::ShowError(message) => {
|
||||||
|
let dialog = unsafe {
|
||||||
|
adw::MessageDialog::new(
|
||||||
|
MAIN_WINDOW.as_ref(),
|
||||||
|
Some("Something went wrong"),
|
||||||
|
Some(&message),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
dialog.add_response("close", "Close");
|
||||||
|
dialog.add_response("copy", "Copy");
|
||||||
|
|
||||||
|
dialog.set_response_appearance("copy", adw::ResponseAppearance::Suggested);
|
||||||
|
|
||||||
|
dialog.connect_response(Some("copy"), move |_, _| {
|
||||||
|
if let Err(err) = Clipboard::new().unwrap().set_text(&message.clone()) {
|
||||||
|
error!("Failed to copy the error to the clipboard : {}", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.present();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
use std::{path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
|
use babylonia_terminal_sdk::{game_config::GameConfig, game_manager::GameManager};
|
||||||
|
use log::info;
|
||||||
|
use relm4::{
|
||||||
|
gtk,
|
||||||
|
prelude::{AsyncComponentParts, SimpleAsyncComponent},
|
||||||
|
view, RelmWidgetExt,
|
||||||
|
};
|
||||||
|
|
||||||
|
use libadwaita::{self as adw, prelude::*};
|
||||||
|
|
||||||
|
use super::SetupPageMsg;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ChooseGameDirectoryMsg {
|
||||||
|
ChoosePath,
|
||||||
|
Next,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ChooseGameDirectoryPage {
|
||||||
|
path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(async, pub)]
|
||||||
|
impl SimpleAsyncComponent for ChooseGameDirectoryPage {
|
||||||
|
type Input = ChooseGameDirectoryMsg;
|
||||||
|
|
||||||
|
type Output = SetupPageMsg;
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
gtk::Box {
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_hexpand: true,
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Game directory",
|
||||||
|
add_css_class: "title-1"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_width_request: 500,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
adw::ActionRow {
|
||||||
|
set_title: "Game directory",
|
||||||
|
set_icon_name: Some("folder-symbolic"),
|
||||||
|
set_activatable: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_subtitle: model.path.to_str().unwrap(),
|
||||||
|
|
||||||
|
connect_activated => ChooseGameDirectoryMsg::ChoosePath,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
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 => ChooseGameDirectoryMsg::Next,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
init: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: relm4::AsyncComponentSender<Self>,
|
||||||
|
) -> relm4::prelude::AsyncComponentParts<Self> {
|
||||||
|
let path = if let Some(dir) = GameConfig::get_config().await.game_dir {
|
||||||
|
dir
|
||||||
|
} else {
|
||||||
|
GameConfig::get_config_directory().await
|
||||||
|
};
|
||||||
|
|
||||||
|
let model = ChooseGameDirectoryPage { path };
|
||||||
|
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { widgets, model }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, sender: relm4::AsyncComponentSender<Self>) {
|
||||||
|
match message {
|
||||||
|
ChooseGameDirectoryMsg::ChoosePath => {
|
||||||
|
info!("choose path");
|
||||||
|
let result = rfd::AsyncFileDialog::new()
|
||||||
|
.set_directory(self.path.clone())
|
||||||
|
.pick_folder()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
if let Some(result) = result {
|
||||||
|
self.path = result.path().to_path_buf();
|
||||||
|
}
|
||||||
|
|
||||||
|
GameConfig::set_game_dir(Some(self.path.clone()))
|
||||||
|
.await
|
||||||
|
.unwrap(); // TODO: remove unwrap
|
||||||
|
}
|
||||||
|
ChooseGameDirectoryMsg::Next => {
|
||||||
|
let _ = sender.output(SetupPageMsg::GoToDownloadComponentPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
465
babylonia-terminal-gui/src/ui/pages/steps/download_components.rs
Normal file
465
babylonia-terminal-gui/src/ui/pages/steps/download_components.rs
Normal file
@ -0,0 +1,465 @@
|
|||||||
|
use std::{convert::identity, usize};
|
||||||
|
|
||||||
|
use arboard::Clipboard;
|
||||||
|
use babylonia_terminal_sdk::{
|
||||||
|
components::{
|
||||||
|
dxvk_component::{self, DXVKComponent},
|
||||||
|
proton_component::{self, ProtonComponent},
|
||||||
|
},
|
||||||
|
game_config::GameConfig,
|
||||||
|
game_state::GameState,
|
||||||
|
utils::{
|
||||||
|
github_requester::{GithubRelease, GithubRequester},
|
||||||
|
kuro_prod_api::CurrentGameInfo,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use log::{debug, error, info};
|
||||||
|
use relm4::{
|
||||||
|
self,
|
||||||
|
gtk::{self, prelude::*},
|
||||||
|
prelude::*,
|
||||||
|
*,
|
||||||
|
};
|
||||||
|
|
||||||
|
use adw::prelude::*;
|
||||||
|
use libadwaita as adw;
|
||||||
|
|
||||||
|
use crate::{manager, ui::MAIN_WINDOW};
|
||||||
|
|
||||||
|
use super::SetupPageMsg;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum DownloadComponentsMsg {
|
||||||
|
UpdateProgressBar((u64, u64)), // current and max_progress
|
||||||
|
UpdateProgressBarMsg(String, Option<String>), // current msg and when done msg
|
||||||
|
ShowDoneMsg,
|
||||||
|
UpdateDownloadedComponentName(String),
|
||||||
|
UpdateCurrentlyInstalling(CurrentlyInstalling),
|
||||||
|
ShowError(String), // error message
|
||||||
|
Finish,
|
||||||
|
Quit,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub enum CurrentlyInstalling {
|
||||||
|
None,
|
||||||
|
Proton,
|
||||||
|
DXVK,
|
||||||
|
Fonts,
|
||||||
|
Denpendecies,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct DownloadComponentsPage {
|
||||||
|
// widgets
|
||||||
|
proton_combo: adw::ComboRow,
|
||||||
|
dxvk_combo: adw::ComboRow,
|
||||||
|
//error_dialog: Controller<CopyDialog>,
|
||||||
|
|
||||||
|
// values
|
||||||
|
proton_versions: Vec<GithubRelease>,
|
||||||
|
dxvk_versions: Vec<GithubRelease>,
|
||||||
|
selected_proton_version: Option<GithubRelease>,
|
||||||
|
selected_dxvk_version: Option<GithubRelease>,
|
||||||
|
game_config: GameConfig,
|
||||||
|
|
||||||
|
//progress_bar
|
||||||
|
progress_bar_reporter: std::sync::Arc<DownloadComponentProgressBarReporter>,
|
||||||
|
progress_bar_message: String,
|
||||||
|
fraction: f64,
|
||||||
|
show_progress_bar: bool,
|
||||||
|
|
||||||
|
// download part
|
||||||
|
installation_handler: WorkerController<manager::HandleComponentInstallation>,
|
||||||
|
downloaded_component_name: String,
|
||||||
|
currently_installing: CurrentlyInstalling,
|
||||||
|
msg_when_done: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[relm4::component(async, pub)]
|
||||||
|
impl SimpleAsyncComponent for DownloadComponentsPage {
|
||||||
|
type Input = DownloadComponentsMsg;
|
||||||
|
|
||||||
|
type Output = SetupPageMsg;
|
||||||
|
|
||||||
|
type Init = ();
|
||||||
|
|
||||||
|
view! {
|
||||||
|
#[root]
|
||||||
|
gtk::Box {
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_hexpand: true,
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::None,
|
||||||
|
|
||||||
|
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_width_request: 500,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
#[local_ref]
|
||||||
|
proton_combo -> adw::ComboRow {
|
||||||
|
set_title: "proton version",
|
||||||
|
|
||||||
|
set_model: Some(>k::StringList::new(model
|
||||||
|
.proton_versions
|
||||||
|
.iter()
|
||||||
|
.map(|r| r.tag_name.as_str())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.as_slice())),
|
||||||
|
},
|
||||||
|
|
||||||
|
#[local_ref]
|
||||||
|
dxvk_combo -> adw::ComboRow {
|
||||||
|
set_title: "dxvk version",
|
||||||
|
|
||||||
|
set_model: Some(>k::StringList::new(model
|
||||||
|
.dxvk_versions
|
||||||
|
.iter()
|
||||||
|
.map(|r| r.tag_name.as_str())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.as_slice())),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
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::UpdateCurrentlyInstalling(CurrentlyInstalling::Proton),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::PreferencesPage {
|
||||||
|
set_hexpand: true,
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing != CurrentlyInstalling::None,
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_width_request: 500,
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
set_label: "Downloading and installing components",
|
||||||
|
add_css_class: "title-1"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
adw::ActionRow {
|
||||||
|
set_title: "Proton",
|
||||||
|
#[watch]
|
||||||
|
set_subtitle: match &model.selected_proton_version {
|
||||||
|
Some(release) => &release.tag_name,
|
||||||
|
None => "WTF??!! there's no proton version found ????",
|
||||||
|
},
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_icon_name: if model.currently_installing != CurrentlyInstalling::Proton && model.game_config.is_wine_installed { Some("emblem-ok-symbolic") } else { None },
|
||||||
|
|
||||||
|
add_prefix = >k::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::Proton,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::ActionRow {
|
||||||
|
set_title: "DXVK",
|
||||||
|
#[watch]
|
||||||
|
set_subtitle: match &model.selected_dxvk_version {
|
||||||
|
Some(release) => &release.tag_name,
|
||||||
|
None => "WTF??!! there's no proton version found ????",
|
||||||
|
},
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_icon_name: if model.currently_installing != CurrentlyInstalling::DXVK && model.game_config.is_dxvk_installed { Some("emblem-ok-symbolic") } else { None },
|
||||||
|
|
||||||
|
add_prefix = >k::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::DXVK,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::ActionRow {
|
||||||
|
#[watch]
|
||||||
|
set_title: "Fonts",
|
||||||
|
set_subtitle: "Arial",
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_icon_name: if model.currently_installing != CurrentlyInstalling::Fonts && model.game_config.is_font_installed { Some("emblem-ok-symbolic") } else { None },
|
||||||
|
|
||||||
|
add_prefix = >k::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::Fonts,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
adw::ActionRow {
|
||||||
|
#[watch]
|
||||||
|
set_title: "Denpendecies",
|
||||||
|
set_subtitle: "vcrun2022",
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_icon_name: if model.currently_installing != CurrentlyInstalling::Denpendecies && model.game_config.is_dependecies_installed { Some("emblem-ok-symbolic") } else { None },
|
||||||
|
|
||||||
|
add_prefix = >k::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::Denpendecies,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
add = &adw::PreferencesGroup {
|
||||||
|
set_valign: gtk::Align::Center,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
gtk::ProgressBar {
|
||||||
|
#[watch]
|
||||||
|
set_fraction: model.fraction,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing != CurrentlyInstalling::Fonts && model.currently_installing != CurrentlyInstalling::Denpendecies,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_text: Some(&model.progress_bar_message),
|
||||||
|
set_show_text: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Box {
|
||||||
|
set_halign: gtk::Align::Center,
|
||||||
|
set_orientation: gtk::Orientation::Horizontal,
|
||||||
|
|
||||||
|
gtk::Label {
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::Fonts || model.currently_installing == CurrentlyInstalling::Denpendecies,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_label: &model.progress_bar_message,
|
||||||
|
add_css_class: "title-3",
|
||||||
|
},
|
||||||
|
|
||||||
|
gtk::Spinner {
|
||||||
|
set_spinning: true,
|
||||||
|
set_margin_start: 24,
|
||||||
|
|
||||||
|
#[watch]
|
||||||
|
set_visible: model.currently_installing == CurrentlyInstalling::Fonts || model.currently_installing == CurrentlyInstalling::Denpendecies,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn init(
|
||||||
|
_: Self::Init,
|
||||||
|
root: Self::Root,
|
||||||
|
sender: AsyncComponentSender<Self>,
|
||||||
|
) -> AsyncComponentParts<Self> {
|
||||||
|
let proton_releases = ProtonComponent::get_github_releases(
|
||||||
|
proton_component::PROTON_DEV,
|
||||||
|
proton_component::PROTON_REPO,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(); //TODO: remove unwrap()
|
||||||
|
|
||||||
|
let dxvk_releases =
|
||||||
|
DXVKComponent::get_github_releases(dxvk_component::DXVK_DEV, dxvk_component::DXVK_REPO)
|
||||||
|
.await
|
||||||
|
.unwrap(); //TODO: remove unwrap()
|
||||||
|
|
||||||
|
let model = DownloadComponentsPage {
|
||||||
|
proton_combo: adw::ComboRow::new(),
|
||||||
|
dxvk_combo: adw::ComboRow::new(),
|
||||||
|
|
||||||
|
proton_versions: proton_releases,
|
||||||
|
dxvk_versions: dxvk_releases,
|
||||||
|
selected_proton_version: None,
|
||||||
|
selected_dxvk_version: None,
|
||||||
|
game_config: GameConfig::get_config().await,
|
||||||
|
|
||||||
|
progress_bar_reporter: DownloadComponentProgressBarReporter::create(sender.clone()),
|
||||||
|
progress_bar_message: String::new(),
|
||||||
|
fraction: 0.0,
|
||||||
|
show_progress_bar: false,
|
||||||
|
|
||||||
|
installation_handler: manager::HandleComponentInstallation::builder()
|
||||||
|
.detach_worker(())
|
||||||
|
.forward(sender.input_sender(), identity),
|
||||||
|
downloaded_component_name: String::new(),
|
||||||
|
currently_installing: CurrentlyInstalling::None,
|
||||||
|
msg_when_done: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let proton_combo = &model.proton_combo;
|
||||||
|
let dxvk_combo = &model.dxvk_combo;
|
||||||
|
|
||||||
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
AsyncComponentParts { widgets, model }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn update(&mut self, message: Self::Input, sender: AsyncComponentSender<Self>) -> () {
|
||||||
|
match message {
|
||||||
|
DownloadComponentsMsg::UpdateDownloadedComponentName(name) => {
|
||||||
|
self.downloaded_component_name = name;
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::UpdateProgressBar((current, max_progress)) => {
|
||||||
|
if self.currently_installing != CurrentlyInstalling::Fonts
|
||||||
|
&& self.currently_installing != CurrentlyInstalling::Denpendecies
|
||||||
|
{
|
||||||
|
self.fraction = if current == 0 {
|
||||||
|
0.0
|
||||||
|
} else {
|
||||||
|
current as f64 / max_progress as f64
|
||||||
|
};
|
||||||
|
|
||||||
|
self.progress_bar_message = format!(
|
||||||
|
"Downloading {} : {:.2}%",
|
||||||
|
self.downloaded_component_name,
|
||||||
|
self.fraction * 100.0
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
self.progress_bar_message =
|
||||||
|
format!("Downloading {}", self.downloaded_component_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::UpdateProgressBarMsg(message, message_when_done) => {
|
||||||
|
self.progress_bar_message = message;
|
||||||
|
self.msg_when_done = message_when_done;
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::ShowDoneMsg => {
|
||||||
|
if let Some(msg) = self.msg_when_done.clone() {
|
||||||
|
self.progress_bar_message = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::UpdateCurrentlyInstalling(currently_installing) => {
|
||||||
|
self.game_config = GameConfig::get_config().await;
|
||||||
|
|
||||||
|
self.currently_installing = currently_installing;
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::ShowError(message) => {
|
||||||
|
let dialog = unsafe {
|
||||||
|
adw::MessageDialog::new(
|
||||||
|
MAIN_WINDOW.as_ref(),
|
||||||
|
Some("Error while downloading components"),
|
||||||
|
Some(&message),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
dialog.add_response("close", "Close");
|
||||||
|
dialog.add_response("copy", "Copy");
|
||||||
|
|
||||||
|
dialog.set_response_appearance("copy", adw::ResponseAppearance::Suggested);
|
||||||
|
|
||||||
|
dialog.connect_response(Some("copy"), move |_, _| {
|
||||||
|
if let Err(err) = Clipboard::new().unwrap().set_text(&message.clone()) {
|
||||||
|
error!("Failed to copy the error to the clipboard : {}", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.present();
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::Finish => {
|
||||||
|
let _ = sender.output(SetupPageMsg::Finish);
|
||||||
|
}
|
||||||
|
DownloadComponentsMsg::Quit => relm4::main_application().quit(),
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.selected_proton_version.is_none()
|
||||||
|
&& self.selected_dxvk_version.is_none()
|
||||||
|
&& self.currently_installing != CurrentlyInstalling::None
|
||||||
|
{
|
||||||
|
let proton_index = self.proton_combo.selected() as usize;
|
||||||
|
let dxvk_index = self.dxvk_combo.selected() as usize;
|
||||||
|
|
||||||
|
let proton_release = self.proton_versions[proton_index].clone();
|
||||||
|
let dxvk_release = self.dxvk_versions[dxvk_index].clone();
|
||||||
|
|
||||||
|
self.selected_proton_version = Some(proton_release);
|
||||||
|
self.selected_dxvk_version = Some(dxvk_release);
|
||||||
|
let _ = self.installation_handler.sender().send(
|
||||||
|
manager::HandleComponentInstallationMsg::StartInstallation((
|
||||||
|
proton_index,
|
||||||
|
dxvk_index,
|
||||||
|
self.progress_bar_reporter.clone(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct ProgressBarReporterPrivate {
|
||||||
|
max_progress: Option<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct DownloadComponentProgressBarReporter {
|
||||||
|
private: std::sync::Mutex<Option<ProgressBarReporterPrivate>>,
|
||||||
|
sender: relm4::AsyncComponentSender<DownloadComponentsPage>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DownloadComponentProgressBarReporter {
|
||||||
|
fn create(page: relm4::AsyncComponentSender<DownloadComponentsPage>) -> std::sync::Arc<Self> {
|
||||||
|
std::sync::Arc::new(Self {
|
||||||
|
private: std::sync::Mutex::new(None),
|
||||||
|
sender: page,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl downloader::progress::Reporter for DownloadComponentProgressBarReporter {
|
||||||
|
fn setup(&self, max_progress: Option<u64>, message: &str) {
|
||||||
|
let private = ProgressBarReporterPrivate { max_progress };
|
||||||
|
|
||||||
|
let mut guard = self.private.lock().unwrap();
|
||||||
|
*guard = Some(private);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn progress(&self, current: u64) {
|
||||||
|
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
||||||
|
self.sender.input(DownloadComponentsMsg::UpdateProgressBar((
|
||||||
|
current,
|
||||||
|
p.max_progress.unwrap(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_message(&self, message: &str) {}
|
||||||
|
|
||||||
|
fn done(&self) {
|
||||||
|
self.sender.input(DownloadComponentsMsg::ShowDoneMsg);
|
||||||
|
let mut guard = self.private.lock().unwrap();
|
||||||
|
*guard = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
119
babylonia-terminal-gui/src/ui/pages/steps/mod.rs
Normal file
119
babylonia-terminal-gui/src/ui/pages/steps/mod.rs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
use std::convert::identity;
|
||||||
|
|
||||||
|
use babylonia_terminal_sdk::{game_config::GameConfig, game_state::GameState};
|
||||||
|
use choose_game_directory::ChooseGameDirectoryPage;
|
||||||
|
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 choose_game_directory;
|
||||||
|
pub mod download_components;
|
||||||
|
mod welcome;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SetupPageMsg {
|
||||||
|
GoToChooseGameDirectoryPage,
|
||||||
|
GoToDownloadComponentPage,
|
||||||
|
Finish,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SetupPage {
|
||||||
|
game_state: GameState,
|
||||||
|
welcome_page: Controller<welcome::WelcomePage>,
|
||||||
|
choose_game_directory_page: AsyncController<choose_game_directory::ChooseGameDirectoryPage>,
|
||||||
|
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,
|
||||||
|
set_hexpand: true,
|
||||||
|
set_vexpand: true,
|
||||||
|
|
||||||
|
#[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.choose_game_directory_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 choose_game_directory_page = ChooseGameDirectoryPage::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,
|
||||||
|
choose_game_directory_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>) {
|
||||||
|
self.game_state = GameState::get_current_state().await.unwrap(); // TODO: delete this unwrap()
|
||||||
|
|
||||||
|
match message {
|
||||||
|
SetupPageMsg::GoToChooseGameDirectoryPage => {
|
||||||
|
self.carousel
|
||||||
|
.scroll_to(self.choose_game_directory_page.widget(), true);
|
||||||
|
}
|
||||||
|
SetupPageMsg::GoToDownloadComponentPage => {
|
||||||
|
self.carousel
|
||||||
|
.scroll_to(self.download_components_page.widget(), true);
|
||||||
|
}
|
||||||
|
SetupPageMsg::Finish => {
|
||||||
|
sender.output(MainWindowMsg::UpdateGameState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
86
babylonia-terminal-gui/src/ui/pages/steps/welcome.rs
Normal file
86
babylonia-terminal-gui/src/ui/pages/steps/welcome.rs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
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::GoToChooseGameDirectoryPage)
|
||||||
|
.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "babylonia-terminal-sdk"
|
name = "babylonia-terminal-sdk"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["ALEZ-DEV <raidersfocus@gmail.com>"]
|
authors = ["ALEZ-DEV <raidersfocus@gmail.com>"]
|
||||||
description = "A SDK for launcher for a certain anime game "
|
description = "A SDK for launcher for a certain anime game "
|
||||||
@ -15,17 +15,19 @@ anyhow = "1.0.81"
|
|||||||
chksum-md5 = { version = "0.0.0", features = ["reader"] }
|
chksum-md5 = { version = "0.0.0", features = ["reader"] }
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
downloader = { git = "https://github.com/ALEZ-DEV/downloader" } # version = "0.2.7",
|
downloader = { workspace = true }
|
||||||
flate2 = "1.0.28"
|
flate2 = "1.0.28"
|
||||||
fs_extra = "1.3.0"
|
fs_extra = "1.3.0"
|
||||||
|
futures = "0.3.30"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
|
num_cpus = "1.16.0"
|
||||||
reqwest = { version = "0.12.2", features = ["gzip"] }
|
reqwest = { version = "0.12.2", features = ["gzip"] }
|
||||||
rust-embed = "8.3.0"
|
rust-embed = "8.3.0"
|
||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.115"
|
||||||
tar = "0.4.40"
|
tar = "0.4.40"
|
||||||
tokio = { version = "1.37.0", features = ["fs"] }
|
tokio = { version = "1.37.0", features = ["fs"] }
|
||||||
wincompatlib = { version = "0.7.4", features = [
|
wincompatlib = { version = "0.7.5", features = [
|
||||||
"dxvk",
|
"dxvk",
|
||||||
"wine-bundles",
|
"wine-bundles",
|
||||||
"wine-proton",
|
"wine-proton",
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
use std::fs as std_fs;
|
use std::fs as std_fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::sync::Mutex;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
|
use downloader::progress::Reporter;
|
||||||
use downloader::Downloader;
|
use downloader::Downloader;
|
||||||
|
use futures::future::join_all;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use log::info;
|
use log::info;
|
||||||
use tokio::fs::{create_dir_all, remove_file};
|
use tokio::fs::{create_dir_all, remove_file};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::Semaphore;
|
||||||
use tokio::sync::mpsc::Receiver;
|
|
||||||
use tokio::sync::mpsc::Sender;
|
|
||||||
use tokio::time::timeout;
|
|
||||||
|
|
||||||
use super::component_downloader::ComponentDownloader;
|
use super::component_downloader::ComponentDownloader;
|
||||||
use crate::utils::get_game_name;
|
use crate::utils::get_game_name;
|
||||||
@ -36,60 +35,63 @@ impl GameComponent {
|
|||||||
resources: &Resources,
|
resources: &Resources,
|
||||||
) -> anyhow::Result<Vec<Resource>> {
|
) -> anyhow::Result<Vec<Resource>> {
|
||||||
info!("checking all files, this can take a while...");
|
info!("checking all files, this can take a while...");
|
||||||
let mut to_download: Vec<Resource> = vec![];
|
let to_download: Arc<Mutex<Vec<Resource>>> = Arc::new(Mutex::new(vec![]));
|
||||||
|
|
||||||
for r in &resources.resource {
|
let threads_number = num_cpus::get();
|
||||||
let file_path = game_dir.join(r.dest.clone().strip_prefix("/").unwrap());
|
debug!("Starting Md5 files check with {} threads", threads_number);
|
||||||
|
let mut handles = vec![];
|
||||||
|
let semaphore = Arc::new(Semaphore::new(threads_number));
|
||||||
|
|
||||||
if file_path.try_exists()? {
|
let chunks = resources.resource.chunks(threads_number);
|
||||||
|
|
||||||
|
for chunked_resources in chunks {
|
||||||
|
let to_download_ref = to_download.clone();
|
||||||
|
let cloned_resources = chunked_resources.to_owned();
|
||||||
|
let game_dir = game_dir.clone();
|
||||||
|
let semaphore = semaphore.clone();
|
||||||
|
|
||||||
|
let handle = tokio::task::spawn(async move {
|
||||||
|
let _permit = semaphore.acquire().await;
|
||||||
|
|
||||||
|
for resource_to_check in cloned_resources {
|
||||||
|
let file_path = game_dir.join(resource_to_check.dest.clone());
|
||||||
|
|
||||||
|
if file_path.try_exists().unwrap() {
|
||||||
let blocking_file_path = file_path.clone();
|
let blocking_file_path = file_path.clone();
|
||||||
let file =
|
let file = tokio::task::spawn_blocking(move || {
|
||||||
tokio::task::spawn_blocking(move || std_fs::File::open(blocking_file_path))
|
std_fs::File::open(blocking_file_path)
|
||||||
.await??; // only the std::File is supported by chksum_md5, that's why I block
|
})
|
||||||
let digest = chksum_md5::chksum(file)?;
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.unwrap(); // only the std::File is supported by chksum_md5, that's why I block
|
||||||
|
let digest = chksum_md5::chksum(file)
|
||||||
|
.expect("Failed to check the checksum of the file");
|
||||||
|
|
||||||
if digest.to_hex_lowercase() != r.md5 {
|
if digest.to_hex_lowercase() != resource_to_check.md5 {
|
||||||
to_download.push(r.clone());
|
to_download_ref
|
||||||
remove_file(file_path).await?;
|
.lock()
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.push(resource_to_check.clone());
|
||||||
|
remove_file(file_path).await.unwrap();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
to_download.push(r.clone());
|
to_download_ref
|
||||||
}
|
.lock()
|
||||||
}
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
Ok(to_download)
|
.push(resource_to_check.clone());
|
||||||
}
|
|
||||||
|
|
||||||
fn update_progress<P: downloader::progress::Reporter + 'static>(
|
|
||||||
progress: Arc<P>,
|
|
||||||
max_size: u64,
|
|
||||||
game_dir: PathBuf,
|
|
||||||
mut rx: Receiver<&'static str>,
|
|
||||||
) {
|
|
||||||
tokio::spawn(async move {
|
|
||||||
progress.setup(Some(max_size.to_owned()), "");
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let current_size = fs_extra::dir::get_size(game_dir.clone());
|
|
||||||
if let Ok(size) = current_size {
|
|
||||||
progress.progress(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Ok(v) = timeout(Duration::from_millis(250), rx.recv()).await {
|
|
||||||
match v {
|
|
||||||
Some(str) => {
|
|
||||||
if str == "done" {
|
|
||||||
if let Ok(size) = current_size {
|
|
||||||
progress.done();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
handles.push(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
join_all(handles).await;
|
||||||
|
|
||||||
|
Ok(Arc::try_unwrap(to_download)
|
||||||
|
.expect("There is multiple references of this Vector")
|
||||||
|
.into_inner()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,32 +117,34 @@ impl ComponentDownloader for GameComponent {
|
|||||||
) -> anyhow::Result<std::path::PathBuf> {
|
) -> anyhow::Result<std::path::PathBuf> {
|
||||||
let game_info = kuro_prod_api::GameInfo::get_info().await?;
|
let game_info = kuro_prod_api::GameInfo::get_info().await?;
|
||||||
let resources = game_info.fetch_resources().await?;
|
let resources = game_info.fetch_resources().await?;
|
||||||
|
|
||||||
|
let threads_number = num_cpus::get();
|
||||||
|
|
||||||
let mut downloader = Downloader::builder()
|
let mut downloader = Downloader::builder()
|
||||||
.download_folder(output_dir)
|
.download_folder(output_dir)
|
||||||
.parallel_requests(5)
|
.parallel_requests(threads_number as u16)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let checked_resources =
|
let checked_resources =
|
||||||
GameComponent::check_and_get_resources_to_download(output_dir, &resources).await?;
|
GameComponent::check_and_get_resources_to_download(output_dir, &resources).await?;
|
||||||
let (tx, rx): (Sender<&str>, Receiver<&str>) = mpsc::channel(100);
|
|
||||||
|
let mut global_reporter = None;
|
||||||
|
|
||||||
if let Some(p) = progress {
|
if let Some(p) = progress {
|
||||||
GameComponent::update_progress(
|
let max_size: u64 = checked_resources.iter().map(|r| r.size as u64).sum();
|
||||||
p,
|
|
||||||
resources.get_max_size_resources(),
|
global_reporter = Some(Arc::new(Mutex::new(GlobalReporter::new(p, max_size))));
|
||||||
output_dir.clone(),
|
global_reporter.clone().unwrap().lock().unwrap().setup();
|
||||||
rx,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for chunk_resource in checked_resources.chunks(5) {
|
for chunk_resource in checked_resources.chunks(threads_number) {
|
||||||
let mut output_path: Vec<PathBuf> = vec![];
|
let mut output_path: Vec<PathBuf> = vec![];
|
||||||
|
|
||||||
for path in chunk_resource
|
for path in chunk_resource
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| {
|
.map(|r| {
|
||||||
output_dir
|
output_dir
|
||||||
.join(r.dest.strip_prefix("/").unwrap())
|
.join(r.dest.clone())
|
||||||
.parent()
|
.parent()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_path_buf()
|
.to_path_buf()
|
||||||
@ -169,6 +173,10 @@ impl ComponentDownloader for GameComponent {
|
|||||||
);
|
);
|
||||||
dl.check_file_name = false;
|
dl.check_file_name = false;
|
||||||
|
|
||||||
|
if let Some(gr) = global_reporter.clone() {
|
||||||
|
dl = dl.progress(Arc::new(FileReporter::new(gr)));
|
||||||
|
}
|
||||||
|
|
||||||
dl
|
dl
|
||||||
})
|
})
|
||||||
.collect::<Vec<downloader::Download>>();
|
.collect::<Vec<downloader::Download>>();
|
||||||
@ -176,7 +184,9 @@ impl ComponentDownloader for GameComponent {
|
|||||||
downloader.async_download(&to_download).await?;
|
downloader.async_download(&to_download).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = tx.send("done").await;
|
if let Some(gr) = global_reporter {
|
||||||
|
gr.lock().unwrap().done();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(output_dir.clone())
|
Ok(output_dir.clone())
|
||||||
}
|
}
|
||||||
@ -188,3 +198,66 @@ impl ComponentDownloader for GameComponent {
|
|||||||
anyhow::bail!("How did you run this function??!!")
|
anyhow::bail!("How did you run this function??!!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct GlobalReporter<P: downloader::progress::Reporter + 'static> {
|
||||||
|
progress: Arc<P>,
|
||||||
|
pub to_download_max_size: u64,
|
||||||
|
current_progress: Mutex<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: downloader::progress::Reporter + 'static> GlobalReporter<P> {
|
||||||
|
pub fn new(progress: Arc<P>, max_size: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
progress,
|
||||||
|
to_download_max_size: max_size,
|
||||||
|
current_progress: Mutex::new(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn setup(&self) {
|
||||||
|
self.progress.setup(Some(self.to_download_max_size), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(&self, new_value: u64, old_value: u64) {
|
||||||
|
let mut current_progress = self.current_progress.lock().unwrap();
|
||||||
|
let current = current_progress.clone() + new_value - old_value;
|
||||||
|
*current_progress = current;
|
||||||
|
self.progress.progress(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn done(&self) {
|
||||||
|
self.progress.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FileReporter<P: downloader::progress::Reporter + 'static> {
|
||||||
|
global_reporter: Arc<Mutex<GlobalReporter<P>>>,
|
||||||
|
old_current: Mutex<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: downloader::progress::Reporter + 'static> FileReporter<P> {
|
||||||
|
pub fn new(global_reporter: Arc<Mutex<GlobalReporter<P>>>) -> Self {
|
||||||
|
Self {
|
||||||
|
global_reporter,
|
||||||
|
old_current: Mutex::new(0),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: downloader::progress::Reporter + 'static> Reporter for FileReporter<P> {
|
||||||
|
fn setup(&self, _: Option<u64>, _: &str) {}
|
||||||
|
|
||||||
|
fn progress(&self, current: u64) {
|
||||||
|
let p = self.global_reporter.lock().unwrap();
|
||||||
|
let mut old_current_guard = self.old_current.lock().unwrap();
|
||||||
|
let old_current = old_current_guard.clone();
|
||||||
|
|
||||||
|
*old_current_guard = current;
|
||||||
|
|
||||||
|
p.update(current, old_current);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_message(&self, _: &str) {}
|
||||||
|
|
||||||
|
fn done(&self) {}
|
||||||
|
}
|
||||||
|
|||||||
@ -106,16 +106,39 @@ impl ProtonComponent {
|
|||||||
|
|
||||||
pub fn init_proton(&self) -> Result<wincompatlib::prelude::Proton, String> {
|
pub fn init_proton(&self) -> Result<wincompatlib::prelude::Proton, String> {
|
||||||
let prefix = self.path.parent().unwrap().join("data");
|
let prefix = self.path.parent().unwrap().join("data");
|
||||||
let steam_location = dirs::home_dir().unwrap().join(".steam/steam");
|
|
||||||
if !steam_location.exists() {
|
|
||||||
debug!("Can't find steam installation");
|
|
||||||
return Err(String::from_str("We can't find your steam installation, please install steam in '~/.steam/steam' or specify your steam installation").unwrap());
|
|
||||||
}
|
|
||||||
let mut proton =
|
let mut proton =
|
||||||
wincompatlib::prelude::Proton::new(self.path.clone(), Some(prefix.clone()));
|
wincompatlib::prelude::Proton::new(self.path.clone(), Some(prefix.clone()));
|
||||||
|
let steam_location = Self::get_steam_location()?;
|
||||||
|
|
||||||
|
debug!("Steam location used -> {:?}", steam_location);
|
||||||
|
|
||||||
proton.steam_client_path = Some(steam_location);
|
proton.steam_client_path = Some(steam_location);
|
||||||
proton.init_prefix(Some(prefix)).unwrap();
|
proton.init_prefix(Some(prefix)).unwrap();
|
||||||
|
|
||||||
Ok(proton)
|
Ok(proton)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_steam_location() -> Result<PathBuf, String> {
|
||||||
|
let specified_steam_location = std::env::var("BT_STEAM_CLIENT_PATH");
|
||||||
|
if let Ok(location) = specified_steam_location {
|
||||||
|
return Ok(PathBuf::from(location));
|
||||||
|
}
|
||||||
|
|
||||||
|
let location_to_check = [
|
||||||
|
dirs::home_dir().unwrap().join(".steam/steam"),
|
||||||
|
dirs::home_dir()
|
||||||
|
.unwrap()
|
||||||
|
.join(".var/app/com.valvesoftware.Steam/steam"), // for the flatpak version of steam
|
||||||
|
];
|
||||||
|
|
||||||
|
for location in location_to_check {
|
||||||
|
if location.exists() {
|
||||||
|
return Ok(location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("Can't find steam installation");
|
||||||
|
Err(String::from_str("We can't find your steam installation, please install steam in '~/.steam/steam' or specify your steam installation").unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
105
babylonia-terminal-sdk/src/game_config.rs
Normal file
105
babylonia-terminal-sdk/src/game_config.rs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use dirs::home_dir;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tokio::{
|
||||||
|
fs::{create_dir_all, read_to_string, File},
|
||||||
|
io::AsyncWriteExt,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct GameConfig {
|
||||||
|
pub config_dir: PathBuf,
|
||||||
|
pub is_wine_installed: bool,
|
||||||
|
pub is_dxvk_installed: bool,
|
||||||
|
pub is_font_installed: bool,
|
||||||
|
pub is_dependecies_installed: bool,
|
||||||
|
pub game_dir: Option<PathBuf>,
|
||||||
|
pub is_game_installed: bool,
|
||||||
|
pub is_game_patched: bool,
|
||||||
|
pub launch_options: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GameConfig {
|
||||||
|
pub async fn get_config_directory() -> PathBuf {
|
||||||
|
let path = home_dir().unwrap().join(".babylonia-terminal"); // I will try to change that to a dynamic one if people want to change the config dir
|
||||||
|
|
||||||
|
let _ = create_dir_all(path.clone()).await;
|
||||||
|
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_config_file_path() -> PathBuf {
|
||||||
|
Self::get_config_directory()
|
||||||
|
.await
|
||||||
|
.join("babylonia-terminal-config")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_game_dir(path: Option<PathBuf>) -> anyhow::Result<()> {
|
||||||
|
let mut config = Self::get_config().await;
|
||||||
|
config.game_dir = path;
|
||||||
|
Self::save_config(config).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_game_dir() -> Option<PathBuf> {
|
||||||
|
Self::get_config().await.game_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn try_get_config_file() -> anyhow::Result<File> {
|
||||||
|
let _ = tokio::fs::create_dir(Self::get_config_directory().await).await;
|
||||||
|
|
||||||
|
Ok(tokio::fs::File::create(Self::get_config_file_path().await).await?)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn save_config(config: Self) -> anyhow::Result<()> {
|
||||||
|
let mut file = Self::try_get_config_file().await?;
|
||||||
|
let content = serde_json::to_string(&config)?;
|
||||||
|
file.write_all(content.as_bytes()).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_config() -> Self {
|
||||||
|
let content = match read_to_string(Self::get_config_file_path().await).await {
|
||||||
|
Err(_) => return Self::default(),
|
||||||
|
Ok(c) => c,
|
||||||
|
};
|
||||||
|
match serde_json::from_str::<Self>(&content) {
|
||||||
|
Ok(config) => return config,
|
||||||
|
Err(_) => return Self::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_launch_options(command: Option<String>) -> anyhow::Result<()> {
|
||||||
|
let mut config = Self::get_config().await;
|
||||||
|
config.launch_options = command;
|
||||||
|
Self::save_config(config).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_launch_options() -> anyhow::Result<Option<String>> {
|
||||||
|
Ok(Self::get_config().await.launch_options)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct GameConfigPath {
|
||||||
|
path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for GameConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
GameConfig {
|
||||||
|
config_dir: dirs::home_dir().unwrap().join(".babylonia-terminal"),
|
||||||
|
is_wine_installed: false,
|
||||||
|
is_dxvk_installed: false,
|
||||||
|
is_font_installed: false,
|
||||||
|
is_dependecies_installed: false,
|
||||||
|
game_dir: None,
|
||||||
|
is_game_installed: false,
|
||||||
|
is_game_patched: false,
|
||||||
|
launch_options: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,16 @@
|
|||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{
|
||||||
|
io::{BufRead, BufReader},
|
||||||
|
path::PathBuf,
|
||||||
|
process::{Child, Command, Stdio},
|
||||||
|
sync::{Arc, Mutex},
|
||||||
|
};
|
||||||
|
|
||||||
use downloader::progress::Reporter;
|
use downloader::progress::Reporter;
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use tokio::fs::create_dir_all;
|
use tokio::{
|
||||||
|
fs::{create_dir_all, remove_file, File, OpenOptions},
|
||||||
|
io::AsyncWriteExt,
|
||||||
|
};
|
||||||
use wincompatlib::prelude::*;
|
use wincompatlib::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -10,11 +18,27 @@ use crate::{
|
|||||||
component_downloader::ComponentDownloader, dxvk_component::DXVKComponent,
|
component_downloader::ComponentDownloader, dxvk_component::DXVKComponent,
|
||||||
game_component::GameComponent, proton_component::ProtonComponent,
|
game_component::GameComponent, proton_component::ProtonComponent,
|
||||||
},
|
},
|
||||||
|
game_config::GameConfig,
|
||||||
game_patcher,
|
game_patcher,
|
||||||
game_state::GameState,
|
|
||||||
utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester},
|
utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub struct EnvironmentVariable {
|
||||||
|
name: String,
|
||||||
|
value: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EnvironmentVariable {
|
||||||
|
pub fn parse(variable: &str) -> Self {
|
||||||
|
let split: Vec<&str> = variable.split('=').collect();
|
||||||
|
|
||||||
|
Self {
|
||||||
|
name: split[0].to_string(),
|
||||||
|
value: split[1].to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct GameManager;
|
pub struct GameManager;
|
||||||
|
|
||||||
impl GameManager {
|
impl GameManager {
|
||||||
@ -31,9 +55,9 @@ impl GameManager {
|
|||||||
|
|
||||||
wine_component.install(progress).await?;
|
wine_component.install(progress).await?;
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_wine_installed = true;
|
config.is_wine_installed = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(wine_component)
|
Ok(wine_component)
|
||||||
}
|
}
|
||||||
@ -52,9 +76,9 @@ impl GameManager {
|
|||||||
|
|
||||||
dxvk_component.install(progress).await?;
|
dxvk_component.install(progress).await?;
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_dxvk_installed = true;
|
config.is_dxvk_installed = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -67,45 +91,21 @@ impl GameManager {
|
|||||||
.wine()
|
.wine()
|
||||||
.clone()
|
.clone()
|
||||||
.with_prefix(proton.wine().prefix.parent().unwrap());
|
.with_prefix(proton.wine().prefix.parent().unwrap());
|
||||||
|
|
||||||
|
let max = 1;
|
||||||
|
|
||||||
if let Some(p) = &progress {
|
if let Some(p) = &progress {
|
||||||
p.setup(Some(10), "");
|
p.setup(Some(max), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_fonts_progress(0, &progress);
|
notify_fonts_progress(0, max, &progress);
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Arial)?;
|
wine_with_proton_prefix.install_font(Font::Arial)?;
|
||||||
notify_fonts_progress(1, &progress);
|
notify_fonts_progress(1, max, &progress);
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Andale)?;
|
let mut config = GameConfig::get_config().await;
|
||||||
notify_fonts_progress(2, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Courier)?;
|
|
||||||
notify_fonts_progress(3, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::ComicSans)?;
|
|
||||||
notify_fonts_progress(4, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Georgia)?;
|
|
||||||
notify_fonts_progress(5, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Impact)?;
|
|
||||||
notify_fonts_progress(6, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Times)?;
|
|
||||||
notify_fonts_progress(7, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Trebuchet)?;
|
|
||||||
notify_fonts_progress(8, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Verdana)?;
|
|
||||||
notify_fonts_progress(9, &progress);
|
|
||||||
|
|
||||||
wine_with_proton_prefix.install_font(Font::Webdings)?;
|
|
||||||
notify_fonts_progress(10, &progress);
|
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
|
||||||
config.is_font_installed = true;
|
config.is_font_installed = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -124,9 +124,9 @@ impl GameManager {
|
|||||||
.wait()
|
.wait()
|
||||||
.expect("Something failed when waiting for the installation");
|
.expect("Something failed when waiting for the installation");
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_dependecies_installed = true;
|
config.is_dependecies_installed = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -140,9 +140,9 @@ impl GameManager {
|
|||||||
let game_component = GameComponent::new(game_dir);
|
let game_component = GameComponent::new(game_dir);
|
||||||
game_component.install(Some(progress)).await?;
|
game_component.install(Some(progress)).await?;
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_game_installed = true;
|
config.is_game_installed = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -150,10 +150,10 @@ impl GameManager {
|
|||||||
// this function just pass is_game_installed and is_game_patched to false,
|
// this function just pass is_game_installed and is_game_patched to false,
|
||||||
// so the launcher on the next iteration download the new file and delete the old one with the check process in the installation process
|
// so the launcher on the next iteration download the new file and delete the old one with the check process in the installation process
|
||||||
pub async fn update_game() -> anyhow::Result<()> {
|
pub async fn update_game() -> anyhow::Result<()> {
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_game_installed = false;
|
config.is_game_installed = false;
|
||||||
config.is_game_patched = false;
|
config.is_game_patched = false;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -164,24 +164,193 @@ impl GameManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn start_game(proton: &Proton, game_dir: PathBuf) {
|
pub async fn start_game(
|
||||||
debug!("Wine version : {:?}", proton.wine().version().unwrap());
|
proton: &Proton,
|
||||||
let mut child = proton
|
game_dir: PathBuf,
|
||||||
.run(
|
options: Option<String>,
|
||||||
game_dir
|
env_variables: Vec<EnvironmentVariable>,
|
||||||
|
show_logs: bool,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let proton_version = proton.wine().version()?;
|
||||||
|
let binary_path = game_dir
|
||||||
.join(get_game_name())
|
.join(get_game_name())
|
||||||
.join(get_game_name_with_executable()),
|
.join(get_game_name_with_executable());
|
||||||
)
|
|
||||||
.unwrap();
|
debug!("Wine version : {:?}", proton_version);
|
||||||
child.wait().expect("The game failed to run");
|
|
||||||
|
let mut child = if let Some(custom_command) = options {
|
||||||
|
Self::run(proton, binary_path, Some(custom_command), env_variables).await?
|
||||||
|
} else {
|
||||||
|
if let Some(custom_command) = GameConfig::get_launch_options().await.unwrap() {
|
||||||
|
Self::run(proton, binary_path, Some(custom_command), env_variables).await?
|
||||||
|
} else {
|
||||||
|
Self::run(proton, binary_path, None, env_variables).await?
|
||||||
|
}
|
||||||
|
}?;
|
||||||
|
|
||||||
|
let log_stdout = Arc::new(Mutex::new(None));
|
||||||
|
let log_stderr = Arc::new(Mutex::new(None));
|
||||||
|
|
||||||
|
if show_logs {
|
||||||
|
let stderr = child.stderr.take().unwrap();
|
||||||
|
let stdout = child.stdout.take().unwrap();
|
||||||
|
|
||||||
|
let log_stdout_ref = log_stdout.clone();
|
||||||
|
let log_stderr_ref = log_stderr.clone();
|
||||||
|
|
||||||
|
tokio::task::spawn(async move {
|
||||||
|
let bufread = BufReader::new(stdout);
|
||||||
|
let mut stdout_save = String::new();
|
||||||
|
let _: Vec<_> = bufread
|
||||||
|
.lines()
|
||||||
|
.inspect(|s| {
|
||||||
|
if let Ok(str) = s {
|
||||||
|
info!("[Proton] > {}", str);
|
||||||
|
stdout_save.push_str(str);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
*log_stdout_ref.lock().unwrap() = Some(stdout_save);
|
||||||
|
});
|
||||||
|
tokio::task::spawn(async move {
|
||||||
|
let bufread = BufReader::new(stderr);
|
||||||
|
let mut stderr_save = String::new();
|
||||||
|
let _: Vec<_> = bufread
|
||||||
|
.lines()
|
||||||
|
.inspect(|s| {
|
||||||
|
if let Ok(str) = s {
|
||||||
|
info!("[Proton] > {}", str);
|
||||||
|
stderr_save.push_str(str);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
*log_stderr_ref.lock().unwrap() = Some(stderr_save);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = child
|
||||||
|
.wait_with_output()
|
||||||
|
.expect("Failed to wait for the process");
|
||||||
|
|
||||||
|
let log_file_path = GameConfig::get_config_directory().await.join("game.log");
|
||||||
|
if log_file_path.exists() {
|
||||||
|
remove_file(log_file_path.clone())
|
||||||
|
.await
|
||||||
|
.expect("Failed to remove old log file");
|
||||||
|
}
|
||||||
|
File::create(log_file_path.clone())
|
||||||
|
.await
|
||||||
|
.expect("Failed to create build file");
|
||||||
|
|
||||||
|
let mut log_file = OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.append(true)
|
||||||
|
.open(log_file_path)
|
||||||
|
.await
|
||||||
|
.expect("Failed to open the log file");
|
||||||
|
|
||||||
|
log_file
|
||||||
|
.write_all("--- stdout ---\n".as_bytes())
|
||||||
|
.await
|
||||||
|
.expect("Failed to write the output to the log file");
|
||||||
|
|
||||||
|
let log_stdout_value = log_stdout.lock().unwrap();
|
||||||
|
let v;
|
||||||
|
let to_write = if log_stdout_value.is_some() {
|
||||||
|
v = log_stdout_value.clone().unwrap();
|
||||||
|
v.as_bytes()
|
||||||
|
} else {
|
||||||
|
&output.stdout
|
||||||
|
};
|
||||||
|
|
||||||
|
log_file
|
||||||
|
.write_all(to_write)
|
||||||
|
.await
|
||||||
|
.expect("Failed to write the output to the log file");
|
||||||
|
|
||||||
|
log_file
|
||||||
|
.write_all("--- stderr ---\n".as_bytes())
|
||||||
|
.await
|
||||||
|
.expect("Failed to write the output to the log file");
|
||||||
|
|
||||||
|
let log_stderr_value = log_stderr.lock().unwrap();
|
||||||
|
let v;
|
||||||
|
let to_write = if log_stderr_value.is_some() {
|
||||||
|
debug!("test");
|
||||||
|
v = log_stderr_value.clone().unwrap();
|
||||||
|
v.as_bytes()
|
||||||
|
} else {
|
||||||
|
&output.stderr
|
||||||
|
};
|
||||||
|
|
||||||
|
log_file
|
||||||
|
.write_all(to_write)
|
||||||
|
.await
|
||||||
|
.expect("Failed to write the output to the log file");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run(
|
||||||
|
proton: &Proton,
|
||||||
|
binary_path: PathBuf,
|
||||||
|
custom_command: Option<String>,
|
||||||
|
env_variables: Vec<EnvironmentVariable>,
|
||||||
|
) -> anyhow::Result<Result<Child, std::io::Error>> {
|
||||||
|
let mut command: Vec<&str> = vec![];
|
||||||
|
|
||||||
|
let proton_path = GameConfig::get_config_directory()
|
||||||
|
.await
|
||||||
|
.join("proton")
|
||||||
|
.join("proton");
|
||||||
|
|
||||||
|
command.push(proton.python.to_str().unwrap());
|
||||||
|
command.push(proton_path.to_str().unwrap());
|
||||||
|
command.push("run");
|
||||||
|
command.push(binary_path.to_str().unwrap());
|
||||||
|
|
||||||
|
let launch_option;
|
||||||
|
if custom_command.is_some() {
|
||||||
|
launch_option = custom_command.unwrap();
|
||||||
|
debug!("Starting game with --options -> {}", launch_option.clone());
|
||||||
|
let tokens: Vec<&str> = launch_option.split_whitespace().collect();
|
||||||
|
|
||||||
|
// position of the %command%
|
||||||
|
let index = if let Some(v) = tokens.iter().position(|&s| s == "%command%") {
|
||||||
|
v
|
||||||
|
} else {
|
||||||
|
anyhow::bail!("You forget to put %command% in your custom launch command");
|
||||||
|
};
|
||||||
|
|
||||||
|
let start_command = tokens[0..index].to_vec();
|
||||||
|
let mut end_command = tokens[(index + 1)..tokens.len()].to_vec();
|
||||||
|
|
||||||
|
start_command.iter().rev().for_each(|str| {
|
||||||
|
command.insert(0, str);
|
||||||
|
});
|
||||||
|
command.append(&mut end_command);
|
||||||
|
} else {
|
||||||
|
debug!("Starting game without --options");
|
||||||
|
}
|
||||||
|
|
||||||
|
debug!("Command preview -> {}", command.join(" "));
|
||||||
|
|
||||||
|
Ok(Command::new(command[0])
|
||||||
|
.args(&command[1..command.len()])
|
||||||
|
.envs(proton.get_envs())
|
||||||
|
.env("PROTON_LOG", "1")
|
||||||
|
.stdin(Stdio::piped())
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped())
|
||||||
|
.spawn())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify_fonts_progress<P>(nbr: u64, progress: &Option<Arc<P>>)
|
fn notify_fonts_progress<P>(nbr: u64, max: u64, progress: &Option<Arc<P>>)
|
||||||
where
|
where
|
||||||
P: Reporter + 'static,
|
P: Reporter + 'static,
|
||||||
{
|
{
|
||||||
info!("{}", format!("{}/10 font installed", nbr));
|
info!("{}", format!("{}/{} font installed", nbr, max));
|
||||||
if let Some(p) = progress {
|
if let Some(p) = progress {
|
||||||
p.progress(nbr);
|
p.progress(nbr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use tokio::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
game_state::GameState,
|
game_config::GameConfig,
|
||||||
utils::{get_game_name, get_game_name_with_executable},
|
utils::{get_game_name, get_game_name_with_executable},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,9 +82,9 @@ pub async fn patch_game(game_dir: PathBuf) -> anyhow::Result<()> {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut config = GameState::get_config().await;
|
let mut config = GameConfig::get_config().await;
|
||||||
config.is_game_patched = true;
|
config.is_game_patched = true;
|
||||||
GameState::save_config(config).await?;
|
GameConfig::save_config(config).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,6 @@
|
|||||||
use dirs::home_dir;
|
use crate::{game_config::GameConfig, utils::kuro_prod_api::GameInfo};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use tokio::{
|
|
||||||
fs::{create_dir_all, read_to_string, File},
|
|
||||||
io::AsyncWriteExt,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::utils::kuro_prod_api::GameInfo;
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub enum GameState {
|
pub enum GameState {
|
||||||
ProtonNotInstalled,
|
ProtonNotInstalled,
|
||||||
DXVKNotInstalled,
|
DXVKNotInstalled,
|
||||||
@ -20,91 +12,9 @@ pub enum GameState {
|
|||||||
GameInstalled,
|
GameInstalled,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
pub struct GameConfig {
|
|
||||||
pub config_dir: PathBuf,
|
|
||||||
pub is_wine_installed: bool,
|
|
||||||
pub is_dxvk_installed: bool,
|
|
||||||
pub is_font_installed: bool,
|
|
||||||
pub is_dependecies_installed: bool,
|
|
||||||
pub game_dir: Option<PathBuf>,
|
|
||||||
pub is_game_installed: bool,
|
|
||||||
pub is_game_patched: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
pub struct GameConfigPath {
|
|
||||||
path: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for GameConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
GameConfig {
|
|
||||||
config_dir: dirs::home_dir().unwrap().join(".babylonia-terminal"),
|
|
||||||
is_wine_installed: false,
|
|
||||||
is_dxvk_installed: false,
|
|
||||||
is_font_installed: false,
|
|
||||||
is_dependecies_installed: false,
|
|
||||||
game_dir: None,
|
|
||||||
is_game_installed: false,
|
|
||||||
is_game_patched: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GameState {
|
impl GameState {
|
||||||
pub async fn get_config_directory() -> PathBuf {
|
|
||||||
let path = home_dir().unwrap().join(".babylonia-terminal"); // I will try to change that to a dynamic one if people want to change the config dir
|
|
||||||
|
|
||||||
let _ = create_dir_all(path.clone()).await;
|
|
||||||
|
|
||||||
path
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_config_file_path() -> PathBuf {
|
|
||||||
GameState::get_config_directory()
|
|
||||||
.await
|
|
||||||
.join("babylonia-terminal-config")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn set_game_dir(path: Option<PathBuf>) -> anyhow::Result<()> {
|
|
||||||
let mut config = GameState::get_config().await;
|
|
||||||
config.game_dir = path;
|
|
||||||
GameState::save_config(config).await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_game_dir() -> Option<PathBuf> {
|
|
||||||
GameState::get_config().await.game_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn try_get_config_file() -> anyhow::Result<File> {
|
|
||||||
let _ = tokio::fs::create_dir(GameState::get_config_directory().await).await;
|
|
||||||
|
|
||||||
Ok(tokio::fs::File::create(GameState::get_config_file_path().await).await?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn save_config(config: GameConfig) -> anyhow::Result<()> {
|
|
||||||
let mut file = GameState::try_get_config_file().await?;
|
|
||||||
let content = serde_json::to_string(&config)?;
|
|
||||||
file.write_all(content.as_bytes()).await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_config() -> GameConfig {
|
|
||||||
let content = match read_to_string(GameState::get_config_file_path().await).await {
|
|
||||||
Err(_) => return GameConfig::default(),
|
|
||||||
Ok(c) => c,
|
|
||||||
};
|
|
||||||
match serde_json::from_str::<GameConfig>(&content) {
|
|
||||||
Ok(config) => return config,
|
|
||||||
Err(_) => return GameConfig::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_current_state() -> anyhow::Result<Self> {
|
pub async fn get_current_state() -> anyhow::Result<Self> {
|
||||||
let config = GameState::get_config().await;
|
let config = GameConfig::get_config().await;
|
||||||
|
|
||||||
if !config.is_wine_installed {
|
if !config.is_wine_installed {
|
||||||
return Ok(GameState::ProtonNotInstalled);
|
return Ok(GameState::ProtonNotInstalled);
|
||||||
@ -136,4 +46,11 @@ impl GameState {
|
|||||||
|
|
||||||
Ok(GameState::GameInstalled)
|
Ok(GameState::GameInstalled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_environment_ready(&self) -> bool {
|
||||||
|
self == &GameState::GameNotInstalled
|
||||||
|
|| self == &GameState::GameNeedUpdate
|
||||||
|
|| self == &GameState::GameNotPatched
|
||||||
|
|| self == &GameState::GameInstalled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
pub mod components;
|
pub mod components;
|
||||||
|
pub mod game_config;
|
||||||
pub mod game_manager;
|
pub mod game_manager;
|
||||||
pub mod game_patcher;
|
pub mod game_patcher;
|
||||||
pub mod game_state;
|
pub mod game_state;
|
||||||
|
|||||||
@ -1,19 +1,40 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use log::debug;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use serde_json::Value;
|
||||||
use tokio::fs::read_to_string;
|
use tokio::fs::read_to_string;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
|
||||||
use crate::game_state::GameState;
|
use crate::game_config::GameConfig;
|
||||||
|
|
||||||
// start data ---------------------------------------------------------------------
|
// start data ---------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct GameInfo {
|
pub struct GameInfo {
|
||||||
pub default: Default,
|
pub chunk_download_switch: i64,
|
||||||
|
pub key_file_check_switch: i64,
|
||||||
|
pub resources_login: ResourcesLogin,
|
||||||
|
pub check_exe_is_running: i64,
|
||||||
pub hash_cache_check_acc_switch: i64,
|
pub hash_cache_check_acc_switch: i64,
|
||||||
|
pub fingerprints: Vec<String>,
|
||||||
|
pub default: Default,
|
||||||
|
#[serde(rename = "RHIOptionSwitch")]
|
||||||
|
pub rhioption_switch: i64,
|
||||||
|
pub predownload_switch: i64,
|
||||||
|
#[serde(rename = "RHIOptionList")]
|
||||||
|
pub rhioption_list: Vec<Value>,
|
||||||
|
pub experiment: Experiment,
|
||||||
|
pub key_file_check_list: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ResourcesLogin {
|
||||||
|
pub host: String,
|
||||||
|
pub login_switch: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
@ -21,33 +42,82 @@ pub struct GameInfo {
|
|||||||
pub struct Default {
|
pub struct Default {
|
||||||
pub cdn_list: Vec<CdnList>,
|
pub cdn_list: Vec<CdnList>,
|
||||||
pub changelog: Changelog,
|
pub changelog: Changelog,
|
||||||
|
pub changelog_visible: i64,
|
||||||
|
pub config: Config,
|
||||||
pub resources: String,
|
pub resources: String,
|
||||||
pub resources_base_path: String,
|
pub resources_base_path: String,
|
||||||
pub resources_diff: ResourcesDiff,
|
pub resources_diff: ResourcesDiff,
|
||||||
pub resources_exclude_path: Vec<String>,
|
pub resources_exclude_path: Vec<String>,
|
||||||
pub resources_exclude_path_need_update: Vec<String>,
|
pub resources_exclude_path_need_update: Vec<String>,
|
||||||
pub sample_hash_switch: i64,
|
|
||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CdnList {
|
pub struct CdnList {
|
||||||
|
#[serde(rename = "P")]
|
||||||
|
pub p: i64,
|
||||||
#[serde(rename = "K1")]
|
#[serde(rename = "K1")]
|
||||||
pub k1: i64,
|
pub k1: i64,
|
||||||
#[serde(rename = "K2")]
|
#[serde(rename = "K2")]
|
||||||
pub k2: i64,
|
pub k2: i64,
|
||||||
#[serde(rename = "P")]
|
|
||||||
pub p: i64,
|
|
||||||
pub url: String,
|
pub url: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Changelog {
|
pub struct Changelog {}
|
||||||
#[serde(rename = "zh-Hans")]
|
|
||||||
pub zh_hans: String,
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub en: String,
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Config {
|
||||||
|
pub index_file_md5: String,
|
||||||
|
pub un_compress_size: i64,
|
||||||
|
pub base_url: String,
|
||||||
|
pub size: i64,
|
||||||
|
pub patch_type: String,
|
||||||
|
pub zip_config: ZipConfig,
|
||||||
|
pub index_file: String,
|
||||||
|
pub resources_exclude_path_need_update: Vec<String>,
|
||||||
|
pub version: String,
|
||||||
|
pub resources_exclude_path: Vec<String>,
|
||||||
|
pub patch_config: Vec<PatchConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ZipConfig {
|
||||||
|
pub index_file_md5: String,
|
||||||
|
pub un_compress_size: i64,
|
||||||
|
pub ext: Ext,
|
||||||
|
pub base_url: String,
|
||||||
|
pub size: i64,
|
||||||
|
pub index_file: String,
|
||||||
|
pub version: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Ext {
|
||||||
|
pub max_file_size: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PatchConfig {
|
||||||
|
pub index_file_md5: String,
|
||||||
|
pub un_compress_size: i64,
|
||||||
|
pub ext: Ext2,
|
||||||
|
pub base_url: String,
|
||||||
|
pub size: i64,
|
||||||
|
pub index_file: String,
|
||||||
|
pub version: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Ext2 {
|
||||||
|
pub max_file_size: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
@ -73,13 +143,36 @@ pub struct PreviousGameInfo {
|
|||||||
pub version: String,
|
pub version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Experiment {
|
||||||
|
pub download: Download,
|
||||||
|
#[serde(rename = "res_check")]
|
||||||
|
pub res_check: ResCheck,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Download {
|
||||||
|
pub download_cdn_select_test_duration: String,
|
||||||
|
pub download_read_block_timeout: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct ResCheck {
|
||||||
|
pub file_chunk_check_switch: String,
|
||||||
|
pub file_size_check_switch: String,
|
||||||
|
pub res_valid_check_time_out: String,
|
||||||
|
pub file_check_white_list_config: String,
|
||||||
|
}
|
||||||
|
|
||||||
// Resources ---------------------------------------------------------------------
|
// Resources ---------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Resources {
|
pub struct Resources {
|
||||||
pub resource: Vec<Resource>,
|
pub resource: Vec<Resource>,
|
||||||
pub sample_hash_info: SampleHashInfo,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
@ -87,7 +180,6 @@ pub struct Resources {
|
|||||||
pub struct Resource {
|
pub struct Resource {
|
||||||
pub dest: String,
|
pub dest: String,
|
||||||
pub md5: String,
|
pub md5: String,
|
||||||
pub sample_hash: String,
|
|
||||||
pub size: i64,
|
pub size: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +191,11 @@ pub struct SampleHashInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// end data ---------------------------------------------------------------------
|
// end data ---------------------------------------------------------------------
|
||||||
|
|
||||||
static URL: &str = concat!(
|
static URL: &str = concat!(
|
||||||
"https://prod-alicdn-gamestarter.k",
|
"https://prod-alicdn-gamestarter.k",
|
||||||
"uro",
|
"uro",
|
||||||
"gam",
|
"gam",
|
||||||
"e.com/pcstarter/prod/game/G143/4/index.json"
|
"e.com/launcher/game/G143/50015_LWdk9D2Ep9mpJmqBZZkcPBU2YNraEWBQ/index.json"
|
||||||
);
|
);
|
||||||
|
|
||||||
impl GameInfo {
|
impl GameInfo {
|
||||||
@ -137,13 +228,16 @@ impl GameInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_resource_base_path(&self) -> String {
|
pub fn get_resource_base_path(&self) -> String {
|
||||||
self.default.resources_base_path.clone()
|
let mut result = self.default.resources_base_path.clone();
|
||||||
|
result.push('/');
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn fetch_resources(&self) -> anyhow::Result<Resources> {
|
pub async fn fetch_resources(&self) -> anyhow::Result<Resources> {
|
||||||
let resources_base_url = self.get_first_cdn();
|
let resources_base_url = self.get_first_cdn();
|
||||||
let resources_path_url = &self.default.resources;
|
let resources_path_url = &self.default.resources;
|
||||||
let resources_url = format!("{}{}", resources_base_url, resources_path_url);
|
let resources_url = format!("{}{}", resources_base_url, resources_path_url);
|
||||||
|
debug!("{}", &resources_url);
|
||||||
|
|
||||||
let response = reqwest::get(&resources_url).await?;
|
let response = reqwest::get(&resources_url).await?;
|
||||||
let body = response.text().await?;
|
let body = response.text().await?;
|
||||||
@ -157,13 +251,13 @@ impl GameInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_cache_file_path() -> PathBuf {
|
async fn get_cache_file_path() -> PathBuf {
|
||||||
GameState::get_config_directory()
|
GameConfig::get_config_directory()
|
||||||
.await
|
.await
|
||||||
.join("version-cache")
|
.join("version-cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn save_in_cache(&self) -> anyhow::Result<()> {
|
async fn save_in_cache(&self) -> anyhow::Result<()> {
|
||||||
let _ = tokio::fs::create_dir(GameState::get_config_directory().await).await;
|
let _ = tokio::fs::create_dir(GameConfig::get_config_directory().await).await;
|
||||||
let mut file = tokio::fs::File::create(GameInfo::get_cache_file_path().await).await?;
|
let mut file = tokio::fs::File::create(GameInfo::get_cache_file_path().await).await?;
|
||||||
|
|
||||||
let content = serde_json::to_string(self)?;
|
let content = serde_json::to_string(self)?;
|
||||||
|
|||||||
12
babylonia-terminal/Cargo.toml
Normal file
12
babylonia-terminal/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "babylonia-terminal"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
babylonia-terminal-gui = { path = "./../babylonia-terminal-gui" }
|
||||||
|
babylonia-terminal-cli = { path = "./../babylonia-terminal-cli" }
|
||||||
|
log = "0.4.22"
|
||||||
|
simple_logger = "5.0.0"
|
||||||
|
tokio = { version = "1.37.0", features = ["full"] }
|
||||||
|
clap = "4.5.23"
|
||||||
28
babylonia-terminal/src/main.rs
Normal file
28
babylonia-terminal/src/main.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
use clap::Parser;
|
||||||
|
use log::{debug, info, LevelFilter};
|
||||||
|
use simple_logger::SimpleLogger;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args = babylonia_terminal_cli::arguments::Args::parse();
|
||||||
|
|
||||||
|
let simple_logger = SimpleLogger::new()
|
||||||
|
.with_module_level("hyper", LevelFilter::Off)
|
||||||
|
.with_module_level("hyper_util", LevelFilter::Off)
|
||||||
|
.with_module_level("tracing", LevelFilter::Off)
|
||||||
|
.with_module_level("rustls", LevelFilter::Off)
|
||||||
|
.with_module_level("minreq", LevelFilter::Off)
|
||||||
|
.with_module_level("tokio_utils", LevelFilter::Off);
|
||||||
|
|
||||||
|
if args.debug || cfg!(debug_assertions) {
|
||||||
|
simple_logger.init().unwrap();
|
||||||
|
info!("Debug messages enabled");
|
||||||
|
} else {
|
||||||
|
simple_logger.with_level(LevelFilter::Info).init().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if args.gui {
|
||||||
|
babylonia_terminal_gui::run();
|
||||||
|
} else {
|
||||||
|
babylonia_terminal_cli::run();
|
||||||
|
}
|
||||||
|
}
|
||||||
56
babylonia_terminal_launcher/.gitignore
vendored
56
babylonia_terminal_launcher/.gitignore
vendored
@ -1,56 +0,0 @@
|
|||||||
# Miscellaneous
|
|
||||||
*.class
|
|
||||||
*.log
|
|
||||||
*.pyc
|
|
||||||
*.swp
|
|
||||||
.DS_Store
|
|
||||||
.atom/
|
|
||||||
.buildlog/
|
|
||||||
.history
|
|
||||||
.svn/
|
|
||||||
migrate_working_dir/
|
|
||||||
|
|
||||||
# IntelliJ related
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
|
||||||
# VS Code which you may wish to be included in version control, so this line
|
|
||||||
# is commented out by default.
|
|
||||||
#.vscode/
|
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
|
||||||
**/doc/api/
|
|
||||||
**/ios/Flutter/.last_build_id
|
|
||||||
.dart_tool/
|
|
||||||
.flutter-plugins
|
|
||||||
.flutter-plugins-dependencies
|
|
||||||
.pub-cache/
|
|
||||||
.pub/
|
|
||||||
/build/
|
|
||||||
|
|
||||||
# Symbolication related
|
|
||||||
app.*.symbols
|
|
||||||
|
|
||||||
# Obfuscation related
|
|
||||||
app.*.map.json
|
|
||||||
|
|
||||||
# Android Studio will place build artifacts here
|
|
||||||
/android/app/debug
|
|
||||||
/android/app/profile
|
|
||||||
/android/app/release
|
|
||||||
|
|
||||||
# Ignore platforms
|
|
||||||
/linux
|
|
||||||
|
|
||||||
# Misc
|
|
||||||
/test
|
|
||||||
|
|
||||||
# Rust related
|
|
||||||
.cargo/
|
|
||||||
target/
|
|
||||||
|
|
||||||
# Generated messages
|
|
||||||
*/**/messages/
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
# This file tracks properties of this Flutter project.
|
|
||||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
|
||||||
#
|
|
||||||
# This file should be version controlled and should not be manually edited.
|
|
||||||
|
|
||||||
version:
|
|
||||||
revision: "54e66469a933b60ddf175f858f82eaeb97e48c8d"
|
|
||||||
channel: "stable"
|
|
||||||
|
|
||||||
project_type: app
|
|
||||||
|
|
||||||
# Tracks metadata for the flutter migrate command
|
|
||||||
migration:
|
|
||||||
platforms:
|
|
||||||
- platform: root
|
|
||||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
|
||||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
|
||||||
- platform: linux
|
|
||||||
create_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
|
||||||
base_revision: 54e66469a933b60ddf175f858f82eaeb97e48c8d
|
|
||||||
|
|
||||||
# User provided section
|
|
||||||
|
|
||||||
# List of Local paths (relative to this file) that should be
|
|
||||||
# ignored by the migrate tool.
|
|
||||||
#
|
|
||||||
# Files that are not part of the templates will be ignored by default.
|
|
||||||
unmanaged_files:
|
|
||||||
- 'lib/main.dart'
|
|
||||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
# This file is used for telling Rust-related tools
|
|
||||||
# where various Rust crates are.
|
|
||||||
# This also unifies `./target` output folder and
|
|
||||||
# various Rust configurations.
|
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = ["./native/*"]
|
|
||||||
resolver = "2"
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
# How to compile the GUI version
|
|
||||||
|
|
||||||
!! **Disclaimer :** this might not work on your steam deck, a pre-compiled binary or Flatpak version will be distributed in the future !!
|
|
||||||
|
|
||||||
## Requirement
|
|
||||||
|
|
||||||
You need the [base](https://github.com/ALEZ-DEV/Babylonia-terminal?tab=readme-ov-file#requirement) requirement
|
|
||||||
You will need [Flutter](https://flutter.dev/) in order to compile the GUI version
|
|
||||||
Install [Rinf](https://github.com/cunarist/rinf) with **Cargo** :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo install rinf
|
|
||||||
```
|
|
||||||
|
|
||||||
And check if all the requirement are installed successfully :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
rustc --version
|
|
||||||
flutter doctor
|
|
||||||
```
|
|
||||||
|
|
||||||
## Compile
|
|
||||||
|
|
||||||
First generate all the necessary messages :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
rinf message
|
|
||||||
```
|
|
||||||
|
|
||||||
Then compile the project :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
flutter run
|
|
||||||
```
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
# This file configures the analyzer, which statically analyzes Dart code to
|
|
||||||
# check for errors, warnings, and lints.
|
|
||||||
#
|
|
||||||
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
|
||||||
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
|
||||||
# invoked from the command line by running `flutter analyze`.
|
|
||||||
|
|
||||||
# The following line activates a set of recommended lints for Flutter apps,
|
|
||||||
# packages, and plugins designed to encourage good coding practices.
|
|
||||||
include: package:flutter_lints/flutter.yaml
|
|
||||||
|
|
||||||
linter:
|
|
||||||
# The lint rules applied to this project can be customized in the
|
|
||||||
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
|
||||||
# included above or to enable additional rules. A list of all available lints
|
|
||||||
# and their documentation is published at https://dart.dev/lints.
|
|
||||||
#
|
|
||||||
# Instead of disabling a lint rule for the entire project in the
|
|
||||||
# section below, it can also be suppressed for a single line of code
|
|
||||||
# or a specific dart file by using the `// ignore: name_of_lint` and
|
|
||||||
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
|
||||||
# producing the lint.
|
|
||||||
rules:
|
|
||||||
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
|
||||||
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
|
||||||
# https://dart.dev/guides/language/analysis-options
|
|
||||||
@ -1,125 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './screens/screens.dart';
|
|
||||||
import './screens/setup_screen.dart';
|
|
||||||
import './providers/providers.dart';
|
|
||||||
import './models/error_reporter.dart';
|
|
||||||
import './models/game.dart';
|
|
||||||
|
|
||||||
class BabyloniaLauncher extends StatelessWidget {
|
|
||||||
BabyloniaLauncher(
|
|
||||||
{super.key,
|
|
||||||
required this.settingsProvider,
|
|
||||||
required this.gameStateProvider});
|
|
||||||
final SettingsProvider settingsProvider;
|
|
||||||
final GameStateProvider gameStateProvider;
|
|
||||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
ErrorReporter.listenAllRustError(navigatorKey);
|
|
||||||
gameStateProvider.updateSetup();
|
|
||||||
return MultiProvider(
|
|
||||||
providers: [
|
|
||||||
ChangeNotifierProvider(
|
|
||||||
create: (context) => settingsProvider,
|
|
||||||
),
|
|
||||||
ChangeNotifierProvider(
|
|
||||||
create: (context) => gameStateProvider,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: YaruTheme(
|
|
||||||
builder: (context, yaru, child) => MaterialApp(
|
|
||||||
navigatorKey: navigatorKey,
|
|
||||||
title: "Babylonia Terminal",
|
|
||||||
debugShowCheckedModeBanner: false,
|
|
||||||
theme: yaru.theme,
|
|
||||||
darkTheme: yaru.darkTheme,
|
|
||||||
themeMode: ThemeMode.system,
|
|
||||||
highContrastTheme: yaruHighContrastLight,
|
|
||||||
highContrastDarkTheme: yaruHighContrastDark,
|
|
||||||
home: Provider.of<GameStateProvider>(context).haveToSetup
|
|
||||||
? const SetupScreen()
|
|
||||||
: const Menu(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Menu extends StatefulWidget {
|
|
||||||
const Menu({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Menu> createState() => _MenuState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MenuState extends State<Menu> {
|
|
||||||
int _selectedIndex = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
List<Widget> items = Screens.drawerItem(
|
|
||||||
selectedIndex: _selectedIndex,
|
|
||||||
onSelected: (index) {
|
|
||||||
setState(() => _selectedIndex = index);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
items.insert(
|
|
||||||
0,
|
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
border: Border(
|
|
||||||
bottom: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 8.0,
|
|
||||||
horizontal: 50.0,
|
|
||||||
),
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/images/Lee6.png',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
"Babylonia Terminal",
|
|
||||||
style: TextStyle(fontSize: 24),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return ChangeNotifierProvider(
|
|
||||||
create: (context) => Game(),
|
|
||||||
child: Scaffold(
|
|
||||||
drawer: Drawer(
|
|
||||||
child: ListView(
|
|
||||||
children: items,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("Babylonia Terminal"),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: Screens.getCurrent(_selectedIndex),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:media_kit/media_kit.dart';
|
|
||||||
|
|
||||||
import './app.dart';
|
|
||||||
import './messages/generated.dart';
|
|
||||||
import './providers/providers.dart';
|
|
||||||
|
|
||||||
void main() async {
|
|
||||||
await initializeRust();
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
MediaKit.ensureInitialized();
|
|
||||||
|
|
||||||
final SettingsProvider settings = SettingsProvider();
|
|
||||||
await settings.init();
|
|
||||||
|
|
||||||
final GameStateProvider gameState = GameStateProvider();
|
|
||||||
await gameState.updateGameState();
|
|
||||||
|
|
||||||
runApp(BabyloniaLauncher(
|
|
||||||
settingsProvider: settings,
|
|
||||||
gameStateProvider: gameState,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:babylonia_terminal_launcher/models/config.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
class Background {
|
|
||||||
String path;
|
|
||||||
|
|
||||||
Background._({required this.path});
|
|
||||||
|
|
||||||
static Future<Background> get(SettingsProvider provider) async {
|
|
||||||
final json = await _fetchMainMenu();
|
|
||||||
final info = json['pcTopPicture'];
|
|
||||||
final backgroundId = info['topPictureId'];
|
|
||||||
final videoLink = info['backgroundVideo'];
|
|
||||||
final path = "${Config.instance.path}/background.mp4";
|
|
||||||
|
|
||||||
if (provider.backgroundId == null ||
|
|
||||||
provider.backgroundId != backgroundId) {
|
|
||||||
provider.backgroundId = backgroundId;
|
|
||||||
|
|
||||||
await _updateVideo(videoLink, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Background._(path: path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<Map<String, dynamic>> _fetchMainMenu() async {
|
|
||||||
// ignore: prefer_interpolation_to_compose_strings, prefer_adjacent_string_concatenation
|
|
||||||
final response = await http.get(
|
|
||||||
Uri.parse('https://media-cdn-zspms.' +
|
|
||||||
'k' +
|
|
||||||
'u' +
|
|
||||||
'r' +
|
|
||||||
'o' +
|
|
||||||
'game.net/pnswebsite/website2.0/json/G167/MainMenu.json'),
|
|
||||||
);
|
|
||||||
return jsonDecode(response.body);
|
|
||||||
}
|
|
||||||
|
|
||||||
static _updateVideo(String link, String path) async {
|
|
||||||
final response = await http.get(Uri.parse(link));
|
|
||||||
final file = File(path);
|
|
||||||
if (await file.exists()) {
|
|
||||||
// just to be sure to overwrite the file
|
|
||||||
await file.delete();
|
|
||||||
await file.create();
|
|
||||||
}
|
|
||||||
await file.writeAsBytes(response.bodyBytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/messages/config.pb.dart';
|
|
||||||
|
|
||||||
class Config {
|
|
||||||
String path;
|
|
||||||
|
|
||||||
static late Config instance;
|
|
||||||
Config._({required this.path});
|
|
||||||
|
|
||||||
static bool _isLoadingConfig = false;
|
|
||||||
|
|
||||||
static Future update() async {
|
|
||||||
if (!_isLoadingConfig) {
|
|
||||||
_isLoadingConfig = true;
|
|
||||||
ConfigInput().sendSignalToRust();
|
|
||||||
final stream = ConfigOutput.rustSignalStream;
|
|
||||||
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
instance = Config._(
|
|
||||||
path: rustSignal.message.configPath,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_isLoadingConfig = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../messages/steps/dependencies.pb.dart';
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
enum DependenciesInstallationState {
|
|
||||||
idle,
|
|
||||||
installing,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Dependencies with ChangeNotifier {
|
|
||||||
DependenciesInstallationState dependeciesState =
|
|
||||||
DependenciesInstallationState.idle;
|
|
||||||
|
|
||||||
Future startInstallation(GameStateProvider gameState) async {
|
|
||||||
StartDependenciesInstallation().sendSignalToRust();
|
|
||||||
final stream = NotifyDependenciesSuccessfullyInstalled.rustSignalStream;
|
|
||||||
await for (final _ in stream) {
|
|
||||||
gameState.updateGameState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
import 'package:fixnum/fixnum.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../messages/steps/dxvk.pb.dart';
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
enum DXVKInstallationState {
|
|
||||||
idle,
|
|
||||||
downloading,
|
|
||||||
decompressing,
|
|
||||||
}
|
|
||||||
|
|
||||||
class DXVK with ChangeNotifier {
|
|
||||||
DXVKInstallationState dxvkState = DXVKInstallationState.idle;
|
|
||||||
|
|
||||||
Int64 currentProgress = Int64(0);
|
|
||||||
Int64 maxProgress = Int64(0);
|
|
||||||
|
|
||||||
Future startInstallation(
|
|
||||||
GameStateProvider gameStateProvider, String protonVersion) async {
|
|
||||||
StartDXVKInstallation(protonVersion: protonVersion).sendSignalToRust();
|
|
||||||
final progressStream = DXVKDownloadProgress.rustSignalStream;
|
|
||||||
await for (final rustSignal in progressStream) {
|
|
||||||
currentProgress = rustSignal.message.current;
|
|
||||||
maxProgress = rustSignal.message.max;
|
|
||||||
|
|
||||||
if (dxvkState == DXVKInstallationState.idle) {
|
|
||||||
dxvkState = DXVKInstallationState.downloading;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
if (currentProgress >= maxProgress) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final notificationDecompressingStream =
|
|
||||||
NotifyDXVKStartDecompressing.rustSignalStream;
|
|
||||||
await for (final _ in notificationDecompressingStream) {
|
|
||||||
dxvkState = DXVKInstallationState.decompressing;
|
|
||||||
notifyListeners();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
final notificationInstalledStream =
|
|
||||||
NotifyDXVKSuccessfullyInstalled.rustSignalStream;
|
|
||||||
await for (final _ in notificationInstalledStream) {
|
|
||||||
gameStateProvider.updateGameState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_highlight/flutter_highlight.dart';
|
|
||||||
import 'package:flutter_highlight/themes/vs.dart';
|
|
||||||
import 'package:flutter_highlight/themes/vs2015.dart';
|
|
||||||
import 'package:yaru/icons.dart';
|
|
||||||
import 'package:yaru/widgets.dart';
|
|
||||||
|
|
||||||
import './../messages/error.pb.dart';
|
|
||||||
|
|
||||||
class ErrorReporter {
|
|
||||||
static Future listenAllRustError(
|
|
||||||
GlobalKey<NavigatorState> navigatorState) async {
|
|
||||||
final stream = ReportError.rustSignalStream;
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
final context = navigatorState.currentState!.overlay!.context;
|
|
||||||
await showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
titlePadding: EdgeInsets.zero,
|
|
||||||
title: YaruDialogTitleBar(
|
|
||||||
title: const Text('Error'),
|
|
||||||
isClosable: true,
|
|
||||||
leading: Center(
|
|
||||||
child: YaruIconButton(
|
|
||||||
icon: const Icon(YaruIcons.copy),
|
|
||||||
tooltip: 'Copy',
|
|
||||||
onPressed: () async {
|
|
||||||
Clipboard.setData(
|
|
||||||
ClipboardData(text: rustSignal.message.errorMessage),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
content: SizedBox(
|
|
||||||
height: 400,
|
|
||||||
width: 700,
|
|
||||||
child: HighlightView(
|
|
||||||
rustSignal.message.errorMessage,
|
|
||||||
language: '',
|
|
||||||
theme: Theme.of(context).brightness == Brightness.dark
|
|
||||||
? vs2015Theme
|
|
||||||
: vsTheme,
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
textStyle: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
import 'package:fixnum/fixnum.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../messages/steps/fonts.pb.dart';
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
enum FontsInstallationState {
|
|
||||||
idle,
|
|
||||||
installing,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Fonts with ChangeNotifier {
|
|
||||||
FontsInstallationState fontsState = FontsInstallationState.idle;
|
|
||||||
|
|
||||||
Int64 currentProgress = Int64(0);
|
|
||||||
Int64 maxProgress = Int64(0);
|
|
||||||
|
|
||||||
Future startInstallation(GameStateProvider gameState) async {
|
|
||||||
StartFontsInstallation().sendSignalToRust();
|
|
||||||
final stream = FontsInstallationProgress.rustSignalStream;
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
maxProgress = rustSignal.message.max;
|
|
||||||
currentProgress = rustSignal.message.current;
|
|
||||||
|
|
||||||
if (fontsState == FontsInstallationState.idle) {
|
|
||||||
fontsState = FontsInstallationState.installing;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
if (currentProgress >= maxProgress) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gameState.updateGameState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,77 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/messages/steps/game.pb.dart';
|
|
||||||
import 'package:fixnum/fixnum.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
enum GameInstallationState {
|
|
||||||
idle,
|
|
||||||
checkingFile,
|
|
||||||
downloading,
|
|
||||||
patching,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum GameRunState {
|
|
||||||
idle,
|
|
||||||
running,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Game with ChangeNotifier {
|
|
||||||
GameInstallationState gameInstallationState = GameInstallationState.idle;
|
|
||||||
GameRunState gameRunState = GameRunState.idle;
|
|
||||||
|
|
||||||
Int64 currentProgress = Int64(0);
|
|
||||||
Int64 maxProgress = Int64(0);
|
|
||||||
|
|
||||||
Future startInstallation(GameStateProvider gameState, bool isUpdating) async {
|
|
||||||
StartGameInstallation(isUpdating: isUpdating).sendSignalToRust();
|
|
||||||
gameInstallationState = GameInstallationState.checkingFile;
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
//final downloadStream = NotifyGameStartDownloading.rustSignalStream;
|
|
||||||
//await for (final _ in downloadStream) {
|
|
||||||
// gameInstallationState = GameInstallationState.downloading;
|
|
||||||
// notifyListeners();
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
|
|
||||||
final downloadProgresStream = GameInstallationProgress.rustSignalStream;
|
|
||||||
await for (final rustSignal in downloadProgresStream) {
|
|
||||||
if (gameInstallationState == GameInstallationState.checkingFile) {
|
|
||||||
gameInstallationState = GameInstallationState.downloading;
|
|
||||||
}
|
|
||||||
|
|
||||||
currentProgress = rustSignal.message.current;
|
|
||||||
maxProgress = rustSignal.message.max;
|
|
||||||
print("progress current : $currentProgress / $maxProgress");
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
if (currentProgress >= maxProgress) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print("patching game...");
|
|
||||||
gameInstallationState = GameInstallationState.patching;
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
final successStream = NotifyGameSuccessfullyInstalled.rustSignalStream;
|
|
||||||
await for (final _ in successStream) {
|
|
||||||
gameState.updateGameState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future startGame() async {
|
|
||||||
RunGame().sendSignalToRust();
|
|
||||||
gameRunState = GameRunState.running;
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
final stream = GameStopped.rustSignalStream;
|
|
||||||
await for (final _ in stream) {
|
|
||||||
gameRunState = GameRunState.idle;
|
|
||||||
notifyListeners();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/messages/github.pb.dart';
|
|
||||||
|
|
||||||
class Github {
|
|
||||||
static bool _isFetchingProtonVersions = false;
|
|
||||||
static bool _isFetchingDXVKVersions = false;
|
|
||||||
|
|
||||||
static Future<List<String>> getProtonVersions() async {
|
|
||||||
if (!_isFetchingProtonVersions) {
|
|
||||||
_isFetchingProtonVersions = true;
|
|
||||||
AskProtonVersions().sendSignalToRust();
|
|
||||||
final stream = ProtonVersions.rustSignalStream;
|
|
||||||
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
_isFetchingProtonVersions = false;
|
|
||||||
return rustSignal.message.versions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<List<String>> getDXVKVersions() async {
|
|
||||||
if (!_isFetchingDXVKVersions) {
|
|
||||||
_isFetchingDXVKVersions = true;
|
|
||||||
AskDXVKVersions().sendSignalToRust();
|
|
||||||
final stream = DXVKVersions.rustSignalStream;
|
|
||||||
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
_isFetchingDXVKVersions = false;
|
|
||||||
return rustSignal.message.versions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
import 'package:fixnum/fixnum.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../messages/steps/proton.pb.dart';
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
|
|
||||||
enum ProtonInstallationState {
|
|
||||||
idle,
|
|
||||||
downloading,
|
|
||||||
decompressing,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Proton with ChangeNotifier {
|
|
||||||
ProtonInstallationState protonState = ProtonInstallationState.idle;
|
|
||||||
|
|
||||||
Int64 currentProgress = Int64(0);
|
|
||||||
Int64 maxProgress = Int64(0);
|
|
||||||
|
|
||||||
Future startInstallation(
|
|
||||||
GameStateProvider gameStateProvider, String protonVersion) async {
|
|
||||||
StartProtonInstallation(protonVersion: protonVersion).sendSignalToRust();
|
|
||||||
final progressStream = ProtonDownloadProgress.rustSignalStream;
|
|
||||||
await for (final rustSignal in progressStream) {
|
|
||||||
currentProgress = rustSignal.message.current;
|
|
||||||
maxProgress = rustSignal.message.max;
|
|
||||||
|
|
||||||
if (protonState == ProtonInstallationState.idle) {
|
|
||||||
protonState = ProtonInstallationState.downloading;
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyListeners();
|
|
||||||
|
|
||||||
if (currentProgress >= maxProgress) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final notificationDecompressingStream =
|
|
||||||
NotifyProtonStartDecompressing.rustSignalStream;
|
|
||||||
await for (final _ in notificationDecompressingStream) {
|
|
||||||
protonState = ProtonInstallationState.decompressing;
|
|
||||||
notifyListeners();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
final notificationInstalledStream =
|
|
||||||
NotifyProtonSuccessfullyInstalled.rustSignalStream;
|
|
||||||
await for (final _ in notificationInstalledStream) {
|
|
||||||
gameStateProvider.updateGameState();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,136 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
enum BackgroundType {
|
|
||||||
contain,
|
|
||||||
fill,
|
|
||||||
cover,
|
|
||||||
fitHeight,
|
|
||||||
fitWidth,
|
|
||||||
disable,
|
|
||||||
}
|
|
||||||
|
|
||||||
class Settings {
|
|
||||||
final SharedPreferences prefs;
|
|
||||||
|
|
||||||
Settings({required this.prefs});
|
|
||||||
|
|
||||||
static Future<Settings> create() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
return Settings(prefs: prefs);
|
|
||||||
}
|
|
||||||
|
|
||||||
String firstTimeKey = 'first_time';
|
|
||||||
bool? get firstTime {
|
|
||||||
return prefs.getBool(firstTimeKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
set firstTime(bool? value) {
|
|
||||||
prefs.setBool(firstTimeKey, value!);
|
|
||||||
}
|
|
||||||
|
|
||||||
BackgroundType? _backgroundType;
|
|
||||||
String backgroundTypeKey = 'background_type';
|
|
||||||
|
|
||||||
BackgroundType get selectedBackgroundType {
|
|
||||||
final bt = prefs.getString(backgroundTypeKey);
|
|
||||||
if (bt == null) {
|
|
||||||
_backgroundType = BackgroundType.disable;
|
|
||||||
prefs.setString(
|
|
||||||
backgroundTypeKey,
|
|
||||||
getStringNameOfBackgroundType(_backgroundType!),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
_backgroundType ??= getBackgroundTypeFromString(bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _backgroundType!;
|
|
||||||
}
|
|
||||||
|
|
||||||
set selectedBackgroundType(BackgroundType selectedBackground) {
|
|
||||||
_backgroundType = selectedBackground;
|
|
||||||
prefs.setString(
|
|
||||||
backgroundTypeKey,
|
|
||||||
getStringNameOfBackgroundType(selectedBackground),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
int? _backgroundId;
|
|
||||||
String backgroundIdKey = 'background_id';
|
|
||||||
|
|
||||||
int? get backgroundId {
|
|
||||||
_backgroundId ??= prefs.getInt(backgroundIdKey);
|
|
||||||
|
|
||||||
return _backgroundId;
|
|
||||||
}
|
|
||||||
|
|
||||||
set backgroundId(int? value) {
|
|
||||||
_backgroundId = value;
|
|
||||||
prefs.setInt(backgroundIdKey, value!);
|
|
||||||
}
|
|
||||||
|
|
||||||
static final List<BackgroundType> backgoundList = [
|
|
||||||
BackgroundType.contain,
|
|
||||||
BackgroundType.fill,
|
|
||||||
BackgroundType.cover,
|
|
||||||
BackgroundType.fitHeight,
|
|
||||||
BackgroundType.fitWidth,
|
|
||||||
BackgroundType.disable,
|
|
||||||
];
|
|
||||||
|
|
||||||
static String getStringNameOfBackgroundType(BackgroundType backgroundType) {
|
|
||||||
switch (backgroundType) {
|
|
||||||
case BackgroundType.contain:
|
|
||||||
return 'contain';
|
|
||||||
case BackgroundType.fill:
|
|
||||||
return 'fill';
|
|
||||||
case BackgroundType.cover:
|
|
||||||
return 'cover';
|
|
||||||
case BackgroundType.fitHeight:
|
|
||||||
return 'fitHeight';
|
|
||||||
case BackgroundType.fitWidth:
|
|
||||||
return 'fitWidth';
|
|
||||||
case BackgroundType.disable:
|
|
||||||
return 'disable';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static BackgroundType getBackgroundTypeFromString(String background) {
|
|
||||||
switch (background) {
|
|
||||||
case 'contain':
|
|
||||||
return BackgroundType.contain;
|
|
||||||
case 'fill':
|
|
||||||
return BackgroundType.fill;
|
|
||||||
case 'cover':
|
|
||||||
return BackgroundType.cover;
|
|
||||||
case 'fitHeight':
|
|
||||||
return BackgroundType.fitHeight;
|
|
||||||
case 'fitWidth':
|
|
||||||
return BackgroundType.fitWidth;
|
|
||||||
case 'disable':
|
|
||||||
return BackgroundType.disable;
|
|
||||||
default:
|
|
||||||
throw FormatException('Can\'t convert String to Enum BackgroundType!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static BoxFit getBoxFitFromBackgroundType(BackgroundType backgroundType) {
|
|
||||||
switch (backgroundType) {
|
|
||||||
case BackgroundType.contain:
|
|
||||||
return BoxFit.contain;
|
|
||||||
case BackgroundType.fill:
|
|
||||||
return BoxFit.fill;
|
|
||||||
case BackgroundType.cover:
|
|
||||||
return BoxFit.cover;
|
|
||||||
case BackgroundType.fitHeight:
|
|
||||||
return BoxFit.fitHeight;
|
|
||||||
case BackgroundType.fitWidth:
|
|
||||||
return BoxFit.fitWidth;
|
|
||||||
case BackgroundType.disable:
|
|
||||||
throw FormatException(
|
|
||||||
'Can\'t convert BackgroundType to widget BoxFit!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/messages/game_state.pb.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class GameStateProvider with ChangeNotifier {
|
|
||||||
States? _gameState;
|
|
||||||
bool isUpdating = false;
|
|
||||||
bool haveToSetup = false;
|
|
||||||
|
|
||||||
get gameState {
|
|
||||||
return _gameState;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future updateGameState() async {
|
|
||||||
if (!isUpdating) {
|
|
||||||
isUpdating = true;
|
|
||||||
AskGameState().sendSignalToRust();
|
|
||||||
|
|
||||||
final stream = GameState.rustSignalStream;
|
|
||||||
await for (final rustSignal in stream) {
|
|
||||||
_gameState = rustSignal.message.state;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
isUpdating = false;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateSetup() {
|
|
||||||
haveToSetup = needToSetup();
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool needToSetup() {
|
|
||||||
return _gameState == States.ProtonNotInstalled ||
|
|
||||||
_gameState == States.DXVKNotInstalled ||
|
|
||||||
_gameState == States.FontNotInstalled ||
|
|
||||||
_gameState == States.DependecieNotInstalled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isGameUpdating() {
|
|
||||||
return _gameState == States.GameNeedUpdate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export './settings_provider.dart';
|
|
||||||
export './game_state_provider.dart';
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import './../models/settings.dart';
|
|
||||||
import './../models/config.dart';
|
|
||||||
|
|
||||||
class SettingsProvider with ChangeNotifier {
|
|
||||||
late final Settings _settings;
|
|
||||||
|
|
||||||
Future init() async {
|
|
||||||
_settings = await Settings.create();
|
|
||||||
if (kDebugMode) {
|
|
||||||
_settings.firstTime = true;
|
|
||||||
}
|
|
||||||
await Config.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool get firstTime {
|
|
||||||
final result = _settings.firstTime;
|
|
||||||
if (result == null) {
|
|
||||||
_settings.firstTime = true;
|
|
||||||
}
|
|
||||||
return _settings.firstTime!;
|
|
||||||
}
|
|
||||||
|
|
||||||
set firstTime(bool value) {
|
|
||||||
_settings.firstTime = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
set setSelectedBackgroundType(BackgroundType selectedBackground) {
|
|
||||||
_settings.selectedBackgroundType = selectedBackground;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
get getSelectedBackgroundType {
|
|
||||||
return _settings.selectedBackgroundType;
|
|
||||||
}
|
|
||||||
|
|
||||||
int? get backgroundId {
|
|
||||||
return _settings.backgroundId;
|
|
||||||
}
|
|
||||||
|
|
||||||
set backgroundId(int? value) {
|
|
||||||
_settings.backgroundId = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/messages/game_state.pb.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import '../widgets/background_widget.dart';
|
|
||||||
import '../widgets/serious_lee_widget.dart';
|
|
||||||
import '../widgets/play_button.dart';
|
|
||||||
import '../widgets/steps/game_steps_widget.dart';
|
|
||||||
import './../providers/providers.dart';
|
|
||||||
import './../models/settings.dart';
|
|
||||||
import './../models/background.dart';
|
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
|
||||||
const HomeScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
|
||||||
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
const ShowBackground(),
|
|
||||||
gameStateProvider.gameState != States.GameInstalled
|
|
||||||
? const GameSteps()
|
|
||||||
: const PlayButton(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ShowBackground extends StatefulWidget {
|
|
||||||
const ShowBackground({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ShowBackground> createState() => _ShowBackgroundState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ShowBackgroundState extends State<ShowBackground> {
|
|
||||||
bool isLoading = false;
|
|
||||||
bool hadLoaded = false;
|
|
||||||
late final Background _background;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() async {
|
|
||||||
if (!hadLoaded) {
|
|
||||||
isLoading = true;
|
|
||||||
|
|
||||||
_background =
|
|
||||||
await Background.get(Provider.of<SettingsProvider>(context));
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
hadLoaded = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
super.didChangeDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (Provider.of<SettingsProvider>(context).getSelectedBackgroundType !=
|
|
||||||
BackgroundType.disable) {
|
|
||||||
if (isLoading) {
|
|
||||||
return const SeriousLeeWidget(
|
|
||||||
title: 'Babylonia Terminal',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return BackgroundWidget(
|
|
||||||
background: _background,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return const SeriousLeeWidget(
|
|
||||||
title: 'Babylonia Terminal',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/screens/settings_screen.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:yaru/icons.dart';
|
|
||||||
|
|
||||||
import 'package:babylonia_terminal_launcher/screens/home_screen.dart';
|
|
||||||
|
|
||||||
class Screens {
|
|
||||||
static final _screens = <Widget, (Widget, Widget, String)>{
|
|
||||||
const HomeScreen(): (
|
|
||||||
const Icon(YaruIcons.home_filled),
|
|
||||||
const Icon(YaruIcons.home),
|
|
||||||
'Home',
|
|
||||||
),
|
|
||||||
const SettingsScreen(): (
|
|
||||||
const Icon(YaruIcons.settings_filled),
|
|
||||||
const Icon(YaruIcons.settings),
|
|
||||||
'Settings',
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
static List<Widget> drawerItem(
|
|
||||||
{required Function(int) onSelected, required int selectedIndex}) =>
|
|
||||||
[
|
|
||||||
for (int i = 0; i < Screens._screens.values.length; i++)
|
|
||||||
ListTile(
|
|
||||||
selected: i == selectedIndex,
|
|
||||||
leading: i == selectedIndex
|
|
||||||
? Screens._screens.values.elementAt(i).$1
|
|
||||||
: Screens._screens.values.elementAt(i).$2,
|
|
||||||
title: Text(Screens._screens.values.elementAt(i).$3),
|
|
||||||
onTap: () => onSelected(i),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
static Widget getCurrent(int index) => Screens._screens.keys.toList()[index];
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class GameSettingsPage extends StatelessWidget {
|
|
||||||
const GameSettingsPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Center(
|
|
||||||
child: Text('Game settings'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class GeneralSettingsPage extends StatelessWidget {
|
|
||||||
const GeneralSettingsPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Center(
|
|
||||||
child: Text("General settings"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './general_settings_page.dart';
|
|
||||||
import './game_settings_page.dart';
|
|
||||||
import './style_settings_page.dart';
|
|
||||||
|
|
||||||
class SettingsPage {
|
|
||||||
static final _pages = <Widget, (Widget, String)>{
|
|
||||||
const GeneralSettingsPage(): (
|
|
||||||
const Icon(YaruIcons.gears),
|
|
||||||
'General',
|
|
||||||
),
|
|
||||||
const GameSettingsPage(): (
|
|
||||||
const Icon(YaruIcons.game_controller_filled),
|
|
||||||
'Game',
|
|
||||||
),
|
|
||||||
const StyleSettingsPage(): (
|
|
||||||
const Icon(YaruIcons.desktop_appearance_filled),
|
|
||||||
'Style',
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
static List<Widget> tabItems() => [
|
|
||||||
for (int i = 0; i < SettingsPage._pages.values.length; i++)
|
|
||||||
YaruTab(
|
|
||||||
icon: SettingsPage._pages.values.elementAt(i).$1,
|
|
||||||
label: SettingsPage._pages.values.elementAt(i).$2,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
static List<Widget> getPages() => SettingsPage._pages.keys.toList();
|
|
||||||
}
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './../../providers/settings_provider.dart';
|
|
||||||
import './../../models/settings.dart';
|
|
||||||
|
|
||||||
class StyleSettingsPage extends StatefulWidget {
|
|
||||||
const StyleSettingsPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<StyleSettingsPage> createState() => _StyleSettingsPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _StyleSettingsPageState extends State<StyleSettingsPage> {
|
|
||||||
late BackgroundType _radioValue;
|
|
||||||
|
|
||||||
void setBackgroundValue(
|
|
||||||
BuildContext context,
|
|
||||||
SettingsProvider provider,
|
|
||||||
BackgroundType? value,
|
|
||||||
) {
|
|
||||||
if (value != null) {
|
|
||||||
provider.setSelectedBackgroundType = value;
|
|
||||||
setState(() {
|
|
||||||
_radioValue = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<SettingsProvider>(context, listen: false);
|
|
||||||
_radioValue = provider.getSelectedBackgroundType;
|
|
||||||
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(15.0),
|
|
||||||
child: SizedBox(
|
|
||||||
child: YaruSection(
|
|
||||||
headline: const Text('Background video'),
|
|
||||||
child: Column(
|
|
||||||
children: Settings.backgoundList
|
|
||||||
.map(
|
|
||||||
(b) => YaruRadioListTile(
|
|
||||||
value: b,
|
|
||||||
groupValue: _radioValue,
|
|
||||||
onChanged: (v) =>
|
|
||||||
setBackgroundValue(context, provider, v),
|
|
||||||
toggleable: true,
|
|
||||||
title: Text(
|
|
||||||
Settings.getStringNameOfBackgroundType(
|
|
||||||
b,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './settings/settings_pages.dart';
|
|
||||||
|
|
||||||
class SettingsScreen extends StatefulWidget {
|
|
||||||
const SettingsScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SettingsScreenState extends State<SettingsScreen>
|
|
||||||
with TickerProviderStateMixin {
|
|
||||||
late TabController tabController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
tabController =
|
|
||||||
TabController(length: SettingsPage.getPages().length, vsync: this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
tabController.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 15.0),
|
|
||||||
child: YaruTabBar(
|
|
||||||
tabController: tabController,
|
|
||||||
tabs: SettingsPage.tabItems(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: TabBarView(
|
|
||||||
controller: tabController,
|
|
||||||
children: SettingsPage.getPages(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import './../providers/settings_provider.dart';
|
|
||||||
import './setups/welcome_screen.dart';
|
|
||||||
import 'setups/steps_screen.dart';
|
|
||||||
|
|
||||||
class SetupScreen extends StatelessWidget {
|
|
||||||
const SetupScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final settingsProvider = Provider.of<SettingsProvider>(context);
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text("Babylonia Terminal"),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: settingsProvider.firstTime ? const WelcomeScreen() : StepsScreen(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './../../messages/game_state.pb.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
import './../../widgets/selectable_yaru_expansion_panel.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
import './../../widgets/steps/proton_steps_widget.dart';
|
|
||||||
import './../../widgets/steps/dxvk_steps_widget.dart';
|
|
||||||
import './../../widgets/steps/fonts_steps_widget.dart';
|
|
||||||
import './../../widgets/steps/dependencies_steps_widget.dart';
|
|
||||||
|
|
||||||
class StepsScreen extends StatelessWidget {
|
|
||||||
StepsScreen({super.key});
|
|
||||||
final SectionController controller = SectionController(selectedItem: 0);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
|
||||||
switch (gameStateProvider.gameState) {
|
|
||||||
case States.ProtonNotInstalled:
|
|
||||||
controller.updateSection(0);
|
|
||||||
break;
|
|
||||||
case States.DXVKNotInstalled:
|
|
||||||
controller.updateSection(1);
|
|
||||||
break;
|
|
||||||
case States.FontNotInstalled:
|
|
||||||
controller.updateSection(2);
|
|
||||||
break;
|
|
||||||
case States.DependecieNotInstalled:
|
|
||||||
controller.updateSection(3);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
controller.updateSection(null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxHeight: 600,
|
|
||||||
maxWidth: 750,
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
|
||||||
child: SelectableYaruExpansionPanel(
|
|
||||||
controller: controller,
|
|
||||||
headers: const [
|
|
||||||
Text("Proton"),
|
|
||||||
Text("DXVK"),
|
|
||||||
Text("Fonts"),
|
|
||||||
Text("Dependencies"),
|
|
||||||
],
|
|
||||||
children: const [
|
|
||||||
ProtonSteps(),
|
|
||||||
DXVKSteps(),
|
|
||||||
FontsSteps(),
|
|
||||||
DependenciesSteps(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12.0),
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: !gameStateProvider.needToSetup()
|
|
||||||
? () => gameStateProvider.updateSetup()
|
|
||||||
: null,
|
|
||||||
child: const Text('next'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import './../../providers/settings_provider.dart';
|
|
||||||
import './../../widgets/serious_lee_widget.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
|
|
||||||
class WelcomeScreen extends StatelessWidget {
|
|
||||||
const WelcomeScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const SeriousLeeWidget(title: 'Welcome to Babylonia Terminal!'),
|
|
||||||
const Text(
|
|
||||||
'We have to setup some things first',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 15.0),
|
|
||||||
child: SizedBox(
|
|
||||||
width: 200,
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: () =>
|
|
||||||
Provider.of<SettingsProvider>(context, listen: false)
|
|
||||||
.firstTime = false,
|
|
||||||
child: const Text('Start'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:media_kit/media_kit.dart';
|
|
||||||
import 'package:media_kit_video/media_kit_video.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import './../providers/settings_provider.dart';
|
|
||||||
import './../models/settings.dart';
|
|
||||||
import './../models/background.dart';
|
|
||||||
|
|
||||||
class BackgroundWidget extends StatefulWidget {
|
|
||||||
const BackgroundWidget({super.key, required this.background});
|
|
||||||
|
|
||||||
final Background background;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<BackgroundWidget> createState() => _BackgroundWidgetState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _BackgroundWidgetState extends State<BackgroundWidget> {
|
|
||||||
late final player = Player(
|
|
||||||
configuration: const PlayerConfiguration(),
|
|
||||||
);
|
|
||||||
late final controller = VideoController(player);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
player.open(
|
|
||||||
Media(
|
|
||||||
widget.background.path,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
player.setPlaylistMode(PlaylistMode.loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
player.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<SettingsProvider>(context);
|
|
||||||
|
|
||||||
player.play();
|
|
||||||
return Video(
|
|
||||||
controller: controller,
|
|
||||||
controls: NoVideoControls,
|
|
||||||
wakelock: false,
|
|
||||||
fit: Settings.getBoxFitFromBackgroundType(
|
|
||||||
provider.getSelectedBackgroundType,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,112 +0,0 @@
|
|||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class GtkSpinner extends StatefulWidget {
|
|
||||||
const GtkSpinner({
|
|
||||||
super.key,
|
|
||||||
this.size = 15.0,
|
|
||||||
this.strokeSize = 5.0,
|
|
||||||
this.color = Colors.grey,
|
|
||||||
});
|
|
||||||
final double size;
|
|
||||||
final double strokeSize;
|
|
||||||
final Color color;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<GtkSpinner> createState() => _GtkSpinnerState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GtkSpinnerState extends State<GtkSpinner>
|
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
late AnimationController _controller;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_controller = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(seconds: 1, milliseconds: 500),
|
|
||||||
)..repeat();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_controller.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: AnimatedBuilder(
|
|
||||||
animation: _controller,
|
|
||||||
builder: (context, child) {
|
|
||||||
return CustomPaint(
|
|
||||||
painter: _GtkSpinnerPainter(
|
|
||||||
_controller.value * 2 * pi,
|
|
||||||
widget.strokeSize,
|
|
||||||
widget.color,
|
|
||||||
),
|
|
||||||
size: Size(widget.size, widget.size),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _GtkSpinnerPainter extends CustomPainter {
|
|
||||||
_GtkSpinnerPainter(this.angle, this.strokeSize, this.color);
|
|
||||||
|
|
||||||
final double angle;
|
|
||||||
final double strokeSize;
|
|
||||||
final Color color;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
final double radius = size.width / 2;
|
|
||||||
final Rect rect =
|
|
||||||
Rect.fromCircle(center: Offset(radius, radius), radius: radius);
|
|
||||||
|
|
||||||
// Define the gradient for the arc
|
|
||||||
final Paint gradientPaint = Paint()
|
|
||||||
..shader = SweepGradient(
|
|
||||||
startAngle: 0.0,
|
|
||||||
endAngle: 2 * pi,
|
|
||||||
colors: [
|
|
||||||
color,
|
|
||||||
color.withOpacity(0.0),
|
|
||||||
],
|
|
||||||
stops: const [0.0, 0.90],
|
|
||||||
transform: GradientRotation(angle),
|
|
||||||
).createShader(rect)
|
|
||||||
..style = PaintingStyle.stroke
|
|
||||||
..strokeCap = StrokeCap.round
|
|
||||||
..strokeWidth = strokeSize;
|
|
||||||
|
|
||||||
// Draw the gradient arc
|
|
||||||
canvas.drawArc(
|
|
||||||
rect,
|
|
||||||
angle,
|
|
||||||
7 * pi / 4, // Draw an arc of 300 degrees
|
|
||||||
false,
|
|
||||||
gradientPaint,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add two circles at the start and end to create the rounded caps effect
|
|
||||||
final Paint capPaint = Paint()
|
|
||||||
..color = color
|
|
||||||
..style = PaintingStyle.fill;
|
|
||||||
|
|
||||||
canvas.drawCircle(
|
|
||||||
Offset(radius + radius * cos(angle), radius + radius * sin(angle)),
|
|
||||||
strokeSize / 2,
|
|
||||||
capPaint,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) => true;
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import './simple_button.dart';
|
|
||||||
import './../models/game.dart';
|
|
||||||
|
|
||||||
class PlayButton extends StatelessWidget {
|
|
||||||
const PlayButton({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final game = Provider.of<Game>(context);
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(50.0),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
const Expanded(
|
|
||||||
child: SizedBox(),
|
|
||||||
),
|
|
||||||
const Expanded(
|
|
||||||
child: SizedBox(),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxWidth: 600,
|
|
||||||
maxHeight: 50,
|
|
||||||
),
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: game.gameRunState == GameRunState.idle
|
|
||||||
? () {
|
|
||||||
Provider.of<Game>(context, listen: false)
|
|
||||||
.startGame();
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Center(
|
|
||||||
child: game.gameRunState == GameRunState.idle
|
|
||||||
? const Text("Play")
|
|
||||||
: const Text("Running..."),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,237 +0,0 @@
|
|||||||
// This file has been literally copied from https://github.com/ubuntu/yaru.dart/blob/main/lib/src/widgets/yaru_expansion_panel.dart
|
|
||||||
// and https://github.com/ubuntu/yaru.dart/blob/main/lib/src/widgets/yaru_expandable.dart
|
|
||||||
// Just want to make some change to it for specific needs instead of contributing to it, because I'm too lazy for that and I think they don't want these change
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:yaru/constants.dart';
|
|
||||||
import 'package:yaru/widgets.dart';
|
|
||||||
|
|
||||||
class SectionController extends ChangeNotifier {
|
|
||||||
int? selectedItem;
|
|
||||||
Function()? onChange;
|
|
||||||
|
|
||||||
SectionController({required this.selectedItem});
|
|
||||||
|
|
||||||
void updateSection(int? newSelectedItem) {
|
|
||||||
selectedItem = newSelectedItem;
|
|
||||||
notifyListeners();
|
|
||||||
if (onChange != null) {
|
|
||||||
onChange!();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SelectableYaruExpansionPanel extends StatefulWidget {
|
|
||||||
const SelectableYaruExpansionPanel({
|
|
||||||
super.key,
|
|
||||||
required this.controller,
|
|
||||||
required this.children,
|
|
||||||
this.borderRadius =
|
|
||||||
const BorderRadius.all(Radius.circular(kYaruContainerRadius)),
|
|
||||||
this.border,
|
|
||||||
required this.headers,
|
|
||||||
this.width,
|
|
||||||
this.height,
|
|
||||||
this.padding,
|
|
||||||
this.margin,
|
|
||||||
this.expandIconPadding = const EdgeInsets.all(10),
|
|
||||||
this.headerPadding = const EdgeInsets.only(left: 20),
|
|
||||||
this.color,
|
|
||||||
this.placeDividers = true,
|
|
||||||
this.expandIcon,
|
|
||||||
this.shrinkWrap = true,
|
|
||||||
this.scrollPhysics = const ClampingScrollPhysics(),
|
|
||||||
this.collapseOnExpand = true,
|
|
||||||
}) : assert(headers.length == children.length);
|
|
||||||
|
|
||||||
final SectionController controller;
|
|
||||||
final List<Widget> children;
|
|
||||||
final List<Widget> headers;
|
|
||||||
final BorderRadius borderRadius;
|
|
||||||
final BoxBorder? border;
|
|
||||||
final double? width;
|
|
||||||
final double? height;
|
|
||||||
final EdgeInsetsGeometry? padding;
|
|
||||||
final EdgeInsetsGeometry? margin;
|
|
||||||
final EdgeInsetsGeometry expandIconPadding;
|
|
||||||
final EdgeInsetsGeometry headerPadding;
|
|
||||||
final Color? color;
|
|
||||||
final bool placeDividers;
|
|
||||||
final Widget? expandIcon;
|
|
||||||
final bool shrinkWrap;
|
|
||||||
final ScrollPhysics scrollPhysics;
|
|
||||||
final bool collapseOnExpand;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<SelectableYaruExpansionPanel> createState() =>
|
|
||||||
_SelectableYaruExpansionPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SelectableYaruExpansionPanelState
|
|
||||||
extends State<SelectableYaruExpansionPanel> {
|
|
||||||
late List<bool> _expandedStore;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
widget.controller.onChange = widget.collapseOnExpand
|
|
||||||
? () {
|
|
||||||
if (widget.controller.selectedItem != null) {
|
|
||||||
_expandedStore[widget.controller.selectedItem!];
|
|
||||||
for (var n = 0; n < _expandedStore.length; n++) {
|
|
||||||
if (_expandedStore[n]) {
|
|
||||||
setState(() => _expandedStore[n] = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var n = 0; n < _expandedStore.length; n++) {
|
|
||||||
setState(() => _expandedStore[n] = false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
_expandedStore =
|
|
||||||
List<bool>.generate(widget.children.length, (index) => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
assert(widget.children.length == widget.headers.length);
|
|
||||||
|
|
||||||
if (widget.controller.selectedItem != null) {
|
|
||||||
_expandedStore[widget.controller.selectedItem!] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return YaruBorderContainer(
|
|
||||||
border: widget.border,
|
|
||||||
borderRadius: widget.borderRadius,
|
|
||||||
color: widget.color,
|
|
||||||
width: widget.width,
|
|
||||||
height: widget.height,
|
|
||||||
padding: widget.padding,
|
|
||||||
margin: widget.margin,
|
|
||||||
child: widget.placeDividers
|
|
||||||
? ListView.separated(
|
|
||||||
shrinkWrap: widget.shrinkWrap,
|
|
||||||
physics: widget.scrollPhysics,
|
|
||||||
itemCount: widget.children.length,
|
|
||||||
itemBuilder: _itemBuilder,
|
|
||||||
separatorBuilder: (context, index) {
|
|
||||||
if (index != widget.children.length - 1) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 1),
|
|
||||||
child: Divider(),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return const SizedBox.shrink();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
: ListView.builder(
|
|
||||||
shrinkWrap: widget.shrinkWrap,
|
|
||||||
physics: widget.scrollPhysics,
|
|
||||||
itemCount: widget.children.length,
|
|
||||||
itemBuilder: _itemBuilder,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget? _itemBuilder(context, index) {
|
|
||||||
return YaruExpandable(
|
|
||||||
expandIconPadding: widget.expandIconPadding,
|
|
||||||
isExpanded: _expandedStore[index],
|
|
||||||
header: Padding(
|
|
||||||
padding: widget.headerPadding,
|
|
||||||
child: widget.headers[index],
|
|
||||||
),
|
|
||||||
child: widget.children[index],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _kAnimationDuration = Duration(milliseconds: 250);
|
|
||||||
const _kAnimationCurve = Curves.easeInOutCubic;
|
|
||||||
|
|
||||||
class YaruExpandable extends StatefulWidget {
|
|
||||||
const YaruExpandable({
|
|
||||||
super.key,
|
|
||||||
required this.header,
|
|
||||||
this.expandIconPadding = EdgeInsets.zero,
|
|
||||||
required this.child,
|
|
||||||
this.collapsedChild,
|
|
||||||
this.gapHeight = 4.0,
|
|
||||||
this.isExpanded = false,
|
|
||||||
this.onChange,
|
|
||||||
});
|
|
||||||
|
|
||||||
final Widget header;
|
|
||||||
final EdgeInsetsGeometry expandIconPadding;
|
|
||||||
final Widget child;
|
|
||||||
final Widget? collapsedChild;
|
|
||||||
final double gapHeight;
|
|
||||||
final bool isExpanded;
|
|
||||||
final ValueChanged<bool>? onChange;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<YaruExpandable> createState() => _YaruExpandableState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _YaruExpandableState extends State<YaruExpandable> {
|
|
||||||
late bool _isExpanded;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_isExpanded = widget.isExpanded;
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(YaruExpandable oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
if (oldWidget.isExpanded != widget.isExpanded) {
|
|
||||||
_isExpanded = widget.isExpanded;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
widget.header,
|
|
||||||
Padding(
|
|
||||||
padding: widget.expandIconPadding,
|
|
||||||
child: const SizedBox(
|
|
||||||
height: 36,
|
|
||||||
width: 36,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
AnimatedCrossFade(
|
|
||||||
firstChild: _buildChild(widget.child),
|
|
||||||
secondChild: widget.collapsedChild != null
|
|
||||||
? _buildChild(widget.collapsedChild!)
|
|
||||||
: Container(),
|
|
||||||
crossFadeState: _isExpanded
|
|
||||||
? CrossFadeState.showFirst
|
|
||||||
: CrossFadeState.showSecond,
|
|
||||||
sizeCurve: _kAnimationCurve,
|
|
||||||
duration: _kAnimationDuration,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildChild(Widget child) {
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(height: widget.gapHeight),
|
|
||||||
child,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SeriousLeeWidget extends StatelessWidget {
|
|
||||||
const SeriousLeeWidget({super.key, required this.title});
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: 300,
|
|
||||||
child: Image.asset('assets/images/Lee6.png'),
|
|
||||||
),
|
|
||||||
Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 34,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class SimpleButton extends StatelessWidget {
|
|
||||||
const SimpleButton({super.key, required this.child, required this.onPressed});
|
|
||||||
final Function()? onPressed;
|
|
||||||
final Widget? child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ElevatedButton(
|
|
||||||
style: ButtonStyle(
|
|
||||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
|
||||||
if (states.contains(MaterialState.disabled)) {
|
|
||||||
return Colors.grey;
|
|
||||||
}
|
|
||||||
return Colors.blue[500];
|
|
||||||
}),
|
|
||||||
side: MaterialStateProperty.all(BorderSide.none),
|
|
||||||
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
|
||||||
RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(100.0),
|
|
||||||
side: const BorderSide(color: Colors.red),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/widgets/gtk_spinner_widget.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import './../../models/dependencies.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
|
|
||||||
class DependenciesSteps extends StatelessWidget {
|
|
||||||
const DependenciesSteps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: ChangeNotifierProvider(
|
|
||||||
create: (context) => Dependencies(),
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
switch (Provider.of<Dependencies>(context).dependeciesState) {
|
|
||||||
case DependenciesInstallationState.idle:
|
|
||||||
return const InstallDependecies();
|
|
||||||
case DependenciesInstallationState.installing:
|
|
||||||
return const DependeciesInstallationProgress();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InstallDependecies extends StatefulWidget {
|
|
||||||
const InstallDependecies({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<InstallDependecies> createState() => _InstallDependeciesState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InstallDependeciesState extends State<InstallDependecies> {
|
|
||||||
bool canInstall = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SimpleButton(
|
|
||||||
onPressed: canInstall
|
|
||||||
? () {
|
|
||||||
Provider.of<Dependencies>(context, listen: false)
|
|
||||||
.startInstallation(
|
|
||||||
Provider.of<GameStateProvider>(context, listen: false),
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
canInstall = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text("Install"),
|
|
||||||
),
|
|
||||||
if (!canInstall) const GtkSpinner(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DependeciesInstallationProgress extends StatelessWidget {
|
|
||||||
const DependeciesInstallationProgress({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Row(
|
|
||||||
children: [
|
|
||||||
GtkSpinner(),
|
|
||||||
Text(
|
|
||||||
'Installing dependecies (this can take a while, so go grab a coffee)',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/widgets.dart';
|
|
||||||
|
|
||||||
import './../../models/github.dart';
|
|
||||||
import './../../models/dxvk.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
import './../../widgets/gtk_spinner_widget.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
|
|
||||||
class DXVKSteps extends StatefulWidget {
|
|
||||||
const DXVKSteps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<DXVKSteps> createState() => _DXVKStepsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DXVKStepsState extends State<DXVKSteps> {
|
|
||||||
final DXVK proton = DXVK();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: ChangeNotifierProvider(
|
|
||||||
create: (_) => proton,
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
switch (Provider.of<DXVK>(context).dxvkState) {
|
|
||||||
case DXVKInstallationState.idle:
|
|
||||||
return const InstallDXVK();
|
|
||||||
case DXVKInstallationState.downloading:
|
|
||||||
return const DXVKDownloadProgress();
|
|
||||||
case DXVKInstallationState.decompressing:
|
|
||||||
return const Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: GtkSpinner(),
|
|
||||||
),
|
|
||||||
Text('Installing...'),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InstallDXVK extends StatefulWidget {
|
|
||||||
const InstallDXVK({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<InstallDXVK> createState() => _InstallDXVKState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InstallDXVKState extends State<InstallDXVK> {
|
|
||||||
bool hasLoaded = false;
|
|
||||||
bool isLoading = false;
|
|
||||||
late List<String> protonVersions;
|
|
||||||
String? selectedValue;
|
|
||||||
bool canInstall = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() async {
|
|
||||||
if (!hasLoaded) {
|
|
||||||
isLoading = true;
|
|
||||||
protonVersions = await Github.getDXVKVersions();
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
hasLoaded = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
super.didChangeDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (hasLoaded && selectedValue == null) {
|
|
||||||
selectedValue = protonVersions.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isLoading
|
|
||||||
? const Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: GtkSpinner(),
|
|
||||||
),
|
|
||||||
Text('Fetching versions...'),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
YaruPopupMenuButton(
|
|
||||||
enabled: canInstall,
|
|
||||||
initialValue: selectedValue,
|
|
||||||
itemBuilder: (_) => protonVersions
|
|
||||||
.map(
|
|
||||||
(e) => PopupMenuItem(
|
|
||||||
value: e,
|
|
||||||
child: Text(e),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
onSelected: (v) => setState(() {
|
|
||||||
selectedValue = v;
|
|
||||||
}),
|
|
||||||
child: Text(selectedValue!),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: canInstall
|
|
||||||
? () {
|
|
||||||
Provider.of<DXVK>(context, listen: false)
|
|
||||||
.startInstallation(
|
|
||||||
Provider.of<GameStateProvider>(context,
|
|
||||||
listen: false),
|
|
||||||
selectedValue!);
|
|
||||||
setState(() {
|
|
||||||
canInstall = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text("Install"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!canInstall) const GtkSpinner(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DXVKDownloadProgress extends StatelessWidget {
|
|
||||||
const DXVKDownloadProgress({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<DXVK>(context);
|
|
||||||
final pourcent =
|
|
||||||
(provider.currentProgress.toInt() / provider.maxProgress.toInt()) * 100;
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Text("Downloaded: ${pourcent.toStringAsFixed(2)}%"),
|
|
||||||
YaruLinearProgressIndicator(
|
|
||||||
value: pourcent / 100,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
import 'package:babylonia_terminal_launcher/widgets/gtk_spinner_widget.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './../../models/fonts.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
|
|
||||||
class FontsSteps extends StatelessWidget {
|
|
||||||
const FontsSteps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: ChangeNotifierProvider(
|
|
||||||
create: (context) => Fonts(),
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
switch (Provider.of<Fonts>(context).fontsState) {
|
|
||||||
case FontsInstallationState.idle:
|
|
||||||
return const InstallFonts();
|
|
||||||
case FontsInstallationState.installing:
|
|
||||||
return const FontsInstallationProgress();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InstallFonts extends StatefulWidget {
|
|
||||||
const InstallFonts({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<InstallFonts> createState() => _InstallFontsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InstallFontsState extends State<InstallFonts> {
|
|
||||||
bool canInstall = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SimpleButton(
|
|
||||||
onPressed: canInstall
|
|
||||||
? () {
|
|
||||||
Provider.of<Fonts>(context, listen: false)
|
|
||||||
.startInstallation(
|
|
||||||
Provider.of<GameStateProvider>(context, listen: false),
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
canInstall = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text("Install"),
|
|
||||||
),
|
|
||||||
if (!canInstall) const GtkSpinner(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FontsInstallationProgress extends StatelessWidget {
|
|
||||||
const FontsInstallationProgress({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<Fonts>(context);
|
|
||||||
final pourcent =
|
|
||||||
(provider.currentProgress.toInt() / provider.maxProgress.toInt()) * 100;
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const GtkSpinner(),
|
|
||||||
Text(
|
|
||||||
"${provider.currentProgress} / ${provider.maxProgress} fonts installed"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
YaruLinearProgressIndicator(
|
|
||||||
value: pourcent / 100,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,152 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/yaru.dart';
|
|
||||||
|
|
||||||
import './../../models/game.dart';
|
|
||||||
import './../simple_button.dart';
|
|
||||||
import './../gtk_spinner_widget.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
|
|
||||||
class GameSteps extends StatelessWidget {
|
|
||||||
const GameSteps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(50.0),
|
|
||||||
child: Builder(builder: (context) {
|
|
||||||
switch (Provider.of<Game>(context).gameInstallationState) {
|
|
||||||
case GameInstallationState.idle:
|
|
||||||
return const _InstallGame();
|
|
||||||
case GameInstallationState.checkingFile:
|
|
||||||
return const _CheckingFileGame();
|
|
||||||
case GameInstallationState.downloading:
|
|
||||||
return const _DownloadingGame();
|
|
||||||
case GameInstallationState.patching:
|
|
||||||
return const _PatchingGame();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InstallGame extends StatelessWidget {
|
|
||||||
const _InstallGame({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
|
||||||
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
const Expanded(
|
|
||||||
child: SizedBox(),
|
|
||||||
),
|
|
||||||
const Expanded(
|
|
||||||
child: SizedBox(),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxWidth: 600,
|
|
||||||
maxHeight: 50,
|
|
||||||
),
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: () async {
|
|
||||||
Provider.of<Game>(context, listen: false).startInstallation(
|
|
||||||
Provider.of<GameStateProvider>(context, listen: false),
|
|
||||||
gameStateProvider.isGameUpdating(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: gameStateProvider.isGameUpdating()
|
|
||||||
? const Center(
|
|
||||||
child: Text("Update"),
|
|
||||||
)
|
|
||||||
: const Center(
|
|
||||||
child: Text("Download"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CheckingFileGame extends StatelessWidget {
|
|
||||||
const _CheckingFileGame({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.only(bottom: 40.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
GtkSpinner(),
|
|
||||||
Text("Checking files... (This can take a while)"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DownloadingGame extends StatelessWidget {
|
|
||||||
const _DownloadingGame({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<Game>(context);
|
|
||||||
final pourcent =
|
|
||||||
(provider.currentProgress.toInt() / provider.maxProgress.toInt()) * 100;
|
|
||||||
final currentGb = provider.currentProgress.toInt() / 1024 / 1024 / 1024;
|
|
||||||
final maxGb = provider.maxProgress.toInt() / 1024 / 1024 / 1024;
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 40.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 8.0),
|
|
||||||
child: Text(
|
|
||||||
"${currentGb.toStringAsFixed(2)} / ${maxGb.toStringAsFixed(2)} Gb (${pourcent.toStringAsFixed(2)}%)",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
YaruLinearProgressIndicator(
|
|
||||||
value: pourcent / 100,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PatchingGame extends StatelessWidget {
|
|
||||||
const _PatchingGame({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.only(bottom: 40.0),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
GtkSpinner(),
|
|
||||||
Text("Patching game"),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,157 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
import 'package:yaru/widgets.dart';
|
|
||||||
|
|
||||||
import './../../models/github.dart';
|
|
||||||
import './../../models/proton.dart';
|
|
||||||
import './../../widgets/simple_button.dart';
|
|
||||||
import './../../widgets/gtk_spinner_widget.dart';
|
|
||||||
import './../../providers/providers.dart';
|
|
||||||
|
|
||||||
class ProtonSteps extends StatefulWidget {
|
|
||||||
const ProtonSteps({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ProtonSteps> createState() => _ProtonStepsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ProtonStepsState extends State<ProtonSteps> {
|
|
||||||
final Proton proton = Proton();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: ChangeNotifierProvider(
|
|
||||||
create: (_) => proton,
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
switch (Provider.of<Proton>(context).protonState) {
|
|
||||||
case ProtonInstallationState.idle:
|
|
||||||
return const InstallProton();
|
|
||||||
case ProtonInstallationState.downloading:
|
|
||||||
return const ProtonDownloadProgress();
|
|
||||||
case ProtonInstallationState.decompressing:
|
|
||||||
return const Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: GtkSpinner(),
|
|
||||||
),
|
|
||||||
Text('decompressing...'),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class InstallProton extends StatefulWidget {
|
|
||||||
const InstallProton({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<InstallProton> createState() => _InstallProtonState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _InstallProtonState extends State<InstallProton> {
|
|
||||||
bool hasLoaded = false;
|
|
||||||
bool isLoading = false;
|
|
||||||
late List<String> protonVersions;
|
|
||||||
String? selectedValue;
|
|
||||||
bool canInstall = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didChangeDependencies() async {
|
|
||||||
if (!hasLoaded) {
|
|
||||||
isLoading = true;
|
|
||||||
protonVersions = await Github.getProtonVersions();
|
|
||||||
setState(() {
|
|
||||||
isLoading = false;
|
|
||||||
hasLoaded = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
super.didChangeDependencies();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (hasLoaded && selectedValue == null) {
|
|
||||||
selectedValue = protonVersions.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isLoading
|
|
||||||
? const Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: GtkSpinner(),
|
|
||||||
),
|
|
||||||
Text('Fetching versions...'),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
YaruPopupMenuButton(
|
|
||||||
initialValue: selectedValue,
|
|
||||||
itemBuilder: (_) => protonVersions
|
|
||||||
.map(
|
|
||||||
(e) => PopupMenuItem(
|
|
||||||
value: e,
|
|
||||||
child: Text(e),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
onSelected: (v) => setState(() {
|
|
||||||
selectedValue = v;
|
|
||||||
}),
|
|
||||||
child: Text(selectedValue!),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0),
|
|
||||||
child: SimpleButton(
|
|
||||||
onPressed: canInstall
|
|
||||||
? () {
|
|
||||||
Provider.of<Proton>(context, listen: false)
|
|
||||||
.startInstallation(
|
|
||||||
Provider.of<GameStateProvider>(context,
|
|
||||||
listen: false),
|
|
||||||
selectedValue!);
|
|
||||||
setState(() {
|
|
||||||
canInstall = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: const Text("Install"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProtonDownloadProgress extends StatelessWidget {
|
|
||||||
const ProtonDownloadProgress({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final provider = Provider.of<Proton>(context);
|
|
||||||
final pourcent =
|
|
||||||
(provider.currentProgress.toInt() / provider.maxProgress.toInt()) * 100;
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Text("Downloaded: ${pourcent.toStringAsFixed(2)}%"),
|
|
||||||
YaruLinearProgressIndicator(
|
|
||||||
value: pourcent / 100,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package config;
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message ConfigInput {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message ConfigOutput {
|
|
||||||
string configPath = 1;
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package error;
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message ReportError {
|
|
||||||
string errorMessage = 1;
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package game_state;
|
|
||||||
|
|
||||||
enum States {
|
|
||||||
ProtonNotInstalled = 0;
|
|
||||||
DXVKNotInstalled = 1;
|
|
||||||
FontNotInstalled = 2;
|
|
||||||
DependecieNotInstalled = 3;
|
|
||||||
GameNotInstalled = 4;
|
|
||||||
GameNeedUpdate = 5;
|
|
||||||
GameNotPatched = 6;
|
|
||||||
GameInstalled = 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message GameState {
|
|
||||||
States state = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message AskGameState {}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package github;
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message AskProtonVersions {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message ProtonVersions {
|
|
||||||
repeated string versions = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message AskDXVKVersions {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message DXVKVersions {
|
|
||||||
repeated string versions = 1;
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package dependencies;
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message StartDependenciesInstallation {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyDependenciesSuccessfullyInstalled {}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package dxvk;
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message DXVKDownloadProgress {
|
|
||||||
uint64 current = 1;
|
|
||||||
uint64 max = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message StartDXVKInstallation {
|
|
||||||
string protonVersion = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyDXVKStartDecompressing {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyDXVKSuccessfullyInstalled {}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package fonts;
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message FontsInstallationProgress {
|
|
||||||
uint64 current = 1;
|
|
||||||
uint64 max = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message StartFontsInstallation {};
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyFontsSuccessfullyInstalled {}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package game;
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message GameInstallationProgress {
|
|
||||||
uint64 current = 1;
|
|
||||||
uint64 max = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message StartGameInstallation {
|
|
||||||
bool isUpdating = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyGameStartDownloading {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyGameStartPatching {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyGameSuccessfullyInstalled {}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message RunGame {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message GameStopped {}
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
syntax = "proto3";
|
|
||||||
package proton;
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message ProtonDownloadProgress {
|
|
||||||
uint64 current = 1;
|
|
||||||
uint64 max = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
|
||||||
message StartProtonInstallation {
|
|
||||||
string protonVersion = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyProtonStartDecompressing {}
|
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
|
||||||
message NotifyProtonSuccessfullyInstalled {}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
[package]
|
|
||||||
# Do not change the name of this crate.
|
|
||||||
name = "hub"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
# `lib` is required for non-library targets,
|
|
||||||
# such as tests and benchmarks.
|
|
||||||
# `cdylib` is for Linux, Android, Windows, and web.
|
|
||||||
# `staticlib` is for iOS and macOS.
|
|
||||||
crate-type = ["lib", "cdylib", "staticlib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
rinf = "6.9.0"
|
|
||||||
prost = "0.12.3"
|
|
||||||
wasm-bindgen = "0.2.91"
|
|
||||||
tokio_with_wasm = "0.4.3"
|
|
||||||
babylonia-terminal-sdk = { path = "./../../../babylonia-terminal-sdk" }
|
|
||||||
downloader = { git = "https://github.com/ALEZ-DEV/downloader" } # version = "0.2.7",
|
|
||||||
once_cell = "1.19.0"
|
|
||||||
wincompatlib = { version = "0.7.4", features = [
|
|
||||||
"dxvk",
|
|
||||||
"wine-bundles",
|
|
||||||
"wine-proton",
|
|
||||||
"wine-fonts",
|
|
||||||
"winetricks",
|
|
||||||
] }
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
use babylonia_terminal_sdk::game_state::GameState;
|
|
||||||
|
|
||||||
use crate::messages::config::{ConfigInput, ConfigOutput};
|
|
||||||
|
|
||||||
pub async fn listen_config() {
|
|
||||||
let mut receiver = ConfigInput::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let config = GameState::get_config().await;
|
|
||||||
ConfigOutput {
|
|
||||||
config_path: config.config_dir.to_str().unwrap().to_string(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
use std::thread;
|
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use tokio_with_wasm::tokio;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
messages::{
|
|
||||||
error::ReportError,
|
|
||||||
steps::dependencies::{
|
|
||||||
NotifyDependenciesSuccessfullyInstalled, StartDependenciesInstallation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
proton::get_proton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn listen_dependecies_installation() {
|
|
||||||
let mut receiver = StartDependenciesInstallation::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let proton = get_proton().await;
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
match GameManager::install_dependencies(&proton).await {
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install dependencies : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => NotifyDependenciesSuccessfullyInstalled {}.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
use std::thread;
|
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::{
|
|
||||||
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
|
||||||
proton_component::ProtonComponent,
|
|
||||||
},
|
|
||||||
game_manager::GameManager,
|
|
||||||
game_state::GameState,
|
|
||||||
utils::github_requester::{GithubRelease, GithubRequester},
|
|
||||||
};
|
|
||||||
use tokio_with_wasm::tokio;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
github::GithubInfo,
|
|
||||||
messages::{
|
|
||||||
error::ReportError,
|
|
||||||
steps::dxvk::{
|
|
||||||
DxvkDownloadProgress, NotifyDxvkStartDecompressing, NotifyDxvkSuccessfullyInstalled,
|
|
||||||
StartDxvkInstallation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
proton::get_proton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn listen_dxvk_installation() {
|
|
||||||
let mut receiver = StartDxvkInstallation::get_dart_signal_receiver();
|
|
||||||
while let Some(info) = receiver.recv().await {
|
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
|
||||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
|
||||||
if releases.is_err() {
|
|
||||||
ReportError {
|
|
||||||
error_message: format!("When fetching DXVK versions : {}", releases.unwrap_err()),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let checked_releases = releases.unwrap();
|
|
||||||
let release_index = checked_releases
|
|
||||||
.iter()
|
|
||||||
.position(|v| v.tag_name == info.message.proton_version);
|
|
||||||
|
|
||||||
if release_index.is_none() {
|
|
||||||
ReportError {
|
|
||||||
error_message: "Failed to find DXVK version".to_string(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let proton = get_proton().await;
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
match GameManager::install_dxvk(
|
|
||||||
&proton,
|
|
||||||
GameState::get_config().await.config_dir,
|
|
||||||
release_index.unwrap(),
|
|
||||||
Some(DownloadReporter::create()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install DXVK : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => NotifyDxvkSuccessfullyInstalled {}.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporterPrivate {
|
|
||||||
max_progress: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporter {
|
|
||||||
private: std::sync::Mutex<Option<DownloadReporterPrivate>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DownloadReporter {
|
|
||||||
pub fn create() -> std::sync::Arc<Self> {
|
|
||||||
std::sync::Arc::new(Self {
|
|
||||||
private: std::sync::Mutex::new(None),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl downloader::progress::Reporter for DownloadReporter {
|
|
||||||
fn setup(&self, max_progress: Option<u64>, _: &str) {
|
|
||||||
let private = DownloadReporterPrivate { max_progress };
|
|
||||||
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = Some(private);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn progress(&self, current: u64) {
|
|
||||||
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
|
||||||
DxvkDownloadProgress {
|
|
||||||
current,
|
|
||||||
max: p.max_progress.unwrap(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_message(&self, _: &str) {}
|
|
||||||
|
|
||||||
fn done(&self) {
|
|
||||||
NotifyDxvkStartDecompressing {}.send_signal_to_dart();
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
use std::thread;
|
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use tokio_with_wasm::tokio;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
messages::{
|
|
||||||
error::ReportError,
|
|
||||||
steps::fonts::{
|
|
||||||
FontsInstallationProgress, NotifyFontsSuccessfullyInstalled, StartFontsInstallation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
proton::get_proton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn listen_fonts_installation() {
|
|
||||||
let mut receiver = StartFontsInstallation::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let proton = get_proton().await;
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
match GameManager::install_font(&proton, Some(InstallationReporter::create()))
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install DXVK : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => NotifyFontsSuccessfullyInstalled {}.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporterPrivate {
|
|
||||||
max_progress: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct InstallationReporter {
|
|
||||||
private: std::sync::Mutex<Option<DownloadReporterPrivate>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InstallationReporter {
|
|
||||||
pub fn create() -> std::sync::Arc<Self> {
|
|
||||||
std::sync::Arc::new(Self {
|
|
||||||
private: std::sync::Mutex::new(None),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl downloader::progress::Reporter for InstallationReporter {
|
|
||||||
fn setup(&self, max_progress: Option<u64>, _: &str) {
|
|
||||||
let private = DownloadReporterPrivate { max_progress };
|
|
||||||
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = Some(private);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn progress(&self, current: u64) {
|
|
||||||
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
|
||||||
FontsInstallationProgress {
|
|
||||||
current,
|
|
||||||
max: p.max_progress.unwrap(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_message(&self, _: &str) {}
|
|
||||||
|
|
||||||
fn done(&self) {
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,157 +0,0 @@
|
|||||||
use std::thread;
|
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use rinf::debug_print;
|
|
||||||
use tokio_with_wasm::tokio;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
messages::{
|
|
||||||
error::ReportError,
|
|
||||||
steps::game::{
|
|
||||||
GameInstallationProgress, GameStopped, NotifyGameStartDownloading,
|
|
||||||
NotifyGameStartPatching, NotifyGameSuccessfullyInstalled, RunGame,
|
|
||||||
StartGameInstallation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
proton::get_proton,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn listen_game_running() {
|
|
||||||
let mut receiver = RunGame::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let proton = get_proton().await;
|
|
||||||
let game_dir = GameState::get_game_dir().await;
|
|
||||||
if game_dir.is_none() {
|
|
||||||
ReportError {
|
|
||||||
error_message: "Failed to start game, the game directory was not found".to_string(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
GameStopped {}.send_signal_to_dart();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameManager::start_game(&proton, game_dir.unwrap()).await;
|
|
||||||
|
|
||||||
GameStopped {}.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn listen_game_installation() {
|
|
||||||
let mut receiver = StartGameInstallation::get_dart_signal_receiver();
|
|
||||||
while let Some(info) = receiver.recv().await {
|
|
||||||
thread::spawn(move || {
|
|
||||||
debug_print!("start downloading game...");
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
if GameState::get_game_dir().await.is_none() {
|
|
||||||
if let Err(e) = GameState::set_game_dir(Some(
|
|
||||||
GameState::get_config_directory()
|
|
||||||
.await
|
|
||||||
.join("babylonia-terminal-config"),
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
ReportError {
|
|
||||||
error_message: format!("Failed to set new path : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if info.message.is_updating {
|
|
||||||
if let Err(e) = GameManager::update_game().await {
|
|
||||||
ReportError {
|
|
||||||
error_message: format!("Failed to start updating the game : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let game_dir = GameState::get_game_dir().await;
|
|
||||||
if game_dir.is_none() {
|
|
||||||
ReportError {
|
|
||||||
error_message: "Failed to get the game directory".to_string(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
|
|
||||||
match GameManager::install_game(
|
|
||||||
game_dir.clone().unwrap(),
|
|
||||||
InstallationReporter::create(),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install game : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => {
|
|
||||||
NotifyGameStartPatching {}.send_signal_to_dart();
|
|
||||||
debug_print!("start patching game...");
|
|
||||||
match GameManager::patch_game(game_dir.unwrap()).await {
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install game : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => NotifyGameSuccessfullyInstalled {}.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporterPrivate {
|
|
||||||
max_progress: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct InstallationReporter {
|
|
||||||
private: std::sync::Mutex<Option<DownloadReporterPrivate>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InstallationReporter {
|
|
||||||
pub fn create() -> std::sync::Arc<Self> {
|
|
||||||
std::sync::Arc::new(Self {
|
|
||||||
private: std::sync::Mutex::new(None),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl downloader::progress::Reporter for InstallationReporter {
|
|
||||||
fn setup(&self, max_progress: Option<u64>, _: &str) {
|
|
||||||
let private = DownloadReporterPrivate { max_progress };
|
|
||||||
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = Some(private);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn progress(&self, current: u64) {
|
|
||||||
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
|
||||||
GameInstallationProgress {
|
|
||||||
current,
|
|
||||||
max: p.max_progress.unwrap(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_message(&self, _: &str) {}
|
|
||||||
|
|
||||||
fn done(&self) {
|
|
||||||
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
|
||||||
GameInstallationProgress {
|
|
||||||
current: p.max_progress.unwrap(),
|
|
||||||
max: p.max_progress.unwrap(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
use babylonia_terminal_sdk::game_state::GameState;
|
|
||||||
|
|
||||||
use crate::messages::{
|
|
||||||
error::ReportError,
|
|
||||||
game_state::{AskGameState, GameState as GameStateMessage, States},
|
|
||||||
};
|
|
||||||
|
|
||||||
impl GameStateMessage {
|
|
||||||
fn from_sdk_state_to_msg_state(state: GameState) -> Self {
|
|
||||||
let game_state = match state {
|
|
||||||
GameState::ProtonNotInstalled => States::ProtonNotInstalled,
|
|
||||||
GameState::DXVKNotInstalled => States::DxvkNotInstalled,
|
|
||||||
GameState::FontNotInstalled => States::FontNotInstalled,
|
|
||||||
GameState::DependecieNotInstalled => States::DependecieNotInstalled,
|
|
||||||
GameState::GameNotInstalled => States::GameNotInstalled,
|
|
||||||
GameState::GameNeedUpdate => States::GameNeedUpdate,
|
|
||||||
GameState::GameNotPatched => States::GameNotPatched,
|
|
||||||
GameState::GameInstalled => States::GameInstalled,
|
|
||||||
};
|
|
||||||
GameStateMessage {
|
|
||||||
state: game_state.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn listen_game_state() {
|
|
||||||
let mut receiver = AskGameState::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let result_state = GameState::get_current_state().await;
|
|
||||||
match result_state {
|
|
||||||
Ok(state) => GameStateMessage::from_sdk_state_to_msg_state(state).send_signal_to_dart(),
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("When updating the game state : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,57 +0,0 @@
|
|||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::{
|
|
||||||
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
|
||||||
proton_component::{PROTON_DEV, PROTON_REPO},
|
|
||||||
},
|
|
||||||
utils::github_requester::{GithubRelease, GithubRequester},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::messages::{
|
|
||||||
error::ReportError,
|
|
||||||
github::{AskDxvkVersions, AskProtonVersions, DxvkVersions, ProtonVersions},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[warn(dead_code)]
|
|
||||||
pub struct GithubInfo;
|
|
||||||
|
|
||||||
impl GithubRequester for GithubInfo {
|
|
||||||
fn set_github_release_index(&mut self, _: usize) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn listen_proton_version() {
|
|
||||||
let mut receiver = AskProtonVersions::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
|
||||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
|
||||||
match releases {
|
|
||||||
Ok(r) => ProtonVersions {
|
|
||||||
versions: r.iter().map(|v| v.tag_name.to_owned()).collect(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("When fetching proton versions : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn listen_dxvk_version() {
|
|
||||||
let mut receiver = AskDxvkVersions::get_dart_signal_receiver();
|
|
||||||
while let Some(_) = receiver.recv().await {
|
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
|
||||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
|
||||||
match releases {
|
|
||||||
Ok(r) => DxvkVersions {
|
|
||||||
versions: r.iter().map(|v| v.tag_name.to_owned()).collect(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("When fetching dxvk versions : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
use tokio_with_wasm::tokio;
|
|
||||||
|
|
||||||
mod config;
|
|
||||||
mod dependencies;
|
|
||||||
mod dxvk;
|
|
||||||
mod fonts;
|
|
||||||
mod game;
|
|
||||||
mod game_state;
|
|
||||||
mod github;
|
|
||||||
mod messages;
|
|
||||||
mod proton;
|
|
||||||
|
|
||||||
rinf::write_interface!();
|
|
||||||
|
|
||||||
async fn main() {
|
|
||||||
//config
|
|
||||||
tokio::spawn(game_state::listen_game_state());
|
|
||||||
tokio::spawn(config::listen_config());
|
|
||||||
|
|
||||||
//github
|
|
||||||
tokio::spawn(github::listen_proton_version());
|
|
||||||
tokio::spawn(github::listen_dxvk_version());
|
|
||||||
|
|
||||||
//installation
|
|
||||||
tokio::spawn(proton::listen_proton_installation());
|
|
||||||
tokio::spawn(dxvk::listen_dxvk_installation());
|
|
||||||
tokio::spawn(fonts::listen_fonts_installation());
|
|
||||||
tokio::spawn(dependencies::listen_dependecies_installation());
|
|
||||||
tokio::spawn(game::listen_game_installation());
|
|
||||||
|
|
||||||
// game
|
|
||||||
tokio::spawn(game::listen_game_running());
|
|
||||||
}
|
|
||||||
@ -1,137 +0,0 @@
|
|||||||
use std::thread;
|
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
|
||||||
components::{
|
|
||||||
component_downloader::ComponentDownloader,
|
|
||||||
proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
|
||||||
},
|
|
||||||
game_manager::GameManager,
|
|
||||||
game_state::GameState,
|
|
||||||
utils::github_requester::{GithubRelease, GithubRequester},
|
|
||||||
};
|
|
||||||
use rinf::debug_print;
|
|
||||||
use tokio_with_wasm::tokio::{self, sync::OnceCell};
|
|
||||||
use wincompatlib::wine::bundle::proton::Proton;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
github::GithubInfo,
|
|
||||||
messages::{
|
|
||||||
error::ReportError,
|
|
||||||
steps::proton::{
|
|
||||||
NotifyProtonStartDecompressing, NotifyProtonSuccessfullyInstalled,
|
|
||||||
ProtonDownloadProgress, StartProtonInstallation,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static PROTON: OnceCell<Proton> = OnceCell::const_new();
|
|
||||||
|
|
||||||
pub async fn get_proton() -> Proton {
|
|
||||||
PROTON
|
|
||||||
.get_or_init(|| async {
|
|
||||||
let proton_component = ProtonComponent::new(GameState::get_config().await.config_dir);
|
|
||||||
let proton = proton_component.init_proton();
|
|
||||||
if let Err(ref e) = proton {
|
|
||||||
ReportError {
|
|
||||||
error_message: format!("Failed to initialize proton : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
proton.unwrap()
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn listen_proton_installation() {
|
|
||||||
let mut receiver = StartProtonInstallation::get_dart_signal_receiver();
|
|
||||||
while let Some(info) = receiver.recv().await {
|
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
|
||||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
|
||||||
if releases.is_err() {
|
|
||||||
ReportError {
|
|
||||||
error_message: format!("When fetching proton versions : {}", releases.unwrap_err()),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let checked_releases = releases.unwrap();
|
|
||||||
let release_index = checked_releases
|
|
||||||
.iter()
|
|
||||||
.position(|v| v.tag_name == info.message.proton_version);
|
|
||||||
|
|
||||||
if release_index.is_none() {
|
|
||||||
ReportError {
|
|
||||||
error_message: "Failed to find Proton version".to_string(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
tokio::runtime::Builder::new_current_thread()
|
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
match GameManager::install_wine(
|
|
||||||
GameState::get_config().await.config_dir,
|
|
||||||
release_index.unwrap(),
|
|
||||||
Some(DownloadReporter::create()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Err(e) => ReportError {
|
|
||||||
error_message: format!("Failed to install Proton : {}", e),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart(),
|
|
||||||
Ok(_) => NotifyProtonSuccessfullyInstalled {}.send_signal_to_dart(),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporterPrivate {
|
|
||||||
max_progress: Option<u64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct DownloadReporter {
|
|
||||||
private: std::sync::Mutex<Option<DownloadReporterPrivate>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DownloadReporter {
|
|
||||||
pub fn create() -> std::sync::Arc<Self> {
|
|
||||||
std::sync::Arc::new(Self {
|
|
||||||
private: std::sync::Mutex::new(None),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl downloader::progress::Reporter for DownloadReporter {
|
|
||||||
fn setup(&self, max_progress: Option<u64>, _: &str) {
|
|
||||||
let private = DownloadReporterPrivate { max_progress };
|
|
||||||
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = Some(private);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn progress(&self, current: u64) {
|
|
||||||
if let Some(p) = self.private.lock().unwrap().as_mut() {
|
|
||||||
ProtonDownloadProgress {
|
|
||||||
current,
|
|
||||||
max: p.max_progress.unwrap(),
|
|
||||||
}
|
|
||||||
.send_signal_to_dart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_message(&self, _: &str) {}
|
|
||||||
|
|
||||||
fn done(&self) {
|
|
||||||
NotifyProtonStartDecompressing {}.send_signal_to_dart();
|
|
||||||
let mut guard = self.private.lock().unwrap();
|
|
||||||
*guard = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,128 +0,0 @@
|
|||||||
name: babylonia_terminal_launcher
|
|
||||||
description: "A new Flutter project."
|
|
||||||
# The following line prevents the package from being accidentally published to
|
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
# The following defines the version and build number for your application.
|
|
||||||
# A version number is three numbers separated by dots, like 1.2.43
|
|
||||||
# followed by an optional build number separated by a +.
|
|
||||||
# Both the version and the builder number may be overridden in flutter
|
|
||||||
# build by specifying --build-name and --build-number, respectively.
|
|
||||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
|
||||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
|
|
||||||
# Read more about iOS versioning at
|
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
|
||||||
version: 1.0.0+1
|
|
||||||
|
|
||||||
environment:
|
|
||||||
sdk: '>=3.3.4 <4.0.0'
|
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
|
||||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
|
||||||
# dependencies can be manually updated by changing the version numbers below to
|
|
||||||
# the latest version available on pub.dev. To see which dependencies have newer
|
|
||||||
# versions available, run `flutter pub outdated`.
|
|
||||||
dependencies:
|
|
||||||
flutter:
|
|
||||||
sdk: flutter
|
|
||||||
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
|
||||||
cupertino_icons: ^1.0.6
|
|
||||||
yaru: ^4.1.0
|
|
||||||
# media_kit: ^1.1.10+1
|
|
||||||
# media_kit_video: ^1.2.4
|
|
||||||
# media_kit_libs_video: ^1.0.4
|
|
||||||
media_kit: any
|
|
||||||
media_kit_video: any
|
|
||||||
media_kit_libs_video: any
|
|
||||||
media_kit_native_event_loop: any
|
|
||||||
provider: ^6.1.2
|
|
||||||
rinf: ^6.9.0
|
|
||||||
protobuf: ^3.1.0
|
|
||||||
shared_preferences: ^2.2.3
|
|
||||||
http: ^1.2.1
|
|
||||||
flutter_highlight: ^0.7.0
|
|
||||||
fixnum: ^1.1.0
|
|
||||||
|
|
||||||
dependency_overrides:
|
|
||||||
media_kit:
|
|
||||||
git:
|
|
||||||
url: https://github.com/media-kit/media-kit
|
|
||||||
path: media_kit
|
|
||||||
ref: main
|
|
||||||
media_kit_video:
|
|
||||||
git:
|
|
||||||
url: https://github.com/media-kit/media-kit
|
|
||||||
path: media_kit_video
|
|
||||||
ref: main
|
|
||||||
media_kit_libs_video:
|
|
||||||
git:
|
|
||||||
url: https://github.com/media-kit/media-kit
|
|
||||||
path: libs/universal/media_kit_libs_video
|
|
||||||
ref: main
|
|
||||||
|
|
||||||
media_kit_native_event_loop:
|
|
||||||
git:
|
|
||||||
url: https://github.com/media-kit/media-kit
|
|
||||||
path: media_kit_native_event_loop
|
|
||||||
ref: main
|
|
||||||
|
|
||||||
dev_dependencies:
|
|
||||||
flutter_test:
|
|
||||||
sdk: flutter
|
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
|
||||||
# package. See that file for information about deactivating specific lint
|
|
||||||
# rules and activating additional ones.
|
|
||||||
flutter_lints: ^3.0.0
|
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
|
||||||
|
|
||||||
# The following section is specific to Flutter packages.
|
|
||||||
flutter:
|
|
||||||
|
|
||||||
# The following line ensures that the Material Icons font is
|
|
||||||
# included with your application, so that you can use the icons in
|
|
||||||
# the material Icons class.
|
|
||||||
uses-material-design: true
|
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
|
||||||
assets:
|
|
||||||
- assets/images/Lee6.png
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
|
||||||
|
|
||||||
# For details regarding adding assets from package dependencies, see
|
|
||||||
# https://flutter.dev/assets-and-images/#from-packages
|
|
||||||
|
|
||||||
# To add custom fonts to your application, add a fonts section here,
|
|
||||||
# in this "flutter" section. Each entry in this list should have a
|
|
||||||
# "family" key with the font family name, and a "fonts" key with a
|
|
||||||
# list giving the asset and other descriptors for the font. For
|
|
||||||
# example:
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
# - family: Trajan Pro
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/TrajanPro.ttf
|
|
||||||
# - asset: fonts/TrajanPro_Bold.ttf
|
|
||||||
# weight: 700
|
|
||||||
#
|
|
||||||
# For details regarding fonts from package dependencies,
|
|
||||||
# see https://flutter.dev/custom-fonts/#from-packages
|
|
||||||
34
build.sh
Normal file
34
build.sh
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Are you on steam deck? (y/n): " confirm
|
||||||
|
if [[ $confirm =~ ^yes$|^y$|^Y$|^no$|^n$|^N$ ]]; then
|
||||||
|
if [[ $confirm =~ ^yes$|^y$|^Y$ ]]; then
|
||||||
|
isSteamdeck=true
|
||||||
|
else
|
||||||
|
isSteamdeck=false
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $isSteamdeck; then
|
||||||
|
sudo steamos-readonly disable
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v distrobox &>/dev/null; then
|
||||||
|
curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $isSteamdeck; then
|
||||||
|
sudo steamos-readonly enable
|
||||||
|
fi
|
||||||
|
|
||||||
|
xhost +si:localuser:$USER >/dev/null
|
||||||
|
|
||||||
|
distroname="babylonia-terminal-image"
|
||||||
|
distrobox create --image registry.fedoraproject.org/fedora-toolbox:38 -Y --name $distroname
|
||||||
|
distrobox enter --name $distroname -- sudo dnf install -y pkg-config openssl-devel llvm-devel gcc-c++.x86_64
|
||||||
|
distrobox enter --name $distroname -- rustup update
|
||||||
|
distrobox enter --name $distroname -- rustup toolchain install 1.78.0
|
||||||
|
distrobox enter --name $distroname -- cargo install --git https://github.com/ALEZ-DEV/Babylonia-terminal --bin
|
||||||
BIN
docs/Screenshot1.png
Normal file
BIN
docs/Screenshot1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 175 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user