26
26
#include < openrct2/core/Guard.hpp>
27
27
#include < openrct2/core/Path.hpp>
28
28
#include < openrct2/core/String.hpp>
29
+ #include < openrct2/drawing/Drawing.h>
29
30
#include < openrct2/localisation/Formatter.h>
30
31
#include < openrct2/network/network.h>
31
32
#include < openrct2/platform/Platform.h>
32
33
#include < openrct2/rct2/T6Exporter.h>
33
34
#include < openrct2/ride/TrackDesign.h>
34
35
#include < openrct2/scenario/Scenario.h>
35
36
#include < openrct2/scenes/title/TitleScene.h>
37
+ #include < openrct2/sprites.h>
36
38
#include < openrct2/ui/UiContext.h>
37
39
#include < openrct2/windows/Intent.h>
38
40
#include < openrct2/world/Park.h>
@@ -86,10 +88,10 @@ namespace OpenRCT2::Ui::Windows
86
88
87
89
static WindowBase* WindowOverwritePromptOpen (const std::string_view name, const std::string_view path);
88
90
89
- enum
91
+ enum class FileType : uint8_t
90
92
{
91
- TYPE_DIRECTORY ,
92
- TYPE_FILE ,
93
+ directory ,
94
+ file ,
93
95
};
94
96
95
97
struct LoadSaveListItem
@@ -99,7 +101,7 @@ namespace OpenRCT2::Ui::Windows
99
101
time_t date_modified{ 0 };
100
102
std::string date_formatted{};
101
103
std::string time_formatted{};
102
- uint8_t type{ 0 };
104
+ FileType type{};
103
105
bool loaded{ false };
104
106
};
105
107
@@ -116,7 +118,7 @@ namespace OpenRCT2::Ui::Windows
116
118
static bool ListItemSort (LoadSaveListItem& a, LoadSaveListItem& b)
117
119
{
118
120
if (a.type != b.type )
119
- return a.type - b.type < 0 ;
121
+ return EnumValue ( a.type ) - EnumValue ( b.type ) < 0 ;
120
122
121
123
switch (Config::Get ().general .LoadSaveSort )
122
124
{
@@ -525,7 +527,7 @@ namespace OpenRCT2::Ui::Windows
525
527
LoadSaveListItem newListItem;
526
528
newListItem.path = std::string (1 , ' A' + x) + " :" PATH_SEPARATOR;
527
529
newListItem.name = newListItem.path ;
528
- newListItem.type = TYPE_DIRECTORY ;
530
+ newListItem.type = FileType::directory ;
529
531
530
532
_listItems.push_back (std::move (newListItem));
531
533
}
@@ -577,7 +579,7 @@ namespace OpenRCT2::Ui::Windows
577
579
LoadSaveListItem newListItem;
578
580
newListItem.path = Path::Combine (absoluteDirectory, subDir);
579
581
newListItem.name = std::move (subDir);
580
- newListItem.type = TYPE_DIRECTORY ;
582
+ newListItem.type = FileType::directory ;
581
583
newListItem.loaded = false ;
582
584
583
585
_listItems.push_back (std::move (newListItem));
@@ -593,7 +595,7 @@ namespace OpenRCT2::Ui::Windows
593
595
{
594
596
LoadSaveListItem newListItem;
595
597
newListItem.path = scanner->GetPath ();
596
- newListItem.type = TYPE_FILE ;
598
+ newListItem.type = FileType::file ;
597
599
newListItem.date_modified = Platform::FileGetModifiedTime (newListItem.path .c_str ());
598
600
599
601
// Cache a human-readable version of the modified date.
@@ -950,7 +952,7 @@ namespace OpenRCT2::Ui::Windows
950
952
if (selectedItem >= no_list_items)
951
953
return ;
952
954
953
- if (_listItems[selectedItem].type == TYPE_DIRECTORY )
955
+ if (_listItems[selectedItem].type == FileType::directory )
954
956
{
955
957
// The selected item is a folder
956
958
int32_t includeNewItem;
@@ -967,9 +969,8 @@ namespace OpenRCT2::Ui::Windows
967
969
968
970
no_list_items = static_cast <uint16_t >(_listItems.size ());
969
971
}
970
- else
972
+ else // FileType::file
971
973
{
972
- // TYPE_FILE
973
974
// Load or overwrite
974
975
if ((_type & 0x01 ) == LOADSAVETYPE_SAVE)
975
976
WindowOverwritePromptOpen (_listItems[selectedItem].name , _listItems[selectedItem].path );
@@ -1011,15 +1012,21 @@ namespace OpenRCT2::Ui::Windows
1011
1012
DrawTextBasic (dpi, { 0 , y }, stringId, ft);
1012
1013
}
1013
1014
1015
+ // Folders get a folder icon
1016
+ if (_listItems[i].type == FileType::directory)
1017
+ {
1018
+ GfxDrawSprite (dpi, ImageId (SPR_G2_FOLDER), { 1 , y });
1019
+ }
1020
+
1014
1021
// Print filename
1015
1022
auto ft = Formatter ();
1016
1023
ft.Add <StringId>(STR_STRING);
1017
1024
ft.Add <char *>(_listItems[i].name .c_str ());
1018
- int32_t max_file_width = widgets[WIDX_SORT_NAME].width () - 10 ;
1019
- DrawTextEllipsised (dpi, { 10 , y }, max_file_width, stringId, ft);
1025
+ int32_t max_file_width = widgets[WIDX_SORT_NAME].width () - 15 ;
1026
+ DrawTextEllipsised (dpi, { 15 , y }, max_file_width, stringId, ft);
1020
1027
1021
1028
// Print formatted modified date, if this is a file
1022
- if (_listItems[i].type == TYPE_FILE )
1029
+ if (_listItems[i].type == FileType::file )
1023
1030
{
1024
1031
ft = Formatter ();
1025
1032
ft.Add <StringId>(STR_STRING);
0 commit comments