mirror of https://github.com/OpenRCT2/OpenRCT2.git
Made window_loadsave_open accept a default file name
This fixes #1231, #1245, and adds room for future work, such as porting track saving.
This commit is contained in:
parent
75903ec2d9
commit
d3a6965f95
10
src/game.c
10
src/game.c
|
@ -568,7 +568,7 @@ static int open_load_game_dialog()
|
|||
*/
|
||||
static void load_landscape()
|
||||
{
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE);
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE, NULL);
|
||||
return;
|
||||
|
||||
if (open_landscape_file_dialog() == 0) {
|
||||
|
@ -612,6 +612,10 @@ int game_load_save(const char *path)
|
|||
|
||||
strcpy((char*)0x0141EF68, path);
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, path);
|
||||
|
||||
strcpy(scenarioSaveName, path_get_filename(path));
|
||||
path_remove_extension(scenarioSaveName);
|
||||
|
||||
file = fopen(path, "rb");
|
||||
if (file == NULL) {
|
||||
log_error("unable to open %s", path);
|
||||
|
@ -738,7 +742,7 @@ void reset_all_sprite_quadrant_placements()
|
|||
*/
|
||||
static void load_game()
|
||||
{
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME);
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME, NULL);
|
||||
return;
|
||||
|
||||
if (open_load_game_dialog() == 0) {
|
||||
|
@ -795,7 +799,7 @@ static int show_save_game_dialog(char *resultPath)
|
|||
|
||||
char save_game()
|
||||
{
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME);
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME, scenarioSaveName);
|
||||
return 0;
|
||||
|
||||
char path[256];
|
||||
|
|
|
@ -576,7 +576,7 @@ void window_themes_open();
|
|||
void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, rct_string_id existing_text, uint32 existing_args, int maxLength);
|
||||
void window_text_input_raw_open(rct_window* call_w, int call_widget, rct_string_id title, rct_string_id description, utf8string existing_text, int maxLength);
|
||||
rct_window *window_mapgen_open();
|
||||
rct_window *window_loadsave_open(int type);
|
||||
rct_window *window_loadsave_open(int type, char *defaultName);
|
||||
|
||||
void window_editor_main_open();
|
||||
void window_editor_bottom_toolbar_open();
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
static char _scenarioPath[MAX_PATH];
|
||||
static const char *_scenarioFileName;
|
||||
|
||||
char scenarioSaveName[MAX_PATH];
|
||||
|
||||
static int scenario_create_ducks();
|
||||
|
||||
/**
|
||||
|
@ -305,8 +307,9 @@ int scenario_load_and_play_from_path(const char *path)
|
|||
}
|
||||
|
||||
// Set the last saved game path
|
||||
format_string(scenarioSaveName, RCT2_GLOBAL(RCT2_ADDRESS_PARK_NAME, rct_string_id), (void*)RCT2_ADDRESS_PARK_NAME_ARGS);
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, (char*)RCT2_ADDRESS_SAVED_GAMES_PATH);
|
||||
format_string((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2 + strlen((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2), RCT2_GLOBAL(0x0013573D4, uint16), (void*)0x0013573D8);
|
||||
strcpy((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2 + strlen((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2), scenarioSaveName);
|
||||
strcat((char*)RCT2_ADDRESS_SAVED_GAMES_PATH_2, ".SV6");
|
||||
|
||||
memset((void*)0x001357848, 0, 56);
|
||||
|
@ -968,6 +971,9 @@ int scenario_save(char *path, int flags)
|
|||
rct_viewport *viewport;
|
||||
int viewX, viewY, viewZoom, viewRotation;
|
||||
|
||||
strcpy(scenarioSaveName, path_get_filename(path));
|
||||
path_remove_extension(scenarioSaveName);
|
||||
|
||||
if (flags & 2)
|
||||
log_verbose("saving scenario, %s", path);
|
||||
else
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "rct2.h"
|
||||
#include "object.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
/**
|
||||
* SV6/SC6 header chunk
|
||||
|
@ -400,6 +401,8 @@ extern int gScenarioListCount;
|
|||
extern int gScenarioListCapacity;
|
||||
extern rct_scenario_basic *gScenarioList;
|
||||
|
||||
extern char scenarioSaveName[MAX_PATH];
|
||||
|
||||
int scenario_scores_save();
|
||||
void scenario_load_list();
|
||||
rct_scenario_basic *get_scenario_by_filename(const char *filename);
|
||||
|
|
|
@ -314,7 +314,7 @@ void window_editor_bottom_toolbar_jump_forward_to_save_scenario()
|
|||
|
||||
window_close_all();
|
||||
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO);
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO, s6Info->name);
|
||||
return;
|
||||
|
||||
if (!show_save_scenario_dialog(path)) {
|
||||
|
|
|
@ -354,7 +354,7 @@ static void window_editor_object_selection_mouseup()
|
|||
}
|
||||
window_invalidate(w);
|
||||
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK);
|
||||
window_loadsave_open(LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK, NULL);
|
||||
break;
|
||||
case WIDX_FILTER_STRING_BUTTON:
|
||||
//window_text_input_open(w, widgetIndex, 5275, 5276, 1170, (uint32)_filter_string, 40);
|
||||
|
|
|
@ -113,6 +113,7 @@ int _listItemsCount = 0;
|
|||
loadsave_list_item *_listItems = NULL;
|
||||
char _directory[MAX_PATH];
|
||||
char _extension[32];
|
||||
char *_defaultName = NULL;
|
||||
int _loadsaveType;
|
||||
int _type;
|
||||
|
||||
|
@ -123,12 +124,13 @@ static int hasExtension(char *path, char *extension);
|
|||
|
||||
static rct_window *window_overwrite_prompt_open(const char *name, const char *path);
|
||||
|
||||
rct_window *window_loadsave_open(int type)
|
||||
rct_window *window_loadsave_open(int type, char *defaultName)
|
||||
{
|
||||
char path[MAX_PATH], *ch;
|
||||
int includeNewItem;
|
||||
rct_window* w;
|
||||
_type = type;
|
||||
_defaultName = defaultName;
|
||||
|
||||
w = window_bring_to_front_by_class(WC_LOADSAVE);
|
||||
if (w == NULL) {
|
||||
|
@ -346,8 +348,7 @@ static void window_loadsave_scrollmousedown()
|
|||
char *templateString;
|
||||
|
||||
templateString = (char*)language_get_string(templateStringId);
|
||||
strcpy(templateString, path_get_filename(RCT2_ADDRESS(RCT2_ADDRESS_SAVED_GAMES_PATH_2, char)));
|
||||
path_remove_extension(templateString);
|
||||
strcpy(templateString, _defaultName);
|
||||
|
||||
window_text_input_open(w, WIDX_SCROLL, STR_NONE, 2710, templateStringId, 0, 64);
|
||||
} else {
|
||||
|
|
|
@ -434,7 +434,8 @@ static void window_top_toolbar_dropdown()
|
|||
case DDIDX_SAVE_GAME:
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) {
|
||||
// RCT2_CALLPROC_EBPSAFE(0x0066FE2A);
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
|
||||
rct_s6_info *s6Info = (rct_s6_info*)0x0141F570;
|
||||
window_loadsave_open(LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE, s6Info->name);
|
||||
} else {
|
||||
tool_cancel();
|
||||
save_game();
|
||||
|
|
Loading…
Reference in New Issue