From 51ec0cde389421e3253c30e1465c69c9bd69f164 Mon Sep 17 00:00:00 2001 From: AmanSe Date: Tue, 6 Feb 2024 16:59:07 +0530 Subject: [PATCH 1/4] Remove ULWGL path config option It needs to be in ~/.local/share/ULWGL now or it doesn't work lol EVEYTHING CHANGED RIGHT WHEN I GOT IT TO WORK, gotta rework runner and config everything goddamit --- src/config/config.rs | 14 -------------- src/config/extra_config.rs | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/config/config.rs b/src/config/config.rs index e2a13a6..db6a8cd 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -44,7 +44,6 @@ enum ConfigMenu { DeleteGame, PrefixDir, RunnerDir, - AddUlwglDir, } impl std::fmt::Display for ConfigMenu { @@ -55,7 +54,6 @@ impl std::fmt::Display for ConfigMenu { ConfigMenu::DeleteGame => write!(f, "Delete game"), ConfigMenu::PrefixDir => write!(f, "Add prefix directory"), ConfigMenu::RunnerDir => write!(f, "Add runners directory"), - ConfigMenu::AddUlwglDir => write!(f, "Add ULGWL directory"), } } } @@ -159,18 +157,6 @@ impl MainConfig { confy::store("game-rs", "Extra", self.extra.clone())?; return Ok(()); } - ConfigMenu::AddUlwglDir => { - let old = self.extra.ulwgl_path.clone().unwrap_or("".to_string()); - - let path: String = Input::new() - .with_prompt("Add path to the ULGWL(directory of ./gamelauncher.sh)") - .default(old) - .interact_text()?; - - self.extra.ulwgl_path = Some(path); - confy::store("game-rs", "Extra", self.extra.clone())?; - return Ok(()); - } } } diff --git a/src/config/extra_config.rs b/src/config/extra_config.rs index 4a02bda..e139f57 100644 --- a/src/config/extra_config.rs +++ b/src/config/extra_config.rs @@ -7,7 +7,6 @@ pub struct ExtraConfig { pub runner_path: Option, pub prefix_dir: Option, pub runner_dirs: Option>, - pub ulwgl_path: Option, } impl ::std::default::Default for ExtraConfig { @@ -16,7 +15,6 @@ impl ::std::default::Default for ExtraConfig { runner_path: None, prefix_dir: None, runner_dirs: None, - ulwgl_path: None, } } } @@ -66,7 +64,7 @@ impl ExtraConfig { let runner_list = self.get_runners()?; let runner_s = Select::new() .with_prompt( - "Wine Runner [You can add runner dir to automatically fetch these in config]", + "Wine Runner [Leave this empty with ULGWL to automatically download proton]", ) .default(0) .item("Custom path") From 586231d77970963c5687de76c22e298aa8731256 Mon Sep 17 00:00:00 2001 From: AmanSe Date: Tue, 6 Feb 2024 17:00:15 +0530 Subject: [PATCH 2/4] Update ulwgl download --- src/download/mod.rs | 22 ++++++++++++++-------- src/download/util.rs | 27 +++++++++++++++++---------- src/runner.rs | 21 +++------------------ 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/download/mod.rs b/src/download/mod.rs index c66923e..fb6d7af 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -6,18 +6,24 @@ use eyre::{eyre, Result}; pub fn download(what: &DownloadOptions) -> Result<()> { match what { DownloadOptions::Proton => util::download_and_extract(&get_proton_url()?, true), - DownloadOptions::ULGWL => util::download_and_extract( - "https://api.github.com/repos/Open-Wine-Components/ULWGL-launcher/tarball", - false, - ), + DownloadOptions::ULGWL => util::download_and_extract(&get_ulgwl_url()?, false), } } +fn get_ulgwl_url() -> Result { + get_latest_release( + "https://api.github.com/repos/Open-Wine-Components/ULWGL-launcher".to_string(), + ) +} + fn get_proton_url() -> Result { - let resp: serde_json::Value = - ureq::get("https://api.github.com/repos/GloriousEggroll/wine-ge-custom/releases/latest") - .call()? - .into_json()?; + get_latest_release("https://api.github.com/repos/GloriousEggroll/wine-ge-custom".to_string()) +} + +fn get_latest_release(repo: String) -> Result { + let resp: serde_json::Value = ureq::get(&format!("{}/releases/latest", repo)) + .call()? + .into_json()?; Ok(resp["assets"][1]["browser_download_url"] .as_str() diff --git a/src/download/util.rs b/src/download/util.rs index f15e7c2..6c48695 100644 --- a/src/download/util.rs +++ b/src/download/util.rs @@ -4,15 +4,21 @@ use std::{fs, io::BufWriter}; use tar::Archive; pub fn download_and_extract(download_url: &str, is_xz: bool) -> Result<()> { - let output = Input::new() - .with_prompt("Where do you want to download? (put / at the end)") - .default("".to_string()) - .show_default(false) - .interact_text()?; - - let file_path = download_to_tmp(download_url, "file")?; - - extract(file_path, output, is_xz)?; + let output = { + if is_xz { + Input::new() + .with_prompt("Where do you want to download? (put / at the end)") + .default("".to_string()) + .show_default(false) + .interact_text()? + } else { + String::from("") + } + }; + + download_to_tmp(download_url, "file")?; + + extract("/tmp/file".to_string(), output, is_xz)?; Ok(()) } @@ -30,7 +36,8 @@ fn extract(file_path: String, output: String, is_xz: bool) -> Result<()> { let decomp = flate2::read::GzDecoder::new(file); let mut a = Archive::new(decomp); - a.unpack(output).unwrap(); + a.unpack(format!("{}/.local/share/ULWGL", std::env::var("HOME")?)) + .unwrap(); } Ok(()) diff --git a/src/runner.rs b/src/runner.rs index 69c5100..516bf42 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -56,16 +56,7 @@ impl<'a> Runner<'a> { envs.insert("PROTONPATH", game.runner_path.as_str()); envs.insert("GAMEID", "game-rs"); - run_ulwgl( - &envs, - self.config - .extra - .ulwgl_path - .clone() - .expect("ULGWL path not set in config"), - game.exect_path, - self.is_verbose, - ); + run_ulwgl(&envs, game.exect_path, self.is_verbose); return Ok(()); } @@ -87,14 +78,8 @@ impl<'a> Runner<'a> { } } -fn run_ulwgl(envs: &HashMap<&str, &str>, ulwgl_path: String, exect_path: String, is_verbose: bool) { - let ulwgl_path = { - if ulwgl_path.chars().last().unwrap() != '/' { - format!("{}/gamelauncher.sh", ulwgl_path) - } else { - format!("{}gamelauncher.sh", ulwgl_path) - } - }; +fn run_ulwgl(envs: &HashMap<&str, &str>, exect_path: String, is_verbose: bool) { + let ulwgl_path = String::from("~/.local/share/ULGWL/ulgwl-run"); let mut args: Vec = vec![]; From b9307edf0b10f2a3878ea71d4c029a3bf4c9e0c8 Mon Sep 17 00:00:00 2001 From: AmanSe Date: Tue, 6 Feb 2024 17:17:01 +0530 Subject: [PATCH 3/4] Fix spelling errors in ulwgl, im dumb ulwgl writes log into a log file in currect directory, dunno how to turn that off for now, i'll see that later --- src/download/mod.rs | 2 +- src/main.rs | 2 +- src/runner.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/download/mod.rs b/src/download/mod.rs index fb6d7af..a9329b6 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -6,7 +6,7 @@ use eyre::{eyre, Result}; pub fn download(what: &DownloadOptions) -> Result<()> { match what { DownloadOptions::Proton => util::download_and_extract(&get_proton_url()?, true), - DownloadOptions::ULGWL => util::download_and_extract(&get_ulgwl_url()?, false), + DownloadOptions::ULWGL => util::download_and_extract(&get_ulgwl_url()?, false), } } diff --git a/src/main.rs b/src/main.rs index 7888a09..8337640 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,7 +32,7 @@ enum Command { #[derive(Subcommand)] pub enum DownloadOptions { Proton, - ULGWL, + ULWGL, } #[derive(Args)] diff --git a/src/runner.rs b/src/runner.rs index 516bf42..e3be730 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -79,7 +79,7 @@ impl<'a> Runner<'a> { } fn run_ulwgl(envs: &HashMap<&str, &str>, exect_path: String, is_verbose: bool) { - let ulwgl_path = String::from("~/.local/share/ULGWL/ulgwl-run"); + let ulwgl_path = String::from("~/.local/share/ULWGL/ulwgl-run"); let mut args: Vec = vec![]; From 85182bf258fa449515c6b54dacc6eddb85e3b23d Mon Sep 17 00:00:00 2001 From: AmanSe Date: Tue, 6 Feb 2024 17:29:47 +0530 Subject: [PATCH 4/4] Fix runner with new ulwgl --- src/config/extra_config.rs | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/config/extra_config.rs b/src/config/extra_config.rs index e139f57..f2e03ea 100644 --- a/src/config/extra_config.rs +++ b/src/config/extra_config.rs @@ -63,22 +63,29 @@ impl ExtraConfig { let runner_path: String; let runner_list = self.get_runners()?; let runner_s = Select::new() - .with_prompt( - "Wine Runner [Leave this empty with ULGWL to automatically download proton]", - ) + .with_prompt("Wine Runner") .default(0) .item("Custom path") + .item("Auto download(needs ulwgl)") .items(&runner_list) .interact()?; - if runner_s != 0 { - runner_path = runner_list[runner_s - 1].clone(); - } else { - runner_path = Input::new() - .with_prompt("Path to proton/wine binary") - .default(self.runner_path.clone().unwrap_or("".to_string())) - .interact_text()?; + // @TODO: Remove this crap with wine-ge phaseout + match runner_s { + 0 => { + runner_path = Input::new() + .with_prompt("Path to proton/wine binary") + .default(self.runner_path.clone().unwrap_or("".to_string())) + .interact_text()?; + } + 1 => { + runner_path = "".to_string(); + } + _ => { + runner_path = runner_list[runner_s - 1].clone(); + } } + Ok(runner_path) } }