(af16ecdfa) Merge branch 'dev' into human-ai
This commit is contained in:
@@ -129,6 +129,8 @@ namespace Barotrauma
|
||||
get { return pauseMenuOpen; }
|
||||
}
|
||||
|
||||
public static bool PreventPauseMenuToggle = false;
|
||||
|
||||
public static Color ScreenOverlayColor
|
||||
{
|
||||
get;
|
||||
@@ -1413,6 +1415,7 @@ namespace Barotrauma
|
||||
public static void TogglePauseMenu()
|
||||
{
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) return;
|
||||
if (PreventPauseMenuToggle) return;
|
||||
|
||||
settingsMenuOpen = false;
|
||||
|
||||
@@ -1546,9 +1549,16 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
if (ContextualTutorial.Initialized && GameMain.GameSession.GameMode is SinglePlayerCampaign)
|
||||
if (Tutorial.Initialized)
|
||||
{
|
||||
((SinglePlayerCampaign)GameMain.GameSession.GameMode).ContextualTutorial.Stop();
|
||||
if (GameMain.GameSession.GameMode is SinglePlayerCampaign)
|
||||
{
|
||||
((SinglePlayerCampaign)GameMain.GameSession.GameMode).ContextualTutorial.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
((TutorialMode)GameMain.GameSession.GameMode).Tutorial.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (GameSettings.SendUserStatistics)
|
||||
|
||||
@@ -174,6 +174,11 @@ namespace Barotrauma
|
||||
if (frame != null) frame.ApplyStyle(style);
|
||||
}
|
||||
|
||||
public override void Flash(Color? color = null, float flashDuration = 1.5f, bool useRectangleFlash = false, Vector2? flashRectInflate = null)
|
||||
{
|
||||
Frame.Flash(color, flashDuration, useRectangleFlash, flashRectInflate);
|
||||
}
|
||||
|
||||
protected override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
//do nothing
|
||||
|
||||
@@ -121,77 +121,22 @@ namespace Barotrauma
|
||||
protected Color selectedColor;
|
||||
protected Color pressedColor;
|
||||
|
||||
private CoroutineHandle pulsateCoroutine;
|
||||
|
||||
protected ComponentState state;
|
||||
|
||||
protected Color flashColor;
|
||||
protected float flashDuration = 1.5f;
|
||||
private bool useRectangleFlash;
|
||||
public float FlashTimer
|
||||
{
|
||||
get { return flashTimer; }
|
||||
}
|
||||
protected float flashTimer;
|
||||
private Vector2 flashRectInflate;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public bool IgnoreLayoutGroups;
|
||||
|
||||
public virtual ScalableFont Font
|
||||
{
|
||||
get;
|
||||
@@ -324,6 +269,8 @@ namespace Barotrauma
|
||||
set { pressedColor = value; }
|
||||
}
|
||||
|
||||
public bool ExternalHighlight = false;
|
||||
|
||||
private RectTransform rectTransform;
|
||||
public RectTransform RectTransform
|
||||
{
|
||||
@@ -496,11 +443,21 @@ namespace Barotrauma
|
||||
int flashCycleCount = (int)Math.Max(flashDuration, 1);
|
||||
float flashCycleDuration = flashDuration / flashCycleCount;
|
||||
|
||||
Rectangle flashRect = Rect;
|
||||
flashRect.Inflate(flashRectInflate.X, flashRectInflate.Y);
|
||||
|
||||
//MathHelper.Pi * 0.8f -> the curve goes from 144 deg to 0,
|
||||
//i.e. quickly bumps up from almost full brightness to full and then fades out
|
||||
GUI.UIGlow.Draw(spriteBatch,
|
||||
rect,
|
||||
flashColor * (float)Math.Sin(flashTimer % flashCycleDuration / flashCycleDuration * MathHelper.Pi * 0.8f));
|
||||
if (!useRectangleFlash)
|
||||
{
|
||||
GUI.UIGlow.Draw(spriteBatch,
|
||||
flashRect,
|
||||
flashColor * (float)Math.Sin(flashTimer % flashCycleDuration / flashCycleDuration * MathHelper.Pi * 0.8f));
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, flashRect, flashColor * (float)Math.Sin(flashTimer % flashCycleDuration / flashCycleDuration * MathHelper.Pi * 0.8f), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,6 +482,7 @@ namespace Barotrauma
|
||||
toolTipBlock.WrappedText.Split('\n').Length * 18 + 7);
|
||||
toolTipBlock.userData = toolTip;
|
||||
}
|
||||
toolTipBlock.SetTextPos();
|
||||
|
||||
toolTipBlock.RectTransform.AbsoluteOffset = new Point(targetElement.Center.X, targetElement.Bottom);
|
||||
if (toolTipBlock.Rect.Right > GameMain.GraphicsWidth - 10)
|
||||
@@ -548,9 +506,11 @@ namespace Barotrauma
|
||||
color = new Color(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, a);
|
||||
}
|
||||
|
||||
public virtual void Flash(Color? color = null, float flashDuration = 1.5f)
|
||||
public virtual void Flash(Color? color = null, float flashDuration = 1.5f, bool useRectangleFlash = false, Vector2? flashRectInflate = null)
|
||||
{
|
||||
flashTimer = flashDuration;
|
||||
this.flashRectInflate = flashRectInflate ?? Vector2.Zero;
|
||||
this.useRectangleFlash = useRectangleFlash;
|
||||
this.flashDuration = flashDuration;
|
||||
flashColor = (color == null) ? Color.Red : (Color)color;
|
||||
}
|
||||
@@ -568,12 +528,9 @@ namespace Barotrauma
|
||||
while (t < duration)
|
||||
{
|
||||
t += CoroutineManager.DeltaTime;
|
||||
|
||||
SetAlpha(MathHelper.Lerp(startA, to, t / duration));
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
toolTipBlock.SetTextPos();
|
||||
|
||||
SetAlpha(to);
|
||||
|
||||
@@ -584,9 +541,31 @@ namespace Barotrauma
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public void Pulsate(Vector2 startScale, Vector2 endScale, float duration)
|
||||
{
|
||||
if (CoroutineManager.IsCoroutineRunning(pulsateCoroutine))
|
||||
{
|
||||
return;
|
||||
}
|
||||
pulsateCoroutine = CoroutineManager.StartCoroutine(DoPulsate(startScale, endScale, duration), "Pulsate" + ToString());
|
||||
}
|
||||
|
||||
private IEnumerable<object> DoPulsate(Vector2 startScale, Vector2 endScale, float duration)
|
||||
{
|
||||
float t = 0.0f;
|
||||
while (t < duration)
|
||||
{
|
||||
t += CoroutineManager.DeltaTime;
|
||||
RectTransform.LocalScale = Vector2.Lerp(startScale, endScale, (float)Math.Sin(t / duration * MathHelper.Pi));
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
RectTransform.LocalScale = startScale;
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected virtual void SetAlpha(float a)
|
||||
public virtual void ApplyStyle(GUIComponentStyle style)
|
||||
{
|
||||
if (style == null) return;
|
||||
|
||||
@@ -599,11 +578,7 @@ namespace Barotrauma
|
||||
|
||||
OutlineColor = style.OutlineColor;
|
||||
|
||||
public virtual void Flash(Color? color = null, float flashDuration = 1.5f)
|
||||
{
|
||||
flashTimer = flashDuration;
|
||||
this.flashDuration = flashDuration;
|
||||
flashColor = (color == null) ? Color.Red : (Color)color;
|
||||
this.style = style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +227,12 @@ namespace Barotrauma
|
||||
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
|
||||
Tag = tag;
|
||||
|
||||
InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null);
|
||||
GUI.Style.Apply(InnerFrame, "", this);
|
||||
|
||||
Content = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), InnerFrame.RectTransform, Anchor.Center)) { AbsoluteSpacing = 5 };
|
||||
Tag = tag;
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
string wrappedText = ToolBox.WrapText(text, Content.Rect.Width, GUI.Font);
|
||||
|
||||
@@ -365,9 +365,9 @@ namespace Barotrauma
|
||||
OnDeselected?.Invoke(this, Keys.None);
|
||||
}
|
||||
|
||||
public override void Flash(Color? color = null, float flashDuration = 1.5f)
|
||||
public override void Flash(Color? color = null, float flashDuration = 1.5f, bool useRectangleFlash = false, Vector2? flashRectOffset = null)
|
||||
{
|
||||
textBlock.Flash(color, flashDuration);
|
||||
textBlock.Flash(color, flashDuration, useRectangleFlash, flashRectOffset);
|
||||
}
|
||||
|
||||
protected override void Update(float deltaTime)
|
||||
|
||||
@@ -10,9 +10,10 @@ namespace Barotrauma
|
||||
{
|
||||
class VideoPlayer
|
||||
{
|
||||
public bool IsPlaying;
|
||||
|
||||
private Video currentVideo;
|
||||
private string filePath;
|
||||
private bool isPlaying;
|
||||
|
||||
private GUIFrame background, videoFrame, textFrame;
|
||||
private GUITextBlock title, textContent, objectiveTitle, objectiveText;
|
||||
@@ -24,12 +25,14 @@ namespace Barotrauma
|
||||
|
||||
private Point scaledVideoResolution;
|
||||
private readonly int borderSize = 20;
|
||||
private readonly Point buttonSize = new Point(160, 50);
|
||||
private readonly Point buttonSize = new Point(120, 30);
|
||||
private readonly int titleHeight = 30;
|
||||
private readonly int objectiveFrameHeight = 60;
|
||||
private readonly int textHeight = 25;
|
||||
|
||||
public struct TextSettings
|
||||
private bool useTextOnRightSide = false;
|
||||
|
||||
public class TextSettings
|
||||
{
|
||||
public string Text;
|
||||
public int Width;
|
||||
@@ -41,7 +44,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public struct VideoSettings
|
||||
public class VideoSettings
|
||||
{
|
||||
public string File;
|
||||
|
||||
@@ -62,7 +65,14 @@ namespace Barotrauma
|
||||
background = new GUIFrame(new RectTransform(Point.Zero, GUI.Canvas, Anchor.Center), "InnerFrame", backgroundColor);
|
||||
videoFrame = new GUIFrame(new RectTransform(Point.Zero, background.RectTransform, Anchor.Center, Pivot.Center), "SonarFrame");
|
||||
|
||||
textFrame = new GUIFrame(new RectTransform(Point.Zero, videoFrame.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft), "TextFrame");
|
||||
if (useTextOnRightSide)
|
||||
{
|
||||
textFrame = new GUIFrame(new RectTransform(Point.Zero, videoFrame.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft), "TextFrame");
|
||||
}
|
||||
else
|
||||
{
|
||||
textFrame = new GUIFrame(new RectTransform(Point.Zero, videoFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter), "TextFrame");
|
||||
}
|
||||
|
||||
videoView = new GUICustomComponent(new RectTransform(Point.Zero, videoFrame.RectTransform, Anchor.Center), (spriteBatch, guiCustomComponent) => { DrawVideo(spriteBatch, guiCustomComponent.Rect); });
|
||||
title = new GUITextBlock(new RectTransform(Point.Zero, textFrame.RectTransform, Anchor.TopLeft, Pivot.TopLeft), string.Empty, font: GUI.VideoTitleFont, textColor: new Color(253, 174, 0), textAlignment: Alignment.Left);
|
||||
@@ -70,7 +80,7 @@ namespace Barotrauma
|
||||
textContent = new GUITextBlock(new RectTransform(Point.Zero, textFrame.RectTransform, Anchor.TopLeft, Pivot.TopLeft), string.Empty, font: GUI.Font, textAlignment: Alignment.TopLeft);
|
||||
|
||||
objectiveTitle = new GUITextBlock(new RectTransform(new Vector2(1f, 0f), textFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter), string.Empty, font: GUI.ObjectiveTitleFont, textAlignment: Alignment.CenterRight, textColor: Color.White);
|
||||
objectiveTitle.Text = TextManager.Get("NewObjective");
|
||||
objectiveTitle.Text = TextManager.Get("Tutorial.NewObjective");
|
||||
objectiveText = new GUITextBlock(new RectTransform(Point.Zero, textFrame.RectTransform, Anchor.TopCenter, Pivot.TopCenter), string.Empty, font: GUI.ObjectiveNameFont, textColor: new Color(4, 180, 108), textAlignment: Alignment.CenterRight);
|
||||
|
||||
objectiveTitle.Visible = objectiveText.Visible = false;
|
||||
@@ -78,12 +88,12 @@ namespace Barotrauma
|
||||
|
||||
public void Play()
|
||||
{
|
||||
isPlaying = true;
|
||||
IsPlaying = true;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
isPlaying = false;
|
||||
IsPlaying = false;
|
||||
if (currentVideo == null) return;
|
||||
currentVideo.Dispose();
|
||||
currentVideo = null;
|
||||
@@ -99,13 +109,6 @@ namespace Barotrauma
|
||||
public void Update()
|
||||
{
|
||||
if (currentVideo == null) return;
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Enter) || PlayerInput.KeyHit(Keys.Escape))
|
||||
{
|
||||
DisposeVideo(null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentVideo.IsPlaying) return;
|
||||
|
||||
currentVideo.Dispose();
|
||||
@@ -115,7 +118,7 @@ namespace Barotrauma
|
||||
|
||||
public void AddToGUIUpdateList(bool ignoreChildren = false, int order = 0)
|
||||
{
|
||||
if (!isPlaying) return;
|
||||
if (!IsPlaying) return;
|
||||
background.AddToGUIUpdateList(ignoreChildren, order);
|
||||
}
|
||||
|
||||
@@ -139,7 +142,7 @@ namespace Barotrauma
|
||||
|
||||
currentVideo = CreateVideo(scaledVideoResolution);
|
||||
title.Text = TextManager.Get(contentId);
|
||||
textContent.Text = textSettings.Text;
|
||||
textContent.Text = textSettings != null ? textSettings.Text : string.Empty;
|
||||
objectiveText.Text = objective;
|
||||
|
||||
AdjustFrames(videoSettings, textSettings);
|
||||
@@ -165,7 +168,8 @@ namespace Barotrauma
|
||||
title.TextScale = textContent.TextScale = objectiveText.TextScale = objectiveTitle.TextScale = GUI.Scale;
|
||||
|
||||
int scaledBorderSize = (int)(borderSize * GUI.Scale);
|
||||
int scaledTextWidth = (int)(textSettings.Width * GUI.Scale);
|
||||
int scaledTextWidth = 0;
|
||||
if (textSettings != null) scaledTextWidth = useTextOnRightSide ? (int)(textSettings.Width * GUI.Scale) : scaledVideoResolution.X / 2;
|
||||
int scaledTitleHeight = (int)(titleHeight * GUI.Scale);
|
||||
int scaledTextHeight = (int)(textHeight * GUI.Scale);
|
||||
int scaledObjectiveFrameHeight = (int)(objectiveFrameHeight * GUI.Scale);
|
||||
@@ -180,13 +184,21 @@ namespace Barotrauma
|
||||
title.RectTransform.NonScaledSize += new Point(scaledTextWidth, scaledTitleHeight);
|
||||
title.RectTransform.AbsoluteOffset = new Point((int)(5 * GUI.Scale), (int)(10 * GUI.Scale));
|
||||
|
||||
if (!string.IsNullOrEmpty(textSettings.Text))
|
||||
if (textSettings != null && !string.IsNullOrEmpty(textSettings.Text))
|
||||
{
|
||||
textSettings.Text = ToolBox.WrapText(textSettings.Text, scaledTextWidth, GUI.Font);
|
||||
int wrappedHeight = textSettings.Text.Split('\n').Length * scaledTextHeight;
|
||||
|
||||
textFrame.RectTransform.NonScaledSize += new Point(scaledTextWidth + scaledBorderSize, wrappedHeight + scaledBorderSize + scaledButtonSize.Y + scaledTitleHeight);
|
||||
textFrame.RectTransform.AbsoluteOffset = new Point(scaledVideoResolution.X + scaledBorderSize * 2, 0);
|
||||
|
||||
if (useTextOnRightSide)
|
||||
{
|
||||
textFrame.RectTransform.AbsoluteOffset = new Point(scaledVideoResolution.X + scaledBorderSize * 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
textFrame.RectTransform.AbsoluteOffset = new Point(0, scaledVideoResolution.Y + scaledBorderSize * 2);
|
||||
}
|
||||
|
||||
textContent.RectTransform.NonScaledSize += new Point(scaledTextWidth, wrappedHeight);
|
||||
textContent.RectTransform.AbsoluteOffset = new Point(0, scaledBorderSize + scaledTitleHeight);
|
||||
@@ -209,22 +221,41 @@ namespace Barotrauma
|
||||
objectiveTitle.Visible = objectiveText.Visible = false;
|
||||
}
|
||||
|
||||
int totalFrameWidth = videoFrame.Rect.Width + textFrame.Rect.Width + scaledBorderSize * 2;
|
||||
int xOffset = videoFrame.Rect.Width / 2 + scaledBorderSize - (videoFrame.Rect.Width / 2 - textFrame.Rect.Width / 2);
|
||||
|
||||
|
||||
videoFrame.RectTransform.AbsoluteOffset = new Point(-xOffset, (int)(50 * GUI.Scale));
|
||||
|
||||
if (okButton != null)
|
||||
{
|
||||
textFrame.RemoveChild(okButton);
|
||||
okButton = null;
|
||||
}
|
||||
|
||||
okButton = new GUIButton(new RectTransform(scaledButtonSize, textFrame.RectTransform, Anchor.BottomRight, Pivot.BottomRight) { AbsoluteOffset = new Point(scaledBorderSize, scaledBorderSize) }, TextManager.Get("OK"))
|
||||
if (textSettings != null)
|
||||
{
|
||||
OnClicked = DisposeVideo
|
||||
};
|
||||
if (useTextOnRightSide)
|
||||
{
|
||||
int totalFrameWidth = videoFrame.Rect.Width + textFrame.Rect.Width + scaledBorderSize * 2;
|
||||
int xOffset = videoFrame.Rect.Width / 2 + scaledBorderSize - (videoFrame.Rect.Width / 2 - textFrame.Rect.Width / 2);
|
||||
videoFrame.RectTransform.AbsoluteOffset = new Point(-xOffset, (int)(50 * GUI.Scale));
|
||||
}
|
||||
else
|
||||
{
|
||||
int totalFrameHeight = videoFrame.Rect.Height + textFrame.Rect.Height + scaledBorderSize * 2;
|
||||
int yOffset = videoFrame.Rect.Height / 2 + scaledBorderSize - (videoFrame.Rect.Height / 2 - textFrame.Rect.Height / 2);
|
||||
videoFrame.RectTransform.AbsoluteOffset = new Point(0, -yOffset);
|
||||
}
|
||||
|
||||
okButton = new GUIButton(new RectTransform(scaledButtonSize, textFrame.RectTransform, Anchor.BottomRight, Pivot.BottomRight) { AbsoluteOffset = new Point(scaledBorderSize, scaledBorderSize) }, TextManager.Get("OK"))
|
||||
{
|
||||
OnClicked = DisposeVideo
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
videoFrame.RectTransform.AbsoluteOffset = new Point(0, (int)(100 * GUI.Scale));
|
||||
|
||||
okButton = new GUIButton(new RectTransform(scaledButtonSize, videoFrame.RectTransform, Anchor.TopLeft, Pivot.TopLeft) { AbsoluteOffset = new Point(scaledBorderSize, scaledBorderSize) }, TextManager.Get("Back"))
|
||||
{
|
||||
OnClicked = DisposeVideo
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private Video CreateVideo(Point resolution)
|
||||
@@ -245,7 +276,7 @@ namespace Barotrauma
|
||||
|
||||
private void DrawVideo(SpriteBatch spriteBatch, Rectangle rect)
|
||||
{
|
||||
if (!isPlaying) return;
|
||||
if (!IsPlaying) return;
|
||||
spriteBatch.Draw(currentVideo.GetTexture(), rect, Color.White);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user