Beispiel #1
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);
            }
        public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property)
        {
            _property = property;
            var label  = view.TreeItem;
            var config = _enabled ? GameViewColors.TextConfig : GameViewColors.ReadonlyTextConfig;

            if (!_enabled)
            {
                view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>().RestrictionList.RestrictionList.Add(id);
            }
            var textbox = _factory.UI.GetTextBox(id,
                                                 label.X, label.Y, label.TreeNode.Parent,
                                                 "", config, width: 100f, height: 20f);

            textbox.Text = property.Value;
            textbox.TextBackgroundVisible = false;
            textbox.Enabled = _enabled;
            if (_enabled)
            {
                GameViewColors.AddHoverEffect(textbox);
            }
            _textbox            = textbox;
            textbox.RenderLayer = label.RenderLayer;
            textbox.Z           = label.Z;
            HoverEffect.Add(textbox, Colors.Transparent, Colors.DarkSlateBlue);
            textbox.OnPressingKey.Subscribe(args =>
            {
                if (args.PressedKey != Key.Enter)
                {
                    return;
                }
                args.ShouldCancel = true;
                textbox.IsFocused = false;
                setString();
            });
            textbox.LostFocus.Subscribe(args =>
            {
                textbox.IsFocused = false;
                setString();
            });
        }