Пример #1
0
void OneTweakConfig::ReadConfig()
{
	_MESSAGE(__FUNCTION__);

	inifilename = FullPathFromPath("OneTweak.ini");

	CSimpleIniA ini;
	ini.LoadFile(inifilename.c_str());

	version = ini.GetLongValue("Version", "Config");
	if (version != CONFIG_VERSION)
	{
		SaveConfig(&ini);
	}

	borderless.enabled = ini.GetBoolValue("Global", "BorderlessWindow");
	double_cursor_fix.enabled = ini.GetBoolValue("Global", "DoubleCursorFix");

	priority.enabled = ini.GetBoolValue("Global", "Priority");

	if (priority.enabled)
	{
		DWORD id_fg = ini.GetLongValue("Priority", "Foreground");
		DWORD id_bg = ini.GetLongValue("Priority", "Background");

		priority.high = PriorityIdToClass(id_fg);
		priority.low = PriorityIdToClass(id_bg);
	}

	if (borderless.enabled)
	{
		borderless.active = ini.GetBoolValue("BorderlessWindow", "Active");

		borderless.flags = ini.GetLongValue("BorderlessWindow", "StyleFlags");
		borderless.flagsEx = ini.GetLongValue("BorderlessWindow", "StyleFlagsEx");

		borderless.posX = ini.GetLongValue("BorderlessWindow", "WindowPosX");
		borderless.posY = ini.GetLongValue("BorderlessWindow", "WindowPosY");

		borderless.WindowWidth = ini.GetLongValue("BorderlessWindow", "WindowWidth");
		borderless.WindowHeight = ini.GetLongValue("BorderlessWindow", "WindowHeight");

		borderless.RenderWidth = ini.GetLongValue("BorderlessWindow", "RenderWidth");
		borderless.RenderHeight = ini.GetLongValue("BorderlessWindow", "RenderHeight");
	}

	directinput.nonexclusive = ini.GetBoolValue("DirectInput", "NonExclusive");

	OnReadConfig(&ini);
}
Пример #2
0
////////////////////////////////////////////////////////////
/// 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)
ApplicationConfiguration::ApplicationConfiguration(LPCSTR configurationFile)
{
    CSimpleIniA ini;
    ini.SetUnicode();
    ini.LoadFile(configurationFile);
    
    _isInViewSourceMode = ini.GetBoolValue("Debug", "ViewSource", false, false);
}
Пример #4
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);


}
	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");
	}
Пример #6
0
int main( int argc, const char** argv )
{
  daemon_active = true;

  bool noDaemon = false;
  bool clockOn = false;
  std::string logFile;
  int topn;
  
  std::string configFile;
  std::string country;

  TCLAP::CmdLine cmd("OpenAlpr Daemon", ' ', Alpr::getVersion());

  TCLAP::ValueArg<std::string> countryCodeArg("c","country","Country code to identify (either us for USA or eu for Europe).  Default=us",false, "us" ,"country_code");
  TCLAP::ValueArg<std::string> configFileArg("","config","Path to the openalpr.conf file.",false, "" ,"config_file");
  TCLAP::ValueArg<int> topNArg("n","topn","Max number of possible plate numbers to return.  Default=25",false, 25 ,"topN");
  TCLAP::ValueArg<std::string> logFileArg("l","log","Log file to write to.  Default=" + DEFAULT_LOG_FILE_PATH,false, DEFAULT_LOG_FILE_PATH ,"topN");

  TCLAP::SwitchArg daemonOffSwitch("f","foreground","Set this flag for debugging.  Disables forking the process as a daemon and runs in the foreground.  Default=off", cmd, false);
  TCLAP::SwitchArg clockSwitch("","clock","Display timing information to log.  Default=off", cmd, false);

  try
  {
    
    cmd.add( countryCodeArg );
    cmd.add( topNArg );
    cmd.add( configFileArg );
    cmd.add( logFileArg );

    
    if (cmd.parse( argc, argv ) == false)
    {
      // Error occured while parsing.  Exit now.
      return 1;
    }

    country = countryCodeArg.getValue();
    configFile = configFileArg.getValue();
    logFile = logFileArg.getValue();
    topn = topNArg.getValue();
    noDaemon = daemonOffSwitch.getValue();
    clockOn = clockSwitch.getValue();
  }
  catch (TCLAP::ArgException &e)    // catch any exceptions
  {
    std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
    return 1;
  }
  
  log4cplus::BasicConfigurator config;
  config.configure();
    
  if (noDaemon == false)
  {
    // Fork off into a separate daemon
    daemon(0, 0);
    
    
    log4cplus::SharedAppenderPtr myAppender(new log4cplus::RollingFileAppender(logFile));
    myAppender->setName("alprd_appender");
    // Redirect std out to log file
    logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("alprd"));
    logger.addAppender(myAppender);
    
    
    LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in daemon mode.");
  }
  else
  {
    //log4cplus::SharedAppenderPtr myAppender(new log4cplus::ConsoleAppender());
    //myAppender->setName("alprd_appender");
    // Redirect std out to log file
    logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("alprd"));
    //logger.addAppender(myAppender);
    
    LOG4CPLUS_INFO(logger, "Running OpenALPR daemon in the foreground.");
  }
  
  CSimpleIniA ini;
  ini.SetMultiKey();
  
  ini.LoadFile(DAEMON_CONFIG_FILE_PATH.c_str());
  
  std::vector<std::string> stream_urls;
  
  
  CSimpleIniA::TNamesDepend values;
  ini.GetAllValues("daemon", "stream", values);

  // sort the values into the original load order
  values.sort(CSimpleIniA::Entry::LoadOrder());

  // output all of the items
  CSimpleIniA::TNamesDepend::const_iterator i;
  for (i = values.begin(); i != values.end(); ++i) { 
      stream_urls.push_back(i->pItem);
  }
  
  
  if (stream_urls.size() == 0)
  {
    LOG4CPLUS_FATAL(logger, "No video streams defined in the configuration.");
    return 1;
  }
  
  bool storePlates = ini.GetBoolValue("daemon", "store_plates", false);
  std::string imageFolder = ini.GetValue("daemon", "store_plates_location", "/tmp/");
  bool uploadData = ini.GetBoolValue("daemon", "upload_data", false);
  std::string upload_url = ini.GetValue("daemon", "upload_address", "");
  std::string site_id = ini.GetValue("daemon", "site_id", "");
  
  LOG4CPLUS_INFO(logger, "Using: " << imageFolder << " for storing valid plate images");
  
  pid_t pid;
  
  for (int i = 0; i < stream_urls.size(); i++)
  {
    pid = fork();
    if (pid == (pid_t) 0)
    {
      // This is the child process, kick off the capture data and upload threads
      CaptureThreadData* tdata = new CaptureThreadData();
      tdata->stream_url = stream_urls[i];
      tdata->camera_id = i + 1;
      tdata->config_file = configFile;
      tdata->output_images = storePlates;
      tdata->output_image_folder = imageFolder;
      tdata->country_code = country;
      tdata->site_id = site_id;
      tdata->top_n = topn;
      tdata->clock_on = clockOn;
      
      tthread::thread* thread_recognize = new tthread::thread(streamRecognitionThread, (void*) tdata);
      
      if (uploadData)
      {
	// Kick off the data upload thread
	UploadThreadData* udata = new UploadThreadData();
	udata->upload_url = upload_url;
	tthread::thread* thread_upload = new tthread::thread(dataUploadThread, (void*) udata );
      }
      
      break;
    }

    // Parent process will continue and spawn more children
  }



  while (daemon_active)
  {
    usleep(30000);
  }

}
Пример #7
0
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;
	}
}
Пример #8
0
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)
}