mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Save settings button (#187)
* Show warning in images ui when invalid settings
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 470 B |
@@ -17,6 +17,7 @@ pub mod ui_images {
|
|||||||
use egui::{ColorImage, ImageData};
|
use egui::{ColorImage, ImageData};
|
||||||
|
|
||||||
pub const IMPORT_GAMES_IMAGE: &[u8] = include_bytes!("../../resources/import_games_button.png");
|
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_32: &[u8] = include_bytes!("../../resources/logo32.png");
|
||||||
pub const LOGO_ICON: &[u8] = include_bytes!("../../resources/logo_small.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())
|
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 {
|
pub fn get_logo() -> ImageData {
|
||||||
ImageData::Color(load_image_from_memory(LOGO_32).unwrap())
|
ImageData::Color(load_image_from_memory(LOGO_32).unwrap())
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-2
@@ -1,7 +1,7 @@
|
|||||||
use std::{env::Args, error::Error};
|
use std::{env::Args, error::Error};
|
||||||
|
|
||||||
use eframe::{egui, App, Frame};
|
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 steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
runtime::Runtime,
|
runtime::Runtime,
|
||||||
@@ -20,7 +20,7 @@ use super::{
|
|||||||
BACKGROUND_COLOR, BG_STROKE_COLOR, EXTRA_BACKGROUND_COLOR, LIGHT_ORANGE, ORANGE, PURLPLE,
|
BACKGROUND_COLOR, BG_STROKE_COLOR, EXTRA_BACKGROUND_COLOR, LIGHT_ORANGE, ORANGE, PURLPLE,
|
||||||
TEXT_COLOR,
|
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,
|
ui_import_games::FetcStatus,
|
||||||
BackupState, DiconnectState, ImageSelectState,
|
BackupState, DiconnectState, ImageSelectState,
|
||||||
};
|
};
|
||||||
@@ -30,6 +30,7 @@ const SECTION_SPACING: f32 = 25.0;
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct UiImages {
|
struct UiImages {
|
||||||
import_button: Option<egui::TextureHandle>,
|
import_button: Option<egui::TextureHandle>,
|
||||||
|
save_button: Option<egui::TextureHandle>,
|
||||||
logo_32: Option<egui::TextureHandle>,
|
logo_32: Option<egui::TextureHandle>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +128,20 @@ impl App for MyEguiApp {
|
|||||||
self.games_to_sync = watch::channel(FetcStatus::NeedsFetched).1;
|
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() {
|
if self.games_to_sync.borrow().is_some() {
|
||||||
egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel")
|
egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel")
|
||||||
.frame(frame)
|
.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 {
|
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user