1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

button for campaignsets

This commit is contained in:
Laserlicht
2025-09-18 13:25:19 +02:00
parent 9a95f249fa
commit 946e6815cf
7 changed files with 46 additions and 18 deletions

View File

@@ -425,6 +425,7 @@
"vcmi.keyBindings.keyBinding.lobbySelectScenario": "Lobby select scenario",
"vcmi.keyBindings.keyBinding.lobbyToggleChat": "Lobby toggle chat",
"vcmi.keyBindings.keyBinding.lobbyTurnOptions": "Lobby turn options",
"vcmi.keyBindings.keyBinding.lobbyCampaignSets": "Lobby campaign sets",
"vcmi.keyBindings.keyBinding.mainMenuBack": "Main menu back",
"vcmi.keyBindings.keyBinding.mainMenuCampaign": "Main menu campaign",
"vcmi.keyBindings.keyBinding.mainMenuCampaignAb": "Main menu campaign ab",
@@ -848,6 +849,9 @@
"vcmi.optionsTab.simturns.months.1" : " %d month",
"vcmi.optionsTab.simturns.months.2" : " %d months",
"vcmi.selectionTab.campaignSets.hover" : "Campaign sets",
"vcmi.selectionTab.campaignSets.help" : "Multiple campaigns bundeled as set",
"vcmi.optionsTab.extraOptions.hover" : "Extra Options",
"vcmi.optionsTab.extraOptions.help" : "Additional settings for the game",

View File

@@ -434,6 +434,7 @@
"vcmi.keyBindings.keyBinding.lobbySelectScenario": "Lobby Szenario wählen",
"vcmi.keyBindings.keyBinding.lobbyToggleChat": "Lobby Chat umschalten",
"vcmi.keyBindings.keyBinding.lobbyTurnOptions": "Lobby Zugoptionen",
"vcmi.keyBindings.keyBinding.lobbyCampaignSets": "Lobby Kampagnensätze",
"vcmi.keyBindings.keyBinding.mainMenuBack": "Hauptmenü zurück",
"vcmi.keyBindings.keyBinding.mainMenuCampaign": "Hauptmenü Kampagne",
"vcmi.keyBindings.keyBinding.mainMenuCampaignAb": "Hauptmenü Kampagne Ab",
@@ -847,6 +848,9 @@
"vcmi.optionsTab.simturns.months.1" : "%d Monat",
"vcmi.optionsTab.simturns.months.2" : "%d Monate",
"vcmi.selectionTab.campaignSets.hover" : "Kampagnensätze",
"vcmi.selectionTab.campaignSets.help" : "Mehrere Kampagnen gebündelt als Satz",
"vcmi.optionsTab.extraOptions.hover" : "Extra Optionen",
"vcmi.optionsTab.extraOptions.help" : "Zusätzliche Einstellungen für das Spiel",

View File

@@ -97,6 +97,7 @@ enum class EShortcut
LOBBY_RANDOM_TOWN,
LOBBY_RANDOM_TOWN_VS,
LOBBY_HANDICAP,
LOBBY_CAMPAIGN_SETS,
MAPS_SIZE_S,
MAPS_SIZE_M,

View File

@@ -304,6 +304,7 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
{"lobbyRandomTown", EShortcut::LOBBY_RANDOM_TOWN },
{"lobbyRandomTownVs", EShortcut::LOBBY_RANDOM_TOWN_VS },
{"lobbyHandicap", EShortcut::LOBBY_HANDICAP },
{"lobbyCampaignSets", EShortcut::LOBBY_CAMPAIGN_SETS },
{"mapsSizeS", EShortcut::MAPS_SIZE_S },
{"mapsSizeM", EShortcut::MAPS_SIZE_M },
{"mapsSizeL", EShortcut::MAPS_SIZE_L },

View File

@@ -154,15 +154,24 @@ static ESortBy getSortBySelectionScreen(ESelectionScreen Type)
}
SelectionTab::SelectionTab(ESelectionScreen Type)
: CIntObject(LCLICK | SHOW_POPUP | KEYBOARD | DOUBLECLICK), callOnSelect(nullptr), tabType(Type), selectionPos(0), sortModeAscending(true), inputNameRect{32, 539, 350, 20}, curFolder(""), currentMapSizeFilter(0), showRandom(false), deleteMode(false)
: CIntObject(LCLICK | SHOW_POPUP | KEYBOARD | DOUBLECLICK)
, callOnSelect(nullptr)
, tabType(Type)
, selectionPos(0)
, sortModeAscending(true)
, inputNameRect{32, 539, 350, 20}
, curFolder("")
, currentMapSizeFilter(0)
, showRandom(false)
, deleteMode(false)
, enableUiEnhancements(settings["general"]["enableUiEnhancements"].Bool())
, campaignSets(JsonUtils::assembleFromFiles("config/campaignSets.json"))
{
OBJECT_CONSTRUCTION;
generalSortingBy = getSortBySelectionScreen(tabType);
sortingBy = _format;
bool enableUiEnhancements = settings["general"]["enableUiEnhancements"].Bool();
if(tabType != ESelectionScreen::campaignList)
{
background = std::make_shared<CPicture>(ImagePath::builtin("SCSELBCK.bmp"), 0, 6);
@@ -244,6 +253,14 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
if(tabType == ESelectionScreen::newGame)
buttonDeleteMode->setEnabled(false);
}
if(tabType == ESelectionScreen::campaignList)
{
buttonCampaignSet = std::make_shared<CButton>(Point(262, 53), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("", LIBRARY->generaltexth->translate("vcmi.selectionTab.campaignSets.help")), [this]{
showCampaignSetWindow();
}, EShortcut::LOBBY_CAMPAIGN_SETS);
buttonCampaignSet->setTextOverlay(LIBRARY->generaltexth->translate("vcmi.selectionTab.campaignSets.hover"), FONT_SMALL, Colors::WHITE);
}
}
for(int i = 0; i < positionsToShow; i++)
@@ -961,9 +978,6 @@ void SelectionTab::handleUnsupportedSavegames(const std::vector<ResourcePath> &
void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files)
{
auto campaignSets = JsonUtils::assembleFromFiles("config/campaignSets.json");
auto mainmenu = JsonNode(JsonPath::builtin("config/mainmenu.json"));
allItems.reserve(files.size());
for(auto & file : files)
{
@@ -977,22 +991,13 @@ void SelectionTab::parseCampaigns(const std::unordered_set<ResourcePath> & files
if(info->campaign)
{
// skip campaigns organized in sets
std::string foundInSet = "";
bool foundInSet = false;
for (auto const & set : campaignSets.Struct())
for (auto const & item : set.second["items"].Vector())
if(file.getName() == ResourcePath(item["file"].String()).getName())
foundInSet = set.first;
foundInSet = true;
// set has to be used in main menu
bool setInMainmenu = false;
if(!foundInSet.empty())
for (auto const & item : mainmenu["window"]["items"].Vector())
if(item["name"].String() == "campaign")
for (auto const & button : item["buttons"].Vector())
if(boost::algorithm::ends_with(boost::algorithm::to_lower_copy(button["command"].String()), boost::algorithm::to_lower_copy(foundInSet)))
setInMainmenu = true;
if(!setInMainmenu)
if(!foundInSet || !enableUiEnhancements)
allItems.push_back(info);
}
}
@@ -1128,3 +1133,8 @@ void SelectionTab::ListItem::updateItem(std::shared_ptr<ElementInfo> info, bool
labelName->setText(info->name);
labelName->setColor(color);
}
void SelectionTab::showCampaignSetWindow()
{
}

View File

@@ -74,6 +74,8 @@ class SelectionTab : public CIntObject
std::shared_ptr<CAnimation> iconsLossCondition;
std::vector<std::shared_ptr<ListItem>> unSupportedSaves;
JsonNode campaignSets;
public:
std::vector<std::shared_ptr<ElementInfo>> allItems;
std::vector<std::shared_ptr<ElementInfo>> curItems;
@@ -125,6 +127,9 @@ private:
std::shared_ptr<CButton> buttonDeleteMode;
bool deleteMode;
bool enableUiEnhancements;
std::shared_ptr<CButton> buttonCampaignSet;
auto checkSubfolder(std::string path);
bool isMapSupported(const CMapInfo & info);
@@ -133,5 +138,7 @@ private:
void parseCampaigns(const std::unordered_set<ResourcePath> & files);
std::unordered_set<ResourcePath> getFiles(std::string dirURI, EResType resType);
void showCampaignSetWindow();
void handleUnsupportedSavegames(const std::vector<ResourcePath> & files);
};

View File

@@ -154,6 +154,7 @@
"lobbySelectScenario": "S",
"lobbyToggleChat": "C",
"lobbyTurnOptions": "T",
"lobbyCampaignSets": "G",
"mainMenuBack": [ "B", "Escape" ],
"mainMenuCampaign": "C",
"mainMenuCampaignAb": "A",