예제 #1
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(Colors.Green, 2f);
            _searchBox.Tint        = Colors.Transparent;
            _searchBox.Pivot       = new PointF(0f, 1f);
            _searchBox.GetComponent <ITextComponent>().PropertyChanged += onSearchPropertyChanged;

            var height = parent.Height - _searchBox.Height;

            _scrollingPanel             = factory.UI.GetPanel("GameDebugInspectorScrollingPanel", parent.Width, height, 0f, height, parent);
            _scrollingPanel.RenderLayer = _layer;
            _scrollingPanel.Pivot       = new PointF(0f, 1f);
            _scrollingPanel.Tint        = Colors.Transparent;
            _scrollingPanel.Border      = AGSBorders.SolidColor(Colors.Green, 2f);

            _panel             = factory.UI.GetPanel("GameDebugInspectorPanel", parent.Width, _padding, 0f, height - _padding, _scrollingPanel);
            _panel.Tint        = Colors.Transparent;
            _panel.RenderLayer = _layer;
            var treeView = _panel.AddComponent <ITreeViewComponent>();

            treeView.SkipRenderingRoot = true;
            treeView.NodeViewProvider  = new InspectorTreeNodeProvider(treeView.NodeViewProvider, _game.Factory);

            Inspector = new AGSInspector(_game.Factory, _game.Settings);
            _panel.AddComponent <IInspectorComponent>(Inspector);
            factory.UI.CreateScrollingPanel(_scrollingPanel);
            _parent.Bind <IScaleComponent>(c => c.PropertyChanged += onParentPanelScaleChanged,
                                           c => c.PropertyChanged -= onParentPanelScaleChanged);
        }
예제 #2
0
 private ButtonAnimation getAnimation(IAnimationComponent container, ButtonAnimation animation)
 {
     if (animation.Border == null || container == null || container.Border == null) return animation;
     ButtonAnimation newAnimation = new ButtonAnimation(AGSBorders.Multiple(container.Border, animation.Border),
                                                        animation.TextConfig, animation.Tint);
     newAnimation.Animation = animation.Animation;
     return newAnimation;
 }
예제 #3
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(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;
            };
        }
예제 #4
0
        private (ButtonAnimation idle, ButtonAnimation hovered, ButtonAnimation pushed) getArrowButtonAnimations(ArrowDirection direction, float lineWidth)
        {
            var whiteArrow = AGSBorders.Multiple(AGSBorders.SolidColor(Colors.WhiteSmoke, lineWidth),
                                                 _graphics.Icons.GetArrowIcon(direction, Colors.WhiteSmoke));
            var yellowArrow = AGSBorders.Multiple(AGSBorders.SolidColor(Colors.Yellow, lineWidth),
                                                  _graphics.Icons.GetArrowIcon(direction, Colors.Yellow));

            return(new ButtonAnimation(whiteArrow, null, Colors.Transparent),
                   new ButtonAnimation(yellowArrow, null, Colors.Transparent),
                   new ButtonAnimation(yellowArrow, null, Colors.White.WithAlpha(100)));
        }
예제 #5
0
        public IBorderStyle ToItem(AGSSerializationContext context)
        {
            if (!BorderSupported)
            {
                return(null);
            }
            var          color     = Color.FromHexa(ColorValue);
            var          lineWidth = LineWidth;
            IBorderStyle style     = AGSBorders.SolidColor(context.GLUtils, color, lineWidth);

            return(style);
        }
예제 #6
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;
            };
        }
예제 #7
0
        private static ISayConfig getDefaultConfig()
        {
            AGSSayConfig config = new AGSSayConfig();

            config.Border = AGSBorders.Gradient(AGSGame.Resolver.Container.Resolve <IGLUtils>(), new FourCorners <Color>(Colors.DarkOliveGreen,
                                                                                                                         Colors.LightGreen, Colors.LightGreen, Colors.DarkOliveGreen), 3f, true);
            config.TextConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight
                                                  , paddingLeft: 8, paddingTop: 8, paddingBottom: 8, paddingRight: 8);
            config.LabelSize = new SizeF(AGSGame.Game.Settings.VirtualResolution.Width * 3 / 4f,
                                         AGSGame.Game.Settings.VirtualResolution.Height * 3 / 4f);
            config.BackgroundColor = Colors.Black;
            return(config);
        }
예제 #8
0
 public AGSGraySkin(IGraphicsFactory factory, IGLUtils glUtils)
 {
     _skin = new AGSColoredSkin(factory)
     {
         ButtonIdleBackColor          = Colors.DimGray,
         ButtonHoverBackColor         = Colors.LightGray,
         ButtonPushedBackColor        = Colors.LightYellow,
         ButtonBorderStyle            = AGSBorders.SolidColor(glUtils, Colors.Black, 1f),
         TextBoxBackColor             = Colors.DimGray,
         TextBoxBorderStyle           = AGSBorders.SolidColor(glUtils, Colors.Black, 1f),
         CheckboxCheckedColor         = Colors.SlateGray,
         CheckboxNotCheckedColor      = Colors.DimGray,
         CheckboxHoverCheckedColor    = Colors.LightGray,
         CheckboxHoverNotCheckedColor = Colors.LightGray,
         CheckboxBorderStyle          = AGSBorders.SolidColor(glUtils, Colors.Black, 1f),
         DialogBoxColor  = Colors.DarkGray,
         DialogBoxBorder = AGSBorders.SolidColor(glUtils, Colors.Black, 2f)
     };
 }
예제 #9
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;

            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 =>
            {
                property.Prop.SetValue(property.Object, Color.FromHexa(_namedColors[args.Item.Text]));
            });
        }
예제 #10
0
        public AGSBlueSkin(IGraphicsFactory factory, IGLUtils glUtils)
        {
            var buttonBorder = AGSBorders.SolidColor(glUtils, Colors.DarkBlue, 1f);

            _skin = new AGSColoredSkin(factory)
            {
                ButtonIdleAnimation              = new ButtonAnimation(buttonBorder, null, Colors.CornflowerBlue),
                ButtonHoverAnimation             = new ButtonAnimation(buttonBorder, null, Colors.Blue),
                ButtonPushedAnimation            = new ButtonAnimation(buttonBorder, null, Colors.DarkSlateBlue),
                TextBoxBackColor                 = Colors.CornflowerBlue,
                TextBoxBorderStyle               = AGSBorders.SolidColor(glUtils, Colors.DarkBlue, 1f),
                CheckboxCheckedAnimation         = new ButtonAnimation(buttonBorder, null, Colors.DarkSlateBlue),
                CheckboxNotCheckedAnimation      = new ButtonAnimation(buttonBorder, null, Colors.CornflowerBlue),
                CheckboxHoverCheckedAnimation    = new ButtonAnimation(buttonBorder, null, Colors.Blue),
                CheckboxHoverNotCheckedAnimation = new ButtonAnimation(buttonBorder, null, Colors.Blue),
                DialogBoxColor  = Colors.DarkSlateBlue,
                DialogBoxBorder = AGSBorders.SolidColor(glUtils, Colors.DarkBlue, 2f)
            };
        }
예제 #11
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;
        }
예제 #12
0
        private static ISayConfig getDefaultConfig()
        {
            AGSSayConfig config = new AGSSayConfig();

            config.Border = AGSBorders.Gradient(AGSGame.Resolver.Container.Resolve <IGLUtils>(), new FourCorners <Color>(Colors.DarkOliveGreen,
                                                                                                                         Colors.LightGreen, Colors.LightGreen, Colors.DarkOliveGreen), 3f, true);
            config.TextConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight, alignment: Alignment.TopCenter
                                                  , paddingLeft: 30, paddingTop: 30, paddingBottom: 30, paddingRight: 30);
            var screenWidth  = AGSGame.Game.Settings.VirtualResolution.Width;
            var screenHeight = AGSGame.Game.Settings.VirtualResolution.Height;

            if (RenderLayer.IndependentResolution != null)
            {
                screenWidth  = RenderLayer.IndependentResolution.Value.Width;
                screenHeight = RenderLayer.IndependentResolution.Value.Height;
            }
            config.LabelSize       = new SizeF(screenWidth * 3 / 4f, screenHeight * 3 / 4f);
            config.BackgroundColor = Colors.Black;
            return(config);
        }
예제 #13
0
        public static async Task <bool> YesNoAsync(string text, string yes = "Yes", string no = "No")
        {
            var        factory = AGSGame.Game.Factory;
            IAnimation idle    = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics);

            idle.Sprite.Tint = Colors.Black;
            IAnimation hovered = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics);

            hovered.Sprite.Tint = Colors.Yellow;
            IAnimation pushed = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics);

            pushed.Sprite.Tint = Colors.DarkSlateBlue;
            var border = AGSBorders.Gradient(AGSGame.Resolver.Container.Resolve <IGLUtils>(), new FourCorners <Color>(Colors.DarkOliveGreen,
                                                                                                                      Colors.LightGreen, Colors.LightGreen, Colors.DarkOliveGreen), 3f, true);

            IButton yesButton = factory.UI.GetButton("Dialog Yes Button", idle, hovered, pushed, 0f, 0f, null, yes, ButtonConfig, false);
            IButton noButton  = factory.UI.GetButton("Dialog No Button", idle, hovered, pushed, 0f, 0f, null, no, ButtonConfig, false);

            yesButton.Border = border;
            noButton.Border  = border;
            return(await DisplayAsync(text, yesButton, noButton) == yesButton);
        }
예제 #14
0
        private void selectObject(ITreeStringNode node)
        {
            var obj = node.Properties.Entities.GetValue(Fields.Entity);

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

            if (animation != null)
            {
                _lastSelectedObject = animation;
                IBorderStyle border = null;
                border            = animation.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)
                {
                    animation.Border = hoverBorder;
                }
                else
                {
                    animation.Border = AGSBorders.Multiple(border, hoverBorder);
                }
            }
            if (visibleComponent != null)
            {
                _lastMaskVisible         = visibleComponent.Visible;
                _lastSelectedMaskVisible = visibleComponent;
                visibleComponent.Visible = true;
            }
            if (image != null && image.Opacity == 0)
            {
                _lastOpacity           = image.Opacity;
                _lastSelectedMaskImage = image;
                image.Opacity          = 100;
            }
        }
예제 #15
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;
            };
        }
예제 #16
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;
            };
        }
예제 #17
0
        public IPanel CreateScrollingPanel(IPanel panel, float gutterSize = 15f)
        {
            var contentsPanel = GetPanel($"{panel.ID}_Contents", panel.Width, panel.Height, 0f, 0f, panel);

            contentsPanel.Opacity = 0;

            contentsPanel.RenderLayer = panel.RenderLayer;

            contentsPanel.AddComponent <ICropChildrenComponent>();
            var box = contentsPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            IScrollingComponent scroll = contentsPanel.AddComponent <IScrollingComponent>();

            var horizSlider = GetSlider($"{panel.ID}_HorizontalSlider", null, null, 0f, 0f, 0f, panel);

            horizSlider.HandleGraphics.Pivot  = new PointF(0f, 0f);
            horizSlider.Direction             = SliderDirection.LeftToRight;
            horizSlider.Graphics.Pivot        = new PointF(0f, 0f);
            horizSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            horizSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            HoverEffect.Add(horizSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(horizSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            var verSlider = GetSlider($"{panel.ID}_VerticalSlider", null, null, 0f, 0f, 0f, panel);

            verSlider.HandleGraphics.Pivot  = new PointF(0f, 0f);
            verSlider.Direction             = SliderDirection.TopToBottom;
            verSlider.Graphics.Pivot        = new PointF(0f, 0f);
            verSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            verSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            verSlider.MaxHandleOffset       = gutterSize;
            HoverEffect.Add(verSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(verSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            (var idle, var hovered, var pushed) = getArrowButtonAnimations(ArrowDirection.Up, 1f);
            var upButton = GetButton($"{panel.ID}_ScrollUpButton", idle, hovered, pushed, 0f, panel.Height - gutterSize * 2f, verSlider, width: gutterSize, height: gutterSize);

            upButton.Pivot = new PointF(0f, 1f);
            upButton.MouseClicked.Subscribe(args => verSlider.Value--);

            (idle, hovered, pushed) = getArrowButtonAnimations(ArrowDirection.Down, 1f);
            var downButton = GetButton($"{panel.ID}_ScrollDownButton", idle, hovered, pushed, 0f, 0f, verSlider, width: gutterSize, height: gutterSize);

            downButton.Pivot = new PointF(0f, 1f);
            downButton.MouseClicked.Subscribe(args => verSlider.Value++);

            (idle, hovered, pushed) = getArrowButtonAnimations(ArrowDirection.Left, 1f);
            var leftButton = GetButton($"{panel.ID}_ScrollUpLeft", idle, hovered, pushed, 0f, 0f, horizSlider, width: gutterSize, height: gutterSize);

            leftButton.Pivot = new PointF(1f, 0f);
            leftButton.MouseClicked.Subscribe(args => horizSlider.Value--);

            (idle, hovered, pushed) = getArrowButtonAnimations(ArrowDirection.Right, 1f);
            var rightButton = GetButton($"{panel.ID}_ScrollDownRight", idle, hovered, pushed, panel.Width - gutterSize * 2f, 0f, horizSlider, width: gutterSize, height: gutterSize);

            rightButton.Pivot = new PointF(0f, 0f);
            rightButton.MouseClicked.Subscribe(args => horizSlider.Value++);

            PropertyChangedEventHandler resize = (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Width) && args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                panel.BaseSize                   = new SizeF(contentsPanel.Width + gutterSize, contentsPanel.Height + gutterSize);
                horizSlider.Graphics.Image       = new EmptyImage(panel.Width - gutterSize * 2f, gutterSize);
                horizSlider.HandleGraphics.Image = new EmptyImage(gutterSize, gutterSize);
                verSlider.Graphics.Image         = new EmptyImage(gutterSize, panel.Height - gutterSize * 3f);
                verSlider.HandleGraphics.Image   = new EmptyImage(gutterSize, gutterSize);
                horizSlider.X   = -panel.Width * panel.Pivot.X + gutterSize;
                verSlider.X     = panel.Width - gutterSize;
                verSlider.Y     = gutterSize * 2f;
                upButton.Y      = panel.Height - gutterSize * 2f;
                rightButton.X   = panel.Width - gutterSize * 2f;
                contentsPanel.Y = gutterSize;
            };

            resize(this, new PropertyChangedEventArgs(nameof(IScaleComponent.Width)));
            scroll.HorizontalScrollBar = horizSlider;
            scroll.VerticalScrollBar   = verSlider;

            contentsPanel.Bind <IScaleComponent>(c => c.PropertyChanged += resize, c => c.PropertyChanged -= resize);

            return(contentsPanel);
        }
예제 #18
0
        public void CreateScrollingPanel(IPanel panel)
        {
            panel.AddComponent <ICropChildrenComponent>();
            var box = panel.AddComponent <IBoundingBoxWithChildrenComponent>();
            IScrollingComponent scroll = panel.AddComponent <IScrollingComponent>();

            var horizSlider = GetSlider($"{panel.ID}_HorizontalSlider", null, null, 0f, 0f, 0f, panel);

            horizSlider.HandleGraphics.Pivot  = new PointF(0f, 0.5f);
            horizSlider.Direction             = SliderDirection.LeftToRight;
            horizSlider.Graphics.Pivot        = new PointF(0f, 0.5f);
            horizSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            horizSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            HoverEffect.Add(horizSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(horizSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            var verSlider = GetSlider($"{panel.ID}_VerticalSlider", null, null, 0f, 0f, 0f, panel);

            verSlider.HandleGraphics.Pivot  = new PointF(0.5f, 0f);
            verSlider.Direction             = SliderDirection.TopToBottom;
            verSlider.Graphics.Pivot        = new PointF(0.5f, 0f);
            verSlider.Graphics.Border       = AGSBorders.SolidColor(Colors.DarkGray, 0.5f, true);
            verSlider.HandleGraphics.Border = AGSBorders.SolidColor(Colors.White, 0.5f, true);
            HoverEffect.Add(verSlider.Graphics, Colors.Gray, Colors.LightGray);
            HoverEffect.Add(verSlider.HandleGraphics, Colors.DarkGray, Colors.WhiteSmoke);

            box.EntitiesToSkip.AddRange(new List <string> {
                horizSlider.ID, horizSlider.HandleGraphics.ID, horizSlider.Graphics.ID,
                verSlider.ID, verSlider.HandleGraphics.ID, verSlider.Graphics.ID
            });

            PropertyChangedEventHandler resize = (_, args) =>
            {
                if (args.PropertyName != nameof(IScaleComponent.Width) && args.PropertyName != nameof(IScaleComponent.Height))
                {
                    return;
                }
                const float widthFactor  = 25f;
                const float heightFactor = 25f;
                float       widthUnit    = panel.Width / widthFactor;
                float       heightUnit   = panel.Height / heightFactor;
                horizSlider.Graphics.Image       = new EmptyImage(panel.Width - widthUnit * 2f, heightUnit / 2f);
                horizSlider.HandleGraphics.Image = new EmptyImage(widthUnit, heightUnit);
                verSlider.Graphics.Image         = new EmptyImage(widthUnit / 2f, panel.Height - heightUnit * 4f);
                verSlider.HandleGraphics.Image   = new EmptyImage(widthUnit, heightUnit);
                horizSlider.X = -panel.Width * panel.Pivot.X + widthUnit;
                horizSlider.Y = heightUnit;
                verSlider.X   = panel.Width - widthUnit;
                verSlider.Y   = heightUnit * 2f;
            };

            panel.Bind <IStackLayoutComponent>(
                c => c.EntitiesToIgnore.AddRange(new List <string> {
                verSlider.ID, horizSlider.ID
            }), _ => {});

            resize(this, new PropertyChangedEventArgs(nameof(IScaleComponent.Width)));
            scroll.HorizontalScrollBar = horizSlider;
            scroll.VerticalScrollBar   = verSlider;

            panel.Bind <IScaleComponent>(c => c.PropertyChanged += resize, c => c.PropertyChanged -= resize);
        }
예제 #19
0
        public IComboBox GetComboBox(string id, IButton dropDownButton        = null, ITextBox textBox = null,
                                     Func <string, IButton> itemButtonFactory = null, IObject parent   = null, bool addToUi = true,
                                     float defaultWidth = 500f, float defaultHeight = 40f, string watermark = "")
        {
            TypedParameter idParam  = new TypedParameter(typeof(string), id);
            IComboBox      comboBox = _resolver.Container.Resolve <IComboBox>(idParam);

            if (parent != null)
            {
                comboBox.RenderLayer = parent.RenderLayer;
            }
            defaultHeight = dropDownButton?.Height ?? textBox?.Height ?? defaultHeight;
            float itemWidth = textBox?.Width ?? defaultWidth;

            if (textBox == null)
            {
                textBox = GetTextBox(id + "_TextBox", 0f, 0f, comboBox, watermark, new AGSTextConfig(alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel),
                                     false, itemWidth, defaultHeight);
                textBox.Border = AGSBorders.SolidColor(Colors.WhiteSmoke, 3f);
                textBox.Tint   = Colors.Transparent;
            }
            else
            {
                setParent(textBox, comboBox);
            }
            textBox.RenderLayer = comboBox.RenderLayer;
            textBox.Enabled     = false;

            if (dropDownButton == null)
            {
                (var idle, var hovered, var pushed) = getArrowButtonAnimations(ArrowDirection.Down, 3f);
                dropDownButton        = GetButton(id + "_DropDownButton", idle, hovered, pushed, 0f, 0f, comboBox, "", null, false, 30f, defaultHeight);
                dropDownButton.Border = idle.Border;
            }
            else
            {
                setParent(dropDownButton, comboBox);
            }
            dropDownButton.RenderLayer = comboBox.RenderLayer;
            dropDownButton.Z           = textBox.Z - 1;
            dropDownButton.SkinTags.Add(AGSSkin.DropDownButtonTag);
            dropDownButton.Skin?.Apply(dropDownButton);

            var dropDownPanelLayer = new AGSRenderLayer(comboBox.RenderLayer.Z - 1, comboBox.RenderLayer.ParallaxSpeed, comboBox.RenderLayer.IndependentResolution); //Making sure that the drop-down layer is rendered before the combobox layer, so that it will appear in front of other ui elements that may be below.

            if (itemButtonFactory == null)
            {
                var yellowBrush = _graphics.Brushes.LoadSolidBrush(Colors.Yellow);
                var whiteBrush  = _graphics.Brushes.LoadSolidBrush(Colors.White);
                itemButtonFactory = text =>
                {
                    var button = GetButton(id + "_" + 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: itemWidth, height: defaultHeight);
                    button.Pivot       = new PointF(0f, 1f);
                    button.RenderLayer = dropDownPanelLayer;
                    return(button);
                };
            }

            var dropDownPanel = GetPanel(id + "_DropDownPanel", new EmptyImage(1f, 1f), 0f, 0f, null, false);

            dropDownPanel.Visible = false;
            _gameState.UI.Add(dropDownPanel);
            dropDownPanel.Border      = AGSBorders.SolidColor(Colors.White, 3f);
            dropDownPanel.Tint        = Colors.Black;
            dropDownPanel.RenderLayer = dropDownPanelLayer;
            _gameState.FocusedUI.CannotLoseFocus.Add(dropDownPanel.ID);
            var contentsPanel = CreateScrollingPanel(dropDownPanel);
            var listBox       = contentsPanel.AddComponent <IListboxComponent>();

            listBox.ItemButtonFactory = itemButtonFactory;
            listBox.MaxHeight         = 300f;

            Action placePanel = () =>
            {
                var box = textBox.GetBoundingBoxes(_gameState.Viewport)?.ViewportBox;
                if (box == null)
                {
                    return;
                }
                dropDownPanel.Location = new AGSLocation(box.Value.BottomLeft.X, box.Value.BottomLeft.Y);
            };

            textBox.OnBoundingBoxesChanged.Subscribe(placePanel);
            placePanel();

            contentsPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            contentsPanel.AddComponent <IStackLayoutComponent>();

            comboBox.DropDownButton = dropDownButton;
            comboBox.TextBox        = textBox;
            comboBox.DropDownPanel  = contentsPanel;

            setParent(comboBox, parent);

            if (addToUi)
            {
                _gameState.UI.Add(textBox);
                _gameState.UI.Add(dropDownButton);
                _gameState.UI.Add(comboBox);
            }

            return(comboBox);
        }
예제 #20
0
        public ICheckBox GetCheckBox(string id, ButtonAnimation notChecked, ButtonAnimation notCheckedHovered, ButtonAnimation @checked, ButtonAnimation checkedHovered,
                                     float x, float y, IObject parent = null, string text = "", ITextConfig config = null, bool addToUi = true, float width = -1F, float height = -1F, bool isCheckButton = false)
        {
            bool pixelArtButton = notChecked?.Animation != null && notChecked.Animation.Frames.Count > 0;

            if (width == -1f && pixelArtButton)
            {
                width = notChecked.Animation.Frames[0].Sprite.Width;
            }
            if (height == -1f && pixelArtButton)
            {
                height = notChecked.Animation.Frames[0].Sprite.Height;
            }

            var                    idleColor         = Colors.White;
            var                    hoverColor        = Colors.Yellow;
            const float            lineWidth         = 1f;
            const float            padding           = 300f;
            Func <ButtonAnimation> notCheckedDefault = () => new ButtonAnimation(AGSBorders.SolidColor(idleColor, lineWidth), null, Colors.Black);
            Func <ButtonAnimation> checkedDefault    = () =>
            {
                var checkIcon = _graphics.Icons.GetXIcon(color: idleColor, padding: padding);
                return(new ButtonAnimation(AGSBorders.Multiple(AGSBorders.SolidColor(idleColor, lineWidth), checkIcon), null, Colors.Black));
            };
            Func <ButtonAnimation> hoverNotCheckedDefault = () => new ButtonAnimation(AGSBorders.SolidColor(hoverColor, lineWidth), null, Colors.Black);
            Func <ButtonAnimation> hoverCheckedDefault    = () =>
            {
                var checkHoverIcon = _graphics.Icons.GetXIcon(color: hoverColor, padding: padding);
                return(new ButtonAnimation(AGSBorders.Multiple(AGSBorders.SolidColor(hoverColor, lineWidth), checkHoverIcon), null, Colors.Black));
            };

            notChecked        = validateAnimation(id, notChecked, notCheckedDefault, width, height);
            notCheckedHovered = validateAnimation(id, notCheckedHovered, hoverNotCheckedDefault, width, height);
            @checked          = validateAnimation(id, @checked, checkedDefault, width, height);
            checkedHovered    = validateAnimation(id, checkedHovered, hoverCheckedDefault, width, height);
            TypedParameter idParam  = new TypedParameter(typeof(string), id);
            ICheckBox      checkbox = _resolver.Container.Resolve <ICheckBox>(idParam);

            if (!string.IsNullOrEmpty(text))
            {
                checkbox.TextLabel = GetLabel($"{id}_Label", text, 100f, 20f, x + width + 5f, y, parent, config, addToUi);
            }
            if (!isCheckButton)
            {
                checkbox.SkinTags.Add(AGSSkin.CheckBoxTag);
            }
            if (notChecked != null)
            {
                checkbox.NotCheckedAnimation = notChecked;
            }
            if (notCheckedHovered != null)
            {
                checkbox.HoverNotCheckedAnimation = notCheckedHovered;
            }
            if (@checked != null)
            {
                checkbox.CheckedAnimation = @checked;
            }
            if (checkedHovered != null)
            {
                checkbox.HoverCheckedAnimation = checkedHovered;
            }

            checkbox.Tint = pixelArtButton ? Colors.White : Colors.Transparent;
            checkbox.X    = x;
            checkbox.Y    = y;
            setParent(checkbox, parent);

            checkbox.Skin?.Apply(checkbox);
            checkbox.NotCheckedAnimation.StartAnimation(checkbox, checkbox.TextLabel, checkbox, checkbox);

            if (addToUi)
            {
                _gameState.UI.Add(checkbox);
            }

            return(checkbox);
        }
예제 #21
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();
            };
        }