Beispiel #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);
        }
        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 #3
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 #4
0
        public void Load()
        {
            float center  = _editor.ToEditorResolution(_editor.Game.Settings.VirtualResolution.Width / 2f, 0f, null).x;
            var   factory = _editor.Editor.Factory;

            _parent             = factory.UI.GetPanel($"MethodWizardPanel_{_method.Name}", 600f, 400f, -1000f, 100f, addToUi: false);
            _parent.RenderLayer = _layer;
            _parent.Tint        = GameViewColors.Panel;
            _parent.Border      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 3f);
            var host = new AGSComponentHost(_editor.GameResolver);

            host.Init(_parent, typeof(AGSComponentHost));
            _modal = host.AddComponent <IModalWindowComponent>();
            _modal.GrabFocus();
            var box = _parent.AddComponent <IBoundingBoxWithChildrenComponent>();

            box.IncludeSelf = false;

            _parent.Visible = false;
            _editor.Editor.State.UI.Add(_parent);

            var inspectorParent = factory.UI.GetPanel("WizardInspectorParentPanel", WIDTH, 300f, MARGIN_HORIZONTAL, 0f, _parent);

            inspectorParent.Tint  = Colors.Transparent;
            inspectorParent.Pivot = (0f, 1f);

            _inspector = new InspectorPanel(_editor, _layer, new ActionManager(), "Wizard");
            _inspector.Load(inspectorParent);
            _inspector.Inspector.SortValues = false;

            var methodDescriptor = new MethodTypeDescriptor(_method, _hideProperties, _overrideDefaults);

            _inspector.Show(methodDescriptor);

            _addUiExternal?.Invoke(_parent);
            addButtons();

            var layout = _parent.AddComponent <IStackLayoutComponent>();

            layout.AbsoluteSpacing = -30f;
            layout.LayoutAfterCrop = true;

            box.OnBoundingBoxWithChildrenChanged.Subscribe(() =>
            {
                layout.StartLocation = box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL;
                _parent.BaseSize     = (box.BoundingBoxWithChildren.Width + MARGIN_HORIZONTAL * 2f, box.BoundingBoxWithChildren.Height + MARGIN_VERTICAL * 2f);
                _parent.X            = center - _parent.BaseSize.Width / 2f;
            });

            layout.StartLayout();
        }
Beispiel #5
0
        public async Task LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory factory = game.Factory;

            _panel = await factory.UI.GetPanelAsync(_panelId, "Gui/DialogBox/options.bmp", 160f, 100f);

            _panel.Pivot   = (0.5f, 0.5f);
            _panel.Visible = false;
            _panel.AddComponent <IModalWindowComponent>();

            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));

            ISlider volumeSlider = await factory.UI.GetSliderAsync("Volume Slider", _sliderFolder + "slider.bmp",
                                                                   _sliderFolder + "handle.bmp", 0.5f, 0f, 1f, _panel, loadConfig : loadConfig);

            volumeSlider.Position             = (120f, 10f);
            volumeSlider.HandleGraphics.Pivot = (0.5f, 0.5f);
            volumeSlider.OnValueChanged(onVolumeChanged, _game);

            ILabel volumeLabel = factory.UI.GetLabel("Volume Label", "Volume", 50f, 30f, 120f, 85f, _panel, _textConfig);

            volumeLabel.Pivot = (0.5f, 0f);

            ISlider speedSlider = await factory.UI.GetSliderAsync("Speed Slider", _sliderFolder + "slider.bmp",
                                                                  _sliderFolder + "handle.bmp", 100f, 1f, 200f, _panel, loadConfig : loadConfig);

            speedSlider.Position             = (180f, 10f);
            speedSlider.HandleGraphics.Pivot = (0.5f, 0.5f);
            speedSlider.OnValueChanged(onSpeedChanged, _game);

            ILabel speedLabel = factory.UI.GetLabel("Speed Label", "Speed", 50f, 30f, 180f, 85f, _panel, _textConfig);

            speedLabel.Pivot = (0.5f, 0f);

            _game.Events.OnSavedGameLoad.Subscribe(findPanel);

#if __IOS__
            const int top  = 85;
            const int step = -25;
#else
            const int top  = 95;
            const int step = -20;
#endif
            _buttonsPanel = factory.UI.GetPanel(_buttonsPanelId, (IImage)null, 15f, top, _panel);
            _buttonsPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            var layout = _buttonsPanel.AddComponent <IStackLayoutComponent>();
            layout.RelativeSpacing = 0f;
            layout.AbsoluteSpacing = step;
            layout.StartLayout();
            await loadButton("Resume", hide);
            await loadButton("Restart", restart);
            await loadButton("Load", load);
            await loadButton("Save", save);

#if !__IOS__ //IOS does not allow for a quit button in its guidelines
            await loadButton("Quit", quit);
#endif
        }
Beispiel #6
0
        public async Task LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory factory = game.Factory;

            _panel = await factory.UI.GetPanelAsync(_panelId, "../../Assets/Gui/DialogBox/options.bmp", 160f, 100f);

            _panel.Anchor  = new AGS.API.PointF(0.5f, 0.5f);
            _panel.Visible = false;
            _panel.AddComponent <IModalWindowComponent>();

            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new AGS.API.Point(0, 0));

            ISlider volumeSlider = await factory.UI.GetSliderAsync("Volume Slider", _sliderFolder + "slider.bmp", _sliderFolder + "handle.bmp", 0.5f, 0f, 1f,
                                                                   loadConfig : loadConfig);

            volumeSlider.X = 120f;
            volumeSlider.Y = 10f;
            volumeSlider.HandleGraphics.Anchor = new AGS.API.PointF(0.5f, 0.5f);
            volumeSlider.TreeNode.SetParent(_panel.TreeNode);
            volumeSlider.OnValueChanged(onVolumeChanged, _game);

            ILabel volumeLabel = factory.UI.GetLabel("Volume Label", "Volume", 50f, 30f, 120f, 85f, _textConfig);

            volumeLabel.Anchor = new AGS.API.PointF(0.5f, 0f);
            volumeLabel.TreeNode.SetParent(_panel.TreeNode);

            ISlider speedSlider = await factory.UI.GetSliderAsync("Speed Slider", _sliderFolder + "slider.bmp", _sliderFolder + "handle.bmp", 100f, 1f, 200f,
                                                                  loadConfig : loadConfig);

            speedSlider.X = 180f;
            speedSlider.Y = 10f;
            speedSlider.HandleGraphics.Anchor = new AGS.API.PointF(0.5f, 0.5f);
            speedSlider.TreeNode.SetParent(_panel.TreeNode);
            speedSlider.OnValueChanged(onSpeedChanged, _game);

            ILabel speedLabel = factory.UI.GetLabel("Speed Label", "Speed", 50f, 30f, 180f, 85f, _textConfig);

            speedLabel.Anchor = new AGS.API.PointF(0.5f, 0f);
            speedLabel.TreeNode.SetParent(_panel.TreeNode);

            _game.Events.OnSavedGameLoad.Subscribe((sender, args) => findPanel());

#if __IOS__
            const int top  = 85;
            const int step = 25;
#else
            const int top  = 95;
            const int step = 20;
#endif
            await loadButton("Resume", top, Hide);
            await loadButton("Restart", top - step, restart);
            await loadButton("Load", top - step * 2, load);
            await loadButton("Save", top - step * 3, save);

#if !__IOS__ //IOS does not allow for a quit button in its guidelines
            await loadButton("Quit", top - step * 4, quit);
#endif
        }
Beispiel #7
0
        public void Load(IPanel parent, IForm parentForm)
        {
            _parent = parent;
            var factory = _editor.Editor.Factory;

            _searchBox             = factory.UI.GetTextBox($"{_idPrefix}_InspectorSearchBox", 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;

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

            _scrollingPanel             = factory.UI.GetPanel($"{_idPrefix}_InspectorScrollingPanel", 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      = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            _contentsPanel = factory.UI.CreateScrollingPanel(_scrollingPanel);

            _treePanel             = factory.UI.GetPanel($"{_idPrefix}_InspectorPanel", 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(_editor.Editor.Factory, _editor.Game.Settings, _editor.Editor.Settings, _actions, _editor.Project.Model, _editor, parentForm);
            _treePanel.AddComponent <IInspectorComponent>(Inspector);
            Inspector.ScrollingContainer = _contentsPanel;

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

            _parent.Bind <IScaleComponent>(c => c.PropertyChanged += onParentPanelScaleChanged,
                                           c => c.PropertyChanged -= onParentPanelScaleChanged);
        }
Beispiel #8
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 #9
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);
            _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;
            };
        }
Beispiel #10
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 #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }