Fixed incorrect positioning of debug console question prompts. The ShowQuestionPrompt method used to take the last textblock in the console and consider that as the question prompt text, even though the text had only been queued and the actual GUITexblock hadn't been instantiated yet.
This commit is contained in:
@@ -15,6 +15,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private static Queue<ColoredText> queuedMessages = new Queue<ColoredText>();
|
private static Queue<ColoredText> queuedMessages = new Queue<ColoredText>();
|
||||||
|
|
||||||
|
private static GUITextBlock activeQuestionText;
|
||||||
|
|
||||||
public static bool IsOpen
|
public static bool IsOpen
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -69,6 +71,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (activeQuestionText != null &&
|
||||||
|
(listBox.children.Count == 0 || listBox.children[listBox.children.Count - 1] != activeQuestionText))
|
||||||
|
{
|
||||||
|
listBox.children.Remove(activeQuestionText);
|
||||||
|
listBox.children.Add(activeQuestionText);
|
||||||
|
}
|
||||||
|
|
||||||
if (PlayerInput.KeyHit(Keys.F3))
|
if (PlayerInput.KeyHit(Keys.F3))
|
||||||
{
|
{
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
@@ -177,13 +186,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedIndex = Messages.Count;
|
selectedIndex = Messages.Count;
|
||||||
|
|
||||||
if (activeQuestionText != null)
|
|
||||||
{
|
|
||||||
//make sure the active question stays at the bottom of the list
|
|
||||||
listBox.children.Remove(activeQuestionText);
|
|
||||||
listBox.children.Add(activeQuestionText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void InitProjectSpecific()
|
private static void InitProjectSpecific()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -106,9 +106,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public delegate void QuestionCallback(string answer);
|
public delegate void QuestionCallback(string answer);
|
||||||
private static QuestionCallback activeQuestionCallback;
|
private static QuestionCallback activeQuestionCallback;
|
||||||
#if CLIENT
|
|
||||||
private static GUIComponent activeQuestionText;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private static List<Command> commands = new List<Command>();
|
private static List<Command> commands = new List<Command>();
|
||||||
public static List<Command> Commands
|
public static List<Command> Commands
|
||||||
@@ -1127,8 +1124,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
NewMessage(command, Color.White);
|
NewMessage(command, Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !DEBUG && CLIENT
|
#if CLIENT
|
||||||
if (GameMain.Client != null)
|
if (GameMain.Client != null)
|
||||||
{
|
{
|
||||||
if (GameMain.Client.HasConsoleCommandPermission(splitCommand[0].ToLowerInvariant()))
|
if (GameMain.Client.HasConsoleCommandPermission(splitCommand[0].ToLowerInvariant()))
|
||||||
@@ -1148,11 +1145,13 @@ namespace Barotrauma
|
|||||||
NewMessage("Server command: " + command, Color.White);
|
NewMessage("Server command: " + command, Color.White);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if !DEBUG
|
||||||
if (!IsCommandPermitted(splitCommand[0].ToLowerInvariant(), GameMain.Client))
|
if (!IsCommandPermitted(splitCommand[0].ToLowerInvariant(), GameMain.Client))
|
||||||
{
|
{
|
||||||
ThrowError("You're not permitted to use the command \"" + splitCommand[0].ToLowerInvariant() + "\"!");
|
ThrowError("You're not permitted to use the command \"" + splitCommand[0].ToLowerInvariant() + "\"!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1427,14 +1426,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void ShowQuestionPrompt(string question, QuestionCallback onAnswered)
|
public static void ShowQuestionPrompt(string question, QuestionCallback onAnswered)
|
||||||
{
|
{
|
||||||
NewMessage(" >>" + question, Color.Cyan);
|
|
||||||
activeQuestionCallback += onAnswered;
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
if (listBox != null && listBox.children.Count > 0)
|
activeQuestionText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 30), " >>" + question, "", Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
|
||||||
{
|
activeQuestionText.CanBeFocused = false;
|
||||||
activeQuestionText = listBox.children[listBox.children.Count - 1];
|
activeQuestionText.TextColor = Color.Cyan;
|
||||||
}
|
#else
|
||||||
|
NewMessage(" >>" + question, Color.Cyan);
|
||||||
#endif
|
#endif
|
||||||
|
activeQuestionCallback += onAnswered;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryParseTimeSpan(string s, out TimeSpan timeSpan)
|
private static bool TryParseTimeSpan(string s, out TimeSpan timeSpan)
|
||||||
|
|||||||
Reference in New Issue
Block a user