コード例 #1
0
ファイル: Theme.cpp プロジェクト: 1337Noob1337/OpenRCT2
 void theme_delete()
 {
     platform_file_delete(ThemeManager::CurrentThemePath);
     ThemeManager::LoadTheme((UITheme *)&PredefinedThemeRCT2);
     ThemeManager::ActiveAvailableThemeIndex = 1;
     String::DiscardDuplicate(&gConfigInterface.current_theme_preset, theme_manager_get_available_theme_name(1));
 }
コード例 #2
0
ファイル: title_sequences.c プロジェクト: Aitchwing/OpenRCT2
void title_sequence_remove_save(int preset, int index)
{
	if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index < gConfigTitleSequences.presets[preset].num_saves) {
		// Delete the save file
		char separator = platform_get_path_separator();
		utf8 path[MAX_PATH];
		platform_get_user_directory(path, "title sequences");
		strcat(path, gConfigTitleSequences.presets[preset].name);
		strncat(path, &separator, 1);
		strcat(path, gConfigTitleSequences.presets[preset].saves[index]);
		platform_file_delete(path);

		// Remove all references to this save in the commands and decrement save indecies
		for (int i = 0; i < gConfigTitleSequences.presets[preset].num_commands; i++) {
			if (gConfigTitleSequences.presets[preset].commands[i].command == TITLE_SCRIPT_LOAD) {
				if (gConfigTitleSequences.presets[preset].commands[i].saveIndex == index)
					gConfigTitleSequences.presets[preset].commands[i].saveIndex = 0xFF;
				else if (gConfigTitleSequences.presets[preset].commands[i].saveIndex > index && gConfigTitleSequences.presets[preset].commands[i].saveIndex != 0xFF)
					gConfigTitleSequences.presets[preset].commands[i].saveIndex--;
			}
		}

		for (int i = index; i < gConfigTitleSequences.presets[preset].num_saves - 1; i++) {
			safe_strncpy(gConfigTitleSequences.presets[preset].saves[i], gConfigTitleSequences.presets[preset].saves[i + 1], TITLE_SEQUENCE_MAX_SAVE_LENGTH);
		}
		gConfigTitleSequences.presets[preset].num_saves--;
		gConfigTitleSequences.presets[preset].saves = realloc(gConfigTitleSequences.presets[preset].saves, sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * (size_t)gConfigTitleSequences.presets[preset].num_saves);
		title_sequence_save_preset_script(preset);
	}
}
コード例 #3
0
ファイル: title_sequences.c プロジェクト: Aitchwing/OpenRCT2
void title_sequence_create_preset(const char *name)
{
	if (filename_valid_characters(name) && !title_sequence_name_exists(name)) {
		int preset = gConfigTitleSequences.num_presets;
		gConfigTitleSequences.num_presets++;
		gConfigTitleSequences.presets = realloc(gConfigTitleSequences.presets, sizeof(title_sequence) * (size_t)gConfigTitleSequences.num_presets);
		safe_strncpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
		gConfigTitleSequences.presets[preset].path[0] = 0;

		gConfigTitleSequences.presets[preset].saves = malloc(0);
		gConfigTitleSequences.presets[preset].commands = malloc(0);
		gConfigTitleSequences.presets[preset].num_saves = 0;
		gConfigTitleSequences.presets[preset].num_commands = 0;

		// Create the folder
		utf8 path[MAX_PATH];
		platform_get_user_directory(path, "title sequences");
		strcat(path, gConfigTitleSequences.presets[preset].name);
		platform_file_delete(path);
		platform_ensure_directory_exists(path);

		title_sequence_save_preset_script(preset);
		gCurrentTitleSequence = preset;
	}
}
コード例 #4
0
ファイル: themes.c プロジェクト: MaikelS11/OpenRCT2
void theme_delete_preset(int preset)
{
	if (preset >= 2) {
		utf8 path[MAX_PATH];
		platform_get_user_directory(path, "themes");
		strcat(path, gConfigThemes.presets[preset].name);
		strcat(path, ".ini");
		platform_file_delete(path);

		free(gConfigThemes.presets[preset].windows);

		for (int i = preset; i < gConfigThemes.num_presets - 1; i++) {
			gConfigThemes.presets[i] = gConfigThemes.presets[i + 1];
		}
		gConfigThemes.num_presets--;
		theme_change_preset(0);
	}
}
コード例 #5
0
ファイル: title_sequences.c プロジェクト: Aitchwing/OpenRCT2
void title_sequence_duplicate_preset(int duplicate, const char *name)
{
	if (duplicate >= 0 && duplicate < gConfigTitleSequences.num_presets && filename_valid_characters(name) && !title_sequence_name_exists(name)) {
		int preset = gConfigTitleSequences.num_presets;
		gConfigTitleSequences.num_presets++;
		gConfigTitleSequences.presets = realloc(gConfigTitleSequences.presets, sizeof(title_sequence) * (size_t)gConfigTitleSequences.num_presets);
		safe_strncpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
		gConfigTitleSequences.presets[preset].path[0] = 0;

		size_t savesSize = sizeof(char[TITLE_SEQUENCE_MAX_SAVE_LENGTH]) * gConfigTitleSequences.presets[duplicate].num_saves;
		size_t commandsSize = sizeof(title_command) * gConfigTitleSequences.presets[duplicate].num_commands;
		gConfigTitleSequences.presets[preset].saves = malloc(savesSize);
		gConfigTitleSequences.presets[preset].commands = malloc(commandsSize);
		memcpy(gConfigTitleSequences.presets[preset].saves, gConfigTitleSequences.presets[duplicate].saves, savesSize);
		memcpy(gConfigTitleSequences.presets[preset].commands, gConfigTitleSequences.presets[duplicate].commands, commandsSize);
		gConfigTitleSequences.presets[preset].num_saves = gConfigTitleSequences.presets[duplicate].num_saves;
		gConfigTitleSequences.presets[preset].num_commands = gConfigTitleSequences.presets[duplicate].num_commands;

		bool loadmm = false;
		for (int i = 0; i < gConfigTitleSequences.presets[preset].num_commands; i++) {
			if (gConfigTitleSequences.presets[preset].commands[i].command == TITLE_SCRIPT_LOADMM) {
				loadmm = true;
				gConfigTitleSequences.presets[preset].commands[i].command = TITLE_SCRIPT_LOAD;
				gConfigTitleSequences.presets[preset].commands[i].saveIndex = gConfigTitleSequences.presets[duplicate].num_saves;
			}
		}

		// Create the folder
		utf8 path[MAX_PATH], srcPath[MAX_PATH];
		platform_get_user_directory(path, "title sequences");
		strcat(path, gConfigTitleSequences.presets[preset].name);
		platform_file_delete(path);
		platform_ensure_directory_exists(path);

		// Copy the saves
		char separator = platform_get_path_separator();
		for (int i = 0; i < gConfigTitleSequences.presets[preset].num_saves; i++) {
			if (gConfigTitleSequences.presets[duplicate].path[0]) {
				safe_strncpy(srcPath, gConfigTitleSequences.presets[duplicate].path, MAX_PATH);
				strcat(srcPath, gConfigTitleSequences.presets[duplicate].saves[i]);
			}
			else {
				platform_get_user_directory(srcPath, "title sequences");
				strcat(srcPath, gConfigTitleSequences.presets[duplicate].name);
				strncat(srcPath, &separator, 1);
				strcat(srcPath, gConfigTitleSequences.presets[duplicate].saves[i]);
			}
			platform_get_user_directory(path, "title sequences");
			strcat(path, gConfigTitleSequences.presets[preset].name);
			strncat(path, &separator, 1);
			strcat(path, gConfigTitleSequences.presets[preset].saves[i]);

			platform_file_copy(srcPath, path, false);
		}

		if (loadmm) {
			title_sequence_add_save(preset, get_file_path(PATH_ID_SIXFLAGS_MAGICMOUNTAIN), "Six Flags Magic Mountain.SC6");
		}

		title_sequence_save_preset_script(preset);
		gCurrentTitleSequence = preset;
	}
}