@@ -71,6 +71,7 @@ struct savedValues
71
71
LoadingPrimitive Loading ;
72
72
LoadingScreenPrimitive LoadingScreen ;
73
73
LoadingBarPrimitive LoadingBar ;
74
+ TimetableLoadingBarPrimitive TimetableLoadingBar ;
74
75
Matrix LoadingMatrix = Matrix . Identity ;
75
76
76
77
public GameStateRunActivity ( string [ ] args )
@@ -83,6 +84,7 @@ internal override void Dispose()
83
84
Loading . Dispose ( ) ;
84
85
LoadingScreen . Dispose ( ) ;
85
86
LoadingBar . Dispose ( ) ;
87
+ TimetableLoadingBar . Dispose ( ) ;
86
88
base . Dispose ( ) ;
87
89
}
88
90
@@ -106,6 +108,14 @@ internal override void Update(RenderFrame frame, double totalRealSeconds)
106
108
frame . AddPrimitive ( LoadingBar . Material , LoadingBar , RenderPrimitiveGroup . Overlay , ref LoadingMatrix ) ;
107
109
}
108
110
111
+ if ( Simulator != null && Simulator . TimetableMode && TimetableLoadingBar != null
112
+ && Simulator . TimetableLoadedFraction < 0.99f // 0.99 to hide loading bar at end of timetable pre-run
113
+ )
114
+ {
115
+ TimetableLoadingBar . Material . Shader . LoadingPercent = Simulator . TimetableLoadedFraction ;
116
+ frame . AddPrimitive ( TimetableLoadingBar . Material , TimetableLoadingBar , RenderPrimitiveGroup . Overlay , ref LoadingMatrix ) ;
117
+ }
118
+
109
119
base . Update ( frame , totalRealSeconds ) ;
110
120
}
111
121
@@ -116,7 +126,8 @@ internal override void Load()
116
126
Loading = new LoadingPrimitive ( Game ) ;
117
127
if ( LoadingBar == null )
118
128
LoadingBar = new LoadingBarPrimitive ( Game ) ;
119
-
129
+ if ( TimetableLoadingBar == null )
130
+ TimetableLoadingBar = new TimetableLoadingBarPrimitive ( Game ) ;
120
131
var args = Arguments ;
121
132
122
133
// Look for an action to perform.
@@ -1329,7 +1340,7 @@ protected override VertexPositionTexture[] GetVerticies(Game game)
1329
1340
1330
1341
class LoadingBarPrimitive : LoadingPrimitive
1331
1342
{
1332
- public LoadingBarPrimitive ( Game game )
1343
+ public LoadingBarPrimitive ( Game game )
1333
1344
: base ( game )
1334
1345
{
1335
1346
}
@@ -1341,17 +1352,42 @@ protected override LoadingMaterial GetMaterial(Game game)
1341
1352
1342
1353
protected override VertexPositionTexture [ ] GetVerticies ( Game game )
1343
1354
{
1344
- var w = game . RenderProcess . DisplaySize . X ;
1345
- var h = 10 ;
1346
- var x = - w / 2 - 0.5f ;
1347
- var y = game . RenderProcess . DisplaySize . Y / 2 - h - 0.5f ;
1355
+ GetLoadingBarSize ( game , out int w , out int h , out float x , out float y ) ;
1356
+ return GetLoadingBarCoords ( w , h , x , y ) ;
1357
+ }
1358
+
1359
+ protected VertexPositionTexture [ ] GetLoadingBarCoords ( int w , int h , float x , float y )
1360
+ {
1348
1361
return new [ ] {
1349
1362
new VertexPositionTexture ( new Vector3 ( x + 0 , - y - 0 , - 1 ) , new Vector2 ( 0 , 0 ) ) ,
1350
1363
new VertexPositionTexture ( new Vector3 ( x + w , - y - 0 , - 1 ) , new Vector2 ( 1 , 0 ) ) ,
1351
1364
new VertexPositionTexture ( new Vector3 ( x + 0 , - y - h , - 1 ) , new Vector2 ( 0 , 1 ) ) ,
1352
1365
new VertexPositionTexture ( new Vector3 ( x + w , - y - h , - 1 ) , new Vector2 ( 1 , 1 ) ) ,
1353
1366
} ;
1354
1367
}
1368
+
1369
+ protected static void GetLoadingBarSize ( Game game , out int w , out int h , out float x , out float y )
1370
+ {
1371
+ w = game . RenderProcess . DisplaySize . X ;
1372
+ h = 10 ;
1373
+ x = - w / 2 - 0.5f ;
1374
+ y = game . RenderProcess . DisplaySize . Y / 2 - h - 0.5f ;
1375
+ }
1376
+ }
1377
+
1378
+ class TimetableLoadingBarPrimitive : LoadingBarPrimitive
1379
+ {
1380
+ public TimetableLoadingBarPrimitive ( Game game )
1381
+ : base ( game )
1382
+ {
1383
+ }
1384
+
1385
+ protected override VertexPositionTexture [ ] GetVerticies ( Game game )
1386
+ {
1387
+ GetLoadingBarSize ( game , out int w , out int h , out float x , out float y ) ;
1388
+ y -= h + 1 ; // Allow for second bar and 1 pixel gap between
1389
+ return GetLoadingBarCoords ( w , h , x , y ) ;
1390
+ }
1355
1391
}
1356
1392
1357
1393
class LoadingMaterial : Material , IDisposable
@@ -1481,6 +1517,20 @@ public override void SetState(GraphicsDevice graphicsDevice, Material previousMa
1481
1517
}
1482
1518
}
1483
1519
1520
+ class TimetableLoadingBarMaterial : LoadingMaterial
1521
+ {
1522
+ public TimetableLoadingBarMaterial ( Game game )
1523
+ : base ( game )
1524
+ {
1525
+ }
1526
+
1527
+ public override void SetState ( GraphicsDevice graphicsDevice , Material previousMaterial )
1528
+ {
1529
+ base . SetState ( graphicsDevice , previousMaterial ) ;
1530
+ Shader . CurrentTechnique = Shader . Techniques [ "LoadingBar" ] ;
1531
+ }
1532
+ }
1533
+
1484
1534
class LoadingShader : Shader
1485
1535
{
1486
1536
readonly EffectParameter worldViewProjection ;
0 commit comments