2f107db...5202af9
This commit is contained in:
@@ -172,7 +172,7 @@ namespace Barotrauma
|
||||
|
||||
float prevSize = chatBox.BarSize;
|
||||
|
||||
string displayedText = message.Text;
|
||||
string displayedText = message.TranslatedText;
|
||||
string senderName = "";
|
||||
if (!string.IsNullOrWhiteSpace(message.SenderName))
|
||||
{
|
||||
@@ -245,7 +245,7 @@ namespace Barotrauma
|
||||
|
||||
if ((prevSize == 1.0f && chatBox.BarScroll == 0.0f) || (prevSize < 1.0f && chatBox.BarScroll == 1.0f)) chatBox.BarScroll = 1.0f;
|
||||
|
||||
GUISoundType soundType = GUISoundType.Message;
|
||||
GUISoundType soundType = GUISoundType.ChatMessage;
|
||||
if (message.Type == ChatMessageType.Radio)
|
||||
{
|
||||
soundType = GUISoundType.RadioMessage;
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace Barotrauma
|
||||
{
|
||||
public enum GUISoundType
|
||||
{
|
||||
Message,
|
||||
UIMessage,
|
||||
ChatMessage,
|
||||
RadioMessage,
|
||||
DeadMessage,
|
||||
Click,
|
||||
@@ -58,7 +59,7 @@ namespace Barotrauma
|
||||
private static GUIFrame pauseMenu;
|
||||
private static Sprite arrow, lockIcon, checkmarkIcon, timerIcon;
|
||||
|
||||
public static KeyboardDispatcher KeyboardDispatcher { get; private set; }
|
||||
public static KeyboardDispatcher KeyboardDispatcher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Has the selected Screen changed since the last time the GUI was drawn.
|
||||
@@ -131,12 +132,11 @@ namespace Barotrauma
|
||||
set;
|
||||
}
|
||||
|
||||
public static bool DisableHUD;
|
||||
public static bool DisableHUD, DisableUpperHUD, DisableItemHighlights, DisableCharacterNames;
|
||||
|
||||
public static void Init(GameWindow window, IEnumerable<ContentPackage> selectedContentPackages, GraphicsDevice graphicsDevice)
|
||||
{
|
||||
GUI.graphicsDevice = graphicsDevice;
|
||||
KeyboardDispatcher = new KeyboardDispatcher(window);
|
||||
var uiStyles = ContentPackage.GetFilesOfType(selectedContentPackages, ContentType.UIStyle).ToList();
|
||||
if (uiStyles.Count == 0)
|
||||
{
|
||||
@@ -157,14 +157,15 @@ namespace Barotrauma
|
||||
{
|
||||
sounds = new Sound[Enum.GetValues(typeof(GUISoundType)).Length];
|
||||
|
||||
sounds[(int)GUISoundType.Message] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/UImsg.ogg", false);
|
||||
sounds[(int)GUISoundType.RadioMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/radiomsg.ogg", false);
|
||||
sounds[(int)GUISoundType.DeadMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/deadmsg.ogg", false);
|
||||
sounds[(int)GUISoundType.Click] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/beep-shinymetal.ogg", false);
|
||||
sounds[(int)GUISoundType.UIMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/UImsg.ogg", false);
|
||||
sounds[(int)GUISoundType.ChatMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/ChatMsg.ogg", false);
|
||||
sounds[(int)GUISoundType.RadioMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/RadioMsg.ogg", false);
|
||||
sounds[(int)GUISoundType.DeadMessage] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/DeadMsg.ogg", false);
|
||||
sounds[(int)GUISoundType.Click] = GameMain.SoundManager.LoadSound("Content/Sounds/UI/Click.ogg", false);
|
||||
|
||||
sounds[(int)GUISoundType.PickItem] = GameMain.SoundManager.LoadSound("Content/Sounds/pickItem.ogg", false);
|
||||
sounds[(int)GUISoundType.PickItemFail] = GameMain.SoundManager.LoadSound("Content/Sounds/pickItemFail.ogg", false);
|
||||
sounds[(int)GUISoundType.DropItem] = GameMain.SoundManager.LoadSound("Content/Sounds/dropItem.ogg", false);
|
||||
sounds[(int)GUISoundType.PickItem] = GameMain.SoundManager.LoadSound("Content/Sounds/PickItem.ogg", false);
|
||||
sounds[(int)GUISoundType.PickItemFail] = GameMain.SoundManager.LoadSound("Content/Sounds/PickItemFail.ogg", false);
|
||||
sounds[(int)GUISoundType.DropItem] = GameMain.SoundManager.LoadSound("Content/Sounds/DropItem.ogg", false);
|
||||
}
|
||||
// create 1x1 texture for line drawing
|
||||
t = new Texture2D(GraphicsDevice, 1, 1);
|
||||
@@ -290,7 +291,7 @@ namespace Barotrauma
|
||||
{
|
||||
Color clr = Color.White;
|
||||
string soundStr = i + ": ";
|
||||
SoundChannel playingSoundChannel = GameMain.SoundManager.GetSoundChannelFromIndex(i);
|
||||
SoundChannel playingSoundChannel = GameMain.SoundManager.GetSoundChannelFromIndex(SoundManager.SourcePoolIndex.Default, i);
|
||||
if (playingSoundChannel == null)
|
||||
{
|
||||
soundStr += "none";
|
||||
@@ -363,7 +364,7 @@ namespace Barotrauma
|
||||
|
||||
if (HUDLayoutSettings.DebugDraw) HUDLayoutSettings.Draw(spriteBatch);
|
||||
|
||||
if (GameMain.NetworkMember != null) GameMain.NetworkMember.Draw(spriteBatch);
|
||||
if (GameMain.Client != null) GameMain.Client.Draw(spriteBatch);
|
||||
|
||||
if (Character.Controlled?.Inventory != null)
|
||||
{
|
||||
@@ -1527,10 +1528,10 @@ namespace Barotrauma
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
}
|
||||
|
||||
if (GameMain.NetworkMember != null)
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.NetworkMember.Disconnect();
|
||||
GameMain.NetworkMember = null;
|
||||
GameMain.Client.Disconnect();
|
||||
GameMain.Client = null;
|
||||
}
|
||||
|
||||
CoroutineManager.StopCoroutines("EndCinematic");
|
||||
@@ -1563,13 +1564,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (messages.Any(msg => msg.Text == message)) { return; }
|
||||
messages.Add(new GUIMessage(message, color, lifeTime ?? MathHelper.Clamp(message.Length / 5.0f, 3.0f, 10.0f), font ?? LargeFont));
|
||||
if (playSound) PlayUISound(GUISoundType.Message);
|
||||
if (playSound) PlayUISound(GUISoundType.UIMessage);
|
||||
}
|
||||
|
||||
public static void AddMessage(string message, Color color, Vector2 worldPos, Vector2 velocity, float lifeTime = 3.0f, bool playSound = true)
|
||||
{
|
||||
messages.Add(new GUIMessage(message, color, worldPos, velocity, lifeTime, Alignment.Center, LargeFont));
|
||||
if (playSound) PlayUISound(GUISoundType.Message);
|
||||
if (playSound) PlayUISound(GUISoundType.UIMessage);
|
||||
}
|
||||
|
||||
public static void ClearMessages()
|
||||
|
||||
@@ -36,6 +36,12 @@ namespace Barotrauma
|
||||
set { listBox.Enabled = value; }
|
||||
}
|
||||
|
||||
public bool ButtonEnabled
|
||||
{
|
||||
get { return button.Enabled; }
|
||||
set { button.Enabled = value; }
|
||||
}
|
||||
|
||||
public GUIComponent Selected
|
||||
{
|
||||
get { return listBox.SelectedComponent; }
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public class GUIRadioButtonGroup : GUIComponent
|
||||
{
|
||||
private Dictionary<Enum, GUITickBox> radioButtons; //TODO: use children list instead?
|
||||
|
||||
public GUIRadioButtonGroup() : base("GUIFrame")
|
||||
{
|
||||
radioButtons = new Dictionary<Enum, GUITickBox>();
|
||||
}
|
||||
|
||||
public void AddRadioButton(Enum key, GUITickBox radioButton)
|
||||
{
|
||||
if (selected == key) radioButton.Selected = true;
|
||||
else if (radioButton.Selected) selected = key;
|
||||
|
||||
radioButton.SetRadioButtonGroup(this);
|
||||
radioButtons.Add(key, radioButton);
|
||||
}
|
||||
|
||||
public delegate void RadioButtonGroupDelegate(GUIRadioButtonGroup rbg, Enum val);
|
||||
public RadioButtonGroupDelegate OnSelect = null;
|
||||
|
||||
public void SelectRadioButton(GUITickBox radioButton)
|
||||
{
|
||||
foreach (KeyValuePair<Enum, GUITickBox> rbPair in radioButtons)
|
||||
{
|
||||
if (radioButton == rbPair.Value)
|
||||
{
|
||||
Selected = rbPair.Key;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Enum selected;
|
||||
public Enum Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
OnSelect?.Invoke(this, value);
|
||||
if (selected != null && selected.Equals((Enum)value)) return;
|
||||
selected = value;
|
||||
foreach (KeyValuePair<Enum, GUITickBox> radioButton in radioButtons)
|
||||
{
|
||||
if (radioButton.Key.Equals((Enum)value))
|
||||
{
|
||||
radioButton.Value.Selected = true;
|
||||
}
|
||||
else if (radioButton.Value.Selected) radioButton.Value.Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GUITickBox SelectedRadioButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return radioButtons[selected];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace Barotrauma
|
||||
|
||||
public delegate bool OnMovedHandler(GUIScrollBar scrollBar, float barScroll);
|
||||
public OnMovedHandler OnMoved;
|
||||
public OnMovedHandler OnReleased;
|
||||
|
||||
public bool IsBooleanSwitch;
|
||||
|
||||
@@ -87,6 +88,39 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 range;
|
||||
public Vector2 Range
|
||||
{
|
||||
get
|
||||
{
|
||||
return range;
|
||||
}
|
||||
set
|
||||
{
|
||||
float oldBarScrollValue = BarScrollValue;
|
||||
range = value;
|
||||
BarScrollValue = oldBarScrollValue;
|
||||
}
|
||||
}
|
||||
|
||||
public delegate float ScrollConversion(GUIScrollBar scrollBar, float f);
|
||||
public ScrollConversion ScrollToValue = null;
|
||||
public ScrollConversion ValueToScroll = null;
|
||||
|
||||
public float BarScrollValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ScrollToValue==null) return (BarScroll * (Range.Y - Range.X)) + Range.X;
|
||||
return ScrollToValue(this, BarScroll);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (ValueToScroll==null) BarScroll = (value - Range.X) / (Range.Y - Range.X);
|
||||
else BarScroll = ValueToScroll(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float BarScroll
|
||||
{
|
||||
get { return step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step); }
|
||||
@@ -187,7 +221,11 @@ namespace Barotrauma
|
||||
|
||||
if (draggingBar == this)
|
||||
{
|
||||
if (!PlayerInput.LeftButtonHeld()) draggingBar = null;
|
||||
if (!PlayerInput.LeftButtonHeld())
|
||||
{
|
||||
OnReleased?.Invoke(this, BarScroll);
|
||||
draggingBar = null;
|
||||
}
|
||||
if ((isHorizontal && PlayerInput.MousePosition.X > Rect.X && PlayerInput.MousePosition.X < Rect.Right) ||
|
||||
(!isHorizontal && PlayerInput.MousePosition.Y > Rect.Y && PlayerInput.MousePosition.Y < Rect.Bottom))
|
||||
{
|
||||
@@ -198,6 +236,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (PlayerInput.LeftButtonClicked())
|
||||
{
|
||||
draggingBar?.OnReleased?.Invoke(draggingBar, draggingBar.BarScroll);
|
||||
MoveButton(new Vector2(
|
||||
Math.Sign(PlayerInput.MousePosition.X - Bar.Rect.Center.X) * Bar.Rect.Width,
|
||||
Math.Sign(PlayerInput.MousePosition.Y - Bar.Rect.Center.Y) * Bar.Rect.Height));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -216,25 +217,36 @@ namespace Barotrauma
|
||||
if (autoScale && textScale > 0.1f &&
|
||||
(TextSize.X * textScale > rect.Width - padding.X - padding.Z || TextSize.Y * textScale > rect.Height - padding.Y - padding.W))
|
||||
{
|
||||
TextScale -= 0.05f;
|
||||
TextScale = Math.Max(0.1f, Math.Min(
|
||||
(rect.Width - padding.X - padding.Z) / TextSize.X,
|
||||
(rect.Height - padding.Y - padding.W) / TextSize.Y)) - 0.01f;
|
||||
return;
|
||||
}
|
||||
|
||||
textPos = new Vector2(rect.Width / 2.0f, rect.Height / 2.0f);
|
||||
origin = TextSize / textScale * 0.5f;
|
||||
origin = TextSize * 0.5f;
|
||||
|
||||
if (textAlignment.HasFlag(Alignment.Left) && !overflowClipActive)
|
||||
origin.X += (rect.Width / 2.0f - TextSize.X / 2) / textScale - padding.X;
|
||||
|
||||
{
|
||||
textPos.X = padding.X;
|
||||
origin.X = 0;
|
||||
}
|
||||
if (textAlignment.HasFlag(Alignment.Right) || overflowClipActive)
|
||||
origin.X -= (rect.Width / 2.0f - TextSize.X / 2) / textScale - padding.Z;
|
||||
|
||||
{
|
||||
textPos.X = rect.Width - padding.Z;
|
||||
origin.X = TextSize.X;
|
||||
}
|
||||
if (textAlignment.HasFlag(Alignment.Top))
|
||||
origin.Y += (rect.Height / 2.0f - TextSize.Y / 2) / textScale - padding.Y;
|
||||
|
||||
{
|
||||
textPos.Y = padding.Y;
|
||||
origin.Y = 0;
|
||||
}
|
||||
if (textAlignment.HasFlag(Alignment.Bottom))
|
||||
origin.Y -= (rect.Height / 2.0f - TextSize.Y / 2) / textScale - padding.W;
|
||||
|
||||
{
|
||||
textPos.Y = rect.Height - padding.W;
|
||||
origin.Y = TextSize.Y;
|
||||
}
|
||||
|
||||
origin.X = (int)(origin.X);
|
||||
origin.Y = (int)(origin.Y);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma
|
||||
{
|
||||
public event TextBoxEvent OnSelected;
|
||||
public event TextBoxEvent OnDeselected;
|
||||
|
||||
|
||||
bool caretVisible;
|
||||
float caretTimer;
|
||||
|
||||
@@ -76,10 +76,24 @@ namespace Barotrauma
|
||||
set { textBlock.TextGetter = value; }
|
||||
}
|
||||
|
||||
private bool selected;
|
||||
public bool Selected
|
||||
{
|
||||
get;
|
||||
set;
|
||||
get
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!selected && value)
|
||||
{
|
||||
Select();
|
||||
}
|
||||
else if (selected && !value)
|
||||
{
|
||||
Deselect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Wrap
|
||||
@@ -326,9 +340,9 @@ namespace Barotrauma
|
||||
{
|
||||
memento.Store(Text);
|
||||
}
|
||||
Selected = true;
|
||||
CaretIndex = GetCaretIndexFromScreenPos(PlayerInput.MousePosition);
|
||||
ClearSelection();
|
||||
selected = true;
|
||||
GUI.KeyboardDispatcher.Subscriber = this;
|
||||
OnSelected?.Invoke(this, Keys.None);
|
||||
}
|
||||
@@ -336,7 +350,8 @@ namespace Barotrauma
|
||||
public void Deselect()
|
||||
{
|
||||
memento.Clear();
|
||||
Selected = false;
|
||||
selected = false;
|
||||
|
||||
if (GUI.KeyboardDispatcher.Subscriber == this)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
@@ -382,6 +397,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerInput.LeftButtonClicked() && selected) Deselect();
|
||||
isSelecting = false;
|
||||
state = ComponentState.None;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma
|
||||
|
||||
public static int size = 20;
|
||||
|
||||
private List<GUITickBox> radioButtonGroup;
|
||||
private GUIRadioButtonGroup radioButtonGroup;
|
||||
|
||||
private bool selected;
|
||||
|
||||
@@ -24,30 +24,21 @@ namespace Barotrauma
|
||||
set
|
||||
{
|
||||
if (value == selected) return;
|
||||
if (radioButtonGroup != null && !value) return;
|
||||
|
||||
if (radioButtonGroup != null && radioButtonGroup.SelectedRadioButton == this)
|
||||
{
|
||||
selected = true;
|
||||
return;
|
||||
}
|
||||
|
||||
selected = value;
|
||||
state = (selected) ? ComponentState.Selected : ComponentState.None;
|
||||
box.State = state;
|
||||
if (radioButtonGroup != null)
|
||||
if (value && radioButtonGroup != null)
|
||||
{
|
||||
foreach (GUITickBox tickBox in radioButtonGroup)
|
||||
{
|
||||
if (tickBox == this) continue;
|
||||
tickBox.selected = false;
|
||||
tickBox.state = tickBox.box.State = ComponentState.None;
|
||||
}
|
||||
radioButtonGroup.SelectRadioButton(this);
|
||||
}
|
||||
|
||||
OnSelected?.Invoke(this);
|
||||
if (radioButtonGroup != null)
|
||||
{
|
||||
foreach (GUITickBox tickBox in radioButtonGroup)
|
||||
{
|
||||
if (tickBox == this) continue;
|
||||
tickBox.OnSelected?.Invoke(tickBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,14 +114,10 @@ namespace Barotrauma
|
||||
rectT.ScaleChanged += ResizeBox;
|
||||
rectT.SizeChanged += ResizeBox;
|
||||
}
|
||||
|
||||
public static void CreateRadioButtonGroup(IEnumerable<GUITickBox> tickBoxes)
|
||||
|
||||
public void SetRadioButtonGroup(GUIRadioButtonGroup rbg)
|
||||
{
|
||||
var group = new List<GUITickBox>(tickBoxes);
|
||||
foreach (GUITickBox tickBox in tickBoxes)
|
||||
{
|
||||
tickBox.radioButtonGroup = group;
|
||||
}
|
||||
radioButtonGroup = rbg;
|
||||
}
|
||||
|
||||
private void ResizeBox()
|
||||
|
||||
@@ -140,8 +140,8 @@ namespace Barotrauma
|
||||
}
|
||||
AfflictionAreaRight = new Rectangle(HealthBarAreaRight.X, HealthBarAreaRight.Y - Padding - afflictionAreaHeight, healthBarWidth, afflictionAreaHeight);
|
||||
|
||||
int messageAreaPos = GameMain.GraphicsWidth - HealthBarAreaRight.X;
|
||||
MessageAreaTop = new Rectangle(messageAreaPos + Padding, ButtonAreaTop.Bottom, GameMain.GraphicsWidth - (messageAreaPos + Padding) * 2, ButtonAreaTop.Height);
|
||||
int messageAreaWidth = GameMain.GraphicsWidth / 3;
|
||||
MessageAreaTop = new Rectangle((GameMain.GraphicsWidth - messageAreaWidth) / 2, ButtonAreaTop.Bottom, messageAreaWidth, ButtonAreaTop.Height);
|
||||
|
||||
//slice for the upper slots of the inventory (clothes, id card, headset)
|
||||
int inventoryAreaUpperWidth = (int)(GameMain.GraphicsWidth * 0.2f);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Barotrauma
|
||||
var length = Vector2.Distance(point1, point2);
|
||||
var angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
|
||||
var scale = new Vector2(length, thickness);
|
||||
spriteBatch.Draw(texture, point1, color: color, rotation: angle, scale: scale);
|
||||
spriteBatch.Draw(GetTexture(spriteBatch), point1, null, color, angle, Vector2.Zero, scale, SpriteEffects.None, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -117,7 +117,7 @@ namespace Barotrauma
|
||||
{
|
||||
var scale = Vector2.One * size;
|
||||
var offset = new Vector2(0.5f) - new Vector2(size * 0.5f);
|
||||
spriteBatch.Draw(GetTexture(spriteBatch), position + offset, color: color, scale: scale);
|
||||
spriteBatch.Draw(GetTexture(spriteBatch), position + offset, null, color, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0);
|
||||
}
|
||||
|
||||
public static void DrawCircle(this SpriteBatch spriteBatch, Vector2 center, float radius, int sides, Color color,
|
||||
|
||||
Reference in New Issue
Block a user