Hlavní menu, synchronizace jmen hráčů. Client hru spustí až ve chvíli kdy dostane správný packet. Oprava bugu v se scalováním UIElementu
This commit is contained in:
parent
e6128dc9f5
commit
7656707177
19 changed files with 315 additions and 53 deletions
45
FNAF_Clone/GUI/MenuInputField.cs
Normal file
45
FNAF_Clone/GUI/MenuInputField.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGameLibrary.Graphics;
|
||||
|
||||
namespace FNAF_Clone.GUI;
|
||||
|
||||
public class MenuInputField : UIElement {
|
||||
private TextUIElement labelElement;
|
||||
private TextBoxUIElement textBoxElement;
|
||||
|
||||
public MenuInputField(SpriteFont font, Point position, string label, string defaultValue = "") : base(position, position) {
|
||||
labelElement =
|
||||
new TextUIElement(position, font){Text = label, Color = Color.Gray};
|
||||
textBoxElement =
|
||||
new TextBoxUIElement(font,
|
||||
new(labelElement.Bounds.Item1.X + (int)labelElement.Measure().X, labelElement.Bounds.Item1.Y),
|
||||
new(640, labelElement.Bounds.Item2.Y + (int)labelElement.Measure().Y));
|
||||
textBoxElement.OnFocused = () => {
|
||||
textBoxElement.Color = Color.LightGreen;
|
||||
labelElement.Color = Color.DarkGreen;
|
||||
};
|
||||
textBoxElement.OnUnfocused = () => {
|
||||
textBoxElement.Color = Color.White;
|
||||
labelElement.Color = Color.Gray;
|
||||
};
|
||||
|
||||
Bounds = (labelElement.Bounds.Item1, textBoxElement.Bounds.Item2);
|
||||
Pressable = true;
|
||||
OnMousePress = textBoxElement.OnMousePress;
|
||||
textBoxElement.Text = defaultValue;
|
||||
}
|
||||
|
||||
public string Text => textBoxElement.Text;
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch) {
|
||||
labelElement.Draw(spriteBatch);
|
||||
textBoxElement.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
base.Update();
|
||||
labelElement.Update();
|
||||
textBoxElement.Update();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue