diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index ac49ba3b02..6ab34cd7f3 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -106,7 +106,6 @@ static TrackDesign* _trackDesign; static std::vector _listItems; static char _directory[MAX_PATH]; -static char _shortenedDirectory[MAX_PATH]; static char _parentDirectory[MAX_PATH]; static u8string _extensionPattern; static u8string _defaultPath; @@ -527,7 +526,6 @@ public: SafeStrCpy(_directory, absoluteDirectory.c_str(), std::size(_directory)); // Note: This compares the pointers, not values _extensionPattern = extensionPattern; - _shortenedDirectory[0] = '\0'; _listItems.clear(); @@ -740,18 +738,15 @@ public: { DrawWidgets(dpi); - if (_shortenedDirectory[0] == '\0') - { - ShortenPath(_shortenedDirectory, sizeof(_shortenedDirectory), _directory, width - 8, FontStyle::Medium); - } + const auto shortPath = ShortenPath(_directory, width - 8, FontStyle::Medium); // Format text - thread_local std::string _buffer; - _buffer.assign("{BLACK}"); - _buffer += _shortenedDirectory; + std::string buffer; + buffer.assign("{BLACK}"); + buffer += shortPath; // Draw path text - const auto normalisedPath = Platform::StrDecompToPrecomp(_buffer.data()); + const auto normalisedPath = Platform::StrDecompToPrecomp(buffer.data()); const auto* normalisedPathC = normalisedPath.c_str(); auto ft = Formatter(); ft.Add(normalisedPathC); diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 884a7bf5f2..17be7c2c3e 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -218,13 +218,10 @@ public: // Scenario path if (gConfigGeneral.DebuggingTools) { - utf8 path[MAX_PATH]; + const auto shortPath = ShortenPath(scenario->Path, width - 6 - TabWidth, FontStyle::Medium); - ShortenPath(path, sizeof(path), scenario->Path, width - 6 - TabWidth, FontStyle::Medium); - - const utf8* pathPtr = path; auto ft = Formatter(); - ft.Add(pathPtr); + ft.Add(shortPath.c_str()); DrawTextBasic(dpi, windowPos + ScreenCoordsXY{ TabWidth + 3, height - 3 - 11 }, STR_STRING, ft, { colours[1] }); } diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 7c0cf9ae90..84fdaac1cd 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -470,11 +470,9 @@ public: // Show track file path (in debug mode) if (gConfigGeneral.DebuggingTools) { - utf8 pathBuffer[MAX_PATH]; - const utf8* pathPtr = pathBuffer; - ShortenPath(pathBuffer, sizeof(pathBuffer), path.c_str(), width, FontStyle::Medium); + const auto shortPath = ShortenPath(path, width, FontStyle::Medium); auto ft = Formatter(); - ft.Add(pathPtr); + ft.Add(shortPath.c_str()); DrawTextBasic( dpi, windowPos + ScreenCoordsXY{ 0, height - DEBUG_PATH_HEIGHT - 3 }, STR_STRING, ft, { colours[1] }); // TODO Check dpi