Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Screens/Screen.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 {
8  abstract partial class Screen
9  {
10  public readonly GUIFrame Frame;
11 
12  protected Screen()
13  {
14  Frame = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: null)
15  {
16  CanBeFocused = false
17  };
18  }
19 
25  public virtual void AddToGUIUpdateList()
26  {
28  }
29 
30  public virtual void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
31  {
32  }
33 
34  public void ColorFade(Color from, Color to, float duration)
35  {
36  if (duration <= 0.0f) return;
37 
38  CoroutineManager.StartCoroutine(UpdateColorFade(from, to, duration));
39  }
40 
41  private IEnumerable<CoroutineStatus> UpdateColorFade(Color from, Color to, float duration)
42  {
43  while (Selected != this)
44  {
45  yield return CoroutineStatus.Running;
46  }
47 
48  float timer = 0.0f;
49 
50  while (timer < duration)
51  {
52  GUI.ScreenOverlayColor = Color.Lerp(from, to, Math.Min(timer / duration, 1.0f));
53  timer += CoroutineManager.DeltaTime;
54  yield return CoroutineStatus.Running;
55  }
56 
57  GUI.ScreenOverlayColor = to;
58 
59  yield return CoroutineStatus.Success;
60  }
61 
62  public virtual void OnFileDropped(string filePath, string extension) { }
63 
64  public virtual void Release()
65  {
66  Frame.RectTransform.Parent = null;
67  }
68  }
69 }
static CoroutineStatus Running
static CoroutineStatus Success
virtual void AddToGUIUpdateList(bool ignoreChildren=false, int order=0)
RectTransform RectTransform
RectTransform?? Parent
virtual void AddToGUIUpdateList()
By default, submits the screen's main GUIFrame and, if requested upon construction,...
void ColorFade(Color from, Color to, float duration)
virtual void OnFileDropped(string filePath, string extension)
virtual void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)