Projekt přejmenován. Neko nastaven na výchozí pozici
This commit is contained in:
parent
1a27dd6fab
commit
ceac37920b
104 changed files with 873 additions and 208 deletions
48
ONDClient/GUI/MenuInputField.cs
Normal file
48
ONDClient/GUI/MenuInputField.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGameLibrary.Graphics;
|
||||
|
||||
namespace ONDClient.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{
|
||||
get => textBoxElement.Text;
|
||||
set => textBoxElement.Text = value;
|
||||
}
|
||||
|
||||
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