void Inventory::init() { m_selectedSlotId.first = ""; m_selectedSlotId.second = ItemType::VOID; // init window sf::FloatRect box(INVENTORY_LEFT, GUIConstants::TOP, INVENTORY_WIDTH, INVENTORY_HEIGHT); m_window = new Window(box, WindowOrnamentStyle::FANCY, GUIConstants::MAIN_COLOR, GUIConstants::BACK_COLOR, GUIConstants::ORNAMENT_COLOR); m_descriptionWindow = new ItemDescriptionWindow(); // init text m_selectedTabText.setPosition(sf::Vector2f(INVENTORY_LEFT + GUIConstants::TEXT_OFFSET, GUIConstants::TOP + GUIConstants::TEXT_OFFSET)); m_selectedTabText.setColor(sf::Color::White); m_selectedTabText.setCharacterSize(GUIConstants::CHARACTER_SIZE_M); m_goldText.setPosition(sf::Vector2f(INVENTORY_LEFT + GUIConstants::TEXT_OFFSET, GUIConstants::TOP + INVENTORY_HEIGHT - GUIConstants::TEXT_OFFSET - GUIConstants::CHARACTER_SIZE_S)); m_goldText.setColor(sf::Color::White); m_goldText.setCharacterSize(GUIConstants::CHARACTER_SIZE_M); // fill the helper map m_typeMap.insert({ { ItemType::Consumable, &m_consumableItems }, { ItemType::Misc, &m_miscItems }, { ItemType::Document, &m_documentItems }, { ItemType::Quest, &m_questItems }, { ItemType::Equipment_back, &m_equipmentItems }, { ItemType::Equipment_body, &m_equipmentItems }, { ItemType::Equipment_head, &m_equipmentItems }, { ItemType::Equipment_neck, &m_equipmentItems }, { ItemType::Equipment_ring_1, &m_equipmentItems }, { ItemType::Equipment_ring_2, &m_equipmentItems }, { ItemType::Equipment_weapon, &m_equipmentItems }, }); // init buttons TexturedButton button = TexturedButton(sf::FloatRect(0, 0, BUTTON_SIZE.x, BUTTON_SIZE.y)); m_tabs.push_back(std::pair<TexturedButton, ItemType>(button, ItemType::Equipment_weapon)); m_tabs.push_back(std::pair<TexturedButton, ItemType>(button, ItemType::Consumable)); m_tabs.push_back(std::pair<TexturedButton, ItemType>(button, ItemType::Document)); m_tabs.push_back(std::pair<TexturedButton, ItemType>(button, ItemType::Quest)); m_tabs.push_back(std::pair<TexturedButton, ItemType>(button, ItemType::Misc)); int textureOffset = 0; float xOffset = INVENTORY_LEFT + GUIConstants::TEXT_OFFSET; float yOffset = GUIConstants::TOP + GUIConstants::TEXT_OFFSET + GUIConstants::CHARACTER_SIZE_M + 2 * MARGIN; float buttonMargin = (INVENTORY_WIDTH - 5 * BUTTON_SIZE.x - 2 * GUIConstants::TEXT_OFFSET) / 4.f; for (auto& it : m_tabs) { it.first.setTexture(g_resourceManager->getTexture(ResourceID::Texture_inventorytabs), sf::IntRect(textureOffset, 0, 60, 35)); it.first.setPosition(sf::Vector2f(xOffset, yOffset)); it.first.setBackgroundLayerColor(CENDRIC_COLOR_TRANS_BLACK); it.first.setMainLayerColor(CENDRIC_COLOR_TRANS_BLACK); it.first.setOrnamentLayerColor(CENDRIC_COLOR_DARK_PURPLE); it.first.setMouseOverColor(CENDRIC_COLOR_LIGHT_PURPLE); xOffset += BUTTON_SIZE.x + buttonMargin; textureOffset += 60; } selectTab(ItemType::Consumable); m_equipment = new InventoryEquipment(m_core, m_levelInterface != nullptr); reload(); }
void Spellbook::init() { // init window sf::FloatRect box(GUIConstants::LEFT, GUIConstants::TOP, WIDTH, HEIGHT); m_window = new Window(box, WindowOrnamentStyle::LARGE, GUIConstants::MAIN_COLOR, GUIConstants::BACK_COLOR, GUIConstants::ORNAMENT_COLOR); // init text m_selectedTabText.setPosition(sf::Vector2f(GUIConstants::LEFT + GUIConstants::TEXT_OFFSET, GUIConstants::TOP + GUIConstants::TEXT_OFFSET)); m_selectedTabText.setColor(sf::Color::White); m_selectedTabText.setCharacterSize(GUIConstants::CHARACTER_SIZE_M); // init buttons TexturedButton button = TexturedButton(sf::FloatRect(0, 0, BUTTON_SIZE.x, BUTTON_SIZE.y)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_gems), sf::IntRect(50, 0, 50, 50)); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::VOID)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_GUI_spell_color_elemental), sf::IntRect(50, 50, 400, 400)); button.setTextureColor(CENDRIC_COLOR_ELEMENTAL); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::Elemental)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_GUI_spell_color_divine), sf::IntRect(50, 50, 400, 400)); button.setTextureColor(CENDRIC_COLOR_DIVINE); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::Divine)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_GUI_spell_color_illusion), sf::IntRect(50, 50, 400, 400)); button.setTextureColor(CENDRIC_COLOR_ILLUSION); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::Illusion)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_GUI_spell_color_necromancy), sf::IntRect(50, 50, 400, 400)); button.setTextureColor(CENDRIC_COLOR_NECROMANCY); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::Necromancy)); button.setTexture(g_resourceManager->getTexture(ResourceID::Texture_GUI_spell_color_twilight), sf::IntRect(50, 50, 400, 400)); button.setTextureColor(CENDRIC_COLOR_TWILIGHT); m_tabs.push_back(std::pair<TexturedButton, SpellType>(button, SpellType::Twilight)); float xOffset = GUIConstants::LEFT + GUIConstants::TEXT_OFFSET; float yOffset = GUIConstants::TOP + GUIConstants::TEXT_OFFSET + GUIConstants::CHARACTER_SIZE_M + 2 * MARGIN; float buttonMargin = (WIDTH - 6 * BUTTON_SIZE.x - 2 * GUIConstants::TEXT_OFFSET) / 5.f; for (auto& it : m_tabs) { it.first.setPosition(sf::Vector2f(xOffset, yOffset)); it.first.setBackgroundLayerColor(CENDRIC_COLOR_TRANS_BLACK); it.first.setMainLayerColor(CENDRIC_COLOR_TRANS_BLACK); it.first.setOrnamentLayerColor(CENDRIC_COLOR_DARK_PURPLE); it.first.setMouseOverColor(CENDRIC_COLOR_LIGHT_PURPLE); xOffset += BUTTON_SIZE.x + buttonMargin; } // fill the helper map m_typeMap.insert({ { SpellType::Twilight, &m_twilightSlots }, { SpellType::Divine, &m_divineSlots }, { SpellType::Elemental, &m_elementalSlots }, { SpellType::Illusion, &m_illusionSlots }, { SpellType::Necromancy, &m_necromancySlots } }); selectTab(SpellType::VOID); delete m_weaponWindow; m_weaponWindow = new WeaponWindow(m_core, m_isClickable); reload(); }