mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
text margin fix, removed some mutable variables, can_perform for modulars accounts for crafting sprites [ci skip]
This commit is contained in:
parent
f6bf8206ab
commit
0d4b05b256
@ -852,7 +852,7 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
_ => RecipeKind::Simple,
|
_ => RecipeKind::Simple,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut modular_slot_check_hack = (None, None);
|
let mut modular_slot_check_hack = (None, None, false);
|
||||||
|
|
||||||
// Output slot, tags, and modular input slots
|
// Output slot, tags, and modular input slots
|
||||||
match recipe_kind {
|
match recipe_kind {
|
||||||
@ -1184,9 +1184,11 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
&item_tooltip,
|
&item_tooltip,
|
||||||
)
|
)
|
||||||
.set(state.ids.output_img, ui);
|
.set(state.ids.output_img, ui);
|
||||||
|
modular_slot_check_hack =
|
||||||
|
(primary_slot.invslot, secondary_slot.invslot, true);
|
||||||
} else {
|
} else {
|
||||||
Text::new(self.localized_strings.get("hud.crafting.modular_desc"))
|
Text::new(self.localized_strings.get("hud.crafting.modular_desc"))
|
||||||
.mid_top_with_margin_on(state.ids.modular_art, -25.0)
|
.mid_top_with_margin_on(state.ids.modular_art, -18.0)
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.font_size(self.fonts.cyri.scale(13))
|
.font_size(self.fonts.cyri.scale(13))
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
@ -1197,9 +1199,9 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
.w_h(70.0, 70.0)
|
.w_h(70.0, 70.0)
|
||||||
.graphics_for(state.ids.output_img)
|
.graphics_for(state.ids.output_img)
|
||||||
.set(state.ids.modular_wep_empty_bg, ui);
|
.set(state.ids.modular_wep_empty_bg, ui);
|
||||||
|
modular_slot_check_hack =
|
||||||
|
(primary_slot.invslot, secondary_slot.invslot, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
modular_slot_check_hack = (primary_slot.invslot, secondary_slot.invslot);
|
|
||||||
},
|
},
|
||||||
RecipeKind::Simple => {
|
RecipeKind::Simple => {
|
||||||
// Output Image Frame
|
// Output Image Frame
|
||||||
@ -1294,9 +1296,15 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
|
|
||||||
let can_perform = match recipe_kind {
|
let can_perform = match recipe_kind {
|
||||||
RecipeKind::ModularWeapon => {
|
RecipeKind::ModularWeapon => {
|
||||||
modular_slot_check_hack.0.is_some() && modular_slot_check_hack.1.is_some()
|
modular_slot_check_hack.2
|
||||||
|
&& self.show.crafting_fields.craft_sprite.map(|(_, s)| s)
|
||||||
|
== recipe.craft_sprite
|
||||||
|
},
|
||||||
|
RecipeKind::Component(_) => {
|
||||||
|
modular_slot_check_hack.2
|
||||||
|
&& self.show.crafting_fields.craft_sprite.map(|(_, s)| s)
|
||||||
|
== recipe.craft_sprite
|
||||||
},
|
},
|
||||||
RecipeKind::Component(_) => modular_slot_check_hack.0.is_some(),
|
|
||||||
RecipeKind::Simple => {
|
RecipeKind::Simple => {
|
||||||
self.client
|
self.client
|
||||||
.available_recipes()
|
.available_recipes()
|
||||||
@ -1335,7 +1343,8 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
{
|
{
|
||||||
match recipe_kind {
|
match recipe_kind {
|
||||||
RecipeKind::ModularWeapon => {
|
RecipeKind::ModularWeapon => {
|
||||||
if let (Some(primary_slot), Some(secondary_slot)) = modular_slot_check_hack
|
if let (Some(primary_slot), Some(secondary_slot), true) =
|
||||||
|
modular_slot_check_hack
|
||||||
{
|
{
|
||||||
events.push(Event::CraftModularWeapon {
|
events.push(Event::CraftModularWeapon {
|
||||||
primary_slot,
|
primary_slot,
|
||||||
@ -1344,6 +1353,7 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
RecipeKind::Component(toolkind) => {
|
RecipeKind::Component(toolkind) => {
|
||||||
|
// if let Some(primary_slot) = modular_slot_check_hack.0 {
|
||||||
if let Some(primary_slot) = modular_slot_check_hack.0 {
|
if let Some(primary_slot) = modular_slot_check_hack.0 {
|
||||||
events.push(Event::CraftModularWeaponComponent {
|
events.push(Event::CraftModularWeaponComponent {
|
||||||
toolkind,
|
toolkind,
|
||||||
@ -1358,24 +1368,22 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
|
|
||||||
// Crafting Station Info
|
// Crafting Station Info
|
||||||
if recipe.craft_sprite.is_some() {
|
if recipe.craft_sprite.is_some() {
|
||||||
let mut sprite_text = Text::new(
|
Text::new(
|
||||||
self.localized_strings
|
self.localized_strings
|
||||||
.get("hud.crafting.req_crafting_station"),
|
.get("hud.crafting.req_crafting_station"),
|
||||||
)
|
)
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.font_size(self.fonts.cyri.scale(18))
|
.font_size(self.fonts.cyri.scale(18))
|
||||||
.color(TEXT_COLOR);
|
.color(TEXT_COLOR)
|
||||||
match recipe_kind {
|
.and(|t| match recipe_kind {
|
||||||
RecipeKind::Simple => {
|
RecipeKind::Simple => {
|
||||||
sprite_text =
|
t.top_left_with_margins_on(state.ids.align_ing, 10.0, 5.0)
|
||||||
sprite_text.top_left_with_margins_on(state.ids.align_ing, 10.0, 5.0);
|
|
||||||
},
|
},
|
||||||
RecipeKind::ModularWeapon | RecipeKind::Component(_) => {
|
RecipeKind::ModularWeapon | RecipeKind::Component(_) => {
|
||||||
sprite_text =
|
t.top_left_with_margins_on(state.ids.align_ing, 325.0, 5.0)
|
||||||
sprite_text.top_left_with_margins_on(state.ids.align_ing, 325.0, 5.0);
|
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
sprite_text.set(state.ids.req_station_title, ui);
|
.set(state.ids.req_station_title, ui);
|
||||||
let station_img = match recipe.craft_sprite {
|
let station_img = match recipe.craft_sprite {
|
||||||
Some(SpriteKind::Anvil) => "Anvil",
|
Some(SpriteKind::Anvil) => "Anvil",
|
||||||
Some(SpriteKind::Cauldron) => "Cauldron",
|
Some(SpriteKind::Cauldron) => "Cauldron",
|
||||||
@ -1474,16 +1482,18 @@ impl<'a> Widget for Crafting<'a> {
|
|||||||
|
|
||||||
let num_ingredients = ingredients.len();
|
let num_ingredients = ingredients.len();
|
||||||
if num_ingredients > 0 {
|
if num_ingredients > 0 {
|
||||||
let mut ing_txt = Text::new(self.localized_strings.get("hud.crafting.ingredients"))
|
Text::new(self.localized_strings.get("hud.crafting.ingredients"))
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
.font_size(self.fonts.cyri.scale(18))
|
.font_size(self.fonts.cyri.scale(18))
|
||||||
.color(TEXT_COLOR);
|
.color(TEXT_COLOR)
|
||||||
if recipe.craft_sprite.is_some() {
|
.and(|t| {
|
||||||
ing_txt = ing_txt.down_from(state.ids.req_station_img, 10.0);
|
if recipe.craft_sprite.is_some() {
|
||||||
} else {
|
t.down_from(state.ids.req_station_img, 10.0)
|
||||||
ing_txt = ing_txt.top_left_with_margins_on(state.ids.align_ing, 10.0, 5.0);
|
} else {
|
||||||
};
|
t.top_left_with_margins_on(state.ids.align_ing, 10.0, 5.0)
|
||||||
ing_txt.set(state.ids.ingredients_txt, ui);
|
}
|
||||||
|
})
|
||||||
|
.set(state.ids.ingredients_txt, ui);
|
||||||
|
|
||||||
// Ingredient images with tooltip
|
// Ingredient images with tooltip
|
||||||
if state.ids.ingredient_frame.len() < num_ingredients {
|
if state.ids.ingredient_frame.len() < num_ingredients {
|
||||||
|
Loading…
Reference in New Issue
Block a user