mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
code review
This commit is contained in:
@@ -37,18 +37,11 @@ CampaignRegions::RegionDescription CampaignRegions::RegionDescription::fromJson(
|
||||
{
|
||||
CampaignRegions::RegionDescription rd;
|
||||
rd.infix = node["infix"].String();
|
||||
rd.xpos = static_cast<int>(node["x"].Float());
|
||||
rd.ypos = static_cast<int>(node["y"].Float());
|
||||
rd.pos = Point(static_cast<int>(node["x"].Float()), static_cast<int>(node["y"].Float()));
|
||||
if(!node["labelPos"].isNull())
|
||||
{
|
||||
rd.xLabelpos = static_cast<int>(node["labelPos"]["x"].Float());
|
||||
rd.yLabelpos = static_cast<int>(node["labelPos"]["y"].Float());
|
||||
}
|
||||
rd.labelPos = Point(static_cast<int>(node["labelPos"]["x"].Float()), static_cast<int>(node["labelPos"]["y"].Float()));
|
||||
else
|
||||
{
|
||||
rd.xLabelpos = std::nullopt;
|
||||
rd.yLabelpos = std::nullopt;
|
||||
}
|
||||
rd.labelPos = std::nullopt;
|
||||
return rd;
|
||||
}
|
||||
|
||||
@@ -90,16 +83,13 @@ ImagePath CampaignRegions::getBackgroundName() const
|
||||
Point CampaignRegions::getPosition(CampaignScenarioID which) const
|
||||
{
|
||||
auto const & region = regions[which.getNum()];
|
||||
return Point(region.xpos, region.ypos);
|
||||
return region.pos;
|
||||
}
|
||||
|
||||
std::optional<Point> CampaignRegions::getLabelPosition(CampaignScenarioID which) const
|
||||
{
|
||||
auto const & region = regions[which.getNum()];
|
||||
if(region.xLabelpos && region.yLabelpos)
|
||||
return Point(*region.xLabelpos, *region.yLabelpos);
|
||||
else
|
||||
return std::nullopt;
|
||||
return region.labelPos;
|
||||
}
|
||||
|
||||
ImagePath CampaignRegions::getNameFor(CampaignScenarioID which, int colorIndex, std::string type) const
|
||||
|
||||
Reference in New Issue
Block a user