public void AskNameForMultiplayer(object sender, MousePointer mousePointer, Controler controler, Vector2 clickPosition)
        {
            controler.Camera.LookAt(new Vector2(0, 0));
            ClearScene();
            var ti = new TextinputBox(controler.TextureManager.CreateTexture(200, 50, e => Color.Black), controler.Fonts["Default"], controler.KeyboardUtils, false);

            ti.Validated += ConnectToServer;
            instance.sprites.Add(ti);
        }
Example #2
0
        internal void OnTextInput(object sender, TextInputEventArgs e)
        {
            if (e.Character == '/' && !TerminalTexintput.IsFocused)
            {
                TerminalTexintput.Clear();
                TerminalTexintput.Focus(this);
            }
            TextinputBox itemFocus = (TextinputBox)_sprites.Where(s => s is TextinputBox).FirstOrDefault(t => (t as TextinputBox).IsFocused);

            if (itemFocus == null)
            {
                IsTextInputBoxFocused = false;
                return;
            }
            IsTextInputBoxFocused = true;
            KeyboardUtils.OnTextInput(sender, e, itemFocus);
        }
Example #3
0
        public Controler(GameWindow gameWindow, Dictionary <string, SpriteFont> Fonts, List <Sprite> sprites, GraphicsDeviceManager Graphics, ContentManager content, SpriteBatch spriteBatch, Vector2 Bounds)
        {
            ScripterManager.InstanceCreated += OnScripteManagerCreation;
            IsTextInputBoxFocused            = false;
            action         = new List <Action <object> >();
            actionArg      = new List <object>();
            KeyboardUtils  = new KeyboardUtils();
            RenderManager  = new RenderManager(sprites, Graphics, spriteBatch);
            TextureManager = new TextureManager(Graphics, content, spriteBatch, RenderManager, Fonts);
            DebugManager   = new DebugManager(TextureManager, Fonts, Graphics);
            Terminal       = new Terminal(TextureManager.CreateTexture(700, 30, paint => Color.Black), Fonts["Default"], this)
            {
                Position = new Vector2(0, 185)
            };
            NetworkManager = new NetworkManager(this, Terminal);

            window            = gameWindow;
            window.TextInput += OnTextInput;

            KeyboardUtils.KeyPressed   += DebugManager.AddEvent;
            KeyboardUtils.KeyRealeased += DebugManager.AddEvent;

            this.Bounds = Bounds;
            _sprites    = sprites;
            this.Fonts  = Fonts;
            graphics    = Graphics;

            Camera            = new Camera(new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
            TerminalTexintput = new TextinputBox(TextureManager.CreateTexture(700, 35, paint => Color.Black * .8f), Fonts["Default"], KeyboardUtils, true)
            {
                IsHUD = true, Position = new Vector2(0, 695), Opacity = 0f,
            };
            TerminalTexintput.Validated += Terminal.OnTextinputValidation;

            MousePointer = new MousePointer(TextureManager.LoadTexture("cursor"));
            _sprites.Add(Terminal);
            _sprites.Add(TerminalTexintput);
            _sprites.Add(MousePointer);

            ScripterManager.Instance.CreateMenu();
            InitKeyEvent();
        }
Example #4
0
        public void OnTextInput(object sender, TextInputEventArgs e, TextinputBox t)
        {
            switch (e.Key)
            {
            case Keys.Delete:
                t.RemoveChar(true);
                break;

            case Keys.Back:
                t.RemoveChar();
                break;

            case Keys.Escape:
                t.UnFocus();
                break;

            case Keys.Enter:
                break;

            default:
                t.AddChar(e.Character);
                break;
            }
        }
 public void ConnectToServer(string message, TextinputBox textinput)
 {
     instance.controler.NetworkManager.Connect(message);
 }