Just blocks and sinks mouse events
Inheritance: FSO.Client.UI.Framework.UIElement
Exemple #1
0
        public void SetPanel(int newPanel)
        {
            OptionsModeButton.Selected = false;
            BuyModeButton.Selected = false;
            BuildModeButton.Selected = false;
            LiveModeButton.Selected = false;

            if (Game.InLot)
            {
                Game.LotController.QueryPanel.Active = false;
                Game.LotController.QueryPanel.Visible = false;
                Game.LotController.LiveMode = true;
                Game.vm.Context.World.State.BuildMode = false;
            }

            if (CurrentPanel != -1)
            {
                this.Remove(Panel);
                Panel.Destroy();

                if (Game.InLot) Game.LotController.PanelActive = false;
            }
            if (newPanel != CurrentPanel)
            {
                if (Game.InLot) Game.LotController.PanelActive = true;
                switch (newPanel)
                {
                    case 5:
                        Panel = new UIOptions();
                        Panel.X = 177;
                        Panel.Y = 96;
                        this.Add(Panel);
                        OptionsModeButton.Selected = true;
                        SetFocus(UCPFocusMode.ActiveTab);
                        break;
                    case 2:
                        if (!Game.InLot) break; //not ingame
                        Panel = new UIBuyMode(Game.LotController);
                        Game.LotController.LiveMode = false;
                        Panel.X = 177;
                        Panel.Y = 96;
                        ((UIBuyMode)Panel).vm = Game.vm;
                        this.Add(Panel);
                        BuyModeButton.Selected = true;
                        SetFocus(UCPFocusMode.ActiveTab);
                        break;
                    case 3:
                        if (!Game.InLot) break; //not ingame
                        Panel = new UIBuildMode(Game.LotController);

                        //enable air tile graphics
                        Game.vm.Context.World.State.BuildMode = true;

                        Game.LotController.LiveMode = false;
                        Panel.X = 177;
                        Panel.Y = 96;
                        ((UIBuildMode)Panel).vm = Game.vm;
                        this.Add(Panel);
                        BuildModeButton.Selected = true;
                        SetFocus(UCPFocusMode.ActiveTab);
                        break;
                    case 1:
                        if (!Game.InLot) break; //not ingame
                        Panel = new UILiveMode(Game.LotController);
                        Panel.X = 177;
                        Panel.Y = 63;
                        this.Add(Panel);
                        LiveModeButton.Selected = true;
                        SetFocus(UCPFocusMode.ActiveTab);
                        break;
                    default:
                        if (Game.InLot) Game.LotController.PanelActive = false;
                        break;
                }
                CurrentPanel = newPanel;
            }
            else
            {
                Remove(PanelBlocker);
                PanelBlocker = null;
                CurrentPanel = -1;
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets the "focus mode" of the UCP, used to make the UI accessible on phones.
        /// </summary>
        /// <param name="focus"></param>
        public void SetFocus(UCPFocusMode focus)
        {
            if (Focus == focus) return;
            if (FSOEnvironment.UIZoomFactor>1f)
            {
                if (focus != UCPFocusMode.Game)
                {
                    var tween = GameFacade.Screens.Tween.To(this, 0.33f, new Dictionary<string, float>()
                    {
                        {"ScaleX", FSOEnvironment.UIZoomFactor},
                        {"ScaleY", FSOEnvironment.UIZoomFactor},
                        {"Y", Game.ScreenHeight-(int)(210*FSOEnvironment.UIZoomFactor) },
                        {"X", (focus == UCPFocusMode.ActiveTab)?-(int)(225*FSOEnvironment.UIZoomFactor):0 }
                    }, TweenQuad.EaseInOut);

                    Remove(SelfBlocker); SelfBlocker = null;
                    if (focus == UCPFocusMode.ActiveTab)
                    {
                        Remove(PanelBlocker); PanelBlocker = null;
                    }

                    if (GameBlocker == null)
                    {
                        GameBlocker = new UIBlocker();
                        GameBlocker.Position = new Vector2(0, 220 - Game.ScreenHeight);
                        GameBlocker.OnMouseEvt += (evt, state) =>
                        {
                            if (evt == UIMouseEventType.MouseDown) SetFocus(UCPFocusMode.Game);
                        };
                        AddAt(0, GameBlocker);
                    }
                } else
                {
                    var tween = GameFacade.Screens.Tween.To(this, 0.33f, new Dictionary<string, float>()
                    {
                        {"ScaleX", 1f},
                        {"ScaleY", 1f},
                        {"Y", Game.ScreenHeight-210 },
                        {"X", 0 }
                    }, TweenQuad.EaseInOut);

                    if (SelfBlocker == null)
                    {
                        SelfBlocker = new UIBlocker(220, 210);
                        SelfBlocker.OnMouseEvt += (evt, state) =>
                        {
                            if (evt == UIMouseEventType.MouseDown) SetFocus(UCPFocusMode.UCP);
                        };
                        Add(SelfBlocker);
                    }

                    if (CurrentPanel > -1 && PanelBlocker == null)
                    {
                        PanelBlocker = new UIBlocker(580, 104);
                        PanelBlocker.Position = new Vector2(220, 106);
                        PanelBlocker.OnMouseEvt += (evt, state) =>
                        {
                            if (evt == UIMouseEventType.MouseDown) SetFocus(UCPFocusMode.ActiveTab);
                        };
                        Add(PanelBlocker);
                    }

                    Remove(GameBlocker); GameBlocker = null;
                }
            }
            Focus = focus;
        }