Beispiel #1
0
 public void Show()
 {
     _lastMode               = _scheme.CurrentMode;
     _scheme.CurrentMode     = MouseCursors.POINT_MODE;
     _scheme.RotatingEnabled = false;
     _panel.Visible          = true;
     _panel.GetComponent <IModalWindowComponent>().GrabFocus();
 }
Beispiel #2
0
        public void Load(IPanel parent)
        {
            _parent  = parent;
            _panelId = parent.TreeNode.GetRoot().ID;
            var factory = _editor.Editor.Factory;

            _searchBox             = factory.UI.GetTextBox("GameDebugTreeSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _searchBox.Tint        = GameViewColors.Textbox;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugTreeScrollingPanel", parent.Width - _gutterSize, parent.Height - _searchBox.Height - _gutterSize, 0f, 0f, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 0f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _contentsPanel = factory.UI.CreateScrollingPanel(_scrollingPanel);
            _treeView      = _contentsPanel.AddComponent <ITreeViewComponent>();
            _treeView.OnNodeSelected.Subscribe(onTreeNodeSelected);
            _treeView.TopPadding  = 30f;
            _treeView.LeftPadding = 5f;
            parent.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                _contentsPanel.BaseSize = new SizeF(_contentsPanel.Width, parent.Height - _searchBox.Height - _gutterSize);
                _searchBox.Y            = _parent.Height;
            };
        }
        public void Load(IPanel parent)
        {
            _parent = parent;
            var factory = _game.Factory;

            _searchBox             = factory.UI.GetTextBox("GameDebugDisplayListSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = AGSBorders.SolidColor(Colors.Green, 2f);
            _searchBox.Tint        = Colors.Transparent;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.Visible     = false;
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugDisplayListScrollingPanel", parent.Width, parent.Height - _searchBox.Height, 0f, 0f, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 0f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = AGSBorders.SolidColor(Colors.Green, 2f);
            _scrollingPanel.Visible     = false;

            const float lineHeight = 42f;

            _listPanel             = factory.UI.GetPanel("GameDebugDisplayListPanel", 1f, 1f, 0f, _scrollingPanel.Height - lineHeight, _scrollingPanel);
            _listPanel.Tint        = Colors.Transparent;
            _listPanel.RenderLayer = _layer;
            _listPanel.Pivot       = new PointF(0f, 1f);
            _listPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            _layout  = _listPanel.AddComponent <IStackLayoutComponent>();
            _listBox = _listPanel.AddComponent <IListboxComponent>();
            var yellowBrush = factory.Graphics.Brushes.LoadSolidBrush(Colors.Yellow);
            var whiteBrush  = factory.Graphics.Brushes.LoadSolidBrush(Colors.White);

            _listBox.ItemButtonFactory = text =>
            {
                var button = factory.UI.GetButton("GameDebugDisplayListPanel_" + text,
                                                  new ButtonAnimation(null, new AGSTextConfig(whiteBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, new AGSTextConfig(yellowBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, new AGSTextConfig(yellowBrush, outlineBrush: whiteBrush, outlineWidth: 0.5f, autoFit: AutoFit.LabelShouldFitText), null),
                                                  0f, 0f, width: 500f, height: 50f);
                button.RenderLayer = parent.RenderLayer;
                return(button);
            };
            factory.UI.CreateScrollingPanel(_scrollingPanel);
            parent.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                _scrollingPanel.Image = new EmptyImage(_scrollingPanel.Width, parent.Height - _searchBox.Height);
                _listPanel.Y          = _scrollingPanel.Height - 10f;
                _searchBox.Y          = _parent.Height;
            };
        }
Beispiel #4
0
        public void Load(IPanel parent)
        {
            _parent = parent;
            var factory = _editor.Factory;

            _searchBox             = factory.UI.GetTextBox("GameDebugDisplayListSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _searchBox.Tint        = GameViewColors.Textbox;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.Visible     = false;
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugDisplayListScrollingPanel", parent.Width - _gutterSize, parent.Height - _searchBox.Height - _gutterSize, 0f, 0f, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 0f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _scrollingPanel.Visible     = false;
            _contentsPanel = factory.UI.CreateScrollingPanel(_scrollingPanel);

            _listPanel             = factory.UI.GetPanel("GameDebugDisplayListPanel", 1f, 1f, 0f, _contentsPanel.Height - _padding, _contentsPanel);
            _listPanel.Tint        = Colors.Transparent;
            _listPanel.RenderLayer = _layer;
            _listPanel.Pivot       = new PointF(0f, 1f);
            _listPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            _layout  = _listPanel.AddComponent <IStackLayoutComponent>();
            _listBox = _listPanel.AddComponent <IListboxComponent>();
            var hoverBrush = factory.Graphics.Brushes.LoadSolidBrush(GameViewColors.HoveredText);
            var textBrush  = factory.Graphics.Brushes.LoadSolidBrush(GameViewColors.Text);

            _listBox.ListItemFactory = text =>
            {
                var button = factory.UI.GetButton("GameDebugDisplayListPanel_" + text,
                                                  new ButtonAnimation(null, factory.Fonts.GetTextConfig(textBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, factory.Fonts.GetTextConfig(hoverBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, factory.Fonts.GetTextConfig(hoverBrush, outlineBrush: textBrush, outlineWidth: 0.5f, autoFit: AutoFit.LabelShouldFitText), null),
                                                  0f, 0f, width: 500f, height: 50f);
                button.RenderLayer = parent.RenderLayer;
                button.Text        = text;
                return(button);
            };
            parent.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                _contentsPanel.BaseSize = new SizeF(_contentsPanel.Width, parent.Height - _searchBox.Height - _gutterSize);
                _listPanel.Y            = _contentsPanel.Height - _padding;
                _searchBox.Y            = _parent.Height;
            };
        }
Beispiel #5
0
        public void Load(IPanel parent)
        {
            _parent  = parent;
            _panelId = parent.TreeNode.GetRoot().ID;
            var factory = _game.Factory;

            _searchBox             = factory.UI.GetTextBox("GameDebugTreeSearchBox", 0f, parent.Height, parent, "Search...", width: parent.Width, height: 30f);
            _searchBox.RenderLayer = _layer;
            _searchBox.Border      = AGSBorders.SolidColor(Colors.Green, 2f);
            _searchBox.Tint        = Colors.Transparent;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugTreeScrollingPanel", parent.Width, parent.Height - _searchBox.Height, 0f, 0f, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 0f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = AGSBorders.SolidColor(Colors.Green, 2f);
            const float lineHeight = 42f;

            _treePanel             = factory.UI.GetPanel("GameDebugTreePanel", 1f, 1f, 0f, _scrollingPanel.Height - lineHeight, _scrollingPanel);
            _treePanel.Tint        = Colors.Transparent;
            _treePanel.RenderLayer = _layer;
            _treeView = _treePanel.AddComponent <ITreeViewComponent>();
            _treeView.OnNodeSelected.Subscribe(onTreeNodeSelected);
            factory.UI.CreateScrollingPanel(_scrollingPanel);
            parent.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                _scrollingPanel.Image = new EmptyImage(_scrollingPanel.Width, parent.Height - _searchBox.Height);
                _treePanel.Y          = _scrollingPanel.Height - lineHeight;
                _searchBox.Y          = _parent.Height;
            };
        }
Beispiel #6
0
        public void Load()
        {
            const float  headerHeight = 50f;
            const float  borderWidth  = 3f;
            IGameFactory factory      = _editor.Editor.Factory;

            _panel = factory.UI.GetPanel(_panelId, _layer.IndependentResolution.Value.Width / 4f, _layer.IndependentResolution.Value.Height,
                                         1f, _layer.IndependentResolution.Value.Height / 2f);
            _panel.Pivot        = new PointF(0f, 0.5f);
            _panel.Visible      = false;
            _panel.Tint         = GameViewColors.Panel;
            _panel.Border       = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true);
            _panel.RenderLayer  = _layer;
            _panel.ClickThrough = false;
            _editor.Editor.State.FocusedUI.CannotLoseFocus.Add(_panelId);

            var headerLabel = factory.UI.GetLabel("GameDebugTreeLabel", "Game Debug", _panel.Width, headerHeight, 0f, _panel.Height - headerHeight,
                                                  _panel, new AGSTextConfig(alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel));

            headerLabel.Tint        = Colors.Transparent;
            headerLabel.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true);
            headerLabel.RenderLayer = _layer;

            var xButton = factory.UI.GetButton("GameDebugTreeCloseButton", (IAnimation)null, null, null, 0f, _panel.Height - headerHeight + 5f, _panel, "X",
                                               new AGSTextConfig(factory.Graphics.Brushes.LoadSolidBrush(Colors.Red),
                                                                 autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter),
                                               width: 40f, height: 40f);

            xButton.Pivot       = new PointF();
            xButton.RenderLayer = _layer;
            xButton.Tint        = Colors.Transparent;
            xButton.MouseEnter.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f));
            xButton.MouseLeave.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Red, Colors.Transparent, 0f));
            xButton.MouseClicked.Subscribe(_ => Hide());

            _panesButton = factory.UI.GetButton("GameDebugViewPanesButton", (IAnimation)null, null, null, _panel.Width, xButton.Y, _panel, "Display List",
                                                new AGSTextConfig(autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleRight),
                                                width: 120f, height: 40f);
            _panesButton.Pivot       = new PointF(1f, 0f);
            _panesButton.RenderLayer = _layer;
            _panesButton.Tint        = GameViewColors.Button;
            _panesButton.MouseEnter.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f));
            _panesButton.MouseLeave.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.Text, Colors.Transparent, 0f));
            _panesButton.MouseClicked.SubscribeToAsync(onPaneSwitch);

            var parentPanelHeight = _panel.Height - headerHeight;
            var parentPanel       = factory.UI.GetPanel("GameDebugParentPanel", _panel.Width, parentPanelHeight, 0f, parentPanelHeight, _panel);

            parentPanel.Pivot       = new PointF(0f, 1f);
            parentPanel.Tint        = Colors.Transparent;
            parentPanel.RenderLayer = _layer;

            var topPanel = factory.UI.GetPanel("GameDebugTopPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel);

            topPanel.Pivot       = new PointF(0f, 0f);
            topPanel.Tint        = Colors.Transparent;
            topPanel.RenderLayer = _layer;

            var bottomPanel = factory.UI.GetPanel("GameDebugBottomPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel);

            bottomPanel.Pivot       = new PointF(0f, 1f);
            bottomPanel.Tint        = Colors.Transparent;
            bottomPanel.RenderLayer = _layer;

            Tree.Load(topPanel);
            _displayList.Load(topPanel);
            _inspector.Load(bottomPanel);
            _currentTab             = Tree;
            _splitPanel             = parentPanel.AddComponent <ISplitPanelComponent>();
            _splitPanel.TopPanel    = topPanel;
            _splitPanel.BottomPanel = bottomPanel;

            var horizSplit = _panel.AddComponent <ISplitPanelComponent>();

            horizSplit.IsHorizontal = true;
            horizSplit.TopPanel     = _panel;

            _panel.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Width))
                {
                    return;
                }
                _panesButton.X = _panel.Width;
                headerLabel.LabelRenderSize = new SizeF(_panel.Width, headerLabel.LabelRenderSize.Height);
                parentPanel.BaseSize        = new SizeF(_panel.Width, parentPanel.Height);
                topPanel.BaseSize           = new SizeF(_panel.Width, topPanel.Height);
                bottomPanel.BaseSize        = new SizeF(_panel.Width, bottomPanel.Height);
                _currentTab.Resize();
                _inspector.Resize();
                resizeGameWindow();
            };
        }
Beispiel #7
0
        public async Task <string> Run()
        {
            IGameFactory factory       = _game.Factory;
            float        panelWidth    = _game.Settings.VirtualResolution.Width * 3 / 4f;
            float        panelHeight   = _game.Settings.VirtualResolution.Height * 3 / 4f;
            const float  labelHeight   = 20f;
            const float  textBoxHeight = 20f;
            const float  buttonHeight  = 20f;
            float        itemHeight    = panelHeight / 8f;

            ITEM_WIDTH = panelWidth / 10f;
            float       itemPaddingX        = panelWidth / 10f;
            float       itemPaddingY        = panelHeight / 12f;
            const float scrollButtonWidth   = 20f;
            const float scrollButtonHeight  = 20f;
            const float scrollButtonOffsetX = 5f;
            const float scrollButtonOffsetY = 5f;
            const float okButtonWidth       = 50f;
            const float okButtonHeight      = 20f;
            const float okButtonPaddingX    = 20f;
            const float okButtonPaddingY    = 20f;
            float       okCancelWidth       = okButtonWidth * 2 + okButtonPaddingX;
            float       okButtonX           = panelWidth / 2f - okCancelWidth / 2f;
            float       cancelButtonX       = okButtonX + okButtonWidth + okButtonPaddingX;
            float       panelX        = _game.Settings.VirtualResolution.Width / 2f - panelWidth / 2f;
            float       panelY        = _game.Settings.VirtualResolution.Height / 2f - panelHeight / 2f;
            ITextConfig textBoxConfig = factory.Fonts.GetTextConfig(alignment: Alignment.BottomLeft,
                                                                    autoFit: AutoFit.TextShouldCrop, font: _game.Factory.Fonts.LoadFont(_game.Settings.Defaults.TextFont.FontFamily, 10f));

            IPanel panel = factory.UI.GetPanel("SelectFilePanel", panelWidth, panelHeight, panelX, panelY);

            panel.RenderLayer = new AGSRenderLayer(AGSLayers.UI.Z - 1);
            panel.SkinTags.Add(AGSSkin.DialogBoxTag);
            panel.Skin?.Apply(panel);
            panel.AddComponent <IModalWindowComponent>().GrabFocus();
            factory.UI.GetLabel("SelectFileTitle", _title, panelWidth, labelHeight, 0f, panelHeight - labelHeight, panel, _buttonsTextConfig);
            _fileTextBox = factory.UI.GetTextBox("SelectFileTextBox", 0f, panelHeight - labelHeight - textBoxHeight, panel, _startPath, textBoxConfig, width: panelWidth, height: textBoxHeight);

            _inventory = new AGSInventory();
            IInventoryWindow invWindow = factory.Inventory.GetInventoryWindow("SelectFileInventory", panelWidth - scrollButtonWidth - scrollButtonOffsetX * 2,
                                                                              panelHeight - labelHeight - buttonHeight - textBoxHeight - okButtonPaddingY, ITEM_WIDTH + itemPaddingX, itemHeight + itemPaddingY, 0f, okButtonPaddingY + okButtonHeight, _inventory);

            invWindow.Z = 1;
            IButton okButton         = factory.UI.GetButton("SelectFileOkButton", (string)null, null, null, okButtonX, okButtonPaddingY, panel, "OK", _buttonsTextConfig, width: okButtonWidth, height: okButtonHeight);
            IButton cancelButton     = factory.UI.GetButton("SelectFileCancelButton", (string)null, null, null, cancelButtonX, okButtonPaddingY, panel, "Cancel", _buttonsTextConfig, width: okButtonWidth, height: okButtonHeight);
            IButton scrollDownButton = factory.UI.GetButton("SelectFileScrollDown", (string)null, null, null, panelWidth - scrollButtonWidth - scrollButtonOffsetX, okButton.Y + okButtonHeight + scrollButtonOffsetY, panel, "", _buttonsTextConfig, width: scrollButtonWidth, height: scrollButtonHeight);
            IButton scrollUpButton   = factory.UI.GetButton("SelectFileScrollUp", (string)null, null, null, panelWidth - scrollButtonWidth - scrollButtonOffsetX, panelHeight - labelHeight - textBoxHeight - scrollButtonHeight - scrollButtonOffsetY, panel, "", _buttonsTextConfig, width: scrollButtonWidth, height: scrollButtonHeight);

            invWindow.TreeNode.SetParent(panel.TreeNode);

            cancelButton.MouseClicked.Subscribe(onCancelClicked);
            okButton.MouseClicked.SubscribeToAsync(onOkClicked);

            scrollDownButton.MouseClicked.Subscribe(_ => invWindow.ScrollDown());
            scrollUpButton.MouseClicked.Subscribe(_ => invWindow.ScrollUp());

            var iconFactory = factory.Graphics.Icons;

            _fileIcon           = iconFactory.GetFileIcon();
            _fileIconSelected   = iconFactory.GetFileIcon(true);
            _folderIcon         = iconFactory.GetFolderIcon();
            _folderIconSelected = iconFactory.GetFolderIcon(true);

            var arrowDownIcon = getIcon("ArrowDown", factory, scrollButtonWidth, scrollButtonHeight,
                                        iconFactory.GetArrowIcon(ArrowDirection.Down), scrollDownButton.RenderLayer);

            arrowDownIcon.Pivot   = new PointF();
            arrowDownIcon.Enabled = false;
            arrowDownIcon.TreeNode.SetParent(scrollDownButton.TreeNode);
            _game.State.UI.Add(arrowDownIcon);

            var arrowUpIcon = getIcon("ArrowUp", factory, scrollButtonWidth, scrollButtonHeight,
                                      iconFactory.GetArrowIcon(ArrowDirection.Up), scrollUpButton.RenderLayer);

            arrowUpIcon.Pivot   = new PointF();
            arrowUpIcon.Enabled = false;
            arrowUpIcon.TreeNode.SetParent(scrollUpButton.TreeNode);
            _game.State.UI.Add(arrowUpIcon);

            _fileGraphics   = getIcon("FileGraphics", factory, ITEM_WIDTH, itemHeight, _fileIcon, scrollUpButton.RenderLayer);
            _folderGraphics = getIcon("FolderGraphics", factory, ITEM_WIDTH, itemHeight, _folderIcon, scrollUpButton.RenderLayer);

            fillAllFiles(_startPath);

            _fileTextBox.OnPressingKey.Subscribe(onTextBoxKeyPressed);

            bool okGiven = await _tcs.Task;

            clearInventory();
            panel.GetComponent <IModalWindowComponent>().LoseFocus();
            destroy(panel);
            destroy(_fileGraphics);
            destroy(_folderGraphics);
            destroy(_fileTextBox);
            var result = _fileTextBox.Text;

            if (!okGiven)
            {
                return(null);
            }
            return(result);
        }