1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Minimize changes

This commit is contained in:
George King
2025-03-17 21:59:10 +01:00
committed by GitHub
parent 29ccc70f17
commit 784b5ba09e

View File

@@ -76,10 +76,10 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
if (!images.empty()) if (!images.empty())
{ {
images[0]->center(); images[0]->center(); // move background to center
moveTo(images[0]->pos.topLeft()); moveTo(images[0]->pos.topLeft()); // move everything else to center
images[0]->moveTo(pos.topLeft()); images[0]->moveTo(pos.topLeft()); // restore moved twice background
pos = images[0]->pos; pos = images[0]->pos; // fix height\width of this window
} }
@@ -98,7 +98,6 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
buttonPrev = std::make_shared<CButton>(Point(275, 560), AnimationPath::builtin("campaigns/back"), std::make_pair("", ""), [this, name]() { switchPage(-1, name); }); buttonPrev = std::make_shared<CButton>(Point(275, 560), AnimationPath::builtin("campaigns/back"), std::make_pair("", ""), [this, name]() { switchPage(-1, name); });
buttonPrev->disable(); buttonPrev->disable();
if (!config[name]["exitbutton"].isNull()) if (!config[name]["exitbutton"].isNull())
{ {
buttonBack = createExitButton(config[name]["exitbutton"]); buttonBack = createExitButton(config[name]["exitbutton"]);
@@ -118,16 +117,15 @@ void CCampaignScreen::activate()
std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & button) std::shared_ptr<CButton> CCampaignScreen::createExitButton(const JsonNode & button)
{ {
std::pair<std::string, std::string> help; std::pair<std::string, std::string> help;
if (!button["help"].isNull() && button["help"].Float() > 0) if(!button["help"].isNull() && button["help"].Float() > 0)
help = LIBRARY->generaltexth->zelp[(size_t)button["help"].Float()]; help = LIBRARY->generaltexth->zelp[(size_t)button["help"].Float()];
return std::make_shared<CButton>(Point((int)button["x"].Float(), (int)button["y"].Float()), AnimationPath::fromJson(button["name"]), help, [this]() { close(); }, EShortcut::GLOBAL_CANCEL); return std::make_shared<CButton>(Point((int)button["x"].Float(), (int)button["y"].Float()), AnimationPath::fromJson(button["name"]), help, [this](){ close();}, EShortcut::GLOBAL_CANCEL);
} }
CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const JsonNode & parentConfig, std::string campaignSet) CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const JsonNode & parentConfig, std::string campaignSet)
: campaignSet(campaignSet) : campaignSet(campaignSet)
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;
pos.x += static_cast<int>(config["x"].Float()); pos.x += static_cast<int>(config["x"].Float());
@@ -137,10 +135,9 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const
campFile = config["file"].String(); campFile = config["file"].String();
videoPath = VideoPath::fromJson(config["video"]); videoPath = VideoPath::fromJson(config["video"]);
status = CCampaignScreen::ENABLED; status = CCampaignScreen::ENABLED;
// Check if campaign file exists
if(CResourceHandler::get()->existsResource(ResourcePath(campFile, EResType::CAMPAIGN))) if(CResourceHandler::get()->existsResource(ResourcePath(campFile, EResType::CAMPAIGN)))
{ {
auto header = CampaignHandler::getHeader(campFile); auto header = CampaignHandler::getHeader(campFile);
@@ -154,7 +151,6 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const
status = CCampaignScreen::DISABLED; status = CCampaignScreen::DISABLED;
} }
for(const JsonNode & node : parentConfig[campaignSet]["items"].Vector()) for(const JsonNode & node : parentConfig[campaignSet]["items"].Vector())
{ {
for(const JsonNode & requirement : config["requires"].Vector()) for(const JsonNode & requirement : config["requires"].Vector())
@@ -164,7 +160,7 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const
status = CCampaignScreen::DISABLED; status = CCampaignScreen::DISABLED;
} }
} }
if(persistentStorage["unlockAllCampaigns"].Bool()) if(persistentStorage["unlockAllCampaigns"].Bool())
status = CCampaignScreen::ENABLED; status = CCampaignScreen::ENABLED;
@@ -178,7 +174,6 @@ CCampaignScreen::CCampaignButton::CCampaignButton(const JsonNode & config, const
if(status == CCampaignScreen::COMPLETED) if(status == CCampaignScreen::COMPLETED)
graphicsCompleted = std::make_shared<CPicture>(ImagePath::builtin("CAMPCHK")); graphicsCompleted = std::make_shared<CPicture>(ImagePath::builtin("CAMPCHK"));
} }
void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPosition) void CCampaignScreen::CCampaignButton::clickReleased(const Point & cursorPosition)
@@ -190,7 +185,7 @@ void CCampaignScreen::CCampaignButton::hover(bool on)
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;
if(on && !videoPath.empty()) if (on && !videoPath.empty())
videoPlayer = std::make_shared<VideoWidget>(Point(), videoPath, false); videoPlayer = std::make_shared<VideoWidget>(Point(), videoPath, false);
else else
videoPlayer.reset(); videoPlayer.reset();