diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-31 01:34:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-31 01:34:38 +0300 |
commit | e826d4c63365dde4c988453846437dcb65370945 (patch) | |
tree | 1bd23d4694c06d97e7e8c885253c0100fe6142b9 /src/defaults.cpp | |
parent | 75ca03c95c90064e67fa9eaddb4c609196dd3a27 (diff) | |
download | mv-e826d4c63365dde4c988453846437dcb65370945.tar.gz mv-e826d4c63365dde4c988453846437dcb65370945.tar.bz2 mv-e826d4c63365dde4c988453846437dcb65370945.tar.xz mv-e826d4c63365dde4c988453846437dcb65370945.zip |
Improve setting default values for configuration objects.
Diffstat (limited to 'src/defaults.cpp')
-rw-r--r-- | src/defaults.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 5a26ba8f8..b77bf1875 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -21,6 +21,7 @@ #include "defaults.h" +#include "configuration.h" #include "graphicsmanager.h" #include "variabledata.h" @@ -82,12 +83,13 @@ VariableData* createData(const bool defData) } #define AddDEF(key, value) \ - configData->insert(std::pair<std::string, VariableData*> \ + configData.insert(std::pair<std::string, VariableData*> \ (key, createData(value))); -DefaultsData* getConfigDefaults() +void setConfigDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("OverlayDetail", 2); AddDEF("speechBubbleAlpha", 1.0F); AddDEF("MostUsedServerName0", "server.themanaworld.org"); @@ -410,13 +412,11 @@ DefaultsData* getConfigDefaults() AddDEF("openglContext", false); AddDEF("allowMoveByMouse", true); AddDEF("enableDSA", true); - return configData; } -void getConfigDefaults2(DefaultsData *const configData) +void setConfigDefaults2(Configuration &cfg) { - if (configData == nullptr) - return; + DefaultsData &configData = cfg.getDefaultValues(); const int density = graphicsManager.getDensity(); int size = 12; int buttonSize = 1; @@ -459,9 +459,10 @@ void getConfigDefaults2(DefaultsData *const configData) } } -DefaultsData* getBrandingDefaults() +void setBrandingDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("wallpapersPath", ""); AddDEF("wallpapersFile", ""); AddDEF("appName", "ManaPlus"); @@ -514,12 +515,12 @@ DefaultsData* getBrandingDefaults() AddDEF("updateMirror5", ""); AddDEF("updateMirror6", ""); AddDEF("updateMirror7", ""); - return configData; } -DefaultsData* getPathsDefaults() +void setPathsDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("itemIcons", "graphics/items/"); AddDEF("unknownItemFile", "unknown-item.png"); AddDEF("sprites", "graphics/sprites/"); @@ -710,19 +711,17 @@ DefaultsData* getPathsDefaults() #endif // TMWA_SUPPORT AddDEF("enableNewMailSystem", true); - - return configData; } -DefaultsData* getFeaturesDefaults() +void setFeaturesDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("languageTab", false); AddDEF("allowFollow", true); AddDEF("fixDeadAnimation", true); AddDEF("forceAccountGender", -1); AddDEF("forceCharGender", -1); - return configData; } #undef AddDEF |