Beispiel #1
0
 public void AddEvent(object e, KeyboardUtils keyboardUtils)
 {
     if (EventLogList.Count > 10)
     {
         EventLogList.RemoveAt(0);
     }
     if (e is KeysArray)
     {
         EventLogList.Add(new LogElement(e.ToString()));
     }
     if (e is string)
     {
         EventLogList.Add(new LogElement(e as string));
     }
 }
Beispiel #2
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();
        }
Beispiel #3
0
        private void OnKeyPressed(Keys[] keys, KeyboardUtils keyboardUtils)
        {
            if (KeyboardUtils.Contains(keys, Keys.Enter))
            {
                TerminalTexintput.ToggleFocus(this, true);
            }
            if (KeyboardUtils.Contains(keys, Keys.OemQuestion))
            {
                Terminal.AddMessageToTerminal("This is a ne message", "Client", Color.Green);
            }
            if (KeyboardUtils.Contains(keys, Keys.F3))
            {
                DebugManager.ToggleDebugMode(_sprites);
            }
            if (KeyboardUtils.Contains(keys, Keys.F2))
            {
                Texture2D screenshot = RenderManager.RenderSceneToTexture();

                Stream stream = File.Create(@"C:\Users\nicol\Desktop\image.png");
                screenshot.SaveAsPng(stream, (int)Bounds.X, (int)Bounds.Y);
                stream.Dispose();
            }
            if (KeyboardUtils.Contains(keys, Keys.F5))
            {
                Camera.ToggleFollow();
            }
            if (KeyboardUtils.Contains(keys, Keys.F1))
            {
                using (StreamReader sr = new StreamReader("ip.txt"))
                {
                    string ip = sr.ReadLine();
                    NetworkManager.Connect(ip);
                }
            }
            DebugManager.AddEvent("Key pressed : " + new KeysArray(keys), keyboardUtils);
        }
Beispiel #4
0
 private void OnKeyRealeased(Keys[] keys, KeyboardUtils keyboardUtils)
 {
     DebugManager.AddEvent("Key realeased : " + new KeysArray(keys), keyboardUtils);
 }