inline std::map<std::string,std::string> getMap(const std::string& obj) { using namespace std; _guard g(m); map<std::string,std::string> res; CSimpleIniA::TNamesDepend keys; ini.GetAllKeys(obj.c_str(), keys); CSimpleIniA::TNamesDepend::const_iterator i; for(i = keys.begin(); i != keys.end(); ++i) { const CSimpleIniA::SI_CHAR_T* _key = i->pItem; const CSimpleIniA::SI_CHAR_T* _val = ini.GetValue(obj.c_str(), _key, NULL); res[std::string(_key)] = std::string(_val); } return res; }
//////////////////////////////////////////////////////////// /// Load & apply some settings //////////////////////////////////////////////////////////// void MainClient::_loadGameSettings(void) { CSimpleIniA ini; if( ini.LoadFile("settings.ini") < 0 ){ throw "Could not open the settings file!"; } //Input .ini file settings info.debug = ini.GetBoolValue("Settings", "debug"); info.mapfile = ini.GetValue("Settings", "map"); info.demoFile = ini.GetValue("Settings", "demo"); info.demoPlay = ini.GetBoolValue("Settings", "play"); info.demoRecord = ini.GetBoolValue("Settings", "record"); info.texturefile = ini.GetValue("Settings", "textures"); info.fullscreen = ini.GetBoolValue("Window", "fullscreen"); info.window_width = ini.GetLongValue("Window", "width"); info.window_height = ini.GetLongValue("Window", "height"); info.cursorfile = ini.GetValue("Window", "cursor"); info.fpslimit = ini.GetLongValue("Graphics", "fpslimit"); info.frameskip = ini.GetLongValue("Graphics", "frameskip"); /* Load the weapon list */ CSimpleIniA weaponlist; weaponlist.LoadFile("assets/weaponlist.ini"); CSimpleIniA::TNamesDepend keys; weaponlist.GetAllKeys("Weapons", keys); //Build Weapon definitions CSimpleIniA::TNamesDepend::const_iterator i; for(i = keys.begin(); i != keys.end(); ++i){ //corresponds to the weapon select menu WeaponList.push_back(weaponlist.GetValue("Weapons", i->pItem)); { //Push back a weapon info object::Weapon::Info winfo; std::string path = WeaponList.back() + "/weapon.ini"; object::Weapon::Info::Load(path.c_str(), &winfo); WeaponInfo.push_back(winfo); } } } //void MainClient::_loadGameSettings(void)