mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-15 01:24:45 +02:00
Make new buttons moddable
This commit is contained in:
@ -92,11 +92,33 @@ CCampaignScreen::CCampaignScreen(const JsonNode & config, std::string name)
|
||||
|
||||
maxPages = (campaigns.size() + campaignsPerPage - 1) / campaignsPerPage;
|
||||
|
||||
buttonNext = std::make_shared<CButton>(Point(340, 560), AnimationPath::builtin("campaigns/next"), std::make_pair("", ""), [this, name]() { switchPage(1, name); });
|
||||
buttonNext->disable();
|
||||
|
||||
buttonPrev = std::make_shared<CButton>(Point(275, 560), AnimationPath::builtin("campaigns/back"), std::make_pair("", ""), [this, name]() { switchPage(-1, name); });
|
||||
|
||||
if (!config[name]["nextbutton"].isNull())
|
||||
{
|
||||
buttonNext = std::make_shared<CButton>(
|
||||
Point((int)config[name]["nextbutton"]["x"].Float(), (int)config[name]["nextbutton"]["y"].Float()),
|
||||
AnimationPath::fromJson(config[name]["nextbutton"]["name"]),
|
||||
std::make_pair("", ""),
|
||||
[this, name]() { switchPage(1, name); }
|
||||
);
|
||||
buttonNext->setHoverable(true);
|
||||
buttonNext->disable();
|
||||
}
|
||||
|
||||
|
||||
if (!config[name]["backbutton"].isNull())
|
||||
{
|
||||
buttonPrev = std::make_shared<CButton>(
|
||||
Point((int)config[name]["backbutton"]["x"].Float(), (int)config[name]["backbutton"]["y"].Float()),
|
||||
AnimationPath::fromJson(config[name]["backbutton"]["name"]),
|
||||
std::make_pair("", ""),
|
||||
[this, name]() { switchPage(-1, name); }
|
||||
);
|
||||
buttonPrev->setHoverable(true);
|
||||
buttonPrev->disable();
|
||||
}
|
||||
|
||||
|
||||
if (!config[name]["exitbutton"].isNull())
|
||||
{
|
||||
@ -232,15 +254,18 @@ void CCampaignScreen::updateCampaignButtons(const JsonNode & parentConfig, const
|
||||
}
|
||||
}
|
||||
|
||||
if(maxId < campaigns.size())
|
||||
if(buttonNext && buttonPrev)
|
||||
{
|
||||
if (maxId < campaigns.size())
|
||||
buttonNext->enable();
|
||||
else
|
||||
buttonNext->disable();
|
||||
|
||||
if(currentPage > 0)
|
||||
if (currentPage > 0)
|
||||
buttonPrev->enable();
|
||||
else
|
||||
buttonPrev->disable();
|
||||
}
|
||||
|
||||
redraw();
|
||||
}
|
@ -64,6 +64,14 @@
|
||||
|
||||
ISelectionScreenInfo * SEL = nullptr;
|
||||
|
||||
static void do_quit()
|
||||
{
|
||||
ENGINE->dispatchMainThread([]()
|
||||
{
|
||||
handleQuit(false);
|
||||
});
|
||||
}
|
||||
|
||||
CMenuScreen::CMenuScreen(const JsonNode & configNode)
|
||||
: CWindowObject(BORDERED), config(configNode)
|
||||
{
|
||||
@ -202,7 +210,7 @@ static std::function<void()> genCommand(CMenuScreen * menu, std::vector<std::str
|
||||
break;
|
||||
case 4: //exit
|
||||
{
|
||||
return []() { CInfoWindow::showYesNoDialog(LIBRARY->generaltexth->allTexts[69], std::vector<std::shared_ptr<CComponent>>(), [](){GAME->onShutdownRequested(false);}, 0, PlayerColor(1)); };
|
||||
return []() { CInfoWindow::showYesNoDialog(LIBRARY->generaltexth->allTexts[69], std::vector<std::shared_ptr<CComponent>>(), do_quit, 0, PlayerColor(1)); };
|
||||
}
|
||||
break;
|
||||
case 5: //highscores
|
||||
|
Reference in New Issue
Block a user