mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix going up at top level and issue when saving
This commit is contained in:
parent
10babd3c77
commit
c59aadb676
|
@ -39,14 +39,14 @@ enum {
|
|||
WIDX_BACKGROUND,
|
||||
WIDX_TITLE,
|
||||
WIDX_CLOSE,
|
||||
WIDX_SCROLL
|
||||
WIDX_SCROLL,
|
||||
};
|
||||
|
||||
// 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 },
|
||||
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
|
||||
{ WWT_SCROLL, 0, 4, WW - 5, 18, WH - 18, 2, STR_NONE },
|
||||
{ WIDGETS_END }
|
||||
};
|
||||
|
@ -266,12 +266,29 @@ static void window_loadsave_scrollmousedown()
|
|||
templateString = (char*)language_get_string(templateStringId);
|
||||
strcpy(templateString, (char*)RCT2_ADDRESS_SCENARIO_NAME);
|
||||
window_text_input_open(w, WIDX_SCROLL, STR_NONE, 2710, templateStringId, 0, 64);
|
||||
} else {
|
||||
if (_listItems[selectedItem].path[strlen(_listItems[selectedItem].path) - 1] == '\\'){
|
||||
// The selected item is a folder
|
||||
int includeNewItem;
|
||||
|
||||
w->no_list_items = 0;
|
||||
w->selected_list_item = -1;
|
||||
|
||||
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
|
||||
|
||||
char directory[MAX_PATH];
|
||||
strncpy(directory, _listItems[selectedItem].path, sizeof(directory));
|
||||
|
||||
window_loadsave_populate_list(includeNewItem, 1, directory, _extension);
|
||||
|
||||
w->no_list_items = _listItemsCount;
|
||||
} else {
|
||||
if ((_loadsaveType & 1) == LOADSAVETYPE_SAVE)
|
||||
window_overwrite_prompt_open(_listItems[selectedItem].name, _listItems[selectedItem].path);
|
||||
else
|
||||
window_loadsave_select(w, _listItems[selectedItem].path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void window_loadsave_scrollmouseover()
|
||||
|
@ -392,12 +409,14 @@ static void window_loadsave_populate_list(int includeNewItem, int browsable, con
|
|||
_listItemsCount = 0;
|
||||
|
||||
if (browsable) {
|
||||
int topLevel = 1;
|
||||
int lastSlash = MAX_PATH;
|
||||
for (int index = MAX_PATH - 3; index >= 0; index--){
|
||||
if (directory[index] == '\\'){
|
||||
if (lastSlash != MAX_PATH){
|
||||
// The last slash has been changed before, we're now one up
|
||||
lastSlash = index;
|
||||
topLevel = 0;
|
||||
break;
|
||||
} else {
|
||||
// The last slash, after the whole path
|
||||
|
@ -405,6 +424,7 @@ static void window_loadsave_populate_list(int includeNewItem, int browsable, con
|
|||
}
|
||||
}
|
||||
}
|
||||
if (!topLevel){
|
||||
listItem = &_listItems[_listItemsCount];
|
||||
strncpy(listItem->name, "(up) ", sizeof(listItem->name));
|
||||
strncat(listItem->name, directory, sizeof(listItem->name) - strlen(listItem->name));
|
||||
|
@ -412,6 +432,7 @@ static void window_loadsave_populate_list(int includeNewItem, int browsable, con
|
|||
strncpy(listItem->path, directory, lastSlash + 1);
|
||||
_listItemsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (includeNewItem) {
|
||||
listItem = &_listItems[_listItemsCount];
|
||||
|
@ -464,22 +485,7 @@ static void window_loadsave_populate_list(int includeNewItem, int browsable, con
|
|||
|
||||
static void window_loadsave_select(rct_window *w, const char *path)
|
||||
{
|
||||
if (path[strlen(path) - 1] == '\\'){
|
||||
|
||||
int includeNewItem;
|
||||
|
||||
w->no_list_items = 0;
|
||||
w->selected_list_item = -1;
|
||||
|
||||
includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE;
|
||||
|
||||
char directory[MAX_PATH];
|
||||
strncpy(directory, path, sizeof(directory));
|
||||
|
||||
window_loadsave_populate_list(includeNewItem, 1, directory, _extension);
|
||||
|
||||
w->no_list_items = _listItemsCount;
|
||||
} else {
|
||||
switch (_loadsaveType) {
|
||||
case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME) :
|
||||
if (game_load_save(path)) {
|
||||
|
@ -543,7 +549,6 @@ static void window_loadsave_select(rct_window *w, const char *path)
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma region Overwrite prompt
|
||||
|
|
Loading…
Reference in New Issue