mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Write default location in steam
This commit is contained in:
@@ -121,6 +121,14 @@ fn save_settings_to_file(settings: &Settings) {
|
|||||||
|
|
||||||
#[cfg(feature = "ui")]
|
#[cfg(feature = "ui")]
|
||||||
fn update_ui_with_settings(ui: &mut mainview::UserInterface, settings: &Settings) {
|
fn update_ui_with_settings(ui: &mut mainview::UserInterface, settings: &Settings) {
|
||||||
|
ui.steam_location_input.set_value(
|
||||||
|
&settings
|
||||||
|
.steam
|
||||||
|
.location
|
||||||
|
.clone()
|
||||||
|
.unwrap_or(steam::get_default_location().unwrap_or(String::from(""))),
|
||||||
|
);
|
||||||
|
|
||||||
ui.enable_steamgrid_db_checkbox
|
ui.enable_steamgrid_db_checkbox
|
||||||
.set_value(settings.steamgrid_db.enabled);
|
.set_value(settings.steamgrid_db.enabled);
|
||||||
ui.steamgrid_db_auth_key_input.set_value(
|
ui.steamgrid_db_auth_key_input.set_value(
|
||||||
|
|||||||
+27
-14
@@ -60,20 +60,7 @@ pub fn get_shortcuts_paths(
|
|||||||
let user_location = settings.location.clone();
|
let user_location = settings.location.clone();
|
||||||
let steam_path_str = match user_location {
|
let steam_path_str = match user_location {
|
||||||
Some(location) => location,
|
Some(location) => location,
|
||||||
None => {
|
None => get_default_location()?,
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
let path_string = {
|
|
||||||
let key = "PROGRAMFILES(X86)";
|
|
||||||
let program_files = env::var(key)?;
|
|
||||||
format!("{program_files}//Steam//", program_files = program_files)
|
|
||||||
};
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let path_string = {
|
|
||||||
let home = std::env::var("HOME")?;
|
|
||||||
format!("{}/.steam/steam/", home)
|
|
||||||
};
|
|
||||||
path_string
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let steam_path = Path::new(&steam_path_str);
|
let steam_path = Path::new(&steam_path_str);
|
||||||
if !steam_path.exists() {
|
if !steam_path.exists() {
|
||||||
@@ -113,6 +100,32 @@ pub fn get_shortcuts_paths(
|
|||||||
Ok(users_info)
|
Ok(users_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_default_location() -> Result<String, Box<dyn Error>> {
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
let path_string = {
|
||||||
|
let key = "PROGRAMFILES(X86)";
|
||||||
|
let program_files = env::var(key)?;
|
||||||
|
String::from(
|
||||||
|
Path::new(&program_files)
|
||||||
|
.join("Steam")
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or(""),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let path_string = {
|
||||||
|
let home = std::env::var("HOME")?;
|
||||||
|
String::from(
|
||||||
|
Path::new(&home)
|
||||||
|
.join(".steam")
|
||||||
|
.join("steam")
|
||||||
|
.to_str()
|
||||||
|
.unwrap_or(""),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
Ok(path_string)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct SteamFolderNotFound {
|
struct SteamFolderNotFound {
|
||||||
location_tried: String,
|
location_tried: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user