From c6103be68d16492c40762ce6e75366bdd97e5768 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Tue, 18 Jun 2024 19:18:52 +0200 Subject: [PATCH 01/10] added clap --- babylonia-terminal-cli/Cargo.toml | 4 +++- babylonia-terminal-cli/src/arguments.rs | 9 +++++++++ babylonia-terminal-cli/src/main.rs | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 babylonia-terminal-cli/src/arguments.rs diff --git a/babylonia-terminal-cli/Cargo.toml b/babylonia-terminal-cli/Cargo.toml index b2b2752..6e4ba4e 100644 --- a/babylonia-terminal-cli/Cargo.toml +++ b/babylonia-terminal-cli/Cargo.toml @@ -3,7 +3,7 @@ name = "babylonia-terminal-cli" version = "0.1.0" edition = "2021" authors = ["ALEZ-DEV "] -description = "A launcher for a certain anime game " +description = "A launcher to launch a certain anime game on linux" repository = "https://github.com/ALEZ-DEV/Babylonia-terminal" license = "LGPL-3.0-or-later" keywords = ["launcher", "game"] @@ -16,6 +16,8 @@ name = "babylonia-terminal-cli" [dependencies] anyhow = "1.0.83" babylonia-terminal-sdk = { path = "./../babylonia-terminal-sdk" } +clap = { version = "4.5.7", features = ["derive"] } +derive = "1.0.0" dialoguer = "0.11.0" downloader = { git = "https://github.com/ALEZ-DEV/downloader" } # version = "0.2.7", indicatif = "0.17.8" diff --git a/babylonia-terminal-cli/src/arguments.rs b/babylonia-terminal-cli/src/arguments.rs new file mode 100644 index 0000000..acbc3ed --- /dev/null +++ b/babylonia-terminal-cli/src/arguments.rs @@ -0,0 +1,9 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +pub struct Args { + /// Pass launch options to tink the behavior of the game + #[arg(long)] + pub options: Option, +} diff --git a/babylonia-terminal-cli/src/main.rs b/babylonia-terminal-cli/src/main.rs index f5c41d5..01e4e18 100644 --- a/babylonia-terminal-cli/src/main.rs +++ b/babylonia-terminal-cli/src/main.rs @@ -8,14 +8,17 @@ use babylonia_terminal_sdk::{ game_manager::GameManager, game_state::GameState, }; +use clap::Parser; use log::{debug, info, LevelFilter}; use simple_logger::SimpleLogger; use tokio::io::{AsyncBufReadExt, BufReader}; use wincompatlib::prelude::*; +mod arguments; pub mod reporter; pub mod utils; +use crate::arguments::Args; use crate::reporter::DownloadReporter; #[tokio::main] @@ -34,6 +37,9 @@ async fn main() { simple_logger.with_level(LevelFilter::Info).init().unwrap(); } + let args = Args::parse(); + debug!("Launch option -> {:?}", args.options); + let mut proton_component: Option = None; let mut proton: Option = None; From 2fe44960405fad4541896779e915f9d356f7464b Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 21:03:26 +0200 Subject: [PATCH 02/10] can now pass custom launch command with --options " %command%" and the launcher can now print the output of Proton/Wine, it didn't do that previously --- babylonia-terminal-sdk/src/game_manager.rs | 60 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 8007300..4346f3e 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -1,5 +1,6 @@ -use std::{path::PathBuf, sync::Arc}; +use std::{path::PathBuf, sync::Arc, process::{Command, Stdio}, io::{BufReader, BufRead}}; +use dirs::config_dir; use downloader::progress::Reporter; use log::{debug, info}; use tokio::fs::create_dir_all; @@ -11,7 +12,7 @@ use crate::{ game_component::GameComponent, proton_component::ProtonComponent, }, game_patcher, - game_state::GameState, + game_state::{GameConfig, GameState}, utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester}, }; @@ -164,16 +165,55 @@ impl GameManager { Ok(()) } - pub async fn start_game(proton: &Proton, game_dir: PathBuf) { - debug!("Wine version : {:?}", proton.wine().version().unwrap()); - let mut child = proton - .run( - game_dir + pub async fn start_game(proton: &Proton, game_dir: PathBuf, options: Option) { + let proton_version = proton.wine().version().unwrap(); + let exec_path = game_dir .join(get_game_name()) - .join(get_game_name_with_executable()), + .join(get_game_name_with_executable()); + + debug!("Wine version : {:?}", proton_version); + + let mut child = if let Some(custom_command) = options { + debug!("Starting game with --options -> {}", custom_command); + let mut tokens: Vec<&str> = custom_command.split_whitespace().collect(); + + // position of the %command% + let index = tokens.iter().position(|&s| s == "%command%").expect("You forget to put %command% in your custom launch command"); + + Command::new(tokens.get(0).unwrap()) + .args(&tokens[0..(index - 1)]) + .arg(proton.python.as_os_str()) + .arg(GameState::get_config_directory().await.join("proton").join("proton")) + .arg("run") + .arg(exec_path) + .args(&tokens[(index + 1)..tokens.len()]) + .envs(proton.get_envs()) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap() + } else { + debug!("Starting game without --options"); + proton + .run( + exec_path, ) - .unwrap(); - child.wait().expect("The game failed to run"); + .unwrap() + }; + + let stdout = child.stdout.take().unwrap(); + let mut bufread = BufReader::new(stdout); + let mut buf = String::new(); + + while let Ok(n) = bufread.read_line(&mut buf) { + if n > 0 { + info!("[Wine {:?}] : {}", proton_version, buf.trim()); + buf.clear(); + } else { + break; + } + } } } From f87289be544d187e9e23cd39aa7a14de7d5ba4ae Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 21:03:38 +0200 Subject: [PATCH 03/10] typo --- babylonia-terminal-cli/src/arguments.rs | 2 +- babylonia-terminal-cli/src/main.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/babylonia-terminal-cli/src/arguments.rs b/babylonia-terminal-cli/src/arguments.rs index acbc3ed..586e4ee 100644 --- a/babylonia-terminal-cli/src/arguments.rs +++ b/babylonia-terminal-cli/src/arguments.rs @@ -3,7 +3,7 @@ use clap::Parser; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] pub struct Args { - /// Pass launch options to tink the behavior of the game + /// Pass launch options to tinker the behavior of the game #[arg(long)] pub options: Option, } diff --git a/babylonia-terminal-cli/src/main.rs b/babylonia-terminal-cli/src/main.rs index 01e4e18..844ed30 100644 --- a/babylonia-terminal-cli/src/main.rs +++ b/babylonia-terminal-cli/src/main.rs @@ -192,6 +192,7 @@ async fn main() { GameState::get_game_dir() .await .expect("Failed to start game, the game directory was not found"), + args.options, ) .await; } From 245e0425601580da7bc6687e6dee871570361151 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 21:17:52 +0200 Subject: [PATCH 04/10] remove warning --- babylonia-terminal-sdk/src/components/game_component.rs | 2 +- babylonia-terminal-sdk/src/game_manager.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/babylonia-terminal-sdk/src/components/game_component.rs b/babylonia-terminal-sdk/src/components/game_component.rs index 5d1e6bd..6f4840b 100644 --- a/babylonia-terminal-sdk/src/components/game_component.rs +++ b/babylonia-terminal-sdk/src/components/game_component.rs @@ -79,7 +79,7 @@ impl GameComponent { match v { Some(str) => { if str == "done" { - if let Ok(size) = current_size { + if let Ok(_size) = current_size { progress.done(); } break; diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 4346f3e..38026ea 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -1,6 +1,5 @@ use std::{path::PathBuf, sync::Arc, process::{Command, Stdio}, io::{BufReader, BufRead}}; -use dirs::config_dir; use downloader::progress::Reporter; use log::{debug, info}; use tokio::fs::create_dir_all; @@ -12,7 +11,7 @@ use crate::{ game_component::GameComponent, proton_component::ProtonComponent, }, game_patcher, - game_state::{GameConfig, GameState}, + game_state::GameState, utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester}, }; @@ -175,7 +174,7 @@ impl GameManager { let mut child = if let Some(custom_command) = options { debug!("Starting game with --options -> {}", custom_command); - let mut tokens: Vec<&str> = custom_command.split_whitespace().collect(); + let tokens: Vec<&str> = custom_command.split_whitespace().collect(); // position of the %command% let index = tokens.iter().position(|&s| s == "%command%").expect("You forget to put %command% in your custom launch command"); From 57708783900ac9fd9d5144479c97fdcd81cffb9e Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 22:08:25 +0200 Subject: [PATCH 05/10] some refactor --- babylonia-terminal-cli/src/main.rs | 24 ++-- babylonia-terminal-sdk/src/game_manager.rs | 28 ++--- babylonia-terminal-sdk/src/game_patcher.rs | 6 +- babylonia-terminal-sdk/src/game_state.rs | 104 +++++++++--------- babylonia-terminal-sdk/src/lib.rs | 1 + .../src/utils/kuro_prod_api.rs | 5 +- shell.nix | 1 + 7 files changed, 87 insertions(+), 82 deletions(-) diff --git a/babylonia-terminal-cli/src/main.rs b/babylonia-terminal-cli/src/main.rs index 844ed30..10d1ec6 100644 --- a/babylonia-terminal-cli/src/main.rs +++ b/babylonia-terminal-cli/src/main.rs @@ -6,7 +6,7 @@ use babylonia_terminal_sdk::{ proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO}, }, game_manager::GameManager, - game_state::GameState, + game_state::{GameConfig, GameState}, }; use clap::Parser; use log::{debug, info, LevelFilter}; @@ -52,7 +52,7 @@ async fn main() { let state = state_result.unwrap(); 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() { Ok(p) => proton = Some(p), Err(err) => panic!("{}", err), @@ -77,7 +77,7 @@ async fn main() { info!("Proton not installed, installing it..."); proton_component = Some( GameManager::install_wine( - GameState::get_config_directory().await, + GameConfig::get_config_directory().await, release, Some(DownloadReporter::create(false)), ) @@ -106,7 +106,7 @@ async fn main() { debug!("{:?}", proton_component); GameManager::install_dxvk( &proton.clone().unwrap(), - GameState::get_config_directory().await, + GameConfig::get_config_directory().await, release, Some(DownloadReporter::create(false)), ) @@ -130,10 +130,10 @@ async fn main() { } GameState::GameNotInstalled => { info!("Game not installed, installing it..."); - if GameState::get_game_dir().await.is_none() { + if GameConfig::get_game_dir().await.is_none() { info!( "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 : "); let mut input = BufReader::new(tokio::io::stdin()) @@ -145,21 +145,21 @@ async fn main() { let dir; if let Some(i) = &mut input { if i.is_empty() { - dir = GameState::get_config_directory().await; + dir = GameConfig::get_config_directory().await; } else { dir = PathBuf::from_str(i).expect("This is not a valid directory!\n Please restart the launcher and put a valid path."); } } 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!", ); } GameManager::install_game( - GameState::get_game_dir().await.unwrap(), + GameConfig::get_game_dir().await.unwrap(), DownloadReporter::create(false), ) .await @@ -174,7 +174,7 @@ async fn main() { } GameState::GameNotPatched => { info!("Patching game..."); - GameManager::patch_game(GameState::get_game_dir().await.unwrap()) + GameManager::patch_game(GameConfig::get_game_dir().await.unwrap()) .await .expect("Failed to patch the game"); info!("Game patched!"); @@ -189,7 +189,7 @@ async fn main() { debug!("{:?}", proton); GameManager::start_game( &proton.unwrap(), - GameState::get_game_dir() + GameConfig::get_game_dir() .await .expect("Failed to start game, the game directory was not found"), args.options, diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 38026ea..f414b97 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -11,7 +11,7 @@ use crate::{ game_component::GameComponent, proton_component::ProtonComponent, }, game_patcher, - game_state::GameState, + game_state::{GameConfig, GameState}, utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester}, }; @@ -31,9 +31,9 @@ impl GameManager { wine_component.install(progress).await?; - let mut config = GameState::get_config().await; + let mut config = GameConfig::get_config().await; config.is_wine_installed = true; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(wine_component) } @@ -52,9 +52,9 @@ impl GameManager { dxvk_component.install(progress).await?; - let mut config = GameState::get_config().await; + let mut config = GameConfig::get_config().await; config.is_dxvk_installed = true; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } @@ -103,9 +103,9 @@ impl GameManager { wine_with_proton_prefix.install_font(Font::Webdings)?; notify_fonts_progress(10, &progress); - let mut config = GameState::get_config().await; + let mut config = GameConfig::get_config().await; config.is_font_installed = true; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } @@ -124,9 +124,9 @@ impl GameManager { .wait() .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; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } @@ -140,9 +140,9 @@ impl GameManager { let game_component = GameComponent::new(game_dir); 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; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } @@ -150,10 +150,10 @@ impl GameManager { // 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 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_patched = false; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } @@ -182,7 +182,7 @@ impl GameManager { Command::new(tokens.get(0).unwrap()) .args(&tokens[0..(index - 1)]) .arg(proton.python.as_os_str()) - .arg(GameState::get_config_directory().await.join("proton").join("proton")) + .arg(GameConfig::get_config_directory().await.join("proton").join("proton")) .arg("run") .arg(exec_path) .args(&tokens[(index + 1)..tokens.len()]) diff --git a/babylonia-terminal-sdk/src/game_patcher.rs b/babylonia-terminal-sdk/src/game_patcher.rs index 9dac873..23fb99e 100644 --- a/babylonia-terminal-sdk/src/game_patcher.rs +++ b/babylonia-terminal-sdk/src/game_patcher.rs @@ -8,7 +8,7 @@ use tokio::{ }; use crate::{ - game_state::GameState, + game_state::{GameConfig, GameState}, 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; - GameState::save_config(config).await?; + GameConfig::save_config(config).await?; Ok(()) } diff --git a/babylonia-terminal-sdk/src/game_state.rs b/babylonia-terminal-sdk/src/game_state.rs index 508024e..36b7c12 100644 --- a/babylonia-terminal-sdk/src/game_state.rs +++ b/babylonia-terminal-sdk/src/game_state.rs @@ -32,6 +32,58 @@ pub struct GameConfig { pub is_game_patched: bool, } +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) -> 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 { + Self::get_config().await.game_dir + } + + async fn try_get_config_file() -> anyhow::Result { + 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::(&content) { + Ok(config) => return config, + Err(_) => return Self::default(), + } + } +} + #[derive(Debug, Serialize, Deserialize)] pub struct GameConfigPath { path: PathBuf, @@ -53,58 +105,8 @@ impl Default for GameConfig { } 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) -> 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 { - GameState::get_config().await.game_dir - } - - async fn try_get_config_file() -> anyhow::Result { - 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::(&content) { - Ok(config) => return config, - Err(_) => return GameConfig::default(), - } - } - pub async fn get_current_state() -> anyhow::Result { - let config = GameState::get_config().await; + let config = GameConfig::get_config().await; if !config.is_wine_installed { return Ok(GameState::ProtonNotInstalled); diff --git a/babylonia-terminal-sdk/src/lib.rs b/babylonia-terminal-sdk/src/lib.rs index 770fe8d..1ad7518 100644 --- a/babylonia-terminal-sdk/src/lib.rs +++ b/babylonia-terminal-sdk/src/lib.rs @@ -1,4 +1,5 @@ pub mod components; +pub mod game_config; pub mod game_manager; pub mod game_patcher; pub mod game_state; diff --git a/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs b/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs index 2831bbf..a1887c8 100644 --- a/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs +++ b/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs @@ -5,6 +5,7 @@ use serde::Serialize; use tokio::fs::read_to_string; use tokio::io::AsyncWriteExt; +use crate::game_state::GameConfig; use crate::game_state::GameState; // start data --------------------------------------------------------------------- @@ -157,13 +158,13 @@ impl GameInfo { } async fn get_cache_file_path() -> PathBuf { - GameState::get_config_directory() + GameConfig::get_config_directory() .await .join("version-cache") } 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 content = serde_json::to_string(self)?; diff --git a/shell.nix b/shell.nix index 52608d7..7ae1118 100644 --- a/shell.nix +++ b/shell.nix @@ -4,6 +4,7 @@ pkgs.mkShell { rustup rustfmt clippy + rust-analyzer gcc pkg-config ]; From dcf90310e35ff19a2e5f4c132fa19c44d8960098 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 22:15:03 +0200 Subject: [PATCH 06/10] move all config part from `game_state.rs` to `game_config.rs` --- babylonia-terminal-sdk/src/game_config.rs | 92 ++++++++++++++++++ babylonia-terminal-sdk/src/game_manager.rs | 35 ++++--- babylonia-terminal-sdk/src/game_patcher.rs | 2 +- babylonia-terminal-sdk/src/game_state.rs | 94 +------------------ .../src/utils/kuro_prod_api.rs | 3 +- 5 files changed, 117 insertions(+), 109 deletions(-) create mode 100644 babylonia-terminal-sdk/src/game_config.rs diff --git a/babylonia-terminal-sdk/src/game_config.rs b/babylonia-terminal-sdk/src/game_config.rs new file mode 100644 index 0000000..d61954e --- /dev/null +++ b/babylonia-terminal-sdk/src/game_config.rs @@ -0,0 +1,92 @@ +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, + pub is_game_installed: bool, + pub is_game_patched: bool, +} + +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) -> 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 { + Self::get_config().await.game_dir + } + + async fn try_get_config_file() -> anyhow::Result { + 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::(&content) { + Ok(config) => return config, + Err(_) => return Self::default(), + } + } +} + +#[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, + } + } +} diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index f414b97..6c6c92e 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -1,4 +1,9 @@ -use std::{path::PathBuf, sync::Arc, process::{Command, Stdio}, io::{BufReader, BufRead}}; +use std::{ + io::{BufRead, BufReader}, + path::PathBuf, + process::{Command, Stdio}, + sync::Arc, +}; use downloader::progress::Reporter; use log::{debug, info}; @@ -10,8 +15,8 @@ use crate::{ component_downloader::ComponentDownloader, dxvk_component::DXVKComponent, game_component::GameComponent, proton_component::ProtonComponent, }, + game_config::GameConfig, game_patcher, - game_state::{GameConfig, GameState}, utils::{get_game_name, get_game_name_with_executable, github_requester::GithubRequester}, }; @@ -167,22 +172,30 @@ impl GameManager { pub async fn start_game(proton: &Proton, game_dir: PathBuf, options: Option) { let proton_version = proton.wine().version().unwrap(); let exec_path = game_dir - .join(get_game_name()) - .join(get_game_name_with_executable()); + .join(get_game_name()) + .join(get_game_name_with_executable()); debug!("Wine version : {:?}", proton_version); - + let mut child = if let Some(custom_command) = options { debug!("Starting game with --options -> {}", custom_command); let tokens: Vec<&str> = custom_command.split_whitespace().collect(); // position of the %command% - let index = tokens.iter().position(|&s| s == "%command%").expect("You forget to put %command% in your custom launch command"); + let index = tokens + .iter() + .position(|&s| s == "%command%") + .expect("You forget to put %command% in your custom launch command"); Command::new(tokens.get(0).unwrap()) .args(&tokens[0..(index - 1)]) .arg(proton.python.as_os_str()) - .arg(GameConfig::get_config_directory().await.join("proton").join("proton")) + .arg( + GameConfig::get_config_directory() + .await + .join("proton") + .join("proton"), + ) .arg("run") .arg(exec_path) .args(&tokens[(index + 1)..tokens.len()]) @@ -194,13 +207,9 @@ impl GameManager { .unwrap() } else { debug!("Starting game without --options"); - proton - .run( - exec_path, - ) - .unwrap() + proton.run(exec_path).unwrap() }; - + let stdout = child.stdout.take().unwrap(); let mut bufread = BufReader::new(stdout); let mut buf = String::new(); diff --git a/babylonia-terminal-sdk/src/game_patcher.rs b/babylonia-terminal-sdk/src/game_patcher.rs index 23fb99e..20e40c5 100644 --- a/babylonia-terminal-sdk/src/game_patcher.rs +++ b/babylonia-terminal-sdk/src/game_patcher.rs @@ -8,7 +8,7 @@ use tokio::{ }; use crate::{ - game_state::{GameConfig, GameState}, + game_config::GameConfig, utils::{get_game_name, get_game_name_with_executable}, }; diff --git a/babylonia-terminal-sdk/src/game_state.rs b/babylonia-terminal-sdk/src/game_state.rs index 36b7c12..5039a8d 100644 --- a/babylonia-terminal-sdk/src/game_state.rs +++ b/babylonia-terminal-sdk/src/game_state.rs @@ -1,12 +1,4 @@ -use dirs::home_dir; -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; +use crate::{game_config::GameConfig, utils::kuro_prod_api::GameInfo}; #[derive(Debug, PartialEq, Eq)] pub enum GameState { @@ -20,90 +12,6 @@ pub enum GameState { 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, - pub is_game_installed: bool, - pub is_game_patched: bool, -} - -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) -> 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 { - Self::get_config().await.game_dir - } - - async fn try_get_config_file() -> anyhow::Result { - 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::(&content) { - Ok(config) => return config, - Err(_) => return Self::default(), - } - } -} - -#[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 { pub async fn get_current_state() -> anyhow::Result { let config = GameConfig::get_config().await; diff --git a/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs b/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs index a1887c8..df24ae2 100644 --- a/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs +++ b/babylonia-terminal-sdk/src/utils/kuro_prod_api.rs @@ -5,8 +5,7 @@ use serde::Serialize; use tokio::fs::read_to_string; use tokio::io::AsyncWriteExt; -use crate::game_state::GameConfig; -use crate::game_state::GameState; +use crate::game_config::GameConfig; // start data --------------------------------------------------------------------- From 735ca25e08a3d2ef3cd29b3ea616451412d95115 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 22:48:57 +0200 Subject: [PATCH 07/10] can now set in the config file a launch command with --set-options --- babylonia-terminal-cli/src/arguments.rs | 8 +- babylonia-terminal-cli/src/game.rs | 175 +++++++++++++++++++++ babylonia-terminal-cli/src/main.rs | 175 +-------------------- babylonia-terminal-sdk/src/game_config.rs | 13 ++ babylonia-terminal-sdk/src/game_manager.rs | 75 +++++---- 5 files changed, 248 insertions(+), 198 deletions(-) create mode 100644 babylonia-terminal-cli/src/game.rs diff --git a/babylonia-terminal-cli/src/arguments.rs b/babylonia-terminal-cli/src/arguments.rs index 586e4ee..418fa0d 100644 --- a/babylonia-terminal-cli/src/arguments.rs +++ b/babylonia-terminal-cli/src/arguments.rs @@ -3,7 +3,13 @@ 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 + /// Pass launch options to tinker the behavior of the game, this parameter have priotiy over the + /// --set-options param #[arg(long)] pub options: Option, + + /// 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, } diff --git a/babylonia-terminal-cli/src/game.rs b/babylonia-terminal-cli/src/game.rs new file mode 100644 index 0000000..f471839 --- /dev/null +++ b/babylonia-terminal-cli/src/game.rs @@ -0,0 +1,175 @@ +use std::{path::PathBuf, str::FromStr, sync::Arc}; + +use babylonia_terminal_sdk::{ + components::{ + dxvk_component::{DXVK_DEV, DXVK_REPO}, + proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO}, + }, + game_config::GameConfig, + game_manager::GameManager, + game_state::GameState, +}; + +use log::{debug, info}; +use tokio::io::{AsyncBufReadExt, BufReader}; +use wincompatlib::prelude::*; + +use crate::{reporter::DownloadReporter, utils}; + +pub async fn run(launch_options: Option) { + let mut proton_component: Option = None; + let mut proton: Option = None; + + loop { + let state_result = GameState::get_current_state().await; + if let Err(error) = state_result { + info!("Something goes wrong : {:?}", error); + break; + } + let state = state_result.unwrap(); + + if state != GameState::ProtonNotInstalled && proton == None { + let proton_component = ProtonComponent::new(GameConfig::get_config_directory().await); + match proton_component.init_proton() { + Ok(p) => proton = Some(p), + Err(err) => panic!("{}", err), + }; + } + + match state { + GameState::ProtonNotInstalled => { + let release; + if utils::use_latest("Do you want to install latest version of Proton GE or a specific version of it?") { + release = 0; + } else { + release = utils::choose_release_version( + PROTON_DEV, + PROTON_REPO, + "Please, select a version of Proton GE to install.", + ) + .await + .expect("Failed to fetch proton version!"); + } + + info!("Proton not installed, installing it..."); + proton_component = Some( + GameManager::install_wine( + GameConfig::get_config_directory().await, + release, + Some(DownloadReporter::create(false)), + ) + .await + .expect("Failed to install Wine"), + ); + info!("Proton installed"); + } + GameState::DXVKNotInstalled => { + let release; + if utils::use_latest( + "Do you want to install latest version of DXVK or a specific version of it?", + ) { + release = 0; + } else { + release = utils::choose_release_version( + DXVK_DEV, + DXVK_REPO, + "Please, select a version of DXVK to install.", + ) + .await + .expect("Failed to fetch DXVK version!"); + } + + info!("DXVK not installed, installing it..."); + debug!("{:?}", proton_component); + GameManager::install_dxvk( + &proton.clone().unwrap(), + GameConfig::get_config_directory().await, + release, + Some(DownloadReporter::create(false)), + ) + .await + .expect("Failed to installed DXVK"); + info!("DXVK installed"); + } + GameState::FontNotInstalled => { + info!("Fonts not installed, installing it..."); + GameManager::install_font(&proton.clone().unwrap(), None::>) + .await + .expect("Failed to install fonts"); + info!("Fonts installed"); + } + GameState::DependecieNotInstalled => { + info!("Dependecies not installed, installing it..."); + GameManager::install_dependencies(&proton.clone().unwrap()) + .await + .expect("Failed to install dependecies"); + info!("Dependecies installed"); + } + GameState::GameNotInstalled => { + info!("Game not installed, installing it..."); + if GameConfig::get_game_dir().await.is_none() { + info!( + "You can choose where to put your game directory, (default '{}')", + GameConfig::get_config_directory().await.to_str().unwrap(), + ); + info!("Please enter your wanted game directory : "); + let mut input = BufReader::new(tokio::io::stdin()) + .lines() + .next_line() + .await + .unwrap(); + + let dir; + if let Some(i) = &mut input { + if i.is_empty() { + dir = GameConfig::get_config_directory().await; + } else { + dir = PathBuf::from_str(i).expect("This is not a valid directory!\n Please restart the launcher and put a valid path."); + } + } else { + dir = GameConfig::get_config_directory().await; + } + + GameConfig::set_game_dir(Some(dir)).await.expect( + "Failed to save the game directory into the config file, please retry!", + ); + } + + GameManager::install_game( + GameConfig::get_game_dir().await.unwrap(), + DownloadReporter::create(false), + ) + .await + .expect("Failed to install the game"); + } + GameState::GameNeedUpdate => { + info!("Game need an update, updating it"); + info!("This will restart the installation process..."); + GameManager::update_game() + .await + .expect("Failed to start the installation process"); + } + GameState::GameNotPatched => { + info!("Patching game..."); + GameManager::patch_game(GameConfig::get_game_dir().await.unwrap()) + .await + .expect("Failed to patch the game"); + info!("Game patched!"); + } + GameState::GameInstalled => { + break; + } + } + } + + info!("Starting game..."); + debug!("{:?}", proton); + GameManager::start_game( + &proton.unwrap(), + GameConfig::get_game_dir() + .await + .expect("Failed to start game, the game directory was not found"), + launch_options, + ) + .await; +} diff --git a/babylonia-terminal-cli/src/main.rs b/babylonia-terminal-cli/src/main.rs index 10d1ec6..bd700da 100644 --- a/babylonia-terminal-cli/src/main.rs +++ b/babylonia-terminal-cli/src/main.rs @@ -1,25 +1,14 @@ -use std::{path::PathBuf, str::FromStr, sync::Arc}; - -use babylonia_terminal_sdk::{ - components::{ - dxvk_component::{DXVK_DEV, DXVK_REPO}, - proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO}, - }, - game_manager::GameManager, - game_state::{GameConfig, GameState}, -}; +use babylonia_terminal_sdk::game_config::GameConfig; use clap::Parser; -use log::{debug, info, LevelFilter}; +use log::{debug, LevelFilter}; use simple_logger::SimpleLogger; -use tokio::io::{AsyncBufReadExt, BufReader}; -use wincompatlib::prelude::*; mod arguments; +pub mod game; pub mod reporter; pub mod utils; use crate::arguments::Args; -use crate::reporter::DownloadReporter; #[tokio::main] async fn main() { @@ -40,159 +29,11 @@ async fn main() { let args = Args::parse(); debug!("Launch option -> {:?}", args.options); - let mut proton_component: Option = None; - let mut proton: Option = None; - - loop { - let state_result = GameState::get_current_state().await; - if let Err(error) = state_result { - info!("Something goes wrong : {:?}", error); - break; - } - let state = state_result.unwrap(); - - if state != GameState::ProtonNotInstalled && proton == None { - let proton_component = ProtonComponent::new(GameConfig::get_config_directory().await); - match proton_component.init_proton() { - Ok(p) => proton = Some(p), - Err(err) => panic!("{}", err), - }; - } - - match state { - GameState::ProtonNotInstalled => { - let release; - if utils::use_latest("Do you want to install latest version of Proton GE or a specific version of it?") { - release = 0; - } else { - release = utils::choose_release_version( - PROTON_DEV, - PROTON_REPO, - "Please, select a version of Proton GE to install.", - ) - .await - .expect("Failed to fetch proton version!"); - } - - info!("Proton not installed, installing it..."); - proton_component = Some( - GameManager::install_wine( - GameConfig::get_config_directory().await, - release, - Some(DownloadReporter::create(false)), - ) - .await - .expect("Failed to install Wine"), - ); - info!("Proton installed"); - } - GameState::DXVKNotInstalled => { - let release; - if utils::use_latest( - "Do you want to install latest version of DXVK or a specific version of it?", - ) { - release = 0; - } else { - release = utils::choose_release_version( - DXVK_DEV, - DXVK_REPO, - "Please, select a version of DXVK to install.", - ) - .await - .expect("Failed to fetch DXVK version!"); - } - - info!("DXVK not installed, installing it..."); - debug!("{:?}", proton_component); - GameManager::install_dxvk( - &proton.clone().unwrap(), - GameConfig::get_config_directory().await, - release, - Some(DownloadReporter::create(false)), - ) - .await - .expect("Failed to installed DXVK"); - info!("DXVK installed"); - } - GameState::FontNotInstalled => { - info!("Fonts not installed, installing it..."); - GameManager::install_font(&proton.clone().unwrap(), None::>) - .await - .expect("Failed to install fonts"); - info!("Fonts installed"); - } - GameState::DependecieNotInstalled => { - info!("Dependecies not installed, installing it..."); - GameManager::install_dependencies(&proton.clone().unwrap()) - .await - .expect("Failed to install dependecies"); - info!("Dependecies installed"); - } - GameState::GameNotInstalled => { - info!("Game not installed, installing it..."); - if GameConfig::get_game_dir().await.is_none() { - info!( - "You can choose where to put your game directory, (default '{}')", - GameConfig::get_config_directory().await.to_str().unwrap(), - ); - info!("Please enter your wanted game directory : "); - let mut input = BufReader::new(tokio::io::stdin()) - .lines() - .next_line() - .await - .unwrap(); - - let dir; - if let Some(i) = &mut input { - if i.is_empty() { - dir = GameConfig::get_config_directory().await; - } else { - dir = PathBuf::from_str(i).expect("This is not a valid directory!\n Please restart the launcher and put a valid path."); - } - } else { - dir = GameConfig::get_config_directory().await; - } - - GameConfig::set_game_dir(Some(dir)).await.expect( - "Failed to save the game directory into the config file, please retry!", - ); - } - - GameManager::install_game( - GameConfig::get_game_dir().await.unwrap(), - DownloadReporter::create(false), - ) - .await - .expect("Failed to install the game"); - } - GameState::GameNeedUpdate => { - info!("Game need an update, updating it"); - info!("This will restart the installation process..."); - GameManager::update_game() - .await - .expect("Failed to start the installation process"); - } - GameState::GameNotPatched => { - info!("Patching game..."); - GameManager::patch_game(GameConfig::get_game_dir().await.unwrap()) - .await - .expect("Failed to patch the game"); - info!("Game patched!"); - } - GameState::GameInstalled => { - break; - } - } + if let Some(command) = args.set_options { + GameConfig::set_launch_options(command) + .await + .expect("Failed to save launch options into the config file"); } - info!("Starting game..."); - debug!("{:?}", proton); - GameManager::start_game( - &proton.unwrap(), - GameConfig::get_game_dir() - .await - .expect("Failed to start game, the game directory was not found"), - args.options, - ) - .await; + game::run(args.options).await; } diff --git a/babylonia-terminal-sdk/src/game_config.rs b/babylonia-terminal-sdk/src/game_config.rs index d61954e..6a359e0 100644 --- a/babylonia-terminal-sdk/src/game_config.rs +++ b/babylonia-terminal-sdk/src/game_config.rs @@ -17,6 +17,7 @@ pub struct GameConfig { pub game_dir: Option, pub is_game_installed: bool, pub is_game_patched: bool, + pub launch_options: Option, } impl GameConfig { @@ -69,6 +70,17 @@ impl GameConfig { Err(_) => return Self::default(), } } + + pub async fn set_launch_options(command: String) -> anyhow::Result<()> { + let mut config = Self::get_config().await; + config.launch_options = Some(command); + Self::save_config(config).await?; + Ok(()) + } + + pub async fn get_launch_options() -> anyhow::Result> { + Ok(Self::get_config().await.launch_options) + } } #[derive(Debug, Serialize, Deserialize)] @@ -87,6 +99,7 @@ impl Default for GameConfig { game_dir: None, is_game_installed: false, is_game_patched: false, + launch_options: None, } } } diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 6c6c92e..7f96fb9 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -1,7 +1,7 @@ use std::{ io::{BufRead, BufReader}, path::PathBuf, - process::{Command, Stdio}, + process::{Child, Command, Stdio}, sync::Arc, }; @@ -171,43 +171,25 @@ impl GameManager { pub async fn start_game(proton: &Proton, game_dir: PathBuf, options: Option) { let proton_version = proton.wine().version().unwrap(); - let exec_path = game_dir + let binary_path = game_dir .join(get_game_name()) .join(get_game_name_with_executable()); debug!("Wine version : {:?}", proton_version); let mut child = if let Some(custom_command) = options { - debug!("Starting game with --options -> {}", custom_command); - let tokens: Vec<&str> = custom_command.split_whitespace().collect(); - - // position of the %command% - let index = tokens - .iter() - .position(|&s| s == "%command%") - .expect("You forget to put %command% in your custom launch command"); - - Command::new(tokens.get(0).unwrap()) - .args(&tokens[0..(index - 1)]) - .arg(proton.python.as_os_str()) - .arg( - GameConfig::get_config_directory() - .await - .join("proton") - .join("proton"), - ) - .arg("run") - .arg(exec_path) - .args(&tokens[(index + 1)..tokens.len()]) - .envs(proton.get_envs()) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() + Self::run(proton, binary_path, custom_command) + .await .unwrap() } else { - debug!("Starting game without --options"); - proton.run(exec_path).unwrap() + if let Some(custom_command) = GameConfig::get_launch_options().await.unwrap() { + Self::run(proton, binary_path, custom_command) + .await + .unwrap() + } else { + debug!("Starting game without --options"); + proton.run(binary_path).unwrap() + } }; let stdout = child.stdout.take().unwrap(); @@ -223,6 +205,39 @@ impl GameManager { } } } + + async fn run( + proton: &Proton, + binary_path: PathBuf, + custom_command: String, + ) -> Result { + debug!("Starting game with --options -> {}", custom_command); + let tokens: Vec<&str> = custom_command.split_whitespace().collect(); + + // position of the %command% + let index = tokens + .iter() + .position(|&s| s == "%command%") + .expect("You forget to put %command% in your custom launch command"); + + Command::new(tokens.get(0).unwrap()) + .args(&tokens[0..(index - 1)]) + .arg(proton.python.as_os_str()) + .arg( + GameConfig::get_config_directory() + .await + .join("proton") + .join("proton"), + ) + .arg("run") + .arg(binary_path) + .args(&tokens[(index + 1)..tokens.len()]) + .envs(proton.get_envs()) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + } } fn notify_fonts_progress

(nbr: u64, progress: &Option>) From b4d4a6802b60bc7b89bcfc97f8ecd456c4b26ecd Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 22:52:59 +0200 Subject: [PATCH 08/10] typo --- babylonia-terminal-cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babylonia-terminal-cli/Cargo.toml b/babylonia-terminal-cli/Cargo.toml index 6e4ba4e..4e47b5c 100644 --- a/babylonia-terminal-cli/Cargo.toml +++ b/babylonia-terminal-cli/Cargo.toml @@ -3,7 +3,7 @@ name = "babylonia-terminal-cli" version = "0.1.0" edition = "2021" authors = ["ALEZ-DEV "] -description = "A launcher to launch a certain anime game on linux" +description = "A launcher for a certain anime game on linux" repository = "https://github.com/ALEZ-DEV/Babylonia-terminal" license = "LGPL-3.0-or-later" keywords = ["launcher", "game"] From 5890fce5f4f23fc37f49c30ebee8b6b04492d3bf Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 23:06:39 +0200 Subject: [PATCH 09/10] add explanation to the README --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c0678fa..af8f296 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ You need Steam to be installed to run the game To install the cli version of the launcher, just start this command : -``` +```bash cargo install --git https://github.com/ALEZ-DEV/Babylonia-terminal --bin ``` @@ -37,6 +37,30 @@ babylonia-terminal-cli ``` If you have any issue installing it on Steam deck or any other distro, [go check the wiki](https://github.com/ALEZ-DEV/Babylonia-terminal/wiki) +## Launch options + +If you want to wrap mangohud, gamescope, gamemoderun or any other process over the game, you can't just wrap the launcher for the wrapper to work, example : `mangohud babylonia-terminal-cli`. +The launcher has a parameter you can use to pass special launch options, you can pass options like this : + +```bash +# %command% will be replaced by the actual command that Babylonia-terminal will generate +babylonia-terminal-cli --options " %command%" +``` + +So for example, if I want to wrap the game with mangohud : + +```bash +babylonia-terminal-cli --options "mangohud %command%" +``` + +But start the game with the `--options` parameter every time is a bit annoying, so you can just run the command with `--set-options` instead the first time you want to set the launch options : + +```bash +babylonia-terminal-cli --set-options "mangohud %command%" +``` + +and the next time you want to start the launcher, you will just need to start it with `babylonia-terminal-cli` + ## Special thank Thank to [krypt0nn](https://github.com/krypt0nn) to made the [wincompatlib](https://github.com/krypt0nn/wincompatlib) library! From d7f10a16ffccd54cdf1b938e21009f10c191b46a Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 17 Jul 2024 23:08:26 +0200 Subject: [PATCH 10/10] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af8f296..a6cdf62 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ So for example, if I want to wrap the game with mangohud : babylonia-terminal-cli --options "mangohud %command%" ``` -But start the game with the `--options` parameter every time is a bit annoying, so you can just run the command with `--set-options` instead the first time you want to set the launch options : +But start the game with the `--options` parameter every time is a bit annoying, so you can just run the command with `--set-options` instead the first time you want to setup the launch options : ```bash babylonia-terminal-cli --set-options "mangohud %command%"