From 1dad1169814f24ce59bf737557ccdb68da617418 Mon Sep 17 00:00:00 2001 From: Regalis Date: Mon, 29 Aug 2016 20:51:00 +0300 Subject: [PATCH] Adding a textblock with whitespace as the text doesn't blow up GUIListBoxes anymore, missing key bindings don't crash the game --- Subsurface/Source/GUI/GUITextBlock.cs | 2 +- Subsurface/Source/GameSettings.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Subsurface/Source/GUI/GUITextBlock.cs b/Subsurface/Source/GUI/GUITextBlock.cs index cb5852d16..5e20ad9f7 100644 --- a/Subsurface/Source/GUI/GUITextBlock.cs +++ b/Subsurface/Source/GUI/GUITextBlock.cs @@ -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; } diff --git a/Subsurface/Source/GameSettings.cs b/Subsurface/Source/GameSettings.cs index 0316a206d..3a2caff9a 100644 --- a/Subsurface/Source/GameSettings.cs +++ b/Subsurface/Source/GameSettings.cs @@ -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;