Example #1
0
bool loadSettings() {

	// init defaults
	for (int i = 0; i < config_size; i++) {
		ConfigEntry * entry = config + i;
		tryParseValue(*entry->type, entry->default_val, entry->storage);
	}

	// try read from file
	FileParser infile;
	if (!infile.open(PATH_CONF + FILE_SETTINGS, false, "")) {
		loadMobileDefaults();
		if (!infile.open("engine/default_settings.txt", true, "")) {
			saveSettings();
			return true;
		}
		else saveSettings();
	}

	while (infile.next()) {

		ConfigEntry * entry = getConfigEntry(infile.key);
		if (entry) {
			tryParseValue(*entry->type, infile.val, entry->storage);
		}
	}
	infile.close();

	loadMobileDefaults();

	return true;
}
Example #2
0
void Settings::loadSettings() {
	// init defaults
	for (size_t i = 0; i < config.size(); i++) {
		Parse::tryParseValue(*config[i].type, config[i].default_val, config[i].storage);
	}

	// try read from file
	FileParser infile;
	if (!infile.open(settings->path_conf + "settings.txt", !FileParser::MOD_FILE, FileParser::ERROR_NONE)) {
		loadMobileDefaults();
		if (!infile.open("engine/default_settings.txt", FileParser::MOD_FILE, FileParser::ERROR_NONE)) {
			saveSettings();
			return;
		}
		else saveSettings();
	}

	while (infile.next()) {
		size_t entry = getConfigEntry(infile.key);
		if (entry != config.size()) {
			Parse::tryParseValue(*config[entry].type, infile.val, config[entry].storage);
		}
	}
	infile.close();

	loadMobileDefaults();
}
Example #3
0
/**
 * Load all default settings, except video settings.
 */
void Settings::loadDefaults() {
	// HACK init defaults except video
	for (size_t i = 3; i < config.size(); i++) {
		Parse::tryParseValue(*config[i].type, config[i].default_val, config[i].storage);
	}

	loadMobileDefaults();
}
Example #4
0
/**
 * Load all default settings, except video settings.
 */
bool loadDefaults() {

	// HACK init defaults except video
	for (int i = 3; i < config_size; i++) {
		ConfigEntry * entry = config + i;
		tryParseValue(*entry->type, entry->default_val, entry->storage);
	}

	loadMobileDefaults();

	return true;
}