diff --git a/contributors.md b/contributors.md index 5455a3cf60..73ff1c7d2e 100644 --- a/contributors.md +++ b/contributors.md @@ -76,7 +76,7 @@ The following people are not part of the development team, but have been contrib * Nicolas Hawrysh (xp4xbox) - Various (ride) sprite improvements. * Albert Morgese (Fusxfaranto) - Shop auto-rotation, unicode uppercasing. * Olivier Wervers (oli414) - Remove unused objects command, various bugfixes -* Christian Schubert (Osmodium) - Ensuring custom user content folders. +* Christian Schubert (Osmodium) - Ensuring custom user content folders, incl. open folder. ## Bug fixes * (halfbro) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 55a58e28a7..e7295d65fc 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3726,6 +3726,7 @@ STR_6262 :Master volume STR_6263 :{SMALLFONT}{BLACK}Toggle all sound on/off STR_6264 :Always use system file browser STR_6265 :{SMALLFONT}{BLACK}When enabled, your operating system's file browser will be used instead of OpenRCT2's. +STR_6266 :Open custom content folder ############# # Scenarios # diff --git a/src/openrct2-ui/UiContext.Win32.cpp b/src/openrct2-ui/UiContext.Win32.cpp index b6298c7a4b..e4da3840ca 100644 --- a/src/openrct2-ui/UiContext.Win32.cpp +++ b/src/openrct2-ui/UiContext.Win32.cpp @@ -91,6 +91,12 @@ namespace OpenRCT2::Ui MessageBoxW(hwnd, messageW.c_str(), L"OpenRCT2", MB_OK); } + void OpenFolder(const std::string& path) override + { + std::wstring pathW = String::ToUtf16(path); + ShellExecuteW(NULL, L"open", pathW.c_str(), NULL, NULL, SW_SHOWNORMAL); + } + std::string ShowFileDialog(SDL_Window* window, const FileDialogDesc& desc) override { std::wstring wcFilename = String::ToUtf16(desc.DefaultFilename); diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index f3555bc191..60ad83f239 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -581,6 +581,11 @@ public: _platformUiContext->ShowMessageBox(_window, message); } + void OpenFolder(const std::string& path) override + { + _platformUiContext->OpenFolder(path); + } + std::string ShowFileDialog(const FileDialogDesc& desc) override { return _platformUiContext->ShowFileDialog(_window, desc); diff --git a/src/openrct2-ui/UiContext.h b/src/openrct2-ui/UiContext.h index d411d9092c..cbfb44b418 100644 --- a/src/openrct2-ui/UiContext.h +++ b/src/openrct2-ui/UiContext.h @@ -33,6 +33,7 @@ namespace OpenRCT2 virtual bool IsSteamOverlayAttached() abstract; virtual void ShowMessageBox(SDL_Window * window, const std::string& message) abstract; + virtual void OpenFolder(const std::string& path) abstract; virtual std::string ShowFileDialog(SDL_Window * window, const FileDialogDesc& desc) abstract; virtual std::string ShowDirectoryDialog(SDL_Window * window, const std::string& title) abstract; }; diff --git a/src/openrct2-ui/windows/TitleMenu.cpp b/src/openrct2-ui/windows/TitleMenu.cpp index 0338efd17a..e068459a36 100644 --- a/src/openrct2-ui/windows/TitleMenu.cpp +++ b/src/openrct2-ui/windows/TitleMenu.cpp @@ -178,9 +178,10 @@ static void window_title_menu_mousedown(rct_window* w, rct_widgetindex widgetInd gDropdownItemsFormat[1] = STR_CONVERT_SAVED_GAME_TO_SCENARIO; gDropdownItemsFormat[2] = STR_ROLLER_COASTER_DESIGNER; gDropdownItemsFormat[3] = STR_TRACK_DESIGNS_MANAGER; + gDropdownItemsFormat[4] = STR_OPEN_CUSTOM_USER_FOLDER; window_dropdown_show_text( w->x + widget->left, w->y + widget->top, widget->bottom - widget->top + 1, TRANSLUCENT(w->colours[0]), - DROPDOWN_FLAG_STAY_OPEN, 4); + DROPDOWN_FLAG_STAY_OPEN, 5); } } @@ -202,6 +203,9 @@ static void window_title_menu_dropdown(rct_window* w, rct_widgetindex widgetInde case 3: Editor::LoadTrackManager(); break; + case 4: + context_open_custom_user_content_folder(); + break; } } } diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index a09ac2a5cb..99024461b8 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -1029,6 +1029,11 @@ namespace OpenRCT2 } delete scanner; } + + void OpenCustomUserContentFolder() final override + { + _uiContext->OpenFolder(_env->GetDirectoryPath(DIRBASE::USER)); + } }; Context* Context::Instance = nullptr; @@ -1262,6 +1267,11 @@ const utf8* context_get_path_legacy(int32_t pathId) return result; } +void context_open_custom_user_content_folder() +{ + GetContext()->OpenCustomUserContentFolder(); +} + bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize) { try diff --git a/src/openrct2/Context.h b/src/openrct2/Context.h index 9532ad2fba..32f67b48d0 100644 --- a/src/openrct2/Context.h +++ b/src/openrct2/Context.h @@ -116,6 +116,7 @@ namespace OpenRCT2 virtual void WriteLine(const std::string& s) abstract; virtual void Finish() abstract; virtual void Quit() abstract; + virtual void OpenCustomUserContentFolder() abstract; /** * This is deprecated, use IPlatformEnvironment. @@ -239,3 +240,4 @@ void context_quit(); const utf8* context_get_path_legacy(int32_t pathId); bool context_load_park_from_file(const utf8* path); bool context_load_park_from_stream(void* stream); +void context_open_custom_user_content_folder(); diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index f23704ab58..c4e81efe30 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3891,6 +3891,8 @@ enum STR_ALWAYS_NATIVE_LOADSAVE = 6264, STR_ALWAYS_NATIVE_LOADSAVE_TIP = 6265, + STR_OPEN_CUSTOM_USER_FOLDER = 6266, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2/ui/DummyUiContext.cpp b/src/openrct2/ui/DummyUiContext.cpp index f2a79179c9..010175e5e0 100644 --- a/src/openrct2/ui/DummyUiContext.cpp +++ b/src/openrct2/ui/DummyUiContext.cpp @@ -85,6 +85,9 @@ namespace OpenRCT2::Ui void ShowMessageBox(const std::string& /*message*/) override { } + void OpenFolder(const std::string& /*path*/) override + { + } std::string ShowFileDialog(const FileDialogDesc& /*desc*/) override { return std::string(); diff --git a/src/openrct2/ui/UiContext.h b/src/openrct2/ui/UiContext.h index d701abd81a..e65322f725 100644 --- a/src/openrct2/ui/UiContext.h +++ b/src/openrct2/ui/UiContext.h @@ -110,6 +110,7 @@ namespace OpenRCT2 virtual void TriggerResize() abstract; virtual void ShowMessageBox(const std::string& message) abstract; + virtual void OpenFolder(const std::string& path) abstract; virtual std::string ShowFileDialog(const FileDialogDesc& desc) abstract; virtual std::string ShowDirectoryDialog(const std::string& title) abstract;