(7765c6989) Only show a bunch of pathfinder errors and warnings in debug builds.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:57:22 +03:00
parent 18a58a313b
commit f8ca1444fd
30 changed files with 529 additions and 357 deletions
@@ -9,11 +9,9 @@ namespace Barotrauma
public class GUIMessageBox : GUIFrame
{
public static List<GUIComponent> MessageBoxes = new List<GUIComponent>();
private static int DefaultWidth
{
get { return Math.Max(400, 400 * (GameMain.GraphicsWidth / 1920)); }
}
public const int DefaultWidth = 400, DefaultHeight = 250;
public List<GUIButton> Buttons { get; private set; } = new List<GUIButton>();
//public GUIFrame BackgroundFrame { get; private set; }
public GUILayoutGroup Content { get; private set; }
@@ -23,31 +21,23 @@ namespace Barotrauma
public string Tag { get; private set; }
public static GUIComponent VisibleBox => MessageBoxes.LastOrDefault();
public GUIMessageBox(string headerText, string text, Vector2? relativeSize = null, Point? minSize = null)
: this(headerText, text, new string[] { "OK" }, relativeSize, minSize)
public GUIMessageBox(string headerText, string text)
: this(headerText, text, new string[] {"OK"}, DefaultWidth, 0)
{
this.Buttons[0].OnClicked = Close;
}
public GUIMessageBox(string headerText, string text, string[] buttons, Vector2? relativeSize = null, Point? minSize = null, Alignment textAlignment = Alignment.TopLeft, string tag = "")
public GUIMessageBox(string headerText, string text, int width, int height)
: this(headerText, text, new string[] { "OK" }, width, height)
{
this.Buttons[0].OnClicked = Close;
}
// TODO: allow to use a relative size.
public GUIMessageBox(string headerText, string text, string[] buttons, int width = DefaultWidth, int height = 0, Alignment textAlignment = Alignment.TopLeft, string tag = "")
: base(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: "")
{
int width = DefaultWidth, height = 0;
if (relativeSize.HasValue)
{
width = (int)(GameMain.GraphicsWidth * relativeSize.Value.X);
height = (int)(GameMain.GraphicsHeight * relativeSize.Value.Y);
}
if (minSize.HasValue)
{
width = Math.Max(width, minSize.Value.X);
if (height > 0)
{
height = Math.Max(height, minSize.Value.Y);
}
}
InnerFrame = new GUIFrame(new RectTransform(new Point(width, height), RectTransform, Anchor.Center) { IsFixedSize = false }, style: null);
GUI.Style.Apply(InnerFrame, "", this);
@@ -59,7 +49,7 @@ namespace Barotrauma
GUI.Style.Apply(Header, "", this);
Header.RectTransform.MinSize = new Point(0, Header.Rect.Height);
if (height == 0)
if (!string.IsNullOrWhiteSpace(text))
{
Text = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), Content.RectTransform),
text, textAlignment: textAlignment, wrap: true);
@@ -84,11 +74,7 @@ namespace Barotrauma
height += Header.Rect.Height + Content.AbsoluteSpacing;
height += (Text == null ? 0 : Text.Rect.Height) + Content.AbsoluteSpacing;
height += buttonContainer.Rect.Height;
if (minSize.HasValue)
{
height = Math.Max(height, minSize.Value.Y);
}
InnerFrame.RectTransform.NonScaledSize =
new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + 50));
Content.RectTransform.NonScaledSize =
@@ -18,38 +18,21 @@ namespace Barotrauma
private Sprite languageSelectionCursor;
private ScalableFont languageSelectionFont;
private Video currSplashScreen;
private DateTime videoStartTime;
private Queue<Pair<string, Point>> pendingSplashScreens = new Queue<Pair<string, Point>>();
/// <summary>
/// Pair.first = filepath, Pair.second = resolution
/// </summary>
public Queue<Pair<string, Point>> PendingSplashScreens
private Video splashScreen;
public Video SplashScreen
{
get
{
lock (loadMutex)
{
return pendingSplashScreens;
return splashScreen;
}
}
set
{
lock (loadMutex)
{
pendingSplashScreens = value;
}
}
}
public bool PlayingSplashScreen
{
get
{
lock (loadMutex)
{
return currSplashScreen != null;
splashScreen = value;
}
}
}
@@ -117,8 +100,8 @@ namespace Barotrauma
{
try
{
DrawSplashScreen(spriteBatch, graphics);
if (currSplashScreen != null || PendingSplashScreens.Count > 0) { return; }
DrawSplashScreen(spriteBatch);
if (SplashScreen != null && SplashScreen.IsPlaying) return;
}
catch (Exception e)
{
@@ -218,77 +201,46 @@ namespace Barotrauma
{
if (languageSelectionFont == null)
{
languageSelectionFont = new ScalableFont("Content/Fonts/BebasNeue-Regular.otf", (uint)(30 * (GameMain.GraphicsHeight / 1080.0f)), graphicsDevice);
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.3f);
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)
{
Vector2 textSize = languageSelectionFont.MeasureString(language);
bool hover =
Math.Abs(PlayerInput.MousePosition.X - textPos.X) < textSize.X / 2 &&
Math.Abs(PlayerInput.MousePosition.Y - textPos.Y) < textSpacing.Y / 2;
//TODO: display the name of the language in the target language?
languageSelectionFont.DrawString(spriteBatch, language, textPos - textSize / 2,
hover ? Color.White : Color.White * 0.6f);
if (hover && PlayerInput.LeftButtonClicked())
{
GameMain.Config.Language = language;
WaitForLanguageSelection = false;
}
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, GraphicsDevice graphics)
private void DrawSplashScreen(SpriteBatch spriteBatch)
{
if (currSplashScreen == null && PendingSplashScreens.Count == 0) { return; }
if (currSplashScreen == null)
if (SplashScreen != null)
{
var newSplashScreen = PendingSplashScreens.Dequeue();
string fileName = newSplashScreen.First;
Point resolution = newSplashScreen.Second;
try
if (SplashScreen.IsPlaying)
{
currSplashScreen = new Video(graphics, GameMain.SoundManager, fileName, (uint)resolution.X, (uint)resolution.Y);
videoStartTime = DateTime.Now;
}
catch (Exception e)
{
GameMain.Config.EnableSplashScreen = false;
DebugConsole.ThrowError("Playing the splash screen \"" + fileName + "\" failed.", e);
PendingSplashScreens.Clear();
currSplashScreen = null;
}
}
spriteBatch.Begin();
spriteBatch.Draw(SplashScreen.GetTexture(), new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
if (currSplashScreen.IsPlaying)
{
spriteBatch.Begin();
spriteBatch.Draw(currSplashScreen.GetTexture(), new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
if (PlayerInput.KeyHit(Keys.Space) || PlayerInput.KeyHit(Keys.Enter) || PlayerInput.LeftButtonDown())
{
currSplashScreen.Dispose(); currSplashScreen = null;
if (PlayerInput.KeyHit(Keys.Space) || PlayerInput.KeyHit(Keys.Enter) || PlayerInput.LeftButtonDown())
{
SplashScreen.Dispose(); SplashScreen = null;
}
}
}
else if (DateTime.Now > videoStartTime + new TimeSpan(0, 0, 0, 0, milliseconds: 500))
{
currSplashScreen.Dispose(); currSplashScreen = null;
}
else
{
SplashScreen.Dispose(); SplashScreen = null;
}
}
}
bool drawn;
public IEnumerable<object> DoLoading(IEnumerable<object> loader)
{