Client LuaCsForBarotrauma
RoundSummaryScreen.cs
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 using System;
4 using System.Collections.Generic;
5 
6 namespace Barotrauma
7 {
9  {
10  private Sprite backgroundSprite;
11  private RoundSummary roundSummary;
12  private LocalizedString loadText;
13 
14  private RectTransform prevGuiElementParent;
15 
16  public Exception LoadException;
17 
18  public static RoundSummaryScreen Select(Sprite backgroundSprite, RoundSummary roundSummary)
19  {
20  var summaryScreen = new RoundSummaryScreen()
21  {
22  roundSummary = roundSummary,
23  backgroundSprite = backgroundSprite,
24  prevGuiElementParent = roundSummary.Frame.RectTransform.Parent,
25  loadText = TextManager.Get("campaignstartingpleasewait")
26  };
27  roundSummary.Frame.RectTransform.Parent = summaryScreen.Frame.RectTransform;
28  summaryScreen.Select();
29  summaryScreen.AddToGUIUpdateList();
30  return summaryScreen;
31  }
32 
33  public override void Deselect()
34  {
35  roundSummary.Frame.RectTransform.Parent = prevGuiElementParent;
36  }
37 
38  public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
39  {
40  spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
41 
42  if (backgroundSprite != null)
43  {
44  float scale = Math.Max(GameMain.GraphicsWidth / backgroundSprite.size.X, GameMain.GraphicsHeight / backgroundSprite.size.Y);
45  backgroundSprite.Draw(spriteBatch, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) / 2, Color.White, backgroundSprite.size / 2, scale: scale);
46  }
47 
48  GUI.Draw(Cam, spriteBatch);
49 
50  LocalizedString loadingText = loadText + new string('.', (int)Timing.TotalTime % 3 + 1);
51  Vector2 textSize = GUIStyle.LargeFont.MeasureString(loadText);
52  GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight * 0.95f) - textSize / 2, loadingText, Color.White, font: GUIStyle.LargeFont);
53 
54  spriteBatch.End();
55  }
56 
57  public override void Update(double deltaTime)
58  {
59  base.Update(deltaTime);
60  if (LoadException != null)
61  {
62  var temp = LoadException;
63  LoadException = null;
64  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(temp).Throw();
65  }
66  }
67  }
68 }
RectTransform RectTransform
static int GraphicsWidth
Definition: GameMain.cs:162
static RasterizerState ScissorTestEnable
Definition: GameMain.cs:195
static int GraphicsHeight
Definition: GameMain.cs:168
RectTransform?? Parent
RectTransform(Vector2 relativeSize, RectTransform parent, Anchor anchor=Anchor.TopLeft, Pivot? pivot=null, Point? minSize=null, Point? maxSize=null, ScaleBasis scaleBasis=ScaleBasis.Normal)
override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
static RoundSummaryScreen Select(Sprite backgroundSprite, RoundSummary roundSummary)
override void Update(double deltaTime)
void Draw(ISpriteBatch spriteBatch, Vector2 pos, float rotate=0.0f, float scale=1.0f, SpriteEffects spriteEffect=SpriteEffects.None)