|
9 | 9 | #include <vector> |
10 | 10 |
|
11 | 11 | Settings* Settings::sInstance = NULL; |
12 | | -static std::string mEmptyString = ""; |
13 | 12 |
|
14 | 13 | // these values are NOT saved to es_settings.xml |
15 | 14 | // since they're set through command-line arguments, and not the in-program settings menu |
@@ -279,55 +278,20 @@ void Settings::processBackwardCompatibility() |
279 | 278 |
|
280 | 279 |
|
281 | 280 | //Print a warning message if the setting we're trying to get doesn't already exist in the map, then return the value in the map. |
282 | | -#define SETTINGS_GETSET(type, mapName, getMethodName, setMethodName, defaultValue) type Settings::getMethodName(const std::string& name) \ |
| 281 | +#define SETTINGS_GETSET(type, mapName, getMethodName, setMethodName) type Settings::getMethodName(const std::string& name) \ |
283 | 282 | { \ |
284 | 283 | if(mapName.find(name) == mapName.cend()) \ |
285 | 284 | { \ |
286 | | - /* LOG(LogError) << "Tried to use unset setting " << name << "!"; */ \ |
287 | | - return defaultValue; \ |
| 285 | + LOG(LogError) << "Tried to use unset setting " << name << "!"; \ |
288 | 286 | } \ |
289 | 287 | return mapName[name]; \ |
290 | 288 | } \ |
291 | | -bool Settings::setMethodName(const std::string& name, type value) \ |
| 289 | +void Settings::setMethodName(const std::string& name, type value) \ |
292 | 290 | { \ |
293 | | - if(mapName.count(name) == 0 || mapName[name] != value) { \ |
294 | 291 | mapName[name] = value; \ |
295 | | -\ |
296 | | - if(std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), name) == settings_dont_save.cend()) \ |
297 | | - mWasChanged = true; \ |
298 | | -\ |
299 | | - return true; \ |
300 | | - } \ |
301 | | - return false; \ |
302 | | -} |
303 | | - |
304 | | -SETTINGS_GETSET(bool, mBoolMap, getBool, setBool, false); |
305 | | -SETTINGS_GETSET(int, mIntMap, getInt, setInt, 0); |
306 | | -SETTINGS_GETSET(float, mFloatMap, getFloat, setFloat, 0.0f); |
307 | | - |
308 | | - |
309 | | -std::string Settings::getString(const std::string& name) |
310 | | -{ |
311 | | - if(mStringMap.find(name) == mStringMap.cend()) |
312 | | - return mEmptyString; |
313 | | - |
314 | | - return mStringMap[name]; |
315 | 292 | } |
316 | 293 |
|
317 | | -bool Settings::setString(const std::string& name, const std::string& value) |
318 | | -{ |
319 | | - if(mStringMap.count(name) == 0 || mStringMap[name] != value) |
320 | | - { |
321 | | - if(value == "" && mStringMap.count(name) == 0) |
322 | | - return false; |
323 | | - |
324 | | - mStringMap[name] = value; |
325 | | - |
326 | | - if(std::find(settings_dont_save.cbegin(), settings_dont_save.cend(), name) == settings_dont_save.cend()) |
327 | | - mWasChanged = true; |
328 | | - |
329 | | - return true; |
330 | | - } |
331 | | - |
332 | | - return false; |
333 | | -} |
| 294 | +SETTINGS_GETSET(bool, mBoolMap, getBool, setBool); |
| 295 | +SETTINGS_GETSET(int, mIntMap, getInt, setInt); |
| 296 | +SETTINGS_GETSET(float, mFloatMap, getFloat, setFloat); |
| 297 | +SETTINGS_GETSET(const std::string&, mStringMap, getString, setString); |
0 commit comments