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

Initial draft of tabbed settings window

This commit is contained in:
Dydzio
2023-01-30 20:18:59 +01:00
parent 1898b8218c
commit 9dd692cea4
19 changed files with 226 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 KiB

View File

@@ -0,0 +1,8 @@
{
"basepath" : "buttons/",
"images" :
[
{ "frame" : 0, "file" : "vcmisettingsNormal.png"},
{ "frame" : 1, "file" : "vcmisettingsPressed.png"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1,8 @@
{
"basepath" : "buttons/",
"images" :
[
{ "frame" : 0, "file" : "vcmisettingsbackNormal.png"},
{ "frame" : 1, "file" : "vcmisettingsbackPressed.png"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -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

View File

@@ -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<CAdventureOptions>();
}
void CAdvMapInt::fsystemOptions()
void CAdvMapInt::openSettings()
{
GH.pushIntT<SystemOptionsWindow>();
GH.pushIntT<SettingsMainContainer>();
}
void CAdvMapInt::fnextHero()

View File

@@ -217,7 +217,7 @@ public:
void fmoveHero();
void fshowSpellbok();
void fadventureOPtions();
void fsystemOptions();
void openSettings();
void fnextHero();
void fendTurn();

View File

@@ -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<CTabbedInt>(std::bind(&SettingsMainContainer::createTab, this, _1), Point(50, 50));
}
std::shared_ptr<CIntObject> SettingsMainContainer::createTab(size_t index)
{
switch(index)
{
case 0:
return std::make_shared<SystemOptionsWindow>();
case 1:
return std::make_shared<VcmiSettingsWindow>();
default:
logGlobal->error("Wrong settings tab ID!");
return std::make_shared<CIntObject>();
}
}

View File

@@ -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<CTabbedInt> tabContentArea;
std::shared_ptr<CIntObject> createTab(size_t index);
public:
SettingsMainContainer();
};

View File

@@ -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<CSlider>("musicSlider")->redraw(); });
addCallback("setVolume", [this](int value) { setIntSetting("general", "sound", value); widget<CSlider>("soundVolumeSlider")->redraw(); });
addCallback("openVcmiSettings", [this](int) { showVcmiSettingsButtonCallback(); });
build(config);
std::shared_ptr<CPicture> background = widget<CPicture>("background");
pos.w = background->pos.w;
pos.h = background->pos.h;
pos = center();
// std::shared_ptr<CPicture> background = widget<CPicture>("background");
// pos.w = background->pos.w;
// pos.h = background->pos.h;
// pos = center();
std::shared_ptr<CLabel> resolutionLabel = widget<CLabel>("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<VcmiSettingsWindow>();
}
void SystemOptionsWindow::closeAndPushEvent(int eventType, int code)
{
close();

View File

@@ -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();

View File

@@ -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<SystemOptionsWindow>();
}

View File

@@ -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();
};

View File

@@ -1,14 +1,6 @@
{
"items":
[
{
"name": "background",
"type": "picture",
"playerColored" : true,
"position": {"x": 0, "y": 0},
"image": "SysOpBck"
},
{
"name": "title",
"type": "label",

View File

@@ -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"
}
]
}

View File

@@ -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"
}
]
}