1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Load/save window: show folder icon next to folders (#23404)

This commit is contained in:
Aaron van Geffen
2024-12-14 16:14:22 +01:00
committed by GitHub
parent 8d645c6316
commit 7274c67c6c
5 changed files with 26 additions and 15 deletions

View File

@@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

View File

@@ -324,6 +324,9 @@
{
"path": "icons/colour_invisible_pressed.png"
},
{
"path": "icons/folder.png"
},
{
"path": "loader/loader_hybrid_supports.png",
"y": 10

View File

@@ -26,6 +26,7 @@
#include <openrct2/core/Guard.hpp>
#include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h>
#include <openrct2/network/network.h>
#include <openrct2/platform/Platform.h>
@@ -33,6 +34,7 @@
#include <openrct2/ride/TrackDesign.h>
#include <openrct2/scenario/Scenario.h>
#include <openrct2/scenes/title/TitleScene.h>
#include <openrct2/sprites.h>
#include <openrct2/ui/UiContext.h>
#include <openrct2/windows/Intent.h>
#include <openrct2/world/Park.h>
@@ -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<uint16_t>(_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<StringId>(STR_STRING);
ft.Add<char*>(_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<StringId>(STR_STRING);

View File

@@ -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