From c8b6d6a684e0b3b9721f5eb8788c02ade3b8c8a6 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:40:56 +0100 Subject: [PATCH] add extra button for campaigns --- client/lobby/CBonusSelection.cpp | 15 +++++++++++++-- client/lobby/CBonusSelection.h | 4 ++++ client/lobby/OptionsTabBase.cpp | 9 ++++++++- client/lobby/OptionsTabBase.h | 2 +- config/widgets/extraOptionsTab.json | 7 +++++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index 0939e776b..21de1f104 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -15,6 +15,7 @@ #include #include "CSelectionBase.h" +#include "ExtraOptionsTab.h" #include "../CGameInfo.h" #include "../CMusicHandler.h" @@ -103,8 +104,8 @@ CBonusSelection::CBonusSelection() if(getCampaign()->playerSelectedDifficulty()) { - buttonDifficultyLeft = std::make_shared(Point(694, 508), AnimationPath::builtin("SCNRBLF.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::decreaseDifficulty, this)); - buttonDifficultyRight = std::make_shared(Point(738, 508), AnimationPath::builtin("SCNRBRT.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::increaseDifficulty, this)); + buttonDifficultyLeft = std::make_shared(settings["general"]["enableUiEnhancements"].Bool() ? Point(693, 470) : Point(694, 508), AnimationPath::builtin("SCNRBLF.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::decreaseDifficulty, this)); + buttonDifficultyRight = std::make_shared(settings["general"]["enableUiEnhancements"].Bool() ? Point(739, 470) : Point(738, 508), AnimationPath::builtin("SCNRBRT.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::increaseDifficulty, this)); } for(auto scenarioID : getCampaign()->allScenarios()) @@ -117,6 +118,16 @@ CBonusSelection::CBonusSelection() if (!getCampaign()->getMusic().empty()) CCS->musich->playMusic( getCampaign()->getMusic(), true, false); + + if(settings["general"]["enableUiEnhancements"].Bool()) + { + tabExtraOptions = std::make_shared(); + tabExtraOptions->recActions = UPDATE | SHOWALL | LCLICK | RCLICK_POPUP; + tabExtraOptions->recreate(true); + tabExtraOptions->setEnabled(false); + buttonExtraOptions = std::make_shared(Point(642, 509), AnimationPath::builtin("GSPBUT2.DEF"), CGI->generaltexth->zelp[46], [this]{ tabExtraOptions->setEnabled(!tabExtraOptions->isActive()); GH.windows().totalRedraw(); }, EShortcut::NONE); + buttonExtraOptions->addTextOverlay(CGI->generaltexth->translate("vcmi.optionsTab.extraOptions.hover"), FONT_SMALL, Colors::WHITE); + } } void CBonusSelection::createBonusesIcons() diff --git a/client/lobby/CBonusSelection.h b/client/lobby/CBonusSelection.h index 394c3b81b..989e459b3 100644 --- a/client/lobby/CBonusSelection.h +++ b/client/lobby/CBonusSelection.h @@ -27,6 +27,7 @@ class CAnimImage; class CLabel; class CFlagBox; class ISelectionScreenInfo; +class ExtraOptionsTab; /// Campaign screen where you can choose one out of three starting bonuses class CBonusSelection : public CWindowObject @@ -82,4 +83,7 @@ public: std::shared_ptr buttonDifficultyLeft; std::shared_ptr buttonDifficultyRight; std::shared_ptr iconsMapSizes; + + std::shared_ptr tabExtraOptions; + std::shared_ptr buttonExtraOptions; }; diff --git a/client/lobby/OptionsTabBase.cpp b/client/lobby/OptionsTabBase.cpp index a89943dc8..bb150efe7 100644 --- a/client/lobby/OptionsTabBase.cpp +++ b/client/lobby/OptionsTabBase.cpp @@ -12,6 +12,7 @@ #include "CSelectionBase.h" #include "../widgets/ComboBox.h" +#include "../widgets/Images.h" #include "../widgets/Slider.h" #include "../widgets/TextControls.h" #include "../CServerHandler.h" @@ -295,7 +296,7 @@ OptionsTabBase::OptionsTabBase(const JsonPath & configPath) } } -void OptionsTabBase::recreate() +void OptionsTabBase::recreate(bool campaign) { auto const & generateSimturnsDurationText = [](int days) -> std::string { @@ -417,4 +418,10 @@ void OptionsTabBase::recreate() buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay); buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame); } + + if(auto textureCampaignOverdraw = widget("textureCampaignOverdraw")) + { + if(!campaign) + textureCampaignOverdraw->disable(); + } } diff --git a/client/lobby/OptionsTabBase.h b/client/lobby/OptionsTabBase.h index dc7bf63f2..15c6372c9 100644 --- a/client/lobby/OptionsTabBase.h +++ b/client/lobby/OptionsTabBase.h @@ -28,5 +28,5 @@ class OptionsTabBase : public InterfaceObjectConfigurable public: OptionsTabBase(const JsonPath & configPath); - void recreate(); + void recreate(bool campaign = false); }; diff --git a/config/widgets/extraOptionsTab.json b/config/widgets/extraOptionsTab.json index d8a333b9c..91b41bced 100644 --- a/config/widgets/extraOptionsTab.json +++ b/config/widgets/extraOptionsTab.json @@ -9,6 +9,13 @@ "image": "ADVOPTBK", "position": {"x": 0, "y": 6} }, + { + "name": "textureCampaignOverdraw", + "type": "texture", + "color" : "blue", + "image": "DIBOXBCK", + "rect": {"x": 391, "y": 14, "w": 82, "h": 569} + }, { "name": "labelTitle", "type": "label",