mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Add option to reset all images (#220)
This commit is contained in:
@@ -128,6 +128,7 @@ enum UserAction {
|
||||
SetGamesMode(GameMode),
|
||||
BackButton,
|
||||
NoAction,
|
||||
ClearImages,
|
||||
}
|
||||
|
||||
impl MyEguiApp {
|
||||
@@ -147,7 +148,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) {
|
||||
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() {
|
||||
@@ -399,6 +400,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(){
|
||||
self.handle_image_type_clear(*image_type);
|
||||
}
|
||||
self.handle_back_button_action();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -638,12 +645,27 @@ impl MyEguiApp {
|
||||
fn render_possible_names(
|
||||
possible_names: &Vec<steamgriddb_api::search::SearchResult>,
|
||||
ui: &mut egui::Ui,
|
||||
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() {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
if ui.button("Clear all images").on_hover_text("Clicking this deletes all images for this shortcut").clicked(){
|
||||
return Some(UserAction::ClearImages);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -661,12 +683,7 @@ fn render_steam_game_select(ui: &mut egui::Ui, state: &ImageSelectState) -> Opti
|
||||
}
|
||||
|
||||
fn render_shortcut_images(ui: &mut egui::Ui, state: &ImageSelectState) -> Option<UserAction> {
|
||||
let mut grid_id_text = state.grid_id.map(|id| id.to_string()).unwrap_or_default();
|
||||
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));
|
||||
}
|
||||
};
|
||||
|
||||
if ui
|
||||
.button("Click here if the images are for a wrong game")
|
||||
.clicked()
|
||||
|
||||
Reference in New Issue
Block a user