mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Implement simple clippy suggestions (#159)
This commit is contained in:
@@ -13,7 +13,7 @@ impl From<AmazonGame> for ShortcutOwned {
|
|||||||
fn from(game: AmazonGame) -> Self {
|
fn from(game: AmazonGame) -> Self {
|
||||||
let launch = format!("amazon-games://play/{}", game.id);
|
let launch = format!("amazon-games://play/{}", game.id);
|
||||||
let exe = game.launcher_path.to_string_lossy().to_string();
|
let exe = game.launcher_path.to_string_lossy().to_string();
|
||||||
let start_dir= game.launcher_path.parent().unwrap_or(Path::new("")).to_string_lossy().to_string();
|
let start_dir= game.launcher_path.parent().unwrap_or_else(||Path::new("")).to_string_lossy().to_string();
|
||||||
Shortcut::new("0", game.title.as_str(), exe.as_str(), start_dir.as_str(), "", "", launch.as_str()).to_owned()
|
Shortcut::new("0", game.title.as_str(), exe.as_str(), start_dir.as_str(), "", "", launch.as_str()).to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -18,7 +18,7 @@ pub fn get_config_folder() -> PathBuf {
|
|||||||
pub fn get_config_folder() -> PathBuf {
|
pub fn get_config_folder() -> PathBuf {
|
||||||
let config_home = std::env::var("APPDATA");
|
let config_home = std::env::var("APPDATA");
|
||||||
match config_home {
|
match config_home {
|
||||||
Ok(p) => Path::new(&p).join("boilr").to_path_buf(),
|
Ok(p) => Path::new(&p).join("boilr"),
|
||||||
Err(_) => Path::new("").to_path_buf(),
|
Err(_) => Path::new("").to_path_buf(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,21 +26,21 @@ pub fn get_config_folder() -> PathBuf {
|
|||||||
pub fn get_thumbnails_folder() -> PathBuf {
|
pub fn get_thumbnails_folder() -> PathBuf {
|
||||||
let thumbnails_path = get_config_folder().join("thumbnails");
|
let thumbnails_path = get_config_folder().join("thumbnails");
|
||||||
let _ = create_dir_all(&thumbnails_path);
|
let _ = create_dir_all(&thumbnails_path);
|
||||||
thumbnails_path.to_path_buf()
|
thumbnails_path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_file() -> PathBuf {
|
pub fn get_config_file() -> PathBuf {
|
||||||
get_config_folder().join("config.toml").to_path_buf()
|
get_config_folder().join("config.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cache_file() -> PathBuf {
|
pub fn get_cache_file() -> PathBuf {
|
||||||
get_config_folder().join("cache.json").to_path_buf()
|
get_config_folder().join("cache.json")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_backups_flder() -> PathBuf {
|
pub fn get_backups_flder() -> PathBuf {
|
||||||
let backups_path = get_config_folder().join("backup");
|
let backups_path = get_config_folder().join("backup");
|
||||||
let _ = create_dir_all(&backups_path);
|
let _ = create_dir_all(&backups_path);
|
||||||
backups_path.to_path_buf()
|
backups_path
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use super::{EpicGamesLauncherSettings, ManifestItem};
|
use super::{EpicGamesLauncherSettings, ManifestItem};
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use std::env::{self};
|
|
||||||
|
|
||||||
use std::fs::{DirEntry, File};
|
use std::fs::{DirEntry, File};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ fn launcher_shortcut(manifest: ManifestItem) -> ShortcutOwned {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|p| {
|
.map(|p| {
|
||||||
p.parent()
|
p.parent()
|
||||||
.unwrap_or(Path::new(""))
|
.unwrap_or_else(||Path::new(""))
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string()
|
.to_string()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ impl From<OriginGame> for ShortcutOwned {
|
|||||||
fn from(game: OriginGame) -> Self {
|
fn from(game: OriginGame) -> Self {
|
||||||
let launch = match game.origin_compat_folder{
|
let launch = match game.origin_compat_folder{
|
||||||
Some(compat_folder) =>
|
Some(compat_folder) =>
|
||||||
format!("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"", compat_folder.to_string_lossy().to_string(), game.id)
|
format!("STEAM_COMPAT_DATA_PATH=\"{}\" %command% \"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"", compat_folder.to_string_lossy(), game.id)
|
||||||
,
|
,
|
||||||
None => format!(
|
None => format!(
|
||||||
"\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
"\"origin2://game/launch?offerIds={}&autoDownload=1&authCode=&cmdParams=\"",
|
||||||
|
|||||||
@@ -174,10 +174,11 @@ fn get_default_locations() -> Option<OriginPathData> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let exe_path = get_exe_path();
|
let exe_path = get_exe_path();
|
||||||
if exe_path.is_none() {
|
match exe_path {
|
||||||
return None;
|
Some(exe_path) => {
|
||||||
} else {
|
res.exe_path = exe_path;
|
||||||
res.exe_path = exe_path.unwrap();
|
}
|
||||||
|
None => return None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(res)
|
Some(res)
|
||||||
@@ -194,7 +195,7 @@ fn get_exe_path() -> Option<PathBuf> {
|
|||||||
let launcher_string: Result<String, _> = launcher_key.get_value("");
|
let launcher_string: Result<String, _> = launcher_key.get_value("");
|
||||||
if let Ok(launcher_string) = launcher_string {
|
if let Ok(launcher_string) = launcher_string {
|
||||||
let path = Path::new(&launcher_string[1..launcher_string.len() - 6]);
|
let path = Path::new(&launcher_string[1..launcher_string.len() - 6]);
|
||||||
println!("{:?}",path);
|
println!("{:?}", path);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
return Some(path.to_path_buf());
|
return Some(path.to_path_buf());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
use std::{ffi::OsStr, path::{Path, PathBuf}};
|
use std::{
|
||||||
|
ffi::OsStr,
|
||||||
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
use super::{get_steam_path, SteamSettings};
|
use super::{get_steam_path, SteamSettings};
|
||||||
|
|
||||||
@@ -13,17 +16,15 @@ pub fn get_installed_games(settings: &SteamSettings) -> Vec<SteamGameInfo> {
|
|||||||
let mut games = vec![];
|
let mut games = vec![];
|
||||||
for apps_path in install_folders {
|
for apps_path in install_folders {
|
||||||
if let Ok(files) = std::fs::read_dir(apps_path) {
|
if let Ok(files) = std::fs::read_dir(apps_path) {
|
||||||
for file in files {
|
for file in files.flatten() {
|
||||||
if let Ok(file) = file {
|
|
||||||
if let Some(game_info) = parse_manifest_file(&file.path()) {
|
if let Some(game_info) = parse_manifest_file(&file.path()) {
|
||||||
games.push(game_info);
|
games.push(game_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
games.sort_by_key(|g| g.name.clone());
|
games.sort_by_key(|g| g.name.clone());
|
||||||
return games;
|
games
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_install_folders(settings: &SteamSettings) -> Vec<PathBuf> {
|
fn get_install_folders(settings: &SteamSettings) -> Vec<PathBuf> {
|
||||||
@@ -33,7 +34,7 @@ fn get_install_folders(settings: &SteamSettings) -> Vec<PathBuf> {
|
|||||||
|
|
||||||
let vdf_path = path.join("steamapps").join("libraryfolders.vdf");
|
let vdf_path = path.join("steamapps").join("libraryfolders.vdf");
|
||||||
if !vdf_path.exists() {
|
if !vdf_path.exists() {
|
||||||
result.push(path.join("steamapps").to_path_buf());
|
result.push(path.join("steamapps"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if let Ok(vdf_file) = std::fs::read_to_string(vdf_path) {
|
if let Ok(vdf_file) = std::fs::read_to_string(vdf_path) {
|
||||||
@@ -46,7 +47,7 @@ fn get_install_folders(settings: &SteamSettings) -> Vec<PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_manifest_file(path: &Path) -> Option<SteamGameInfo> {
|
fn parse_manifest_file(path: &Path) -> Option<SteamGameInfo> {
|
||||||
|
|||||||
+5
-9
@@ -35,7 +35,7 @@ impl MyEguiApp {
|
|||||||
let available_backups = self
|
let available_backups = self
|
||||||
.backup_state
|
.backup_state
|
||||||
.available_backups
|
.available_backups
|
||||||
.get_or_insert_with(|| load_backups());
|
.get_or_insert_with(load_backups);
|
||||||
|
|
||||||
if available_backups.is_empty() {
|
if available_backups.is_empty() {
|
||||||
ui.label("No backups found, they will be created every time you run import");
|
ui.label("No backups found, they will be created every time you run import");
|
||||||
@@ -58,8 +58,6 @@ impl MyEguiApp {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +75,7 @@ pub fn restore_backup(steam_settings: &SteamSettings, shortcut_path: &Path) -> b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_backups() -> Vec<PathBuf> {
|
pub fn load_backups() -> Vec<PathBuf> {
|
||||||
@@ -85,8 +83,7 @@ pub fn load_backups() -> Vec<PathBuf> {
|
|||||||
let files = std::fs::read_dir(&backup_folder);
|
let files = std::fs::read_dir(&backup_folder);
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
if let Ok(files) = files {
|
if let Ok(files) = files {
|
||||||
for file in files {
|
for file in files.flatten() {
|
||||||
if let Ok(file) = file {
|
|
||||||
if file
|
if file
|
||||||
.path()
|
.path()
|
||||||
.extension()
|
.extension()
|
||||||
@@ -98,15 +95,14 @@ pub fn load_backups() -> Vec<PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
result.sort();
|
result.sort();
|
||||||
result.reverse();
|
result.reverse();
|
||||||
return result;
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn backup_shortcuts(steam_settings: &SteamSettings) {
|
pub fn backup_shortcuts(steam_settings: &SteamSettings) {
|
||||||
let backup_folder = get_backups_flder();
|
let backup_folder = get_backups_flder();
|
||||||
let paths = get_shortcuts_paths(&steam_settings);
|
let paths = get_shortcuts_paths(steam_settings);
|
||||||
let date = Local::now();
|
let date = Local::now();
|
||||||
let date_string = date.format("%Y-%m-%d-%H-%M-%S");
|
let date_string = date.format("%Y-%m-%d-%H-%M-%S");
|
||||||
if let Ok(user_infos) = paths {
|
if let Ok(user_infos) = paths {
|
||||||
|
|||||||
+19
-30
@@ -148,17 +148,14 @@ impl MyEguiApp {
|
|||||||
if let Some(value) = render_possible_names(possible_names, ui) {
|
if let Some(value) = render_possible_names(possible_names, ui) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(image_type) = state.image_type_selected.as_ref() {
|
||||||
if let Some(image_type) = state.image_type_selected.as_ref() {
|
|
||||||
if let Some(action) = self.render_possible_images(ui, image_type, state) {
|
if let Some(action) = self.render_possible_images(ui, image_type, state) {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(action) = render_shortcut_images(ui, state) {
|
||||||
if let Some(action) = render_shortcut_images(ui, state) {
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let is_shortcut = state.game_mode.is_shortcuts();
|
let is_shortcut = state.game_mode.is_shortcuts();
|
||||||
if ui
|
if ui
|
||||||
@@ -178,11 +175,10 @@ impl MyEguiApp {
|
|||||||
if let Some(action) = self.render_shortcut_select(ui) {
|
if let Some(action) = self.render_shortcut_select(ui) {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(action) = render_steam_game_select(ui, state) {
|
||||||
if let Some(action) = render_steam_game_select(ui, state) {
|
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
UserAction::NoAction
|
UserAction::NoAction
|
||||||
}
|
}
|
||||||
@@ -201,15 +197,12 @@ impl MyEguiApp {
|
|||||||
let texture = self.image_selected_state.image_handles.get(&key);
|
let texture = self.image_selected_state.image_handles.get(&key);
|
||||||
let mut clicked = false;
|
let mut clicked = false;
|
||||||
if let Some(texture) = texture {
|
if let Some(texture) = texture {
|
||||||
match &texture.value() {
|
if let TextureState::Loaded(texture) = &texture.value() {
|
||||||
TextureState::Loaded(texture) => {
|
|
||||||
let mut size = texture.size_vec2();
|
let mut size = texture.size_vec2();
|
||||||
clamp_to_width(&mut size, 100.);
|
clamp_to_width(&mut size, 100.);
|
||||||
let image_button = ImageButton::new(texture, size);
|
let image_button = ImageButton::new(texture, size);
|
||||||
clicked = clicked || ui.add(image_button).clicked();
|
clicked = clicked || ui.add(image_button).clicked();
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let button = ui.button(&shortcut.app_name);
|
let button = ui.button(&shortcut.app_name);
|
||||||
@@ -241,7 +234,7 @@ impl MyEguiApp {
|
|||||||
.on_hover_text("Click here to clear the image")
|
.on_hover_text("Click here to clear the image")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
return Some(UserAction::ImageTypeCleared(image_type.clone(), false));
|
return Some(UserAction::ImageTypeCleared(*image_type, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ui
|
if ui
|
||||||
@@ -249,7 +242,7 @@ impl MyEguiApp {
|
|||||||
.on_hover_text("Stop downloading this type of image for this shortcut at all")
|
.on_hover_text("Stop downloading this type of image for this shortcut at all")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
return Some(UserAction::ImageTypeCleared(image_type.clone(), true));
|
return Some(UserAction::ImageTypeCleared(*image_type, true));
|
||||||
}
|
}
|
||||||
match &*state.image_options.borrow() {
|
match &*state.image_options.borrow() {
|
||||||
FetcStatus::Fetched(images) => {
|
FetcStatus::Fetched(images) => {
|
||||||
@@ -428,7 +421,7 @@ impl MyEguiApp {
|
|||||||
.image_selected_state
|
.image_selected_state
|
||||||
.selected_shortcut
|
.selected_shortcut
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| s.name().clone())
|
.map(|s| s.name())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let auth_key = self
|
let auth_key = self
|
||||||
.settings
|
.settings
|
||||||
@@ -437,7 +430,7 @@ impl MyEguiApp {
|
|||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let client = steamgriddb_api::Client::new(&auth_key);
|
let client = steamgriddb_api::Client::new(&auth_key);
|
||||||
let search_results = self.rt.block_on(client.search(&app_name));
|
let search_results = self.rt.block_on(client.search(app_name));
|
||||||
self.image_selected_state.possible_names = search_results.ok();
|
self.image_selected_state.possible_names = search_results.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,7 +445,7 @@ impl MyEguiApp {
|
|||||||
let client = steamgriddb_api::Client::new(auth_key);
|
let client = steamgriddb_api::Client::new(auth_key);
|
||||||
let mut cache = CachedSearch::new(&client);
|
let mut cache = CachedSearch::new(&client);
|
||||||
if let Some(shortcut) = &self.image_selected_state.selected_shortcut {
|
if let Some(shortcut) = &self.image_selected_state.selected_shortcut {
|
||||||
cache.set_cache(shortcut.app_id(), shortcut.name().clone(), grid_id);
|
cache.set_cache(shortcut.app_id(), shortcut.name(), grid_id);
|
||||||
cache.save();
|
cache.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,15 +564,12 @@ impl MyEguiApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn clear_loaded_images(&mut self) {
|
fn clear_loaded_images(&mut self) {
|
||||||
match &*self.image_selected_state.image_options.borrow() {
|
if let FetcStatus::Fetched(options) = &*self.image_selected_state.image_options.borrow() {
|
||||||
FetcStatus::Fetched(options) => {
|
|
||||||
for option in options {
|
for option in options {
|
||||||
let key = option.thumbnail_path.to_string_lossy().to_string();
|
let key = option.thumbnail_path.to_string_lossy().to_string();
|
||||||
self.image_selected_state.image_handles.remove(&key);
|
self.image_selected_state.image_handles.remove(&key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_shortcut_selected(&mut self, shortcut: GameType, ui: &mut egui::Ui) {
|
fn handle_shortcut_selected(&mut self, shortcut: GameType, ui: &mut egui::Ui) {
|
||||||
@@ -598,7 +588,7 @@ impl MyEguiApp {
|
|||||||
state.selected_shortcut = Some(shortcut.clone());
|
state.selected_shortcut = Some(shortcut.clone());
|
||||||
|
|
||||||
for image_type in ImageType::all() {
|
for image_type in ImageType::all() {
|
||||||
let (path, key) = shortcut.key(image_type, &Path::new(&user.steam_user_data_folder));
|
let (path, key) = shortcut.key(image_type, Path::new(&user.steam_user_data_folder));
|
||||||
let image = load_image_from_path(&path);
|
let image = load_image_from_path(&path);
|
||||||
if let Some(image) = image {
|
if let Some(image) = image {
|
||||||
let texture = ui.ctx().load_texture(&key, image);
|
let texture = ui.ctx().load_texture(&key, image);
|
||||||
@@ -669,15 +659,14 @@ fn render_shortcut_images(ui: &mut egui::Ui, state: &ImageSelectState) -> Option
|
|||||||
let user_path = &state.steam_user.as_ref().unwrap().steam_user_data_folder;
|
let user_path = &state.steam_user.as_ref().unwrap().steam_user_data_folder;
|
||||||
for image_type in ImageType::all() {
|
for image_type in ImageType::all() {
|
||||||
ui.label(image_type.name());
|
ui.label(image_type.name());
|
||||||
let (_path, key) = shortcut.key(&image_type, Path::new(&user_path));
|
let (_path, key) = shortcut.key(image_type, Path::new(&user_path));
|
||||||
let texture = state
|
let texture = state
|
||||||
.image_handles
|
.image_handles
|
||||||
.get(&key)
|
.get(&key)
|
||||||
.map(|k| match k.value() {
|
.and_then(|k| match k.value() {
|
||||||
TextureState::Loaded(texture) => Some(texture.clone()),
|
TextureState::Loaded(texture) => Some(texture.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
});
|
||||||
.flatten();
|
|
||||||
let clicked = render_thumbnail(ui, texture);
|
let clicked = render_thumbnail(ui, texture);
|
||||||
if clicked {
|
if clicked {
|
||||||
return Some(UserAction::ImageTypeSelected(*image_type));
|
return Some(UserAction::ImageTypeSelected(*image_type));
|
||||||
@@ -728,7 +717,7 @@ fn clamp_to_width(size: &mut egui::Vec2, max_width: f32) {
|
|||||||
trait HasImageKey {
|
trait HasImageKey {
|
||||||
fn key(&self, image_type: &ImageType, user_path: &Path) -> (PathBuf, String);
|
fn key(&self, image_type: &ImageType, user_path: &Path) -> (PathBuf, String);
|
||||||
}
|
}
|
||||||
const POSSIBLE_EXTENSIONS: [&'static str; 4] = ["png", "jpg", "ico", "webp"];
|
const POSSIBLE_EXTENSIONS: [&str; 4] = ["png", "jpg", "ico", "webp"];
|
||||||
|
|
||||||
impl HasImageKey for GameType {
|
impl HasImageKey for GameType {
|
||||||
fn key(&self, image_type: &ImageType, user_path: &Path) -> (PathBuf, String) {
|
fn key(&self, image_type: &ImageType, user_path: &Path) -> (PathBuf, String) {
|
||||||
@@ -744,7 +733,7 @@ impl HasImageKey for SteamGameInfo {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|ext| key_from_extension(self.appid, image_type, user_path, ext));
|
.map(|ext| key_from_extension(self.appid, image_type, user_path, ext));
|
||||||
let first = keys.next().unwrap();
|
let first = keys.next().unwrap();
|
||||||
let other = keys.filter(|(exsists, _, _)| *exsists).next();
|
let other = keys.find(|(exsists, _, _)| *exsists);
|
||||||
let (_, path, key) = other.unwrap_or(first);
|
let (_, path, key) = other.unwrap_or(first);
|
||||||
(path, key)
|
(path, key)
|
||||||
}
|
}
|
||||||
@@ -756,7 +745,7 @@ impl HasImageKey for ShortcutOwned {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|ext| key_from_extension(self.app_id, image_type, user_path, ext));
|
.map(|ext| key_from_extension(self.app_id, image_type, user_path, ext));
|
||||||
let first = keys.next().unwrap();
|
let first = keys.next().unwrap();
|
||||||
let other = keys.filter(|(exsists, _, _)| *exsists).next();
|
let other = keys.find(|(exsists, _, _)| *exsists);
|
||||||
let (_, path, key) = other.unwrap_or(first);
|
let (_, path, key) = other.unwrap_or(first);
|
||||||
(path, key)
|
(path, key)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ self.settings.heroic.default_launch_through_heroic{
|
|||||||
let heroic_platform =HeroicPlatform{
|
let heroic_platform =HeroicPlatform{
|
||||||
settings:heroic_setting
|
settings:heroic_setting
|
||||||
};
|
};
|
||||||
let heroic_games = heroic_platform.get_heroic_games(&install_modes);
|
heroic_platform.get_heroic_games(&install_modes)
|
||||||
heroic_games
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let safe_open_games = &mut self.settings.heroic.launch_games_through_heroic;
|
let safe_open_games = &mut self.settings.heroic.launch_games_through_heroic;
|
||||||
@@ -243,12 +242,10 @@ self.settings.heroic.default_launch_through_heroic{
|
|||||||
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
|
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if auth_key.is_empty() {
|
if auth_key.is_empty() && ui.button("Paste from clipboard").clicked(){
|
||||||
if ui.button("Paste from clipboard").clicked() {
|
|
||||||
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
|
||||||
if let Ok(content) = clipboard_ctx.get_contents() {
|
if let Ok(content) = clipboard_ctx.get_contents() {
|
||||||
self.settings.steamgrid_db.auth_key = Some(content.clone());
|
self.settings.steamgrid_db.auth_key = Some(content);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ pub(crate) struct Game {
|
|||||||
impl From<Game> for ShortcutOwned {
|
impl From<Game> for ShortcutOwned {
|
||||||
fn from(game: Game) -> Self {
|
fn from(game: Game) -> Self {
|
||||||
let launch = format!("\"uplay://launch/{}/0\"", game.id);
|
let launch = format!("\"uplay://launch/{}/0\"", game.id);
|
||||||
let start_dir = game.launcher.parent().unwrap_or(Path::new("")).to_string_lossy();
|
let start_dir = game.launcher.parent().unwrap_or_else(|| {Path::new("")}).to_string_lossy();
|
||||||
let exe = format!("\"{}\"",game.launcher.to_string_lossy());
|
let exe = format!("\"{}\"",game.launcher.to_string_lossy());
|
||||||
Shortcut::new("0", &game.name, &exe, &start_dir, &game.icon, "", &launch).to_owned()
|
Shortcut::new("0", &game.name, &exe, &start_dir, &game.icon, "", &launch).to_owned()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,18 +29,18 @@ impl Platform<Game, Box<dyn Error>> for Uplay {
|
|||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
{
|
{
|
||||||
//Linux not supported yet
|
//Linux not supported yet
|
||||||
return crate::platform::SettingsValidity::Invalid {
|
crate::platform::SettingsValidity::Invalid {
|
||||||
reason: "Linux not supported yet".to_string(),
|
reason: "Linux not supported yet".to_string(),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
if get_launcher_path().is_some() {
|
if get_launcher_path().is_some() {
|
||||||
return crate::platform::SettingsValidity::Valid;
|
crate::platform::SettingsValidity::Valid
|
||||||
} else {
|
} else {
|
||||||
return crate::platform::SettingsValidity::Invalid {
|
crate::platform::SettingsValidity::Invalid {
|
||||||
reason: "Could not find UPlay instalation".to_string(),
|
reason: "Could not find UPlay instalation".to_string(),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ fn get_launcher_path() -> Option<PathBuf> {
|
|||||||
if let Ok(launcher_dir) = launcher_dir {
|
if let Ok(launcher_dir) = launcher_dir {
|
||||||
let path = Path::new(&launcher_dir).join("upc.exe");
|
let path = Path::new(&launcher_dir).join("upc.exe");
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
return Some(path.to_path_buf());
|
return Some(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user