1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Sort out settings files structure

This commit is contained in:
Dydzio 2023-02-12 17:49:41 +01:00
parent 7430616ada
commit 58bed920b4
13 changed files with 80 additions and 43 deletions

View File

@ -91,10 +91,11 @@ set(client_SRCS
windows/GUIClasses.cpp
windows/InfoWindows.cpp
windows/QuickRecruitmentWindow.cpp
windows/settings/SystemOptionsWindow.cpp
windows/settings/GeneralOptionsTab.cpp
windows/settings/VcmiSettingsWindow.cpp
windows/settings/SettingsMainContainer.cpp
windows/settings/BattleOptionsWindow.cpp
windows/settings/BattleOptionsTab.cpp
windows/settings/AdventureOptionsTab.cpp
CGameInfo.cpp
CMT.cpp
@ -207,10 +208,11 @@ set(client_HEADERS
windows/GUIClasses.h
windows/InfoWindows.h
windows/QuickRecruitmentWindow.h
windows/settings/SystemOptionsWindow.h
windows/settings/GeneralOptionsTab.h
windows/settings/VcmiSettingsWindow.h
windows/settings/SettingsMainContainer.h
windows/settings/BattleOptionsWindow.h
windows/settings/BattleOptionsTab.h
windows/settings/AdventureOptionsTab.h
CGameInfo.h
CMT.h

View File

@ -0,0 +1,16 @@
/*
* AdventureOptionsTab.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 "AdventureOptionsTab.h"
AdventureOptionsTab::AdventureOptionsTab()
{
}

View File

@ -0,0 +1,19 @@
/*
* AdventureOptionsTab.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 AdventureOptionsTab : InterfaceObjectConfigurable
{
public:
AdventureOptionsTab();
};

View File

@ -1,5 +1,5 @@
/*
* BattleOptionsWindow.cpp, part of VCMI engine
* BattleOptionsTab.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
@ -9,7 +9,7 @@
*/
#include "StdInc.h"
#include "BattleOptionsWindow.h"
#include "BattleOptionsTab.h"
#include "CConfigHandler.h"
#include "../../gui/CGuiHandler.h"
@ -18,16 +18,16 @@
#include "../../widgets/Buttons.h"
#include "../../widgets/TextControls.h"
BattleOptionsWindow::BattleOptionsWindow(BattleInterface * owner):
BattleOptionsTab::BattleOptionsTab(BattleInterface * owner):
InterfaceObjectConfigurable()
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/battleOptionsWindow.json"));
addCallback("viewGridChanged", std::bind(&BattleOptionsWindow::viewGridChangedCallback, this, _1, owner));
addCallback("movementShadowChanged", std::bind(&BattleOptionsWindow::movementShadowChangedCallback, this, _1, owner));
addCallback("mouseShadowChanged", std::bind(&BattleOptionsWindow::mouseShadowChangedCallback, this, _1));
addCallback("animationSpeedChanged", std::bind(&BattleOptionsWindow::animationSpeedChangedCallback, this, _1));
const JsonNode config(ResourceID("config/widgets/settings/battleOptionsTab.json"));
addCallback("viewGridChanged", std::bind(&BattleOptionsTab::viewGridChangedCallback, this, _1, owner));
addCallback("movementShadowChanged", std::bind(&BattleOptionsTab::movementShadowChangedCallback, this, _1, owner));
addCallback("mouseShadowChanged", std::bind(&BattleOptionsTab::mouseShadowChangedCallback, this, _1));
addCallback("animationSpeedChanged", std::bind(&BattleOptionsTab::animationSpeedChangedCallback, this, _1));
build(config);
std::shared_ptr<CToggleGroup> animationSpeedToggle = widget<CToggleGroup>("animationSpeedPicker");
@ -44,7 +44,7 @@ BattleOptionsWindow::BattleOptionsWindow(BattleInterface * owner):
mouseShadowCheckbox->setSelected((bool)settings["battle"]["mouseShadow"].Bool());
}
int BattleOptionsWindow::getAnimSpeed() const
int BattleOptionsTab::getAnimSpeed() const
{
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-battle-speed"].isNull())
return static_cast<int>(std::round(settings["session"]["spectate-battle-speed"].Float()));
@ -52,7 +52,7 @@ int BattleOptionsWindow::getAnimSpeed() const
return static_cast<int>(std::round(settings["battle"]["speedFactor"].Float()));
}
void BattleOptionsWindow::viewGridChangedCallback(bool value, BattleInterface * parentBattleInterface)
void BattleOptionsTab::viewGridChangedCallback(bool value, BattleInterface * parentBattleInterface)
{
Settings cellBorders = settings.write["battle"]["cellBorders"];
cellBorders->Bool() = value;
@ -60,7 +60,7 @@ void BattleOptionsWindow::viewGridChangedCallback(bool value, BattleInterface *
parentBattleInterface->redrawBattlefield();
}
void BattleOptionsWindow::movementShadowChangedCallback(bool value, BattleInterface * parentBattleInterface)
void BattleOptionsTab::movementShadowChangedCallback(bool value, BattleInterface * parentBattleInterface)
{
Settings stackRange = settings.write["battle"]["stackRange"];
stackRange->Bool() = value;
@ -68,13 +68,13 @@ void BattleOptionsWindow::movementShadowChangedCallback(bool value, BattleInterf
parentBattleInterface->redrawBattlefield();
}
void BattleOptionsWindow::mouseShadowChangedCallback(bool value)
void BattleOptionsTab::mouseShadowChangedCallback(bool value)
{
Settings shadow = settings.write["battle"]["mouseShadow"];
shadow->Bool() = value;
}
void BattleOptionsWindow::animationSpeedChangedCallback(int value)
void BattleOptionsTab::animationSpeedChangedCallback(int value)
{
Settings speed = settings.write["battle"]["speedFactor"];
speed->Float() = float(value);

View File

@ -1,5 +1,5 @@
/*
* BattleOptionsWindow.h, part of VCMI engine
* BattleOptionsTab.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
@ -12,7 +12,7 @@
#include "../../gui/InterfaceObjectConfigurable.h"
#include "../../battle/BattleInterface.h"
class BattleOptionsWindow : public InterfaceObjectConfigurable
class BattleOptionsTab : public InterfaceObjectConfigurable
{
private:
std::shared_ptr<CToggleGroup> animSpeeds;
@ -24,7 +24,7 @@ private:
void mouseShadowChangedCallback(bool value);
void animationSpeedChangedCallback(int value);
public:
BattleOptionsWindow(BattleInterface * owner = nullptr);
BattleOptionsTab(BattleInterface * owner = nullptr);
};

View File

@ -1,5 +1,5 @@
/*
* SystemOptionsWindow.cpp, part of VCMI engine
* GeneralOptionsTab.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
@ -9,7 +9,7 @@
*/
#include "StdInc.h"
#include "SystemOptionsWindow.h"
#include "GeneralOptionsTab.h"
#include <SDL_surface.h>
#include <SDL_rect.h>
@ -46,21 +46,21 @@ static std::string resolutionToString(int w, int h)
return std::to_string(w) + 'x' + std::to_string(h);
}
SystemOptionsWindow::SystemOptionsWindow()
GeneralOptionsTab::GeneralOptionsTab()
: InterfaceObjectConfigurable(),
onFullscreenChanged(settings.listen["video"]["fullscreen"])
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/optionsMenu.json"));
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
addCallback("playerHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "heroSpeed", _1));
addCallback("enemyHeroSpeedChanged", std::bind(&setIntSetting, "adventure", "enemySpeed", _1));
addCallback("mapScrollSpeedChanged", std::bind(&setIntSetting, "adventure", "scrollSpeed", _1));
addCallback("heroReminderChanged", std::bind(&setBoolSetting, "adventure", "heroReminder", _1));
addCallback("quickCombatChanged", std::bind(&setBoolSetting, "adventure", "quickCombat", _1));
addCallback("spellbookAnimationChanged", std::bind(&setBoolSetting, "video", "spellbookAnimation", _1));
addCallback("fullscreenChanged", std::bind(&SystemOptionsWindow::setFullscreenMode, this, _1));
addCallback("setGameResolution", std::bind(&SystemOptionsWindow::selectGameResolution, this));
addCallback("fullscreenChanged", std::bind(&GeneralOptionsTab::setFullscreenMode, this, _1));
addCallback("setGameResolution", std::bind(&GeneralOptionsTab::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(); });
build(config);
@ -105,12 +105,12 @@ SystemOptionsWindow::SystemOptionsWindow()
}
bool SystemOptionsWindow::isResolutionSupported(const Point & resolution)
bool GeneralOptionsTab::isResolutionSupported(const Point & resolution)
{
return isResolutionSupported( resolution, settings["video"]["fullscreen"].Bool());
}
bool SystemOptionsWindow::isResolutionSupported(const Point & resolution, bool fullscreen)
bool GeneralOptionsTab::isResolutionSupported(const Point & resolution, bool fullscreen)
{
if (!fullscreen)
return true;
@ -120,7 +120,7 @@ bool SystemOptionsWindow::isResolutionSupported(const Point & resolution, bool f
return CSDL_Ext::isResolutionSupported(supportedList, resolution);
}
void SystemOptionsWindow::selectGameResolution()
void GeneralOptionsTab::selectGameResolution()
{
fillSelectableResolutions();
@ -139,11 +139,11 @@ void SystemOptionsWindow::selectGameResolution()
GH.pushIntT<CObjectListWindow>(items, nullptr,
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.hover"),
CGI->generaltexth->translate("vcmi.systemOptions.resolutionMenu.help"),
std::bind(&SystemOptionsWindow::setGameResolution, this, _1),
std::bind(&GeneralOptionsTab::setGameResolution, this, _1),
currentResolutionIndex);
}
void SystemOptionsWindow::setGameResolution(int index)
void GeneralOptionsTab::setGameResolution(int index)
{
assert(index >= 0 && index < selectableResolutions.size());
@ -163,7 +163,7 @@ void SystemOptionsWindow::setGameResolution(int index)
widget<CLabel>("resolutionLabel")->setText(resText);
}
void SystemOptionsWindow::setFullscreenMode(bool on)
void GeneralOptionsTab::setFullscreenMode(bool on)
{
fillSelectableResolutions();
@ -193,7 +193,7 @@ void SystemOptionsWindow::setFullscreenMode(bool on)
}
}
void SystemOptionsWindow::fillSelectableResolutions()
void GeneralOptionsTab::fillSelectableResolutions()
{
selectableResolutions.clear();

View File

@ -1,5 +1,5 @@
/*
* SystemOptionsWindow.h, part of VCMI engine
* GeneralOptionsTab.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
@ -12,7 +12,7 @@
#include "../../../lib/CConfigHandler.h"
#include "../../gui/InterfaceObjectConfigurable.h"
class SystemOptionsWindow : public InterfaceObjectConfigurable
class GeneralOptionsTab : public InterfaceObjectConfigurable
{
private:
SettingsListener onFullscreenChanged;
@ -29,5 +29,5 @@ private:
void setGameResolution(int index);
public:
SystemOptionsWindow();
GeneralOptionsTab();
};

View File

@ -13,9 +13,9 @@
#include "SettingsMainContainer.h"
#include "SystemOptionsWindow.h"
#include "GeneralOptionsTab.h"
#include "VcmiSettingsWindow.h"
#include "BattleOptionsWindow.h"
#include "BattleOptionsTab.h"
#include "filesystem/ResourceID.h"
#include "CGeneralTextHandler.h"
@ -31,7 +31,7 @@ SettingsMainContainer::SettingsMainContainer(BattleInterface * parentBattleUi) :
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/settingsMainContainer.json"));
const JsonNode config(ResourceID("config/widgets/settings/settingsMainContainer.json"));
addCallback("activateMainTab", [this](int) { openTab(0); });
addCallback("activateBattleSettingsTab", [this](int) { openTab(1); });
addCallback("activateVcmiSettingsTab", [this](int) { openTab(2); });
@ -78,14 +78,14 @@ std::shared_ptr<CIntObject> SettingsMainContainer::createTab(size_t index)
switch(index)
{
case 0:
return std::make_shared<SystemOptionsWindow>();
return std::make_shared<GeneralOptionsTab>();
case 1:
return std::make_shared<BattleOptionsWindow>(parentBattleInterface);
return std::make_shared<BattleOptionsTab>(parentBattleInterface);
case 2:
return std::make_shared<VcmiSettingsWindow>();
default:
logGlobal->error("Wrong settings tab ID!");
return std::make_shared<SystemOptionsWindow>();
return std::make_shared<GeneralOptionsTab>();
}
}

View File

@ -18,7 +18,7 @@ VcmiSettingsWindow::VcmiSettingsWindow() : InterfaceObjectConfigurable()
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
const JsonNode config(ResourceID("config/widgets/vcmiSettings.json"));
const JsonNode config(ResourceID("config/widgets/settings/vcmiSettingsTab.json"));
build(config);
}