1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Refactor a large amount of title sequence loading

Still not yet able to load parks from zip.
This commit is contained in:
Ted John
2016-11-12 17:12:11 +00:00
parent e6377b40ef
commit 0c51dee94d
13 changed files with 392 additions and 567 deletions

View File

@@ -325,6 +325,7 @@
<ClCompile Include="src\scenario.c" />
<ClCompile Include="src\ScenarioRepository.cpp" />
<ClCompile Include="src\title\TitleSequence.cpp" />
<ClCompile Include="src\title\TitleSequenceManager.cpp" />
<ClCompile Include="src\windows\changelog.c" />
<ClCompile Include="src\windows\multiplayer.c" />
<ClCompile Include="src\windows\network_status.c" />
@@ -570,6 +571,7 @@
<ClInclude Include="src\ScenarioSources.h" />
<ClInclude Include="src\sprites.h" />
<ClInclude Include="src\title\TitleSequence.h" />
<ClInclude Include="src\title\TitleSequenceManager.h" />
<ClInclude Include="src\version.h" />
<ClInclude Include="src\title.h" />
<ClInclude Include="src\util\sawyercoding.h" />

View File

@@ -17,7 +17,6 @@
#include "config.h"
#include "interface/keyboard_shortcut.h"
#include "interface/themes.h"
#include "interface/title_sequences.h"
#include "interface/viewport.h"
#include "localisation/language.h"
#include "localisation/localisation.h"
@@ -334,6 +333,7 @@ sound_configuration gConfigSound;
twitch_configuration gConfigTwitch;
network_configuration gConfigNetwork;
notification_configuration gConfigNotifications;
font_configuration gConfigFonts;
title_sequences_configuration gConfigTitleSequences;
static bool config_open(const utf8string path);
@@ -1090,324 +1090,4 @@ bool config_shortcut_keys_save()
return result;
}
#pragma endregion
#pragma region Title Sequences
static void title_sequence_open(const char *path, const char *customName);
void title_sequences_set_default()
{
char path[MAX_PATH];
char dataPath[MAX_PATH];
platform_get_user_directory(path, "title sequences", sizeof(path));
platform_ensure_directory_exists(path);
gConfigTitleSequences.presets = NULL;
gConfigTitleSequences.num_presets = 0;
platform_get_openrct_data_path(dataPath, sizeof(dataPath));
safe_strcat_path(dataPath, "title", MAX_PATH);
// RCT1 title sequence
safe_strcpy(path, dataPath, MAX_PATH);
safe_strcat_path(path, "rct1.parkseq", MAX_PATH);
title_sequence_open(path, language_get_string(STR_TITLE_SEQUENCE_RCT1));
// RCT1 (AA) title sequence
safe_strcpy(path, dataPath, MAX_PATH);
safe_strcat_path(path, "rct1aa.parkseq", MAX_PATH);
title_sequence_open(path, language_get_string(STR_TITLE_SEQUENCE_RCT1_AA));
// RCT1 (AA + LL) title sequence
safe_strcpy(path, dataPath, MAX_PATH);
safe_strcat_path(path, "rct1aall.parkseq", MAX_PATH);
title_sequence_open(path, language_get_string(STR_TITLE_SEQUENCE_RCT1_AA_LL));
// RCT2 title sequence
safe_strcpy(path, dataPath, MAX_PATH);
safe_strcat_path(path, "rct2.parkseq", MAX_PATH);
title_sequence_open(path, language_get_string(STR_TITLE_SEQUENCE_RCT2));
// OpenRCT2 title sequence
safe_strcpy(path, dataPath, MAX_PATH);
safe_strcat_path(path, "openrct2.parkseq", MAX_PATH);
title_sequence_open(path, language_get_string(STR_TITLE_SEQUENCE_OPENRCT2));
}
void title_sequences_load_presets()
{
utf8 path[MAX_PATH], titleDir[MAX_PATH];
int dirEnumHandle, i;
// Find all directories in the title sequences folder
platform_get_user_directory(path, "title sequences", sizeof(path));
dirEnumHandle = platform_enumerate_directories_begin(path);
while (platform_enumerate_directories_next(dirEnumHandle, titleDir)) {
platform_get_user_directory(path, "title sequences", sizeof(path));
safe_strcat(path, titleDir, sizeof(path));
title_sequence_open(path, NULL);
}
platform_enumerate_directories_end(dirEnumHandle);
// Check which title sequence is the current one
if (_stricmp(gConfigInterface.current_title_sequence_preset, "*RCT1") == 0) {
gCurrentTitleSequence = 0;
}
else if (_stricmp(gConfigInterface.current_title_sequence_preset, "*RCT1AA") == 0) {
gCurrentTitleSequence = 1;
}
else if (_stricmp(gConfigInterface.current_title_sequence_preset, "*RCT1AALL") == 0) {
gCurrentTitleSequence = 2;
}
else if (_stricmp(gConfigInterface.current_title_sequence_preset, "*RCT2") == 0) {
gCurrentTitleSequence = 3;
}
else if (_stricmp(gConfigInterface.current_title_sequence_preset, "*OPENRCT2") == 0) {
gCurrentTitleSequence = 4;
}
else {
for (i = TITLE_SEQUENCE_DEFAULT_PRESETS; i < gConfigTitleSequences.num_presets; i++) {
if (_stricmp(gConfigInterface.current_title_sequence_preset, gConfigTitleSequences.presets[i].name) == 0) {
gCurrentTitleSequence = i;
break;
}
}
if (i == gConfigTitleSequences.num_presets) {
gCurrentTitleSequence = 0;
}
}
gCurrentPreviewTitleSequence = gCurrentTitleSequence;
}
#define ZIP_STATIC 1
#include <zip.h>
static void * get_zip_data(zip_t * zip, const char * name, size_t * outSize)
{
void * data = NULL;
size_t dataSize = 0;
zip_stat_t zipFileStat;
if (zip_stat(zip, name, 0, &zipFileStat) == ZIP_ER_OK) {
zip_file_t * zipFile = zip_fopen(zip, name, 0);
if (zipFile != NULL) {
if (zipFileStat.size < SIZE_MAX) {
dataSize = zipFileStat.size;
data = malloc(dataSize);
size_t readBytes = zip_fread(zipFile, data, dataSize);
if (readBytes != dataSize) {
free(data);
data = NULL;
dataSize = 0;
}
zip_fclose(zipFile);
}
}
}
if (outSize != NULL) *outSize = dataSize;
return data;
}
#include "title/TitleSequence.h"
static void title_sequence_open(const char *path, const char *customName)
{
utf8 titlePath[MAX_PATH];
file_info fileInfo;
SDL_RWops *file;
int fileEnumHandle, i, preset;
char parts[3 * 128], *token, *part1, *part2;
TitleSequence * seq = LoadTitleSequence(path);
FreeTitleSequence(seq);
int error;
zip_t * zip = zip_open(path, ZIP_RDONLY, &error);
if (zip == NULL) {
// Unable to open zip
return;
}
size_t scriptLength;
char * script = (char *)get_zip_data(zip, "script.txt", &scriptLength);
if (script == NULL) {
// Unable to open script
zip_close(zip);
return;
}
zip_close(zip);
// Check if the preset is already loaded
// No need to read the first two presets as they're hardcoded in
for (preset = 0; preset < gConfigTitleSequences.num_presets; preset++) {
if (_stricmp(path, gConfigTitleSequences.presets[preset].name) == 0) {
return;
}
}
// Otherwise allocate one
if (preset == gConfigTitleSequences.num_presets) {
gConfigTitleSequences.num_presets++;
gConfigTitleSequences.presets = realloc(gConfigTitleSequences.presets, sizeof(title_sequence) * (size_t)gConfigTitleSequences.num_presets);
if (customName == NULL) {
char nameBuffer[MAX_PATH];
safe_strcpy(nameBuffer, path, MAX_PATH);
// Get folder name
// First strip off the last folder separator
*strrchr(nameBuffer, *PATH_SEPARATOR) = '\0';
// Then find the name of the folder
char *name = strrchr(nameBuffer, *PATH_SEPARATOR) + 1;
safe_strcpy(gConfigTitleSequences.presets[preset].name, name, TITLE_SEQUENCE_NAME_SIZE);
gConfigTitleSequences.presets[preset].path[0] = 0;
}
else {
safe_strcpy(gConfigTitleSequences.presets[preset].name, customName, TITLE_SEQUENCE_NAME_SIZE);
safe_strcpy(gConfigTitleSequences.presets[preset].path, path, MAX_PATH);
}
gConfigTitleSequences.presets[preset].saves = NULL;
gConfigTitleSequences.presets[preset].commands = NULL;
gConfigTitleSequences.presets[preset].num_saves = 0;
gConfigTitleSequences.presets[preset].num_commands = 0;
}
// Get the save file list
safe_strcpy(titlePath, path, sizeof(titlePath));
safe_strcat_path(titlePath, "*.sv6", sizeof(titlePath));
fileEnumHandle = platform_enumerate_files_begin(titlePath);
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
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);
safe_strcpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1][TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1] = '\0';
}
platform_enumerate_files_end(fileEnumHandle);
safe_strcpy(titlePath, path, sizeof(titlePath));
safe_strcat_path(titlePath, "*.sc6", sizeof(titlePath));
fileEnumHandle = platform_enumerate_files_begin(titlePath);
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
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);
safe_strcpy(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], fileInfo.path, TITLE_SEQUENCE_MAX_SAVE_LENGTH);
gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1][TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1] = '\0';
}
platform_enumerate_files_end(fileEnumHandle);
// Load the script file
file = SDL_RWFromMem(script, (int)scriptLength);
do {
title_script_get_line(file, parts);
token = &parts[0 * 128];
part1 = &parts[1 * 128];
part2 = &parts[2 * 128];
title_command command = { 0 };
command.command = 0xFF;
if (token[0] != 0) {
if (_stricmp(token, "LOAD") == 0) {
command.command = TITLE_SCRIPT_LOAD;
command.saveIndex = 0xFF;
for (i = 0; i < gConfigTitleSequences.presets[preset].num_saves && command.saveIndex == 0xFF; i++) {
if (_stricmp(part1, gConfigTitleSequences.presets[preset].saves[i]) == 0)
command.saveIndex = i;
}
} else if (_stricmp(token, "LOCATION") == 0) {
command.command = TITLE_SCRIPT_LOCATION;
command.x = atoi(part1) & 0xFF;
command.y = atoi(part2) & 0xFF;
} else if (_stricmp(token, "ROTATE") == 0) {
command.command = TITLE_SCRIPT_ROTATE;
command.rotations = atoi(part1) & 0xFF;
} else if (_stricmp(token, "ZOOM") == 0) {
command.command = TITLE_SCRIPT_ZOOM;
command.zoom = atoi(part1) & 0xFF;
} else if (_stricmp(token, "SPEED") == 0) {
command.command = TITLE_SCRIPT_SPEED;
command.speed = max(1, min(4, atoi(part1) & 0xFF));
} else if (_stricmp(token, "WAIT") == 0) {
command.command = TITLE_SCRIPT_WAIT;
command.seconds = atoi(part1) & 0xFF;
} else if (_stricmp(token, "RESTART") == 0) {
command.command = TITLE_SCRIPT_RESTART;
} else if (_stricmp(token, "END") == 0) {
command.command = TITLE_SCRIPT_END;
} else if (_stricmp(token, "LOADMM") == 0) {
command.command = TITLE_SCRIPT_LOADMM;
} else if (_stricmp(token, "LOADRCT1") == 0) {
command.command = TITLE_SCRIPT_LOADRCT1;
command.saveIndex = atoi(part1) & 0xFF;
}
}
if (command.command != 0xFF) {
gConfigTitleSequences.presets[preset].num_commands++;
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(title_command) * (size_t)gConfigTitleSequences.presets[preset].num_commands);
gConfigTitleSequences.presets[preset].commands[gConfigTitleSequences.presets[preset].num_commands - 1] = command;
}
} while (SDL_RWtell(file) < (int)scriptLength);
SDL_RWclose(file);
free(script);
}
void title_sequence_save_preset_script(int preset)
{
utf8 path[MAX_PATH];
SDL_RWops *file;
int i;
platform_get_user_directory(path, "title sequences", sizeof(path));
safe_strcat_path(path, gConfigTitleSequences.presets[preset].name, MAX_PATH);
safe_strcat_path(path, "script.txt", MAX_PATH);
file = SDL_RWFromFile(path, "wb");
if (file == NULL) {
log_error("Unable to write to script file.");
return;
}
for (i = 0; i < gConfigTitleSequences.presets[preset].num_commands; i++) {
title_command *command = &gConfigTitleSequences.presets[preset].commands[i];
switch (command->command) {
case TITLE_SCRIPT_LOAD:
if (command->saveIndex == 0xFF)
rwopsprintf(file, "LOAD <No save file>");
else
rwopsprintf(file, "LOAD %s", gConfigTitleSequences.presets[preset].saves[command->saveIndex]);
break;
case TITLE_SCRIPT_LOCATION:
rwopsprintf(file, "LOCATION %i %i", command->x, command->y);
break;
case TITLE_SCRIPT_ROTATE:
rwopsprintf(file, "ROTATE %i", command->rotations);
break;
case TITLE_SCRIPT_ZOOM:
rwopsprintf(file, "ZOOM %i", command->zoom);
break;
case TITLE_SCRIPT_SPEED:
rwopsprintf(file, "SPEED %i", command->speed);
break;
case TITLE_SCRIPT_WAIT:
rwopsprintf(file, "WAIT %i", command->seconds);
rwopswritenewline(file);
break;
case TITLE_SCRIPT_RESTART:
rwopsprintf(file, "RESTART");
break;
case TITLE_SCRIPT_END:
rwopsprintf(file, "END");
break;
}
rwopswritenewline(file);
}
SDL_RWclose(file);
}
#pragma endregion

View File

@@ -296,39 +296,6 @@ typedef struct theme_features {
uint8 rct1_scenario_font;
} theme_features;
#define TITLE_SEQUENCE_MAX_SAVE_LENGTH 51
typedef struct title_command {
uint8 command;
union {
uint8 saveIndex; // LOAD (this index is internal only)
uint8 x; // LOCATION
uint8 rotations; // ROTATE (counter-clockwise)
uint8 zoom; // ZOOM
uint8 speed; // SPEED
uint8 seconds; // WAIT
};
uint8 y; // LOCATION
} title_command;
#define TITLE_SEQUENCE_NAME_SIZE 256
typedef struct title_sequence {
char name[TITLE_SEQUENCE_NAME_SIZE];
char path[MAX_PATH]; // Needed for non-modifiable presets
char (*saves)[TITLE_SEQUENCE_MAX_SAVE_LENGTH];
title_command *commands;
uint8 num_saves;
uint16 num_commands;
} title_sequence;
typedef struct title_sequences_configuration {
title_sequence *presets;
uint16 num_presets;
} title_sequences_configuration;
typedef struct shortcut_entry {
uint8 key;
uint8 modifier;
@@ -341,7 +308,6 @@ extern twitch_configuration gConfigTwitch;
extern network_configuration gConfigNetwork;
extern notification_configuration gConfigNotifications;
extern font_configuration gConfigFonts;
extern title_sequences_configuration gConfigTitleSequences;
extern uint16 gShortcutKeys[SHORTCUT_COUNT];

View File

@@ -18,6 +18,7 @@
#include "../rct2.h"
#include "../title.h"
#include "../title/TitleSequence.h"
#include "../title/TitleSequenceManager.h"
#include "../util/util.h"
#include "title_sequences.h"
#include "window.h"
@@ -26,16 +27,18 @@
uint16 gCurrentTitleSequence;
uint16 gCurrentPreviewTitleSequence;
title_command TitleScriptMakeCommand(int command, int parameter1, int parameter2)
TitleCommand TitleScriptMakeCommand(int command, int parameter1, int parameter2)
{
title_command titleCommand = { (uint8)command, (uint8)parameter1, (uint8)parameter2 };
// TitleCommand titleCommand = { (uint8)command, (uint8)parameter1, (uint8)parameter2 };
TitleCommand titleCommand = { 0 };
return titleCommand;
}
bool title_sequence_name_exists(const char *name)
{
for (int i = 0; i < gConfigTitleSequences.num_presets; i++) {
if (_stricmp(gConfigTitleSequences.presets[i].name, name) == 0)
size_t count = title_sequence_manager_get_count();
for (size_t i = 0; i < count; i++) {
if (_stricmp(title_sequence_manager_get_name(i), name) == 0)
return true;
}
return false;
@@ -43,6 +46,8 @@ bool title_sequence_name_exists(const char *name)
bool title_sequence_save_exists(int preset, const char *name)
{
return false;
#if 0
utf8 newName[MAX_PATH];
const char *extension = path_get_extension(name);
safe_strcpy(newName, name, MAX_PATH);
@@ -53,43 +58,29 @@ bool title_sequence_save_exists(int preset, const char *name)
return true;
}
return false;
#endif
}
void title_sequence_change_preset(int preset)
{
if (preset >= 0 && preset < gConfigTitleSequences.num_presets) {
SafeFree(gConfigInterface.current_title_sequence_preset);
switch (preset) {
case 0:
gConfigInterface.current_title_sequence_preset = _strdup("*RCT1");
break;
case 1:
gConfigInterface.current_title_sequence_preset = _strdup("*RCT1AA");
break;
case 2:
gConfigInterface.current_title_sequence_preset = _strdup("*RCT1AALL");
break;
case 3:
gConfigInterface.current_title_sequence_preset = _strdup("*RCT2");
break;
case 4:
gConfigInterface.current_title_sequence_preset = _strdup("*OPENRCT2");
break;
default:
gConfigInterface.current_title_sequence_preset = _strdup(gConfigTitleSequences.presets[preset].name);
break;
}
gCurrentPreviewTitleSequence = preset;
int count = (int)title_sequence_manager_get_count();
if (preset < 0 || preset >= count) {
return;
}
window_invalidate_all();
// Switch to (and restart) this title sequence if it's valid
const utf8 * configId = title_sequence_manager_get_config_id(preset);
SafeFree(gConfigInterface.current_title_sequence_preset);
gConfigInterface.current_title_sequence_preset = _strdup(configId);
gCurrentPreviewTitleSequence = preset;
title_refresh_sequence();
window_invalidate_all();
}
void title_sequence_create_preset(const char *name)
{
#if 0
if (filename_valid_characters(name) && !title_sequence_name_exists(name)) {
int preset = gConfigTitleSequences.num_presets;
gConfigTitleSequences.num_presets++;
@@ -112,10 +103,12 @@ void title_sequence_create_preset(const char *name)
title_sequence_save_preset_script(preset);
gCurrentTitleSequence = preset;
}
#endif
}
void title_sequence_duplicate_preset(int duplicate, const char *name)
{
#if 0
if (duplicate >= 0 && duplicate < gConfigTitleSequences.num_presets && filename_valid_characters(name) && !title_sequence_name_exists(name)) {
int preset = gConfigTitleSequences.num_presets;
gConfigTitleSequences.num_presets++;
@@ -124,7 +117,7 @@ void title_sequence_duplicate_preset(int duplicate, const char *name)
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;
size_t commandsSize = sizeof(TitleCommand) * 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);
@@ -173,10 +166,12 @@ void title_sequence_duplicate_preset(int duplicate, const char *name)
title_sequence_save_preset_script(preset);
gCurrentTitleSequence = preset;
}
#endif
}
void title_sequence_delete_preset(int preset)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets) {
// Delete the folder
utf8 path[MAX_PATH];
@@ -201,10 +196,12 @@ void title_sequence_delete_preset(int preset)
else if (gCurrentPreviewTitleSequence == preset)
title_sequence_change_preset(0);
}
#endif
}
void title_sequence_rename_preset(int preset, const char *newName)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && filename_valid_characters(newName) && !title_sequence_name_exists(newName)) {
// Rename the folder
utf8 src[MAX_PATH], dest[MAX_PATH];
@@ -221,11 +218,13 @@ void title_sequence_rename_preset(int preset, const char *newName)
gConfigInterface.current_title_sequence_preset = gConfigTitleSequences.presets[preset].name;
}
}
#endif
}
void title_sequence_add_save(int preset, const char *path, const char *newName)
{
#if 0
utf8 newPath[MAX_PATH];
const char *extension = path_get_extension(newName);
safe_strcpy(newPath, newName, MAX_PATH);
@@ -249,10 +248,12 @@ void title_sequence_add_save(int preset, const char *path, const char *newName)
if (_stricmp(extension, ".sv6") != 0 && _stricmp(extension, ".sc6") != 0)
path_append_extension(gConfigTitleSequences.presets[preset].saves[gConfigTitleSequences.presets[preset].num_saves - 1], ".sv6", TITLE_SEQUENCE_MAX_SAVE_LENGTH);
}
#endif
}
void title_sequence_remove_save(int preset, int index)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index < gConfigTitleSequences.presets[preset].num_saves) {
// Delete the save file
utf8 path[MAX_PATH];
@@ -278,10 +279,12 @@ void title_sequence_remove_save(int preset, int index)
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);
}
#endif
}
void title_sequence_rename_save(int preset, int index, const char *newName)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index < gConfigTitleSequences.presets[preset].num_saves &&
filename_valid_characters(newName) && !title_sequence_save_exists(preset, newName)) {
@@ -305,22 +308,26 @@ void title_sequence_rename_save(int preset, int index, const char *newName)
path_append_extension(gConfigTitleSequences.presets[preset].saves[index], ".sv6", TITLE_SEQUENCE_MAX_SAVE_LENGTH);
title_sequence_save_preset_script(preset);
}
#endif
}
void title_sequence_add_command(int preset, title_command command)
void title_sequence_add_command(int preset, TitleCommand command)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets) {
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(title_command) * (size_t)(gConfigTitleSequences.presets[preset].num_commands + 1));
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(TitleCommand) * (size_t)(gConfigTitleSequences.presets[preset].num_commands + 1));
gConfigTitleSequences.presets[preset].commands[gConfigTitleSequences.presets[preset].num_commands] = command;
gConfigTitleSequences.presets[preset].num_commands++;
title_sequence_save_preset_script(preset);
}
#endif
}
void title_sequence_insert_command(int preset, int index, title_command command)
void title_sequence_insert_command(int preset, int index, TitleCommand command)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index <= gConfigTitleSequences.presets[preset].num_commands) {
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(title_command) * (size_t)(gConfigTitleSequences.presets[preset].num_commands + 1));
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(TitleCommand) * (size_t)(gConfigTitleSequences.presets[preset].num_commands + 1));
for (int i = gConfigTitleSequences.presets[preset].num_commands; i > index; i--) {
gConfigTitleSequences.presets[preset].commands[i] = gConfigTitleSequences.presets[preset].commands[i - 1];
}
@@ -328,36 +335,43 @@ void title_sequence_insert_command(int preset, int index, title_command command)
gConfigTitleSequences.presets[preset].num_commands++;
title_sequence_save_preset_script(preset);
}
#endif
}
void title_sequence_delete_command(int preset, int index)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index < gConfigTitleSequences.presets[preset].num_commands) {
for (int i = index; i < gConfigTitleSequences.presets[preset].num_commands - 1; i++) {
gConfigTitleSequences.presets[preset].commands[i] = gConfigTitleSequences.presets[preset].commands[i + 1];
}
gConfigTitleSequences.presets[preset].num_commands--;
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(title_command) * (size_t)gConfigTitleSequences.presets[preset].num_commands);
gConfigTitleSequences.presets[preset].commands = realloc(gConfigTitleSequences.presets[preset].commands, sizeof(TitleCommand) * (size_t)gConfigTitleSequences.presets[preset].num_commands);
title_sequence_save_preset_script(preset);
}
#endif
}
void title_sequence_move_down_command(int preset, int index)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index >= 0 && index + 1 < gConfigTitleSequences.presets[preset].num_commands) {
title_command command = gConfigTitleSequences.presets[preset].commands[index];
TitleCommand command = gConfigTitleSequences.presets[preset].commands[index];
gConfigTitleSequences.presets[preset].commands[index] = gConfigTitleSequences.presets[preset].commands[index + 1];
gConfigTitleSequences.presets[preset].commands[index + 1] = command;
title_sequence_save_preset_script(preset);
}
#endif
}
void title_sequence_move_up_command(int preset, int index)
{
#if 0
if (preset >= TITLE_SEQUENCE_DEFAULT_PRESETS && preset < gConfigTitleSequences.num_presets && index > 0 && index < gConfigTitleSequences.presets[preset].num_commands) {
title_command command = gConfigTitleSequences.presets[preset].commands[index];
TitleCommand command = gConfigTitleSequences.presets[preset].commands[index];
gConfigTitleSequences.presets[preset].commands[index] = gConfigTitleSequences.presets[preset].commands[index - 1];
gConfigTitleSequences.presets[preset].commands[index - 1] = command;
title_sequence_save_preset_script(preset);
}
#endif
}

View File

@@ -21,10 +21,11 @@
#include "window.h"
#include "../config.h"
#include "../title.h"
#include "../title/TitleSequence.h"
#define TITLE_SEQUENCE_DEFAULT_PRESETS 2
title_command TitleScriptMakeCommand(int command, int parameter1, int parameter2);
TitleCommand TitleScriptMakeCommand(int command, int parameter1, int parameter2);
#define TITLE_WAIT(t) TitleScriptMakeCommand(TITLE_SCRIPT_WAIT, t, 0)
#define TITLE_LOADMM() TitleScriptMakeCommand(TITLE_SCRIPT_LOADMM, 0, 0)
@@ -55,8 +56,8 @@ void title_sequence_remove_save(int preset, int index);
void title_sequence_rename_save(int preset, int index, const char *newName);
// Commands
void title_sequence_add_command(int preset, title_command command);
void title_sequence_insert_command(int preset, int index, title_command command);
void title_sequence_add_command(int preset, TitleCommand command);
void title_sequence_insert_command(int preset, int index, TitleCommand command);
void title_sequence_delete_command(int preset, int index);
void title_sequence_move_down_command(int preset, int index);
void title_sequence_move_up_command(int preset, int index);

View File

@@ -24,6 +24,7 @@
#include "localisation/date.h"
#include "localisation/localisation.h"
#include "interface/screenshot.h"
#include "interface/title_sequences.h"
#include "interface/viewport.h"
#include "intro.h"
#include "management/news_item.h"
@@ -35,15 +36,15 @@
#include "scenario.h"
#include "ScenarioRepository.h"
#include "ScenarioSources.h"
#include "title.h"
#include "title/TitleSequence.h"
#include "title/TitleSequenceManager.h"
#include "util/util.h"
#include "world/climate.h"
#include "world/map.h"
#include "world/park.h"
#include "world/scenery.h"
#include "world/sprite.h"
#include "title.h"
#include "interface/title_sequences.h"
#include "windows/error.h"
static const int gRandomShowcase = 0;
@@ -87,6 +88,9 @@ static int _scriptNoLoadsSinceRestart;
static int _scriptWaitCounter;
static int _scriptCurrentPreset;
static int _loadedTitleSequenceId = -1;
static TitleSequence * _loadedTitleSequence = NULL;
static void title_init_showcase();
static void title_update_showcase();
@@ -94,8 +98,6 @@ static uint8 *generate_random_script();
#pragma endregion
static uint8 *title_script_load();
/**
*
* rct2: 0x0068E8DA
@@ -167,6 +169,14 @@ void title_create_windows()
*/
static void title_init_showcase()
{
size_t seqId = title_sequence_manager_get_index_for_config_id(gConfigInterface.current_title_sequence_preset);
if (seqId == SIZE_MAX) {
seqId = title_sequence_manager_get_index_for_config_id("*OPENRCT2");
if (seqId == SIZE_MAX) {
seqId = 0;
}
}
title_sequence_change_preset((int)seqId);
title_refresh_sequence();
}
@@ -378,18 +388,11 @@ static void title_do_next_script_opcode()
} while (*(_currentScript - 1) != 0);
// Construct full relative path
if (gConfigTitleSequences.presets[_scriptCurrentPreset].path[0]) {
safe_strcpy(path, gConfigTitleSequences.presets[_scriptCurrentPreset].path, MAX_PATH);
}
else {
platform_get_user_directory(path, "title sequences", sizeof(path));
safe_strcat_path(path, gConfigTitleSequences.presets[_scriptCurrentPreset].name, sizeof(path));
}
safe_strcpy(path, _loadedTitleSequence->Path, sizeof(path));
safe_strcat_path(path, filename, sizeof(path));
if (title_load_park(path)) {
_scriptNoLoadsSinceRestart = 0;
gTitleScriptSave = gConfigTitleSequences.presets[gCurrentPreviewTitleSequence].commands[gTitleScriptCommand].saveIndex;
gTitleScriptSave = _loadedTitleSequence->Commands[gTitleScriptCommand].SaveIndex;
} else {
log_error("Failed to load: \"%s\" for the title sequence.", path);
script_opcode = *_currentScript;
@@ -574,159 +577,39 @@ static uint8 *generate_random_script()
return script;
}
#pragma region Load script.txt
void title_script_get_line(SDL_RWops *file, char *parts)
{
int i, c, part, cindex, whitespace, comment, load;
for (i = 0; i < 3; i++)
parts[i * 128] = 0;
part = 0;
cindex = 0;
whitespace = 1;
comment = 0;
load = 0;
for (; part < 3;) {
c = 0;
if (SDL_RWread(file, &c, 1, 1) != 1)
c = EOF;
if (c == '\n' || c == '\r' || c == EOF) {
parts[part * 128 + cindex] = 0;
return;
} else if (c == '#') {
parts[part * 128 + cindex] = 0;
comment = 1;
} else if (c == ' ' && !comment && !load) {
if (!whitespace) {
if (part == 0 && cindex == 4 && _strnicmp(parts, "LOAD", 4) == 0)
load = true;
parts[part * 128 + cindex] = 0;
part++;
cindex = 0;
}
} else if (!comment) {
whitespace = 0;
if (cindex < 127) {
parts[part * 128 + cindex] = c;
cindex++;
}
else {
parts[part * 128 + cindex] = 0;
part++;
cindex = 0;
}
}
}
}
static uint8 *title_script_load()
{
SDL_RWops *file;
char parts[3 * 128], *token, *part1, *part2, *src;
utf8 path[MAX_PATH];
platform_get_openrct_data_path(path, sizeof(path));
safe_strcat_path(path, "title", MAX_PATH);
safe_strcat_path(path, "script.txt", MAX_PATH);
log_verbose("loading title script, %s", path);
file = SDL_RWFromFile(path, "r");
if (file == NULL) {
log_error("unable to load title script");
return NULL;
}
sint64 fileSize = SDL_RWsize(file);
uint8 *binaryScript = (uint8*)malloc(1024 * 8);
if (binaryScript == NULL) {
SDL_RWclose(file);
log_error("unable to allocate memory for script");
return NULL;
}
uint8 *scriptPtr = binaryScript;
do {
title_script_get_line(file, parts);
token = &parts[0 * 128];
part1 = &parts[1 * 128];
part2 = &parts[2 * 128];
if (token[0] != 0) {
if (_stricmp(token, "LOAD") == 0) {
src = part1;
*scriptPtr++ = TITLE_SCRIPT_LOAD;
do {
*scriptPtr++ = *src++;
} while (*(src - 1) != 0);
} else if (_stricmp(token, "LOCATION") == 0) {
*scriptPtr++ = TITLE_SCRIPT_LOCATION;
*scriptPtr++ = atoi(part1) & 0xFF;
*scriptPtr++ = atoi(part2) & 0xFF;
} else if (_stricmp(token, "ROTATE") == 0) {
*scriptPtr++ = TITLE_SCRIPT_ROTATE;
*scriptPtr++ = atoi(part1) & 0xFF;
} else if (_stricmp(token, "ZOOM") == 0) {
*scriptPtr++ = TITLE_SCRIPT_ZOOM;
*scriptPtr++ = atoi(part1) & 0xFF;
} else if (_stricmp(token, "WAIT") == 0) {
*scriptPtr++ = TITLE_SCRIPT_WAIT;
*scriptPtr++ = atoi(part1) & 0xFF;
} else {
log_error("unknown token, %s", token);
SafeFree(binaryScript);
SDL_RWclose(file);
return NULL;
}
}
} while (SDL_RWtell(file) < fileSize);
SDL_RWclose(file);
*scriptPtr++ = TITLE_SCRIPT_RESTART;
int scriptLength = (int)(scriptPtr - binaryScript);
binaryScript = realloc(binaryScript, scriptLength);
if (binaryScript == NULL) {
log_error("unable to reallocate memory for script");
return NULL;
}
return binaryScript;
}
#pragma endregion
bool title_refresh_sequence()
{
_scriptCurrentPreset = gCurrentPreviewTitleSequence;
title_sequence *title = &gConfigTitleSequences.presets[_scriptCurrentPreset];
if (_loadedTitleSequenceId != _scriptCurrentPreset) {
FreeTitleSequence(_loadedTitleSequence);
const utf8 * path = title_sequence_manager_get_path(_scriptCurrentPreset);
_loadedTitleSequence = LoadTitleSequence(path);
_loadedTitleSequenceId = _scriptCurrentPreset;
}
TitleSequence *title = _loadedTitleSequence;
bool hasLoad = false, hasInvalidSave = false, hasWait = false, hasRestart = false;
for (int i = 0; i < title->num_commands && !hasInvalidSave; i++) {
if (title->commands[i].command == TITLE_SCRIPT_LOAD) {
if (title->commands[i].saveIndex == 0xFF)
for (int i = 0; i < title->NumCommands && !hasInvalidSave; i++) {
if (title->Commands[i].Type == TITLE_SCRIPT_LOAD) {
if (title->Commands[i].SaveIndex == 0xFF)
hasInvalidSave = true;
hasLoad = true;
}
else if (title->commands[i].command == TITLE_SCRIPT_LOADRCT1) {
else if (title->Commands[i].Type == TITLE_SCRIPT_LOADRCT1) {
hasLoad = true;
}
else if (title->commands[i].command == TITLE_SCRIPT_LOADMM) {
else if (title->Commands[i].Type == TITLE_SCRIPT_LOADMM) {
hasLoad = true;
}
else if (title->commands[i].command == TITLE_SCRIPT_WAIT && title->commands[i].seconds >= 4) {
else if (title->Commands[i].Type == TITLE_SCRIPT_WAIT && title->Commands[i].Seconds >= 4) {
hasWait = true;
}
else if (title->commands[i].command == TITLE_SCRIPT_RESTART) {
else if (title->Commands[i].Type == TITLE_SCRIPT_RESTART) {
hasRestart = true;
break;
}
else if (title->commands[i].command == TITLE_SCRIPT_END) {
else if (title->Commands[i].Type == TITLE_SCRIPT_END) {
break;
}
}
@@ -736,33 +619,33 @@ bool title_refresh_sequence()
binaryScript = malloc(1024 * 8);
scriptPtr = binaryScript;
for (int i = 0; i < title->num_commands; i++) {
*scriptPtr++ = title->commands[i].command;
switch (title->commands[i].command) {
for (int i = 0; i < title->NumCommands; i++) {
*scriptPtr++ = title->Commands[i].Type;
switch (title->Commands[i].Type) {
case TITLE_SCRIPT_LOADRCT1:
*scriptPtr++ = title->commands[i].saveIndex;
*scriptPtr++ = title->Commands[i].SaveIndex;
break;
case TITLE_SCRIPT_LOAD:
src = title->saves[title->commands[i].saveIndex];
src = title->Saves[title->Commands[i].SaveIndex];
do {
*scriptPtr++ = *src++;
} while (*(src - 1) != 0);
break;
case TITLE_SCRIPT_LOCATION:
*scriptPtr++ = title->commands[i].x;
*scriptPtr++ = title->commands[i].y;
*scriptPtr++ = title->Commands[i].X;
*scriptPtr++ = title->Commands[i].Y;
break;
case TITLE_SCRIPT_ROTATE:
*scriptPtr++ = title->commands[i].rotations;
*scriptPtr++ = title->Commands[i].Rotations;
break;
case TITLE_SCRIPT_ZOOM:
*scriptPtr++ = title->commands[i].zoom;
*scriptPtr++ = title->Commands[i].Zoom;
break;
case TITLE_SCRIPT_SPEED:
*scriptPtr++ = title->commands[i].speed;
*scriptPtr++ = title->Commands[i].Speed;
break;
case TITLE_SCRIPT_WAIT:
*scriptPtr++ = title->commands[i].seconds;
*scriptPtr++ = title->Commands[i].Seconds;
break;
}
}

View File

@@ -65,14 +65,17 @@ extern "C"
void FreeTitleSequence(TitleSequence * seq)
{
Memory::Free(seq->Name);
Memory::Free(seq->Path);
Memory::Free(seq->Commands);
for (size_t i = 0; i < seq->NumSaves; i++)
if (seq != nullptr)
{
Memory::Free(seq->Saves[i]);
Memory::Free(seq->Name);
Memory::Free(seq->Path);
Memory::Free(seq->Commands);
for (size_t i = 0; i < seq->NumSaves; i++)
{
Memory::Free(seq->Saves[i]);
}
Memory::Free(seq->Saves);
}
Memory::Free(seq->Saves);
}
}
@@ -265,3 +268,60 @@ static void * GetZipFileData(zip_t * zip, const char * name, size_t * outSize)
if (outSize != NULL) *outSize = dataSize;
return data;
}
/*
void title_sequence_save_preset_script(int preset)
{
utf8 path[MAX_PATH];
SDL_RWops *file;
int i;
platform_get_user_directory(path, "title sequences", sizeof(path));
safe_strcat_path(path, gConfigTitleSequences.presets[preset].name, MAX_PATH);
safe_strcat_path(path, "script.txt", MAX_PATH);
file = SDL_RWFromFile(path, "wb");
if (file == NULL) {
log_error("Unable to write to script file.");
return;
}
for (i = 0; i < gConfigTitleSequences.presets[preset].num_commands; i++) {
title_command *command = &gConfigTitleSequences.presets[preset].commands[i];
switch (command->command) {
case TITLE_SCRIPT_LOAD:
if (command->saveIndex == 0xFF)
rwopsprintf(file, "LOAD <No save file>");
else
rwopsprintf(file, "LOAD %s", gConfigTitleSequences.presets[preset].saves[command->saveIndex]);
break;
case TITLE_SCRIPT_LOCATION:
rwopsprintf(file, "LOCATION %i %i", command->x, command->y);
break;
case TITLE_SCRIPT_ROTATE:
rwopsprintf(file, "ROTATE %i", command->rotations);
break;
case TITLE_SCRIPT_ZOOM:
rwopsprintf(file, "ZOOM %i", command->zoom);
break;
case TITLE_SCRIPT_SPEED:
rwopsprintf(file, "SPEED %i", command->speed);
break;
case TITLE_SCRIPT_WAIT:
rwopsprintf(file, "WAIT %i", command->seconds);
rwopswritenewline(file);
break;
case TITLE_SCRIPT_RESTART:
rwopsprintf(file, "RESTART");
break;
case TITLE_SCRIPT_END:
rwopsprintf(file, "END");
break;
}
rwopswritenewline(file);
}
SDL_RWclose(file);
}
*/

View File

@@ -0,0 +1,154 @@
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include <vector>
#include "../core/FileScanner.h"
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "TitleSequenceManager.h"
extern "C"
{
#include "../localisation/localisation.h"
#include "../openrct2.h"
}
namespace TitleSequenceManager
{
struct PredefinedSequence
{
const utf8 * ConfigId;
const utf8 * Filename;
rct_string_id StringId;
};
const PredefinedSequence PredefinedSequences[] =
{
{ "*RCT1", "rct1.parkseq", STR_TITLE_SEQUENCE_RCT1 },
{ "*RCT1AA", "rct1aa.parkseq", STR_TITLE_SEQUENCE_RCT1_AA },
{ "*RCT1AALL", "rct1aall.parkseq", STR_TITLE_SEQUENCE_RCT1_AA_LL },
{ "*RCT2", "rct2.parkseq", STR_TITLE_SEQUENCE_RCT2 },
{ "*OPENRCT2", "openrct2.parkseq", STR_TITLE_SEQUENCE_OPENRCT2 },
};
std::vector<TitleSequenceManagerItem> _items;
static std::string GetNameFromSequencePath(const utf8 * path);
size_t GetCount()
{
return _items.size();
}
const TitleSequenceManagerItem * GetItem(size_t i)
{
return &_items[i];
}
void Scan()
{
utf8 path[MAX_PATH];
platform_get_openrct_data_path(path, sizeof(path));
Path::Append(path, sizeof(path), "title");
Path::Append(path, sizeof(path), "*.parkseq");
IFileScanner * fileScanner = Path::ScanDirectory(path, true);
while (fileScanner->Next())
{
const utf8 * path = fileScanner->GetPath();
TitleSequenceManagerItem item;
item.Name = GetNameFromSequencePath(path);
item.Path = std::string(path);
_items.push_back(item);
}
delete fileScanner;
}
static std::string GetNameFromSequencePath(const utf8 * path)
{
const utf8 * filename = Path::GetFileName(path);
for (const auto &pseq : PredefinedSequences)
{
if (String::Equals(filename, pseq.Filename, true))
{
return language_get_string(pseq.StringId);
}
}
utf8 * name = Path::GetFileNameWithoutExtension(filename);
std::string result = std::string(name);
Memory::Free(name);
return result;
}
}
extern "C"
{
size_t title_sequence_manager_get_count()
{
return TitleSequenceManager::GetCount();
}
const utf8 * title_sequence_manager_get_name(size_t index)
{
auto item = TitleSequenceManager::GetItem(index);
const utf8 * name = item->Name.c_str();
return name;
}
const utf8 * title_sequence_manager_get_path(size_t index)
{
auto item = TitleSequenceManager::GetItem(index);
const utf8 * name = item->Path.c_str();
return name;
}
const utf8 * title_sequence_manager_get_config_id(size_t index)
{
auto item = TitleSequenceManager::GetItem(index);
const utf8 * name = item->Name.c_str();
const utf8 * filename = Path::GetFileName(item->Path.c_str());
for (const auto &pseq : TitleSequenceManager::PredefinedSequences)
{
if (String::Equals(filename, pseq.Filename, true))
{
return pseq.ConfigId;
}
}
return name;
}
size_t title_sequence_manager_get_index_for_config_id(const utf8 * configId)
{
size_t count = TitleSequenceManager::GetCount();
for (size_t i = 0; i < count; i++)
{
const utf8 * cid = title_sequence_manager_get_config_id(i);
if (String::Equals(cid, configId))
{
return i;
}
}
return SIZE_MAX;
}
void title_sequence_manager_scan()
{
TitleSequenceManager::Scan();
}
}

View File

@@ -0,0 +1,46 @@
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#pragma once
#include "../common.h"
#ifdef __cplusplus
#include <string>
struct TitleSequenceManagerItem
{
std::string Name;
std::string Path;
};
namespace TitleSequenceManager
{
size_t GetCount();
const TitleSequenceManagerItem * GetItem(size_t i);
}
#else
size_t title_sequence_manager_get_count();
const utf8 * title_sequence_manager_get_name(size_t index);
const utf8 * title_sequence_manager_get_path(size_t index);
const utf8 * title_sequence_manager_get_config_id(size_t index);
size_t title_sequence_manager_get_index_for_config_id(const utf8 * configId);
void title_sequence_manager_scan();
#endif

View File

@@ -745,7 +745,7 @@ static void window_loadsave_select(rct_window *w, const char *path)
path_append_extension(newName, ".sv6", sizeof(newName));
if (title_sequence_save_exists(gCurrentTitleSequence, newName)) {
set_format_arg(0, intptr_t, (intptr_t)&_listItems[w->selected_list_item].name);
window_text_input_open(w, WIDX_SCROLL, STR_FILEBROWSER_RENAME_SAVE_TITLE, STR_ERROR_EXISTING_NAME, STR_STRING, (uintptr_t)_listItems[w->selected_list_item].name, TITLE_SEQUENCE_MAX_SAVE_LENGTH - 1);
window_text_input_open(w, WIDX_SCROLL, STR_FILEBROWSER_RENAME_SAVE_TITLE, STR_ERROR_EXISTING_NAME, STR_STRING, (uintptr_t)_listItems[w->selected_list_item].name, 52 - 1);
}
else {
title_sequence_add_save(gCurrentTitleSequence, path, newName);

View File

@@ -38,6 +38,8 @@
#include "../rct2.h"
#include "../sprites.h"
#include "../title.h"
#include "../title/TitleSequence.h"
#include "../title/TitleSequenceManager.h"
#include "dropdown.h"
#include "error.h"
#include "../util/util.h"
@@ -1123,11 +1125,10 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
dropdown_set_checked(gConfigGeneral.autosave_frequency, true);
break;
case WIDX_TITLE_SEQUENCE_DROPDOWN:
num_items = gConfigTitleSequences.num_presets;
num_items = (int)title_sequence_manager_get_count();
for (i = 0; i < num_items; i++) {
gDropdownItemsFormat[i] = STR_OPTIONS_DROPDOWN_ITEM;
gDropdownItemsArgs[i] = (uintptr_t)&gConfigTitleSequences.presets[i].name;
gDropdownItemsArgs[i] = (uintptr_t)title_sequence_manager_get_name(i);
}
window_dropdown_show_text(
@@ -1842,7 +1843,8 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
w->y + window_options_misc_widgets[WIDX_AUTOSAVE].top
);
set_format_arg(0, uintptr_t, (uintptr_t)&gConfigTitleSequences.presets[gCurrentPreviewTitleSequence].name);
const utf8 * name = title_sequence_manager_get_name(gCurrentPreviewTitleSequence);
set_format_arg(0, uintptr_t, (uintptr_t)name);
gfx_draw_string_left(dpi, STR_TITLE_SEQUENCE, w, w->colours[1], w->x + 10, w->y + window_options_misc_widgets[WIDX_TITLE_SEQUENCE].top + 1);
gfx_draw_string_left_clipped(
dpi,

View File

@@ -30,6 +30,8 @@
#include "../util/util.h"
#include "dropdown.h"
#if 0
typedef struct TITLE_COMMAND_ORDER {
uint8 command;
rct_string_id nameStringId;
@@ -192,8 +194,11 @@ static uint8 get_zoom()
return zoom;
}
#endif
void window_title_command_editor_open(int index, bool insert)
{
#if 0
rct_window* window;
// Check if window is already open
@@ -246,8 +251,11 @@ void window_title_command_editor_open(int index, bool insert)
snprintf(textbox1Buffer, BUF_SIZE, "%d", command.rotations);
break;
}
#endif
}
#if 0
static void window_title_command_editor_mouseup(rct_window *w, int widgetIndex)
{
rct_window *title_editor_w;
@@ -579,3 +587,5 @@ static void window_title_command_editor_paint(rct_window *w, rct_drawpixelinfo *
}
}
}
#endif

View File

@@ -43,6 +43,8 @@ enum {
WINDOW_TITLE_EDITOR_TAB_COUNT
} WINDOW_TITLE_EDITOR_TAB;
#if 0
static void window_title_editor_close(rct_window *w);
static void window_title_editor_mouseup(rct_window *w, int widgetIndex);
static void window_title_editor_resize(rct_window *w);
@@ -223,8 +225,11 @@ static void window_title_editor_draw_tab_images(rct_drawpixelinfo *dpi, rct_wind
}
}
#endif
void window_title_editor_open(int tab)
{
#if 0
rct_window* window;
// Check if window is already open
@@ -278,9 +283,10 @@ void window_title_editor_open(int tab)
window->min_height = WH;
window->max_width = 500;
window->max_height = 450;
#endif
}
#if 0
void window_title_editor_close(rct_window *w)
{
rct_window *command_editor_w, *load_save_w;
@@ -991,3 +997,4 @@ void window_title_editor_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int
}
}
}
#endif