Adding a textblock with whitespace as the text doesn't blow up GUIListBoxes anymore, missing key bindings don't crash the game

This commit is contained in:
Regalis
2016-08-29 20:51:00 +03:00
parent 5de48a030e
commit 1dad116981
2 changed files with 11 additions and 6 deletions

View File

@@ -157,7 +157,7 @@ namespace Barotrauma
SetTextPos();
if (rect.Height == 0 && !string.IsNullOrWhiteSpace(Text))
if (rect.Height == 0 && !string.IsNullOrEmpty(Text))
{
this.rect.Height = (int)Font.MeasureString(wrappedText).Y;
}

View File

@@ -203,6 +203,16 @@ namespace Barotrauma
}
}
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
{
if (keyMapping[(int)inputType]==null)
{
DebugConsole.ThrowError("Key binding for the input type ''" + inputType + " not set!");
keyMapping[(int)inputType] = new KeyOrMouse(Keys.D1);
}
}
UnsavedSettings = false;
}
@@ -384,11 +394,6 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(x, y, 100, 20), inputNames[i]+": ", GUI.Style, settingsFrame);
var keyBox = new GUITextBox(new Rectangle(x + 100, y, 120, 15), GUI.Style, settingsFrame);
if (keyMapping[i]==null)
{
keyMapping[i] = new KeyOrMouse(Keys.D1);
}
keyBox.Text = keyMapping[i].ToString();
keyBox.UserData = i;
keyBox.OnSelected += KeyBoxSelected;