1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

add extra button for campaigns

This commit is contained in:
Laserlicht
2024-02-07 21:40:56 +01:00
parent b319d16de6
commit c8b6d6a684
5 changed files with 33 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
#include <vcmi/spells/Service.h> #include <vcmi/spells/Service.h>
#include "CSelectionBase.h" #include "CSelectionBase.h"
#include "ExtraOptionsTab.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CMusicHandler.h" #include "../CMusicHandler.h"
@@ -103,8 +104,8 @@ CBonusSelection::CBonusSelection()
if(getCampaign()->playerSelectedDifficulty()) if(getCampaign()->playerSelectedDifficulty())
{ {
buttonDifficultyLeft = std::make_shared<CButton>(Point(694, 508), AnimationPath::builtin("SCNRBLF.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::decreaseDifficulty, this)); buttonDifficultyLeft = std::make_shared<CButton>(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<CButton>(Point(738, 508), AnimationPath::builtin("SCNRBRT.DEF"), CButton::tooltip(), std::bind(&CBonusSelection::increaseDifficulty, this)); buttonDifficultyRight = std::make_shared<CButton>(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()) for(auto scenarioID : getCampaign()->allScenarios())
@@ -117,6 +118,16 @@ CBonusSelection::CBonusSelection()
if (!getCampaign()->getMusic().empty()) if (!getCampaign()->getMusic().empty())
CCS->musich->playMusic( getCampaign()->getMusic(), true, false); CCS->musich->playMusic( getCampaign()->getMusic(), true, false);
if(settings["general"]["enableUiEnhancements"].Bool())
{
tabExtraOptions = std::make_shared<ExtraOptionsTab>();
tabExtraOptions->recActions = UPDATE | SHOWALL | LCLICK | RCLICK_POPUP;
tabExtraOptions->recreate(true);
tabExtraOptions->setEnabled(false);
buttonExtraOptions = std::make_shared<CButton>(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() void CBonusSelection::createBonusesIcons()

View File

@@ -27,6 +27,7 @@ class CAnimImage;
class CLabel; class CLabel;
class CFlagBox; class CFlagBox;
class ISelectionScreenInfo; class ISelectionScreenInfo;
class ExtraOptionsTab;
/// Campaign screen where you can choose one out of three starting bonuses /// Campaign screen where you can choose one out of three starting bonuses
class CBonusSelection : public CWindowObject class CBonusSelection : public CWindowObject
@@ -82,4 +83,7 @@ public:
std::shared_ptr<CButton> buttonDifficultyLeft; std::shared_ptr<CButton> buttonDifficultyLeft;
std::shared_ptr<CButton> buttonDifficultyRight; std::shared_ptr<CButton> buttonDifficultyRight;
std::shared_ptr<CAnimImage> iconsMapSizes; std::shared_ptr<CAnimImage> iconsMapSizes;
std::shared_ptr<ExtraOptionsTab> tabExtraOptions;
std::shared_ptr<CButton> buttonExtraOptions;
}; };

View File

@@ -12,6 +12,7 @@
#include "CSelectionBase.h" #include "CSelectionBase.h"
#include "../widgets/ComboBox.h" #include "../widgets/ComboBox.h"
#include "../widgets/Images.h"
#include "../widgets/Slider.h" #include "../widgets/Slider.h"
#include "../widgets/TextControls.h" #include "../widgets/TextControls.h"
#include "../CServerHandler.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 auto const & generateSimturnsDurationText = [](int days) -> std::string
{ {
@@ -417,4 +418,10 @@ void OptionsTabBase::recreate()
buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay); buttonUnlimitedReplay->setSelectedSilent(SEL->getStartInfo()->extraOptionsInfo.unlimitedReplay);
buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame); buttonUnlimitedReplay->block(SEL->screenType == ESelectionScreen::loadGame);
} }
if(auto textureCampaignOverdraw = widget<CFilledTexture>("textureCampaignOverdraw"))
{
if(!campaign)
textureCampaignOverdraw->disable();
}
} }

View File

@@ -28,5 +28,5 @@ class OptionsTabBase : public InterfaceObjectConfigurable
public: public:
OptionsTabBase(const JsonPath & configPath); OptionsTabBase(const JsonPath & configPath);
void recreate(); void recreate(bool campaign = false);
}; };

View File

@@ -9,6 +9,13 @@
"image": "ADVOPTBK", "image": "ADVOPTBK",
"position": {"x": 0, "y": 6} "position": {"x": 0, "y": 6}
}, },
{
"name": "textureCampaignOverdraw",
"type": "texture",
"color" : "blue",
"image": "DIBOXBCK",
"rect": {"x": 391, "y": 14, "w": 82, "h": 569}
},
{ {
"name": "labelTitle", "name": "labelTitle",
"type": "label", "type": "label",