void save_options(struct app_runtime_t *app, Options *options, char *config_file_path) { if ((!config_file_path) || (!strcmp(config_file_path, ""))) { return; } int rc = -1; int buf_size = 8*1024*1024; char *buffer = (char*) malloc(buf_size); memset(buffer, 0, buf_size); CSimpleIniA ini; ini.SetUnicode(); int is_write = formatOptions(options, buffer, buf_size); if (is_write != OPTIONS_WRITE) { goto SAVE_QUIT; } rc = ini.LoadData(buffer, strlen(buffer)); if (rc < 0) { s_logger.log_e(&s_logger, "APP: Load Options Error."); } rc = ini.SaveFile(config_file_path); if (rc < 0) { s_logger.log_e(&s_logger, "APP: Save Options Error."); } SAVE_QUIT: if (buffer != NULL) { free(buffer); buffer = NULL; } }
ApplicationConfiguration::ApplicationConfiguration(LPCSTR configurationFile) { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(configurationFile); _isInViewSourceMode = ini.GetBoolValue("Debug", "ViewSource", false, false); }
void ScriptSettings::Save() const { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(SETTINGSFILE); ini.SetValue("OPTIONS", "Enable", EnableManual ? " 1" : " 0"); ini.SetLongValue("OPTIONS", "ShiftMode", ShiftMode); ini.SaveFile(SETTINGSFILE); }
bool TestStreams() { const char * rgszTestFile[3] = { "test1-input.ini", "test1-output.ini", "test1-expected.ini" }; Test oTest("TestStreams"); CSimpleIniA ini; ini.SetUnicode(true); ini.SetMultiKey(true); ini.SetMultiLine(true); // load the file try { std::ifstream infile; infile.open(rgszTestFile[0], std::ifstream::in | std::ifstream::binary); if (ini.Load(infile) < 0) throw false; infile.close(); } catch (...) { return oTest.Failure("Failed to load file"); } // standard contents test //if (!StandardContentsTest(ini, oTest)) { // return false; //} // save the file try { std::ofstream outfile; outfile.open(rgszTestFile[1], std::ofstream::out | std::ofstream::binary); if (ini.Save(outfile, true) < 0) throw false; outfile.close(); } catch (...) { return oTest.Failure("Failed to save file"); } // file comparison test if (!FileComparisonTest(rgszTestFile[1], rgszTestFile[2])) { return oTest.Failure("Failed file comparison"); } if (!FileLoadTest(rgszTestFile[1], rgszTestFile[2])) { return oTest.Failure("Failed file load comparison"); } return oTest.Success(); }
int main(int argc, const char *argv[]) { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile("myfile.ini"); const char * pVal = ini.GetValue("section", "key", "default"); ini.SetValue("section", "key", "newvalue"); std::string strData; ini.Save(strData); printf("strData.c_str(): %s\n", strData.c_str()); return 0; }
int main(void) { CSimpleIniA ini; const char* filename="test.ini"; ini.SetUnicode(); ini.LoadFile(filename); ini.SetValue("node1","foo","foonew"); const char* inivalue=ini.GetValue("node1","foo",NULL); printf("%s\n",inivalue); printf("end!\n"); bool b=false; ini.SaveFile(filename,b); ini.Reset(); return 0; }
void parseIniFile(const string& filepath) throw(TCLAP::ArgException) { CSimpleIniA inireader; inireader.SetUnicode(); inireader.LoadFile(filepath.c_str()); if(inireader.IsEmpty()) throw(TCLAP::ArgException("Ini-File not found!", "-i")); _RESULT_DIRECTORY_NAME_ = inireader.GetValue("detection", "result_directory_name", DEFAULT_RESULT_DIRECTORY_NAME); _WRITE_PROBABILITY_MAPS_ = inireader.GetBoolValue("detection", "write_probability_maps", DEFAULT_WRITE_PROBABILITY_MAPS); _FILENAME_RESULT_SUFFIX_ = inireader.GetValue("detection", "filename_result_suffix", DEFAULT_FILENAME_RESULT_SUFFIX); _PROB_MAP_RESULT_SUFFIX_ = inireader.GetValue("detection", "prob_map_result_suffix", DEFAULT_PROB_MAP_RESULT_SUFFIX); _MAX_BOUNDINGBOX_OVERLAP_ = inireader.GetDoubleValue("detection", "max_boundingbox_overlap", DEFAULT_MAX_BOUNDINGBOX_OVERLAP); #ifndef PERFORM_EVALUATION _DETECTION_DEFAULT_THRESHOLD_ = inireader.GetValue("detection", "detection_default_threshold", DEFAULT_DETECTION_DEFAULT_THRESHOLD); _DETECTION_LABEL_THRESHOLDS_ = inireader.GetValue("detection", "detection_label_thresholds", DEFAULT_DETECTION_LABEL_THRESHOLDS); _DETECTION_LABELS_ = inireader.GetValue("detection", "detection_labels", DEFAULT_DETECTION_LABELS); #else _DETECTION_DEFAULT_THRESHOLD_ = "0.15"; _DETECTION_LABEL_THRESHOLDS_ = ""; _DETECTION_LABELS_ = ""; #endif _LABEL_DELIMITER_ = inireader.GetValue("training", "label_delimiter", DEFAULT_LABEL_DELIMITER); _MAX_BOOTSTRAP_STAGES_ = inireader.GetLongValue("training", "max_bootstrap_stages", DEFAULT_MAX_BOOTSTRAP_STAGES); _PATCH_WINDOW_SIZE_ = inireader.GetLongValue("common", "patch_window_size", DEFAULT_PATCH_SIZE); _IMG_FILE_EXTENTIONS_ = inireader.GetValue("common", "file_extentions", DEFAULT_IMG_FILE_EXTENTIONS); _BACKGROUND_LABEL_ = inireader.GetLongValue("common", "background_label", DEAFULT_BACKGROUND_LABEL); // cout << "Ini-file: " << endl; // DEBUG_COUT_VAR(_RESULT_DIRECTORY_NAME_); // DEBUG_COUT_VAR(_WRITE_PROBABILITY_MAPS_); // DEBUG_COUT_VAR(_FILENAME_RESULT_SUFFIX_); // DEBUG_COUT_VAR(_PROB_MAP_RESULT_SUFFIX_); // DEBUG_COUT_VAR(_MAX_BOUNDINGBOX_OVERLAP_); // DEBUG_COUT_VAR(_DETECTION_DEFAULT_THRESHOLD_); // DEBUG_COUT_VAR(_DETECTION_LABEL_THRESHOLDS_); // DEBUG_COUT_VAR(_DETECTION_LABELS_); // DEBUG_COUT_VAR(_LABEL_DELIMITER_); // DEBUG_COUT_VAR(_MAX_BOOTSTRAP_STAGES_); // DEBUG_COUT_VAR(_PATCH_WINDOW_SIZE_); // DEBUG_COUT_VAR(_IMG_FILE_EXTENTIONS_); // DEBUG_COUT_VAR(_BACKGROUND_LABEL_); // exit(-1); }
bool loadConfig(void) { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile("config.ini"); const char* url = ini.GetValue("config", "url", "http://127.0.0.1/jieshui.php"); if (NULL == url) { return false; } const char* timer = ini.GetValue("config", "timer", "10"); if (NULL == timer) { return false; } g_jieshuiURL = new string(url); g_timer = atoi(timer); g_timer *= 1000; //cout << *g_jieshuiURL << endl << g_timer << endl; return true; }
void load(const char* filename) { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(filename); _mouseSensitivity = static_cast<float>(ini.GetDoubleValue("Controls", "Mouse Sensitivity", 0.5f)); _displayWidth = ini.GetLongValue("Graphics", "Width", 640); _displayHeight = ini.GetLongValue("Graphics", "Height", 480); _fullscreen = ini.GetBoolValue("Graphics", "Fullscreen"); _borderless = ini.GetBoolValue("Graphics", "Borderless"); _fieldOfView = static_cast<float>(ini.GetDoubleValue("Graphics", "Field of View", 45.f)); _showConsole = ini.GetBoolValue("Debug", "Show Console"); _logging = ini.GetBoolValue("Debug", "Logging"); _showMouseCursor = ini.GetBoolValue("Debug", "Show Mouse Cursor"); _centerMouseCursor = ini.GetBoolValue("Debug", "Center Mouse Cursor", true); _showFPS = ini.GetBoolValue("Debug", "Show FPS", true); _showCursorCoordinates = ini.GetBoolValue("Debug", "Show Cursor Coords", true); _debugContext = ini.GetBoolValue("Debug", "Debug Context", false); *_startingScene = ini.GetValue("Debug", "Starting Scene", "default"); }
void save(const char* filename) { CSimpleIniA ini; ini.SetUnicode(); ini.SetDoubleValue("Controls", "Mouse Sensitivity", _mouseSensitivity); ini.SetLongValue("Graphics", "Width", _displayWidth); ini.SetLongValue("Graphics", "Height", _displayHeight); ini.SetBoolValue("Graphics", "Fullscreen", _fullscreen); ini.SetBoolValue("Graphics", "Borderless", _borderless); ini.SetDoubleValue("Graphics", "Field of View", _fieldOfView); ini.SetBoolValue("Debug", "Show Console", _showConsole); ini.SetBoolValue("Debug", "Logging", _logging); ini.SetBoolValue("Debug", "Show Mouse Cursor", _showMouseCursor); ini.SetBoolValue("Debug", "Center Mouse Cursor", _centerMouseCursor); ini.SetBoolValue("Debug", "Show FPS", _showFPS); ini.SetBoolValue("Debug", "Show Cursor Coords", _showCursorCoordinates); ini.SetBoolValue("Debug", "Debug Context", _debugContext); ini.SetValue("Debug", "Starting Scene", _startingScene->c_str()); SI_Error rc = ini.SaveFile(filename); if (rc < 0) fputs("Couldn't save settings", stderr); }
bool SettingsManager::saveSettings() { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile("CONFIG.ini"); if(ini.IsEmpty()) {return false;} ini.SetValue("HIGHSCORE", "NAME", m_settings->HIGHSCORE_NAME.c_str()); ini.SetLongValue("HIGHSCORE", "SCORE", m_settings->HIGHSCORE_SCORE); ini.SetValue("HIGHSCORE2", "NAME", m_settings->HIGHSCORE2_NAME.c_str()); ini.SetLongValue("HIGHSCORE2", "SCORE", m_settings->HIGHSCORE2_SCORE); ini.SetValue("HIGHSCORE3", "NAME", m_settings->HIGHSCORE3_NAME.c_str()); ini.SetLongValue("HIGHSCORE3", "SCORE", m_settings->HIGHSCORE3_SCORE); //Save the file if(ini.SaveFile("CONFIG.ini") < 0) {return false;} return true; }
// Main int main(int argc, char **argv) { // Check the number of command line arguments if(argc < 2) { cout << "Try " << argv[0] << " -h or --help" << endl; return 1; } try { TCLAP::CmdLine cmd("Push notifications to your phone easily.", ' ', "0.3"); // Values TCLAP::ValueArg<int> idArg("i","id","ID of the device.",false,0,"number"); cmd.add(idArg); // Switches TCLAP::SwitchArg tokenSwitch("t", "token", "Request your token.", cmd, false); TCLAP::SwitchArg listSwitch("l", "list", "List all your devices.", cmd, false); TCLAP::SwitchArg pipeSwitch("p", "pipe", "Input via pipe.", cmd, false); TCLAP::SwitchArg verifySwitch("v","verify","Checks if token is still valid.", cmd, false); // add unlabeled argument TCLAP::UnlabeledValueArg<string> noLabelMessage("message", "The notification you want to send.", false, "message", "message"); cmd.add(noLabelMessage); // Parse the argv array. cmd.parse(argc, argv); // Variables string message; int id; CSimpleIniA iniReader; iniReader.SetUnicode(); // Request token if(tokenSwitch.getValue()) { string username, password, token; // Read username cout << "Username: "******"Password: "******"pusher", "username", username.c_str()); iniReader.SetValue("pusher", "appToken", token.c_str()); // Check if file is writable if(iniReader.SaveFile(CONFIG_FILE) < 0) { cout << "Try running pusher as root or save the following in " << CONFIG_FILE << "\n" << endl; // Data string strData; iniReader.Save(strData); cout << strData << endl; return 1; } cout << "Success!" << endl; return 0; } // Check if reading of config is possible if(iniReader.LoadFile(CONFIG_FILE) < 0) { throw PusherError("You need to login first."); } string username = iniReader.GetValue("pusher", "username", ""); string appToken = iniReader.GetValue("pusher", "appToken", ""); if(username.empty() || appToken.empty()) { throw PusherError("You need to login first."); } // Loading values PushHandler pusherInstance(username, appToken); // Verify token if(verifySwitch.getValue()) { if(pusherInstance.verifyToken()) { cout << "appToken is valid" << endl; return 0; } else { cout << "appToken is invalid" << endl; return 1; } } // List devices if(listSwitch.getValue()) { vector<PushHandler::Device> devices; devices = pusherInstance.getDevices(); unsigned int titleLength = 5; unsigned int modelLength = 5; unsigned int idLength = 2; for(unsigned int i = 0; i < devices.size(); i++) { if(devices[i].title.length() > titleLength) { titleLength = devices[i].title.length(); } if(devices[i].model.length() > modelLength) { modelLength = devices[i].model.length(); } if(devices[i].id.length() > idLength) { idLength = devices[i].id.length(); } } cout << "ID\033[" << (idLength - 2 + 2) << "C" << "Title\033[" << (titleLength - 5 + 2) << "C" << "Model" << endl; for(unsigned int x = 0; x < (titleLength + modelLength + idLength + 4); x++) { cout << "-"; } cout << endl; for(unsigned int i = 0; i < devices.size(); i++) { cout << devices[i].id << "\033[" << (idLength - devices[i].id.length() + 2) << "C" << devices[i].title << "\033[" << (titleLength - devices[i].title.length() + 2) << "C" << devices[i].model << endl; } return 0; } // Device id if(idArg.getValue() != 0) { id = idArg.getValue(); } else { return 1; } // Load message if(pipeSwitch.getValue()) { string pipeBuffer; while(getline(cin, pipeBuffer)) { message += "\n"; message += pipeBuffer; } message.erase(0,1); } else { message = noLabelMessage.getValue(); } // Send the message stringstream stringID; stringID << id; pusherInstance.sendToDevice(stringID.str(), message); }
void ConfigOptions::init() { //Opening ini file CSimpleIniA ini; ini.SetUnicode(); ini.SetMultiKey(); if (ini.LoadFile("Config.ini") == SI_OK) { /////////////////////GAMEPLAY/////////////////////////////// //Difficulty m_aiThinkingTime = atoi(ini.GetValue("Gameplay", "Difficulty", "1")); m_p1AI = ini.GetBoolValue("Gameplay", "Player1AI", 0); m_p2AI = ini.GetBoolValue("Gameplay", "Player2AI", 0); m_dialogOn = ini.GetBoolValue("Gameplay", "ShowDialog", 0); m_autoReset = ini.GetBoolValue("Gameplay", "AutoReset", 0); /////////////////////GRAPHICS/////////////////////////////// //Resoltion m_resolution = sf::Vector2i(atoi(ini.GetValue("Graphics", "ScreenWidth", "1920")), atoi(ini.GetValue("Graphics", "ScreenHeight", "1080"))); m_inFullscreen = ini.GetBoolValue("Graphics", "FullScreen", 0); m_view.SetFromRect(sf::FloatRect(0, 0, (float) nativeWidth(), (float) nativeHeight())); //////////////////////CONTROLS///////////////////////////// std::string item; std::string val; //Keys std::map<std::string, sf::Key::Code> allKeys = getNamedKeys(); // if there are keys and values... const CSimpleIniA::TKeyVal* keys = ini.GetSection("KeyboardControls"); if (keys) { // iterate over all keys and dump the key name and value for (CSimpleIniA::TKeyVal::const_iterator it = keys->begin() ; it != keys->end() ; ++it) { item = it->first.pItem; val = it->second; m_iHandler.map(item, allKeys[val]); } } //Mouse buttons std::map<std::string, sf::Mouse::Button> allButtons = getNamedButtons(); // if there are keys and values... const CSimpleIniA::TKeyVal* buttons = ini.GetSection("MouseControls"); if (keys) { // iterate over all keys and dump the key name and value for (CSimpleIniA::TKeyVal::const_iterator it = buttons->begin() ; it != buttons->end() ; ++it) { item = it->first.pItem; val = it->second; m_iHandler.map(item, allButtons[val]); } } //////////////////////OTHER///////////////////////////// m_theme = ini.GetValue("Graphics", "Theme", ""); if (m_theme == "Default") //default theme m_theme = ""; } else { std::cerr << "Unable to load file : Config.ini" << std::endl; } }
int main(int argc, const char * argv[]) { CSimpleIniA ini; ini.SetUnicode(); if (ini.LoadFile("config.ini") == SI_FILE) { std::cout<< KWARN "Warning:" <<KREST << " Cannot load config.ini. Default setting is used.\n\n"; } bool gui = true; uint16_t port = atoi(ini.GetValue("server", "port", stringize(SERVER_DEFAULT_PORT))); uint32_t numThreads = atoi(ini.GetValue("server", "threads", stringize(SERVER_DEFAULT_NUM_THREADS))); int width = atoi(ini.GetValue("camera", "width", stringize(CAM_DEFAULT_WIDTH))); int height = atoi(ini.GetValue("camera", "height", stringize(CAM_DEFAULT_HEIGHT))); uint32_t wait = atoi(ini.GetValue("camera", "wait", stringize(CAM_WAIT))); int dev = atoi(ini.GetValue("camera", "device", stringize(CAM_DEV))); const char* unlockPin = ini.GetValue("gpio", "unlock", GPIO_DEFAULT_UNLOCK); const char* errorPin = ini.GetValue("gpio", "error", GPIO_DEFAULT_ERROR); const char* rsapath = ini.GetValue("safety", "pem", SAFETY_DEFAULT_RSA_FILE); const char* passwd = ini.GetValue("safety", "password", SAFETY_DEFAULT_PASSWD); uint32_t qrexp = atoi(ini.GetValue("misc", "qrexpire", stringize(MISC_DEFAULT_QR_EXP))); for (int i = 1; i < argc; i++) { const char* arg = argv[i]; if (strcmp(arg, "--help") == 0) { printf("%s", HELP_STRING); exit(0); } else if (strcmp(arg, "--nogui") == 0) { gui = false; } else { std::cerr<<KERR <<"Error:" << KREST << "unknown argument \""<<arg<<'"'<<std::endl; exit(2); } } ServerThreads::qrexp = qrexp; ServerThreads::port = port; ServerThreads::numThreads = numThreads; ServerThreads::gpioUnlock = unlockPin; ServerThreads::gpioError = errorPin; ServerThreads::rsaFile = rsapath; if (signal(SIGINT, sigHandler) == SIG_ERR) std::cerr<<"Can't catch SIGINT\n"; pthread_t serverThreadId; pthread_create(&serverThreadId, nullptr, ServerThreads::startServer, nullptr); const char* apnRsaFile = ini.GetValue("apn", "pem", APN_DEFAULT_RSA_FILE); APNClient::DefaultClient.host = ini.GetValue("apn", "host", APN_DEFAULT_HOST); APNClient::DefaultClient.port = atoi(ini.GetValue("apn", "port", stringize(APN_DEFAULT_PORT))); APNClient::DefaultClient.rsa = rsaFromFile(apnRsaFile, true); REPL::cleanupFn = cleanup; REPL::password = passwd; pthread_t replThreadId; pthread_create(&replThreadId, nullptr, REPL::startLoop, nullptr); pthread_t btThreadId; pthread_create(&btThreadId, nullptr, BluetoothThread::startLoop, nullptr); CameraLoop::loop(dev, width, height, gui, wait); return 1; }
bool SettingsManager::loadSettings() { CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile("CONFIG.ini"); if(ini.IsEmpty()) {return false;} m_settings = new SettingsObject(); m_settings->FRAME_TITLE = ini.GetValue("FRAME", "TITLE", ""); m_settings->FRAME_FULLSCREEN = ini.GetBoolValue("FRAME", "FULLSCREEN", false); m_settings->FRAME_RESOLUTION_FULLSCREEN_X = ini.GetLongValue("FRAME", "RESOLUTION_FULLSCREEN_X", 0); m_settings->FRAME_RESOLUTION_FULLSCREEN_Y = ini.GetLongValue("FRAME", "RESOLUTION_FULLSCREEN_Y", 0); m_settings->FRAME_RESOLUTION_WINDOWED_X = ini.GetLongValue("FRAME", "RESOLUTION_WINDOWED_X", 0); m_settings->FRAME_RESOLUTION_WINDOWED_Y = ini.GetLongValue("FRAME", "RESOLUTION_WINDOWED_Y", 0); m_settings->FRAME_VIEW_X = ini.GetLongValue("FRAME", "VIEW_X", 0); m_settings->FRAME_VIEW_Y = ini.GetLongValue("FRAME", "VIEW_Y", 0); m_settings->WORLD_GRAVITY = (float)ini.GetDoubleValue("WORLD", "GRAVITY", 0); m_settings->PLAYER_SPEED_SIDE = (float)ini.GetDoubleValue("PLAYER", "SPEED_SIDE", 0); m_settings->PLAYER_SPEED_SIDE_HALTING = (float)ini.GetDoubleValue("PLAYER", "SPEED_SIDE_HALTING", 0); m_settings->PLAYER_SPEED_JUMP = (float)ini.GetDoubleValue("PLAYER", "SPEED_JUMP", 0); m_settings->PLAYER_SPEED_DOWN = (float)ini.GetDoubleValue("PLAYER", "SPEED_DOWN", 0); m_settings->PLAYER_HEALTH = (float)ini.GetDoubleValue("PLAYER", "HEALTH", 0); m_settings->PLAYER_SWORD_SWING_TIME = (float)ini.GetDoubleValue("PLAYER", "SWORD_SWING_TIME", 0); m_settings->PLAYER_HIT_TIME_LIMIT_MELEE = (float)ini.GetDoubleValue("PLAYER", "HIT_TIME_LIMIT_MELEE", 0); m_settings->PLAYER_KNOCKBACK_SPEED_X_INIT = (float)ini.GetDoubleValue("PLAYER", "KNOCKBACK_SPEED_X_INIT", 0); m_settings->PLAYER_KNOCKBACK_SPEED_X_DECREASE = (float)ini.GetDoubleValue("PLAYER", "KNOCKBACK_SPEED_X_DECREASE", 0); m_settings->PLAYER_KNOCKBACK_SPEED_Y = (float)ini.GetDoubleValue("PLAYER", "KNOCKBACK_SPEED_Y", 0); m_settings->DAMAGE_ENEMY_PLACEHOLDER_TO_PLAYER = (float)ini.GetDoubleValue("DAMAGE", "ENEMY_PLACEHOLDER_TO_PLAYER", 0); m_settings->DAMAGE_ENEMY_TROLL_TO_PLAYER = (float)ini.GetDoubleValue("DAMAGE", "ENEMY_TROLL_TO_PLAYER", 0); m_settings->DAMAGE_PLAYER_TO_ENEMY_PLACEHOLDER = (float)ini.GetDoubleValue("DAMAGE", "PLAYER_TO_ENEMY_PLACEHOLDER", 0); m_settings->DAMAGE_PLAYER_TO_ENEMY_TROLL = (float)ini.GetDoubleValue("DAMAGE", "PLAYER_TO_ENEMY_TROLL", 0); m_settings->DAMAGE_ENEMY_PROJECTILE_TO_PLAYER = (float)ini.GetDoubleValue("DAMAGE", "ENEMY_PROJECTILE_TO_PLAYER", 0); m_settings->DAMAGE_PLAYER_TO_ENEMY_SHOOTER = (float)ini.GetDoubleValue("DAMAGE", "PLAYER_TO_ENEMY_SHOOTER", 0); m_settings->DAMAGE_ENEMY_BASE_TO_PLAYER = (float)ini.GetDoubleValue("DAMAGE", "ENEMY_BASE_TO_PLAYER", 0); m_settings->DAMAGE_PLAYER_TO_ENEMY_GOBLIN = (float)ini.GetDoubleValue("DAMAGE", "PLAYER_TO_ENEMY_TROLL", 0); m_settings->ENEMY_TROLL_HEALTH = (float)ini.GetDoubleValue("ENEMY_TROLL", "HEALTH", 0); m_settings->ENEMY_TROLL_HIT_TIME_LIMIT_MELEE = (float)ini.GetDoubleValue("ENEMY_TROLL", "HIT_TIME_LIMIT_MELEE", 0); m_settings->ENEMY_TROLL_SPEED_SIDE = (float)ini.GetDoubleValue("ENEMY_TROLL", "SPEED_SIDE", 0); m_settings->ENEMY_TROLL_HITBOX_SIZE_X = (float)ini.GetDoubleValue("ENEMY_TROLL", "HITBOX_SIZE_X", 0); m_settings->ENEMY_TROLL_HITBOX_SIZE_Y = (float)ini.GetDoubleValue("ENEMY_TROLL", "HITBOX_SIZE_Y", 0); m_settings->ENEMY_TROLL_HITBOX_LOCAL_POSITION_X = (float)ini.GetDoubleValue("ENEMY_TROLL", "HITBOX_LOCAL_POSITION_X", 0); m_settings->ENEMY_TROLL_HITBOX_LOCAL_POSITION_Y = (float)ini.GetDoubleValue("ENEMY_TROLL", "HITBOX_LOCAL_POSITION_Y", 0); m_settings->ENEMY_TROLL_AI_CHANGE_LIMIT_TIME = (float)ini.GetDoubleValue("ENEMY_TROLL", "AI_CHANGE_LIMIT_TIME", 0); m_settings->ENEMY_TROLL_AI_WALKING_BACKWARDS_DISTANCE_LIMIT = (float)ini.GetDoubleValue("ENEMY_TROLL", "AI_WALKING_BACKWARDS_DISTANCE_LIMIT", 0); m_settings->ENEMY_TROLL_ATTACK_STAGE_1_TIME = (float)ini.GetDoubleValue("ENEMY_TROLL", "ATTACK_STAGE_1_TIME", 0); m_settings->ENEMY_TROLL_ATTACK_STAGE_2_TIME = (float)ini.GetDoubleValue("ENEMY_TROLL", "ATTACK_STAGE_2_TIME", 0); m_settings->ENEMY_GOBLIN_HEALTH = (float)ini.GetDoubleValue("ENEMY_GOBLIN", "HEALTH", 0); m_settings->ENEMY_GOBLIN_SPEED_SIDE = (float)ini.GetDoubleValue("ENEMY_GOBLIN", "SPEED_SIDE", 0); m_settings->ENEMY_GOBLIN_BOMB_SPAWN_TIME = (float)ini.GetDoubleValue("ENEMY_GOBLIN", "BOMB_SPAWN_TIME", 0); m_settings->ENEMY_GOBLIN_BOMB_AOE_DURATION = (float)ini.GetDoubleValue("ENEMY_GOBLIN", "BOMB_AOE_DURATION", 0); m_settings->ENEMY_GOBLIN_BOMB_BLAST_AREA_SIZE = (float)ini.GetDoubleValue ("ENEMY_GOBLIN", "BOMB_BLAST_AREA_SIZE", 0); m_settings->ENEMY_SHOOTER_SHOOT_TIME = (float)ini.GetDoubleValue("ENEMY_SHOOTER", "SHOOT_TIME", 0); m_settings->ENEMY_SHOOTER_PROJECTILE_PARTICLE_SPAWN_TIME = (float)ini.GetDoubleValue("ENEMY_SHOOTER", "PROJECTILE_PARTICLE_SPAWN_TIME", 0); m_settings->ENEMY_SHOOTER_PROJETILE_SPEED = (float)ini.GetDoubleValue("ENEMY_SHOOTER", "PROJETILE_SPEED", 0); m_settings->ENEMY_SHOOTER_PROJECTILE_LIFE_TIME = (float)ini.GetDoubleValue("ENEMY_SHOOTER", "PROJECTILE_LIFE_TIME", 0); m_settings->ENEMY_BASE_HEALTH = (float)ini.GetDoubleValue("ENEMY_BASE", "HEALTH", 0); m_settings->ENEMY_BASE_SPEED_BASE = (float)ini.GetDoubleValue("ENEMY_BASE", "SPEED_BASE", 0); m_settings->ENEMY_BASE_SPEED_MIN_MULTIPLIER = (float)ini.GetDoubleValue("ENEMY_BASE", "SPEED_MIN_MULTIPLIER", 0); m_settings->ENEMY_BASE_SPEED_MAX_MULTIPLIER = (float)ini.GetDoubleValue("ENEMY_BASE", "SPEED_MAX_MULTIPLIER", 0); m_settings->PARTICLES_MAX_INIT_SPEED = (float)ini.GetDoubleValue("PARTICLES", "MAX_INIT_SPEED", 0); m_settings->SCORE_KILL_TROLL = ini.GetLongValue("SCORE", "KILL_TROLL", 0); m_settings->SCORE_KILL_GOBLIN = ini.GetLongValue("SCORE", "KILL_GOBLIN", 0); m_settings->SCORE_KILL_SHOOTER = ini.GetLongValue("SCORE", "KILL_SHOOTER", 0); m_settings->SCORE_KILL_BASE = ini.GetLongValue("SCORE", "KILL_BASE", 0); m_settings->SCORE_TIME_LIMIT = (float)ini.GetDoubleValue("SCORE", "TIME_LIMIT", 0); m_settings->HIGHSCORE_NAME = ini.GetValue("HIGHSCORE", "NAME", ""); m_settings->HIGHSCORE2_NAME = ini.GetValue("HIGHSCORE2", "NAME", ""); m_settings->HIGHSCORE3_NAME = ini.GetValue("HIGHSCORE3", "NAME", ""); m_settings->HIGHSCORE_SCORE = ini.GetLongValue("HIGHSCORE", "SCORE", 0); m_settings->HIGHSCORE2_SCORE = ini.GetLongValue("HIGHSCORE2", "SCORE", 0); m_settings->HIGHSCORE3_SCORE = ini.GetLongValue("HIGHSCORE3", "SCORE", 0); return true; }
void ScriptSettings::Read(ScriptControls* scriptControl) { #pragma warning(push) #pragma warning(disable: 4244) // Make everything doubles later... CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(SETTINGSFILE); ini.GetBoolValue("OPTIONS", "Enable", true); // [OPTIONS] EnableManual = ini.GetBoolValue("OPTIONS", "Enable", true); ShiftMode = ini.GetLongValue("OPTIONS", "ShiftMode", 0); SimpleBike = ini.GetBoolValue("OPTIONS", "SimpleBike", false); EngDamage = ini.GetBoolValue("OPTIONS", "EngineDamage", false); EngStall = ini.GetBoolValue("OPTIONS", "EngineStalling", false); EngBrake = ini.GetBoolValue("OPTIONS", "EngineBraking", false); ClutchCatching = ini.GetBoolValue("OPTIONS", "ClutchCatching", false); ClutchShifting = ini.GetBoolValue("OPTIONS", "ClutchShifting", false); ClutchShiftingS = ini.GetBoolValue("OPTIONS", "ClutchShiftingS", false); DefaultNeutral = ini.GetBoolValue("OPTIONS", "DefaultNeutral", true); ClutchCatchpoint = ini.GetDoubleValue("OPTIONS", "ClutchCatchpoint", 15.0) / 100.0f; StallingThreshold = ini.GetDoubleValue("OPTIONS", "StallingThreshold", 75.0) / 100.0f; RPMDamage = ini.GetDoubleValue("OPTIONS", "RPMDamage", 15.0) / 100.0f; MisshiftDamage = ini.GetDoubleValue("OPTIONS", "MisshiftDamage", 10.0); AutoLookBack = ini.GetBoolValue("OPTIONS", "AutoLookBack", false); AutoGear1 = ini.GetBoolValue("OPTIONS", "AutoGear1", false); HillBrakeWorkaround = ini.GetBoolValue("OPTIONS", "HillBrakeWorkaround", false); UITips = ini.GetBoolValue("OPTIONS", "UITips", true); UITips_OnlyNeutral = ini.GetBoolValue("OPTIONS", "UITips_OnlyNeutral", false); UITips_X = ini.GetDoubleValue("OPTIONS", "UITips_X", 95.0) / 100.0f; UITips_Y = ini.GetDoubleValue("OPTIONS", "UITips_Y", 95.0) / 100.0f; UITips_Size = ini.GetDoubleValue("OPTIONS", "UITips_Size", 15.0) / 100.0f; UITips_TopGearC_R = ini.GetLongValue("OPTIONS", "UITips_TopGearC_R", 255); UITips_TopGearC_G = ini.GetLongValue("OPTIONS", "UITips_TopGearC_G", 255); UITips_TopGearC_B = ini.GetLongValue("OPTIONS", "UITips_TopGearC_B", 255); CrossScript = ini.GetBoolValue("OPTIONS", "CrossScript", false); // [CONTROLLER] scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::Toggle)] = ini.GetValue("CONTROLLER", "Toggle", "DpadRight"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::ToggleH)] = ini.GetValue("CONTROLLER", "ToggleShift", "B"); scriptControl->CToggleTime = ini.GetLongValue("CONTROLLER", "ToggleTime", 500); int tval = ini.GetLongValue("CONTROLLER", "TriggerValue", 75); if (tval > 100 || tval < 0) { tval = 75; } scriptControl->SetXboxTrigger(tval); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::ShiftUp)] = ini.GetValue("CONTROLLER", "ShiftUp", "A"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::ShiftDown)] = ini.GetValue("CONTROLLER", "ShiftDown", "X"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::Clutch)] = ini.GetValue("CONTROLLER", "Clutch", "LeftThumbDown"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::Engine)] = ini.GetValue("CONTROLLER", "Engine", "DpadDown"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::Throttle)] = ini.GetValue("CONTROLLER", "Throttle", "RightTrigger"); scriptControl->ControlXbox[static_cast<int>(ScriptControls::ControllerControlType::Brake)] = ini.GetValue("CONTROLLER", "Brake", "LeftTrigger"); // [KEYBOARD] scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::Toggle)] = str2key(ini.GetValue("KEYBOARD", "Toggle", "VK_OEM_5")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::ToggleH)] = str2key(ini.GetValue("KEYBOARD", "ToggleH", "VK_OEM_6")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::ShiftUp)] = str2key(ini.GetValue("KEYBOARD", "ShiftUp", "SHIFT")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::ShiftDown)] = str2key(ini.GetValue("KEYBOARD", "ShiftDown", "CTRL")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::Clutch)] = str2key(ini.GetValue("KEYBOARD", "Clutch", "X")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::Engine)] = str2key(ini.GetValue("KEYBOARD", "Engine", "C")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::Throttle)] = str2key(ini.GetValue("KEYBOARD", "Throttle", "W")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::Brake)] = str2key(ini.GetValue("KEYBOARD", "Brake", "S")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::HR)] = str2key(ini.GetValue("KEYBOARD", "HR", "NUM0")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H1)] = str2key(ini.GetValue("KEYBOARD", "H1", "NUM1")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H2)] = str2key(ini.GetValue("KEYBOARD", "H2", "NUM2")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H3)] = str2key(ini.GetValue("KEYBOARD", "H3", "NUM3")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H4)] = str2key(ini.GetValue("KEYBOARD", "H4", "NUM4")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H5)] = str2key(ini.GetValue("KEYBOARD", "H5", "NUM5")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H6)] = str2key(ini.GetValue("KEYBOARD", "H6", "NUM6")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H7)] = str2key(ini.GetValue("KEYBOARD", "H7", "NUM7")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::H8)] = str2key(ini.GetValue("KEYBOARD", "H8", "NUM8")); scriptControl->KBControl[static_cast<int>(ScriptControls::KeyboardControlType::HN)] = str2key(ini.GetValue("KEYBOARD", "HN", "NUM9")); // [WHEELOPTIONS] WheelEnabled = ini.GetBoolValue("WHEELOPTIONS", "Enable", false); WheelWithoutManual = ini.GetBoolValue("WHEELOPTIONS", "WheelWithoutManual", true); FFEnable = ini.GetBoolValue("WHEELOPTIONS", "FFEnable", true); FFGlobalMult = ini.GetDoubleValue("WHEELOPTIONS", "FFGlobalMult", 100.0) / 100.0f; DamperMax = ini.GetLongValue("WHEELOPTIONS", "DamperMax", 50); DamperMin = ini.GetLongValue("WHEELOPTIONS", "DamperMin", 20); TargetSpeed = ini.GetLongValue("WHEELOPTIONS", "DamperTargetSpeed", 10); FFPhysics = ini.GetDoubleValue("WHEELOPTIONS", "PhysicsStrength", 100.0) / 100.0f; CenterStrength = ini.GetDoubleValue("WHEELOPTIONS", "CenterStrength", 100.0) / 100.0f; DetailStrength = ini.GetDoubleValue("WHEELOPTIONS", "DetailStrength", 100.0) / 1.0f; // [WHEELCONTROLS] scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Toggle)] = ini.GetLongValue("WHEELCONTROLS", "Toggle", 17); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::ToggleH)] = ini.GetLongValue("WHEELCONTROLS", "ToggleH", 6); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::ShiftUp)] = ini.GetLongValue("WHEELCONTROLS", "ShiftUp", 4); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::ShiftDown)] = ini.GetLongValue("WHEELCONTROLS", "ShiftDown", 5); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::HR)] = ini.GetLongValue("WHEELCONTROLS", "HR", 14); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H1)] = ini.GetLongValue("WHEELCONTROLS", "H1", 8 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H2)] = ini.GetLongValue("WHEELCONTROLS", "H2", 9 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H3)] = ini.GetLongValue("WHEELCONTROLS", "H3", 10); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H4)] = ini.GetLongValue("WHEELCONTROLS", "H4", 11); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H5)] = ini.GetLongValue("WHEELCONTROLS", "H5", 12); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::H6)] = ini.GetLongValue("WHEELCONTROLS", "H6", 13); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Handbrake)] = ini.GetLongValue("WHEELCONTROLS", "Handbrake", 19); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Engine)] = ini.GetLongValue("WHEELCONTROLS", "Engine", 21 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Horn)] = ini.GetLongValue("WHEELCONTROLS", "Horn", 20 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Lights)] = ini.GetLongValue("WHEELCONTROLS", "Lights", 7); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::LookBack)] = ini.GetLongValue("WHEELCONTROLS", "LookBack", 22); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::Camera)] = ini.GetLongValue("WHEELCONTROLS", "Camera", 0); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::RadioPrev)] = ini.GetLongValue("WHEELCONTROLS", "RadioPrev", 1); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::RadioNext)] = ini.GetLongValue("WHEELCONTROLS", "RadioNext", 2); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::IndicatorLeft)] = ini.GetLongValue("WHEELCONTROLS", "IndicatorLeft", 19 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::IndicatorRight)] = ini.GetLongValue("WHEELCONTROLS", "IndicatorRight", 21 ); scriptControl->WheelControl[static_cast<int>(ScriptControls::WheelControlType::IndicatorHazard)] = ini.GetLongValue("WHEELCONTROLS", "IndicatorHazard", 15); // [WHEELAXIS] scriptControl->WheelAxes[static_cast<int>(ScriptControls::WheelAxisType::Throttle)] = ini.GetValue("WHEELAXIS", "Throttle", "lY"); scriptControl->ThrottleMin = ini.GetLongValue("WHEELAXIS", "ThrottleMin", 0); scriptControl->ThrottleMax = ini.GetLongValue("WHEELAXIS", "ThrottleMax", 65535); scriptControl->WheelAxes[static_cast<int>(ScriptControls::WheelAxisType::Brake)] = ini.GetValue("WHEELAXIS", "Brake", "lRz"); scriptControl->BrakeMin = ini.GetLongValue("WHEELAXIS", "BrakeMin", 0); scriptControl->BrakeMax = ini.GetLongValue("WHEELAXIS", "BrakeMax", 65535); scriptControl->WheelAxes[static_cast<int>(ScriptControls::WheelAxisType::Clutch)] = ini.GetValue("WHEELAXIS", "Clutch", "rglSlider1"); scriptControl->ClutchMin = ini.GetLongValue("WHEELAXIS", "ClutchMin", 0); scriptControl->ClutchMax = ini.GetLongValue("WHEELAXIS", "ClutchMax", 65535); scriptControl->WheelAxes[static_cast<int>(ScriptControls::WheelAxisType::Steer)] = ini.GetValue("WHEELAXIS", "Steer", "lX"); scriptControl->SteerLeft = ini.GetLongValue("WHEELAXIS", "SteerLeft", 0); scriptControl->SteerRight = ini.GetLongValue("WHEELAXIS", "SteerRight", 65535); scriptControl->FFAxis = ini.GetValue("WHEELAXIS", "FFAxis", "X"); scriptControl->ClutchDisable = ini.GetBoolValue("WHEELAXIS", "ClutchDisable", false); SteerAngleMax = ini.GetDoubleValue("WHEELAXIS", "SteerAngleMax", 900.0); SteerAngleCar = ini.GetDoubleValue("WHEELAXIS", "SteerAngleCar", 720.0); SteerAngleBike = ini.GetDoubleValue("WHEELAXIS", "SteerAngleBike", 180.0); // [WHEELKEYBOARD] for (int i = 0; i < MAX_RGBBUTTONS; i++) { // Ouch std::string entryString = ini.GetValue("WHEELKEYBOARD", std::to_string(i).c_str(), "NOPE"); if (std::string(entryString).compare("NOPE") == 0) { scriptControl->WheelToKey[i] = -1; } else { scriptControl->WheelToKey[i] = str2key(entryString); } } // [DEBUG] Debug = ini.GetBoolValue("DEBUG", "Info", false); AltControls = ini.GetBoolValue("DEBUG", "AltControls", false); SteerAngleAlt = ini.GetDoubleValue("DEBUG", "AltAngle", 180.0); // .ini version check INIver = ini.GetValue("DEBUG", "INIver", "0.0"); #pragma warning(pop) }