mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
code review
This commit is contained in:
@@ -358,11 +358,6 @@ void MetaString::appendName(const ArtifactID & id)
|
||||
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
||||
}
|
||||
|
||||
void MetaString::appendName(const HeroTypeID & id)
|
||||
{
|
||||
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
||||
}
|
||||
|
||||
void MetaString::appendName(const SpellID & id)
|
||||
{
|
||||
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
||||
|
||||
@@ -23,7 +23,6 @@ class SecondarySkill;
|
||||
class SpellID;
|
||||
class FactionID;
|
||||
class GameResID;
|
||||
class HeroTypeID;
|
||||
using TQuantity = si32;
|
||||
|
||||
/// Strings classes that can be used as replacement in MetaString
|
||||
@@ -81,7 +80,6 @@ public:
|
||||
void appendNumber(int64_t value);
|
||||
|
||||
void appendName(const ArtifactID& id);
|
||||
void appendName(const HeroTypeID& id);
|
||||
void appendName(const SpellID& id);
|
||||
void appendName(const PlayerColor& id);
|
||||
void appendName(const CreatureID & id, TQuantity count);
|
||||
|
||||
@@ -141,17 +141,13 @@ void CampaignEditor::changed()
|
||||
setTitle();
|
||||
}
|
||||
|
||||
bool CampaignEditor::saveCampaign()
|
||||
void CampaignEditor::saveCampaign()
|
||||
{
|
||||
if(campaignState->mapPieces.size() != campaignState->campaignRegions.regions.size())
|
||||
{
|
||||
auto reply = QMessageBox::question(nullptr, tr("Maps missing"), tr("Not all regions have a map. Do you want to continue?"), QMessageBox::Yes|QMessageBox::No);
|
||||
if (reply != QMessageBox::Yes)
|
||||
return false;
|
||||
}
|
||||
logGlobal->trace("Not all regions have a map");
|
||||
|
||||
Helper::saveCampaign(campaignState, filename);
|
||||
return true;
|
||||
unsaved = false;
|
||||
}
|
||||
|
||||
void CampaignEditor::showCampaignEditor()
|
||||
@@ -194,8 +190,7 @@ void CampaignEditor::on_actionSave_as_triggered()
|
||||
filenameSelect += ".vcmp";
|
||||
|
||||
filename = filenameSelect;
|
||||
if(saveCampaign())
|
||||
unsaved = false;
|
||||
saveCampaign();
|
||||
setTitle();
|
||||
}
|
||||
|
||||
@@ -226,8 +221,8 @@ void CampaignEditor::on_actionSave_triggered()
|
||||
|
||||
if(filename.isNull())
|
||||
on_actionSave_as_triggered();
|
||||
else if(saveCampaign())
|
||||
unsaved = false;
|
||||
else
|
||||
saveCampaign();
|
||||
setTitle();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
bool getAnswerAboutUnsavedChanges();
|
||||
void setTitle();
|
||||
void changed();
|
||||
bool saveCampaign();
|
||||
void saveCampaign();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ bool StartingBonus::showStartingBonus(PlayerColor color, std::shared_ptr<CMap> m
|
||||
|
||||
QString StartingBonus::getBonusListTitle(CampaignBonus bonus, std::shared_ptr<CMap> map)
|
||||
{
|
||||
auto getHeroName = [](int id){
|
||||
auto getHeroName = [map](int id){
|
||||
MetaString tmp;
|
||||
if(id == HeroTypeID::CAMP_STRONGEST)
|
||||
tmp.appendRawString(tr("strongest hero").toStdString());
|
||||
@@ -292,7 +292,12 @@ QString StartingBonus::getBonusListTitle(CampaignBonus bonus, std::shared_ptr<CM
|
||||
else if(id == HeroTypeID::CAMP_RANDOM)
|
||||
tmp.appendRawString(tr("random hero").toStdString());
|
||||
else
|
||||
tmp.appendName(HeroTypeID(id));
|
||||
{
|
||||
for(auto o : map->objects)
|
||||
if(auto * ins = dynamic_cast<CGHeroInstance *>(o.get()))
|
||||
if(ins->getHeroTypeID().getNum() == id)
|
||||
tmp.appendTextID(ins->getNameTextID());
|
||||
}
|
||||
return QString::fromStdString(tmp.toString());
|
||||
};
|
||||
auto getSpellName = [](int id){
|
||||
|
||||
Reference in New Issue
Block a user