9
9
using OpenLoco . ObjectEditor . Data ;
10
10
using ReactiveUI . Fody . Helpers ;
11
11
using System . Reactive ;
12
+ using System . Security . Cryptography ;
12
13
13
14
namespace AvaGui . ViewModels
14
15
{
@@ -56,6 +57,12 @@ private void LoadObjDirectory(string directory, bool useExistingIndex)
56
57
{
57
58
DirectoryItems = new ( LoadObjDirectoryCore ( directory , useExistingIndex ) ) ;
58
59
60
+ // really just for debugging - puts all dat file types in the collection, even if they don't have anything in them
61
+ //foreach (var dat in Enum.GetValues<DatFileType>().Except(DirectoryItems.Select(x => ((FileSystemDatGroup)x).DatFileType)))
62
+ //{
63
+ // DirectoryItems.Add(new FileSystemDatGroup("", dat, new ObservableCollection<FileSystemItemBase>()));
64
+ //}
65
+
59
66
IEnumerable < FileSystemItemBase > LoadObjDirectoryCore ( string directory , bool useExistingIndex )
60
67
{
61
68
if ( string . IsNullOrEmpty ( directory ) )
@@ -75,46 +82,60 @@ IEnumerable<FileSystemItemBase> LoadObjDirectoryCore(string directory, bool useE
75
82
76
83
Model . LoadObjDirectory ( directory , null , useExistingIndex ) ;
77
84
78
- var groupedObjects = Model . HeaderIndex
85
+ var groupedDatObjects = Model . HeaderIndex
79
86
. Where ( o => ( string . IsNullOrEmpty ( FilenameFilter ) || o . Value . Name . Contains ( FilenameFilter , StringComparison . CurrentCultureIgnoreCase ) ) && ( ! DisplayVanillaOnly || o . Value . SourceGame == SourceGame . Vanilla ) )
80
- . GroupBy ( o => o . Value . ObjectType )
81
- . OrderBy ( fsg => fsg . Key . ToString ( ) ) ;
87
+ . GroupBy ( o => o . Value . DatFileType )
88
+ . OrderBy ( x => x . Key . ToString ( ) ) ;
82
89
83
- foreach ( var objGroup in groupedObjects )
90
+ foreach ( var datObjGroup in groupedDatObjects )
84
91
{
85
- ObservableCollection < FileSystemItemBase > subNodes ; //(objGroup.Select(o => new FileSystemItemBase(o.Key, o.Value.DatFileInfo.S5Header.Name.Trim())));
86
- if ( objGroup . Key == ObjectType . Vehicle )
92
+ ObservableCollection < FileSystemItemBase > groups = [ ] ;
93
+
94
+ var groupedObjects = datObjGroup
95
+ . GroupBy ( x => x . Value . ObjectType )
96
+ . OrderBy ( x => x . Key . ToString ( ) ) ;
97
+
98
+ foreach ( var objGroup in groupedObjects )
87
99
{
88
- subNodes = [ ] ;
89
- foreach ( var vg in objGroup
90
- . GroupBy ( o => o . Value . VehicleType )
91
- . OrderBy ( vg => vg . Key . ToString ( ) ) )
100
+ ObservableCollection < FileSystemItemBase > subNodes ;
101
+ if ( objGroup . Key == ObjectType . Vehicle )
92
102
{
93
- var vehicleSubNodes = new ObservableCollection < FileSystemItemBase > ( vg . Select ( o => new FileSystemItem ( o . Key , o . Value . Name . Trim ( ) , o . Value . SourceGame ) ) ) ;
94
-
95
- if ( vg . Key == null )
103
+ subNodes = [ ] ;
104
+ foreach ( var vg in objGroup
105
+ . GroupBy ( o => o . Value . VehicleType )
106
+ . OrderBy ( vg => vg . Key . ToString ( ) ) )
96
107
{
97
- // this should be impossible - object says its a vehicle but doesn't have a vehicle type
98
- // todo: move validation into the loading stage or cstr of IndexObjectHeader
99
- continue ;
108
+ var vehicleSubNodes = new ObservableCollection < FileSystemItemBase > ( vg . Select ( o => new FileSystemItem ( o . Key , o . Value . Name . Trim ( ) , o . Value . SourceGame ) ) ) ;
109
+
110
+ if ( vg . Key == null )
111
+ {
112
+ // this should be impossible - object says its a vehicle but doesn't have a vehicle type
113
+ // todo: move validation into the loading stage or cstr of IndexObjectHeader
114
+ continue ;
115
+ }
116
+
117
+ subNodes . Add ( new FileSystemVehicleGroup (
118
+ string . Empty ,
119
+ vg . Key . Value ,
120
+ vehicleSubNodes ) ) ;
100
121
}
101
-
102
- subNodes . Add ( new FileSystemVehicleGroup (
103
- string . Empty ,
104
- vg . Key . Value ,
105
- vehicleSubNodes ) ) ;
106
122
}
107
- }
108
- else
109
- {
110
- subNodes = new ObservableCollection < FileSystemItemBase > (
111
- objGroup . Select ( o => new FileSystemItem ( o . Key , o . Value . Name . Trim ( ) , o . Value . SourceGame ) ) ) ;
123
+ else
124
+ {
125
+ subNodes = new ObservableCollection < FileSystemItemBase > (
126
+ objGroup . Select ( o => new FileSystemItem ( o . Key , o . Value . Name . Trim ( ) , o . Value . SourceGame ) ) ) ;
127
+ }
128
+
129
+ groups . Add ( new FileSystemItemGroup (
130
+ string . Empty ,
131
+ objGroup . Key ,
132
+ subNodes ) ) ;
112
133
}
113
134
114
- yield return new FileSystemItemGroup (
135
+ yield return new FileSystemDatGroup (
115
136
string . Empty ,
116
- objGroup . Key ,
117
- subNodes ) ;
137
+ datObjGroup . Key ,
138
+ groups ) ;
118
139
}
119
140
}
120
141
}
0 commit comments