diff --git a/Mods/vcmi/Data/vcmiSettingsWindow.png b/Mods/vcmi/Data/vcmiSettingsWindow.png new file mode 100644 index 000000000..9e78d3744 Binary files /dev/null and b/Mods/vcmi/Data/vcmiSettingsWindow.png differ diff --git a/Mods/vcmi/Sprites/buttons/vcmisettings.json b/Mods/vcmi/Sprites/buttons/vcmisettings.json new file mode 100644 index 000000000..33df80f8c --- /dev/null +++ b/Mods/vcmi/Sprites/buttons/vcmisettings.json @@ -0,0 +1,8 @@ +{ + "basepath" : "buttons/", + "images" : + [ + { "frame" : 0, "file" : "vcmisettingsNormal.png"}, + { "frame" : 1, "file" : "vcmisettingsPressed.png"} + ] +} diff --git a/Mods/vcmi/Sprites/buttons/vcmisettingsNormal.png b/Mods/vcmi/Sprites/buttons/vcmisettingsNormal.png new file mode 100644 index 000000000..cea59eed8 Binary files /dev/null and b/Mods/vcmi/Sprites/buttons/vcmisettingsNormal.png differ diff --git a/Mods/vcmi/Sprites/buttons/vcmisettingsPressed.png b/Mods/vcmi/Sprites/buttons/vcmisettingsPressed.png new file mode 100644 index 000000000..3a9dfa967 Binary files /dev/null and b/Mods/vcmi/Sprites/buttons/vcmisettingsPressed.png differ diff --git a/Mods/vcmi/Sprites/buttons/vcmisettingsback.json b/Mods/vcmi/Sprites/buttons/vcmisettingsback.json new file mode 100644 index 000000000..8386ba63f --- /dev/null +++ b/Mods/vcmi/Sprites/buttons/vcmisettingsback.json @@ -0,0 +1,8 @@ +{ + "basepath" : "buttons/", + "images" : + [ + { "frame" : 0, "file" : "vcmisettingsbackNormal.png"}, + { "frame" : 1, "file" : "vcmisettingsbackPressed.png"} + ] +} diff --git a/Mods/vcmi/Sprites/buttons/vcmisettingsbackNormal.png b/Mods/vcmi/Sprites/buttons/vcmisettingsbackNormal.png new file mode 100644 index 000000000..c36d0ec09 Binary files /dev/null and b/Mods/vcmi/Sprites/buttons/vcmisettingsbackNormal.png differ diff --git a/Mods/vcmi/Sprites/buttons/vcmisettingsbackPressed.png b/Mods/vcmi/Sprites/buttons/vcmisettingsbackPressed.png new file mode 100644 index 000000000..ca7824889 Binary files /dev/null and b/Mods/vcmi/Sprites/buttons/vcmisettingsbackPressed.png differ diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 6865b220f..9b7719648 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -51,6 +51,8 @@ set(client_SRCS windows/InfoWindows.cpp windows/QuickRecruitmentWindow.cpp windows/SystemOptionsWindow.cpp + windows/VcmiSettingsWindow.cpp + windows/SettingsMainContainer.cpp mainmenu/CMainMenu.cpp mainmenu/CCampaignScreen.cpp @@ -140,6 +142,8 @@ set(client_HEADERS windows/InfoWindows.h windows/QuickRecruitmentWindow.h windows/SystemOptionsWindow.h + windows/VcmiSettingsWindow.h + windows/SettingsMainContainer.h mainmenu/CMainMenu.h mainmenu/CCampaignScreen.h diff --git a/client/windows/CAdvmapInterface.cpp b/client/windows/CAdvmapInterface.cpp index 7900c22b9..1e05a0678 100644 --- a/client/windows/CAdvmapInterface.cpp +++ b/client/windows/CAdvmapInterface.cpp @@ -36,7 +36,7 @@ #include "../gui/CGuiHandler.h" #include "../gui/SDL_Extensions.h" #include "../widgets/MiscWidgets.h" -#include "../windows/SystemOptionsWindow.h" +#include "../windows/SettingsMainContainer.h" #include "../../CCallback.h" @@ -606,7 +606,7 @@ CAdvMapInt::CAdvMapInt(): moveHero = makeButton(297, std::bind(&CAdvMapInt::fmoveHero,this), ADVOPT.moveHero, SDLK_m); spellbook = makeButton(298, std::bind(&CAdvMapInt::fshowSpellbok,this), ADVOPT.spellbook, SDLK_c); advOptions = makeButton(299, std::bind(&CAdvMapInt::fadventureOPtions,this), ADVOPT.advOptions, SDLK_a); - sysOptions = makeButton(300, std::bind(&CAdvMapInt::fsystemOptions,this), ADVOPT.sysOptions, SDLK_o); + sysOptions = makeButton(300, std::bind(&CAdvMapInt::openSettings, this), ADVOPT.sysOptions, SDLK_o); nextHero = makeButton(301, std::bind(&CAdvMapInt::fnextHero,this), ADVOPT.nextHero, SDLK_h); endTurn = makeButton(302, std::bind(&CAdvMapInt::fendTurn,this), ADVOPT.endTurn, SDLK_e); @@ -816,9 +816,9 @@ void CAdvMapInt::fadventureOPtions() GH.pushIntT(); } -void CAdvMapInt::fsystemOptions() +void CAdvMapInt::openSettings() { - GH.pushIntT(); + GH.pushIntT(); } void CAdvMapInt::fnextHero() diff --git a/client/windows/CAdvmapInterface.h b/client/windows/CAdvmapInterface.h index b605137ba..3d074606d 100644 --- a/client/windows/CAdvmapInterface.h +++ b/client/windows/CAdvmapInterface.h @@ -217,7 +217,7 @@ public: void fmoveHero(); void fshowSpellbok(); void fadventureOPtions(); - void fsystemOptions(); + void openSettings(); void fnextHero(); void fendTurn(); diff --git a/client/windows/SettingsMainContainer.cpp b/client/windows/SettingsMainContainer.cpp new file mode 100644 index 000000000..7111dfd6a --- /dev/null +++ b/client/windows/SettingsMainContainer.cpp @@ -0,0 +1,46 @@ +/* + * SettingsMainContainer.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#include "StdInc.h" + +#include "gui/CGuiHandler.h" +#include "gui/InterfaceObjectConfigurable.h" +#include "SettingsMainContainer.h" +#include "SystemOptionsWindow.h" +#include "VcmiSettingsWindow.h" +#include "../lib/filesystem/ResourceID.h" + + +SettingsMainContainer::SettingsMainContainer() : InterfaceObjectConfigurable() +{ + OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; + //OBJECT_CONSTRUCTION_CAPTURING(255); + + const JsonNode config(ResourceID("config/widgets/settingsMainContainer.json")); + addCallback("activateMainTab", [this](int) { tabContentArea->setActive(0); CIntObject::redraw(); }); + addCallback("activateVcmiSettingsTab", [this](int) { tabContentArea->setActive(1); CIntObject::redraw(); }); + build(config); + + tabContentArea = std::make_shared(std::bind(&SettingsMainContainer::createTab, this, _1), Point(50, 50)); +} + +std::shared_ptr SettingsMainContainer::createTab(size_t index) +{ + switch(index) + { + case 0: + return std::make_shared(); + case 1: + return std::make_shared(); + default: + logGlobal->error("Wrong settings tab ID!"); + return std::make_shared(); + } +} \ No newline at end of file diff --git a/client/windows/SettingsMainContainer.h b/client/windows/SettingsMainContainer.h new file mode 100644 index 000000000..71db04d6f --- /dev/null +++ b/client/windows/SettingsMainContainer.h @@ -0,0 +1,26 @@ +/* + * SettingsMainContainer.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ + +#pragma once + +#include "../widgets/ObjectLists.h" +#include "../widgets/Buttons.h" +#include "gui/InterfaceObjectConfigurable.h" + +class SettingsMainContainer : public InterfaceObjectConfigurable +{ +private: + std::shared_ptr tabContentArea; + + std::shared_ptr createTab(size_t index); +public: + SettingsMainContainer(); +}; + diff --git a/client/windows/SystemOptionsWindow.cpp b/client/windows/SystemOptionsWindow.cpp index 3f3971b39..ec25a4291 100644 --- a/client/windows/SystemOptionsWindow.cpp +++ b/client/windows/SystemOptionsWindow.cpp @@ -20,6 +20,7 @@ #include "../CGameInfo.h" #include "../CMusicHandler.h" #include "../CPlayerInterface.h" +#include "VcmiSettingsWindow.h" #include "GUIClasses.h" #include "CServerHandler.h" #include "lobby/CSavingScreen.h" @@ -65,12 +66,13 @@ SystemOptionsWindow::SystemOptionsWindow() addCallback("setGameResolution", std::bind(&SystemOptionsWindow::selectGameResolution, this)); addCallback("setMusic", [this](int value) { setIntSetting("general", "music", value); widget("musicSlider")->redraw(); }); addCallback("setVolume", [this](int value) { setIntSetting("general", "sound", value); widget("soundVolumeSlider")->redraw(); }); + addCallback("openVcmiSettings", [this](int) { showVcmiSettingsButtonCallback(); }); build(config); - std::shared_ptr background = widget("background"); - pos.w = background->pos.w; - pos.h = background->pos.h; - pos = center(); +// std::shared_ptr background = widget("background"); +// pos.w = background->pos.w; +// pos.h = background->pos.h; +// pos = center(); std::shared_ptr resolutionLabel = widget("resolutionLabel"); const auto & currentResolution = settings["video"]["screenRes"]; @@ -219,6 +221,12 @@ void SystemOptionsWindow::restartGameButtonCallback() LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[67], [this](){ closeAndPushEvent(SDL_USEREVENT, EUserEvent::RESTART_GAME); }, 0); } +void SystemOptionsWindow::showVcmiSettingsButtonCallback() +{ + close(); + GH.pushIntT(); +} + void SystemOptionsWindow::closeAndPushEvent(int eventType, int code) { close(); diff --git a/client/windows/SystemOptionsWindow.h b/client/windows/SystemOptionsWindow.h index e1e9ca2cf..67b8907a2 100644 --- a/client/windows/SystemOptionsWindow.h +++ b/client/windows/SystemOptionsWindow.h @@ -18,12 +18,13 @@ private: SettingsListener onFullscreenChanged; //functions bound to buttons - void loadGameButtonCallback(); //load game - void saveGameButtonCallback(); //save game - void quitGameButtonCallback(); //quit game - void backButtonCallback(); //return to game - void restartGameButtonCallback(); //restart game - void mainMenuButtonCallback(); //return to main menu + void loadGameButtonCallback(); + void saveGameButtonCallback(); + void quitGameButtonCallback(); + void backButtonCallback(); + void restartGameButtonCallback(); + void mainMenuButtonCallback(); + void showVcmiSettingsButtonCallback(); void close(); //TODO: copypaste of WindowBase::close(), consider changing Windowbase to IWindowbase with default close() implementation and changing WindowBase inheritance to CIntObject + IWindowBase void selectGameResolution(); diff --git a/client/windows/VcmiSettingsWindow.cpp b/client/windows/VcmiSettingsWindow.cpp new file mode 100644 index 000000000..2451443f2 --- /dev/null +++ b/client/windows/VcmiSettingsWindow.cpp @@ -0,0 +1,45 @@ +/* + * VcmiSettingsWindow.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#include "StdInc.h" + +#include "VcmiSettingsWindow.h" + +#include "../lib/filesystem/ResourceID.h" +#include "gui/CGuiHandler.h" +#include "SystemOptionsWindow.h" + +VcmiSettingsWindow::VcmiSettingsWindow() : InterfaceObjectConfigurable() +{ + OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE; + + const JsonNode config(ResourceID("config/widgets/vcmiSettings.json")); + addCallback("closeWindow", [this](int) { backButtonCallback(); }); + addCallback("openSystemOptions", [this](int) { openSystemOptionsCallback(); }); + build(config); +} + +void VcmiSettingsWindow::close() +{ + if(GH.topInt().get() != this) + logGlobal->error("Only top interface must be closed"); + GH.popInts(1); +} + +void VcmiSettingsWindow::backButtonCallback() +{ + close(); +} + +void VcmiSettingsWindow::openSystemOptionsCallback() +{ + close(); + GH.pushIntT(); +} + diff --git a/client/windows/VcmiSettingsWindow.h b/client/windows/VcmiSettingsWindow.h new file mode 100644 index 000000000..e2610953d --- /dev/null +++ b/client/windows/VcmiSettingsWindow.h @@ -0,0 +1,23 @@ +/* + * VcmiSettingsWindow.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include "gui/InterfaceObjectConfigurable.h" + +class VcmiSettingsWindow : public InterfaceObjectConfigurable +{ +private: + void close(); //TODO: copypaste of WindowBase::close(), consider changing Windowbase to IWindowbase with default close() implementation and changing WindowBase inheritance to CIntObject + IWindowBase + void backButtonCallback(); + void openSystemOptionsCallback(); + +public: + VcmiSettingsWindow(); +}; diff --git a/config/widgets/optionsMenu.json b/config/widgets/optionsMenu.json index 6334a0e33..3dc07c007 100644 --- a/config/widgets/optionsMenu.json +++ b/config/widgets/optionsMenu.json @@ -1,14 +1,6 @@ { "items": [ - { - "name": "background", - "type": "picture", - "playerColored" : true, - "position": {"x": 0, "y": 0}, - "image": "SysOpBck" - }, - { "name": "title", "type": "label", diff --git a/config/widgets/settingsMainContainer.json b/config/widgets/settingsMainContainer.json new file mode 100644 index 000000000..b8412f151 --- /dev/null +++ b/config/widgets/settingsMainContainer.json @@ -0,0 +1,28 @@ +{ + "items": + [ + { + "name": "background", + "type": "picture", + "image": "vcmiSettingsWindow", + "position": {"x": 0, "y": 0} + }, + { + "name": "activateSystemOptionsButton", + "type": "button", + "position": {"x": 0, "y": 0}, + "image": "buttons/vcmisettings", + "help": "TODO", + "callback": "activateMainTab" + }, + + { + "name": "activateVcmiSettingsButton", + "type": "button", + "position": {"x": 250, "y": 0}, + "image": "buttons/vcmisettings", + "help": "TODO", + "callback": "activateVcmiSettingsTab" + } + ] +} \ No newline at end of file diff --git a/config/widgets/vcmiSettings.json b/config/widgets/vcmiSettings.json new file mode 100644 index 000000000..7294351f5 --- /dev/null +++ b/config/widgets/vcmiSettings.json @@ -0,0 +1,14 @@ +{ + "items": + [ + { + "name": "closeSettingsButton", + "type": "button", + "position": {"x": 357, "y": 415}, + "image": "soretrn.def", + "imageOrder": [1, 0, 2, 3], + "help": "core.help.325", + "callback": "closeWindow" + } + ] +} \ No newline at end of file