Пример #1
0
 public AGSStringItem(IFont font = null)
 {
     font            = font ?? AGSGame.Game.Settings.Defaults.SpeechFont;
     IdleTextConfig  = new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText, font: font);
     HoverTextConfig = AGSTextConfig.ChangeColor(IdleTextConfig, Colors.Yellow, Colors.Black, 0f);
     Properties      = new AGSCustomProperties();
 }
Пример #2
0
        public void BeforeDisplayingNode(ITreeStringNode item, ITreeNodeView nodeView,
                                         bool isCollapsed, bool isHovered, bool isSelected)
        {
            var textConfig = isHovered ? item.HoverTextConfig : item.IdleTextConfig;
            var label      = nodeView.TreeItem as ITextComponent;

            if (label != null)
            {
                label.TextConfig            = textConfig;
                label.Text                  = item.Text;
                label.TextBackgroundVisible = isSelected;
            }
            nodeView.TreeItem.Tint = isSelected ? Colors.DarkSlateBlue : Colors.Transparent;
            var expandButton = nodeView.ExpandButton;

            if (expandButton != null)
            {
                var expandTextConfig = textConfig;
                if (item.TreeNode.ChildrenCount == 0)
                {
                    expandTextConfig = AGSTextConfig.ChangeColor(textConfig, textConfig.Brush.Color.WithAlpha(0), textConfig.OutlineBrush.Color, textConfig.OutlineWidth);
                }
                expandButton.TextConfig = expandTextConfig;
                expandButton.Text       = isCollapsed ? "+" : "-";
                expandButton.Enabled    = expandButton.TextVisible;
            }
        }
Пример #3
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,
                                         5f, _layer.IndependentResolution.Value.Height / 2f);
            _panel.Pivot        = new PointF(0f, 0.5f);
            _panel.Visible      = false;
            _panel.Tint         = Colors.Black.WithAlpha(150);
            _panel.Border       = AGSBorders.SolidColor(Colors.Green, 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, Colors.Yellow, Colors.White, 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        = Colors.Black;
            _panesButton.MouseEnter.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Yellow, Colors.White, 0.3f));
            _panesButton.MouseLeave.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.White, 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();
            };
        }
Пример #4
0
 public AGSStringItem()
 {
     IdleTextConfig  = new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText, font: AGSGameSettings.DefaultSpeechFont);
     HoverTextConfig = AGSTextConfig.ChangeColor(IdleTextConfig, Colors.Yellow, Colors.Black, 1f);
     Properties      = new AGSCustomProperties();
 }