mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Fix icon overwrite (#128)
* run sync twive to fix up images * Update dependencies versions * update cargo-lock dependencies * Adding spinners to ui * Fix icons for gog games * Run fix shortcuts for all boilr shortcuts * Update flatpak release notes
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ impl From<GogShortcut> for ShortcutOwned {
|
||||
let icon = if icon_path.exists() {
|
||||
icon_path.to_str().unwrap().to_string()
|
||||
} else {
|
||||
exe.to_str().unwrap_or("").to_string()
|
||||
"".to_string()
|
||||
};
|
||||
let mut exe_string = exe.to_string_lossy().to_string();
|
||||
if exe_string.contains(' ') && !exe_string.starts_with('\"') {
|
||||
|
||||
@@ -142,20 +142,15 @@ fn fix_shortcut_icons(
|
||||
|
||||
for shortcut in shortcuts {
|
||||
if shortcut.is_boilr_shortcut() {
|
||||
let replace_icon = shortcut.icon.trim().eq("")
|
||||
|| !Path::new(shortcut.icon.trim()).exists()
|
||||
|| shortcut.icon.eq(&shortcut.exe);
|
||||
if replace_icon {
|
||||
let app_id = steam_shortcuts_util::app_id_generator::calculate_app_id(
|
||||
&shortcut.exe,
|
||||
&shortcut.app_name,
|
||||
);
|
||||
for ext in ["ico", "png", "jpg", "webp"] {
|
||||
let path = image_folder.join(image_type.file_name(app_id, ext));
|
||||
if path.exists() {
|
||||
shortcut.icon = path.to_string_lossy().to_string();
|
||||
break;
|
||||
}
|
||||
let app_id = steam_shortcuts_util::app_id_generator::calculate_app_id(
|
||||
&shortcut.exe,
|
||||
&shortcut.app_name,
|
||||
);
|
||||
for ext in ["ico", "png", "jpg", "webp"] {
|
||||
let path = image_folder.join(image_type.file_name(app_id, ext));
|
||||
if path.exists() {
|
||||
shortcut.icon = path.to_string_lossy().to_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ pub mod ui_colors {
|
||||
pub mod ui_images {
|
||||
use std::path::Path;
|
||||
|
||||
use eframe::epi::IconData;
|
||||
use eframe::IconData;
|
||||
use egui::{ColorImage, ImageData};
|
||||
|
||||
pub const IMPORT_GAMES_IMAGE: &[u8] = include_bytes!("../../resources/import_games_button.png");
|
||||
|
||||
@@ -5,9 +5,9 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
config::get_thumbnails_folder,
|
||||
steam::{get_installed_games, SteamGameInfo},
|
||||
steam::{get_shortcuts_paths, SteamUsersInfo},
|
||||
steamgriddb::{get_image_extension, get_query_type, CachedSearch, ImageType, ToDownload},
|
||||
steam::{get_installed_games, SteamGameInfo},
|
||||
};
|
||||
use dashmap::DashMap;
|
||||
use egui::{ImageButton, ScrollArea};
|
||||
@@ -262,7 +262,10 @@ impl MyEguiApp {
|
||||
TextureState::Downloading => {
|
||||
ui.ctx().request_repaint();
|
||||
//nothing to do,just wait
|
||||
ui.label(format!("Downloading id {}", image.id));
|
||||
ui.horizontal(|ui| {
|
||||
ui.spinner();
|
||||
ui.label(format!("Downloading id {}", image.id));
|
||||
});
|
||||
}
|
||||
TextureState::Downloaded => {
|
||||
//Need to load
|
||||
@@ -272,7 +275,10 @@ impl MyEguiApp {
|
||||
*state.value_mut() = TextureState::Loaded(handle);
|
||||
}
|
||||
ui.ctx().request_repaint();
|
||||
ui.label("Loading");
|
||||
ui.horizontal(|ui| {
|
||||
ui.spinner();
|
||||
ui.label("Loading");
|
||||
});
|
||||
}
|
||||
TextureState::Loaded(texture_handle) => {
|
||||
//need to show
|
||||
@@ -317,7 +323,10 @@ impl MyEguiApp {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
ui.label("Finding possible images");
|
||||
ui.horizontal(|ui| {
|
||||
ui.spinner();
|
||||
ui.label("Finding possible images");
|
||||
});
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
@@ -732,8 +741,8 @@ impl HasImageKey for GameType {
|
||||
impl HasImageKey for SteamGameInfo {
|
||||
fn key(&self, image_type: &ImageType, user_path: &Path) -> (PathBuf, String) {
|
||||
let mut keys = POSSIBLE_EXTENSIONS
|
||||
.iter()
|
||||
.map(|ext| key_from_extension(self.appid, image_type, user_path, ext));
|
||||
.iter()
|
||||
.map(|ext| key_from_extension(self.appid, image_type, user_path, ext));
|
||||
let first = keys.next().unwrap();
|
||||
let other = keys.filter(|(exsists, _, _)| *exsists).next();
|
||||
let (_, path, key) = other.unwrap_or(first);
|
||||
|
||||
@@ -84,7 +84,10 @@ impl MyEguiApp {
|
||||
},
|
||||
_=> {
|
||||
ui.ctx().request_repaint();
|
||||
ui.label("Finding installed games");
|
||||
ui.horizontal(|ui|{
|
||||
ui.spinner();
|
||||
ui.label("Finding installed games");
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -118,6 +121,10 @@ impl MyEguiApp {
|
||||
let usersinfo = sync::run_sync(&settings, &mut some_sender).unwrap();
|
||||
let task = download_images(&settings, &usersinfo, &mut some_sender);
|
||||
block_on(task);
|
||||
|
||||
//Run a second time to fix up shortcuts after images are downloaded
|
||||
sync::run_sync(&settings, &mut some_sender).unwrap();
|
||||
|
||||
if let Some(sender) = some_sender {
|
||||
let _ = sender.send(SyncProgress::Done);
|
||||
}
|
||||
|
||||
+27
-23
@@ -1,6 +1,6 @@
|
||||
use std::error::Error;
|
||||
|
||||
use eframe::{egui, epi};
|
||||
use eframe::{egui, App, Frame};
|
||||
use egui::{ImageButton, Rounding, Stroke, TextureHandle};
|
||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||
use tokio::{
|
||||
@@ -68,26 +68,8 @@ impl Default for Menues {
|
||||
}
|
||||
}
|
||||
|
||||
impl epi::App for MyEguiApp {
|
||||
fn name(&self) -> &str {
|
||||
"BoilR"
|
||||
}
|
||||
|
||||
fn setup(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
_frame: &epi::Frame,
|
||||
_storage: Option<&dyn epi::Storage>,
|
||||
) {
|
||||
#[cfg(target_family = "unix")]
|
||||
ctx.set_pixels_per_point(1.0);
|
||||
|
||||
let mut style: egui::Style = (*ctx.style()).clone();
|
||||
create_style(&mut style);
|
||||
ctx.set_style(style);
|
||||
}
|
||||
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
|
||||
impl App for MyEguiApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut Frame) {
|
||||
let frame = egui::Frame::default()
|
||||
.stroke(Stroke::new(0., BACKGROUND_COLOR))
|
||||
.fill(BACKGROUND_COLOR);
|
||||
@@ -138,7 +120,14 @@ impl epi::App for MyEguiApp {
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
if !status_string.is_empty() {
|
||||
ui.label(status_string);
|
||||
if syncing {
|
||||
ui.horizontal(|c| {
|
||||
c.spinner();
|
||||
c.label(&status_string);
|
||||
});
|
||||
} else {
|
||||
ui.label(&status_string);
|
||||
}
|
||||
}
|
||||
|
||||
let texture = self.get_import_image(ui);
|
||||
@@ -218,6 +207,14 @@ impl MyEguiApp {
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(ctx: &egui::Context) {
|
||||
#[cfg(target_family = "unix")]
|
||||
ctx.set_pixels_per_point(1.0);
|
||||
|
||||
let mut style: egui::Style = (*ctx.style()).clone();
|
||||
create_style(&mut style);
|
||||
ctx.set_style(style);
|
||||
}
|
||||
pub fn run_sync() {
|
||||
let mut app = MyEguiApp::new();
|
||||
app.run_sync();
|
||||
@@ -231,5 +228,12 @@ pub fn run_ui() -> Result<(), Box<dyn Error>> {
|
||||
icon_data: Some(get_logo_icon()),
|
||||
..Default::default()
|
||||
};
|
||||
eframe::run_native(Box::new(app), native_options);
|
||||
eframe::run_native(
|
||||
"BoilR",
|
||||
native_options,
|
||||
Box::new(|cc| {
|
||||
setup(&cc.egui_ctx);
|
||||
Box::new(app)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user