Remove Warnings (#232)

* Remove Windows Warnings
* Fix linux warnings
This commit is contained in:
Philip Kristoffersen
2022-09-11 17:21:21 +02:00
committed by GitHub
parent 941b647986
commit d906f5688a
9 changed files with 466 additions and 424 deletions
+1
View File
@@ -20,6 +20,7 @@ pub(crate) fn get_egs_manifests(
.filter_map(get_manifest_item); .filter_map(get_manifest_item);
let mut manifests = vec![]; let mut manifests = vec![];
for mut manifest in all_manifests { for mut manifest in all_manifests {
manifest.manifest_location = manifest.manifest_location;
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
{ {
if let Some(compat_folder) = locations.compat_folder_path.as_ref() { if let Some(compat_folder) = locations.compat_folder_path.as_ref() {
+4 -4
View File
@@ -22,9 +22,9 @@ impl HeroicGameType {
HeroicGameType::Epic(g) => g.app_name.as_ref(), HeroicGameType::Epic(g) => g.app_name.as_ref(),
HeroicGameType::Gog(g, _) => g.game_id.as_ref(), HeroicGameType::Gog(g, _) => g.game_id.as_ref(),
HeroicGameType::Heroic { HeroicGameType::Heroic {
title, title:_,
app_name, app_name,
install_mode, install_mode:_,
} => app_name, } => app_name,
} }
} }
@@ -35,8 +35,8 @@ impl HeroicGameType {
HeroicGameType::Gog(g, _) => g.name.as_ref(), HeroicGameType::Gog(g, _) => g.name.as_ref(),
HeroicGameType::Heroic { HeroicGameType::Heroic {
title, title,
app_name, app_name:_,
install_mode, install_mode:_,
} => title.as_ref(), } => title.as_ref(),
} }
} }
+2 -1
View File
@@ -3,6 +3,7 @@ mod config;
mod egs; mod egs;
mod flatpak; mod flatpak;
mod gog; mod gog;
#[cfg(target_family = "unix")]
mod heroic; mod heroic;
mod itch; mod itch;
mod legendary; mod legendary;
@@ -17,7 +18,7 @@ mod sync;
mod ui; mod ui;
mod uplay; mod uplay;
fn main(){ fn main() {
ensure_config_folder(); ensure_config_folder();
migration::migrate_config(); migration::migrate_config();
+7 -3
View File
@@ -1,10 +1,13 @@
use crate::{ use crate::{
amazon::AmazonSettings, config::get_config_file, egs::EpicGamesLauncherSettings, amazon::AmazonSettings, config::get_config_file, egs::EpicGamesLauncherSettings,
flatpak::FlatpakSettings, gog::GogSettings, heroic::HeroicSettings, itch::ItchSettings, flatpak::FlatpakSettings, gog::GogSettings, itch::ItchSettings, legendary::LegendarySettings,
legendary::LegendarySettings, lutris::settings::LutrisSettings, origin::OriginSettings, lutris::settings::LutrisSettings, origin::OriginSettings, steam::SteamSettings,
steam::SteamSettings, steamgriddb::SteamGridDbSettings, uplay::UplaySettings, steamgriddb::SteamGridDbSettings, uplay::UplaySettings,
}; };
#[cfg(target_family = "unix")]
use crate::heroic::HeroicSettings;
use config::{Config, ConfigError, Environment, File}; use config::{Config, ConfigError, Environment, File};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::env; use std::env;
@@ -23,6 +26,7 @@ pub struct Settings {
pub gog: GogSettings, pub gog: GogSettings,
pub uplay: UplaySettings, pub uplay: UplaySettings,
pub lutris: LutrisSettings, pub lutris: LutrisSettings,
#[cfg(target_family = "unix")]
pub heroic: HeroicSettings, pub heroic: HeroicSettings,
pub amazon: AmazonSettings, pub amazon: AmazonSettings,
pub flatpak: FlatpakSettings, pub flatpak: FlatpakSettings,
+3 -1
View File
@@ -3,7 +3,6 @@ use tokio::sync::watch::Sender;
use crate::{ use crate::{
egs::EpicPlatform, egs::EpicPlatform,
flatpak::FlatpakPlatform,
legendary::LegendaryPlatform, legendary::LegendaryPlatform,
lutris::lutris_platform::LutrisPlatform, lutris::lutris_platform::LutrisPlatform,
platform::Platform, platform::Platform,
@@ -19,6 +18,9 @@ use crate::{
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
use crate::heroic::HeroicPlatform; use crate::heroic::HeroicPlatform;
#[cfg(target_family = "unix")]
use crate::flatpak::FlatpakPlatform;
use std::error::Error; use std::error::Error;
use crate::{gog::GogPlatform, itch::ItchPlatform, origin::OriginPlatform}; use crate::{gog::GogPlatform, itch::ItchPlatform, origin::OriginPlatform};
+54 -31
View File
@@ -1,6 +1,6 @@
use std::{ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc, thread::Thread, sync::Arc,
}; };
use crate::{ use crate::{
@@ -9,7 +9,6 @@ use crate::{
steam::{get_shortcuts_paths, SteamUsersInfo}, steam::{get_shortcuts_paths, SteamUsersInfo},
steamgriddb::{get_image_extension, get_query_type, CachedSearch, ImageType, ToDownload}, steamgriddb::{get_image_extension, get_query_type, CachedSearch, ImageType, ToDownload},
}; };
use config::File;
use dashmap::DashMap; use dashmap::DashMap;
use egui::{ImageButton, ScrollArea}; use egui::{ImageButton, ScrollArea};
use futures::executor::block_on; use futures::executor::block_on;
@@ -41,6 +40,7 @@ pub enum TextureState {
Downloading, Downloading,
Downloaded, Downloaded,
Loaded(egui::TextureHandle), Loaded(egui::TextureHandle),
Failed,
} }
#[derive(Debug)] #[derive(Debug)]
@@ -149,7 +149,7 @@ impl MyEguiApp {
ui.heading(shortcut.name()); ui.heading(shortcut.name());
if let Some(possible_names) = state.possible_names.as_ref() { if let Some(possible_names) = state.possible_names.as_ref() {
if let Some(value) = render_possible_names(possible_names, ui,state) { if let Some(value) = render_possible_names(possible_names, ui, state) {
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() {
@@ -265,19 +265,22 @@ impl MyEguiApp {
TextureState::Downloaded => { TextureState::Downloaded => {
//Need to load //Need to load
let image_data = load_image_from_path(&image.thumbnail_path); let image_data = load_image_from_path(&image.thumbnail_path);
if let Ok(image_data) = image_data { match image_data {
let handle = ui.ctx().load_texture( Ok(image_data) => {
&image_key, let handle = ui.ctx().load_texture(
image_data, &image_key,
egui::TextureFilter::Linear, image_data,
); egui::TextureFilter::Linear,
*state.value_mut() = TextureState::Loaded(handle); );
*state.value_mut() = TextureState::Loaded(handle);
ui.horizontal(|ui| {
ui.spinner();
ui.label("Loading");
});
}
Err(_) => *state.value_mut() = TextureState::Failed,
} }
ui.ctx().request_repaint(); ui.ctx().request_repaint();
ui.horizontal(|ui| {
ui.spinner();
ui.label("Loading");
});
} }
TextureState::Loaded(texture_handle) => { TextureState::Loaded(texture_handle) => {
//need to show //need to show
@@ -288,6 +291,9 @@ impl MyEguiApp {
return Some(UserAction::ImageSelected(image.clone())); return Some(UserAction::ImageSelected(image.clone()));
} }
} }
TextureState::Failed => {
ui.label("Failed to load image");
}
} }
} }
None => { None => {
@@ -401,12 +407,12 @@ impl MyEguiApp {
.set_image_banned(&image_type, app_id, should_ban); .set_image_banned(&image_type, app_id, should_ban);
self.handle_image_type_clear(image_type); self.handle_image_type_clear(image_type);
} }
UserAction::ClearImages =>{ UserAction::ClearImages => {
for image_type in ImageType::all(){ for image_type in ImageType::all() {
self.handle_image_type_clear(*image_type); self.handle_image_type_clear(*image_type);
} }
self.handle_back_button_action(); self.handle_back_button_action();
}, }
}; };
} }
@@ -523,7 +529,8 @@ impl MyEguiApp {
let mut result = vec![]; let mut result = vec![];
for possible_image in &possible_images { for possible_image in &possible_images {
let ext = get_image_extension(&possible_image.mime); let ext = get_image_extension(&possible_image.mime);
let path = thumbnails_folder.join(format!("{}.{}",possible_image.id,ext)); let path =
thumbnails_folder.join(format!("{}.{}", possible_image.id, ext));
result.push(PossibleImage { result.push(PossibleImage {
thumbnail_path: path, thumbnail_path: path,
mime: possible_image.mime.clone(), mime: possible_image.mime.clone(),
@@ -563,20 +570,25 @@ impl MyEguiApp {
let data_folder = Path::new(&user.steam_user_data_folder); let data_folder = Path::new(&user.steam_user_data_folder);
//Keep deleting images of this type untill we don't find any more //Keep deleting images of this type untill we don't find any more
let mut path = self.get_shortcut_image_path(data_folder); let mut path = self.get_shortcut_image_path(data_folder);
while Path::new(&path).exists(){ while Path::new(&path).exists() {
let _= std::fs::remove_file(&path); let _ = std::fs::remove_file(&path);
path = self.get_shortcut_image_path(data_folder); path = self.get_shortcut_image_path(data_folder);
} }
//Put the loaded thumbnail into the image handler map, we can use that for preview //Put the loaded thumbnail into the image handler map, we can use that for preview
let full_image_key = to_download_to_path.to_string_lossy().to_string(); let full_image_key = to_download_to_path.to_string_lossy().to_string();
let _ = self.image_selected_state.image_handles.remove(&full_image_key); let _ = self
.image_selected_state
.image_handles
.remove(&full_image_key);
let thumbnail_key = image.thumbnail_path.to_string_lossy().to_string(); let thumbnail_key = image.thumbnail_path.to_string_lossy().to_string();
let thumbnail = self.image_selected_state.image_handles.remove(&thumbnail_key); let thumbnail = self
if let Some((key,thumbnail)) = thumbnail { .image_selected_state
.image_handles
.remove(&thumbnail_key);
if let Some((_key, thumbnail)) = thumbnail {
self.image_selected_state self.image_selected_state
.image_handles .image_handles
.insert(full_image_key, thumbnail); .insert(full_image_key, thumbnail);
@@ -601,7 +613,15 @@ impl MyEguiApp {
} }
fn get_shortcut_image_path(&self, data_folder: &Path) -> String { fn get_shortcut_image_path(&self, data_folder: &Path) -> String {
self.image_selected_state.selected_shortcut.as_ref().unwrap().key(&self.image_selected_state.image_type_selected.unwrap(), data_folder).1 self.image_selected_state
.selected_shortcut
.as_ref()
.unwrap()
.key(
&self.image_selected_state.image_type_selected.unwrap(),
data_folder,
)
.1
} }
fn clear_loaded_images(&mut self) { fn clear_loaded_images(&mut self) {
@@ -662,12 +682,12 @@ impl MyEguiApp {
fn render_possible_names( fn render_possible_names(
possible_names: &Vec<steamgriddb_api::search::SearchResult>, possible_names: &Vec<steamgriddb_api::search::SearchResult>,
ui: &mut egui::Ui, ui: &mut egui::Ui,
state: &ImageSelectState state: &ImageSelectState,
) -> Option<UserAction> { ) -> Option<UserAction> {
let mut grid_id_text = state.grid_id.map(|id| id.to_string()).unwrap_or_default(); let mut grid_id_text = state.grid_id.map(|id| id.to_string()).unwrap_or_default();
ui.label("SteamGridDB ID").on_hover_text("You can change this id to one you have found at the steamgriddb webpage"); ui.label("SteamGridDB ID")
if ui.text_edit_singleline(&mut grid_id_text) .on_hover_text("You can change this id to one you have found at the steamgriddb webpage");
.changed() { if ui.text_edit_singleline(&mut grid_id_text).changed() {
if let Ok(grid_id) = grid_id_text.parse::<usize>() { if let Ok(grid_id) = grid_id_text.parse::<usize>() {
return Some(UserAction::GridIdChanged(grid_id)); return Some(UserAction::GridIdChanged(grid_id));
} }
@@ -680,7 +700,11 @@ fn render_possible_names(
} }
ui.separator(); ui.separator();
if ui.button("Clear all images").on_hover_text("Clicking this deletes all images for this shortcut").clicked(){ if ui
.button("Clear all images")
.on_hover_text("Clicking this deletes all images for this shortcut")
.clicked()
{
return Some(UserAction::ClearImages); return Some(UserAction::ClearImages);
} }
None None
@@ -700,7 +724,6 @@ fn render_steam_game_select(ui: &mut egui::Ui, state: &ImageSelectState) -> Opti
} }
fn render_shortcut_images(ui: &mut egui::Ui, state: &ImageSelectState) -> Option<UserAction> { fn render_shortcut_images(ui: &mut egui::Ui, state: &ImageSelectState) -> Option<UserAction> {
if ui if ui
.button("Click here if the images are for a wrong game") .button("Click here if the images are for a wrong game")
.clicked() .clicked()
+12 -7
View File
@@ -2,7 +2,9 @@ use copypasta::ClipboardProvider;
use eframe::egui; use eframe::egui;
use egui::ScrollArea; use egui::ScrollArea;
use crate::{egs::EpicPlatform, heroic::HeroicPlatform}; use crate::{egs::EpicPlatform};
#[cfg(target_family = "unix")]
use crate::heroic::HeroicPlatform;
use super::{ use super::{
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR}, ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
@@ -62,6 +64,7 @@ impl MyEguiApp {
}); });
} }
#[cfg(target_family = "unix")]
fn render_flatpak_settings(&mut self, ui: &mut egui::Ui) { fn render_flatpak_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Flatpak"); ui.heading("Flatpak");
ui.checkbox(&mut self.settings.flatpak.enabled, "Import from Flatpak"); ui.checkbox(&mut self.settings.flatpak.enabled, "Import from Flatpak");
@@ -69,7 +72,7 @@ impl MyEguiApp {
ui.add_space(SECTION_SPACING); ui.add_space(SECTION_SPACING);
} }
#[cfg(target_family = "unix")]
fn render_heroic_settings(&mut self, ui: &mut egui::Ui) { fn render_heroic_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Heroic"); ui.heading("Heroic");
ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic"); ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic");
@@ -95,6 +98,7 @@ self.settings.heroic.default_launch_through_heroic{
ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher."); ui.label("Some games must be started from the Heroic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Heroic Launcher.");
} }
#[cfg(target_family = "unix")]{
let manifests =self.heroic_games.get_or_insert_with(||{ let manifests =self.heroic_games.get_or_insert_with(||{
let heroic_setting = self.settings.heroic.clone(); let heroic_setting = self.settings.heroic.clone();
@@ -110,11 +114,12 @@ self.settings.heroic.default_launch_through_heroic{
let display_name = manifest.title(); let display_name = manifest.title();
let mut safe_open = safe_open_games.contains(&display_name.to_string()) || safe_open_games.contains(&key.to_string()); let mut safe_open = safe_open_games.contains(&display_name.to_string()) || safe_open_games.contains(&key.to_string());
if ui.checkbox(&mut safe_open, display_name).clicked(){ if ui.checkbox(&mut safe_open, display_name).clicked(){
if safe_open{ if safe_open{
safe_open_games.push(key.to_string()); safe_open_games.push(key.to_string());
}else{ }else{
safe_open_games.retain(|m| m!= display_name && m!= key); safe_open_games.retain(|m| m!= display_name && m!= key);
} }
}
} }
} }
}) ; }) ;
+16 -12
View File
@@ -1,19 +1,15 @@
use std::{env::Args, error::Error}; #[cfg(target_family = "unix")]
use crate::heroic::HeroicGameType;
use eframe::{egui, App, Frame}; use eframe::{egui, App, Frame};
use egui::{Button, ImageButton, Rounding, Stroke, TextureHandle}; use egui::{ImageButton, Rounding, Stroke, TextureHandle};
use steam_shortcuts_util::shortcut::ShortcutOwned; use steam_shortcuts_util::shortcut::ShortcutOwned;
use tokio::{ use tokio::{
runtime::Runtime, runtime::Runtime,
sync::watch::{self, Receiver}, sync::watch::{self, Receiver},
}; };
use crate::{ use crate::{egs::ManifestItem, settings::Settings, sync::SyncProgress};
egs::ManifestItem,
heroic::{HeroicGame, HeroicGameType},
settings::Settings,
sync::SyncProgress,
};
use super::{ use super::{
ui_colors::{ ui_colors::{
@@ -42,6 +38,7 @@ pub struct MyEguiApp {
pub(crate) games_to_sync: Receiver<FetcStatus<Vec<(String, Vec<ShortcutOwned>)>>>, pub(crate) games_to_sync: Receiver<FetcStatus<Vec<(String, Vec<ShortcutOwned>)>>>,
pub(crate) status_reciever: Receiver<SyncProgress>, pub(crate) status_reciever: Receiver<SyncProgress>,
pub(crate) epic_manifests: Option<Vec<ManifestItem>>, pub(crate) epic_manifests: Option<Vec<ManifestItem>>,
#[cfg(target_family = "unix")]
pub(crate) heroic_games: Option<Vec<HeroicGameType>>, pub(crate) heroic_games: Option<Vec<HeroicGameType>>,
pub(crate) image_selected_state: ImageSelectState, pub(crate) image_selected_state: ImageSelectState,
pub(crate) backup_state: BackupState, pub(crate) backup_state: BackupState,
@@ -59,6 +56,7 @@ impl MyEguiApp {
ui_images: UiImages::default(), ui_images: UiImages::default(),
status_reciever: watch::channel(SyncProgress::NotStarted).1, status_reciever: watch::channel(SyncProgress::NotStarted).1,
epic_manifests: None, epic_manifests: None,
#[cfg(target_family = "unix")]
heroic_games: None, heroic_games: None,
image_selected_state: ImageSelectState::default(), image_selected_state: ImageSelectState::default(),
backup_state: BackupState::default(), backup_state: BackupState::default(),
@@ -243,21 +241,27 @@ impl MyEguiApp {
fn get_import_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle { fn get_import_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle {
self.ui_images.import_button.get_or_insert_with(|| { self.ui_images.import_button.get_or_insert_with(|| {
// Load the texture only once. // Load the texture only once.
ui.ctx().load_texture("import_image", get_import_image(),egui::TextureFilter::Linear) ui.ctx().load_texture(
"import_image",
get_import_image(),
egui::TextureFilter::Linear,
)
}) })
} }
fn get_save_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle { fn get_save_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle {
self.ui_images.save_button.get_or_insert_with(|| { self.ui_images.save_button.get_or_insert_with(|| {
// Load the texture only once. // Load the texture only once.
ui.ctx().load_texture("save_image", get_save_image(),egui::TextureFilter::Linear) ui.ctx()
.load_texture("save_image", get_save_image(), egui::TextureFilter::Linear)
}) })
} }
fn get_logo_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle { fn get_logo_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle {
self.ui_images.logo_32.get_or_insert_with(|| { self.ui_images.logo_32.get_or_insert_with(|| {
// Load the texture only once. // Load the texture only once.
ui.ctx().load_texture("logo32", get_logo(),egui::TextureFilter::Linear) ui.ctx()
.load_texture("logo32", get_logo(), egui::TextureFilter::Linear)
}) })
} }
} }
@@ -275,7 +279,7 @@ pub fn run_sync() {
app.run_sync(true); app.run_sync(true);
} }
pub fn run_ui(args: Vec<String>){ pub fn run_ui(args: Vec<String>) {
let app = MyEguiApp::new(); let app = MyEguiApp::new();
let no_v_sync = args.contains(&"--no-vsync".to_string()); let no_v_sync = args.contains(&"--no-vsync".to_string());
let native_options = eframe::NativeOptions { let native_options = eframe::NativeOptions {
+2
View File
@@ -1,6 +1,8 @@
use crate::platform::Platform; use crate::platform::Platform;
use std::error::Error; use std::error::Error;
#[cfg(target_os = "windows")]
use std::path::Path; use std::path::Path;
#[cfg(target_os = "windows")]
use std::path::PathBuf; use std::path::PathBuf;
use super::{game::Game, settings::UplaySettings}; use super::{game::Game, settings::UplaySettings};