mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-06 23:26:26 +02:00
Merge pull request #3037 from Laserlicht/missing_res
This commit is contained in:
commit
ab36692847
@ -42,7 +42,13 @@
|
|||||||
CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font):
|
CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font):
|
||||||
perDay(false)
|
perDay(false)
|
||||||
{
|
{
|
||||||
init(Type, Subtype, Val, imageSize, font);
|
init(Type, Subtype, Val, imageSize, font, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
CComponent::CComponent(Etype Type, int Subtype, std::string Val, ESize imageSize, EFonts font):
|
||||||
|
perDay(false)
|
||||||
|
{
|
||||||
|
init(Type, Subtype, 0, imageSize, font, Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
||||||
@ -54,7 +60,7 @@ CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
|||||||
init((Etype)c.id, c.subtype, c.val, imageSize, font);
|
init((Etype)c.id, c.subtype, c.val, imageSize, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts fnt)
|
void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts fnt, std::string ValText)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
@ -63,6 +69,7 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts
|
|||||||
compType = Type;
|
compType = Type;
|
||||||
subtype = Subtype;
|
subtype = Subtype;
|
||||||
val = Val;
|
val = Val;
|
||||||
|
valText = ValText;
|
||||||
size = imageSize;
|
size = imageSize;
|
||||||
font = fnt;
|
font = fnt;
|
||||||
|
|
||||||
@ -87,6 +94,9 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts
|
|||||||
if (size < small)
|
if (size < small)
|
||||||
max = 30;
|
max = 30;
|
||||||
|
|
||||||
|
if(Type == Etype::resource && !valText.empty())
|
||||||
|
max = 80;
|
||||||
|
|
||||||
std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
|
std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(max, pos.w), font);
|
||||||
for(auto & line : textLines)
|
for(auto & line : textLines)
|
||||||
{
|
{
|
||||||
@ -209,7 +219,7 @@ std::string CComponent::getSubtitleInternal()
|
|||||||
{
|
{
|
||||||
case primskill: return boost::str(boost::format("%+d %s") % val % (subtype < 4 ? CGI->generaltexth->primarySkillNames[subtype] : CGI->generaltexth->allTexts[387]));
|
case primskill: return boost::str(boost::format("%+d %s") % val % (subtype < 4 ? CGI->generaltexth->primarySkillNames[subtype] : CGI->generaltexth->allTexts[387]));
|
||||||
case secskill: return CGI->generaltexth->levels[val-1] + "\n" + CGI->skillh->getByIndex(subtype)->getNameTranslated();
|
case secskill: return CGI->generaltexth->levels[val-1] + "\n" + CGI->skillh->getByIndex(subtype)->getNameTranslated();
|
||||||
case resource: return std::to_string(val);
|
case resource: return valText.empty() ? std::to_string(val) : valText;
|
||||||
case creature:
|
case creature:
|
||||||
{
|
{
|
||||||
auto creature = CGI->creh->getByIndex(subtype);
|
auto creature = CGI->creh->getByIndex(subtype);
|
||||||
|
@ -49,7 +49,7 @@ private:
|
|||||||
void setSurface(const AnimationPath & defName, int imgPos);
|
void setSurface(const AnimationPath & defName, int imgPos);
|
||||||
std::string getSubtitleInternal();
|
std::string getSubtitleInternal();
|
||||||
|
|
||||||
void init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font = FONT_SMALL);
|
void init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font = FONT_SMALL, std::string ValText="");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<CAnimImage> image;
|
std::shared_ptr<CAnimImage> image;
|
||||||
@ -59,12 +59,14 @@ public:
|
|||||||
EFonts font; //Font size of label
|
EFonts font; //Font size of label
|
||||||
int subtype; //type-dependant subtype. See getSomething methods for details
|
int subtype; //type-dependant subtype. See getSomething methods for details
|
||||||
int val; // value \ strength \ amount of component. See getSomething methods for details
|
int val; // value \ strength \ amount of component. See getSomething methods for details
|
||||||
|
std::string valText; // value instead of amount; currently only for resource
|
||||||
bool perDay; // add "per day" text to subtitle
|
bool perDay; // add "per day" text to subtitle
|
||||||
|
|
||||||
std::string getDescription();
|
std::string getDescription();
|
||||||
std::string getSubtitle();
|
std::string getSubtitle();
|
||||||
|
|
||||||
CComponent(Etype Type, int Subtype, int Val = 0, ESize imageSize=large, EFonts font = FONT_SMALL);
|
CComponent(Etype Type, int Subtype, int Val = 0, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||||
|
CComponent(Etype Type, int Subtype, std::string Val, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||||
CComponent(const Component &c, ESize imageSize=large, EFonts font = FONT_SMALL);
|
CComponent(const Component &c, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||||
|
|
||||||
void showPopupWindow(const Point & cursorPosition) override; //call-in
|
void showPopupWindow(const Point & cursorPosition) override; //call-in
|
||||||
|
@ -1477,7 +1477,13 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
|||||||
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
for(int i = 0; i<GameConstants::RESOURCE_QUANTITY; i++)
|
||||||
{
|
{
|
||||||
if(building->resources[i])
|
if(building->resources[i])
|
||||||
components.push_back(std::make_shared<CComponent>(CComponent::resource, i, building->resources[i], CComponent::small));
|
{
|
||||||
|
std::string text = std::to_string(building->resources[i]);
|
||||||
|
int resAfterBuy = LOCPLINT->cb->getResourceAmount(GameResID(i)) - building->resources[i];
|
||||||
|
if(resAfterBuy < 0 && state != EBuildingState::ALREADY_PRESENT && settings["general"]["enableUiEnhancements"].Bool())
|
||||||
|
text = "{H3Red|" + std::to_string(LOCPLINT->cb->getResourceAmount(GameResID(i))) + "}" + " / " + text;
|
||||||
|
components.push_back(std::make_shared<CComponent>(CComponent::resource, i, text, CComponent::small));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cost = std::make_shared<CComponentBox>(components, Rect(25, 300, pos.w - 50, 130));
|
cost = std::make_shared<CComponentBox>(components, Rect(25, 300, pos.w - 50, 130));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user