Projekt přejmenován. Neko nastaven na výchozí pozici

This commit is contained in:
Perry 2026-03-22 18:31:05 +01:00
parent 1a27dd6fab
commit ceac37920b
104 changed files with 873 additions and 208 deletions

View file

@ -0,0 +1,42 @@
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGameLibrary;
using MonoGameLibrary.Graphics;
using MonoGameLibrary.Input;
namespace ONDClient.GUI;
public class TextBoxUIElement : TextUIElement {
public bool Focused{ get; set; } = false;
public Action OnFocused{ get; set; } = () => { };
public Action OnUnfocused{ get; set; } = () => { };
public TextBoxUIElement(SpriteFont font, Point corner1, Point corner2) : base(corner1, corner2, font) {
Core.Instance.Window.TextInput += TextInputHandler;
InputManager.AddListener(InputManager.MouseButton.LEFT, () => {
if (!IsWithinBounds(InputManager.MouseState.Position)){
Focused = false;
OnUnfocused();
}
},
InputTiming.PRESS, new InputListenerHook(true));
Pressable = true;
OnMousePress = () => {
Focused = true;
OnFocused();
};
}
public void TextInputHandler(object sender, TextInputEventArgs e) {
if (!Focused) return;
if (e.Character == '\b') {
if (Text.Length > 0) Text = Text[..^1];
return;
}
if(Font.Characters.Contains(e.Character))
Text += e.Character;
}
}