From e3dc02441ada5b07e2671f468ffe7d6ec0a5b660 Mon Sep 17 00:00:00 2001 From: Harry Hopkinson <63599884+Harry-Hopkinson@users.noreply.github.com> Date: Sun, 29 Sep 2024 12:06:05 +0100 Subject: [PATCH] Close #22470: Set default paths for rct1/rct2 saves on Android --- distribution/changelog.txt | 1 + src/openrct2/config/Config.cpp | 24 ++--------------- src/openrct2/platform/Platform.Android.cpp | 10 ++++++++ src/openrct2/platform/Platform.Linux.cpp | 10 ++++++++ src/openrct2/platform/Platform.Win32.cpp | 30 ++++++++++++++++++++++ src/openrct2/platform/Platform.h | 4 +++ src/openrct2/platform/Platform.macOS.mm | 10 ++++++++ 7 files changed, 67 insertions(+), 22 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 4bda088d19..825b30d368 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Feature: [#15642] Track design placement can now use construction modifier keys (ctrl/shift). - Feature: [#21521] [Plugin] Add hook 'park.guest.softcap.calculate' called before calculating the soft guest cap. - Feature: [#22694] Park graphs have tooltips and can be resized like finance graphs. +- Improved: [#22470] Android: automatically detect RCT2 installs in /sdcard/rct2. - Improved: [#22777] Add long flat-to-steep track pieces to the Wooden and Classic Wooden Roller Coasters. - Change: [#22494] Themes window now displays colours and checkboxes vertically. - Change: [#22596] Land ownership fixes described by .parkpatch files are now only considered on scenarios. diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 0858edcb2e..c29f8a78be 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -678,15 +678,7 @@ namespace OpenRCT2::Config { LOG_VERBOSE("config_find_rct1_path(...)"); - static constexpr u8string_view searchLocations[] = { - R"(C:\Program Files\Steam\steamapps\common\Rollercoaster Tycoon Deluxe)", - R"(C:\Program Files (x86)\Steam\steamapps\common\Rollercoaster Tycoon Deluxe)", - R"(C:\GOG Games\RollerCoaster Tycoon Deluxe)", - R"(C:\Program Files\GalaxyClient\Games\RollerCoaster Tycoon Deluxe)", - R"(C:\Program Files (x86)\GalaxyClient\Games\RollerCoaster Tycoon Deluxe)", - R"(C:\Program Files\Hasbro Interactive\RollerCoaster Tycoon)", - R"(C:\Program Files (x86)\Hasbro Interactive\RollerCoaster Tycoon)", - }; + static std::vector searchLocations = Platform::GetSearchablePathsRCT1(); for (const auto& location : searchLocations) { @@ -723,19 +715,7 @@ namespace OpenRCT2::Config { LOG_VERBOSE("config_find_rct2_path(...)"); - static constexpr u8string_view searchLocations[] = { - R"(C:\Program Files\Steam\steamapps\common\Rollercoaster Tycoon 2)", - R"(C:\Program Files (x86)\Steam\steamapps\common\Rollercoaster Tycoon 2)", - R"(C:\GOG Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", - R"(C:\Program Files\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", - R"(C:\Program Files (x86)\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", - R"(C:\Program Files\Atari\RollerCoaster Tycoon 2)", - R"(C:\Program Files (x86)\Atari\RollerCoaster Tycoon 2)", - R"(C:\Program Files\Infogrames\RollerCoaster Tycoon 2)", - R"(C:\Program Files (x86)\Infogrames\RollerCoaster Tycoon 2)", - R"(C:\Program Files\Infogrames Interactive\RollerCoaster Tycoon 2)", - R"(C:\Program Files (x86)\Infogrames Interactive\RollerCoaster Tycoon 2)", - }; + static std::vector searchLocations = Platform::GetSearchablePathsRCT2(); for (const auto& location : searchLocations) { diff --git a/src/openrct2/platform/Platform.Android.cpp b/src/openrct2/platform/Platform.Android.cpp index 59effb1f70..b011e4db98 100644 --- a/src/openrct2/platform/Platform.Android.cpp +++ b/src/openrct2/platform/Platform.Android.cpp @@ -192,6 +192,16 @@ namespace OpenRCT2::Platform AndroidClassLoader::_classLoader, AndroidClassLoader::_findClassMethod, env->NewStringUTF(std::string(name).c_str()))); } + + std::vector GetSearchablePathsRCT1() + { + return { "/sdcard/rct1" }; + } + + std::vector GetSearchablePathsRCT2() + { + return { "/sdcard/rct2" }; + } } // namespace OpenRCT2::Platform JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* pjvm, void* reserved) diff --git a/src/openrct2/platform/Platform.Linux.cpp b/src/openrct2/platform/Platform.Linux.cpp index 120260a8a6..309bb959da 100644 --- a/src/openrct2/platform/Platform.Linux.cpp +++ b/src/openrct2/platform/Platform.Linux.cpp @@ -333,6 +333,16 @@ namespace OpenRCT2::Platform return u8"Rollercoaster Tycoon 2"; } + std::vector GetSearchablePathsRCT1() + { + return {}; + } + + std::vector GetSearchablePathsRCT2() + { + return {}; + } + # ifndef NO_TTF std::string GetFontPath(const TTFFontDescriptor& font) { diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 0a7b7c92f0..bf70e6598e 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -888,6 +888,36 @@ namespace OpenRCT2::Platform return false; } + std::vector GetSearchablePathsRCT1() + { + return { + R"(C:\Program Files\Steam\steamapps\common\Rollercoaster Tycoon Deluxe)", + R"(C:\Program Files (x86)\Steam\steamapps\common\Rollercoaster Tycoon Deluxe)", + R"(C:\GOG Games\RollerCoaster Tycoon Deluxe)", + R"(C:\Program Files\GalaxyClient\Games\RollerCoaster Tycoon Deluxe)", + R"(C:\Program Files (x86)\GalaxyClient\Games\RollerCoaster Tycoon Deluxe)", + R"(C:\Program Files\Hasbro Interactive\RollerCoaster Tycoon)", + R"(C:\Program Files (x86)\Hasbro Interactive\RollerCoaster Tycoon)", + }; + } + + std::vector GetSearchablePathsRCT2() + { + return { + R"(C:\Program Files\Steam\steamapps\common\Rollercoaster Tycoon 2)", + R"(C:\Program Files (x86)\Steam\steamapps\common\Rollercoaster Tycoon 2)", + R"(C:\GOG Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", + R"(C:\Program Files\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", + R"(C:\Program Files (x86)\GalaxyClient\Games\RollerCoaster Tycoon 2 Triple Thrill Pack)", + R"(C:\Program Files\Atari\RollerCoaster Tycoon 2)", + R"(C:\Program Files (x86)\Atari\RollerCoaster Tycoon 2)", + R"(C:\Program Files\Infogrames\RollerCoaster Tycoon 2)", + R"(C:\Program Files (x86)\Infogrames\RollerCoaster Tycoon 2)", + R"(C:\Program Files\Infogrames Interactive\RollerCoaster Tycoon 2)", + R"(C:\Program Files (x86)\Infogrames Interactive\RollerCoaster Tycoon 2)", + }; + } + } // namespace OpenRCT2::Platform #endif diff --git a/src/openrct2/platform/Platform.h b/src/openrct2/platform/Platform.h index c2923349d0..5530eda866 100644 --- a/src/openrct2/platform/Platform.h +++ b/src/openrct2/platform/Platform.h @@ -14,6 +14,7 @@ #include "../core/StringTypes.h" #include +#include #ifdef _WIN32 # define PATH_SEPARATOR u8"\\" @@ -126,6 +127,9 @@ namespace OpenRCT2::Platform bool SSE41Available(); bool AVX2Available(); + + std::vector GetSearchablePathsRCT1(); + std::vector GetSearchablePathsRCT2(); } // namespace OpenRCT2::Platform #ifdef __ANDROID__ diff --git a/src/openrct2/platform/Platform.macOS.mm b/src/openrct2/platform/Platform.macOS.mm index a3ff1ebb09..33015a37ff 100644 --- a/src/openrct2/platform/Platform.macOS.mm +++ b/src/openrct2/platform/Platform.macOS.mm @@ -280,6 +280,16 @@ namespace OpenRCT2::Platform } } } + + std::vector GetSearchablePathsRCT1() + { + return {}; + } + + std::vector GetSearchablePathsRCT2() + { + return {}; + } } #endif