Merge branch 'juliancoffee/fix_dismantle' into 'master'

Improve Dismantle UX

See merge request veloren/veloren!2498
This commit is contained in:
Snowram 2021-06-27 00:11:01 +00:00
commit b477eac816
33 changed files with 296 additions and 80 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Players can press H to greet others
- Ability to toggle chat visibility
- Added gem rings with various stat improvements.
### Changed
- Entity-entity pushback is no longer applied in forced movement states like rolling and leaping.
@ -34,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Crafting Stations aren't exploadable anymore
- Cases where no audio output could be produced before.
- Significantly improved the performance of playing sound effects
- Dismantle and Material crafting tabs don't have duplicated recipes
## [0.10.0] - 2021-06-12

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,6 @@ ItemDef(
)),
quality: Epic,
tags: [
Material(Linen),
Material(Moonweave),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Common,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Common,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Moderate,
tags: [
Material(Linen),
],
)
)

View File

@ -14,6 +14,5 @@ ItemDef(
)),
quality: Common,
tags: [
Material(Linen),
],
)
)

View File

@ -6,6 +6,5 @@ ItemDef(
),
quality: Low,
tags: [
Material(Leather)
],
)
)

View File

@ -6,6 +6,5 @@ ItemDef(
),
quality: Epic,
tags: [
Material(Leather)
],
)
)

View File

@ -6,6 +6,5 @@ ItemDef(
),
quality: Common,
tags: [
Material(Leather)
],
)
],
)

File diff suppressed because it is too large Load Diff

View File

@ -229,6 +229,7 @@ fn make_recipe_def(identifier: String, toolkind: ToolKind) -> RawRecipe {
output,
inputs,
craft_sprite: None,
is_recycling: false,
}
}

View File

@ -21,6 +21,7 @@ pub struct Recipe {
pub output: (Arc<ItemDef>, u32),
pub inputs: Vec<(RecipeInput, u32)>,
pub craft_sprite: Option<SpriteKind>,
pub is_recycling: bool,
}
#[allow(clippy::type_complexity)]
@ -93,8 +94,8 @@ pub enum RawRecipeInput {
pub(crate) struct RawRecipe {
pub(crate) output: (String, u32),
pub(crate) inputs: Vec<(RawRecipeInput, u32)>,
#[serde(default)]
pub(crate) craft_sprite: Option<SpriteKind>,
pub(crate) is_recycling: bool,
}
#[derive(Clone, Deserialize)]
@ -117,6 +118,7 @@ impl assets::Compound for RecipeBook {
let def = Arc::<ItemDef>::load_cloned(&spec.0)?;
Ok((def, spec.1))
}
#[inline]
fn load_recipe_input(
spec: &(RawRecipeInput, u32),
@ -149,6 +151,7 @@ impl assets::Compound for RecipeBook {
output,
inputs,
craft_sprite,
is_recycling,
},
)| {
let inputs = inputs
@ -160,6 +163,7 @@ impl assets::Compound for RecipeBook {
output,
inputs,
craft_sprite: *craft_sprite,
is_recycling: *is_recycling,
}))
},
)

View File

@ -20,7 +20,7 @@ use common::{
},
Inventory,
},
recipe::RecipeInput,
recipe::{Recipe, RecipeInput},
terrain::SpriteKind,
};
use conrod_core::{
@ -138,19 +138,20 @@ impl<'a> Crafting<'a> {
#[derive(Copy, Clone, Debug, EnumIter, PartialEq)]
pub enum CraftingTab {
All,
Tool,
Armor,
Weapon,
Food,
ProcessedMaterial,
Dismantle,
Food,
Potion,
Bag,
Tool,
Utility,
Glider,
ProcessedMaterial,
}
impl CraftingTab {
fn name_key(&self) -> &str {
fn name_key(self) -> &'static str {
match self {
CraftingTab::All => "hud.crafting.tabs.all",
CraftingTab::Armor => "hud.crafting.tabs.armor",
@ -166,7 +167,7 @@ impl CraftingTab {
}
}
fn img_id(&self, imgs: &Imgs) -> image::Id {
fn img_id(self, imgs: &Imgs) -> image::Id {
match self {
CraftingTab::All => imgs.icon_globe,
CraftingTab::Armor => imgs.icon_armor,
@ -182,7 +183,8 @@ impl CraftingTab {
}
}
fn satisfies(&self, item: &ItemDef) -> bool {
fn satisfies(self, recipe: &Recipe) -> bool {
let (item, _count) = &recipe.output;
match self {
CraftingTab::All => true,
CraftingTab::Food => item.tags().contains(&ItemTag::Food),
@ -193,10 +195,11 @@ impl CraftingTab {
CraftingTab::Glider => matches!(item.kind(), ItemKind::Glider(_)),
CraftingTab::Potion => item.tags().contains(&ItemTag::Potion),
CraftingTab::ProcessedMaterial => {
item.tags().contains(&ItemTag::MetalIngot)
| item.tags().contains(&ItemTag::Textile)
| item.tags().contains(&ItemTag::Leather)
| item.tags().contains(&ItemTag::BaseMaterial)
(item.tags().contains(&ItemTag::MetalIngot)
|| item.tags().contains(&ItemTag::Textile)
|| item.tags().contains(&ItemTag::Leather)
|| item.tags().contains(&ItemTag::BaseMaterial))
&& !recipe.is_recycling
},
CraftingTab::Bag => item.tags().contains(&ItemTag::Bag),
CraftingTab::Tool => item.tags().contains(&ItemTag::CraftingTool),
@ -205,10 +208,7 @@ impl CraftingTab {
ItemKind::Tool(_) => !item.tags().contains(&ItemTag::CraftingTool),
_ => false,
},
CraftingTab::Dismantle => match item.kind() {
ItemKind::Ingredient { .. } => !item.tags().contains(&ItemTag::CraftingTool),
_ => false,
},
CraftingTab::Dismantle => recipe.is_recycling,
}
}
}
@ -471,7 +471,7 @@ impl<'a> Widget for Crafting<'a> {
}
for (i, (name, recipe, is_craftable)) in ordered_recipes
.into_iter()
.filter(|(_, recipe, _)| self.show.crafting_tab.satisfies(recipe.output.0.as_ref()))
.filter(|(_, recipe, _)| self.show.crafting_tab.satisfies(&recipe))
.enumerate()
{
let button = Button::image(if state.selected_recipe.as_ref() == Some(name) {
@ -650,7 +650,7 @@ impl<'a> Widget for Crafting<'a> {
for (row, chunk) in CraftingTab::iter()
.filter(|crafting_tab| match crafting_tab {
CraftingTab::All => false,
_ => crafting_tab.satisfies(recipe.output.0.as_ref()),
_ => crafting_tab.satisfies(&recipe),
})
.filter(|crafting_tab| crafting_tab != &self.show.crafting_tab)
.collect::<Vec<_>>()
@ -880,7 +880,7 @@ impl<'a> Widget for Crafting<'a> {
// Ingredients
let name = match recipe_input {
RecipeInput::Item(_) => item_def.name().to_string(),
RecipeInput::Tag(tag) => format!("Any {}", tag.name()),
RecipeInput::Tag(tag) => format!("Any {} item", tag.name()),
};
let input = format!(
"{}x {} ({})",