mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Page identification when needed
This commit is contained in:
@@ -81,7 +81,6 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
|||||||
images[0]->moveTo(pos.topLeft()); // restore moved twice background
|
images[0]->moveTo(pos.topLeft()); // restore moved twice background
|
||||||
pos = images[0]->pos; // fix height\width of this window
|
pos = images[0]->pos; // fix height\width of this window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const auto& node : campaigns)
|
for (const auto& node : campaigns)
|
||||||
{
|
{
|
||||||
@@ -91,8 +90,6 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
maxPages = (campaigns.size() + campaignsPerPage - 1) / campaignsPerPage;
|
maxPages = (campaigns.size() + campaignsPerPage - 1) / campaignsPerPage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!config[name]["nextbutton"].isNull())
|
if (!config[name]["nextbutton"].isNull())
|
||||||
{
|
{
|
||||||
@@ -106,7 +103,6 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
|||||||
buttonNext->disable();
|
buttonNext->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!config[name]["backbutton"].isNull())
|
if (!config[name]["backbutton"].isNull())
|
||||||
{
|
{
|
||||||
buttonPrev = std::make_shared<CButton>(
|
buttonPrev = std::make_shared<CButton>(
|
||||||
@@ -119,6 +115,7 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
|||||||
buttonPrev->disable();
|
buttonPrev->disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
page = std::make_shared<CLabel>(10, 570, FONT_MEDIUM, ETextAlignment::BOTTOMLEFT, Colors::YELLOW, "");
|
||||||
|
|
||||||
if (!config[name]["exitbutton"].isNull())
|
if (!config[name]["exitbutton"].isNull())
|
||||||
{
|
{
|
||||||
@@ -256,6 +253,8 @@ void CCampaignScreen::updateCampaignButtons(const JsonNode & parentConfig)
|
|||||||
|
|
||||||
if(buttonNext && buttonPrev)
|
if(buttonNext && buttonPrev)
|
||||||
{
|
{
|
||||||
|
page->setText(std::to_string(currentPage + 1) + "/" + std::to_string(maxPages));
|
||||||
|
|
||||||
if (maxId < campaigns.size())
|
if (maxId < campaigns.size())
|
||||||
buttonNext->enable();
|
buttonNext->enable();
|
||||||
else
|
else
|
||||||
|
@@ -58,6 +58,7 @@ private:
|
|||||||
std::shared_ptr<CButton> buttonBack;
|
std::shared_ptr<CButton> buttonBack;
|
||||||
std::shared_ptr<CButton> buttonNext;
|
std::shared_ptr<CButton> buttonNext;
|
||||||
std::shared_ptr<CButton> buttonPrev;
|
std::shared_ptr<CButton> buttonPrev;
|
||||||
|
std::shared_ptr<CLabel> page;
|
||||||
|
|
||||||
std::shared_ptr<CButton> createExitButton(const JsonNode & button);
|
std::shared_ptr<CButton> createExitButton(const JsonNode & button);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user