diff --git a/assets/voxygen/item_image_manifest.ron b/assets/voxygen/item_image_manifest.ron index bf11b128af..bd5ba2fdff 100644 --- a/assets/voxygen/item_image_manifest.ron +++ b/assets/voxygen/item_image_manifest.ron @@ -8,7 +8,7 @@ "voxel.weapon.bow.shortbow_starter", (0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0, ), - Tool(Tool("common.items.weapons.bow.wood_shortbow-0")): VoxTrans( + Tool("common.items.weapons.bow.wood_shortbow-0"): VoxTrans( "voxel.weapon.bow.shortbow_wood-0", (0.0, 0.0, 0.0), (90.0, 90.0, 0.0), 1.0, ), diff --git a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron index ec6ae4259f..5a3f965d8f 100644 --- a/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron +++ b/assets/voxygen/voxel/humanoid_main_weapon_manifest.ron @@ -461,7 +461,7 @@ vox_spec: ("weapon.hammer.cult_purp-0", (-3.5, -4.5, -5.0)), color: None ), - "Craftsman": ( //TODO This should be a 1h hammer! + /*"Craftsman": ( //TODO This should be a 1h hammer! vox_spec: ("weapon.hammer.craftsman", (-2.0, -5.0, -5.5)), color: None ),*/ diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 3c1aeadcae..2094f78176 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -351,6 +351,7 @@ pub trait ItemDesc { fn name(&self) -> &str; fn kind(&self) -> &ItemKind; fn quality(&self) -> &Quality; + fn item_definition_id(&self) -> &str; } impl ItemDesc for Item { @@ -361,6 +362,8 @@ impl ItemDesc for Item { fn kind(&self) -> &ItemKind { &self.item_def.kind } fn quality(&self) -> &Quality { &self.item_def.quality } + + fn item_definition_id(&self) -> &str { &self.item_def.item_definition_id } } impl ItemDesc for ItemDef { @@ -371,6 +374,8 @@ impl ItemDesc for ItemDef { fn kind(&self) -> &ItemKind { &self.kind } fn quality(&self) -> &Quality { &self.quality } + + fn item_definition_id(&self) -> &str { &self.item_definition_id } } impl Component for Item { diff --git a/server/src/migrations/2020-11-07-182406_rename_npcweapons/up.sql b/server/src/migrations/2020-11-07-182406_rename_npcweapons/up.sql index 8196eee0be..8951bb1e3f 100644 --- a/server/src/migrations/2020-11-07-182406_rename_npcweapons/up.sql +++ b/server/src/migrations/2020-11-07-182406_rename_npcweapons/up.sql @@ -1,4 +1,4 @@ --- Changes filepaths of sceptres +-- Changes filepaths of npcweapons UPDATE item SET item_definition_id = 'common.items.npc_weapons.unique.beast_claws' WHERE item_definition_id = 'common.items.npc_weapons.npcweapon.beast_claws'; diff --git a/tools/src/main.rs b/tools/src/main.rs index 44b19c1da4..62995f9e24 100644 --- a/tools/src/main.rs +++ b/tools/src/main.rs @@ -87,23 +87,6 @@ fn get_tool_kind(kind: &ToolKind) -> String { } } -/*fn get_tool_kind_kind(kind: &ToolKind) -> String { - match kind { - ToolKind::Sword(x) => x.clone(), - ToolKind::Axe(x) => x.clone(), - ToolKind::Hammer(x) => x.clone(), - ToolKind::Bow(x) => x.clone(), - ToolKind::Dagger(x) => x.clone(), - ToolKind::Staff(x) => x.clone(), - ToolKind::Sceptre(x) => x.clone(), - ToolKind::Shield(x) => x.clone(), - ToolKind::Debug(x) => x.clone(), - ToolKind::Farming(x) => x.clone(), - ToolKind::NpcWeapon(x) => x.clone(), - ToolKind::Empty => "".to_string(), - } -}*/ - fn get_armor_kind(kind: &ArmorKind) -> String { match kind { ArmorKind::Shoulder(_) => "Shoulder".to_string(), @@ -146,7 +129,6 @@ fn all_items() -> Result<(), Box> { let kind = match item.kind() { ItemKind::Armor(armor) => get_armor_kind_kind(&armor.kind), ItemKind::Lantern(lantern) => lantern.kind.clone(), - //ItemKind::Tool(tool) => get_tool_kind_kind(&tool.kind), _ => "".to_owned(), }; diff --git a/voxygen/src/anim/src/character/idle.rs b/voxygen/src/anim/src/character/idle.rs index 58b4a1d2a5..1c9546dc98 100644 --- a/voxygen/src/anim/src/character/idle.rs +++ b/voxygen/src/anim/src/character/idle.rs @@ -93,7 +93,7 @@ impl Animation for IdleAnimation { next.main.position = Vec3::new(0.0, -5.0, 6.0); next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); }, - Some(ToolKind::Staff(_)) | Some(ToolKind::Sceptre(_)) => { + Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { next.main.position = Vec3::new(2.0, -5.0, -1.0); next.main.orientation = Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(1.57); }, diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index d86484ac8f..d9fed33b44 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -272,7 +272,7 @@ impl<'a> Widget for Crafting<'a> { let quality_col = get_quality_col(&*recipe.output.0); Button::image( self.item_imgs - .img_id_or_not_found_img((&*recipe.output.0.kind()).into()), + .img_id_or_not_found_img((&*recipe.output.0).into()), ) .w_h(55.0, 55.0) .label(&output_text) @@ -433,20 +433,17 @@ impl<'a> Widget for Crafting<'a> { frame.set(state.ids.ingredient_frame[i], ui); //Item Image let (title, desc) = super::util::item_text(&**item_def); - Button::image( - self.item_imgs - .img_id_or_not_found_img((&*item_def.kind()).into()), - ) - .w_h(22.0, 22.0) - .middle_of(state.ids.ingredient_frame[i]) - .with_tooltip( - self.tooltip_manager, - title, - &*desc, - &item_tooltip, - quality_col, - ) - .set(state.ids.ingredient_img[i], ui); + Button::image(self.item_imgs.img_id_or_not_found_img((&**item_def).into())) + .w_h(22.0, 22.0) + .middle_of(state.ids.ingredient_frame[i]) + .with_tooltip( + self.tooltip_manager, + title, + &*desc, + &item_tooltip, + quality_col, + ) + .set(state.ids.ingredient_img[i], ui); // Ingredients text and amount // Don't show inventory amounts above 999 to avoid the widget clipping let over9k = "99+"; diff --git a/voxygen/src/hud/item_imgs.rs b/voxygen/src/hud/item_imgs.rs index b86fa53eb8..9ec179e3a0 100644 --- a/voxygen/src/hud/item_imgs.rs +++ b/voxygen/src/hud/item_imgs.rs @@ -3,8 +3,7 @@ use common::{ assets::{self, watch::ReloadIndicator, Asset}, comp::item::{ armor::{Armor, ArmorKind}, - tool::{Tool, ToolKind}, - Glider, ItemKind, Lantern, Throwable, Utility, + Glider, ItemDesc, ItemKind, Lantern, Throwable, Utility, }, figure::Segment, }; @@ -19,7 +18,7 @@ use vek::*; #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ItemKey { - Tool(ToolKind), + Tool(String), Lantern(String), Glider(String), Armor(ArmorKind), @@ -30,10 +29,13 @@ pub enum ItemKey { Empty, } -impl From<&ItemKind> for ItemKey { - fn from(item_kind: &ItemKind) -> Self { +impl From<&T> for ItemKey { + fn from(item_desc: &T) -> Self { + let item_kind = item_desc.kind(); + let item_definition_id = item_desc.item_definition_id(); + match item_kind { - ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()), + ItemKind::Tool(_) => ItemKey::Tool(item_definition_id.to_owned()), ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()), ItemKind::Glider(Glider { kind, .. }) => ItemKey::Glider(kind.clone()), ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()), @@ -140,13 +142,13 @@ impl ItemImgs { } } - pub fn img_id(&self, item_kind: ItemKey) -> Option { - match self.map.get(&item_kind) { + pub fn img_id(&self, item_key: ItemKey) -> Option { + match self.map.get(&item_key) { Some(id) => Some(*id), // There was no specification in the ron None => { warn!( - ?item_kind, + ?item_key, "missing specified image file (note: hot-reloading won't work here)", ); None @@ -154,8 +156,8 @@ impl ItemImgs { } } - pub fn img_id_or_not_found_img(&self, item_kind: ItemKey) -> Id { - self.img_id(item_kind).unwrap_or(self.not_found) + pub fn img_id_or_not_found_img(&self, item_key: ItemKey) -> Id { + self.img_id(item_key).unwrap_or(self.not_found) } } diff --git a/voxygen/src/hud/slots.rs b/voxygen/src/hud/slots.rs index 9fa2a5f280..f6ae54482c 100644 --- a/voxygen/src/hud/slots.rs +++ b/voxygen/src/hud/slots.rs @@ -32,7 +32,7 @@ impl SlotKey for InventorySlot { type ImageKey = ItemKey; fn image_key(&self, source: &Inventory) -> Option<(Self::ImageKey, Option)> { - source.get(self.0).map(|i| (i.kind().into(), None)) + source.get(self.0).map(|i| (i.into(), None)) } fn amount(&self, source: &Inventory) -> Option { @@ -69,7 +69,7 @@ impl SlotKey for EquipSlot { EquipSlot::Glider => source.glider.as_ref(), }; - item.map(|i| (i.kind().into(), None)) + item.map(|i| (i.into(), None)) } fn amount(&self, _: &Loadout) -> Option { None } @@ -103,7 +103,7 @@ impl<'a> SlotKey, HotbarImageSource<'a>> for HotbarSlot { hotbar.get(*self).and_then(|contents| match contents { hotbar::SlotContents::Inventory(idx) => inventory .get(idx) - .map(|item| HotbarImage::Item(item.kind().into())) + .map(|item| HotbarImage::Item(item.into())) .map(|i| (i, None)), hotbar::SlotContents::Ability3 => loadout .active_item diff --git a/voxygen/src/scene/figure/cache.rs b/voxygen/src/scene/figure/cache.rs index 60e48498cf..b405c5b56e 100644 --- a/voxygen/src/scene/figure/cache.rs +++ b/voxygen/src/scene/figure/cache.rs @@ -12,7 +12,6 @@ use common::{ comp::{ item::{ armor::{Armor, ArmorKind}, - tool::ToolKind, ItemKind, }, CharacterState, Loadout, @@ -69,8 +68,8 @@ pub struct FigureKey { /// person or when the character is in a tool-using state). #[derive(Eq, Hash, PartialEq)] pub(super) struct CharacterToolKey { - pub active: Option, - pub second: Option, + pub active: Option, + pub second: Option, } /// Character data that exists in third person only. @@ -180,20 +179,14 @@ impl CharacterCacheKey { }, tool: if are_tools_visible { Some(CharacterToolKey { - active: if let Some(ItemKind::Tool(tool)) = - loadout.active_item.as_ref().map(|i| i.item.kind()) - { - Some(tool.kind.clone()) - } else { - None - }, - second: if let Some(ItemKind::Tool(tool)) = - loadout.second_item.as_ref().map(|i| i.item.kind()) - { - Some(tool.kind.clone()) - } else { - None - }, + active: loadout + .active_item + .as_ref() + .map(|i| i.item.item_definition_id().to_owned()), + second: loadout + .second_item + .as_ref() + .map(|i| i.item.item_definition_id().to_owned()), }) } else { None diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index 77d6bcf7ca..751af13c1a 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -9,7 +9,6 @@ use common::{ fish_medium, fish_small, golem::{self, BodyType as GBodyType, Species as GSpecies}, humanoid::{self, Body, BodyType, EyeColor, Skin, Species}, - item::tool::ToolKind, object, quadruped_low::{self, BodyType as QLBodyType, Species as QLSpecies}, quadruped_medium::{self, BodyType as QMBodyType, Species as QMSpecies}, @@ -327,7 +326,7 @@ struct HumArmorPantsSpec(ArmorVoxSpecMap); #[derive(Deserialize)] struct HumArmorFootSpec(ArmorVoxSpecMap); #[derive(Deserialize)] -struct HumMainWeaponSpec(HashMap); +struct HumMainWeaponSpec(HashMap); #[derive(Deserialize)] struct HumArmorLanternSpec(ArmorVoxSpecMap); #[derive(Deserialize)] @@ -826,11 +825,11 @@ impl HumArmorFootSpec { } impl HumMainWeaponSpec { - fn mesh_main_weapon(&self, tool_kind: &ToolKind, flipped: bool) -> BoneMeshes { - let spec = match self.0.get(tool_kind) { + fn mesh_main_weapon(&self, item_definition_id: &str, flipped: bool) -> BoneMeshes { + let spec = match self.0.get(item_definition_id) { Some(spec) => spec, None => { - error!(?tool_kind, "No tool/weapon specification exists"); + error!(?item_definition_id, "No tool/weapon specification exists"); return load_mesh("not_found", Vec3::new(-1.5, -1.5, -7.0)); }, };