2f107db...5202af9

This commit is contained in:
Joonas Rikkonen
2019-03-18 21:42:26 +02:00
parent 58c92888b7
commit 044fd3344b
395 changed files with 27417 additions and 19754 deletions
@@ -1,10 +1,10 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Barotrauma.Media;
namespace Barotrauma
{
@@ -14,6 +14,25 @@ namespace Barotrauma
private RenderTarget2D renderTarget;
private Video splashScreen;
public Video SplashScreen
{
get
{
lock (loadMutex)
{
return splashScreen;
}
}
set
{
lock (loadMutex)
{
splashScreen = value;
}
}
}
private float state;
private string selectedTip;
@@ -22,11 +41,9 @@ namespace Barotrauma
public Vector2 TitlePosition;
private object loadMutex = new object();
private float? loadState;
#if !(LINUX || OSX)
Video splashScreenVideo;
VideoPlayer videoPlayer;
#endif
public Vector2 TitleSize
{
get { return new Vector2(titleTexture.Width, titleTexture.Height); }
@@ -40,15 +57,20 @@ namespace Barotrauma
public float? LoadState
{
get { return loadState; }
get
{
lock (loadMutex)
{
return loadState;
}
}
set
{
loadState = value;
if (GameSettings.VerboseLogging)
lock (loadMutex)
{
DebugConsole.NewMessage("Loading: " + value.ToString() + "%", Color.Yellow);
loadState = value;
DrawLoadingText = true;
}
DrawLoadingText = true;
}
}
@@ -60,24 +82,6 @@ namespace Barotrauma
public LoadingScreen(GraphicsDevice graphics)
{
#if !(LINUX || OSX)
if (GameMain.Config.EnableSplashScreen)
{
try
{
splashScreenVideo = GameMain.Instance.Content.Load<Video>("splashscreen");
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to load splashscreen", e);
GameMain.Config.EnableSplashScreen = false;
}
}
#endif
backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png");
titleTexture = TextureLoader.FromFile("Content/UI/titleText.png");
@@ -96,14 +100,12 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphics, float deltaTime)
{
#if !(LINUX || OSX)
if (GameMain.Config.EnableSplashScreen && splashScreenVideo != null)
if (GameMain.Config.EnableSplashScreen)
{
try
{
DrawSplashScreen(spriteBatch);
if (videoPlayer != null && videoPlayer.State == MediaState.Playing)
return;
if (SplashScreen!=null && SplashScreen.IsPlaying) return;
}
catch (Exception e)
{
@@ -111,7 +113,6 @@ namespace Barotrauma
GameMain.Config.EnableSplashScreen = false;
}
}
#endif
drawn = true;
@@ -162,16 +163,16 @@ namespace Barotrauma
if (DrawLoadingText)
{
string loadText = "";
if (loadState == 100.0f)
if (LoadState == 100.0f)
{
loadText = TextManager.Get("PressAnyKey");
}
else
{
loadText = TextManager.Get("Loading");
if (loadState != null)
if (LoadState != null)
{
loadText += " " + (int)loadState + " %";
loadText += " " + (int)LoadState + " %";
}
}
@@ -198,56 +199,27 @@ namespace Barotrauma
}
#if !(LINUX || OSX)
private void DrawSplashScreen(SpriteBatch spriteBatch)
{
bool vsync = GameMain.Config.VSyncEnabled;
if (videoPlayer == null)
if (SplashScreen != null)
{
// Enforce the vsync so that the video player doesn't eat all the vram
if (!GameMain.Config.VSyncEnabled)
if (SplashScreen.IsPlaying)
{
GameMain.Config.VSyncEnabled = true;
GameMain.Instance.ApplyGraphicsSettings();
}
videoPlayer = new VideoPlayer();
videoPlayer.Play(splashScreenVideo);
videoPlayer.Volume = GameMain.Config.SoundVolume;
}
else
{
Texture2D videoTexture = null;
if (videoPlayer.State == MediaState.Stopped)
{
videoPlayer.Dispose();
videoPlayer = null;
splashScreenVideo.Dispose();
splashScreenVideo = null;
// If the vsync was enforced, restore the user preference
if (GameMain.Config.VSyncEnabled != vsync)
{
GameMain.Config.VSyncEnabled = vsync;
GameMain.Instance.ApplyGraphicsSettings();
}
}
else
{
videoTexture = videoPlayer.GetTexture();
spriteBatch.Begin();
spriteBatch.Draw(videoTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.Draw(SplashScreen.GetTexture(), new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
if (PlayerInput.KeyHit(Keys.Space) || PlayerInput.KeyHit(Keys.Enter) || PlayerInput.LeftButtonDown())
{
videoPlayer.Stop();
SplashScreen.Dispose(); SplashScreen = null;
}
}
}
else
{
SplashScreen.Dispose(); SplashScreen = null;
}
}
}
#endif
bool drawn;
public IEnumerable<object> DoLoading(IEnumerable<object> loader)
@@ -270,7 +242,7 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
}
loadState = 100.0f;
LoadState = 100.0f;
yield return CoroutineStatus.Success;
}