mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'MHK/auto_search_in_crafting_menu' into 'master'
Add auto searching in crafting menu See merge request veloren/veloren!2932
This commit is contained in:
commit
e6a4e53ef3
@ -60,6 +60,7 @@ widget_ids! {
|
|||||||
recipe_img[],
|
recipe_img[],
|
||||||
ingredients[],
|
ingredients[],
|
||||||
ingredient_frame[],
|
ingredient_frame[],
|
||||||
|
ingredient_btn[],
|
||||||
ingredient_img[],
|
ingredient_img[],
|
||||||
req_text[],
|
req_text[],
|
||||||
ingredients_txt,
|
ingredients_txt,
|
||||||
@ -858,6 +859,14 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
.resize(recipe.inputs().len(), &mut ui.widget_id_generator())
|
.resize(recipe.inputs().len(), &mut ui.widget_id_generator())
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
if state.ids.ingredient_btn.len() < recipe.inputs().len() {
|
||||||
|
state.update(|state| {
|
||||||
|
state
|
||||||
|
.ids
|
||||||
|
.ingredient_btn
|
||||||
|
.resize(recipe.inputs().len(), &mut ui.widget_id_generator())
|
||||||
|
});
|
||||||
|
};
|
||||||
if state.ids.ingredient_img.len() < recipe.inputs().len() {
|
if state.ids.ingredient_img.len() < recipe.inputs().len() {
|
||||||
state.update(|state| {
|
state.update(|state| {
|
||||||
state
|
state
|
||||||
@ -936,15 +945,28 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
frame.down_from(frame_pos, 10.0 + frame_offset)
|
frame.down_from(frame_pos, 10.0 + frame_offset)
|
||||||
};
|
};
|
||||||
frame.set(state.ids.ingredient_frame[i], ui);
|
frame.set(state.ids.ingredient_frame[i], ui);
|
||||||
//Item Image
|
// Item button for auto search
|
||||||
Button::image(animate_by_pulse(
|
if Button::image(self.imgs.wpn_icon_border)
|
||||||
|
.w_h(22.0, 22.0)
|
||||||
|
.middle_of(state.ids.ingredient_frame[i])
|
||||||
|
.hover_image(self.imgs.wpn_icon_border_mo)
|
||||||
|
.with_item_tooltip(self.item_tooltip_manager, &*item_def, &None, &item_tooltip)
|
||||||
|
.set(state.ids.ingredient_btn[i], ui)
|
||||||
|
.was_clicked()
|
||||||
|
{
|
||||||
|
events.push(Event::ChangeCraftingTab(CraftingTab::All));
|
||||||
|
events.push(Event::SearchRecipe(Some(item_def.name().to_string())));
|
||||||
|
}
|
||||||
|
// Item image
|
||||||
|
Image::new(animate_by_pulse(
|
||||||
&self.item_imgs.img_ids_or_not_found_img((&*item_def).into()),
|
&self.item_imgs.img_ids_or_not_found_img((&*item_def).into()),
|
||||||
self.pulse,
|
self.pulse,
|
||||||
))
|
))
|
||||||
.w_h(22.0, 22.0)
|
.middle_of(state.ids.ingredient_btn[i])
|
||||||
.middle_of(state.ids.ingredient_frame[i])
|
.w_h(20.0, 20.0)
|
||||||
.with_item_tooltip(self.item_tooltip_manager, &*item_def, &None, &item_tooltip)
|
.graphics_for(state.ids.ingredient_btn[i])
|
||||||
.set(state.ids.ingredient_img[i], ui);
|
.set(state.ids.ingredient_img[i], ui);
|
||||||
|
|
||||||
// Ingredients text and amount
|
// Ingredients text and amount
|
||||||
// Don't show inventory amounts above 999 to avoid the widget clipping
|
// Don't show inventory amounts above 999 to avoid the widget clipping
|
||||||
let over9k = "99+";
|
let over9k = "99+";
|
||||||
|
Loading…
Reference in New Issue
Block a user