mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
UI for GOG
This commit is contained in:
+12
-13
@@ -52,7 +52,6 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
for install_location in install_locations {
|
||||
let path = Path::new(&install_location);
|
||||
if path.exists() {
|
||||
println!("exists {:?}", &path);
|
||||
let dirs = path.read_dir();
|
||||
if let Ok(dirs) = dirs {
|
||||
for dir in dirs {
|
||||
@@ -122,7 +121,7 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let working_dir = working_dir.replace("\\", "/");
|
||||
|
||||
|
||||
let full_path_string = full_path.to_string();
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@@ -149,17 +148,17 @@ impl Platform<GogShortcut, GogErrors> for GogPlatform {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn fix_paths(wine_c_drive: &String, paths: Vec<String>) -> Vec<String> {
|
||||
paths
|
||||
.iter()
|
||||
.flat_map(|path| {
|
||||
if path.starts_with("C:\\") {
|
||||
let path_buf = Path::new(wine_c_drive).join(&path[3..]);
|
||||
path_buf.to_str().map(|s| s.to_string().replace("\\", "/"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
paths
|
||||
.iter()
|
||||
.flat_map(|path| {
|
||||
if path.starts_with("C:\\") {
|
||||
let path_buf = Path::new(wine_c_drive).join(&path[3..]);
|
||||
path_buf.to_str().map(|s| s.to_string().replace("\\", "/"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_install_locations(path: PathBuf) -> Result<Vec<String>, GogErrors> {
|
||||
|
||||
+5
-6
@@ -164,12 +164,11 @@ fn create_sym_links(shortcut: &ShortcutOwned) -> ShortcutOwned {
|
||||
let workdir_original = Path::new(&shortcut.start_dir);
|
||||
|
||||
use std::os::unix::fs::symlink;
|
||||
|
||||
match (
|
||||
symlink(&target_original, &target_link),
|
||||
symlink(&workdir_original, &workdir_link),
|
||||
) {
|
||||
(Ok(_), Ok(_)) => {
|
||||
// If the links exsists, then they must point towards what is needed, otherwise they would have a different app id
|
||||
let target_ok = target_link.exists() || symlink(&target_original, &target_link).is_ok();
|
||||
let workdir_ok = workdir_link.exists() || symlink(&workdir_original, &workdir_link).is_ok();
|
||||
match (target_ok, workdir_ok) {
|
||||
(true, true) => {
|
||||
let exe = target_link.to_string_lossy().to_string();
|
||||
let start_dir = workdir_link.to_string_lossy().to_string();
|
||||
let new_shortcut = Shortcut::new(
|
||||
|
||||
+31
-1
@@ -71,6 +71,11 @@ fn update_settings_with_ui_values(settings: &mut Settings, ui: &UserInterface) {
|
||||
// Itch
|
||||
settings.itch.enabled = ui.enable_itch_checkbox.value();
|
||||
settings.itch.location = empty_or_whitespace(ui.itch_locatoin_input.value());
|
||||
|
||||
// Gog
|
||||
settings.gog.enabled = ui.enable_gog_checkbox.value();
|
||||
settings.gog.location = empty_or_whitespace(ui.gog_folder_input.value());
|
||||
settings.gog.wine_c_drive = empty_or_whitespace(ui.gog_winedrive_input.value());
|
||||
}
|
||||
|
||||
#[cfg(feature = "ui")]
|
||||
@@ -84,7 +89,7 @@ fn save_settings_to_file(settings: &Settings) {
|
||||
fn update_ui_with_settings(ui: &mut UserInterface, settings: &Settings) {
|
||||
use std::path::Path;
|
||||
|
||||
use crate::{itch, origin, steam};
|
||||
use crate::{gog, itch, origin, steam};
|
||||
|
||||
ui.steam_location_input.set_value(
|
||||
&settings
|
||||
@@ -152,4 +157,29 @@ fn update_ui_with_settings(ui: &mut UserInterface, settings: &Settings) {
|
||||
.clone()
|
||||
.unwrap_or(default_origin_location),
|
||||
);
|
||||
|
||||
ui.enable_gog_checkbox.set_value(settings.gog.enabled);
|
||||
let default_gog_location = gog::default_location();
|
||||
let default_gog_location = if !default_gog_location.exists() {
|
||||
String::from("")
|
||||
} else {
|
||||
default_gog_location.to_string_lossy().to_string()
|
||||
};
|
||||
ui.gog_folder_input.set_value(
|
||||
&settings
|
||||
.gog
|
||||
.location
|
||||
.clone()
|
||||
.unwrap_or(default_gog_location),
|
||||
);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
ui.gog_winedrive_input
|
||||
.set_value(&settings.gog.wine_c_drive.clone().unwrap_or("".to_string()));
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
ui.gog_winedrive_input.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user