예제 #1
0
        public static async Task <bool> YesNoAsync(string text, string yes = "Yes", string no = "No", IMessageBoxSettings settings = null, IGame game = null)
        {
            game = game ?? AGSGame.Game;
            var factory = game.Factory;

            settings = settings ?? game.Settings.Defaults.MessageBox;
            var idle = new ButtonAnimation(new EmptyImage(settings.ButtonWidth, settings.ButtonHeight));

            idle.Tint = Colors.Black;
            var hovered = new ButtonAnimation(new EmptyImage(settings.ButtonWidth, settings.ButtonHeight));

            hovered.Tint = Colors.Yellow;
            var pushed = new ButtonAnimation(new EmptyImage(settings.ButtonWidth, settings.ButtonHeight));

            pushed.Tint = Colors.DarkSlateBlue;
            var border = game.Factory.Graphics.Borders.Gradient(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, settings.ButtonText, false);
            IButton noButton  = factory.UI.GetButton("Dialog No Button", idle, hovered, pushed, 0f, 0f, null, no, settings.ButtonText, false);

            yesButton.Border = border;
            noButton.Border  = border;
            return(await DisplayAsync(text, yesButton, noButton) == yesButton);
        }
예제 #2
0
        private void PlayToState(State state)
        {
            // set the animation time that we want to play to
            targetAnimationEndTime = GetNormalizedTimeForState(state);

            // note that the normalizedTime always resets to zero after finishing the clip.
            // so if button was at Pressed and it was already done playing, its normalizedTime is
            // 0f, even though the Pressed state corresponds to a time of 1f. so, for this special
            // case, force it to 1f.
            if (CurrentState == State.Pressed &&
                animationState.normalizedTime == 0f &&
                !ButtonAnimation.isPlaying)
            {
                animationState.normalizedTime = 1f;
            }

            // move either up or down depending on where the switch is right now
            animationState.speed =
                Mathf.Sign(targetAnimationEndTime - animationState.normalizedTime) * 1f;

            // play animation and actuate switch
            ButtonAnimation.Play(animationName);
            SetState(state);

            // play sound effect if available
            if (SoundEffect != null)
            {
                SoundEffect.Play();
            }
        }
예제 #3
0
        public ITreeNodeView CreateNode(ITreeStringNode item, IRenderLayer layer)
        {
            var buttonWidth  = 20f;
            var buttonHeight = 60f;
            var idle         = new ButtonAnimation(new EmptyImage(buttonWidth, buttonHeight));

            idle.Tint = Colors.Black;
            var hovered = new ButtonAnimation(new EmptyImage(buttonWidth, buttonHeight));

            hovered.Tint = Colors.Yellow;
            var pushed = new ButtonAnimation(new EmptyImage(buttonWidth, buttonHeight));

            pushed.Tint = Colors.DarkSlateBlue;
            int nodeId          = Interlocked.Increment(ref _nextNodeId);
            var itemTextId      = (item.Text ?? "") + "_" + nodeId;
            var parentPanel     = _factory.UI.GetPanel("TreeNodeParentPanel_" + itemTextId, 0f, 0f, 0f, 0f, addToUi: false);
            var horizontalPanel = _factory.UI.GetPanel("TreeNodeHorizontalPanel_" + itemTextId, 0f, 0f, 0f, 0f, parentPanel, false);
            var expandButton    = _factory.UI.GetButton("ExpandButton_" + itemTextId, idle, hovered, pushed, 0f, 0f, horizontalPanel, addToUi: false);
            var label           = _factory.UI.GetLabel("TreeNodeLabel_" + itemTextId, item.Text, 0f, 0f, buttonWidth, 0f, horizontalPanel,
                                                       new AGSTextConfig(paddingTop: 0f, paddingBottom: 0f, autoFit: AutoFit.LabelShouldFitText), addToUi: false);
            var verticalPanel = _factory.UI.GetPanel("TreeNodeVerticalPanel_" + itemTextId, 0f, 0f, 0f, 0f, parentPanel, false);

            horizontalPanel.RenderLayer = layer;
            verticalPanel.RenderLayer   = layer;
            parentPanel.RenderLayer     = layer;
            expandButton.RenderLayer    = layer;
            label.RenderLayer           = layer;
            expandButton.Z       = label.Z - 1;
            horizontalPanel.Tint = Colors.Transparent;
            parentPanel.Tint     = Colors.Transparent;
            verticalPanel.Tint   = Colors.Transparent;
            expandButton.Tint    = Colors.Transparent;
            expandButton.TextBackgroundVisible = false;
            label.Tint = Colors.Transparent;
            label.TextBackgroundVisible = false;
            label.Enabled = true;
            expandButton.IsPixelPerfect = false;
            horizontalPanel.AddComponent <IBoundingBoxWithChildrenComponent>();
            var layout = horizontalPanel.AddComponent <IStackLayoutComponent>();

            layout.RelativeSpacing = 1f;
            layout.Direction       = LayoutDirection.Horizontal;
            layout.StartLayout();

            PropertyChangedEventHandler onPropertyChanged = (sender, e) =>
            {
                if (e.PropertyName != nameof(ITreeStringNode.Text))
                {
                    return;
                }
                label.Text = item.Text;
            };

            item.PropertyChanged += onPropertyChanged;
            label.OnDisposed(() => item.PropertyChanged -= onPropertyChanged);

            var nodeView = new AGSTreeNodeView(label, expandButton, parentPanel, verticalPanel, horizontalPanel);

            return(nodeView);
        }
예제 #4
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;
 }
예제 #5
0
 protected override void Awake()
 {
     base.Awake();
     stateView       = GetComponentInParent <StateView>();
     buttonAnimation = GetComponent <ButtonAnimation>();
     buttonAnimation?.SetOwner(this);
     buttonAnimation?.ChangeState(buttonAnimation.currentState);
 }
 private void restoreAndAddAnimation(Label label)
 {
     if (currentSelectedLabel != null && currentSelectedLabel != label)
     {
         ButtonAnimation.restore(currentSelectedLabel);
     }
     ButtonAnimation.addAnimation(label);
 }
예제 #7
0
        private void btn_RS_supreme_Click(object sender, EventArgs e)
        {
            Button currentButton = sender as Button;

            ButtonAnimation.ButtonSelectInnerTab(this, currentButton);
            pnl_RS_supreme.BringToFront();

            RS_specialtyType = currentButton.TabIndex;
        }
예제 #8
0
        //
        // tabBeverages
        //
        #region tabBeverage Code (Täman)

        private void TG_beverageSelect(object sender, EventArgs e)
        {
            Button currentButton = sender as Button;

            ButtonAnimation.ButtonSelect(this, currentButton);
            Price bevPrice = new Price();

            // Checks what button is selected and sends size and price to object
            if (currentButton.Text == "Small")
            {
                size        = Model.Beverage.BevSize.Small;
                price       = bevPrice.BeverageSm;
                sizeChecked = true;
            }
            else if (currentButton.Text == "Medium")
            {
                size        = Model.Beverage.BevSize.Medium;
                price       = bevPrice.BeverageMd;
                sizeChecked = true;
            }
            else if (currentButton.Text == "Large")
            {
                size        = Model.Beverage.BevSize.Large;
                price       = bevPrice.BeverageLg;
                sizeChecked = true;
            }
            else if (currentButton.Text == "Bazinga XL")
            {
                size        = Model.Beverage.BevSize.XL;
                price       = bevPrice.BeverageXL;
                sizeChecked = true;
            }
            else if (currentButton.Text == "Coca-Cola")
            {
                drink      = currentButton.Text;
                bevChecked = true;
                tabControl_TG_Beverages.SelectedTab = tab_TG_CocaCola;
            }
            else if (currentButton.Text == "Diet Coke")
            {
                drink      = currentButton.Text;
                bevChecked = true;
                tabControl_TG_Beverages.SelectedTab = tab_TG_DietCola;
            }
            else if (currentButton.Text == "Sprite")
            {
                drink      = currentButton.Text;
                bevChecked = true;
                tabControl_TG_Beverages.SelectedTab = tab_TG_Sprite;
            }
            else if (currentButton.Text == "Dr. Pepper")
            {
                drink      = currentButton.Text;
                bevChecked = true;
                tabControl_TG_Beverages.SelectedTab = tab_TG_DrPepper;
            }
        }
예제 #9
0
 public Button(IInterface _interface, Texture2D sprite, Vector2 position, ButtonAnimation animationType)
 {
     Interface       = _interface;
     Sprite          = sprite;
     Position        = position;
     InitialPosition = position;
     AnimationType   = animationType;
     AnimationTime   = 0.25;
 }
예제 #10
0
        private void GoToState(State state)
        {
            SetState(state);

            // switch to animation state instantly
            animationState.normalizedTime = GetNormalizedTimeForState(state);
            animationState.speed          = 0f;
            ButtonAnimation.Play(animationName);
        }
예제 #11
0
        //
        // tabStart - Täman
        //
        #region tabStart Code (Täman)

        #region Dine In, Carry Out

        private void btn_TG_DineIn_Click(object sender, EventArgs e)
        {
            ClearFields();
            tabControl2.SelectTab(tab_TG_DineIn);
            txt_TG_NameDineIn.BackColor = colFormBackColor;
            txt_TG_NameDineIn.Focus();
            Button currentButton = sender as Button;

            ButtonAnimation.ButtonSelect(this, currentButton);
        }
        public Button(Texture2D buttonTexture, Texture2D buttonSelectedTexture)
        {
            tabStop = true;
            enabled = true;
            position = Vector2.Zero;

            this.buttonTexture = buttonTexture;
            this.size = new Vector2(buttonTexture.Width, buttonTexture.Height);
            buttonSelected = new ButtonAnimation(buttonSelectedTexture, this.size, this.position, 75);
        }
예제 #13
0
 public ButtonBase(UIManager manager) : base(manager)
 {
     animation            = ButtonAnimation.None;
     state                = AnimationState.Stay;
     foregroundColor      = Color.Black;
     backgroundColor      = Color.White;
     hoverBackgroundColor = new Color(200, 200, 200);
     hoverForegroundColor = Color.Black;
     transitionTime       = transitionValue = 0;
 }
예제 #14
0
        public async Task <IButton> GetButtonAsync(string id, string idleImagePath, string hoveredImagePath, string pushedImagePath,
                                                   float x, float y, IObject parent = null, string text = "", ITextConfig config = null, bool addToUi = true,
                                                   float width = -1f, float height = -1f)
        {
            ButtonAnimation idle    = new ButtonAnimation(await _graphics.LoadImageAsync(idleImagePath));
            ButtonAnimation hovered = new ButtonAnimation(await _graphics.LoadImageAsync(hoveredImagePath));
            ButtonAnimation pushed  = new ButtonAnimation(await _graphics.LoadImageAsync(pushedImagePath));

            return(GetButton(id, idle, hovered, pushed, x, y, parent, text, config, addToUi, width, height));
        }
예제 #15
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();
        }
예제 #16
0
        private ButtonAnimation getAnimation(IBorderComponent container, ButtonAnimation animation)
        {
            if (animation.Border == null || container == null || container.Border == null)
            {
                return(animation);
            }
            ButtonAnimation newAnimation = new ButtonAnimation(animation.Animation, animation.Image, _factory.Borders.Multiple(container.Border, animation.Border),
                                                               animation.TextConfig, animation.Tint);

            return(newAnimation);
        }
예제 #17
0
        private static IButton getDropDownButton(string id, IGameFactory factory)
        {
            var textConfig = FontIcons.ButtonConfig;

            var idle           = new ButtonAnimation(GameViewColors.ComboboxButtonBorder, textConfig, GameViewColors.TextEditor);
            var hover          = new ButtonAnimation(GameViewColors.HoveredComboboxButtonBorder, null, GameViewColors.HoveredTextEditor);
            var pushed         = new ButtonAnimation(GameViewColors.ComboboxButtonBorder, null, GameViewColors.PushedTextEditor);
            var dropDownButton = factory.UI.GetButton($"{id}_DropDownButton", idle, hover, pushed, 0f, 0f, null, FontIcons.CaretDown, textConfig, false, 25f, 25f);

            return(dropDownButton);
        }
 private void restoreAnimation(Label label)
 {
     if (currentSelectedLabel == null)
     {
         ButtonAnimation.restore(label);
         return;
     }
     if (currentSelectedLabel != label)
     {
         ButtonAnimation.restore(label);
     }
 }
예제 #19
0
    private void UnlockLevel(Button button, int index, bool isJoker)
    {
        button.transform.Find("LevelNumber").GetComponent <TextMesh>().text = LevelSelector.DifferentiatedLevelLabel(index);
        button.transform.Find("Lock").gameObject.SetActive(false);
        button.MethodToCall.SetMethod(base.gameObject.GetComponent <LevelSelector>(), (!isJoker) ? "LoadLevel" : "LoadStarLevel", index.ToString());
        ButtonAnimation component = button.GetComponent <ButtonAnimation>();

        if (component != null)
        {
            component.RemoveInputListener();
        }
        string sceneName = this.Levels[index].sceneName;
        int    @int      = GameProgress.GetInt(sceneName + "_stars", 0, GameProgress.Location.Local, null);
        bool   flag      = GameProgress.HasCollectedSnoutCoins(sceneName, 0);
        bool   flag2     = GameProgress.HasCollectedSnoutCoins(sceneName, 1);
        bool   flag3     = GameProgress.HasCollectedSnoutCoins(sceneName, 2);

        GameObject[] array = new GameObject[]
        {
            button.transform.Find("StarSet/Star1").gameObject,
            button.transform.Find("StarSet/Star2").gameObject,
            button.transform.Find("StarSet/Star3").gameObject,
            button.transform.Find("CoinSet/Star1").gameObject,
            button.transform.Find("CoinSet/Star2").gameObject,
            button.transform.Find("CoinSet/Star3").gameObject
        };
        int num = 0;

        if (flag)
        {
            num++;
        }
        if (flag2)
        {
            num++;
        }
        if (flag3)
        {
            num++;
        }
        for (int i = 0; i < 3; i++)
        {
            bool flag4 = i + 1 <= @int;
            bool flag5 = i + 1 <= num || Singleton <BuildCustomizationLoader> .Instance.IsOdyssey;
            array[i].SetActive(flag4 && !flag5);
            array[i + 3].SetActive(flag4 && flag5);
        }
        if (isJoker)
        {
            GameObject gameObject = button.transform.Find("StarSetsLocked").gameObject;
            gameObject.SetActive(false);
        }
    }
예제 #20
0
        private void addButtons(IObject parent)
        {
            var factory       = _editor.Editor.Factory;
            var border        = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 2f);
            var idleConfig    = factory.Fonts.GetTextConfig(GameViewColors.TextBrush, alignment: Alignment.MiddleCenter);
            var hoveredConfig = factory.Fonts.GetTextConfig(GameViewColors.HoveredTextBrush, alignment: Alignment.MiddleCenter);
            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{_idSuffix}", 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{_idSuffix}", idle, hovered, pushed, 0f, 0f, buttonsPanel, "OK", width: buttonWidth, height: 20f);

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

                closeForm(map);
            });

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

            cancelButton.MouseClicked.Subscribe(() =>
            {
                closeForm(null);
            });

            layout.StartLayout();
            layout.ForceRefreshLayout();
        }
예제 #21
0
        public IButton GetButton(string id,
                                 [MethodParam(DefaultProvider = nameof(GetDefaultIdleAnimation))] ButtonAnimation idle,
                                 [MethodParam(DefaultProvider = nameof(GetDefaultHoverAnimation))] ButtonAnimation hovered,
                                 [MethodParam(DefaultProvider = nameof(GetDefaultPushedAnimation))] ButtonAnimation pushed,
                                 float x, float y, [MethodParam(Browsable = false)] IObject parent = null, string text = "",
                                 [MethodParam(Browsable = false)] ITextConfig config            = null,
                                 [MethodParam(Browsable = false, Default = false)] bool addToUi = true,
                                 [MethodParam(Browsable = false, Default = 25f)] float width    = -1f,
                                 [MethodParam(Browsable = false, Default = 25f)] float height   = -1f)
        {
            bool pixelArtButton = idle?.Image != null || (idle?.Animation != null && idle.Animation.Frames.Count > 0);

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (width == -1f && pixelArtButton)
            {
                width = idle.Image?.Width ?? idle.Animation.Frames[0].Sprite.Width;
            }
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (height == -1f && pixelArtButton)
            {
                height = idle.Image?.Height ?? idle.Animation.Frames[0].Sprite.Height;
            }
            Func <ButtonAnimation> defaultAnimation = () => new ButtonAnimation((IImage)null);

            idle    = validateAnimation(id, idle, defaultAnimation, width, height);
            hovered = validateAnimation(id, hovered, defaultAnimation, width, height);
            pushed  = validateAnimation(id, pushed, defaultAnimation, width, height);

            TypedParameter idParam = new TypedParameter(typeof(string), id);
            IButton        button  = _resolver.Container.Resolve <IButton>(idParam);

            button.LabelRenderSize = new SizeF(width, height);
            button.IdleAnimation   = idle;
            button.HoverAnimation  = hovered;
            button.PushedAnimation = pushed;

            button.Tint       = pixelArtButton ? Colors.White : Colors.Transparent;
            button.X          = x;
            button.Y          = y;
            button.TextConfig = config ?? _fonts.GetTextConfig(alignment: Alignment.MiddleCenter);
            button.Text       = text;
            setParent(button, parent);

            button.Skin?.Apply(button);
            button.IdleAnimation.StartAnimation(button, button, button, button);

            if (addToUi)
            {
                _gameState.UI.Add(button);
            }
            return(button);
        }
예제 #22
0
        private void btn_RS_addSausage_Click(object sender, EventArgs e)
        {
            if (RS_toppings.Contains(Pizza.Topping.ItalianSausage))
            {
                RS_toppings.RemoveAt(RS_toppings.IndexOf(Pizza.Topping.ItalianSausage));
            }
            else
            {
                RS_toppings.Add(Pizza.Topping.ItalianSausage);
            }

            ButtonAnimation.ButtonOnOff(this, btn_RS_addSausage);
        }
예제 #23
0
        private void btn_RS_addMushrooms_Click(object sender, EventArgs e)
        {
            if (RS_toppings.Contains(Pizza.Topping.Mushrooms))
            {
                RS_toppings.RemoveAt(RS_toppings.IndexOf(Pizza.Topping.Mushrooms));
            }
            else
            {
                RS_toppings.Add(Pizza.Topping.Mushrooms);
            }

            ButtonAnimation.ButtonOnOff(this, btn_RS_addMushrooms);
        }
예제 #24
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);
            }
예제 #25
0
 protected override void OnMouseDown(MouseEventArgs mevent)
 {
     base.OnMouseDown(mevent);
     _isPushed = true;
     if (DrawPushAnimation)
     {
         ButtonAnimation.CurrentValue = 0;
         ButtonAnimation.Animated     = true;
         ButtonAnimation.TargetButton = this;
         ButtonAnimation.MousePos     = mevent.Location;
         ButtonAnimation.Restart();
     }
     Refresh();
 }
예제 #26
0
 private ButtonAnimation validateAnimation(string id, ButtonAnimation button, Func <ButtonAnimation> defaultAnimation, float width, float height)
 {
     button = button ?? defaultAnimation();
     if (button.Animation != null)
     {
         return(button);
     }
     if (width == -1f || height == -1)
     {
         throw new InvalidOperationException("No animation and no size was supplied for GUI control " + id);
     }
     button.Animation = new AGSSingleFrameAnimation(new EmptyImage(width, height), _graphics);
     return(button);
 }
 public void Animate(ButtonAnimation animation)
 {
     if (animation.Angle.HasValue)
     {
         Angle = (float)animation.Angle;
     }
     if (animation.Color.HasValue)
     {
         Color = (Color)animation.Color;
     }
     if (animation.Bounds.HasValue)
     {
         Bounds = (Rectangle)animation.Bounds;
     }
 }
예제 #28
0
        public IListbox GetListBox(string id, [MethodParam(Browsable = false)] IRenderLayer layer,
                                   [MethodParam(Browsable = false)] Func <string, IUIControl> listItemFactory = null,
                                   float defaultWidth = 500f, float defaultHeight = 40f,
                                   [MethodParam(Browsable = false, Default = false)] bool addToUi = true,
                                   bool isVisible = true, bool withScrollBars = true)
        {
            layer = layer ?? AGSLayers.UI;
            if (listItemFactory == null)
            {
                var yellowBrush = _graphics.Brushes.LoadSolidBrush(Colors.Yellow);
                var whiteBrush  = _graphics.Brushes.LoadSolidBrush(Colors.White);
                var idle        = new ButtonAnimation(null, _fonts.GetTextConfig(whiteBrush, autoFit: AutoFit.LabelShouldFitText), null);
                var hovered     = new ButtonAnimation(null, _fonts.GetTextConfig(yellowBrush, autoFit: AutoFit.LabelShouldFitText), null);
                var pushed      = new ButtonAnimation(null, _fonts.GetTextConfig(yellowBrush, outlineBrush: whiteBrush, outlineWidth: 0.5f, autoFit: AutoFit.LabelShouldFitText), null);
                listItemFactory = text =>
                {
                    var button = GetButton(id + "_" + text,
                                           idle, hovered, pushed,
                                           0f, 0f, width: defaultWidth, height: defaultHeight);
                    button.Pivot       = new PointF(0f, 1f);
                    button.RenderLayer = layer;
                    button.Text        = text;
                    return(button);
                };
            }

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

            scrollingPanel.Visible     = isVisible;
            scrollingPanel.Border      = _borders.SolidColor(Colors.White, 3f);
            scrollingPanel.Tint        = Colors.Black;
            scrollingPanel.RenderLayer = layer;
            var contentsPanel = withScrollBars ? CreateScrollingPanel(scrollingPanel) : scrollingPanel;
            var listBox       = contentsPanel.AddComponent <IListboxComponent>();

            listBox.ListItemFactory = listItemFactory;
            listBox.MaxHeight       = 300f;

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

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

            return(new AGSListbox(withScrollBars ? scrollingPanel : null, contentsPanel, listBox));
        }
예제 #29
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;
        }
예제 #30
0
 private ButtonAnimation validateAnimation(string id, ButtonAnimation button, Func <ButtonAnimation> defaultAnimation, float width, float height)
 {
     button = button ?? defaultAnimation();
     if (button.Animation != null || button.Image != null)
     {
         return(button);
     }
     // ReSharper disable CompareOfFloatsByEqualityOperator
     if (width == -1f || height == -1)
     // ReSharper restore CompareOfFloatsByEqualityOperator
     {
         throw new InvalidOperationException("No animation/image and no size was supplied for GUI control " + id);
     }
     button = new ButtonAnimation(button.Animation, new EmptyImage(width, height), button.Border, button.TextConfig, button.Tint);
     return(button);
 }
예제 #31
0
        /// <summary>
        /// Event handler for after a game move is made.
        /// Responsible for updating the board to show the new move
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TheGame_AfterMove(object sender, MoveEventArgs e)
        {
            int index = e.TheMove.Row * this.theGame.Columns + e.TheMove.Column;
            Button btnCell = this.tableContainer.Controls[index] as Button;
            ButtonAnimation animation = new ButtonAnimation(AnimateMove);

            for (int i = 0; i < 2; i++)
            {
                btnCell.Invoke(animation, btnCell, false, false);
                Thread.Sleep(100);
                btnCell.Invoke(animation, btnCell, true, false);
                Thread.Sleep(100);
            }

            btnCell.Invoke(animation, btnCell, true, true);
        }