(8015dd67d) Show a language selection prompt when launching the game for the first time (WIP)
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -43,18 +47,7 @@ namespace Barotrauma
|
||||
|
||||
private object loadMutex = new object();
|
||||
private float? loadState;
|
||||
|
||||
public Vector2 TitleSize
|
||||
{
|
||||
get { return new Vector2(titleTexture.Width, titleTexture.Height); }
|
||||
}
|
||||
|
||||
public float Scale
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
public float? LoadState
|
||||
{
|
||||
get
|
||||
@@ -80,12 +73,18 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -95,7 +94,6 @@ namespace Barotrauma
|
||||
selectedTip = TextManager.Get("LoadingScreenTip", true);
|
||||
}
|
||||
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphics, float deltaTime)
|
||||
{
|
||||
if (GameMain.Config.EnableSplashScreen)
|
||||
@@ -103,7 +101,7 @@ namespace Barotrauma
|
||||
try
|
||||
{
|
||||
DrawSplashScreen(spriteBatch);
|
||||
if (SplashScreen!=null && SplashScreen.IsPlaying) return;
|
||||
if (SplashScreen != null && SplashScreen.IsPlaying) return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -111,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);
|
||||
@@ -132,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);
|
||||
@@ -154,11 +153,13 @@ 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 (DrawLoadingText)
|
||||
if (WaitForLanguageSelection)
|
||||
{
|
||||
DrawLanguageSelectionPrompt(spriteBatch, graphics);
|
||||
}
|
||||
else if (DrawLoadingText)
|
||||
{
|
||||
string loadText = "";
|
||||
if (LoadState == 100.0f)
|
||||
@@ -194,7 +195,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)
|
||||
|
||||
Reference in New Issue
Block a user