@@ -45,6 +45,10 @@ public class RouteData
45
45
public RoadTrackDB RoadTrackDB { get ; set ; }
46
46
/// <summary>The signal config file containing, for instance, the information to distinguish normal and non-normal signals</summary>
47
47
public SignalConfigurationFile SigcfgFile { get ; set ; }
48
+ /// <summary>
49
+ /// <summary>Activity names</summary>
50
+ /// </summary>
51
+ public List < string > ActivityNames = new List < string > { } ;
48
52
49
53
private string storedRoutePath ;
50
54
private Dictionary < uint , string > signalFileNames ;
@@ -87,7 +91,7 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
87
91
}
88
92
catch
89
93
{
90
- }
94
+ }
91
95
92
96
string ORfilepath = System . IO . Path . Combine ( routePath , "OpenRails" ) ;
93
97
if ( File . Exists ( ORfilepath + @"\sigcfg.dat" ) )
@@ -102,6 +106,72 @@ public RouteData(string routePath, MessageDelegate messageDelegate)
102
106
{
103
107
//sigcfgFile = null; // default initialization
104
108
}
109
+
110
+ // read the activity location events and store them in the TrackDB.TrItemTable
111
+
112
+ ActivityNames . Clear ( ) ;
113
+ var directory = System . IO . Path . Combine ( routePath , "ACTIVITIES" ) ;
114
+ if ( System . IO . Directory . Exists ( directory ) )
115
+ {
116
+ // counting
117
+ int cnt = 0 ;
118
+
119
+ foreach ( var file in Directory . GetFiles ( directory , "*.act" ) )
120
+ {
121
+ try
122
+ {
123
+ var activityFile = new ActivityFile ( file ) ;
124
+ Events events = activityFile . Tr_Activity . Tr_Activity_File . Events ;
125
+ if ( events != null )
126
+ {
127
+ for ( int i = 0 ; i < events . EventList . Count ; i ++ )
128
+ {
129
+ if ( events . EventList [ i ] . GetType ( ) == typeof ( EventCategoryLocation ) )
130
+ {
131
+ cnt ++ ;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ catch { }
137
+ }
138
+
139
+ // adding
140
+ uint index = 0 ;
141
+ foreach ( var file in Directory . GetFiles ( directory , "*.act" ) )
142
+ {
143
+ try
144
+ {
145
+ var activityFile = new ActivityFile ( file ) ;
146
+ Events events = activityFile . Tr_Activity . Tr_Activity_File . Events ;
147
+ bool found = false ;
148
+ if ( events != null )
149
+ {
150
+ for ( int i = 0 ; i < events . EventList . Count ; i ++ )
151
+ {
152
+ if ( events . EventList [ i ] . GetType ( ) == typeof ( EventCategoryLocation ) )
153
+ {
154
+ EventCategoryLocation eventCategoryLocation = ( EventCategoryLocation ) events . EventList [ i ] ;
155
+ EventItem eventItem = new EventItem (
156
+ activityFile . Tr_Activity . Tr_Activity_Header . Name + ":" + eventCategoryLocation . Name ,
157
+ eventCategoryLocation . Outcomes . DisplayMessage ,
158
+ eventCategoryLocation . TileX , eventCategoryLocation . TileZ ,
159
+ eventCategoryLocation . X , 0 , eventCategoryLocation . Z ,
160
+ index ) ;
161
+ TrackDB . TrItemTable [ index ] = eventItem ;
162
+ index ++ ;
163
+ found = true ;
164
+ }
165
+ }
166
+ }
167
+ if ( found ) {
168
+ ActivityNames . Add ( activityFile . Tr_Activity . Tr_Activity_Header . Name ) ;
169
+ }
170
+ }
171
+ catch { }
172
+ }
173
+
174
+ }
105
175
}
106
176
107
177
/// <summary>
@@ -176,6 +246,32 @@ public string GetSignalFilename(uint signalIndex)
176
246
}
177
247
}
178
248
249
+ /// <summary>
250
+ /// represents an Activity Location EventItem
251
+ /// </summary>
252
+ /// defined in this trackviewer file because I want to keep changes localized to the TrackViewer
253
+
254
+ public class EventItem : TrItem
255
+ {
256
+ /// <summary>
257
+ /// Default constructor, no file parsing used
258
+ /// </summary>
259
+ public EventItem ( string itemName , string briefing , int tileX , int tileZ , float x , float y , float z , uint trItemId )
260
+ {
261
+ // ItemType is trEMPTY on purpose
262
+ // so that Orts.Formats.Msts.TrItem.trItemType does not need a change
263
+ ItemType = trItemType . trEMPTY ;
264
+ ItemName = itemName ;
265
+ TileX = tileX ;
266
+ TileZ = tileZ ;
267
+ X = x ;
268
+ Y = y ;
269
+ Z = z ;
270
+ TrItemId = trItemId ;
271
+ SData2 = briefing ;
272
+ }
273
+ }
274
+
179
275
/// <summary>
180
276
/// This is a big class where the drawing of everything in the track data base is done.
181
277
/// This means tracks themselves (meaning so-called vector nodes that contain a number of sections,
0 commit comments