From 1449a73d2c8421f249559683264e21971a07a7e0 Mon Sep 17 00:00:00 2001 From: hodasemi Date: Sun, 25 Aug 2024 14:30:03 +0200 Subject: [PATCH] Start moving character menu into crate --- Cargo.toml | 4 +- character_window/Cargo.toml | 12 + character_window/resources/menu.xml | 29 + character_window/resources/statistics.xml | 76 +++ .../src/abilities/ability_right_side.rs | 265 +++++++++ character_window/src/abilities/content.rs | 311 ++++++++++ character_window/src/abilities/mod.rs | 281 +++++++++ character_window/src/character/mod.rs | 257 +++++++++ character_window/src/content.rs | 158 +++++ character_window/src/inventory/content.rs | 441 ++++++++++++++ .../src/inventory/item_right_side.rs | 540 ++++++++++++++++++ .../src/inventory/jewel_right_side.rs | 411 +++++++++++++ .../src/inventory/map_right_side.rs | 27 + character_window/src/inventory/mod.rs | 433 ++++++++++++++ character_window/src/lib.rs | 448 +++++++++++++++ character_window/src/page_content.rs | 63 ++ character_window/src/traits.rs | 24 + gavania-core/src/game/game.rs | 8 +- rpg_components/src/items/ability_addon.rs | 12 +- rpg_components/src/items/ability_book.rs | 12 +- rpg_components/src/items/item.rs | 13 +- rpg_components/src/items/jewel.rs | 8 +- rpg_components/src/items/map_item.rs | 4 +- rpg_components/src/items/tooltip.rs | 4 - 24 files changed, 3800 insertions(+), 41 deletions(-) create mode 100644 character_window/Cargo.toml create mode 100644 character_window/resources/menu.xml create mode 100644 character_window/resources/statistics.xml create mode 100644 character_window/src/abilities/ability_right_side.rs create mode 100644 character_window/src/abilities/content.rs create mode 100644 character_window/src/abilities/mod.rs create mode 100644 character_window/src/character/mod.rs create mode 100644 character_window/src/content.rs create mode 100644 character_window/src/inventory/content.rs create mode 100644 character_window/src/inventory/item_right_side.rs create mode 100644 character_window/src/inventory/jewel_right_side.rs create mode 100644 character_window/src/inventory/map_right_side.rs create mode 100644 character_window/src/inventory/mod.rs create mode 100644 character_window/src/lib.rs create mode 100644 character_window/src/page_content.rs create mode 100644 character_window/src/traits.rs diff --git a/Cargo.toml b/Cargo.toml index ef61b0a..ffe1c31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,9 @@ members = [ "scene_update_macros", "transaction_derive", "map", - "rpg_components", "entity_manager", + "rpg_components", + "entity_manager", + "character_window", ] [workspace.dependencies] diff --git a/character_window/Cargo.toml b/character_window/Cargo.toml new file mode 100644 index 0000000..85b4138 --- /dev/null +++ b/character_window/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "character_window" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow = { workspace = true } +paste = { workspace = true } +destructure_traitobject = { workspace = true } + +engine = { path = "../engine" } +rpg_components = { path = "../rpg_components" } \ No newline at end of file diff --git a/character_window/resources/menu.xml b/character_window/resources/menu.xml new file mode 100644 index 0000000..c42201d --- /dev/null +++ b/character_window/resources/menu.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/character_window/resources/statistics.xml b/character_window/resources/statistics.xml new file mode 100644 index 0000000..b3c803d --- /dev/null +++ b/character_window/resources/statistics.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Test + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/character_window/src/abilities/ability_right_side.rs b/character_window/src/abilities/ability_right_side.rs new file mode 100644 index 0000000..b4e5fa2 --- /dev/null +++ b/character_window/src/abilities/ability_right_side.rs @@ -0,0 +1,265 @@ +use std::sync::{Arc, Weak}; + +use rpg_components::components::ability_slots::AbilitySlots; +use rpg_components::components::crafting_materials::CraftingMaterials; +use rpg_components::components::inventory::Storable; +use rpg_components::components::statistics::Statistics; +use rpg_components::items::Rarities; + +use crate::*; + +use crate::{traits::RightSide, CharacterWindow}; + +pub struct AbilityPageRightSide { + snippet: Arc, + + ability_index: usize, +} + +impl AbilityPageRightSide { + const ABILITY_BUTTON_NAMES: [&'static str; 4] = [ + "first_ability", + "second_ability", + "third_ability", + "fourth_ability", + ]; + + pub fn new( + game_handle: &GameHandle, + reference: &Weak, + hero: Entity, + ) -> Result { + let snippet = + game_handle.gui_snippet("gui/xml/ingame/character_menu/abilities/right_side.xml")?; + + let game = game_handle.upgrade(); + let color_settings = &game.item_settings.rarity_color_settings; + + Self::rarity_icon_background(&snippet, "common", color_settings.common)?; + Self::rarity_icon_background(&snippet, "uncommon", color_settings.uncommon)?; + Self::rarity_icon_background(&snippet, "magical", color_settings.magical)?; + Self::rarity_icon_background(&snippet, "rare", color_settings.rare)?; + Self::rarity_icon_background(&snippet, "epic", color_settings.epic)?; + Self::rarity_icon_background(&snippet, "legendary", color_settings.legendary)?; + + for (index, name) in Self::ABILITY_BUTTON_NAMES.iter().enumerate() { + let button: Arc