diff --git a/resources/save.png b/resources/save.png new file mode 100644 index 0000000..843f73a Binary files /dev/null and b/resources/save.png differ diff --git a/src/ui/defines.rs b/src/ui/defines.rs index e3b9b75..e6d928f 100644 --- a/src/ui/defines.rs +++ b/src/ui/defines.rs @@ -17,6 +17,7 @@ pub mod ui_images { use egui::{ColorImage, ImageData}; pub const IMPORT_GAMES_IMAGE: &[u8] = include_bytes!("../../resources/import_games_button.png"); + pub const SAVE_IMAGE: &[u8] = include_bytes!("../../resources/save.png"); pub const LOGO_32: &[u8] = include_bytes!("../../resources/logo32.png"); pub const LOGO_ICON: &[u8] = include_bytes!("../../resources/logo_small.png"); @@ -24,6 +25,10 @@ pub mod ui_images { ImageData::Color(load_image_from_memory(IMPORT_GAMES_IMAGE).unwrap()) } + pub fn get_save_image() -> ImageData { + ImageData::Color(load_image_from_memory(SAVE_IMAGE).unwrap()) + } + pub fn get_logo() -> ImageData { ImageData::Color(load_image_from_memory(LOGO_32).unwrap()) } diff --git a/src/ui/uiapp.rs b/src/ui/uiapp.rs index a24eb38..090fcc8 100644 --- a/src/ui/uiapp.rs +++ b/src/ui/uiapp.rs @@ -1,7 +1,7 @@ use std::{env::Args, error::Error}; use eframe::{egui, App, Frame}; -use egui::{ImageButton, Rounding, Stroke, TextureHandle}; +use egui::{Button, ImageButton, Rounding, Stroke, TextureHandle}; use steam_shortcuts_util::shortcut::ShortcutOwned; use tokio::{ runtime::Runtime, @@ -20,7 +20,7 @@ use super::{ BACKGROUND_COLOR, BG_STROKE_COLOR, EXTRA_BACKGROUND_COLOR, LIGHT_ORANGE, ORANGE, PURLPLE, TEXT_COLOR, }, - ui_images::{get_import_image, get_logo, get_logo_icon}, + ui_images::{get_import_image, get_logo, get_logo_icon, get_save_image}, ui_import_games::FetcStatus, BackupState, DiconnectState, ImageSelectState, }; @@ -30,6 +30,7 @@ const SECTION_SPACING: f32 = 25.0; #[derive(Default)] struct UiImages { import_button: Option, + save_button: Option, logo_32: Option, } @@ -127,6 +128,20 @@ impl App for MyEguiApp { self.games_to_sync = watch::channel(FetcStatus::NeedsFetched).1; } }); + + if self.selected_menu == Menues::Settings { + egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel") + .frame(frame) + .show(ctx, |ui| { + let texture = self.get_save_image(ui); + let size = texture.size_vec2(); + let save_button = ImageButton::new(texture, size * 0.5); + + if ui.add(save_button).on_hover_text("Save settings").clicked() { + MyEguiApp::save_settings_to_file(&self.settings.clone()); + } + }); + } if self.games_to_sync.borrow().is_some() { egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel") .frame(frame) @@ -232,6 +247,13 @@ impl MyEguiApp { }) } + 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()) + }) + } + 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.