Beispiel #1
0
        public override void ExposeData(EntitySerializer serializer)
        {
            base.ExposeData(serializer);

            Window          = new InventoryWindow(this);
            OpenMenuCommand = InputCommand.FromDelegate(() => { Window.AddToScreen(); Window.Open(); });
            serializer.DataField(ref TemplateName, "Template", "HumanInventory");
            Window.CreateInventory(TemplateName);
        }
Beispiel #2
0
        public void Initialize()
        {
            CanvasLayer = new Godot.CanvasLayer
            {
                Name  = "UILayer",
                Layer = CanvasLayers.LAYER_GUI
            };

            _sceneTreeHolder.SceneTree.GetRoot().AddChild(CanvasLayer);

            RootControl = new Control("UIRoot")
            {
                MouseFilter = Control.MouseFilterMode.Ignore
            };
            RootControl.SetAnchorPreset(Control.LayoutPreset.Wide);

            CanvasLayer.AddChild(RootControl.SceneControl);

            StateRoot = new Control("StateRoot")
            {
                MouseFilter = Control.MouseFilterMode.Ignore
            };
            StateRoot.SetAnchorPreset(Control.LayoutPreset.Wide);
            RootControl.AddChild(StateRoot);

            WindowRoot = new Control("WindowRoot");
            WindowRoot.SetAnchorPreset(Control.LayoutPreset.Wide);
            WindowRoot.MouseFilter = Control.MouseFilterMode.Ignore;
            RootControl.AddChild(WindowRoot);

            PopupControl           = new AcceptDialog("RootPopup");
            PopupControl.Resizable = true;
            RootControl.AddChild(PopupControl);

            DebugConsole = new DebugConsole();
            RootControl.AddChild(DebugConsole);

            _debugMonitors = new DebugMonitors();
            RootControl.AddChild(_debugMonitors);

            _inputManager.SetInputCommand(EngineKeyFunctions.ShowDebugMonitors, InputCommand.FromDelegate(enabled: () =>
            {
                DebugMonitors.Visible = true;
            }, disabled: () =>
            {
                DebugMonitors.Visible = false;
            }));
        }
        private void InitInputCommands()
        {
            if (MoveUpCommand != null)
            {
                return;
            }

            MoveUpCommand = InputCommand.FromDelegate(() => { _movingUp = true; HandleKeyChange(); },
                                                      () => { _movingUp = false; HandleKeyChange(); });
            MoveLeftCommand = InputCommand.FromDelegate(() => { _movingLeft = true; HandleKeyChange(); },
                                                        () => { _movingLeft = false; HandleKeyChange(); });
            MoveRightCommand = InputCommand.FromDelegate(() => { _movingRight = true; HandleKeyChange(); },
                                                         () => { _movingRight = false; HandleKeyChange(); });
            MoveDownCommand = InputCommand.FromDelegate(() => { _movingDown = true; HandleKeyChange(); },
                                                        () => { _movingDown = false; HandleKeyChange(); });
            RunCommand = InputCommand.FromDelegate(() => _run = true,
                                                   () => _run = false);
        }
Beispiel #4
0
        public override void Startup()
        {
            IoCManager.InjectDependencies(this);

            escapeMenu = new EscapeMenu
            {
                Visible = false
            };
            escapeMenu.AddToScreen();

            var escapeMenuCommand = InputCommand.FromDelegate(() =>
            {
                if (escapeMenu.Visible)
                {
                    if (escapeMenu.IsAtFront())
                    {
                        escapeMenu.Visible = false;
                    }
                    else
                    {
                        escapeMenu.MoveToFront();
                    }
                }
                else
                {
                    escapeMenu.OpenCentered();
                }
            });

            inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand);
            inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCommand.FromDelegate(() =>
            {
                _gameChat.Input.GrabFocus();
            }));

            _gameChat = new Chatbox();
            userInterfaceManager.StateRoot.AddChild(_gameChat);
            _gameChat.TextSubmitted    += console.ParseChatMessage;
            console.AddString          += _gameChat.AddLine;
            _gameChat.DefaultChatFormat = "say \"{0}\"";
        }