@@ -71,6 +71,7 @@ struct savedValues
7171 LoadingPrimitive Loading ;
7272 LoadingScreenPrimitive LoadingScreen ;
7373 LoadingBarPrimitive LoadingBar ;
74+ TimetableLoadingBarPrimitive TimetableLoadingBar ;
7475 Matrix LoadingMatrix = Matrix . Identity ;
7576
7677 public GameStateRunActivity ( string [ ] args )
@@ -83,6 +84,7 @@ internal override void Dispose()
8384 Loading . Dispose ( ) ;
8485 LoadingScreen . Dispose ( ) ;
8586 LoadingBar . Dispose ( ) ;
87+ TimetableLoadingBar . Dispose ( ) ;
8688 base . Dispose ( ) ;
8789 }
8890
@@ -106,6 +108,14 @@ internal override void Update(RenderFrame frame, double totalRealSeconds)
106108 frame . AddPrimitive ( LoadingBar . Material , LoadingBar , RenderPrimitiveGroup . Overlay , ref LoadingMatrix ) ;
107109 }
108110
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+
109119 base . Update ( frame , totalRealSeconds ) ;
110120 }
111121
@@ -116,7 +126,8 @@ internal override void Load()
116126 Loading = new LoadingPrimitive ( Game ) ;
117127 if ( LoadingBar == null )
118128 LoadingBar = new LoadingBarPrimitive ( Game ) ;
119-
129+ if ( TimetableLoadingBar == null )
130+ TimetableLoadingBar = new TimetableLoadingBarPrimitive ( Game ) ;
120131 var args = Arguments ;
121132
122133 // Look for an action to perform.
@@ -1329,7 +1340,7 @@ protected override VertexPositionTexture[] GetVerticies(Game game)
13291340
13301341 class LoadingBarPrimitive : LoadingPrimitive
13311342 {
1332- public LoadingBarPrimitive ( Game game )
1343+ public LoadingBarPrimitive ( Game game )
13331344 : base ( game )
13341345 {
13351346 }
@@ -1341,17 +1352,42 @@ protected override LoadingMaterial GetMaterial(Game game)
13411352
13421353 protected override VertexPositionTexture [ ] GetVerticies ( Game game )
13431354 {
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+ {
13481361 return new [ ] {
13491362 new VertexPositionTexture ( new Vector3 ( x + 0 , - y - 0 , - 1 ) , new Vector2 ( 0 , 0 ) ) ,
13501363 new VertexPositionTexture ( new Vector3 ( x + w , - y - 0 , - 1 ) , new Vector2 ( 1 , 0 ) ) ,
13511364 new VertexPositionTexture ( new Vector3 ( x + 0 , - y - h , - 1 ) , new Vector2 ( 0 , 1 ) ) ,
13521365 new VertexPositionTexture ( new Vector3 ( x + w , - y - h , - 1 ) , new Vector2 ( 1 , 1 ) ) ,
13531366 } ;
13541367 }
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+ }
13551391 }
13561392
13571393 class LoadingMaterial : Material , IDisposable
@@ -1481,6 +1517,20 @@ public override void SetState(GraphicsDevice graphicsDevice, Material previousMa
14811517 }
14821518 }
14831519
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+
14841534 class LoadingShader : Shader
14851535 {
14861536 readonly EffectParameter worldViewProjection ;
0 commit comments