From 7274c67c6ce58a7e0e8224eff1907f9aa4c6b7a7 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 14 Dec 2024 16:14:22 +0100 Subject: [PATCH] Load/save window: show folder icon next to folders (#23404) --- distribution/changelog.txt | 1 + resources/g2/icons/folder.png | Bin 0 -> 654 bytes resources/g2/sprites.json | 3 +++ src/openrct2-ui/windows/LoadSave.cpp | 35 ++++++++++++++++----------- src/openrct2/sprites.h | 2 +- 5 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 resources/g2/icons/folder.png diff --git a/distribution/changelog.txt b/distribution/changelog.txt index dc7a25780a..a84f5c7301 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Improved: [#23260] Add diagonal (block) brakes to LSM Launched Roller Coaster. - Improved: [#23350] Increased the maximum width of the ride graph window. +- Improved: [#23404] Folders are now paired with an icon in the load/save window. - Fix: [#23286] Currency formatted incorrectly in the in game console. 0.4.17 (2024-12-08) diff --git a/resources/g2/icons/folder.png b/resources/g2/icons/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..75343e3545717009d491978fa1056f0e178fdd3f GIT binary patch literal 654 zcmaJB-t z;1EiN3?78yU|S0}WJp1%Lki&#n!zg$DGgkpHwbmeaKpFuAL!%#;4N=@Z;y|fyIYU8 z0ATm<#r{c^JC(L-4=Nx3QN96eK0bbVdQjE>fS@Rf<5)=&RaG{OmSvgUZg(*7qiCEY z^E@xgl4C&>K#{jwt@`R~QVHAkrtXHA~&aawIXBCTyEB;b;xdpnZ$G>PqoI zn?+_m?XB|Bx=5NN=nU8*cq$f{SnT3iP%mdBTCu3q(Y=RILIEfMI)<4z?vSKM(<4E+ zQj}@CojJ~(@1r;-xjH2htkMv4x@j_+!x^4n4W(`<_b2LTrjPS>gD2T0C8&&S@GVm^ zdrHsO{joVtoh0w4t6;H?aS`e&5N&95fc7xnCz=u6ibXTk+=VqNyaZh-Ox@r~yUDnk z5E#pab99N!itTUA}d7}|E^y0P!4hin_3^Sg$HwcEBNd+B-n^>H-r@eU(^_Vno!#s_+&TXIW3zVo<+=v%E-tQ5f9`F- X?e8Zal=t}8f3G?`INJa8{OrwNh1m&o literal 0 HcmV?d00001 diff --git a/resources/g2/sprites.json b/resources/g2/sprites.json index 1fd7ac0314..e6d11c1051 100644 --- a/resources/g2/sprites.json +++ b/resources/g2/sprites.json @@ -324,6 +324,9 @@ { "path": "icons/colour_invisible_pressed.png" }, + { + "path": "icons/folder.png" + }, { "path": "loader/loader_hybrid_supports.png", "y": 10 diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index a16b7e9743..2b429ed50a 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -86,10 +88,10 @@ namespace OpenRCT2::Ui::Windows static WindowBase* WindowOverwritePromptOpen(const std::string_view name, const std::string_view path); - enum + enum class FileType : uint8_t { - TYPE_DIRECTORY, - TYPE_FILE, + directory, + file, }; struct LoadSaveListItem @@ -99,7 +101,7 @@ namespace OpenRCT2::Ui::Windows time_t date_modified{ 0 }; std::string date_formatted{}; std::string time_formatted{}; - uint8_t type{ 0 }; + FileType type{}; bool loaded{ false }; }; @@ -116,7 +118,7 @@ namespace OpenRCT2::Ui::Windows static bool ListItemSort(LoadSaveListItem& a, LoadSaveListItem& b) { if (a.type != b.type) - return a.type - b.type < 0; + return EnumValue(a.type) - EnumValue(b.type) < 0; switch (Config::Get().general.LoadSaveSort) { @@ -525,7 +527,7 @@ namespace OpenRCT2::Ui::Windows LoadSaveListItem newListItem; newListItem.path = std::string(1, 'A' + x) + ":" PATH_SEPARATOR; newListItem.name = newListItem.path; - newListItem.type = TYPE_DIRECTORY; + newListItem.type = FileType::directory; _listItems.push_back(std::move(newListItem)); } @@ -577,7 +579,7 @@ namespace OpenRCT2::Ui::Windows LoadSaveListItem newListItem; newListItem.path = Path::Combine(absoluteDirectory, subDir); newListItem.name = std::move(subDir); - newListItem.type = TYPE_DIRECTORY; + newListItem.type = FileType::directory; newListItem.loaded = false; _listItems.push_back(std::move(newListItem)); @@ -593,7 +595,7 @@ namespace OpenRCT2::Ui::Windows { LoadSaveListItem newListItem; newListItem.path = scanner->GetPath(); - newListItem.type = TYPE_FILE; + newListItem.type = FileType::file; newListItem.date_modified = Platform::FileGetModifiedTime(newListItem.path.c_str()); // Cache a human-readable version of the modified date. @@ -950,7 +952,7 @@ namespace OpenRCT2::Ui::Windows if (selectedItem >= no_list_items) return; - if (_listItems[selectedItem].type == TYPE_DIRECTORY) + if (_listItems[selectedItem].type == FileType::directory) { // The selected item is a folder int32_t includeNewItem; @@ -967,9 +969,8 @@ namespace OpenRCT2::Ui::Windows no_list_items = static_cast(_listItems.size()); } - else + else // FileType::file { - // TYPE_FILE // Load or overwrite if ((_type & 0x01) == LOADSAVETYPE_SAVE) WindowOverwritePromptOpen(_listItems[selectedItem].name, _listItems[selectedItem].path); @@ -1011,15 +1012,21 @@ namespace OpenRCT2::Ui::Windows DrawTextBasic(dpi, { 0, y }, stringId, ft); } + // Folders get a folder icon + if (_listItems[i].type == FileType::directory) + { + GfxDrawSprite(dpi, ImageId(SPR_G2_FOLDER), { 1, y }); + } + // Print filename auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(_listItems[i].name.c_str()); - int32_t max_file_width = widgets[WIDX_SORT_NAME].width() - 10; - DrawTextEllipsised(dpi, { 10, y }, max_file_width, stringId, ft); + int32_t max_file_width = widgets[WIDX_SORT_NAME].width() - 15; + DrawTextEllipsised(dpi, { 15, y }, max_file_width, stringId, ft); // Print formatted modified date, if this is a file - if (_listItems[i].type == TYPE_FILE) + if (_listItems[i].type == FileType::file) { ft = Formatter(); ft.Add(STR_STRING); diff --git a/src/openrct2/sprites.h b/src/openrct2/sprites.h index 1025e97cd5..7f054ef764 100644 --- a/src/openrct2/sprites.h +++ b/src/openrct2/sprites.h @@ -972,9 +972,9 @@ enum : ImageIndex SPR_G2_MAP_GEN_TERRAIN_TAB, SPR_G2_MAP_GEN_BTN, SPR_G2_PEEP_SPAWN, - SPR_G2_ICON_PALETTE_INVISIBLE, SPR_G2_ICON_PALETTE_INVISIBLE_PRESSED, + SPR_G2_FOLDER, // G2 Loading progress