Add a default button to the loadsave window

This commit is contained in:
Sijmen Schoon 2016-07-07 11:29:22 +02:00
parent 52ed90ed95
commit 127d94d451
3 changed files with 60 additions and 13 deletions

View File

@ -4199,6 +4199,8 @@ STR_5887 :Prefix
STR_5888 :Suffix
STR_5889 :Custom currency symbol
STR_5890 :Enter the currency symbol to display
STR_5898 :Default
STR_5899 :{SMALLFONT}{BLACK}Go to the default directory
#############
# Scenarios #

View File

@ -2668,6 +2668,9 @@ enum {
STR_SUFFIX = 5888,
STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE = 5889,
STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC = 5890,
STR_LOADSAVE_DEFAULT = 5898,
STR_LOADSAVE_DEFAULT_TIP = 5899,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768

View File

@ -45,19 +45,21 @@ enum {
WIDX_SORT_DATE,
WIDX_SCROLL,
WIDX_BROWSE,
WIDX_DEFAULT
};
// 0x9DE48C
static rct_widget window_loadsave_widgets[] = {
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_NONE, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, //Window close button
{ WWT_CLOSEBOX, 0, 4, 104, 36, 47, 2718, STR_NONE}, // Up
{ WWT_CLOSEBOX, 0, 105, 205, 36, 47, 2719, STR_NONE}, // New
{ WWT_CLOSEBOX, 0, 4, (WW - 5) / 2, 50, 61, STR_NONE, STR_NONE }, // Name
{ WWT_CLOSEBOX, 0, (WW - 5) / 2 + 1, WW - 5 - 1, 50, 61, STR_NONE, STR_NONE }, // Date
{ WWT_SCROLL, 0, 4, WW - 5, 61, WH - 40, 2, STR_NONE }, // File list
{ WWT_CLOSEBOX, 0, 4, 200, WH - 36, WH - 18, 2707, STR_NONE }, // Use native browser
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE },
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_NONE, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, //Window close button
{ WWT_CLOSEBOX, 0, 105, 205, 36, 47, 2718, STR_NONE}, // Up
{ WWT_CLOSEBOX, 0, 206, 307, 36, 47, 2719, STR_NONE}, // New
{ WWT_CLOSEBOX, 0, 4, (WW - 5) / 2, 50, 61, STR_NONE, STR_NONE }, // Name
{ WWT_CLOSEBOX, 0, (WW - 5) / 2 + 1, WW - 5 - 1, 50, 61, STR_NONE, STR_NONE }, // Date
{ WWT_SCROLL, 0, 4, WW - 5, 61, WH - 40, 2, STR_NONE }, // File list
{ WWT_CLOSEBOX, 0, 4, 200, WH - 36, WH - 18, 2707, STR_NONE }, // Use native browser
{ WWT_CLOSEBOX, 0, 4, 104, 36, 47, STR_LOADSAVE_DEFAULT, STR_LOADSAVE_DEFAULT_TIP }, // Go to default directory
{ WIDGETS_END }
};
@ -159,7 +161,7 @@ rct_window *window_loadsave_open(int type, char *defaultName)
if (w == NULL) {
w = window_create_centred(WW, WH, &window_loadsave_events, WC_LOADSAVE, WF_STICK_TO_FRONT);
w->widgets = window_loadsave_widgets;
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_UP) | (1 << WIDX_NEW) | (1 << WIDX_SORT_NAME) | (1 << WIDX_SORT_DATE) | (1 << WIDX_BROWSE);
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_UP) | (1 << WIDX_NEW) | (1 << WIDX_SORT_NAME) | (1 << WIDX_SORT_DATE) | (1 << WIDX_BROWSE) | (1 << WIDX_DEFAULT);
w->colours[0] = 7;
w->colours[1] = 7;
w->colours[2] = 7;
@ -247,9 +249,9 @@ rct_window *window_loadsave_open(int type, char *defaultName)
platform_get_user_directory(path, "tracks");
if (!platform_ensure_directory_exists(path)) {
log_error("Unable to create tracks directory.");
window_close(w);
return NULL;
log_error("Unable to create tracks directory.");
window_close(w);
return NULL;
}
*/
@ -387,6 +389,46 @@ static void window_loadsave_mouseup(rct_window *w, int widgetIndex)
window_loadsave_sort_list(0, _listItemsCount - 1);
window_invalidate(w);
break;
case WIDX_DEFAULT:
{
char directory[MAX_PATH];
char *ch = directory;
int includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
switch (_type & 0x0E) {
case LOADSAVETYPE_GAME:
platform_get_user_directory(directory, "save");
break;
case LOADSAVETYPE_LANDSCAPE:
platform_get_user_directory(directory, "landscape");
break;
case LOADSAVETYPE_SCENARIO:
platform_get_user_directory(directory, "scenario");
break;
case LOADSAVETYPE_TRACK:
/*
Uncomment when tracks get separated
platform_get_user_directory(directory, "track");
*/
safe_strcpy(directory, gRCT2AddressTracksPath, MAX_PATH);
ch = strchr(directory, '*');
if (ch != NULL)
*ch = 0;
break;
}
window_loadsave_populate_list(w, includeNewItem, ch, _extension);
window_init_scroll_widgets(w);
w->no_list_items = _listItemsCount;
break;
}
}
}