diff --git a/Cargo.lock b/Cargo.lock index 4e6134f..e563ef5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -375,6 +375,7 @@ dependencies = [ "tar", "tokio", "wincompatlib", + "xz2", ] [[package]] @@ -2069,6 +2070,17 @@ version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +[[package]] +name = "lzma-sys" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "memchr" version = "2.7.4" @@ -4269,6 +4281,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "xz2" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" +dependencies = [ + "lzma-sys", +] + [[package]] name = "yoke" version = "0.7.5" diff --git a/babylonia-terminal-cli/src/game.rs b/babylonia-terminal-cli/src/game.rs index 7dc61e6..eda23d4 100644 --- a/babylonia-terminal-cli/src/game.rs +++ b/babylonia-terminal-cli/src/game.rs @@ -3,7 +3,7 @@ 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}, + wine_component::{WineComponent, WINE_DEV, WINE_REPO}, }, game_config::GameConfig, game_manager::{EnvironmentVariable, GameManager}, @@ -21,8 +21,8 @@ pub async fn run( env_vars: Vec, show_logs: bool, ) { - let mut proton_component: Option = None; - let mut proton: Option = None; + let mut wine_component: Option = None; + let mut wine: Option = None; loop { let state_result = GameState::get_current_state().await; @@ -32,40 +32,42 @@ pub async fn run( } 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), + if state != GameState::WineNotInstalled && wine == None { + let wine_component = WineComponent::new(GameConfig::get_config_directory().await); + match wine_component.init_wine() { + Ok(p) => wine = Some(p), Err(err) => panic!("{}", err), }; } match state { - GameState::ProtonNotInstalled => { + GameState::WineNotInstalled => { 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!"); - } + if utils::use_latest( + "Do you want to install latest version of wine GE or a specific version of it?", + ) { + release = 0; + } else { + release = utils::choose_release_version( + WINE_DEV, + WINE_REPO, + "Please, select a version of wine GE to install.", + ) + .await + .expect("Failed to fetch wine version!"); + } - info!("Proton not installed, installing it..."); - proton_component = Some( + info!("Wine not installed, installing it..."); + wine_component = Some( GameManager::install_wine( GameConfig::get_config_directory().await, release, Some(DownloadReporter::create(false)), ) .await - .expect("Failed to install Wine"), + .expect("Failed to install wine"), ); - info!("Proton installed"); + info!("wine installed"); } GameState::DXVKNotInstalled => { let release; @@ -84,9 +86,9 @@ pub async fn run( } info!("DXVK not installed, installing it..."); - debug!("{:?}", proton_component); + debug!("{:?}", wine_component); GameManager::install_dxvk( - &proton.clone().unwrap(), + &wine.clone().unwrap(), GameConfig::get_config_directory().await, release, Some(DownloadReporter::create(false)), @@ -97,14 +99,14 @@ pub async fn run( } GameState::FontNotInstalled => { info!("Fonts not installed, installing it..."); - GameManager::install_font(&proton.clone().unwrap(), None::>) + GameManager::install_font(&wine.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()) + GameManager::install_dependencies(&wine.clone().unwrap()) .await .expect("Failed to install dependecies"); info!("Dependecies installed"); @@ -167,9 +169,9 @@ pub async fn run( } info!("Starting game..."); - debug!("{:?}", proton); + debug!("{:?}", wine); GameManager::start_game( - &proton.unwrap(), + &wine.unwrap(), GameConfig::get_game_dir() .await .expect("Failed to start game, the game directory was not found"), diff --git a/babylonia-terminal-gui/src/manager.rs b/babylonia-terminal-gui/src/manager.rs index 8b4bf95..4d51185 100644 --- a/babylonia-terminal-gui/src/manager.rs +++ b/babylonia-terminal-gui/src/manager.rs @@ -1,8 +1,8 @@ use std::{ops::Deref, sync::Arc}; use babylonia_terminal_sdk::{ - components::proton_component::ProtonComponent, game_config::GameConfig, - game_manager::GameManager, utils::github_requester::GithubRelease, + components::wine_component::WineComponent, game_config::GameConfig, game_manager::GameManager, + utils::github_requester::GithubRelease, }; use downloader::download; use log::{debug, error}; @@ -10,7 +10,7 @@ use relm4::{ tokio::{self, sync::OnceCell}, Worker, }; -use wincompatlib::prelude::Proton; +use wincompatlib::prelude::Wine; use crate::ui::{ self, @@ -23,36 +23,33 @@ use crate::ui::{ }, }; -static PROTON: OnceCell = OnceCell::const_new(); +static WINE: OnceCell = OnceCell::const_new(); -pub async fn get_proton() -> anyhow::Result { - if !PROTON.initialized() { - let proton_component = ProtonComponent::new(GameConfig::get_config().await.config_dir); - let proton = proton_component.init_proton(); +pub async fn get_wine() -> anyhow::Result { + if !WINE.initialized() { + let wine_component = WineComponent::new(GameConfig::get_config().await.config_dir); + let wine = wine_component.init_wine(); - if let Err(ref e) = proton { - error!("Failed to initialize proton : {}", e); - anyhow::bail!("Failed to initialize proton : {}", e); + if let Err(ref e) = wine { + error!("Failed to initialize wine : {}", e); + anyhow::bail!("Failed to initialize wine : {}", e); } - Ok(PROTON - .get_or_init(|| async { proton.unwrap() }) - .await - .clone()) + Ok(WINE.get_or_init(|| async { wine.unwrap() }).await.clone()) } else { - Ok(PROTON.get().unwrap().clone()) + Ok(WINE.get().unwrap().clone()) } } pub async fn run_game() -> anyhow::Result<()> { - let proton = get_proton().await?; + let wine = get_wine().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?; + GameManager::start_game(&wine, game_dir.unwrap(), None, vec![], false).await?; Ok(()) } @@ -217,7 +214,7 @@ pub enum HandleComponentInstallationMsg { usize, Arc, ), - ), // proton release and dxvk release + ), // wine release and dxvk release } #[derive(Debug)] @@ -237,7 +234,7 @@ impl Worker for HandleComponentInstallation { fn update(&mut self, message: Self::Input, sender: relm4::ComponentSender) { match message { HandleComponentInstallationMsg::StartInstallation(( - proton_release, + wine_release, dxvk_release, progress_bar, )) => { @@ -248,20 +245,20 @@ impl Worker for HandleComponentInstallation { .block_on(async { let _ = sender.output( download_components::DownloadComponentsMsg::UpdateProgressBarMsg( - String::from("Starting download for proton"), - Some(String::from("Unpacking and initializing proton")), + String::from("Starting download for wine"), + Some(String::from("Unpacking and initializing wine")), ), ); let _ = sender.output( download_components::DownloadComponentsMsg::UpdateCurrentlyInstalling( - download_components::CurrentlyInstalling::Proton, + download_components::CurrentlyInstalling::Wine, ), ); let _ = sender.output( download_components::DownloadComponentsMsg::UpdateDownloadedComponentName( - String::from("proton"), + String::from("wine"), ), ); @@ -271,8 +268,8 @@ impl Worker for HandleComponentInstallation { 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(); + if let Err(error) = GameManager::install_wine(game_dir.clone(), wine_release, Some(progress_bar.clone())).await { + sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install wine : {}", error))).unwrap(); return; } @@ -283,15 +280,15 @@ impl Worker for HandleComponentInstallation { let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("DXVK"))); - let proton = match get_proton().await { + let wine = match get_wine().await { Ok(p) => p, Err(e) => { - sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to initialize proton : {:?}", e))).unwrap(); + sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to initialize wine : {:?}", e))).unwrap(); return; } }; - if let Err(error) = GameManager::install_dxvk(&proton, game_dir, dxvk_release, Some(progress_bar.clone())).await { + if let Err(error) = GameManager::install_dxvk(&wine, game_dir, dxvk_release, Some(progress_bar.clone())).await { sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install DXVK : {}", error))).unwrap(); return; } @@ -303,7 +300,7 @@ impl Worker for HandleComponentInstallation { let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("fonts"))); - if let Err(error) = GameManager::install_font(&proton, Some(progress_bar.clone())).await { + if let Err(error) = GameManager::install_font(&wine, Some(progress_bar.clone())).await { sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install fonts : {}", error))).unwrap(); return; } @@ -315,7 +312,7 @@ impl Worker for HandleComponentInstallation { let _ = sender.output(download_components::DownloadComponentsMsg::UpdateDownloadedComponentName(String::from("denpendecies"))); - if let Err(error) = GameManager::install_dependencies(&proton).await { + if let Err(error) = GameManager::install_dependencies(&wine).await { sender.output(download_components::DownloadComponentsMsg::ShowError(format!("Failed to install dependencies : {}", error))).unwrap(); return; } diff --git a/babylonia-terminal-gui/src/ui/pages/steps/download_components.rs b/babylonia-terminal-gui/src/ui/pages/steps/download_components.rs index 2adc9c3..ee025d1 100644 --- a/babylonia-terminal-gui/src/ui/pages/steps/download_components.rs +++ b/babylonia-terminal-gui/src/ui/pages/steps/download_components.rs @@ -4,7 +4,7 @@ use arboard::Clipboard; use babylonia_terminal_sdk::{ components::{ dxvk_component::{self, DXVKComponent}, - proton_component::{self, ProtonComponent}, + wine_component::{self, WineComponent}, }, game_config::GameConfig, game_state::GameState, @@ -43,7 +43,7 @@ pub enum DownloadComponentsMsg { #[derive(Debug, PartialEq, Eq)] pub enum CurrentlyInstalling { None, - Proton, + Wine, DXVK, Fonts, Denpendecies, @@ -52,14 +52,14 @@ pub enum CurrentlyInstalling { #[derive(Debug)] pub struct DownloadComponentsPage { // widgets - proton_combo: adw::ComboRow, + wine_combo: adw::ComboRow, dxvk_combo: adw::ComboRow, //error_dialog: Controller, // values - proton_versions: Vec, + wine_versions: Vec, dxvk_versions: Vec, - selected_proton_version: Option, + selected_wine_version: Option, selected_dxvk_version: Option, game_config: GameConfig, @@ -108,11 +108,11 @@ impl SimpleAsyncComponent for DownloadComponentsPage { set_vexpand: true, #[local_ref] - proton_combo -> adw::ComboRow { - set_title: "proton version", + wine_combo -> adw::ComboRow { + set_title: "Wine version", set_model: Some(>k::StringList::new(model - .proton_versions + .wine_versions .iter() .map(|r| r.tag_name.as_str()) .collect::>() @@ -142,7 +142,7 @@ impl SimpleAsyncComponent for DownloadComponentsPage { set_hexpand: false, set_width_request: 200, - connect_clicked => DownloadComponentsMsg::UpdateCurrentlyInstalling(CurrentlyInstalling::Proton), + connect_clicked => DownloadComponentsMsg::UpdateCurrentlyInstalling(CurrentlyInstalling::Wine), }, }, }, @@ -168,21 +168,21 @@ impl SimpleAsyncComponent for DownloadComponentsPage { set_vexpand: true, adw::ActionRow { - set_title: "Proton", + set_title: "Wine", #[watch] - set_subtitle: match &model.selected_proton_version { + set_subtitle: match &model.selected_wine_version { Some(release) => &release.tag_name, - None => "WTF??!! there's no proton version found ????", + None => "WTF??!! there's no wine version found ????", }, #[watch] - set_icon_name: if model.currently_installing != CurrentlyInstalling::Proton && model.game_config.is_wine_installed { Some("emblem-ok-symbolic") } else { None }, + set_icon_name: if model.currently_installing != CurrentlyInstalling::Wine && 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, + set_visible: model.currently_installing == CurrentlyInstalling::Wine, } }, @@ -191,7 +191,7 @@ impl SimpleAsyncComponent for DownloadComponentsPage { #[watch] set_subtitle: match &model.selected_dxvk_version { Some(release) => &release.tag_name, - None => "WTF??!! there's no proton version found ????", + None => "WTF??!! there's no wine version found ????", }, #[watch] @@ -285,12 +285,10 @@ impl SimpleAsyncComponent for DownloadComponentsPage { root: Self::Root, sender: AsyncComponentSender, ) -> AsyncComponentParts { - let proton_releases = ProtonComponent::get_github_releases( - proton_component::PROTON_DEV, - proton_component::PROTON_REPO, - ) - .await - .unwrap(); //TODO: remove unwrap() + let wine_releases = + WineComponent::get_github_releases(wine_component::WINE_DEV, wine_component::WINE_REPO) + .await + .unwrap(); //TODO: remove unwrap() let dxvk_releases = DXVKComponent::get_github_releases(dxvk_component::DXVK_DEV, dxvk_component::DXVK_REPO) @@ -298,12 +296,12 @@ impl SimpleAsyncComponent for DownloadComponentsPage { .unwrap(); //TODO: remove unwrap() let model = DownloadComponentsPage { - proton_combo: adw::ComboRow::new(), + wine_combo: adw::ComboRow::new(), dxvk_combo: adw::ComboRow::new(), - proton_versions: proton_releases, + wine_versions: wine_releases, dxvk_versions: dxvk_releases, - selected_proton_version: None, + selected_wine_version: None, selected_dxvk_version: None, game_config: GameConfig::get_config().await, @@ -320,7 +318,7 @@ impl SimpleAsyncComponent for DownloadComponentsPage { msg_when_done: None, }; - let proton_combo = &model.proton_combo; + let wine_combo = &model.wine_combo; let dxvk_combo = &model.dxvk_combo; let widgets = view_output!(); @@ -395,21 +393,21 @@ impl SimpleAsyncComponent for DownloadComponentsPage { DownloadComponentsMsg::Quit => relm4::main_application().quit(), } - if self.selected_proton_version.is_none() + if self.selected_wine_version.is_none() && self.selected_dxvk_version.is_none() && self.currently_installing != CurrentlyInstalling::None { - let proton_index = self.proton_combo.selected() as usize; + let wine_index = self.wine_combo.selected() as usize; let dxvk_index = self.dxvk_combo.selected() as usize; - let proton_release = self.proton_versions[proton_index].clone(); + let wine_release = self.wine_versions[wine_index].clone(); let dxvk_release = self.dxvk_versions[dxvk_index].clone(); - self.selected_proton_version = Some(proton_release); + self.selected_wine_version = Some(wine_release); self.selected_dxvk_version = Some(dxvk_release); let _ = self.installation_handler.sender().send( manager::HandleComponentInstallationMsg::StartInstallation(( - proton_index, + wine_index, dxvk_index, self.progress_bar_reporter.clone(), )), diff --git a/babylonia-terminal-sdk/Cargo.toml b/babylonia-terminal-sdk/Cargo.toml index 07fe59e..748843d 100644 --- a/babylonia-terminal-sdk/Cargo.toml +++ b/babylonia-terminal-sdk/Cargo.toml @@ -30,7 +30,7 @@ tokio = { version = "1.37.0", features = ["fs"] } wincompatlib = { version = "0.7.5", features = [ "dxvk", "wine-bundles", - "wine-proton", "wine-fonts", "winetricks", ] } +xz2 = "0.1.7" diff --git a/babylonia-terminal-sdk/src/components/dxvk_component.rs b/babylonia-terminal-sdk/src/components/dxvk_component.rs index c2a5d99..e9ec63b 100644 --- a/babylonia-terminal-sdk/src/components/dxvk_component.rs +++ b/babylonia-terminal-sdk/src/components/dxvk_component.rs @@ -55,12 +55,12 @@ impl<'a> ComponentDownloader for DXVKComponent<'a> { Self::uncompress(file_output.clone(), self.path.clone()).await?; - let wine_with_proton_prefix = self // wine take the data/wine/pfx prefix, but we want the data/wine prefix + let wine_prefix = self // wine take the data/wine/pfx prefix, but we want the data/wine prefix .wine .clone() .with_prefix(self.wine.prefix.parent().unwrap()); - wine_with_proton_prefix + wine_prefix .install_dxvk(self.path.clone(), InstallParams::default()) .expect("Failed to installed DXVK"); diff --git a/babylonia-terminal-sdk/src/components/mod.rs b/babylonia-terminal-sdk/src/components/mod.rs index abee13e..ee1c0cb 100644 --- a/babylonia-terminal-sdk/src/components/mod.rs +++ b/babylonia-terminal-sdk/src/components/mod.rs @@ -1,4 +1,4 @@ pub mod component_downloader; pub mod dxvk_component; pub mod game_component; -pub mod proton_component; +pub mod wine_component; diff --git a/babylonia-terminal-sdk/src/components/proton_component.rs b/babylonia-terminal-sdk/src/components/wine_component.rs similarity index 57% rename from babylonia-terminal-sdk/src/components/proton_component.rs rename to babylonia-terminal-sdk/src/components/wine_component.rs index 64429ce..929b2f5 100644 --- a/babylonia-terminal-sdk/src/components/proton_component.rs +++ b/babylonia-terminal-sdk/src/components/wine_component.rs @@ -6,37 +6,37 @@ use std::{ }; use downloader::{progress::Reporter, Downloader}; -use flate2::read::GzDecoder; use log::debug; use tar::Archive; use wincompatlib::wine::ext::WineBootExt; +use xz2::read::XzDecoder; use super::component_downloader::ComponentDownloader; use crate::utils::github_requester::GithubRequester; -pub static PROTON_DEV: &str = "GloriousEggroll"; -pub static PROTON_REPO: &str = "proton-ge-custom"; +pub static WINE_DEV: &str = "Kron4ek"; +pub static WINE_REPO: &str = "Wine-Builds"; #[derive(Debug, PartialEq, Eq)] -pub struct ProtonComponent { +pub struct WineComponent { path: PathBuf, github_release_index: usize, } -impl GithubRequester for ProtonComponent { +impl GithubRequester for WineComponent { fn set_github_release_index(&mut self, new_release_index: usize) { self.github_release_index = new_release_index; } } -impl ComponentDownloader for ProtonComponent { +impl ComponentDownloader for WineComponent { async fn install(&self, progress: Option>) -> anyhow::Result<()> { let file_output = self .download( &self .path .parent() - .expect("Failed to get the parent directory of Wine") + .expect("Failed to get the parent directory of wine") .to_path_buf(), progress, ) @@ -52,7 +52,7 @@ impl ComponentDownloader for ProtonComponent { progress: Option>, ) -> anyhow::Result { let release = - Self::get_github_release_version(PROTON_DEV, PROTON_REPO, self.github_release_index) + Self::get_github_release_version(WINE_DEV, WINE_REPO, self.github_release_index) .await?; let asset = release @@ -79,14 +79,15 @@ impl ComponentDownloader for ProtonComponent { async fn uncompress(file: PathBuf, new_directory_name: PathBuf) -> anyhow::Result<()> { tokio::task::spawn_blocking(move || { let tar_xz = File::open(file.clone()).unwrap(); - let tar = GzDecoder::new(tar_xz); + let tar = XzDecoder::new(tar_xz); let mut archive = Archive::new(tar); archive.unpack(new_directory_name.parent().unwrap())?; remove_file(file.clone())?; rename( - file.to_str().unwrap().strip_suffix(".tar.gz").unwrap(), + file.to_str().unwrap().strip_suffix(".tar.xz").unwrap(), new_directory_name, )?; + debug!("???5"); Ok::<(), anyhow::Error>(()) }) @@ -96,49 +97,47 @@ impl ComponentDownloader for ProtonComponent { } } -impl ProtonComponent { +impl WineComponent { pub fn new(path: PathBuf) -> Self { - ProtonComponent { - path: path.join("proton"), + WineComponent { + path: path.join("wine"), github_release_index: 0, } } - pub fn init_proton(&self) -> Result { + pub fn init_wine(&self) -> Result { let prefix = self.path.parent().unwrap().join("data"); + let wine_bin_location = self.path.join("bin/wine"); + debug!("Initializing prefix with -> {:?}", prefix); + debug!("Wine binary path : {:?}", wine_bin_location); - let mut proton = - wincompatlib::prelude::Proton::new(self.path.clone(), Some(prefix.clone())); - let steam_location = Self::get_steam_location()?; + let mut wine = wincompatlib::prelude::Wine::from_binary(wine_bin_location); - debug!("Steam location used -> {:?}", steam_location); + wine.init_prefix(Some(prefix)).unwrap(); - proton.steam_client_path = Some(steam_location); - proton.init_prefix(Some(prefix)).unwrap(); - - Ok(proton) + Ok(wine) } - fn get_steam_location() -> Result { - let specified_steam_location = std::env::var("BT_STEAM_CLIENT_PATH"); - if let Ok(location) = specified_steam_location { - return Ok(PathBuf::from(location)); - } + //fn get_steam_location() -> Result { + // 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 - ]; + // 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); - } - } + // 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()) - } + // 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()) + //} } diff --git a/babylonia-terminal-sdk/src/game_manager.rs b/babylonia-terminal-sdk/src/game_manager.rs index 964de94..6504452 100644 --- a/babylonia-terminal-sdk/src/game_manager.rs +++ b/babylonia-terminal-sdk/src/game_manager.rs @@ -16,7 +16,7 @@ use wincompatlib::prelude::*; use crate::{ components::{ component_downloader::ComponentDownloader, dxvk_component::DXVKComponent, - game_component::GameComponent, proton_component::ProtonComponent, + game_component::GameComponent, wine_component::WineComponent, }, game_config::GameConfig, game_patcher, @@ -46,11 +46,11 @@ impl GameManager { config_dir: PathBuf, release_index: usize, progress: Option>, - ) -> anyhow::Result + ) -> anyhow::Result where P: Reporter + 'static, { - let mut wine_component = ProtonComponent::new(config_dir); + let mut wine_component = WineComponent::new(config_dir); wine_component.set_github_release_index(release_index); wine_component.install(progress).await?; @@ -63,7 +63,7 @@ impl GameManager { } pub async fn install_dxvk

( - proton: &Proton, + wine: &Wine, config_dir: PathBuf, release_index: usize, progress: Option>, @@ -71,7 +71,7 @@ impl GameManager { where P: Reporter + 'static, { - let mut dxvk_component = DXVKComponent::from_wine(proton.wine(), config_dir); + let mut dxvk_component = DXVKComponent::from_wine(wine, config_dir); dxvk_component.set_github_release_index(release_index); dxvk_component.install(progress).await?; @@ -83,14 +83,13 @@ impl GameManager { Ok(()) } - pub async fn install_font

(proton: &Proton, progress: Option>) -> anyhow::Result<()> + pub async fn install_font

(wine: &Wine, progress: Option>) -> anyhow::Result<()> where P: Reporter + 'static, { - let wine_with_proton_prefix = proton // wine take the data/wine/pfx prefix, but we want the data/wine prefix - .wine() + let wine_prefix = wine // wine take the data/wine/pfx prefix, but we want the data/wine prefix .clone() - .with_prefix(proton.wine().prefix.parent().unwrap()); + .with_prefix(wine.prefix.parent().unwrap()); let max = 1; @@ -100,7 +99,7 @@ impl GameManager { notify_fonts_progress(0, max, &progress); - wine_with_proton_prefix.install_font(Font::Arial)?; + wine_prefix.install_font(Font::Arial)?; notify_fonts_progress(1, max, &progress); let mut config = GameConfig::get_config().await; @@ -110,13 +109,12 @@ impl GameManager { Ok(()) } - pub async fn install_dependencies(proton: &Proton) -> anyhow::Result<()> { - let wine_with_proton_prefix = proton // wine take the data/wine/pfx prefix, but we want the data/wine prefix - .wine() + pub async fn install_dependencies(wine: &Wine) -> anyhow::Result<()> { + let wine_prefix = wine // wine take the data/wine/pfx prefix, but we want the data/wine prefix .clone() - .with_prefix(proton.wine().prefix.parent().unwrap()); + .with_prefix(wine.prefix.parent().unwrap()); - let winetricks = Winetricks::from_wine("/bin/winetricks", wine_with_proton_prefix); + let winetricks = Winetricks::from_wine("/bin/winetricks", wine_prefix); //winetricks.install("corefonts")?; let mut child = winetricks.install("vcrun2022")?; @@ -165,26 +163,26 @@ impl GameManager { } pub async fn start_game( - proton: &Proton, + wine: &Wine, game_dir: PathBuf, options: Option, env_variables: Vec, show_logs: bool, ) -> anyhow::Result<()> { - let proton_version = proton.wine().version()?; + let wine_version = wine.version()?; let binary_path = game_dir .join(get_game_name()) .join(get_game_name_with_executable()); - debug!("Wine version : {:?}", proton_version); + debug!("wine version : {:?}", wine_version); let mut child = if let Some(custom_command) = options { - Self::run(proton, binary_path, Some(custom_command), env_variables).await? + Self::run(wine, 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? + Self::run(wine, binary_path, Some(custom_command), env_variables).await? } else { - Self::run(proton, binary_path, None, env_variables).await? + Self::run(wine, binary_path, None, env_variables).await? } }?; @@ -205,7 +203,7 @@ impl GameManager { .lines() .inspect(|s| { if let Ok(str) = s { - info!("[Proton] > {}", str); + info!("[wine] > {}", str); stdout_save.push_str(str); } }) @@ -219,7 +217,7 @@ impl GameManager { .lines() .inspect(|s| { if let Ok(str) = s { - info!("[Proton] > {}", str); + info!("[wine] > {}", str); stderr_save.push_str(str); } }) @@ -292,20 +290,20 @@ impl GameManager { } async fn run( - proton: &Proton, + wine: &Wine, binary_path: PathBuf, custom_command: Option, env_variables: Vec, ) -> anyhow::Result> { let mut command: Vec<&str> = vec![]; - let proton_path = GameConfig::get_config_directory() + let wine_path = GameConfig::get_config_directory() .await - .join("proton") - .join("proton"); + .join("wine") + .join("wine"); - command.push(proton.python.to_str().unwrap()); - command.push(proton_path.to_str().unwrap()); + //command.push(wine.python.to_str().unwrap()); + command.push(wine_path.to_str().unwrap()); command.push("run"); command.push(binary_path.to_str().unwrap()); @@ -337,8 +335,8 @@ impl GameManager { Ok(Command::new(command[0]) .args(&command[1..command.len()]) - .envs(proton.get_envs()) - .env("PROTON_LOG", "1") + .envs(wine.get_envs()) + .env("Wine_LOG", "1") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) diff --git a/babylonia-terminal-sdk/src/game_state.rs b/babylonia-terminal-sdk/src/game_state.rs index 3200135..fc95921 100644 --- a/babylonia-terminal-sdk/src/game_state.rs +++ b/babylonia-terminal-sdk/src/game_state.rs @@ -2,7 +2,7 @@ use crate::{game_config::GameConfig, utils::kuro_prod_api::GameInfo}; #[derive(Debug, PartialEq, Eq, Clone)] pub enum GameState { - ProtonNotInstalled, + WineNotInstalled, DXVKNotInstalled, FontNotInstalled, DependecieNotInstalled, @@ -17,7 +17,7 @@ impl GameState { let config = GameConfig::get_config().await; if !config.is_wine_installed { - return Ok(GameState::ProtonNotInstalled); + return Ok(GameState::WineNotInstalled); } if !config.is_dxvk_installed {