1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix track manager issues

This commit is contained in:
Ted John
2016-10-23 00:42:22 +01:00
parent f489bba4f0
commit 9eaf887546
2 changed files with 15 additions and 7 deletions

View File

@@ -135,6 +135,7 @@ public:
if (platform_file_delete(path)) if (platform_file_delete(path))
{ {
_items.erase(_items.begin() + index); _items.erase(_items.begin() + index);
result = true;
} }
} }
} }
@@ -153,19 +154,15 @@ public:
utf8 newPath[MAX_PATH]; utf8 newPath[MAX_PATH];
Path::GetDirectory(newPath, sizeof(newPath), path); Path::GetDirectory(newPath, sizeof(newPath), path);
Path::Append(newPath, sizeof(newPath), newName); Path::Append(newPath, sizeof(newPath), newName);
Path::Append(newPath, sizeof(newPath), Path::GetExtension(path)); String::Append(newPath, sizeof(newPath), Path::GetExtension(path));
if (platform_file_move(path, newPath)) if (platform_file_move(path, newPath))
{ {
item->Name = std::string(newName);
item->Path = std::string(newPath); item->Path = std::string(newPath);
SortItems(); SortItems();
item = GetTrackItem(path); result = newPath;
if (item != nullptr)
{
result = item->Path.c_str();
}
} }
} }
} }

View File

@@ -139,6 +139,7 @@ static rct_window_event_list window_track_delete_prompt_events = {
static track_design_file_ref *_trackDesignFileReference; static track_design_file_ref *_trackDesignFileReference;
static void window_track_delete_prompt_open(); static void window_track_delete_prompt_open();
static void window_track_design_list_reload_tracks();
/** /**
* *
@@ -231,6 +232,7 @@ static void window_track_manage_textinput(rct_window *w, int widgetIndex, char *
if (track_repository_rename(_trackDesignFileReference->path, text)) { if (track_repository_rename(_trackDesignFileReference->path, text)) {
window_close_by_class(WC_TRACK_DELETE_PROMPT); window_close_by_class(WC_TRACK_DELETE_PROMPT);
window_close(w); window_close(w);
window_track_design_list_reload_tracks();
} else { } else {
window_error_open(STR_CANT_RENAME_TRACK_DESIGN, STR_ANOTHER_FILE_EXISTS_WITH_NAME_OR_FILE_IS_WRITE_PROTECTED); window_error_open(STR_CANT_RENAME_TRACK_DESIGN, STR_ANOTHER_FILE_EXISTS_WITH_NAME_OR_FILE_IS_WRITE_PROTECTED);
} }
@@ -294,6 +296,7 @@ static void window_track_delete_prompt_mouseup(rct_window *w, int widgetIndex)
window_close(w); window_close(w);
if (track_repository_delete(_trackDesignFileReference->path)) { if (track_repository_delete(_trackDesignFileReference->path)) {
window_close_by_class(WC_MANAGE_TRACK_DESIGN); window_close_by_class(WC_MANAGE_TRACK_DESIGN);
window_track_design_list_reload_tracks();
} else { } else {
window_error_open(STR_CANT_DELETE_TRACK_DESIGN, STR_FILE_IS_WRITE_PROTECTED_OR_LOCKED); window_error_open(STR_CANT_DELETE_TRACK_DESIGN, STR_FILE_IS_WRITE_PROTECTED_OR_LOCKED);
} }
@@ -324,3 +327,11 @@ static void window_track_delete_prompt_paint(rct_window *w, rct_drawpixelinfo *d
0 0
); );
} }
static void window_track_design_list_reload_tracks()
{
rct_window * trackListWindow = window_find_by_class(WC_TRACK_DESIGN_LIST);
if (trackListWindow != NULL) {
trackListWindow->track_list.reload_track_designs = true;
}
}