(cc26984a5) Merge remote-tracking branch 'origin/dev' into human-ai

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:45:37 +03:00
parent 04997cd2f3
commit 68ced76e1b
53 changed files with 791 additions and 243 deletions
@@ -5,15 +5,19 @@ using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Barotrauma.Media;
using System.Linq;
namespace Barotrauma
{
class LoadingScreen
{
private Texture2D backgroundTexture, monsterTexture, titleTexture;
private Texture2D backgroundTexture;
private RenderTarget2D renderTarget;
private Sprite languageSelectionCursor;
private ScalableFont languageSelectionFont;
private Video splashScreen;
public Video SplashScreen
{
@@ -37,35 +41,6 @@ namespace Barotrauma
private string selectedTip;
public Vector2 CenterPosition;
public Vector2 TitlePosition;
private object loadMutex = new object();
private float? loadState;
public Vector2 TitleSize
{
get
{
lock (loadMutex)
{
return splashScreen;
}
}
set
{
lock (loadMutex)
{
splashScreen = value;
}
}
}
private float state;
private string selectedTip;
public Vector2 BackgroundPosition;
public Vector2 TitlePosition;
@@ -99,11 +74,17 @@ namespace Barotrauma
}
public bool WaitForLanguageSelection
{
get;
set;
}
public LoadingScreen(GraphicsDevice graphics)
{
backgroundTexture = TextureLoader.FromFile("Content/UI/titleBackground.png");
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
GameMain.Instance.OnResolutionChanged += () =>
GameMain.Instance.OnResolutionChanged += () =>
{
renderTarget?.Dispose();
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
@@ -120,7 +101,7 @@ namespace Barotrauma
try
{
DrawSplashScreen(spriteBatch);
if (SplashScreen!=null && SplashScreen.IsPlaying) return;
if (SplashScreen != null && SplashScreen.IsPlaying) return;
}
catch (Exception e)
{
@@ -128,20 +109,27 @@ namespace Barotrauma
GameMain.Config.EnableSplashScreen = false;
}
}
var titleStyle = GUI.Style?.GetComponentStyle("TitleText");
Sprite titleSprite = null;
if (!WaitForLanguageSelection && titleStyle != null && titleStyle.Sprites.ContainsKey(GUIComponent.ComponentState.None))
{
titleSprite = titleStyle.Sprites[GUIComponent.ComponentState.None].First()?.Sprite;
}
drawn = true;
graphics.SetRenderTarget(renderTarget);
Scale = GameMain.GraphicsHeight / 1500.0f;
float backgroundScale = GameMain.GraphicsHeight / 1500.0f;
float titleScale = MathHelper.SmoothStep(0.8f, 1.0f, state / 10.0f) * GameMain.GraphicsHeight / 1000.0f;
state += deltaTime;
if (DrawLoadingText)
{
CenterPosition = new Vector2(GameMain.GraphicsWidth * 0.3f, GameMain.GraphicsHeight / 2.0f);
TitlePosition = CenterPosition + new Vector2(-0.0f + (float)Math.Sqrt(state) * 220.0f, 0.0f) * Scale;
TitlePosition.X = Math.Min(TitlePosition.X, (float)GameMain.GraphicsWidth / 2.0f);
BackgroundPosition = new Vector2(GameMain.GraphicsWidth * 0.3f, GameMain.GraphicsHeight * 0.45f);
TitlePosition = new Vector2(GameMain.GraphicsWidth * 0.5f, GameMain.GraphicsHeight * 0.45f);
}
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
@@ -149,16 +137,10 @@ namespace Barotrauma
spriteBatch.Draw(backgroundTexture, BackgroundPosition, null, Color.White * Math.Min(state / 5.0f, 1.0f), 0.0f,
new Vector2(backgroundTexture.Width / 2.0f, backgroundTexture.Height / 2.0f),
Scale * 1.5f, SpriteEffects.None, 0.2f);
spriteBatch.Draw(monsterTexture,
CenterPosition + new Vector2((state % 40) * 100.0f - 1800.0f, (state % 40) * 30.0f - 200.0f) * Scale, null,
Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0.1f);
spriteBatch.Draw(titleTexture,
TitlePosition, null,
Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), Scale, SpriteEffects.None, 0.0f);
backgroundScale * 1.5f, SpriteEffects.None, 0.2f);
titleSprite?.Draw(spriteBatch, TitlePosition, Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), scale: titleScale);
spriteBatch.End();
graphics.SetRenderTarget(null);
@@ -171,10 +153,6 @@ namespace Barotrauma
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
spriteBatch.Draw(titleTexture,
TitlePosition, null,
Color.White * Math.Min((state - 3.0f) / 5.0f, 1.0f), 0.0f, new Vector2(titleTexture.Width / 2.0f, titleTexture.Height / 2.0f), Scale, SpriteEffects.None, 0.0f);
titleSprite?.Draw(spriteBatch, TitlePosition, Color.White * Math.Min((state - 1.0f) / 5.0f, 1.0f), scale: titleScale);
if (WaitForLanguageSelection)
@@ -219,6 +197,28 @@ namespace Barotrauma
spriteBatch.End();
}
private void DrawLanguageSelectionPrompt(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
{
if (languageSelectionFont == null)
{
languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", 28, graphicsDevice);
}
if (languageSelectionCursor == null)
{
languageSelectionCursor = new Sprite("Content/UI/cursor.png", Vector2.Zero);
}
Vector2 textPos = new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight * 0.25f);
Vector2 textSpacing = new Vector2(0.0f, (GameMain.GraphicsHeight * 0.5f) / TextManager.AvailableLanguages.Count());
foreach (string language in TextManager.AvailableLanguages)
{
languageSelectionFont.DrawString(spriteBatch, language, textPos - languageSelectionFont.MeasureString(language) / 2, Color.White * 0.8f);
textPos += textSpacing;
}
languageSelectionCursor.Draw(spriteBatch, PlayerInput.LatestMousePosition);
}
private void DrawSplashScreen(SpriteBatch spriteBatch)
{
if (SplashScreen != null)