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 0000000000..75343e3545 Binary files /dev/null and b/resources/g2/icons/folder.png differ 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