crafting station model, explanatory text part 1

This commit is contained in:
Monty Marz 2021-10-18 22:18:40 +02:00 committed by Sam
parent 5707377565
commit a97cc95496
4 changed files with 92 additions and 57 deletions

View File

@ -37,7 +37,7 @@
),
Tool("SalvagingBench"): VoxTrans(
"voxel.sprite.salvaging_station.salvaging_station-0",
(0.0, 0.0, 0.0), (-90.0, 20.0, 0.0), 1.0,
(0.0, 0.0, 0.0), (-50.0, 40.0, 30.0), 0.9,
),
// Weapons
// Diary Example Images

Binary file not shown.

View File

@ -3221,7 +3221,7 @@ SalvagingBench: Some((
variations: [
(
model: "voxygen.voxel.sprite.salvaging_station.salvaging_station-0",
offset: (-8.5, -7.5, 0.0),
offset: (-7.0, -8.0, 0.0),
lod_axes: (0.0, 0.0, 0.0),
),
],

View File

@ -142,12 +142,12 @@ pub enum CraftingTab {
Armor,
Weapon,
ProcessedMaterial,
Dismantle,
Food,
Potion,
Bag,
Utility,
Glider,
Dismantle, // Needs to be the last one or widget alignment will be messed up
}
impl CraftingTab {
@ -155,7 +155,6 @@ impl CraftingTab {
match self {
CraftingTab::All => "hud.crafting.tabs.all",
CraftingTab::Armor => "hud.crafting.tabs.armor",
CraftingTab::Dismantle => "hud.crafting.tabs.dismantle",
CraftingTab::Food => "hud.crafting.tabs.food",
CraftingTab::Glider => "hud.crafting.tabs.glider",
CraftingTab::Potion => "hud.crafting.tabs.potion",
@ -164,6 +163,7 @@ impl CraftingTab {
CraftingTab::Weapon => "hud.crafting.tabs.weapon",
CraftingTab::Bag => "hud.crafting.tabs.bag",
CraftingTab::ProcessedMaterial => "hud.crafting.tabs.processed_material",
CraftingTab::Dismantle => "hud.crafting.tabs.dismantle",
}
}
@ -171,7 +171,6 @@ impl CraftingTab {
match self {
CraftingTab::All => imgs.icon_globe,
CraftingTab::Armor => imgs.icon_armor,
CraftingTab::Dismantle => imgs.icon_dismantle,
CraftingTab::Food => imgs.icon_food,
CraftingTab::Glider => imgs.icon_glider,
CraftingTab::Potion => imgs.icon_potion,
@ -180,13 +179,14 @@ impl CraftingTab {
CraftingTab::Weapon => imgs.icon_weapon,
CraftingTab::Bag => imgs.icon_bag,
CraftingTab::ProcessedMaterial => imgs.icon_processed_material,
CraftingTab::Dismantle => imgs.icon_dismantle,
}
}
fn satisfies(self, recipe: &Recipe) -> bool {
let (item, _count) = &recipe.output;
match self {
CraftingTab::All => true,
CraftingTab::All | CraftingTab::Dismantle => true,
CraftingTab::Food => item.tags().contains(&ItemTag::Food),
CraftingTab::Armor => match item.kind() {
ItemKind::Armor(_) => !item.tags().contains(&ItemTag::Bag),
@ -207,8 +207,6 @@ impl CraftingTab {
ItemKind::Tool(_) => !item.tags().contains(&ItemTag::CraftingTool),
_ => false,
},
// Only has salavging UI which doesn't use recipes
CraftingTab::Dismantle => false,
}
}
}
@ -374,53 +372,55 @@ impl<'a> Widget for Crafting<'a> {
};
let sel_crafting_tab = &self.show.crafting_tab;
for (i, crafting_tab) in CraftingTab::iter().enumerate() {
let tab_img = crafting_tab.img_id(self.imgs);
// Button Background
let mut bg = Image::new(self.imgs.pixel)
.w_h(40.0, 30.0)
.color(Some(UI_MAIN));
if i == 0 {
bg = bg.top_left_with_margins_on(state.ids.window_frame, 50.0, -40.0)
} else {
bg = bg.down_from(state.ids.category_bgs[i - 1], 0.0)
};
bg.set(state.ids.category_bgs[i], ui);
// Category Button
if Button::image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border
})
.wh_of(state.ids.category_bgs[i])
.middle_of(state.ids.category_bgs[i])
.hover_image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border_mo
})
.press_image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border_press
})
.with_tooltip(
self.tooltip_manager,
self.localized_strings.get(crafting_tab.name_key()),
"",
&tabs_tooltip,
TEXT_COLOR,
)
.set(state.ids.category_tabs[i], ui)
.was_clicked()
{
events.push(Event::ChangeCraftingTab(crafting_tab))
};
// Tab images
Image::new(tab_img)
.middle_of(state.ids.category_tabs[i])
.w_h(20.0, 20.0)
.graphics_for(state.ids.category_tabs[i])
.set(state.ids.category_imgs[i], ui);
if crafting_tab != CraftingTab::Dismantle {
let tab_img = crafting_tab.img_id(self.imgs);
// Button Background
let mut bg = Image::new(self.imgs.pixel)
.w_h(40.0, 30.0)
.color(Some(UI_MAIN));
if i == 0 {
bg = bg.top_left_with_margins_on(state.ids.window_frame, 50.0, -40.0)
} else {
bg = bg.down_from(state.ids.category_bgs[i - 1], 0.0)
};
bg.set(state.ids.category_bgs[i], ui);
// Category Button
if Button::image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border
})
.wh_of(state.ids.category_bgs[i])
.middle_of(state.ids.category_bgs[i])
.hover_image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border_mo
})
.press_image(if crafting_tab == *sel_crafting_tab {
self.imgs.wpn_icon_border_pressed
} else {
self.imgs.wpn_icon_border_press
})
.with_tooltip(
self.tooltip_manager,
self.localized_strings.get(crafting_tab.name_key()),
"",
&tabs_tooltip,
TEXT_COLOR,
)
.set(state.ids.category_tabs[i], ui)
.was_clicked()
{
events.push(Event::ChangeCraftingTab(crafting_tab))
};
// Tab images
Image::new(tab_img)
.middle_of(state.ids.category_tabs[i])
.w_h(20.0, 20.0)
.graphics_for(state.ids.category_tabs[i])
.set(state.ids.category_imgs[i], ui);
}
}
// TODO: Consider UX for filtering searches, maybe a checkbox or a dropdown if
@ -1021,6 +1021,41 @@ impl<'a> Widget for Crafting<'a> {
.set(state.ids.ingredients[i], ui);
}
}
} else if *sel_crafting_tab == CraftingTab::Dismantle {
// Title
Text::new("Dismantling")
.mid_top_with_margin_on(state.ids.align_ing, -40.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(24))
.color(TEXT_COLOR)
.parent(state.ids.window)
.set(state.ids.title_ing, ui);
// Bench Icon
Image::new(animate_by_pulse(
&self
.item_imgs
.img_ids_or_not_found_img(Tool("SalvagingBench".to_string())),
self.pulse,
))
.w_h(120.0, 120.0)
.mid_top_with_margin_on(state.ids.align_ing, 40.0)
.parent(state.ids.align_ing)
.set(state.ids.output_img_frame, ui);
// Explanation
Text::new("Explanation goes here")
.mid_bottom_with_margin_on(state.ids.output_img_frame, -40.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(14))
.color(TEXT_COLOR)
.parent(state.ids.window)
.set(state.ids.ingredients_txt, ui);
// Colored Overlays
}
// Search / Title Recipes