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());
|
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetaString::appendName(const HeroTypeID & id)
|
|
||||||
{
|
|
||||||
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MetaString::appendName(const SpellID & id)
|
void MetaString::appendName(const SpellID & id)
|
||||||
{
|
{
|
||||||
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
appendTextID(id.toEntity(LIBRARY)->getNameTextID());
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class SecondarySkill;
|
|||||||
class SpellID;
|
class SpellID;
|
||||||
class FactionID;
|
class FactionID;
|
||||||
class GameResID;
|
class GameResID;
|
||||||
class HeroTypeID;
|
|
||||||
using TQuantity = si32;
|
using TQuantity = si32;
|
||||||
|
|
||||||
/// Strings classes that can be used as replacement in MetaString
|
/// Strings classes that can be used as replacement in MetaString
|
||||||
@@ -81,7 +80,6 @@ public:
|
|||||||
void appendNumber(int64_t value);
|
void appendNumber(int64_t value);
|
||||||
|
|
||||||
void appendName(const ArtifactID& id);
|
void appendName(const ArtifactID& id);
|
||||||
void appendName(const HeroTypeID& id);
|
|
||||||
void appendName(const SpellID& id);
|
void appendName(const SpellID& id);
|
||||||
void appendName(const PlayerColor& id);
|
void appendName(const PlayerColor& id);
|
||||||
void appendName(const CreatureID & id, TQuantity count);
|
void appendName(const CreatureID & id, TQuantity count);
|
||||||
|
|||||||
@@ -141,17 +141,13 @@ void CampaignEditor::changed()
|
|||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CampaignEditor::saveCampaign()
|
void CampaignEditor::saveCampaign()
|
||||||
{
|
{
|
||||||
if(campaignState->mapPieces.size() != campaignState->campaignRegions.regions.size())
|
if(campaignState->mapPieces.size() != campaignState->campaignRegions.regions.size())
|
||||||
{
|
logGlobal->trace("Not all regions have a map");
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
Helper::saveCampaign(campaignState, filename);
|
Helper::saveCampaign(campaignState, filename);
|
||||||
return true;
|
unsaved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CampaignEditor::showCampaignEditor()
|
void CampaignEditor::showCampaignEditor()
|
||||||
@@ -194,8 +190,7 @@ void CampaignEditor::on_actionSave_as_triggered()
|
|||||||
filenameSelect += ".vcmp";
|
filenameSelect += ".vcmp";
|
||||||
|
|
||||||
filename = filenameSelect;
|
filename = filenameSelect;
|
||||||
if(saveCampaign())
|
saveCampaign();
|
||||||
unsaved = false;
|
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,8 +221,8 @@ void CampaignEditor::on_actionSave_triggered()
|
|||||||
|
|
||||||
if(filename.isNull())
|
if(filename.isNull())
|
||||||
on_actionSave_as_triggered();
|
on_actionSave_as_triggered();
|
||||||
else if(saveCampaign())
|
else
|
||||||
unsaved = false;
|
saveCampaign();
|
||||||
setTitle();
|
setTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ private:
|
|||||||
bool getAnswerAboutUnsavedChanges();
|
bool getAnswerAboutUnsavedChanges();
|
||||||
void setTitle();
|
void setTitle();
|
||||||
void changed();
|
void changed();
|
||||||
bool saveCampaign();
|
void saveCampaign();
|
||||||
|
|
||||||
void closeEvent(QCloseEvent *event) override;
|
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)
|
QString StartingBonus::getBonusListTitle(CampaignBonus bonus, std::shared_ptr<CMap> map)
|
||||||
{
|
{
|
||||||
auto getHeroName = [](int id){
|
auto getHeroName = [map](int id){
|
||||||
MetaString tmp;
|
MetaString tmp;
|
||||||
if(id == HeroTypeID::CAMP_STRONGEST)
|
if(id == HeroTypeID::CAMP_STRONGEST)
|
||||||
tmp.appendRawString(tr("strongest hero").toStdString());
|
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)
|
else if(id == HeroTypeID::CAMP_RANDOM)
|
||||||
tmp.appendRawString(tr("random hero").toStdString());
|
tmp.appendRawString(tr("random hero").toStdString());
|
||||||
else
|
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());
|
return QString::fromStdString(tmp.toString());
|
||||||
};
|
};
|
||||||
auto getSpellName = [](int id){
|
auto getSpellName = [](int id){
|
||||||
|
|||||||
Reference in New Issue
Block a user