diff --git a/DangerousD/GameCore/GUI/AbstractGui.cs b/DangerousD/GameCore/GUI/AbstractGui.cs index ee65365..d13e77e 100644 --- a/DangerousD/GameCore/GUI/AbstractGui.cs +++ b/DangerousD/GameCore/GUI/AbstractGui.cs @@ -83,12 +83,7 @@ public abstract class AbstractGui : IDrawableObject } if (SelectedElement is TextBox) { - TextBox box = (TextBox)SelectedElement; - box.hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering; - if (isStartedPrint) - { - box.SelectIt(); - } + (SelectedElement as TextBox).hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering; } } } @@ -118,11 +113,6 @@ public abstract class AbstractGui : IDrawableObject Button button = SelectedElement as Button; button.CallLeftBtnEvent(); } - else if (SelectedElement is TextBox) - { - TextBox textBox = SelectedElement as TextBox; - isStartedPrint = true; - } } else if (isPressed && (gamePadState.Buttons.A == ButtonState.Released && gamePadState.DPad.Down == ButtonState.Released && @@ -136,13 +126,11 @@ public abstract class AbstractGui : IDrawableObject if (keyboardState.IsKeyDown(Keys.Up) && !isPressed) { isPressed = true; - isStartedPrint = false; ChangeSelectedElement(-1); } else if (keyboardState.IsKeyDown(Keys.Down) && !isPressed) { isPressed = true; - isStartedPrint = false; ChangeSelectedElement(1); } else if (keyboardState.IsKeyDown(Keys.Enter) && !isPressed) @@ -153,11 +141,6 @@ public abstract class AbstractGui : IDrawableObject Button button = SelectedElement as Button; button.CallLeftBtnEvent(); } - else if (SelectedElement is TextBox) - { - TextBox textBox = SelectedElement as TextBox; - isStartedPrint = true; - } } else if (isPressed && (keyboardState.IsKeyUp(Keys.Enter) && keyboardState.IsKeyUp(Keys.Down) && diff --git a/DangerousD/GameCore/GUI/LoginGUI.cs b/DangerousD/GameCore/GUI/LoginGUI.cs index 5b7f972..3ef45ae 100644 --- a/DangerousD/GameCore/GUI/LoginGUI.cs +++ b/DangerousD/GameCore/GUI/LoginGUI.cs @@ -46,7 +46,7 @@ namespace DangerousD.GameCore.GUI rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)), fontColor = Color.Black, fontName = "font2", - textureName = "textboxbackground1-1" + text = "<-" }; backButton.LeftButtonPressed += () => { AppManager.Instance.ChangeGameState(GameState.Menu); @@ -67,7 +67,6 @@ namespace DangerousD.GameCore.GUI textureName = "textboxbackground6-1" }; - Elements.Add(loginTextBox); loginTextBox.LoadTexture(AppManager.Instance.Content); loginTextBox.TextChanged += input => { if (loginTextBox.fontColor == Color.Gray) @@ -94,7 +93,6 @@ namespace DangerousD.GameCore.GUI textAligment = TextAligment.Left, textureName = "textboxbackground6-1" }; - Elements.Add(passwordTextBox); passwordTextBox.LoadTexture(AppManager.Instance.Content); passwordTextBox.TextChanged += input => { if (passwordTextBox.fontColor == Color.Gray) @@ -122,7 +120,6 @@ namespace DangerousD.GameCore.GUI fontName = "ButtonFont", textureName = "textboxbackground2-1" }; - Elements.Add(logButton); logButton.LeftButtonPressed += () => { if (CheckUser()) { @@ -140,7 +137,6 @@ namespace DangerousD.GameCore.GUI fontName = "ButtonFont", textureName = "textboxbackground2-1" }; - Elements.Add(regButton); regButton.LeftButtonPressed += GoToRegWebServer; Elements.Add(regButton); diff --git a/DangerousD/GameCore/Managers/SettingsManager.cs b/DangerousD/GameCore/Managers/SettingsManager.cs index b781ef1..726f0b1 100644 --- a/DangerousD/GameCore/Managers/SettingsManager.cs +++ b/DangerousD/GameCore/Managers/SettingsManager.cs @@ -13,7 +13,7 @@ namespace DangerousD.GameCore.Managers { public class SettingsManager { - private SettingsContainer settingsContainer= new SettingsContainer(); + private SettingsContainer settingsContainer = new SettingsContainer(); public bool IsFullScreen { get => settingsContainer.IsFullScreen; } public float MainVolume { get => settingsContainer.MainVolume; } public float MusicVolume { get => settingsContainer.MusicVolume; } @@ -57,6 +57,7 @@ namespace DangerousD.GameCore.Managers } settingsContainer = JsonConvert.DeserializeObject(File.ReadAllText("GameSettings.txt")); + if (settingsContainer == null) { settingsContainer = new SettingsContainer(); } SetIsFullScreen(settingsContainer.IsFullScreen); SetMainVolume(settingsContainer.MainVolume); SetMusicVolume(settingsContainer.MusicVolume);