Merge pull request #8 from progtime-net/uiAddon2

fix1
This commit is contained in:
polten0 2023-08-18 17:20:20 +03:00 committed by GitHub
commit b85d0744ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 24 deletions

View file

@ -83,12 +83,7 @@ public abstract class AbstractGui : IDrawableObject
} }
if (SelectedElement is TextBox) if (SelectedElement is TextBox)
{ {
TextBox box = (TextBox)SelectedElement; (SelectedElement as TextBox).hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering;
box.hoverState = MonogameLibrary.UI.Enums.HoverState.Hovering;
if (isStartedPrint)
{
box.SelectIt();
}
} }
} }
} }
@ -118,11 +113,6 @@ public abstract class AbstractGui : IDrawableObject
Button button = SelectedElement as Button; Button button = SelectedElement as Button;
button.CallLeftBtnEvent(); button.CallLeftBtnEvent();
} }
else if (SelectedElement is TextBox)
{
TextBox textBox = SelectedElement as TextBox;
isStartedPrint = true;
}
} }
else if (isPressed && (gamePadState.Buttons.A == ButtonState.Released && else if (isPressed && (gamePadState.Buttons.A == ButtonState.Released &&
gamePadState.DPad.Down == ButtonState.Released && gamePadState.DPad.Down == ButtonState.Released &&
@ -136,13 +126,11 @@ public abstract class AbstractGui : IDrawableObject
if (keyboardState.IsKeyDown(Keys.Up) && !isPressed) if (keyboardState.IsKeyDown(Keys.Up) && !isPressed)
{ {
isPressed = true; isPressed = true;
isStartedPrint = false;
ChangeSelectedElement(-1); ChangeSelectedElement(-1);
} }
else if (keyboardState.IsKeyDown(Keys.Down) && !isPressed) else if (keyboardState.IsKeyDown(Keys.Down) && !isPressed)
{ {
isPressed = true; isPressed = true;
isStartedPrint = false;
ChangeSelectedElement(1); ChangeSelectedElement(1);
} }
else if (keyboardState.IsKeyDown(Keys.Enter) && !isPressed) else if (keyboardState.IsKeyDown(Keys.Enter) && !isPressed)
@ -153,11 +141,6 @@ public abstract class AbstractGui : IDrawableObject
Button button = SelectedElement as Button; Button button = SelectedElement as Button;
button.CallLeftBtnEvent(); button.CallLeftBtnEvent();
} }
else if (SelectedElement is TextBox)
{
TextBox textBox = SelectedElement as TextBox;
isStartedPrint = true;
}
} }
else if (isPressed && (keyboardState.IsKeyUp(Keys.Enter) && else if (isPressed && (keyboardState.IsKeyUp(Keys.Enter) &&
keyboardState.IsKeyUp(Keys.Down) && keyboardState.IsKeyUp(Keys.Down) &&

View file

@ -46,7 +46,7 @@ namespace DangerousD.GameCore.GUI
rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)), rectangle = new Rectangle(screenWidth / 20, screenHeight / 15, (int)(40 * 2.4), (int)(40 * 2.4)),
fontColor = Color.Black, fontColor = Color.Black,
fontName = "font2", fontName = "font2",
textureName = "textboxbackground1-1" text = "<-"
}; };
backButton.LeftButtonPressed += () => { backButton.LeftButtonPressed += () => {
AppManager.Instance.ChangeGameState(GameState.Menu); AppManager.Instance.ChangeGameState(GameState.Menu);
@ -67,7 +67,6 @@ namespace DangerousD.GameCore.GUI
textureName = "textboxbackground6-1" textureName = "textboxbackground6-1"
}; };
Elements.Add(loginTextBox);
loginTextBox.LoadTexture(AppManager.Instance.Content); loginTextBox.LoadTexture(AppManager.Instance.Content);
loginTextBox.TextChanged += input => { loginTextBox.TextChanged += input => {
if (loginTextBox.fontColor == Color.Gray) if (loginTextBox.fontColor == Color.Gray)
@ -94,7 +93,6 @@ namespace DangerousD.GameCore.GUI
textAligment = TextAligment.Left, textAligment = TextAligment.Left,
textureName = "textboxbackground6-1" textureName = "textboxbackground6-1"
}; };
Elements.Add(passwordTextBox);
passwordTextBox.LoadTexture(AppManager.Instance.Content); passwordTextBox.LoadTexture(AppManager.Instance.Content);
passwordTextBox.TextChanged += input => { passwordTextBox.TextChanged += input => {
if (passwordTextBox.fontColor == Color.Gray) if (passwordTextBox.fontColor == Color.Gray)
@ -122,7 +120,6 @@ namespace DangerousD.GameCore.GUI
fontName = "ButtonFont", fontName = "ButtonFont",
textureName = "textboxbackground2-1" textureName = "textboxbackground2-1"
}; };
Elements.Add(logButton);
logButton.LeftButtonPressed += () => { logButton.LeftButtonPressed += () => {
if (CheckUser()) if (CheckUser())
{ {
@ -140,7 +137,6 @@ namespace DangerousD.GameCore.GUI
fontName = "ButtonFont", fontName = "ButtonFont",
textureName = "textboxbackground2-1" textureName = "textboxbackground2-1"
}; };
Elements.Add(regButton);
regButton.LeftButtonPressed += GoToRegWebServer; regButton.LeftButtonPressed += GoToRegWebServer;
Elements.Add(regButton); Elements.Add(regButton);

View file

@ -57,6 +57,7 @@ namespace DangerousD.GameCore.Managers
} }
settingsContainer = JsonConvert.DeserializeObject<SettingsContainer>(File.ReadAllText("GameSettings.txt")); settingsContainer = JsonConvert.DeserializeObject<SettingsContainer>(File.ReadAllText("GameSettings.txt"));
if (settingsContainer == null) { settingsContainer = new SettingsContainer(); }
SetIsFullScreen(settingsContainer.IsFullScreen); SetIsFullScreen(settingsContainer.IsFullScreen);
SetMainVolume(settingsContainer.MainVolume); SetMainVolume(settingsContainer.MainVolume);
SetMusicVolume(settingsContainer.MusicVolume); SetMusicVolume(settingsContainer.MusicVolume);