mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-15 13:33:36 +02:00
Interactable hero status - alternative infobox component
This commit is contained in:
parent
484d03334c
commit
ea0ee87299
@ -51,7 +51,11 @@ CInfoBar::VisibleHeroInfo::VisibleHeroInfo(const CGHeroInstance * hero)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
background = std::make_shared<CPicture>("ADSTATHR");
|
||||
heroTooltip = std::make_shared<CHeroTooltip>(Point(0,0), hero);
|
||||
|
||||
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool())
|
||||
heroTooltip = std::make_shared<CInteractableHeroTooltip>(Point(0,0), hero);
|
||||
else
|
||||
heroTooltip = std::make_shared<CHeroTooltip>(Point(0,0), hero);
|
||||
}
|
||||
|
||||
CInfoBar::VisibleTownInfo::VisibleTownInfo(const CGTownInstance * town)
|
||||
@ -274,7 +278,12 @@ void CInfoBar::tick(uint32_t msPassed)
|
||||
void CInfoBar::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
if(state == HERO || state == TOWN)
|
||||
{
|
||||
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool())
|
||||
return;
|
||||
|
||||
showGameStatus();
|
||||
}
|
||||
else if(state == GAME)
|
||||
showDate();
|
||||
else
|
||||
|
@ -25,6 +25,7 @@ class CShowableAnim;
|
||||
class CComponent;
|
||||
class CComponentBox;
|
||||
class CHeroTooltip;
|
||||
class CInteractableHeroTooltip;
|
||||
class CTownTooltip;
|
||||
class CLabel;
|
||||
class CMultiLineLabel;
|
||||
@ -66,7 +67,7 @@ private:
|
||||
|
||||
class VisibleHeroInfo : public CVisibleInfo
|
||||
{
|
||||
std::shared_ptr<CHeroTooltip> heroTooltip;
|
||||
std::variant<std::shared_ptr<CHeroTooltip>, std::shared_ptr<CInteractableHeroTooltip>> heroTooltip;
|
||||
public:
|
||||
VisibleHeroInfo(const CGHeroInstance * hero);
|
||||
};
|
||||
|
@ -303,6 +303,31 @@ CHeroTooltip::CHeroTooltip(Point pos, const CGHeroInstance * hero):
|
||||
init(InfoAboutHero(hero, InfoAboutHero::EInfoLevel::DETAILED));
|
||||
}
|
||||
|
||||
CInteractableHeroTooltip::CInteractableHeroTooltip(Point pos, const CGHeroInstance * hero):
|
||||
CGarrisonInt(pos.x, pos.y+73, 4, Point(0, 0), hero, nullptr, true, true, CGarrisonInt::EGarrisonIntSlotsLayout::REVERSED_TWO_ROWS)
|
||||
{
|
||||
init(InfoAboutHero(hero, InfoAboutHero::EInfoLevel::DETAILED));
|
||||
}
|
||||
|
||||
void CInteractableHeroTooltip::init(const InfoAboutHero & hero)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
portrait = std::make_shared<CAnimImage>("PortraitsLarge", hero.portrait, 0, 3, 2-73);
|
||||
title = std::make_shared<CLabel>(66, 2-73, FONT_SMALL, ETextAlignment::TOPLEFT, Colors::WHITE, hero.name);
|
||||
|
||||
if(hero.details)
|
||||
{
|
||||
for(size_t i = 0; i < hero.details->primskills.size(); i++)
|
||||
labels.push_back(std::make_shared<CLabel>(75 + 28 * (int)i, 58-73, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE,
|
||||
std::to_string(hero.details->primskills[i])));
|
||||
|
||||
labels.push_back(std::make_shared<CLabel>(158, 98-73, FONT_TINY, ETextAlignment::CENTER, Colors::WHITE, std::to_string(hero.details->mana)));
|
||||
|
||||
morale = std::make_shared<CAnimImage>("IMRL22", hero.details->morale + 3, 0, 5, 74-73);
|
||||
luck = std::make_shared<CAnimImage>("ILCK22", hero.details->luck + 3, 0, 5, 91-73);
|
||||
}
|
||||
}
|
||||
|
||||
void CTownTooltip::init(const InfoAboutTown & town)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../gui/CIntObject.h"
|
||||
#include "CGarrisonInt.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
@ -80,6 +81,20 @@ public:
|
||||
CHeroTooltip(Point pos, const CGHeroInstance * hero);
|
||||
};
|
||||
|
||||
/// Class for HD mod-like interactable infobox tooltip. Does not have any background!
|
||||
class CInteractableHeroTooltip : public CGarrisonInt
|
||||
{
|
||||
std::shared_ptr<CLabel> title;
|
||||
std::shared_ptr<CAnimImage> portrait;
|
||||
std::vector<std::shared_ptr<CLabel>> labels;
|
||||
std::shared_ptr<CAnimImage> morale;
|
||||
std::shared_ptr<CAnimImage> luck;
|
||||
|
||||
void init(const InfoAboutHero & hero);
|
||||
public:
|
||||
CInteractableHeroTooltip(Point pos, const CGHeroInstance * hero);
|
||||
};
|
||||
|
||||
/// Class for town tooltip. Does not have any background!
|
||||
/// background for infoBox: ADSTATCS
|
||||
/// background for tooltip: TOWNQVBK
|
||||
|
@ -110,6 +110,10 @@ AdventureOptionsTab::AdventureOptionsTab()
|
||||
{
|
||||
return setBoolSetting("adventure", "borderScroll", value);
|
||||
});
|
||||
addCallback("infoBoxCreatureManagementChanged", [](bool value)
|
||||
{
|
||||
return setBoolSetting("gameTweaks", "infoBoxCreatureManagement", value);
|
||||
});
|
||||
build(config);
|
||||
|
||||
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
|
||||
@ -141,4 +145,7 @@ AdventureOptionsTab::AdventureOptionsTab()
|
||||
|
||||
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
|
||||
borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool());
|
||||
|
||||
std::shared_ptr<CToggleButton> infoBoxCreatureManagementCheckbox = widget<CToggleButton>("infoBoxCreatureManagementCheckbox");
|
||||
infoBoxCreatureManagementCheckbox->setSelected(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool());
|
||||
}
|
||||
|
@ -373,6 +373,11 @@
|
||||
"name": "borderScrollCheckbox",
|
||||
"help": "vcmi.adventureOptions.borderScroll",
|
||||
"callback": "borderScrollChanged"
|
||||
},
|
||||
{
|
||||
"name": "infoBoxCreatureManagementCheckbox",
|
||||
"help": "vcmi.adventureOptions.infoBoxCreatureManagement",
|
||||
"callback": "infoBoxCreatureManagementChanged"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user