"Undertow games" splashscreen

This commit is contained in:
Regalis
2017-02-04 16:51:09 +02:00
parent 5afca48a82
commit b375422c4e
6 changed files with 86 additions and 2 deletions
+6
View File
@@ -1031,6 +1031,9 @@
<Content Include="Content\UI\uiIcons.png"> <Content Include="Content\UI\uiIcons.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\utg_4.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\waterbump.png"> <Content Include="Content\waterbump.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -1645,6 +1648,9 @@
<None Include="Content\Sounds\Water\WaterAmbience1.ogg"> <None Include="Content\Sounds\Water\WaterAmbience1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="Content\utg_4.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\watershader.xnb"> <None Include="Content\watershader.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
+5
View File
@@ -49,3 +49,8 @@
/processorParam:DebugMode=Auto /processorParam:DebugMode=Auto
/build:damageshader.fx /build:damageshader.fx
#begin utg_4.mp4
/importer:H264Importer
/processor:VideoProcessor
/build:utg_4.mp4
Binary file not shown.
Binary file not shown.
+69 -1
View File
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@@ -23,6 +24,9 @@ namespace Barotrauma
private float? loadState; private float? loadState;
Video splashScreenVideo;
VideoPlayer videoPlayer;
public Vector2 TitleSize public Vector2 TitleSize
{ {
get { return new Vector2(titleTexture.Width, titleTexture.Height); } get { return new Vector2(titleTexture.Width, titleTexture.Height); }
@@ -49,10 +53,23 @@ namespace Barotrauma
get; get;
set; set;
} }
public LoadingScreen(GraphicsDevice graphics) public LoadingScreen(GraphicsDevice graphics)
{ {
if (GameMain.Config.EnableSplashScreen)
{
try
{
splashScreenVideo = GameMain.Instance.Content.Load<Video>("utg_4");
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to load splashscreen", e);
GameMain.Config.EnableSplashScreen = false;
}
}
backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png"); backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png"); monsterTexture = TextureLoader.FromFile("Content/UI/titleMonster.png");
titleTexture = TextureLoader.FromFile("Content/UI/titleText.png"); titleTexture = TextureLoader.FromFile("Content/UI/titleText.png");
@@ -65,6 +82,21 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphics, float deltaTime) public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphics, float deltaTime)
{ {
if (GameMain.Config.EnableSplashScreen && splashScreenVideo != null)
{
try
{
DrawSplashScreen(spriteBatch);
if (videoPlayer != null && videoPlayer.State == MediaState.Playing)
return;
}
catch (Exception e)
{
DebugConsole.ThrowError("Playing splash screen video failed", e);
GameMain.Config.EnableSplashScreen = false;
}
}
drawn = true; drawn = true;
graphics.SetRenderTarget(renderTarget); graphics.SetRenderTarget(renderTarget);
@@ -139,6 +171,42 @@ namespace Barotrauma
} }
private void DrawSplashScreen(SpriteBatch spriteBatch)
{
if (videoPlayer == null)
{
videoPlayer = new VideoPlayer();
videoPlayer.Play(splashScreenVideo);
}
else
{
Texture2D videoTexture = null;
if (videoPlayer.State == MediaState.Stopped)
{
videoPlayer.Dispose();
videoPlayer = null;
splashScreenVideo.Dispose();
splashScreenVideo = null;
}
else
{
videoTexture = videoPlayer.GetTexture();
spriteBatch.Begin();
spriteBatch.Draw(videoTexture, 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();
}
}
}
}
bool drawn; bool drawn;
public IEnumerable<object> DoLoading(IEnumerable<object> loader) public IEnumerable<object> DoLoading(IEnumerable<object> loader)
{ {
+6 -1
View File
@@ -62,6 +62,8 @@ namespace Barotrauma
public static bool VerboseLogging { get; set; } public static bool VerboseLogging { get; set; }
public bool EnableSplashScreen { get; set; }
public bool UnsavedSettings public bool UnsavedSettings
{ {
get get
@@ -154,6 +156,8 @@ namespace Barotrauma
VerboseLogging = ToolBox.GetAttributeBool(doc.Root, "verboselogging", false); VerboseLogging = ToolBox.GetAttributeBool(doc.Root, "verboselogging", false);
EnableSplashScreen = ToolBox.GetAttributeBool(doc.Root, "enablesplashscreen", true);
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length]; keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W); keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S); keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
@@ -236,7 +240,8 @@ namespace Barotrauma
new XAttribute("autocheckupdates", AutoCheckUpdates), new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume), new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume), new XAttribute("soundvolume", soundVolume),
new XAttribute("verboselogging", VerboseLogging)); new XAttribute("verboselogging", VerboseLogging),
new XAttribute("enablesplashscreen", EnableSplashScreen));
if (WasGameUpdated) if (WasGameUpdated)
{ {