-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDriver_GlobalSettings.cpp
55 lines (39 loc) · 1.31 KB
/
Driver_GlobalSettings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#ifndef WORLDSIM_DRIVER_GLOBAL_SETTINGS_CPP
#define WORLDSIM_DRIVER_GLOBAL_SETTINGS_CPP
/* WorldSim: Driver_GlobalSettings.cpp
#include "Driver_GlobalSettings.cpp"
My attempt at moving stuff from a global include into an object which can load ini data.
Obviously everything will lose it's const but what can you do.
*/
#include <File/WTFManager.hpp> // loading raws
#include <algorithm> // replace
#include <string>
class GlobalSettings
{
public:
std::string SAVE_FOLDER_PATH;
std::string SAVE_FOLDER_PATH_FALLBACK; // use this if the custom path is bad.
GlobalSettings()
{
SAVE_FOLDER_PATH = "SAVES";
SAVE_FOLDER_PATH_FALLBACK = "SAVES";
}
void load(std::string settingsData)
{
std::cout<<"\n *** Loading ini data ***\n";
WTFManager iniManager;
iniManager.parse(settingsData);
std::string strSavePath = iniManager.getValue("INI.SAVE_FOLDER_PATH");
// the WTF spec is currently broken and doesn't allow colons, so I'll just use a semicolon and replace it here
// for now
std::replace( strSavePath.begin(), strSavePath.end(), ';', ':'); // replace all semicolons with colon
if ( strSavePath != "" )
{
SAVE_FOLDER_PATH=strSavePath;
}
std::cout<<"SAVE_FOLDER_PATH set to "<<SAVE_FOLDER_PATH<<"\n";
std::cout<<" *** END Loading ini data ***\n\n";
}
};
#endif