Fade in when shift starts, fixed fadeout canceling before screen is switched to lobby

This commit is contained in:
Regalis
2016-01-20 23:22:55 +02:00
parent 6f537ebc7c
commit 2761c4a610
5 changed files with 47 additions and 13 deletions

View File

@@ -182,9 +182,6 @@ namespace Barotrauma
{
GUI.Init(Content);
sw = new Stopwatch();
GUIComponent.Init(Window);
DebugConsole.Init(Window);
yield return CoroutineStatus.Running;
@@ -338,11 +335,8 @@ namespace Barotrauma
//{
// System.Threading.Thread.Sleep((int)((Physics.step - elapsed) * 1000.0));
//}
sw.Restart();
}
Stopwatch sw;
static bool waitForKeyHit = true;
public static void ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
{

View File

@@ -28,7 +28,6 @@ namespace Barotrauma
get
{
return currentMission;
return null;
}
}
@@ -137,6 +136,8 @@ namespace Barotrauma
if (gameMode!=null) gameMode.Start();
TaskManager.StartShift(level);
GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f);
}
public void EndShift(string endMessage)

View File

@@ -54,6 +54,14 @@ namespace Barotrauma
while (timer < duration)
{
if (Screen.Selected != GameMain.GameScreen)
{
yield return new WaitForSeconds(0.1f);
GUI.ScreenOverlayColor = Color.TransparentBlack;
yield return CoroutineStatus.Success;
}
cam.Zoom = Math.Max(0.2f, cam.Zoom - CoroutineManager.DeltaTime * 0.1f);
Vector2 cameraPos = sub.Position + Submarine.HiddenSubPosition;
@@ -73,10 +81,12 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
}
GUI.ScreenOverlayColor = Color.TransparentBlack;
Running = false;
yield return new WaitForSeconds(0.1f);
GUI.ScreenOverlayColor = Color.TransparentBlack;
yield return CoroutineStatus.Success;
}
}

View File

@@ -168,8 +168,6 @@ namespace Barotrauma
{
base.Select();
GUI.ScreenOverlayColor = Color.Transparent;
gameMode = GameMain.GameSession.gameMode as SinglePlayerMode;
foreach (GUIComponent component in topPanel.children)

View File

@@ -1,5 +1,7 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
namespace Barotrauma
{
@@ -20,8 +22,6 @@ namespace Barotrauma
{
if (selected != null && selected!=this) selected.Deselect();
selected = this;
GUI.ScreenOverlayColor = Color.Transparent;
}
public virtual void Update(double deltaTime)
@@ -32,5 +32,36 @@ namespace Barotrauma
{
}
public void ColorFade(Color from, Color to, float duration)
{
if (duration <= 0.0f) return;
CoroutineManager.StartCoroutine(UpdateColorFade(from, to, duration));
}
private IEnumerable<object> UpdateColorFade(Color from, Color to, float duration)
{
while (Screen.Selected != this)
{
yield return CoroutineStatus.Running;
}
float timer = 0.0f;
while (timer < duration)
{
GUI.ScreenOverlayColor = Color.Lerp(from, to, Math.Min(timer / duration, 1.0f));
timer += CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;
}
GUI.ScreenOverlayColor = to;
yield return CoroutineStatus.Success;
}
}
}