Example #1
0
        public static void Init(IFontFactory fontLoader)
        {
            const string path = "Fonts/Font Awesome 5 Free-Solid-900.otf";

            Font       = fontLoader.LoadFontFromPath(path, 14f, FontStyle.Regular);
            IconConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.NoFitting, alignment: Alignment.MiddleCenter,
                                                  paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            ButtonConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                    paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            var tinyFont = fontLoader.LoadFontFromPath(path, 8f, FontStyle.Regular);

            TinyButtonConfig = fontLoader.GetTextConfig(font: tinyFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                        paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f);

            TinyButtonConfigHovered = AGSTextConfig.ChangeColor(TinyButtonConfig, Colors.Black, Colors.White, 0f);

            var largeFont = fontLoader.LoadFontFromPath(path, 56f, FontStyle.Regular);

            LargeIconConfig = fontLoader.GetTextConfig(font: largeFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                                       paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f);

            LargeIconConfigHovered = AGSTextConfig.ChangeColor(LargeIconConfig, GameViewColors.HoveredText, Colors.White, 0f);
        }
        public static ICheckBox CreateRadioButton(IObject parent, IGameFactory factory, string id, float x, float y, string text)
        {
            var checkbox = createCheckbox(parent, factory, id, x, y, text, FontIcons.RadioUnchecked, FontIcons.RadioChecked);
            var config   = AGSTextConfig.Clone(checkbox.TextLabel.TextConfig);

            config.Alignment = Alignment.BottomLeft;
            checkbox.TextLabel.TextConfig = config;
            return(checkbox);
        }
Example #3
0
        public async Task <ICharacter> LoadAsync(IGame game)
        {
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            var footstep = await game.Factory.Sound.LoadAudioClipAsync("Sounds/151238__owlstorm__hard-female-footstep-2.wav");

            ISoundEmitter emitter = new AGSSoundEmitter(game);

            emitter.AudioClip = footstep;

            IOutfit outfit = await game.Factory.Outfit.LoadOutfitFromFoldersAsync(_baseFolder, walkLeftFolder : "Walk/left",
                                                                                  walkDownFolder : "Walk/front", idleLeftFolder : "Idle/left", idleDownFolder : "Idle/front",
                                                                                  speakLeftFolder : "Talk", loadConfig : loadConfig);

            _character = game.Factory.Object.GetCharacter("Cris", outfit).Remember(game, c => _character = c);
            _character.SpeechConfig.TextConfig = AGSTextConfig.ChangeColor(_character.SpeechConfig.TextConfig, Colors.OrangeRed, Colors.Black, 1f);
            var approach = _character.AddComponent <IApproachComponent>();

            approach.ApproachStyle.ApproachWhenVerb["Talk"] = ApproachHotspots.WalkIfHaveWalkPoint;
            emitter.Object = _character;

            _character.AddComponent <ISaturationEffectComponent>();

            var movement = _character.AddComponent <KeyboardMovement>();

            movement.AddArrows();
            movement.AddWASD();

            //Uncomment for portrait

            /*
             * var portrait = game.Factory.Object.GetObject("CrisPortrait");
             * portrait.StartAnimation(game.Factory.Graphics.LoadAnimationFromFolder(_baseFolder + "Talk"));
             * portrait.Border = game.Factory.Graphics.Borders.SolidColor(Colors.AliceBlue, 3f, true);
             * portrait.Visible = false;
             * portrait.RenderLayer = AGSLayers.Speech;
             * portrait.IgnoreViewport = true;
             * portrait.IgnoreScalingArea = true;
             * game.State.UI.Add(portrait);
             * _character.SpeechConfig.PortraitConfig = new AGSPortraitConfig { Portrait = portrait, Positioning = PortraitPositioning.Alternating };
             */

            var speakAnimation = _character.Outfit[AGSOutfit.Speak];

            Characters.RandomAnimationDelay(speakAnimation.Left);
            Characters.RandomAnimationDelay(speakAnimation.Right);
            emitter.Assign(_character.Outfit[AGSOutfit.Walk], 1, 5);

            _character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down);
            _character.DisplayName    = "Cris";
            _character.IsPixelPerfect = true;

            Characters.Cris = _character;
            return(_character);
        }
Example #4
0
        private void addButtons()
        {
            var factory       = _editor.Editor.Factory;
            var font          = _editor.Editor.Settings.Defaults.TextFont;
            var border        = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            var idleConfig    = new AGSTextConfig(GameViewColors.TextBrush, alignment: Alignment.MiddleCenter, font: font);
            var hoveredConfig = new AGSTextConfig(GameViewColors.HoveredTextBrush, alignment: Alignment.MiddleCenter, font: font);
            var idle          = new ButtonAnimation(border, idleConfig, GameViewColors.Button);
            var hovered       = new ButtonAnimation(border, hoveredConfig, GameViewColors.Button);
            var pushed        = new ButtonAnimation(factory.Graphics.Borders.SolidColor(Colors.Black, 2f), idleConfig, GameViewColors.Button);

            var buttonsPanel = factory.UI.GetPanel("MethodWizardButtonsPanel", WIDTH, 20f, MARGIN_HORIZONTAL, 50f, _parent);

            buttonsPanel.Tint = Colors.Transparent;

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

            layout.Direction       = LayoutDirection.Horizontal;
            layout.CenterLayout    = true;
            layout.RelativeSpacing = 1f;
            layout.AbsoluteSpacing = 40f;
            layout.StartLocation   = WIDTH / 2f;

            const float buttonWidth = 80f;
            var         okButton    = factory.UI.GetButton("MethodWizardOkButton", idle, hovered, pushed, 0f, 0f, buttonsPanel, "OK", width: buttonWidth, height: 20f);

            okButton.MouseClicked.Subscribe(async() =>
            {
                Dictionary <string, object> map = new Dictionary <string, object>();
                foreach (var param in _inspector.Inspector.Properties.SelectMany(p => p.Value))
                {
                    map[param.Name] = param.GetValue();
                }
                if (!await _validate(map))
                {
                    return;
                }

                _modal?.LoseFocus();
                _parent.DestroyWithChildren(_editor.Editor.State);
                _taskCompletionSource.TrySetResult(map);
            });

            var cancelButton = factory.UI.GetButton("MethodWizardCancelButton", idle, hovered, pushed, 0f, 0f, buttonsPanel, "Cancel", width: buttonWidth, height: 20f);

            cancelButton.MouseClicked.Subscribe(() =>
            {
                _modal?.LoseFocus();
                _parent.DestroyWithChildren(_editor.Editor.State);
                _taskCompletionSource.TrySetResult(null);
            });

            layout.StartLayout();
        }
Example #5
0
        public static void Init(IFontLoader fontLoader)
        {
            const string path = "Fonts/Font Awesome 5 Free-Solid-900.otf";

            var font = fontLoader.LoadFontFromPath(path, 14f, FontStyle.Regular);

            IconConfig = new AGSTextConfig(font: font, autoFit: AutoFit.NoFitting, alignment: Alignment.MiddleCenter,
                                           paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);

            ButtonConfig = new AGSTextConfig(font: font, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter,
                                             paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f);
        }
Example #6
0
            public RunningTween(string name, Tween tween, IGame game, IObject parent)
            {
                _game  = game;
                _tween = tween;
                var factory = game.Factory.UI;
                var borders = game.Factory.Graphics.Borders;
                var tweenId = ++id;

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

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

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

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

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

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

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

                game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute);
            }
Example #7
0
        public async Task <ICharacter> LoadAsync(IGame game)
        {
            _game = game;
            IGameFactory       factory    = game.Factory;
            AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0));

            IOutfit outfit = await factory.Outfit.LoadOutfitFromFoldersAsync(_baseFolder,
                                                                             walkLeftFolder : "Walk/left", walkDownFolder : "Walk/down", walkRightFolder : "Walk/right", walkUpFolder : "Walk/up",
                                                                             idleLeftFolder : "Idle/left", idleDownFolder : "Idle/down", idleRightFolder : "Idle/right", idleUpFolder : "Idle/up",
                                                                             speakLeftFolder : "Talk/left", speakDownFolder : "Talk/down", speakRightFolder : "Talk/right", speakUpFolder : "Talk/up",
                                                                             loadConfig : loadConfig);

            _character = factory.Object.GetCharacter("Beman", outfit).Remember(_game, character =>
            {
                _character = character;
                subscribeEvents();
            });
            _character.SpeechConfig.TextConfig = AGSTextConfig.ChangeColor(_character.SpeechConfig.TextConfig, Colors.CornflowerBlue, Colors.Black, 1f);
            _character.SpeechConfig.TextOffset = (0f, -10f);

            //Uncomment for portrait

            /*
             * var portrait = game.Factory.Object.GetObject("BemanPortrait");
             * portrait.StartAnimation(game.Factory.Graphics.LoadAnimationFromFolder(_baseFolder + "Talk/down"));
             * portrait.Border = game.Factory.Graphics.Borders.SolidColor(Colors.AliceBlue, 3f, true);
             * portrait.Visible = false;
             * portrait.RenderLayer = AGSLayers.Speech;
             * portrait.IgnoreViewport = true;
             * portrait.IgnoreScalingArea = true;
             * game.State.UI.Add(portrait);
             * _character.SpeechConfig.PortraitConfig = new AGSPortraitConfig { Portrait = portrait, Positioning = PortraitPositioning.Alternating };
             */

            var speakAnimation = _character.Outfit[AGSOutfit.Speak];

            Characters.RandomAnimationDelay(speakAnimation.Left);
            Characters.RandomAnimationDelay(speakAnimation.Right);
            Characters.RandomAnimationDelay(speakAnimation.Down);
            Characters.RandomAnimationDelay(speakAnimation.Up);

            _character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down);
            _character.DisplayName    = "Beman";
            _character.IsPixelPerfect = true;

            Characters.Beman = _character;

            _dialogs.Load(game);
            return(_character);
        }
Example #8
0
        public void Init(IGameFactory factory, AGSEditor editor)
        {
            _pointer       = factory.UI.GetLabel("PointerCursor", "", 25f, 25f, 0f, 0f, config: FontIcons.IconConfig, addToUi: false);
            _pointer.Text  = FontIcons.Pointer;
            _pointer.Pivot = new PointF(0.29f, 0.83f);

            var toolbarHeight = _resolution.Height / 20f;

            _toolbar              = factory.UI.GetPanel("GameToolbar", _resolution.Width / 2f, toolbarHeight, _resolution.Width / 2f, _resolution.Height - toolbarHeight);
            _toolbar.Pivot        = new PointF(0.5f, 0f);
            _toolbar.Tint         = GameViewColors.SubPanel;
            _toolbar.RenderLayer  = new AGSRenderLayer(-99999, independentResolution: _resolution);
            _toolbar.ClickThrough = false;
            _toolbar.Border       = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 3f, true);

            var         idle         = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.Button);
            var         hover        = new ButtonAnimation(null, AGSTextConfig.ChangeColor(FontIcons.ButtonConfig, Colors.Yellow, Colors.White, 0f), GameViewColors.HoveredButton);
            var         pushed       = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.PushedButton);
            const float buttonWidth  = 50f;
            float       buttonHeight = _toolbar.Height * 3 / 4f;
            float       buttonY      = _toolbar.Height / 2f;
            float       buttonX      = _toolbar.Width / 2f;

            _playPauseButton             = factory.UI.GetButton("PlayPauseGameButton", idle, hover, pushed, buttonX, buttonY, _toolbar, width: buttonWidth, height: buttonHeight);
            _playPauseButton.Text        = FontIcons.Pause;
            _playPauseButton.Pivot       = new PointF(0.5f, 0.5f);
            _playPauseButton.RenderLayer = _toolbar.RenderLayer;
            _playPauseButton.MouseClicked.Subscribe(onPlayPauseClicked);

            _fpsLabel       = factory.UI.GetLabel("FPS Label (Editor)", "", 30f, 25f, 0f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font));
            _fpsLabel.Pivot = new PointF(0f, 0.5f);
            _fpsLabel.TextBackgroundVisible = false;
            _fpsLabel.RenderLayer           = _toolbar.RenderLayer;
            _fpsLabel.Enabled = true;
            _fpsLabel.MouseEnter.Subscribe(_ => _fpsLabel.Tint = Colors.Indigo);
            _fpsLabel.MouseLeave.Subscribe(_ => _fpsLabel.Tint = Colors.IndianRed.WithAlpha(125));

            _mousePosLabel = factory.UI.GetLabel("Mouse Position Label (Editor)", "", 1f, 1f, 120f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font));
            _mousePosLabel.TextBackgroundVisible = false;
            _mousePosLabel.Pivot       = new PointF(0f, 0.5f);
            _mousePosLabel.RenderLayer = _toolbar.RenderLayer;

            _hotspotLabel = factory.UI.GetLabel("Debug Hotspot Label (Editor)", "", 250f, _fpsLabel.Height, _toolbar.Width, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(alignment: Alignment.TopRight,
                                                                                                                                                                                              autoFit: AutoFit.TextShouldFitLabel, font: _font));
            _hotspotLabel.TextBackgroundVisible = false;
            _hotspotLabel.Pivot       = new PointF(1f, 0.5f);
            _hotspotLabel.RenderLayer = _toolbar.RenderLayer;
        }
Example #9
0
            public RotateHandle(ILabel handle, AGSEditor editor, IGameState state, IInput input, ActionManager actions, Direction direction)
            {
                _editor      = editor;
                _actions     = actions;
                _state       = state;
                _idleConfig  = handle.TextConfig;
                _hoverConfig = AGSTextConfig.ChangeColor(handle.TextConfig, Colors.Yellow, Colors.White, 0f);
                _direction   = direction;
                _input       = input;
                _handle      = handle;
                setIcon();
                _handle.Visible               = false;
                _handle.Enabled               = true;
                _handle.RenderLayer           = AGSLayers.UI;
                _handle.TextBackgroundVisible = false;
                _handle.MouseEnter.Subscribe(onMouseEnter);
                _handle.MouseDown.Subscribe(onMouseDown);
                _handle.MouseLeave.Subscribe(onMouseLeave);

                state.UI.Add(_handle);
            }
Example #10
0
        private void addTargetUIForCreate(IPanel panel, Target target)
        {
            if (target == Target.Area)
            {
                return;
            }

            var factory      = _editor.Editor.Factory;
            var buttonsPanel = factory.UI.GetPanel("MethodWizardTargetPanel", 100f, 45f, MethodWizard.MARGIN_HORIZONTAL, 50f, panel);

            buttonsPanel.Tint = Colors.Transparent;

            var font        = _editor.Editor.Settings.Defaults.TextFont;
            var labelConfig = new AGSTextConfig(font: factory.Fonts.LoadFont(font.FontFamily, font.SizeInPoints, FontStyle.Underline));

            factory.UI.GetLabel("AddToLabel", "Add To:", 50f, 20f, 0f, 0f, buttonsPanel, labelConfig);

            const float buttonY    = -40f;
            var         roomButton = factory.UI.GetCheckBox("AddToRoomRadioButton", (ButtonAnimation)null, null, null, null, 10f, buttonY, buttonsPanel, "Room", width: 20f, height: 25f);
            var         guiButton  = factory.UI.GetCheckBox("AddToGUIRadioButton", (ButtonAnimation)null, null, null, null, 130f, buttonY, buttonsPanel, "GUI", width: 20f, height: 25f);

            _guiButton            = guiButton.GetComponent <ICheckboxComponent>();
            _targetRadioGroup     = new AGSRadioGroup();
            roomButton.RadioGroup = _targetRadioGroup;
            guiButton.RadioGroup  = _targetRadioGroup;
            if (_potentialParent != null)
            {
                var parentButton = factory.UI.GetCheckBox("AddToParentRadioButton", (ButtonAnimation)null, null, null, null, 250f, buttonY, buttonsPanel, _potentialParent.GetFriendlyName(), width: 20f, height: 25f);
                parentButton.RadioGroup = _targetRadioGroup;
                _parentButton           = parentButton.GetComponent <ICheckboxComponent>();
                parentButton.MouseClicked.Subscribe(() =>
                {
                    resetNumberEditor(panel, "x");
                    resetNumberEditor(panel, "y");
                });
            }
            _targetRadioGroup.SelectedButton = target == Target.UI ? _guiButton : roomButton;
        }
Example #11
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();
            };
        }
Example #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);
        }
Example #13
0
        public ITreeNodeView CreateNode(ITreeStringNode node, IRenderLayer layer, IObject parent)
        {
            var view       = _inner.CreateNode(node, layer, parent);
            int nodeId     = Interlocked.Increment(ref _nextNodeId);
            var folderIcon = _factory.UI.GetLabel($"FolderIcon_{node.Text}_{nodeId}", "", 25f, 25f, 15f, 0f, view.ExpandButton, AGSTextConfig.Clone(FontIcons.IconConfig));

            folderIcon.Text           = FontIcons.Folder;
            folderIcon.IsPixelPerfect = false;
            folderIcon.Enabled        = true;
            folderIcon.MouseEnter.Subscribe(() =>
            {
                node.Properties.Bools.SetValue(FOLDER_HOVERED, true);
                view.OnRefreshDisplayNeeded.Invoke();
            });
            folderIcon.MouseLeave.Subscribe(() =>
            {
                node.Properties.Bools.SetValue(FOLDER_HOVERED, false);
                view.OnRefreshDisplayNeeded.Invoke();
            });
            folderIcon.MouseClicked.Subscribe(async(args) => await view.TreeItem.MouseClicked.InvokeAsync(args));
            return(view);
        }
Example #14
0
 private static ITextConfig modifyConfig(ITextConfig config, float width)
 {
     config = AGSTextConfig.Clone(config);
     config.LabelMinSize = (width, config.LabelMinSize?.Height ?? 0f);
     return(config);
 }