예제 #1
0
        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(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      = AGSBorders.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.ItemButtonFactory = text =>
            {
                var button = factory.UI.GetButton("GameDebugDisplayListPanel_" + text,
                                                  new ButtonAnimation(null, new AGSTextConfig(textBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, new AGSTextConfig(hoverBrush, autoFit: AutoFit.LabelShouldFitText), null),
                                                  new ButtonAnimation(null, new AGSTextConfig(hoverBrush, outlineBrush: textBrush, outlineWidth: 0.5f, autoFit: AutoFit.LabelShouldFitText), null),
                                                  0f, 0f, width: 500f, height: 50f);
                button.RenderLayer = parent.RenderLayer;
                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;
            };
        }
예제 #2
0
            public RunningTween(string name, Tween tween, IGame game, IObject parent)
            {
                _game  = game;
                _tween = tween;
                var factory = game.Factory.UI;
                var tweenId = ++id;

                _panel             = factory.GetPanel($"FeaturesTweenPanel_{tweenId}", 300f, 20f, 0f, 0f, null, false);
                _panel.Visible     = false;
                _panel.RenderLayer = parent.RenderLayer;
                _panel.Tint        = Colors.Transparent;
                _panel.Pivot       = new PointF(0f, 1f);

                _slider                       = factory.GetSlider($"FeaturesTweenSlider_{tweenId}", null, null, 0f, 0f, tween.DurationInTicks, _panel);
                _slider.Location              = new AGSLocation(10f, 10f);
                _slider.HandleGraphics.Pivot  = new PointF(0.5f, 0.5f);
                _slider.Direction             = SliderDirection.LeftToRight;
                _slider.Graphics.Pivot        = new PointF(0f, 0.5f);
                _slider.Graphics.Image        = new EmptyImage(_panel.Width - 100f, 10f);
                _slider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
                _slider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
                HoverEffect.Add(_slider.Graphics, Colors.Green, Colors.LightGray);
                HoverEffect.Add(_slider.HandleGraphics, Colors.DarkGreen, Colors.WhiteSmoke);

                _label = factory.GetLabel($"FeaturesTweenLabel_{tweenId}", name, 100f, 20f,
                                          _slider.X + _slider.Graphics.Width / 2f, _slider.Y + 10f, _panel,
                                          new AGSTextConfig(autoFit: AutoFit.TextShouldFitLabel));
                _label.Pivot = new PointF(0.5f, 0f);

                AGSTextConfig idleConfig  = new AGSTextConfig(alignment: Alignment.MiddleCenter, brush: _game.Factory.Graphics.Brushes.LoadSolidBrush(Colors.White));
                AGSTextConfig hoverConfig = new AGSTextConfig(alignment: Alignment.MiddleCenter, brush: _game.Factory.Graphics.Brushes.LoadSolidBrush(Colors.Black));

                var idle    = new ButtonAnimation(AGSBorders.SolidColor(Colors.AliceBlue, 2f), idleConfig, Colors.Transparent);
                var hovered = new ButtonAnimation(AGSBorders.SolidColor(Colors.Goldenrod, 2f), hoverConfig, Colors.Yellow);
                var pushed  = new ButtonAnimation(AGSBorders.SolidColor(Colors.AliceBlue, 4f), idleConfig, Colors.Transparent);

                _rewindButton    = factory.GetButton($"FeaturesTweenRewindButton_{tweenId}", idle, hovered, pushed, 235f, 0f, _panel, "Rewind", width: 100f, height: 30f);
                _playPauseButton = factory.GetButton($"FeaturesTweenPlayPauseButton_{tweenId}", idle, hovered, pushed, 345f, 0f, _panel, "Pause", width: 100f, height: 30f);
                _stopButton      = factory.GetButton($"FeaturesTweenStopButton_{tweenId}", idle, hovered, pushed, 455f, 0f, _panel, "Stop", width: 100f, height: 30f);
                _stopButton.MouseClicked.Subscribe(_ => Stop());
                _rewindButton.MouseClicked.Subscribe(_ => _tween.Rewind());
                _playPauseButton.MouseClicked.Subscribe(onPlayPauseClick);
                _slider.OnValueChanging.Subscribe(onSliderValueChanging);

                _panel.TreeNode.SetParent(parent.TreeNode);
                game.State.UI.Add(_panel);
                _panel.Visible = true;

                game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
            }
예제 #3
0
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var label    = view.TreeItem;
            var combobox = _factory.UI.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 200f, defaultHeight: 25f);

            _dropDownButton             = combobox.DropDownButton;
            _text                       = combobox.TextBox;
            _text.TextBackgroundVisible = false;
            var list = new List <IStringItem>();

            foreach (var field in typeof(Colors).GetTypeInfo().DeclaredFields)
            {
                list.Add(new AGSStringItem {
                    Text = field.Name
                });
                Color color = (Color)field.GetValue(null);
                _namedColors[field.Name]          = color.Value;
                _namedColorsReversed[color.Value] = field.Name;
            }
            combobox.DropDownPanelList.Items.AddRange(list);
            combobox.Z = label.Z;

            _colorLabel             = _factory.UI.GetLabel($"{id}_ColorLabel", "", 50f, 25f, combobox.Width + 10f, 0f, label.TreeNode.Parent);
            _colorLabel.TextVisible = false;

            view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>().RestrictionList.RestrictionList.AddRange(new List <string> {
                combobox.ID, _colorLabel.ID
            });

            RefreshUI();
            _text.TextConfig.AutoFit    = AutoFit.TextShouldFitLabel;
            _text.TextConfig.Alignment  = Alignment.MiddleLeft;
            _text.TextBackgroundVisible = true;
            _text.Border = AGSBorders.SolidColor(Colors.White, 2f);
            var whiteBrush  = _text.TextConfig.Brush;
            var yellowBrush = _factory.Graphics.Brushes.LoadSolidBrush(Colors.Yellow);

            _text.MouseEnter.Subscribe(_ => { _text.TextConfig.Brush = yellowBrush; });
            _text.MouseLeave.Subscribe(_ => { _text.TextConfig.Brush = whiteBrush; });
            _text.OnPressingKey.Subscribe(onTextboxPressingKey);
            combobox.SuggestMode = ComboSuggest.Suggest;
            combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args =>
            {
                setColor(Color.FromHexa(_namedColors[args.Item.Text]));
            });
        }
예제 #4
0
        public void Load()
        {
            _recentGames.Load();
            _panel      = _game.Factory.UI.GetPanel("WelcomeScreenPanel", 1280, 800, 0, 0, addToUi: false);
            _panel.Tint = GameViewColors.Panel;

            var border = AGSBorders.SolidColor(GameViewColors.Border, 2f);

            var idle       = new ButtonAnimation(border, GameViewColors.TextConfig, GameViewColors.Button);
            var hovered    = new ButtonAnimation(border, GameViewColors.HoverTextConfig, GameViewColors.Button);
            var pushed     = new ButtonAnimation(AGSBorders.SolidColor(Colors.Black, 2f), GameViewColors.TextConfig, GameViewColors.Button);
            var loadButton = _game.Factory.UI.GetButton("LoadGameButton", idle, hovered, pushed, 200f, 700f, _panel,
                                                        "Load Game...", new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText), width: 100f, height: 100f);

            loadButton.Pivot = new PointF(0f, 1f);

            loadButton.MouseClicked.SubscribeToAsync(onLoadGameClicked);
        }
예제 #5
0
        public AGSSilverSkin(IGraphicsFactory factory, IGLUtils glUtils)
        {
            var buttonBorder       = AGSBorders.SolidColor(glUtils, GameViewColors.Border, 1f);
            var pushedButtonBorder = AGSBorders.SolidColor(glUtils, GameViewColors.Border, 2f);

            _skin = new AGSColoredSkin(factory)
            {
                ButtonIdleAnimation              = new ButtonAnimation(buttonBorder, null, GameViewColors.Button),
                ButtonHoverAnimation             = new ButtonAnimation(buttonBorder, null, GameViewColors.HoveredButton),
                ButtonPushedAnimation            = new ButtonAnimation(pushedButtonBorder, null, GameViewColors.PushedButton),
                TextBoxBackColor                 = GameViewColors.Textbox,
                TextBoxBorderStyle               = AGSBorders.SolidColor(glUtils, Colors.WhiteSmoke, 1f),
                CheckboxCheckedAnimation         = new ButtonAnimation(buttonBorder, null, GameViewColors.Button),
                CheckboxNotCheckedAnimation      = new ButtonAnimation(buttonBorder, null, GameViewColors.Button),
                CheckboxHoverCheckedAnimation    = new ButtonAnimation(buttonBorder, null, GameViewColors.HoveredButton),
                CheckboxHoverNotCheckedAnimation = new ButtonAnimation(buttonBorder, null, GameViewColors.HoveredButton),
                DialogBoxColor  = GameViewColors.Panel,
                DialogBoxBorder = AGSBorders.SolidColor(glUtils, Colors.WhiteSmoke, 2f)
            };
        }
예제 #6
0
        public void RefreshUI()
        {
            var color = (Color)_property.Prop.GetValue(_property.Object);

            if (_namedColorsReversed.ContainsKey(color.Value))
            {
                _text.Text = _namedColorsReversed[color.Value];
            }
            else
            {
                _text.Text = $"{color.R},{color.G},{color.B},{color.A}";
            }
            _colorLabel.Tint = color;
            _text.Border     = AGSBorders.SolidColor(color, 2f);
            var buttonBorder = AGSBorders.Multiple(AGSBorders.SolidColor(color, 1f),
                                                   _factory.Graphics.Icons.GetArrowIcon(ArrowDirection.Down, color));

            _dropDownButton.IdleAnimation = new ButtonAnimation(buttonBorder, null, Colors.Transparent);
            _dropDownButton.Border        = buttonBorder;
        }
예제 #7
0
        private void selectObject(ITreeStringNode node)
        {
            var obj = node.Properties.Entities.GetValue(Fields.Entity);

            _inspector.Inspector.Show(obj);
            var visibleComponent = obj.GetComponent <IVisibleComponent>();
            var image            = obj.GetComponent <IImageComponent>();
            var borderComponent  = obj.GetComponent <IBorderComponent>();

            if (image != null && borderComponent != null)
            {
                _lastSelectedBorder = borderComponent;
                IBorderStyle border = null;
                border            = borderComponent.Border;
                _lastObjectBorder = border;
                IBorderStyle hoverBorder = AGSBorders.Gradient(new FourCorners <Color>(Colors.Yellow, Colors.Yellow.WithAlpha(150),
                                                                                       Colors.Yellow.WithAlpha(150), Colors.Yellow), 1, true);
                if (border == null)
                {
                    borderComponent.Border = hoverBorder;
                }
                else
                {
                    borderComponent.Border = AGSBorders.Multiple(border, hoverBorder);
                }

                if (image.Opacity == 0)
                {
                    _lastOpacity           = image.Opacity;
                    _lastSelectedMaskImage = image;
                    image.Opacity          = 100;
                }
            }
            if (visibleComponent != null)
            {
                _lastMaskVisible         = visibleComponent.Visible;
                _lastSelectedMaskVisible = visibleComponent;
                visibleComponent.Visible = true;
            }
        }
예제 #8
0
        public void Load(IPanel parent)
        {
            _parent = parent;
            var factory = _game.Factory;

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

            var height = parent.Height - _searchBox.Height - _gutterSize;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugInspectorScrollingPanel", parent.Width - _gutterSize, height, 0f, parent.Height - _searchBox.Height, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 1f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = AGSBorders.SolidColor(GameViewColors.Border, 2f);
            _contentsPanel = factory.UI.CreateScrollingPanel(_scrollingPanel);

            _treePanel             = factory.UI.GetPanel("GameDebugInspectorPanel", 0f, 0f, 0f, _contentsPanel.Height - _padding, _contentsPanel);
            _treePanel.Tint        = Colors.Transparent;
            _treePanel.RenderLayer = _layer;
            _treePanel.Pivot       = new PointF(0f, 1f);
            var treeView = _treePanel.AddComponent <ITreeViewComponent>();

            treeView.SkipRenderingRoot = true;

            Inspector = new AGSInspector(_game.Factory, _game.Settings, _game.State);
            _treePanel.AddComponent <IInspectorComponent>(Inspector);

            _inspectorNodeView = new InspectorTreeNodeProvider(treeView.NodeViewProvider, _game.Factory,
                                                               _game.Events, _treePanel);
            _inspectorNodeView.Resize(_contentsPanel.Width);
            treeView.NodeViewProvider = _inspectorNodeView;

            _parent.Bind <IScaleComponent>(c => c.PropertyChanged += onParentPanelScaleChanged,
                                           c => c.PropertyChanged -= onParentPanelScaleChanged);
        }
예제 #9
0
        public FeaturesLabelsPanel(IGame game, IObject parent)
        {
            _game   = game;
            _parent = parent;
            var factory = game.Factory;

            _label = factory.UI.GetLabel("FeaturesLabel", LABEL_TEXT,
                                         200f, 50f, 25f, _parent.Height - 25f, parent,
                                         new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight), false);
            _label.RenderLayer = parent.RenderLayer;
            _label.Pivot       = new PointF(0f, 1f);
            _label.Tint        = Colors.DarkOliveGreen;
            _label.Border      = AGSBorders.SolidColor(Colors.LightSeaGreen, 3f);
            _label.MouseEnter.Subscribe(_ => _label.Tint = Colors.DarkGoldenrod);
            _label.MouseLeave.Subscribe(_ => _label.Tint = Colors.DarkOliveGreen);
            _label.Enabled = true;

            float autoFitX = _label.X;
            float autoFitY = _label.Y - _label.Height - 100f;

            _featuresAutoFitCombobox = factory.UI.GetComboBox("FeaturesAutoFitCombo", null, null, null, parent, false);
            _featuresAutoFitCombobox.TextBox.Text = nameof(AutoFit.TextShouldWrapAndLabelShouldFitHeight);
            _featuresAutoFitCombobox.X            = autoFitX;
            _featuresAutoFitCombobox.Y            = autoFitY;
            var autoFitList = _featuresAutoFitCombobox.DropDownPanelList;

            foreach (var autoFitOption in Enum.GetValues(typeof(AutoFit)))
            {
                autoFitList.Items.Add(new AGSStringItem {
                    Text = autoFitOption.ToString()
                });
            }

            autoFitList.OnSelectedItemChanged.Subscribe(args => _label.TextConfig.AutoFit = (AutoFit)Enum.Parse(typeof(AutoFit), args.Item.Text));
            animateText();
        }
예제 #10
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(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      = AGSBorders.SolidColor(GameViewColors.Border, 2f);
            _contentsPanel         = factory.UI.CreateScrollingPanel(_scrollingPanel);
            _treePanel             = factory.UI.GetPanel("GameDebugTreePanel", 1f, 1f, 0f, _contentsPanel.Height - _padding, _contentsPanel);
            _treePanel.Tint        = Colors.Transparent;
            _treePanel.RenderLayer = _layer;
            _treePanel.Pivot       = new PointF(0f, 1f);
            _treeView = _treePanel.AddComponent <ITreeViewComponent>();
            _treeView.OnNodeSelected.Subscribe(onTreeNodeSelected);
            parent.GetComponent <IScaleComponent>().PropertyChanged += (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                _contentsPanel.BaseSize = new SizeF(_contentsPanel.Width, parent.Height - _searchBox.Height - _gutterSize);
                _treePanel.Y            = _contentsPanel.Height - _padding;
                _searchBox.Y            = _parent.Height;
            };
        }
예제 #11
0
        public void Load(IGame game)
        {
            const float headerHeight = 50f;
            const float borderWidth  = 3f;

            _game = game;
            IGameFactory factory = game.Factory;

            _panel = factory.UI.GetPanel(_panelId, 800, 600,
                                         _layer.IndependentResolution.Value.Width / 2f, _layer.IndependentResolution.Value.Height / 2f);
            _panel.Pivot       = new PointF(0.5f, 0.5f);
            _panel.Visible     = false;
            _panel.Tint        = Colors.Black;
            _panel.Border      = AGSBorders.SolidColor(Colors.Green, borderWidth, hasRoundCorners: true);
            _panel.RenderLayer = _layer;
            _panel.AddComponent <IModalWindowComponent>();

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

            headerLabel.Tint        = Colors.Transparent;
            headerLabel.Border      = _panel.Border;
            headerLabel.RenderLayer = _layer;

            var xButton = factory.UI.GetButton("FeaturesCloseButton", (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, Colors.Yellow, Colors.White, 0.3f));
            xButton.MouseLeave.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Red, Colors.Transparent, 0f));
            xButton.OnMouseClick(hide, _game);

            var leftSidePanel = factory.UI.GetPanel("FeaturesLeftSidePanel", _panel.Width / 4f, _panel.Height - headerHeight - borderWidth, 0f, 0f, _panel);

            leftSidePanel.Tint        = Colors.Transparent;
            leftSidePanel.RenderLayer = _layer;
            leftSidePanel.Border      = _panel.Border;

            _rightSidePanel             = factory.UI.GetPanel("FeaturesRightSidePanel", _panel.Width - leftSidePanel.Width, leftSidePanel.Height, leftSidePanel.Width, 0f, _panel);
            _rightSidePanel.RenderLayer = _layer;
            _rightSidePanel.Tint        = Colors.Green.WithAlpha(50);

            var treePanel = factory.UI.GetPanel("FeaturesTreePanel", 1f, 1f, 0f, _panel.Height - headerHeight - 40f, leftSidePanel);

            treePanel.Tint        = Colors.Transparent;
            treePanel.RenderLayer = _layer;

            var tree = createFeaturesLabel("Features", null);

            var treeView = treePanel.AddComponent <ITreeViewComponent>();

            var roomsLabel = createFeaturesLabel("Rooms", tree);

            createFeaturesLabel("Viewports", roomsLabel, () => new FeaturesViewportsPanel(_game, _rightSidePanel));
            createFeaturesLabel("Moving Areas", roomsLabel, () => new FeaturesMoveAreaPanel(_game, _rightSidePanel, _scheme));

            var uiLabel = createFeaturesLabel("GUIs", tree);

            createFeaturesLabel("Labels", uiLabel, () => new FeaturesLabelsPanel(_game, _rightSidePanel));

            var objLabel = createFeaturesLabel("Objects", tree);

            createFeaturesLabel("Textures", objLabel, () => new FeaturesTexturesPanel(_game, _rightSidePanel));
            createFeaturesLabel("Tweens", objLabel, () => new FeaturesTweenPanel(_game, _rightSidePanel, _panel));

            treeView.Tree = tree;
            treeView.OnNodeSelected.Subscribe(onTreeNodeSelected);

            _game.Events.OnSavedGameLoad.Subscribe(findPanel);
        }
예제 #12
0
        public void Load()
        {
            const float  headerHeight = 50f;
            const float  borderWidth  = 3f;
            IGameFactory factory      = _game.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       = AGSBorders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true);
            _panel.RenderLayer  = _layer;
            _panel.ClickThrough = false;
            _game.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      = _panel.Border;
            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;

            _debugTree.Load(topPanel);
            _displayList.Load(topPanel);
            _inspector.Load(bottomPanel);
            _currentTab             = _debugTree;
            _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();
            };
        }