From cf05625135f05ea8dedb3013533cc2240b7b7708 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Sat, 4 May 2024 19:24:59 +0200 Subject: [PATCH] the launcher can now patch the game --- babylonia-terminal-cli/Cargo.lock | 134 ++++++++++++++++++ babylonia-terminal-cli/src/main.rs | 15 +- babylonia-terminal-sdk/Cargo.lock | 134 ++++++++++++++++++ babylonia-terminal-sdk/Cargo.toml | 1 + babylonia-terminal-sdk/assets/patched.exe | Bin 0 -> 3072 bytes .../src/components/game_component.rs | 6 +- babylonia-terminal-sdk/src/game_manager.rs | 17 ++- babylonia-terminal-sdk/src/game_patcher.rs | 104 ++++++++++++++ babylonia-terminal-sdk/src/game_state.rs | 7 + babylonia-terminal-sdk/src/utils/mod.rs | 8 ++ 10 files changed, 421 insertions(+), 5 deletions(-) create mode 100644 babylonia-terminal-sdk/assets/patched.exe create mode 100644 babylonia-terminal-sdk/src/game_patcher.rs diff --git a/babylonia-terminal-cli/Cargo.lock b/babylonia-terminal-cli/Cargo.lock index 8df03cf..7c7223e 100644 --- a/babylonia-terminal-cli/Cargo.lock +++ b/babylonia-terminal-cli/Cargo.lock @@ -83,6 +83,7 @@ dependencies = [ "fs_extra", "log", "reqwest 0.12.2", + "rust-embed", "serde", "serde_json", "tar", @@ -137,6 +138,15 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.15.4" @@ -252,6 +262,15 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.0" @@ -261,6 +280,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "deranged" version = "0.3.11" @@ -270,6 +299,16 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "5.0.1" @@ -493,6 +532,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -1251,6 +1300,40 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rust-embed" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +dependencies = [ + "sha2", + "walkdir", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1319,6 +1402,15 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -1410,6 +1502,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1699,6 +1802,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1749,6 +1858,22 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -1846,6 +1971,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "wincompatlib" version = "0.7.4" diff --git a/babylonia-terminal-cli/src/main.rs b/babylonia-terminal-cli/src/main.rs index 72639bf..b7f57ab 100644 --- a/babylonia-terminal-cli/src/main.rs +++ b/babylonia-terminal-cli/src/main.rs @@ -99,7 +99,7 @@ async fn main() { .await .unwrap(); - let mut dir = PathBuf::new(); + let dir; if let Some(i) = &mut input { if i.is_empty() { dir = GameState::get_config_directory(); @@ -116,12 +116,19 @@ async fn main() { } GameManager::install_game( - GameState::get_config_directory().join("PGR"), + GameState::get_game_dir().await.unwrap(), DownloadReporter::create(false), ) .await .expect("Failed to install the game"); } + GameState::GameNotPatched => { + info!("Patching game..."); + GameManager::patch_game(GameState::get_game_dir().await.unwrap()) + .await + .expect("Failed to patch the game"); + info!("Game patched!"); + } _ => {} } @@ -134,7 +141,9 @@ async fn main() { debug!("{:?}", proton); GameManager::start_game( &proton.unwrap(), - GameState::get_config_directory().join("PGR"), + GameState::get_game_dir() + .await + .expect("Failed to start game, the game directory was not found"), ) .await; } diff --git a/babylonia-terminal-sdk/Cargo.lock b/babylonia-terminal-sdk/Cargo.lock index 1a31a5b..adf9345 100644 --- a/babylonia-terminal-sdk/Cargo.lock +++ b/babylonia-terminal-sdk/Cargo.lock @@ -70,6 +70,7 @@ dependencies = [ "fs_extra", "log", "reqwest 0.12.2", + "rust-embed", "serde", "serde_json", "tar", @@ -124,6 +125,15 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.15.4" @@ -216,6 +226,15 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.4.0" @@ -225,6 +244,26 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "dirs" version = "5.0.1" @@ -442,6 +481,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -1112,6 +1161,40 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rust-embed" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb78f46d0066053d16d4ca7b898e9343bc3530f71c61d5ad84cd404ada068745" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91ac2a3c6c0520a3fb3dd89321177c3c692937c4eb21893378219da10c44fc8" +dependencies = [ + "proc-macro2", + "quote", + "rust-embed-utils", + "syn", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f69089032567ffff4eada41c573fc43ff466c7db7c5688b2e7969584345581" +dependencies = [ + "sha2", + "walkdir", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1180,6 +1263,15 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "schannel" version = "0.1.23" @@ -1265,6 +1357,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "slab" version = "0.4.9" @@ -1486,6 +1589,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -1530,6 +1639,22 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -1627,6 +1752,15 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "winapi-util" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "wincompatlib" version = "0.7.4" diff --git a/babylonia-terminal-sdk/Cargo.toml b/babylonia-terminal-sdk/Cargo.toml index bd6d1ea..54c54fc 100644 --- a/babylonia-terminal-sdk/Cargo.toml +++ b/babylonia-terminal-sdk/Cargo.toml @@ -15,6 +15,7 @@ flate2 = "1.0.28" fs_extra = "1.3.0" log = "0.4.21" reqwest = { version = "0.12.2", features = ["gzip"] } +rust-embed = "8.3.0" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" tar = "0.4.40" diff --git a/babylonia-terminal-sdk/assets/patched.exe b/babylonia-terminal-sdk/assets/patched.exe new file mode 100644 index 0000000000000000000000000000000000000000..05371bb6870bd743966614ebc2109dd427534680 GIT binary patch literal 3072 zcmeHJUuauZ7(Z#75xb?yoQ2^Zb~`3kggEtSxQEp3;t3{Lm_-mI-X(W6nA{s~ZvW(M zl5Xa34FrAJK+tzz#Z^&g4MP8{&^i&(AtDN`jL|2lI2(W8x#uQ9?3nl<%07C|?>pbW z^ZUMgXq$Pd$@&>%16b`gWAi|gq}*@6orinq$j3wMgL~FS=0oYVkr!SqRJ5{VPdY|P z%NdqsyV_Y(bEYhkHKckiGyqSnb2al=J<2qyci^QNS+wAea{eAmrgV^Gv zC28~ZK0kzx#9vAhJM5#|5^#`79q1^^OgTL&JFYQyl8k{IXAD38Sc)2B=WkOb;hM89 z{OdFdB18?Lk6zIjdnJ)KTmwc(a978`I*O&8K1aGNUQ6%)N}3 z5=(%?DX|KOr^E^u`VP_&nf6}Z8Eao#Zn4lnUwEKDG)_d+{qF_$H}p&D!k@v|)4!~J zAFA!J*xUg`#IERH3w>@Y0)3vE!GQ-a7X0<*<|oL4Qsa_2w;H@Y8a!vGCr`U^HV5lwZ#;!zazaEWUAhNiu$zdZ} z;Mk8rwtyiuP@3H%RJ6li^?g5#US`f8Xp;u|5vobSSiAI}*=@I%Tfr>V9FvHX1%-ZV z9)*Ihw-zEo;T1H*z38fh;j08f-{uYd78j?FX)-e<7E@wfenEY^d)?c9g*tLPG#Qey zv3D2bj1S=^l&{FT5nfx2Y~h{s^tMIMntLJD<34a#>M7J+ZuQU)o?*}i>K>AHqxVS| z9wxX`+Sh$%8&Mi++>4*sh&B9A82%hK4C6y`9fb4I6`uQoFaFTay$BC&a1p`Pm;6Mj zze)ODz0b&MchLLb@ATc;58tFm!uG~p<^MB&rR={b9Kyv^$4Aotj!akuw>n-ls-~03 z7mG}uGe*JMqsR@d>nM&eR>b*1U?A(z-+}F~q^jcT3NI^sU*V?;gWPY``A3B}75=91 zz)?SPSm6=ZnbQZH)}YPIjPJ*o0h4jHC=FQdJx&{%%tg-@H*fmiso#A r{%GBm|Lg?z#~G_&xmX_70{+jUbq(u{dwu;a;4FT{ll`vzzb5bpr-;^G literal 0 HcmV?d00001 diff --git a/babylonia-terminal-sdk/src/components/game_component.rs b/babylonia-terminal-sdk/src/components/game_component.rs index 6504f0e..acd9c90 100644 --- a/babylonia-terminal-sdk/src/components/game_component.rs +++ b/babylonia-terminal-sdk/src/components/game_component.rs @@ -21,6 +21,7 @@ use tokio::sync::mpsc::Sender; use tokio::time::timeout; use super::component_downloader::ComponentDownloader; +use crate::utils::get_game_name; use crate::utils::github_requester::GithubRequester; use crate::utils::kuro_prod_api; use crate::utils::kuro_prod_api::Resource; @@ -32,7 +33,9 @@ pub struct GameComponent { impl GameComponent { pub fn new(game_dir: PathBuf) -> Self { - Self { game_dir } + Self { + game_dir: game_dir.join(get_game_name()), + } } async fn check_and_get_resources_to_download( @@ -101,6 +104,7 @@ impl ComponentDownloader for GameComponent { &self, progress: Option>, ) -> anyhow::Result<()> { + let _ = create_dir_all(&self.game_dir).await; Self::download(&self.game_dir, progress).await?; Ok(()) diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index d25cd4d..fb3d403 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -2,6 +2,7 @@ use std::{ fs::{create_dir, remove_file, rename, File}, io::{BufRead, BufReader}, path::PathBuf, + str::FromStr, sync::Arc, time::Duration, }; @@ -22,7 +23,9 @@ use crate::{ game_component::GameComponent, proton_component::ProtonComponent, }, + game_patcher, game_state::GameState, + utils::{get_game_name, get_game_name_with_executable}, }; pub struct GameManager; @@ -146,9 +149,21 @@ impl GameManager { Ok(()) } + pub async fn patch_game(game_dir: PathBuf) -> anyhow::Result<()> { + game_patcher::patch_game(game_dir).await?; + + 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.join("PGR.exe")).unwrap(); + let mut child = proton + .run( + game_dir + .join(get_game_name()) + .join(get_game_name_with_executable()), + ) + .unwrap(); child.wait().expect("The game failed to run"); } } diff --git a/babylonia-terminal-sdk/src/game_patcher.rs b/babylonia-terminal-sdk/src/game_patcher.rs new file mode 100644 index 0000000..04818ee --- /dev/null +++ b/babylonia-terminal-sdk/src/game_patcher.rs @@ -0,0 +1,104 @@ +use std::{ + io::Read, + path::{Path, PathBuf}, +}; + +use dirs::executable_dir; +use log::debug; +use rust_embed::RustEmbed; +use tokio::{ + fs::{remove_file, rename, File}, + io::AsyncWriteExt, +}; + +use crate::{ + game_state::GameState, + utils::{get_game_name, get_game_name_with_executable}, +}; + +pub async fn patch_game(game_dir: PathBuf) -> anyhow::Result<()> { + // section to fix bad named file + + debug!("{:?}", game_dir); + + let unity_resources = game_dir.join(get_game_name()).join(format!( + "{}{}", + get_game_name(), + "_Data/Resources/unity%20default%20resources" + )); + + debug!("unity resources exist? : {}", unity_resources.exists()); + if unity_resources.exists() { + rename( + unity_resources.clone(), + unity_resources + .parent() + .unwrap() + .join("unity default resources"), + ) + .await?; + } else if !unity_resources + .parent() + .unwrap() + .join("unity default resources") + .exists() + { + anyhow::bail!( + "{} file doesn't exists ? Please restart the launcher and make a repair.", + unity_resources.to_str().unwrap() + ); + } + + // section to replace KRSDKExternal.exe by an empty one + // + let krsdk_external_path = game_dir.join(get_game_name()).join(format!( + "{}{}", + get_game_name(), + "_Data/Plugins/KRSDKExternal.exe" + )); + + remove_file(krsdk_external_path.clone()).await?; + File::create(krsdk_external_path).await?; + + // section to replace the executable with the patched one + + let executable_path = game_dir + .join(get_game_name()) + .join(get_game_name_with_executable()); + + debug!("{:?}", executable_path); + + if executable_path.exists() { + remove_file(executable_path.clone()).await?; + } + + match PatchedGameExecutable::get_exectable() { + Some(exe) => { + let mut file = File::create(executable_path).await?; + + let data: Result, _> = exe.data.bytes().collect(); + let data = data.expect("Unable to read executable data"); + + file.write_all(&data).await?; + } + None => anyhow::bail!( + "Game executable not included in the binary! Please report this to the developer!" + ), + } + + let mut config = GameState::get_config().await; + config.is_game_patched = true; + GameState::save_config(config).await?; + + Ok(()) +} + +#[derive(RustEmbed)] +#[folder = "assets/"] +struct PatchedGameExecutable; + +impl PatchedGameExecutable { + fn get_exectable() -> Option { + PatchedGameExecutable::get("patched.exe") + } +} diff --git a/babylonia-terminal-sdk/src/game_state.rs b/babylonia-terminal-sdk/src/game_state.rs index c8d8aaf..1fb4090 100644 --- a/babylonia-terminal-sdk/src/game_state.rs +++ b/babylonia-terminal-sdk/src/game_state.rs @@ -16,6 +16,7 @@ pub enum GameState { FontNotInstalled, DependecieNotInstalled, GameNotInstalled, + GameNotPatched, GameInstalled, } @@ -28,6 +29,7 @@ pub struct GameConfig { pub is_dependecies_installed: bool, pub game_dir: Option, pub is_game_installed: bool, + pub is_game_patched: bool, } #[derive(Debug, Serialize, Deserialize)] @@ -45,6 +47,7 @@ impl Default for GameConfig { is_dependecies_installed: false, game_dir: None, is_game_installed: false, + is_game_patched: false, } } } @@ -117,6 +120,10 @@ impl GameState { return GameState::GameNotInstalled; } + if !config.is_game_patched { + return GameState::GameNotPatched; + } + GameState::GameInstalled } } diff --git a/babylonia-terminal-sdk/src/utils/mod.rs b/babylonia-terminal-sdk/src/utils/mod.rs index baec65a..3d41723 100644 --- a/babylonia-terminal-sdk/src/utils/mod.rs +++ b/babylonia-terminal-sdk/src/utils/mod.rs @@ -1,2 +1,10 @@ pub mod github_requester; pub mod kuro_prod_api; + +pub fn get_game_name() -> String { + concat!("P", "G", "R").to_string() +} + +pub fn get_game_name_with_executable() -> String { + format!("{}.exe", get_game_name()) +}