mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
Interactable hero status - alternative infobox component
This commit is contained in:
@@ -51,7 +51,11 @@ CInfoBar::VisibleHeroInfo::VisibleHeroInfo(const CGHeroInstance * hero)
|
|||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
background = std::make_shared<CPicture>("ADSTATHR");
|
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)
|
CInfoBar::VisibleTownInfo::VisibleTownInfo(const CGTownInstance * town)
|
||||||
@@ -274,7 +278,12 @@ void CInfoBar::tick(uint32_t msPassed)
|
|||||||
void CInfoBar::clickReleased(const Point & cursorPosition)
|
void CInfoBar::clickReleased(const Point & cursorPosition)
|
||||||
{
|
{
|
||||||
if(state == HERO || state == TOWN)
|
if(state == HERO || state == TOWN)
|
||||||
|
{
|
||||||
|
if(settings["gameTweaks"]["infoBoxCreatureManagement"].Bool())
|
||||||
|
return;
|
||||||
|
|
||||||
showGameStatus();
|
showGameStatus();
|
||||||
|
}
|
||||||
else if(state == GAME)
|
else if(state == GAME)
|
||||||
showDate();
|
showDate();
|
||||||
else
|
else
|
||||||
|
@@ -25,6 +25,7 @@ class CShowableAnim;
|
|||||||
class CComponent;
|
class CComponent;
|
||||||
class CComponentBox;
|
class CComponentBox;
|
||||||
class CHeroTooltip;
|
class CHeroTooltip;
|
||||||
|
class CInteractableHeroTooltip;
|
||||||
class CTownTooltip;
|
class CTownTooltip;
|
||||||
class CLabel;
|
class CLabel;
|
||||||
class CMultiLineLabel;
|
class CMultiLineLabel;
|
||||||
@@ -66,7 +67,7 @@ private:
|
|||||||
|
|
||||||
class VisibleHeroInfo : public CVisibleInfo
|
class VisibleHeroInfo : public CVisibleInfo
|
||||||
{
|
{
|
||||||
std::shared_ptr<CHeroTooltip> heroTooltip;
|
std::variant<std::shared_ptr<CHeroTooltip>, std::shared_ptr<CInteractableHeroTooltip>> heroTooltip;
|
||||||
public:
|
public:
|
||||||
VisibleHeroInfo(const CGHeroInstance * hero);
|
VisibleHeroInfo(const CGHeroInstance * hero);
|
||||||
};
|
};
|
||||||
|
@@ -303,6 +303,31 @@ CHeroTooltip::CHeroTooltip(Point pos, const CGHeroInstance * hero):
|
|||||||
init(InfoAboutHero(hero, InfoAboutHero::EInfoLevel::DETAILED));
|
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)
|
void CTownTooltip::init(const InfoAboutTown & town)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../gui/CIntObject.h"
|
#include "../gui/CIntObject.h"
|
||||||
|
#include "CGarrisonInt.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -80,6 +81,20 @@ public:
|
|||||||
CHeroTooltip(Point pos, const CGHeroInstance * hero);
|
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!
|
/// Class for town tooltip. Does not have any background!
|
||||||
/// background for infoBox: ADSTATCS
|
/// background for infoBox: ADSTATCS
|
||||||
/// background for tooltip: TOWNQVBK
|
/// background for tooltip: TOWNQVBK
|
||||||
|
@@ -110,6 +110,10 @@ AdventureOptionsTab::AdventureOptionsTab()
|
|||||||
{
|
{
|
||||||
return setBoolSetting("adventure", "borderScroll", value);
|
return setBoolSetting("adventure", "borderScroll", value);
|
||||||
});
|
});
|
||||||
|
addCallback("infoBoxCreatureManagementChanged", [](bool value)
|
||||||
|
{
|
||||||
|
return setBoolSetting("gameTweaks", "infoBoxCreatureManagement", value);
|
||||||
|
});
|
||||||
build(config);
|
build(config);
|
||||||
|
|
||||||
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
|
std::shared_ptr<CToggleGroup> playerHeroSpeedToggle = widget<CToggleGroup>("heroMovementSpeedPicker");
|
||||||
@@ -141,4 +145,7 @@ AdventureOptionsTab::AdventureOptionsTab()
|
|||||||
|
|
||||||
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
|
std::shared_ptr<CToggleButton> borderScrollCheckbox = widget<CToggleButton>("borderScrollCheckbox");
|
||||||
borderScrollCheckbox->setSelected(settings["adventure"]["borderScroll"].Bool());
|
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",
|
"name": "borderScrollCheckbox",
|
||||||
"help": "vcmi.adventureOptions.borderScroll",
|
"help": "vcmi.adventureOptions.borderScroll",
|
||||||
"callback": "borderScrollChanged"
|
"callback": "borderScrollChanged"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "infoBoxCreatureManagementCheckbox",
|
||||||
|
"help": "vcmi.adventureOptions.infoBoxCreatureManagement",
|
||||||
|
"callback": "infoBoxCreatureManagementChanged"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user