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
+56 -33
View File
@@ -1,6 +1,6 @@
use std::{
path::{Path, PathBuf},
sync::Arc, thread::Thread,
sync::Arc,
};
use crate::{
@@ -9,7 +9,6 @@ use crate::{
steam::{get_shortcuts_paths, SteamUsersInfo},
steamgriddb::{get_image_extension, get_query_type, CachedSearch, ImageType, ToDownload},
};
use config::File;
use dashmap::DashMap;
use egui::{ImageButton, ScrollArea};
use futures::executor::block_on;
@@ -41,6 +40,7 @@ pub enum TextureState {
Downloading,
Downloaded,
Loaded(egui::TextureHandle),
Failed,
}
#[derive(Debug)]
@@ -149,7 +149,7 @@ impl MyEguiApp {
ui.heading(shortcut.name());
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;
}
} else if let Some(image_type) = state.image_type_selected.as_ref() {
@@ -265,19 +265,22 @@ impl MyEguiApp {
TextureState::Downloaded => {
//Need to load
let image_data = load_image_from_path(&image.thumbnail_path);
if let Ok(image_data) = image_data {
let handle = ui.ctx().load_texture(
&image_key,
image_data,
egui::TextureFilter::Linear,
);
*state.value_mut() = TextureState::Loaded(handle);
match image_data {
Ok(image_data) => {
let handle = ui.ctx().load_texture(
&image_key,
image_data,
egui::TextureFilter::Linear,
);
*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.horizontal(|ui| {
ui.spinner();
ui.label("Loading");
});
}
TextureState::Loaded(texture_handle) => {
//need to show
@@ -288,6 +291,9 @@ impl MyEguiApp {
return Some(UserAction::ImageSelected(image.clone()));
}
}
TextureState::Failed => {
ui.label("Failed to load image");
}
}
}
None => {
@@ -401,12 +407,12 @@ impl MyEguiApp {
.set_image_banned(&image_type, app_id, should_ban);
self.handle_image_type_clear(image_type);
}
UserAction::ClearImages =>{
for image_type in ImageType::all(){
UserAction::ClearImages => {
for image_type in ImageType::all() {
self.handle_image_type_clear(*image_type);
}
self.handle_back_button_action();
},
}
};
}
@@ -523,14 +529,15 @@ impl MyEguiApp {
let mut result = vec![];
for possible_image in &possible_images {
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 {
thumbnail_path: path,
mime: possible_image.mime.clone(),
thumbnail_url: possible_image.thumb.clone(),
full_url: possible_image.url.clone(),
id: possible_image.id,
});
});
}
let _ = tx.send(FetcStatus::Fetched(result));
}
@@ -563,20 +570,25 @@ impl MyEguiApp {
let data_folder = Path::new(&user.steam_user_data_folder);
//Keep deleting images of this type untill we don't find any more
let mut path = self.get_shortcut_image_path(data_folder);
while Path::new(&path).exists(){
let _= std::fs::remove_file(&path);
while Path::new(&path).exists() {
let _ = std::fs::remove_file(&path);
path = self.get_shortcut_image_path(data_folder);
}
//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 _ = 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 = self.image_selected_state.image_handles.remove(&thumbnail_key);
if let Some((key,thumbnail)) = thumbnail {
let thumbnail = self
.image_selected_state
.image_handles
.remove(&thumbnail_key);
if let Some((_key, thumbnail)) = thumbnail {
self.image_selected_state
.image_handles
.insert(full_image_key, thumbnail);
@@ -601,7 +613,15 @@ impl MyEguiApp {
}
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) {
@@ -662,17 +682,17 @@ impl MyEguiApp {
fn render_possible_names(
possible_names: &Vec<steamgriddb_api::search::SearchResult>,
ui: &mut egui::Ui,
state: &ImageSelectState
state: &ImageSelectState,
) -> Option<UserAction> {
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");
if ui.text_edit_singleline(&mut grid_id_text)
.changed() {
ui.label("SteamGridDB ID")
.on_hover_text("You can change this id to one you have found at the steamgriddb webpage");
if ui.text_edit_singleline(&mut grid_id_text).changed() {
if let Ok(grid_id) = grid_id_text.parse::<usize>() {
return Some(UserAction::GridIdChanged(grid_id));
}
};
for possible in possible_names {
if ui.button(&possible.name).clicked() {
return Some(UserAction::GridIdChanged(possible.id));
@@ -680,7 +700,11 @@ fn render_possible_names(
}
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);
}
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> {
if ui
.button("Click here if the images are for a wrong game")
.clicked()
+374 -369
View File
@@ -1,369 +1,374 @@
use copypasta::ClipboardProvider;
use eframe::egui;
use egui::ScrollArea;
use crate::{egs::EpicPlatform, heroic::HeroicPlatform};
use super::{
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
MyEguiApp,
};
pub const SECTION_SPACING: f32 = 25.0;
const VERSION: &str = env!("CARGO_PKG_VERSION");
impl MyEguiApp {
pub(crate) fn render_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Settings");
let mut scroll_style = ui.style_mut();
scroll_style.visuals.extreme_bg_color = BACKGROUND_COLOR;
scroll_style.visuals.widgets.inactive.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.widgets.active.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.selection.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.widgets.hovered.bg_fill = EXTRA_BACKGROUND_COLOR;
ScrollArea::vertical()
.stick_to_right(true)
.auto_shrink([false, true])
.show(ui, |ui| {
ui.reset_style();
self.render_steamgriddb_settings(ui);
self.render_steam_settings(ui);
self.render_epic_settings(ui);
#[cfg(target_family = "unix")]
{
self.render_heroic_settings(ui);
}
self.render_legendary_settings(ui);
self.render_itch_settings(ui);
self.render_origin_settings(ui);
self.render_gog_settings(ui);
self.render_uplay_settings(ui);
self.render_lutris_settings(ui);
#[cfg(windows)]
{
self.render_amazon_settings(ui);
}
#[cfg(target_family = "unix")]
{
self.render_flatpak_settings(ui);
}
ui.add_space(SECTION_SPACING);
ui.label(format!("Version: {}", VERSION));
});
}
fn render_flatpak_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Flatpak");
ui.checkbox(&mut self.settings.flatpak.enabled, "Import from Flatpak");
ui.add_space(SECTION_SPACING);
}
fn render_heroic_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Heroic");
ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic");
ui.checkbox(&mut self.settings.heroic.default_launch_through_heroic, "Always launch games through Heroic");
let safe_mode_header = match (self.settings.heroic.default_launch_through_heroic,self.settings.heroic.launch_games_through_heroic.len()) {
(false,0) => "Force games to launch through Heroic Launcher".to_string(),
(false,1) => "One game forced to launch through Heroic Launcher".to_string(),
(false,x) => format!("{} games forced to launch through Heroic Launcher", x),
(true,0) => "Force games to launch directly".to_string(),
(true,1) => "One game forced to launch directly".to_string(),
(true,x) => format!("{} games forced to launch directly", x),
};
egui::CollapsingHeader::new(safe_mode_header)
.id_source("Heroic_Launcher_safe_launch")
.show(ui, |ui| {
if
self.settings.heroic.default_launch_through_heroic{
ui.label("Some games work best when launched directly, select those games below and BoilR will create shortcuts that launch the games directly.");
} else{
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.");
}
let manifests =self.heroic_games.get_or_insert_with(||{
let heroic_setting = self.settings.heroic.clone();
let heroic_platform =HeroicPlatform{
settings:heroic_setting
};
heroic_platform.get_heroic_games()
});
let safe_open_games = &mut self.settings.heroic.launch_games_through_heroic;
for manifest in manifests{
let key = manifest.app_name();
let display_name = manifest.title();
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 safe_open{
safe_open_games.push(key.to_string());
}else{
safe_open_games.retain(|m| m!= display_name && m!= key);
}
}
}
}) ;
ui.add_space(SECTION_SPACING);
}
fn render_lutris_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Lutris");
ui.checkbox(&mut self.settings.lutris.enabled, "Import from Lutris");
if self.settings.lutris.enabled {
ui.checkbox(&mut self.settings.lutris.flatpak, "Flatpak version");
if !self.settings.lutris.flatpak {
ui.horizontal(|ui| {
let lutris_location = &mut self.settings.lutris.executable;
ui.label("Lutris Location: ");
ui.text_edit_singleline(lutris_location);
});
} else {
ui.horizontal(|ui| {
let flatpak_image = &mut self.settings.lutris.flatpak_image;
ui.label("Flatpak image");
ui.text_edit_singleline(flatpak_image);
});
}
}
ui.add_space(SECTION_SPACING);
}
#[cfg(windows)]
fn render_amazon_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Amazon");
ui.checkbox(&mut self.settings.amazon.enabled, "Import from Amazon");
ui.add_space(SECTION_SPACING);
}
fn render_uplay_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Uplay");
ui.checkbox(&mut self.settings.uplay.enabled, "Import from Uplay");
ui.add_space(SECTION_SPACING);
}
fn render_gog_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("GoG Galaxy");
ui.checkbox(&mut self.settings.gog.enabled, "Import from GoG Galaxy");
if self.settings.gog.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let itch_location = self
.settings
.gog
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("GoG Galaxy Folder: ");
if ui.text_edit_singleline(itch_location).changed() {
self.settings.gog.location = Some(itch_location.to_string());
}
});
}
ui.add_space(SECTION_SPACING);
}
fn render_origin_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Origin");
ui.checkbox(&mut self.settings.origin.enabled, "Import from Origin");
ui.add_space(SECTION_SPACING);
}
fn render_itch_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Itch.io");
ui.checkbox(&mut self.settings.itch.enabled, "Import from Itch.io");
if self.settings.itch.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let itch_location = self
.settings
.itch
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Itch.io Folder: ");
if ui.text_edit_singleline(itch_location).changed() {
self.settings.itch.location = if itch_location.is_empty(){
None
}else {
Some(itch_location.to_string())
};
}else{
if !itch_location.is_empty(){
if ui.button("Reset").on_hover_text("Reset the itch path, let BoilR guess again").clicked(){
self.settings.itch.location = None;
}
}
}
});
#[cfg(target_family = "unix")]
{
ui.checkbox(&mut self.settings.itch.create_symlinks, "Create symlinks");
}
}
ui.add_space(SECTION_SPACING);
}
fn render_steam_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Steam");
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let steam_location = self
.settings
.steam
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Steam Location: ");
if ui.text_edit_singleline(steam_location).changed() {
if steam_location.trim().is_empty(){
self.settings.steam.location = None;
}else{
self.settings.steam.location = Some(steam_location.to_string());
}
}
});
ui.checkbox(
&mut self.settings.steam.create_collections,
"Create collections",
)
.on_hover_text("Tries to create a games collection for each platform");
ui.checkbox(&mut self.settings.steam.optimize_for_big_picture, "Optimize for big picture").on_hover_text("Set icons to be larger horizontal images, this looks nice in steam big picture mode, but a bit off in desktop mode");
ui.checkbox(
&mut self.settings.steam.stop_steam,
"Stop Steam before import",
)
.on_hover_text("Stops Steam if it is running when import starts");
ui.checkbox(
&mut self.settings.steam.start_steam,
"Start Steam after import",
)
.on_hover_text("Starts Steam is it is not running after the import");
ui.add_space(SECTION_SPACING);
}
fn render_steamgriddb_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("SteamGridDB");
ui.checkbox(&mut self.settings.steamgrid_db.enabled, "Download images");
if self.settings.steamgrid_db.enabled {
ui.horizontal(|ui| {
let mut auth_key = self
.settings
.steamgrid_db
.auth_key
.clone()
.unwrap_or_default();
ui.label("Authentication key: ");
if ui.text_edit_singleline(&mut auth_key).changed() {
if auth_key.is_empty() {
self.settings.steamgrid_db.auth_key = None;
} else {
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
}
}
if auth_key.is_empty() && ui.button("Paste from clipboard").clicked(){
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
if let Ok(content) = clipboard_ctx.get_contents() {
self.settings.steamgrid_db.auth_key = Some(content);
}
}
}
});
ui.horizontal(|ui| {
ui.label(
"To download images you need an API Key from SteamGridDB, you can find yours",
);
ui.hyperlink_to(
"here",
"https://www.steamgriddb.com/profile/preferences/api",
)
});
ui.checkbox(&mut self.settings.steamgrid_db.prefer_animated, "Prefer animated images").on_hover_text("Prefer downloading animated images over static images (this can slow Steam down but looks neat)");
ui.checkbox(
&mut self.settings.steamgrid_db.only_download_boilr_images,
"Only download images for BoilR shortcuts",
);
}
ui.add_space(SECTION_SPACING);
}
fn render_legendary_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Legendary & Rare");
ui.checkbox(
&mut self.settings.legendary.enabled,
"Import from Legendary & Rare",
);
if self.settings.legendary.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let legendary_location = self
.settings
.legendary
.executable
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Legendary Executable: ")
.on_hover_text("The location of the legendary executable to use");
if ui.text_edit_singleline(legendary_location).changed() {
self.settings.legendary.executable = Some(legendary_location.to_string());
}
});
}
ui.add_space(SECTION_SPACING);
}
fn render_epic_settings(&mut self, ui: &mut egui::Ui) {
let epic_settings = &mut self.settings.epic_games;
ui.heading("Epic Games");
ui.checkbox(&mut epic_settings.enabled, "Import from Epic Games");
if epic_settings.enabled {
let safe_mode_header = match epic_settings.safe_launch.len() {
0 => "Force games to launch through Epic Launcher".to_string(),
1 => "One game forced to launch through Epic Launcher".to_string(),
x => format!("{} games forced to launch through Epic Launcher", x),
};
egui::CollapsingHeader::new(safe_mode_header)
.id_source("Epic_Launcher_safe_launch")
.show(ui, |ui| {
ui.label("Some games must be started from the Epic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Epic Launcher.");
let manifests =self.epic_manifests.get_or_insert_with(||{
let epic_platform = EpicPlatform::new(epic_settings);
let manifests = crate::platform::Platform::get_shortcuts(&epic_platform);
manifests.unwrap_or_default()
});
let mut safe_open_games = epic_settings.safe_launch.clone();
for manifest in manifests{
let key = manifest.get_key();
let display_name = &manifest.display_name;
let mut safe_open = safe_open_games.contains(display_name) || safe_open_games.contains(&key);
if ui.checkbox(&mut safe_open, display_name).clicked(){
if safe_open{
safe_open_games.push(key);
}else{
safe_open_games.retain(|m| m!= display_name && m!= &key);
}
}
}
epic_settings.safe_launch = safe_open_games;
}) ;
ui.add_space(SECTION_SPACING);
}
}
}
use copypasta::ClipboardProvider;
use eframe::egui;
use egui::ScrollArea;
use crate::{egs::EpicPlatform};
#[cfg(target_family = "unix")]
use crate::heroic::HeroicPlatform;
use super::{
ui_colors::{BACKGROUND_COLOR, EXTRA_BACKGROUND_COLOR},
MyEguiApp,
};
pub const SECTION_SPACING: f32 = 25.0;
const VERSION: &str = env!("CARGO_PKG_VERSION");
impl MyEguiApp {
pub(crate) fn render_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Settings");
let mut scroll_style = ui.style_mut();
scroll_style.visuals.extreme_bg_color = BACKGROUND_COLOR;
scroll_style.visuals.widgets.inactive.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.widgets.active.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.selection.bg_fill = EXTRA_BACKGROUND_COLOR;
scroll_style.visuals.widgets.hovered.bg_fill = EXTRA_BACKGROUND_COLOR;
ScrollArea::vertical()
.stick_to_right(true)
.auto_shrink([false, true])
.show(ui, |ui| {
ui.reset_style();
self.render_steamgriddb_settings(ui);
self.render_steam_settings(ui);
self.render_epic_settings(ui);
#[cfg(target_family = "unix")]
{
self.render_heroic_settings(ui);
}
self.render_legendary_settings(ui);
self.render_itch_settings(ui);
self.render_origin_settings(ui);
self.render_gog_settings(ui);
self.render_uplay_settings(ui);
self.render_lutris_settings(ui);
#[cfg(windows)]
{
self.render_amazon_settings(ui);
}
#[cfg(target_family = "unix")]
{
self.render_flatpak_settings(ui);
}
ui.add_space(SECTION_SPACING);
ui.label(format!("Version: {}", VERSION));
});
}
#[cfg(target_family = "unix")]
fn render_flatpak_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Flatpak");
ui.checkbox(&mut self.settings.flatpak.enabled, "Import from Flatpak");
ui.add_space(SECTION_SPACING);
}
#[cfg(target_family = "unix")]
fn render_heroic_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Heroic");
ui.checkbox(&mut self.settings.heroic.enabled, "Import from Heroic");
ui.checkbox(&mut self.settings.heroic.default_launch_through_heroic, "Always launch games through Heroic");
let safe_mode_header = match (self.settings.heroic.default_launch_through_heroic,self.settings.heroic.launch_games_through_heroic.len()) {
(false,0) => "Force games to launch through Heroic Launcher".to_string(),
(false,1) => "One game forced to launch through Heroic Launcher".to_string(),
(false,x) => format!("{} games forced to launch through Heroic Launcher", x),
(true,0) => "Force games to launch directly".to_string(),
(true,1) => "One game forced to launch directly".to_string(),
(true,x) => format!("{} games forced to launch directly", x),
};
egui::CollapsingHeader::new(safe_mode_header)
.id_source("Heroic_Launcher_safe_launch")
.show(ui, |ui| {
if
self.settings.heroic.default_launch_through_heroic{
ui.label("Some games work best when launched directly, select those games below and BoilR will create shortcuts that launch the games directly.");
} else{
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 heroic_setting = self.settings.heroic.clone();
let heroic_platform =HeroicPlatform{
settings:heroic_setting
};
heroic_platform.get_heroic_games()
});
let safe_open_games = &mut self.settings.heroic.launch_games_through_heroic;
for manifest in manifests{
let key = manifest.app_name();
let display_name = manifest.title();
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 safe_open{
safe_open_games.push(key.to_string());
}else{
safe_open_games.retain(|m| m!= display_name && m!= key);
}
}
}
}
}) ;
ui.add_space(SECTION_SPACING);
}
fn render_lutris_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Lutris");
ui.checkbox(&mut self.settings.lutris.enabled, "Import from Lutris");
if self.settings.lutris.enabled {
ui.checkbox(&mut self.settings.lutris.flatpak, "Flatpak version");
if !self.settings.lutris.flatpak {
ui.horizontal(|ui| {
let lutris_location = &mut self.settings.lutris.executable;
ui.label("Lutris Location: ");
ui.text_edit_singleline(lutris_location);
});
} else {
ui.horizontal(|ui| {
let flatpak_image = &mut self.settings.lutris.flatpak_image;
ui.label("Flatpak image");
ui.text_edit_singleline(flatpak_image);
});
}
}
ui.add_space(SECTION_SPACING);
}
#[cfg(windows)]
fn render_amazon_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Amazon");
ui.checkbox(&mut self.settings.amazon.enabled, "Import from Amazon");
ui.add_space(SECTION_SPACING);
}
fn render_uplay_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Uplay");
ui.checkbox(&mut self.settings.uplay.enabled, "Import from Uplay");
ui.add_space(SECTION_SPACING);
}
fn render_gog_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("GoG Galaxy");
ui.checkbox(&mut self.settings.gog.enabled, "Import from GoG Galaxy");
if self.settings.gog.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let itch_location = self
.settings
.gog
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("GoG Galaxy Folder: ");
if ui.text_edit_singleline(itch_location).changed() {
self.settings.gog.location = Some(itch_location.to_string());
}
});
}
ui.add_space(SECTION_SPACING);
}
fn render_origin_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Origin");
ui.checkbox(&mut self.settings.origin.enabled, "Import from Origin");
ui.add_space(SECTION_SPACING);
}
fn render_itch_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Itch.io");
ui.checkbox(&mut self.settings.itch.enabled, "Import from Itch.io");
if self.settings.itch.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let itch_location = self
.settings
.itch
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Itch.io Folder: ");
if ui.text_edit_singleline(itch_location).changed() {
self.settings.itch.location = if itch_location.is_empty(){
None
}else {
Some(itch_location.to_string())
};
}else{
if !itch_location.is_empty(){
if ui.button("Reset").on_hover_text("Reset the itch path, let BoilR guess again").clicked(){
self.settings.itch.location = None;
}
}
}
});
#[cfg(target_family = "unix")]
{
ui.checkbox(&mut self.settings.itch.create_symlinks, "Create symlinks");
}
}
ui.add_space(SECTION_SPACING);
}
fn render_steam_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Steam");
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let steam_location = self
.settings
.steam
.location
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Steam Location: ");
if ui.text_edit_singleline(steam_location).changed() {
if steam_location.trim().is_empty(){
self.settings.steam.location = None;
}else{
self.settings.steam.location = Some(steam_location.to_string());
}
}
});
ui.checkbox(
&mut self.settings.steam.create_collections,
"Create collections",
)
.on_hover_text("Tries to create a games collection for each platform");
ui.checkbox(&mut self.settings.steam.optimize_for_big_picture, "Optimize for big picture").on_hover_text("Set icons to be larger horizontal images, this looks nice in steam big picture mode, but a bit off in desktop mode");
ui.checkbox(
&mut self.settings.steam.stop_steam,
"Stop Steam before import",
)
.on_hover_text("Stops Steam if it is running when import starts");
ui.checkbox(
&mut self.settings.steam.start_steam,
"Start Steam after import",
)
.on_hover_text("Starts Steam is it is not running after the import");
ui.add_space(SECTION_SPACING);
}
fn render_steamgriddb_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("SteamGridDB");
ui.checkbox(&mut self.settings.steamgrid_db.enabled, "Download images");
if self.settings.steamgrid_db.enabled {
ui.horizontal(|ui| {
let mut auth_key = self
.settings
.steamgrid_db
.auth_key
.clone()
.unwrap_or_default();
ui.label("Authentication key: ");
if ui.text_edit_singleline(&mut auth_key).changed() {
if auth_key.is_empty() {
self.settings.steamgrid_db.auth_key = None;
} else {
self.settings.steamgrid_db.auth_key = Some(auth_key.to_string());
}
}
if auth_key.is_empty() && ui.button("Paste from clipboard").clicked(){
if let Ok(mut clipboard_ctx) = copypasta::ClipboardContext::new() {
if let Ok(content) = clipboard_ctx.get_contents() {
self.settings.steamgrid_db.auth_key = Some(content);
}
}
}
});
ui.horizontal(|ui| {
ui.label(
"To download images you need an API Key from SteamGridDB, you can find yours",
);
ui.hyperlink_to(
"here",
"https://www.steamgriddb.com/profile/preferences/api",
)
});
ui.checkbox(&mut self.settings.steamgrid_db.prefer_animated, "Prefer animated images").on_hover_text("Prefer downloading animated images over static images (this can slow Steam down but looks neat)");
ui.checkbox(
&mut self.settings.steamgrid_db.only_download_boilr_images,
"Only download images for BoilR shortcuts",
);
}
ui.add_space(SECTION_SPACING);
}
fn render_legendary_settings(&mut self, ui: &mut egui::Ui) {
ui.heading("Legendary & Rare");
ui.checkbox(
&mut self.settings.legendary.enabled,
"Import from Legendary & Rare",
);
if self.settings.legendary.enabled {
ui.horizontal(|ui| {
let mut empty_string = "".to_string();
let legendary_location = self
.settings
.legendary
.executable
.as_mut()
.unwrap_or(&mut empty_string);
ui.label("Legendary Executable: ")
.on_hover_text("The location of the legendary executable to use");
if ui.text_edit_singleline(legendary_location).changed() {
self.settings.legendary.executable = Some(legendary_location.to_string());
}
});
}
ui.add_space(SECTION_SPACING);
}
fn render_epic_settings(&mut self, ui: &mut egui::Ui) {
let epic_settings = &mut self.settings.epic_games;
ui.heading("Epic Games");
ui.checkbox(&mut epic_settings.enabled, "Import from Epic Games");
if epic_settings.enabled {
let safe_mode_header = match epic_settings.safe_launch.len() {
0 => "Force games to launch through Epic Launcher".to_string(),
1 => "One game forced to launch through Epic Launcher".to_string(),
x => format!("{} games forced to launch through Epic Launcher", x),
};
egui::CollapsingHeader::new(safe_mode_header)
.id_source("Epic_Launcher_safe_launch")
.show(ui, |ui| {
ui.label("Some games must be started from the Epic Launcher, select those games below and BoilR will create shortcuts that opens the games through the Epic Launcher.");
let manifests =self.epic_manifests.get_or_insert_with(||{
let epic_platform = EpicPlatform::new(epic_settings);
let manifests = crate::platform::Platform::get_shortcuts(&epic_platform);
manifests.unwrap_or_default()
});
let mut safe_open_games = epic_settings.safe_launch.clone();
for manifest in manifests{
let key = manifest.get_key();
let display_name = &manifest.display_name;
let mut safe_open = safe_open_games.contains(display_name) || safe_open_games.contains(&key);
if ui.checkbox(&mut safe_open, display_name).clicked(){
if safe_open{
safe_open_games.push(key);
}else{
safe_open_games.retain(|m| m!= display_name && m!= &key);
}
}
}
epic_settings.safe_launch = safe_open_games;
}) ;
ui.add_space(SECTION_SPACING);
}
}
}
+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 egui::{Button, ImageButton, Rounding, Stroke, TextureHandle};
use egui::{ImageButton, Rounding, Stroke, TextureHandle};
use steam_shortcuts_util::shortcut::ShortcutOwned;
use tokio::{
runtime::Runtime,
sync::watch::{self, Receiver},
};
use crate::{
egs::ManifestItem,
heroic::{HeroicGame, HeroicGameType},
settings::Settings,
sync::SyncProgress,
};
use crate::{egs::ManifestItem, settings::Settings, sync::SyncProgress};
use super::{
ui_colors::{
@@ -42,6 +38,7 @@ pub struct MyEguiApp {
pub(crate) games_to_sync: Receiver<FetcStatus<Vec<(String, Vec<ShortcutOwned>)>>>,
pub(crate) status_reciever: Receiver<SyncProgress>,
pub(crate) epic_manifests: Option<Vec<ManifestItem>>,
#[cfg(target_family = "unix")]
pub(crate) heroic_games: Option<Vec<HeroicGameType>>,
pub(crate) image_selected_state: ImageSelectState,
pub(crate) backup_state: BackupState,
@@ -59,6 +56,7 @@ impl MyEguiApp {
ui_images: UiImages::default(),
status_reciever: watch::channel(SyncProgress::NotStarted).1,
epic_manifests: None,
#[cfg(target_family = "unix")]
heroic_games: None,
image_selected_state: ImageSelectState::default(),
backup_state: BackupState::default(),
@@ -243,21 +241,27 @@ impl MyEguiApp {
fn get_import_image(&mut self, ui: &mut egui::Ui) -> &mut TextureHandle {
self.ui_images.import_button.get_or_insert_with(|| {
// 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 {
self.ui_images.save_button.get_or_insert_with(|| {
// 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 {
self.ui_images.logo_32.get_or_insert_with(|| {
// 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);
}
pub fn run_ui(args: Vec<String>){
pub fn run_ui(args: Vec<String>) {
let app = MyEguiApp::new();
let no_v_sync = args.contains(&"--no-vsync".to_string());
let native_options = eframe::NativeOptions {