Add show all recipes icon to crafting window

This commit is contained in:
Isse
2024-11-07 16:52:00 +01:00
parent 757e032ea2
commit ffa860df99
9 changed files with 63 additions and 1 deletions

BIN
assets/voxygen/element/ui/generic/buttons/eye_closed_btn.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/element/ui/generic/buttons/eye_open_btn.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -56,6 +56,7 @@ widget_ids! {
title_rec,
align_rec,
scrollbar_rec,
btn_show_all_recipes,
btn_open_search,
btn_close_search,
input_search,
@ -119,6 +120,7 @@ pub enum Event {
Close,
Focus(widget::Id),
SearchRecipe(Option<String>),
ShowAllRecipes(bool),
ClearRecipeInputs,
RepairItem {
slot: Slot,
@ -2305,9 +2307,36 @@ impl<'a> Widget for Crafting<'a> {
.top_left_with_margins_on(state.ids.window, 52.0, 26.0)
.graphics_for(state.ids.btn_open_search)
.set(state.ids.input_overlay_search, ui);
if Button::image(self.imgs.search_btn)
let (eye, eye_hover, eye_press) = if self.settings.gameplay.show_all_recipes {
(
self.imgs.eye_open_btn,
self.imgs.eye_open_btn_hover,
self.imgs.eye_open_btn_press,
)
} else {
(
self.imgs.eye_closed_btn,
self.imgs.eye_closed_btn_hover,
self.imgs.eye_closed_btn_press,
)
};
if Button::image(eye)
.top_left_with_margins_on(state.ids.align_rec, -21.0, 5.0)
.w_h(16.0, 16.0)
.hover_image(eye_hover)
.press_image(eye_press)
.parent(state.ids.window)
.set(state.ids.btn_show_all_recipes, ui)
.was_clicked()
{
events.push(Event::ShowAllRecipes(
!self.settings.gameplay.show_all_recipes,
));
}
if Button::image(self.imgs.search_btn)
.right_from(state.ids.btn_show_all_recipes, 5.0)
.w_h(16.0, 16.0)
.hover_image(self.imgs.search_btn_hover)
.press_image(self.imgs.search_btn_press)
.parent(state.ids.window)

View File

@ -628,6 +628,14 @@ image_ids! {
search_btn_hover: "voxygen.element.ui.generic.buttons.search_btn_hover",
search_btn_press: "voxygen.element.ui.generic.buttons.search_btn_press",
// Eye-buttons
eye_open_btn: "voxygen.element.ui.generic.buttons.eye_open_btn",
eye_open_btn_hover: "voxygen.element.ui.generic.buttons.eye_open_btn_hover",
eye_open_btn_press: "voxygen.element.ui.generic.buttons.eye_open_btn_press",
eye_closed_btn: "voxygen.element.ui.generic.buttons.eye_closed_btn",
eye_closed_btn_hover: "voxygen.element.ui.generic.buttons.eye_closed_btn_hover",
eye_closed_btn_press: "voxygen.element.ui.generic.buttons.eye_closed_btn_press",
// Edit-Button
edit_btn: "voxygen.element.ui.char_select.icons.pen",
edit_btn_hover: "voxygen.element.ui.char_select.icons.pen_hover",

View File

@ -3524,6 +3524,13 @@ impl Hud {
});
}
},
crafting::Event::ShowAllRecipes(show) => {
events.push(Event::SettingsChange(SettingsChange::Gameplay(
crate::session::settings_change::Gameplay::ChangeShowAllRecipes(
show,
),
)));
},
}
}
}