mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 14:03:42 +02:00
Clippy fixes (#309)
* Automatic clippy fixes * Manual clippy corrections
This commit is contained in:
+1
-1
@@ -25,5 +25,5 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
fn ensure_config_folder() {
|
fn ensure_config_folder() {
|
||||||
let path = config::get_config_folder();
|
let path = config::get_config_folder();
|
||||||
let _ = std::fs::create_dir_all(&path);
|
let _ = std::fs::create_dir_all(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,18 +71,18 @@ fn get_manifest_item(dir_entry: DirEntry, _path: Option<PathBuf>) -> Option<Mani
|
|||||||
item.manifest_location = compat_folder
|
item.manifest_location = compat_folder
|
||||||
.join("pfx")
|
.join("pfx")
|
||||||
.join("dosdevices")
|
.join("dosdevices")
|
||||||
.join(&item.manifest_location[0..2].to_lowercase())
|
.join(item.manifest_location[0..2].to_lowercase())
|
||||||
.join(&item.manifest_location[3..].replace('\\', "/"))
|
.join(item.manifest_location[3..].replace('\\', "/"))
|
||||||
.to_path_buf()
|
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
item.install_location = compat_folder
|
item.install_location = compat_folder
|
||||||
.join("pfx")
|
.join("pfx")
|
||||||
.join("dosdevices")
|
.join("dosdevices")
|
||||||
.join(&item.install_location[0..2].to_lowercase())
|
.join(item.install_location[0..2].to_lowercase())
|
||||||
.join(&item.install_location[3..].replace('\\', "/"))
|
.join(item.install_location[3..].replace('\\', "/"))
|
||||||
.to_path_buf()
|
|
||||||
.to_string_lossy()
|
.to_string_lossy()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ mod unix {
|
|||||||
.join("steamapps")
|
.join("steamapps")
|
||||||
.join("compatdata");
|
.join("compatdata");
|
||||||
|
|
||||||
if let Ok(compat_folder) = std::fs::read_dir(&compat_folder_path) {
|
if let Ok(compat_folder) = std::fs::read_dir(compat_folder_path) {
|
||||||
for dir in compat_folder.flatten() {
|
for dir in compat_folder.flatten() {
|
||||||
let binary_path = dir
|
let binary_path = dir
|
||||||
.path()
|
.path()
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl From<GogShortcut> for ShortcutOwned {
|
|||||||
fn from(gogs: GogShortcut) -> Self {
|
fn from(gogs: GogShortcut) -> Self {
|
||||||
let exe = Path::new(&gogs.game_folder).join(gogs.path);
|
let exe = Path::new(&gogs.game_folder).join(gogs.path);
|
||||||
let icon_file = format!("goggame-{}.ico", gogs.game_id);
|
let icon_file = format!("goggame-{}.ico", gogs.game_id);
|
||||||
let icon_path = Path::new(&gogs.game_folder).join(&icon_file);
|
let icon_path = Path::new(&gogs.game_folder).join(icon_file);
|
||||||
let icon = if icon_path.exists() {
|
let icon = if icon_path.exists() {
|
||||||
icon_path.to_str().unwrap().to_string()
|
icon_path.to_str().unwrap().to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ fn get_shortcuts_from_games(games: Vec<(GogGame, PathBuf)>) -> Vec<GogShortcut>
|
|||||||
|| t.category.as_ref().unwrap_or(&String::from("")) == "game")
|
|| t.category.as_ref().unwrap_or(&String::from("")) == "game")
|
||||||
}) {
|
}) {
|
||||||
if let Some(task_path) = &primary_task.path {
|
if let Some(task_path) = &primary_task.path {
|
||||||
let full_path = game_folder.join(&task_path);
|
let full_path = game_folder.join(task_path);
|
||||||
if let Some(full_path) = full_path.to_str() {
|
if let Some(full_path) = full_path.to_str() {
|
||||||
let folder_path = folder_path.to_string();
|
let folder_path = folder_path.to_string();
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ fn fix_paths(wine_c_drive: &str, paths: Vec<String>) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_install_locations(path: PathBuf) -> eyre::Result<Vec<String>> {
|
fn get_install_locations(path: PathBuf) -> eyre::Result<Vec<String>> {
|
||||||
let data_res = std::fs::read_to_string(&path)?;
|
let data_res = std::fs::read_to_string(path)?;
|
||||||
let config: GogConfig = serde_json::from_str(&data_res)?;
|
let config: GogConfig = serde_json::from_str(&data_res)?;
|
||||||
let path_vec = match config.library_path {
|
let path_vec = match config.library_path {
|
||||||
Some(path) => vec![path],
|
Some(path) => vec![path],
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ impl ItchPlatform {
|
|||||||
|
|
||||||
//This is done to paths dedupe
|
//This is done to paths dedupe
|
||||||
let paths: HashSet<&DbPaths> = paths.iter().collect();
|
let paths: HashSet<&DbPaths> = paths.iter().collect();
|
||||||
let res = paths.iter().filter_map(|e| dbpath_to_game(*e)).collect();
|
let res = paths.iter().filter_map(|e| dbpath_to_game(e)).collect();
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ fn dbpath_to_game(paths: &DbPaths) -> Option<ItchGame> {
|
|||||||
paths
|
paths
|
||||||
.paths
|
.paths
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|p| Path::new(&paths.base_path).join(&p).is_executable())
|
.filter(|p| Path::new(&paths.base_path).join(p).is_executable())
|
||||||
.find_map(|executable| {
|
.find_map(|executable| {
|
||||||
let gz_bytes = std::fs::read(&recipt).unwrap();
|
let gz_bytes = std::fs::read(&recipt).unwrap();
|
||||||
let mut d = GzDecoder::new(gz_bytes.as_slice());
|
let mut d = GzDecoder::new(gz_bytes.as_slice());
|
||||||
|
|||||||
@@ -80,11 +80,9 @@ impl GamesPlatform for MiniGalaxyPlatform{
|
|||||||
};
|
};
|
||||||
let dirs = games_folder.read_dir()?;
|
let dirs = games_folder.read_dir()?;
|
||||||
let mut game_folders = vec![];
|
let mut game_folders = vec![];
|
||||||
for game_folder in dirs{
|
for game_folder in dirs.flatten(){
|
||||||
if let Ok(game_folder) = game_folder{
|
|
||||||
game_folders.push(game_folder.path().to_owned());
|
game_folders.push(game_folder.path().to_owned());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let gog_games = crate::platforms::get_gog_shortcuts_from_game_folders(game_folders);
|
let gog_games = crate::platforms::get_gog_shortcuts_from_game_folders(game_folders);
|
||||||
crate::platforms::to_shortcuts(self, Ok(gog_games))
|
crate::platforms::to_shortcuts(self, Ok(gog_games))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ fn get_folder_mfst_file_content(game_folder_path: &Path) -> Option<String> {
|
|||||||
let mfst_file = game_folder_files
|
let mfst_file = game_folder_files
|
||||||
.filter_map(|file| file.ok())
|
.filter_map(|file| file.ok())
|
||||||
.find(is_mfst_file)
|
.find(is_mfst_file)
|
||||||
.map(|file| std::fs::read_to_string(&file.path()));
|
.map(|file| std::fs::read_to_string(file.path()));
|
||||||
return match mfst_file {
|
return match mfst_file {
|
||||||
Some(mfst_file) => mfst_file.ok(),
|
Some(mfst_file) => mfst_file.ok(),
|
||||||
None => None,
|
None => None,
|
||||||
@@ -111,7 +111,7 @@ fn get_default_locations() -> Option<OriginPathData> {
|
|||||||
.join("steamapps")
|
.join("steamapps")
|
||||||
.join("compatdata");
|
.join("compatdata");
|
||||||
|
|
||||||
if let Ok(compat_folder) = std::fs::read_dir(&compat_folder_path) {
|
if let Ok(compat_folder) = std::fs::read_dir(compat_folder_path) {
|
||||||
for dir in compat_folder.flatten() {
|
for dir in compat_folder.flatten() {
|
||||||
let origin_exe_path = dir
|
let origin_exe_path = dir
|
||||||
.path()
|
.path()
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ pub fn write_collections<S: AsRef<str>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let new_string = write_vdf_collection_to_string(
|
let new_string = write_vdf_collection_to_string(
|
||||||
&path.clone().to_string_lossy(),
|
path.clone().to_string_lossy(),
|
||||||
&vdf_collections,
|
&vdf_collections,
|
||||||
);
|
);
|
||||||
if let Some(new_string) = new_string {
|
if let Some(new_string) = new_string {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ pub fn ensure_steam_started(_settings: &super::SteamSettings) {
|
|||||||
if processes.next().is_none() {
|
if processes.next().is_none() {
|
||||||
//no steam, we need to start it
|
//no steam, we need to start it
|
||||||
println!("Starting steam");
|
println!("Starting steam");
|
||||||
let mut command = Command::new(&steam_name);
|
let mut command = Command::new(steam_name);
|
||||||
if let Err(e) = command.spawn() {
|
if let Err(e) = command.spawn() {
|
||||||
println!("Failed to start steam: {:?}", e);
|
println!("Failed to start steam: {:?}", e);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,6 +68,6 @@ fn get_search_map() -> SearchMap {
|
|||||||
fn save_search_map(search_map: &SearchMap) {
|
fn save_search_map(search_map: &SearchMap) {
|
||||||
let string = serde_json::to_string(search_map).unwrap();
|
let string = serde_json::to_string(search_map).unwrap();
|
||||||
let path = get_cache_file();
|
let path = get_cache_file();
|
||||||
let mut file = File::create(&path).unwrap();
|
let mut file = File::create(path).unwrap();
|
||||||
file.write_all(string.as_bytes()).unwrap();
|
file.write_all(string.as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ pub fn create_sym_links(shortcut: &ShortcutOwned) -> ShortcutOwned {
|
|||||||
|
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
// If the links exsists, then they must point towards what is needed, otherwise they would have a different app id
|
// 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 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();
|
let workdir_ok = workdir_link.exists() || symlink(workdir_original, &workdir_link).is_ok();
|
||||||
match (target_ok, workdir_ok) {
|
match (target_ok, workdir_ok) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
let exe = target_link.to_string_lossy().to_string();
|
let exe = target_link.to_string_lossy().to_string();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ fn render_possible_image(
|
|||||||
}
|
}
|
||||||
TextureDownloadState::Downloaded => {
|
TextureDownloadState::Downloaded => {
|
||||||
//Need to load
|
//Need to load
|
||||||
let image_data = load_image_from_path(&path);
|
let image_data = load_image_from_path(path);
|
||||||
match image_data {
|
match image_data {
|
||||||
Ok(image_data) => {
|
Ok(image_data) => {
|
||||||
let handle = ui.ctx().load_texture(
|
let handle = ui.ctx().load_texture(
|
||||||
|
|||||||
@@ -5,19 +5,14 @@ pub fn render_user_select<'a>(
|
|||||||
steam_users: &'a [SteamUsersInfo],
|
steam_users: &'a [SteamUsersInfo],
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
) -> Option<&'a SteamUsersInfo> {
|
) -> Option<&'a SteamUsersInfo> {
|
||||||
if steam_user.is_none() {
|
if let Some(mut selected_user) = steam_user {
|
||||||
if steam_users.len() > 0 {
|
|
||||||
return Some(&steam_users[0]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let mut selected_user = steam_user.as_ref().unwrap().clone();
|
|
||||||
let id_before = selected_user.user_id.clone();
|
let id_before = selected_user.user_id.clone();
|
||||||
if steam_users.len() > 0 {
|
if !steam_users.is_empty() {
|
||||||
let combo_box = egui::ComboBox::new("ImageUserSelect", "")
|
let combo_box = egui::ComboBox::new("ImageUserSelect", "")
|
||||||
.selected_text(format!("Steam user id: {}", &selected_user.user_id));
|
.selected_text(format!("Steam user id: {}", &selected_user.user_id));
|
||||||
combo_box.show_ui(ui, |ui| {
|
combo_box.show_ui(ui, |ui| {
|
||||||
for user in steam_users {
|
for user in steam_users {
|
||||||
ui.selectable_value(&mut selected_user, &user, &user.user_id);
|
ui.selectable_value(&mut selected_user, user, &user.user_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -25,6 +20,9 @@ pub fn render_user_select<'a>(
|
|||||||
if !id_before.eq(&id_now) {
|
if !id_before.eq(&id_now) {
|
||||||
return Some(selected_user);
|
return Some(selected_user);
|
||||||
}
|
}
|
||||||
|
} else if !steam_users.is_empty() {
|
||||||
|
return Some(&steam_users[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -39,8 +39,8 @@ pub mod ui_images {
|
|||||||
let image_buffer = image.to_rgba8();
|
let image_buffer = image.to_rgba8();
|
||||||
let pixels = image_buffer.as_flat_samples();
|
let pixels = image_buffer.as_flat_samples();
|
||||||
IconData {
|
IconData {
|
||||||
height: image.height() as u32,
|
height: image.height(),
|
||||||
width: image.width() as u32,
|
width: image.width(),
|
||||||
rgba: pixels.as_slice().to_vec(),
|
rgba: pixels.as_slice().to_vec(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ pub mod ui_images {
|
|||||||
pub fn load_image_from_path(path: &std::path::Path) -> eyre::Result<egui::ColorImage> {
|
pub fn load_image_from_path(path: &std::path::Path) -> eyre::Result<egui::ColorImage> {
|
||||||
let path_owned = path.to_owned();
|
let path_owned = path.to_owned();
|
||||||
let handle: JoinHandle<eyre::Result<egui::ColorImage>> = std::thread::spawn(move || {
|
let handle: JoinHandle<eyre::Result<egui::ColorImage>> = std::thread::spawn(move || {
|
||||||
let image = image::io::Reader::open(&path_owned)?
|
let image = image::io::Reader::open(path_owned)?
|
||||||
.with_guessed_format()?
|
.with_guessed_format()?
|
||||||
.decode()?;
|
.decode()?;
|
||||||
let size = [image.width() as _, image.height() as _];
|
let size = [image.width() as _, image.height() as _];
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ fn key_from_extension(
|
|||||||
ext: &str,
|
ext: &str,
|
||||||
) -> (bool, PathBuf, String) {
|
) -> (bool, PathBuf, String) {
|
||||||
let file_name = image_type.file_name(app_id, ext);
|
let file_name = image_type.file_name(app_id, ext);
|
||||||
let path = user_path.join("config").join("grid").join(&file_name);
|
let path = user_path.join("config").join("grid").join(file_name);
|
||||||
let key = path.to_string_lossy().to_string();
|
let key = path.to_string_lossy().to_string();
|
||||||
(path.exists(), path, key)
|
(path.exists(), path, key)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub fn handle_correct_grid_request(app:&mut MyEguiApp) {
|
|||||||
.auth_key
|
.auth_key
|
||||||
.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 = app.rt.block_on(client.search(app_name));
|
let search_results = app.rt.block_on(client.search(app_name));
|
||||||
app.image_selected_state.possible_names = search_results.ok();
|
app.image_selected_state.possible_names = search_results.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub fn render_page_pick_image(
|
|||||||
if render_image_from_path_or_url(
|
if render_image_from_path_or_url(
|
||||||
ui,
|
ui,
|
||||||
&state.image_handles,
|
&state.image_handles,
|
||||||
&path,
|
path,
|
||||||
column_width,
|
column_width,
|
||||||
&image.full_url,
|
&image.full_url,
|
||||||
image_type,
|
image_type,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ impl MyEguiApp {
|
|||||||
let users = state.steam_users.as_ref();
|
let users = state.steam_users.as_ref();
|
||||||
if let Some(users) = users {
|
if let Some(users) = users {
|
||||||
if let Some(value) =
|
if let Some(value) =
|
||||||
render_user_select(state.steam_user.as_ref(), &users, ui)
|
render_user_select(state.steam_user.as_ref(), users, ui)
|
||||||
{
|
{
|
||||||
return Some(UserAction::UserSelected(value.clone()));
|
return Some(UserAction::UserSelected(value.clone()));
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ impl MyEguiApp {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} else if let Some(image_type) = state.image_type_selected.as_ref() {
|
} else if let Some(image_type) = state.image_type_selected.as_ref() {
|
||||||
if let Some(action) = render_page_pick_image(&self, ui, image_type, state) {
|
if let Some(action) = render_page_pick_image(self, ui, image_type, state) {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
} else if let Some(action) = render_page_shortcut_select_image_type(ui, state) {
|
} else if let Some(action) = render_page_shortcut_select_image_type(ui, state) {
|
||||||
@@ -76,7 +76,7 @@ impl MyEguiApp {
|
|||||||
} else {
|
} else {
|
||||||
let is_shortcut = state.game_mode.is_shortcuts();
|
let is_shortcut = state.game_mode.is_shortcuts();
|
||||||
if is_shortcut {
|
if is_shortcut {
|
||||||
if let Some(action) = render_page_shortcut_images_overview(&self, ui) {
|
if let Some(action) = render_page_shortcut_images_overview(self, ui) {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
} else if let Some(action) = render_page_steam_images_overview(ui, state) {
|
} else if let Some(action) = render_page_steam_images_overview(ui, state) {
|
||||||
@@ -246,7 +246,7 @@ impl MyEguiApp {
|
|||||||
let path = Path::new(data_folder)
|
let path = Path::new(data_folder)
|
||||||
.join("config")
|
.join("config")
|
||||||
.join("grid")
|
.join("grid")
|
||||||
.join(&file_name);
|
.join(file_name);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
let _ = std::fs::remove_file(&path);
|
let _ = std::fs::remove_file(&path);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -80,7 +80,7 @@ pub fn restore_backup(steam_settings: &SteamSettings, shortcut_path: &Path) -> b
|
|||||||
|
|
||||||
pub fn load_backups() -> Vec<PathBuf> {
|
pub fn load_backups() -> Vec<PathBuf> {
|
||||||
let backup_folder = get_backups_flder();
|
let backup_folder = get_backups_flder();
|
||||||
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.flatten() {
|
for file in files.flatten() {
|
||||||
@@ -118,7 +118,7 @@ pub fn backup_shortcuts(steam_settings: &SteamSettings) {
|
|||||||
user_info.user_id, date_string
|
user_info.user_id, date_string
|
||||||
));
|
));
|
||||||
println!("Backed up shortcut at: {:?}", new_path);
|
println!("Backed up shortcut at: {:?}", new_path);
|
||||||
std::fs::copy(&shortcut_path, &new_path).unwrap();
|
std::fs::copy(shortcut_path, &new_path).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -372,7 +372,7 @@ pub fn run_ui(args: Vec<String>) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_fullscreen(args: &Vec<String>) -> bool {
|
fn is_fullscreen(args: &[String]) -> bool {
|
||||||
let is_steam_mode = match std::env::var("SteamAppId") {
|
let is_steam_mode = match std::env::var("SteamAppId") {
|
||||||
Ok(value) => !value.is_empty(),
|
Ok(value) => !value.is_empty(),
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
|
|||||||
Reference in New Issue
Block a user