mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
Bugfixing
This commit is contained in:
@@ -44,17 +44,17 @@ CComponent::CComponent(ComponentType Type, ComponentSubType Subtype, std::option
|
||||
init(Type, Subtype, Val, imageSize, font, "");
|
||||
}
|
||||
|
||||
CComponent::CComponent(ComponentType Type, ComponentSubType Subtype, std::string Val, ESize imageSize, EFonts font)
|
||||
CComponent::CComponent(ComponentType Type, ComponentSubType Subtype, const std::string & Val, ESize imageSize, EFonts font)
|
||||
{
|
||||
init(Type, Subtype, std::nullopt, imageSize, font, Val);
|
||||
}
|
||||
|
||||
CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
||||
{
|
||||
init(c.type, c.subType, c.value, imageSize, font);
|
||||
init(c.type, c.subType, c.value, imageSize, font, "");
|
||||
}
|
||||
|
||||
void CComponent::init(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts fnt, std::string ValText)
|
||||
void CComponent::init(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts fnt, const std::string & ValText)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
@@ -107,7 +107,7 @@ void CComponent::init(ComponentType Type, ComponentSubType Subtype, std::optiona
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<AnimationPath> CComponent::getFileName()
|
||||
std::vector<AnimationPath> CComponent::getFileName() const
|
||||
{
|
||||
static const std::array<std::string, 4> primSkillsArr = {"PSKIL32", "PSKIL32", "PSKIL42", "PSKILL"};
|
||||
static const std::array<std::string, 4> secSkillsArr = {"SECSK32", "SECSK32", "SECSKILL", "SECSK82"};
|
||||
@@ -160,7 +160,7 @@ std::vector<AnimationPath> CComponent::getFileName()
|
||||
}
|
||||
}
|
||||
|
||||
size_t CComponent::getIndex()
|
||||
size_t CComponent::getIndex() const
|
||||
{
|
||||
switch(data.type)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ size_t CComponent::getIndex()
|
||||
}
|
||||
}
|
||||
|
||||
std::string CComponent::getDescription()
|
||||
std::string CComponent::getDescription() const
|
||||
{
|
||||
switch(data.type)
|
||||
{
|
||||
@@ -242,11 +242,11 @@ std::string CComponent::getDescription()
|
||||
return "";
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::string CComponent::getSubtitle()
|
||||
std::string CComponent::getSubtitle() const
|
||||
{
|
||||
if (!customSubtitle.empty())
|
||||
return customSubtitle;
|
||||
@@ -273,14 +273,14 @@ std::string CComponent::getSubtitle()
|
||||
case ComponentType::RESOURCE:
|
||||
return std::to_string(data.value.value_or(0));
|
||||
case ComponentType::RESOURCE_PER_DAY:
|
||||
return boost::str(boost::format(CGI->generaltexth->allTexts[387]) % data.value.value_or(0));
|
||||
return boost::str(boost::format(CGI->generaltexth->allTexts[3]) % data.value.value_or(0));
|
||||
case ComponentType::CREATURE:
|
||||
{
|
||||
auto creature = CGI->creh->getById(data.subType.as<CreatureID>());
|
||||
if ( data.value.value_or(0) )
|
||||
return std::to_string(data.value.value_or(0)) + " " + (data.value.value_or(0) > 1 ? creature->getNamePluralTranslated() : creature->getNameSingularTranslated());
|
||||
if(data.value)
|
||||
return std::to_string(*data.value) + " " + (*data.value > 1 ? creature->getNamePluralTranslated() : creature->getNameSingularTranslated());
|
||||
else
|
||||
return data.value.value_or(0) > 1 ? creature->getNamePluralTranslated() : creature->getNameSingularTranslated();
|
||||
return creature->getNamePluralTranslated();
|
||||
}
|
||||
case ComponentType::ARTIFACT:
|
||||
return CGI->artifacts()->getById(data.subType.as<ArtifactID>())->getNameTranslated();
|
||||
|
||||
@@ -40,11 +40,11 @@ public:
|
||||
private:
|
||||
std::vector<std::shared_ptr<CLabel>> lines;
|
||||
|
||||
size_t getIndex();
|
||||
std::vector<AnimationPath> getFileName();
|
||||
size_t getIndex() const;
|
||||
std::vector<AnimationPath> getFileName() const;
|
||||
void setSurface(const AnimationPath & defName, int imgPos);
|
||||
|
||||
void init(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts font = FONT_SMALL, std::string ValText="");
|
||||
void init(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val, ESize imageSize, EFonts font, const std::string & ValText);
|
||||
|
||||
public:
|
||||
std::shared_ptr<CAnimImage> image;
|
||||
@@ -53,11 +53,11 @@ public:
|
||||
ESize size; //component size.
|
||||
EFonts font; //Font size of label
|
||||
|
||||
std::string getDescription();
|
||||
std::string getSubtitle();
|
||||
std::string getDescription() const;
|
||||
std::string getSubtitle() const;
|
||||
|
||||
CComponent(ComponentType Type, ComponentSubType Subtype, std::optional<int32_t> Val = std::nullopt, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||
CComponent(ComponentType Type, ComponentSubType Subtype, std::string Val, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||
CComponent(ComponentType Type, ComponentSubType Subtype, const std::string & Val, 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
|
||||
|
||||
@@ -1535,11 +1535,13 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
|
||||
bool canAfford = resourceAmount >= building->resources[i];
|
||||
|
||||
if(!canAfford && state != EBuildingState::ALREADY_PRESENT && settings["general"]["enableUiEnhancements"].Bool())
|
||||
{
|
||||
message.appendRawString("{H3Red|%d}/%d");
|
||||
message.replaceNumber(resourceAmount);
|
||||
}
|
||||
else
|
||||
message.appendRawString("%d");
|
||||
|
||||
message.replaceNumber(resourceAmount);
|
||||
message.replaceNumber(building->resources[i]);
|
||||
components.push_back(std::make_shared<CComponent>(ComponentType::RESOURCE, i, message.toString(), CComponent::small));
|
||||
}
|
||||
|
||||
@@ -799,14 +799,14 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
|
||||
break;
|
||||
case Obj::SPELL_SCROLL:
|
||||
{
|
||||
int spellID = storedArtifact->getScrollSpellID();
|
||||
iw.components.emplace_back(ComponentType::SPELL, spellID);
|
||||
SpellID spell = storedArtifact->getScrollSpellID();
|
||||
iw.components.emplace_back(ComponentType::SPELL, spell);
|
||||
if(!message.empty())
|
||||
iw.text = message;
|
||||
else
|
||||
{
|
||||
iw.text.appendLocalString(EMetaText::ADVOB_TXT,135);
|
||||
iw.text.replaceLocalString(EMetaText::SPELL_NAME, spellID);
|
||||
iw.text.replaceLocalString(EMetaText::SPELL_NAME, spell.getNum());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -201,7 +201,7 @@ void Rewardable::Info::configureReward(Rewardable::Configuration & object, CRand
|
||||
CreatureID from(VLC->identifiers()->getIdentifier(node.second.meta, "creature", node.first).value());
|
||||
CreatureID dest(VLC->identifiers()->getIdentifier(node.second.meta, "creature", node.second.String()).value());
|
||||
|
||||
reward.extraComponents.emplace_back(ComponentType::CREATURE, dest.getNum());
|
||||
reward.extraComponents.emplace_back(ComponentType::CREATURE, dest);
|
||||
|
||||
reward.creaturesChange[from] = dest;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user