mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Show warning in images ui when invalid settings (#186)
This commit is contained in:
@@ -23,6 +23,7 @@ pub struct ImageSelectState {
|
|||||||
pub grid_id: Option<usize>,
|
pub grid_id: Option<usize>,
|
||||||
|
|
||||||
pub steam_user: Option<SteamUsersInfo>,
|
pub steam_user: Option<SteamUsersInfo>,
|
||||||
|
pub settings_error: Option<String>,
|
||||||
pub steam_users: Option<Vec<SteamUsersInfo>>,
|
pub steam_users: Option<Vec<SteamUsersInfo>>,
|
||||||
pub user_shortcuts: Option<Vec<ShortcutOwned>>,
|
pub user_shortcuts: Option<Vec<ShortcutOwned>>,
|
||||||
pub game_mode: GameMode,
|
pub game_mode: GameMode,
|
||||||
@@ -81,6 +82,7 @@ impl Default for ImageSelectState {
|
|||||||
grid_id: Default::default(),
|
grid_id: Default::default(),
|
||||||
steam_user: Default::default(),
|
steam_user: Default::default(),
|
||||||
steam_users: Default::default(),
|
steam_users: Default::default(),
|
||||||
|
settings_error: Default::default(),
|
||||||
user_shortcuts: Default::default(),
|
user_shortcuts: Default::default(),
|
||||||
game_mode: GameMode::Shortcuts,
|
game_mode: GameMode::Shortcuts,
|
||||||
image_type_selected: Default::default(),
|
image_type_selected: Default::default(),
|
||||||
@@ -325,17 +327,29 @@ impl MyEguiApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_steam_users_loaded(&mut self) {
|
fn ensure_steam_users_loaded(&mut self) {
|
||||||
self.image_selected_state
|
if self.image_selected_state.settings_error.is_none() && self.image_selected_state.steam_users.is_none() {
|
||||||
.steam_users
|
let paths = get_shortcuts_paths(&self.settings.steam);
|
||||||
.get_or_insert_with(|| {
|
match paths{
|
||||||
get_shortcuts_paths(&self.settings.steam).expect("Should have steam user")
|
Ok(paths) => {
|
||||||
});
|
self.image_selected_state.steam_users = Some(paths)
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
self.image_selected_state.settings_error = Some(format!("Could not find user steam location, error message: {} , try to clear the steam location field in settings to let BoilR find it itself",err));
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn render_ui_images(&mut self, ui: &mut egui::Ui) {
|
pub(crate) fn render_ui_images(&mut self, ui: &mut egui::Ui) {
|
||||||
self.ensure_games_loaded();
|
self.ensure_games_loaded();
|
||||||
self.ensure_steam_users_loaded();
|
self.ensure_steam_users_loaded();
|
||||||
|
|
||||||
|
if let Some(error_message) = &self.image_selected_state.settings_error{
|
||||||
|
ui.label(error_message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut action = UserAction::NoAction;
|
let mut action = UserAction::NoAction;
|
||||||
ScrollArea::vertical()
|
ScrollArea::vertical()
|
||||||
.stick_to_right()
|
.stick_to_right()
|
||||||
|
|||||||
@@ -221,8 +221,13 @@ self.settings.heroic.default_launch_through_heroic{
|
|||||||
.unwrap_or(&mut empty_string);
|
.unwrap_or(&mut empty_string);
|
||||||
ui.label("Steam Location: ");
|
ui.label("Steam Location: ");
|
||||||
if ui.text_edit_singleline(steam_location).changed() {
|
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());
|
self.settings.steam.location = Some(steam_location.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
ui.checkbox(
|
ui.checkbox(
|
||||||
&mut self.settings.steam.create_collections,
|
&mut self.settings.steam.create_collections,
|
||||||
|
|||||||
Reference in New Issue
Block a user