MouseUp() public méthode

public MouseUp ( UpdateState state ) : void
state FSO.Common.Rendering.Framework.Model.UpdateState
Résultat void
Exemple #1
0
        private void OnMouse(UIMouseEventType type, UpdateState state)
        {
            if (!vm.Ready)
            {
                return;
            }

            if (type == UIMouseEventType.MouseOver)
            {
                if (QueryPanel.Mode == 1)
                {
                    QueryPanel.Active = false;
                }
                MouseIsOn = true;
            }
            else if (type == UIMouseEventType.MouseOut)
            {
                MouseIsOn = false;
                GameFacade.Cursor.SetCursor(CursorType.Normal);
                Tooltip = null;
            }
            else if (type == UIMouseEventType.MouseDown)
            {
                Touch.MiceDown.Add(state.CurrentMouseID);
            }
            else if (type == UIMouseEventType.MouseUp)
            {
                Touch.MiceDown.Remove(state.CurrentMouseID);
                if (!LiveMode)
                {
                    if (CustomControl != null)
                    {
                        CustomControl.MouseUp(state);
                    }
                    else
                    {
                        ObjectHolder.MouseUp(state);
                    }
                    return;
                }
                state.UIState.TooltipProperties.Show    = false;
                state.UIState.TooltipProperties.Opacity = 0;
                ShowTooltip = false;
                TipIsError  = false;
            }
        }
Exemple #2
0
        private void OnMouse(UIMouseEventType type, UpdateState state)
        {
            if (!vm.Ready)
            {
                return;
            }

            if (type == UIMouseEventType.MouseOver)
            {
                if (QueryPanel.Mode == 1)
                {
                    QueryPanel.Active = false;
                }
                MouseIsOn = true;
            }
            else if (type == UIMouseEventType.MouseOut)
            {
                MouseIsOn = false;
                Tooltip   = null;
            }
            else if (type == UIMouseEventType.MouseDown)
            {
                if (!LiveMode)
                {
                    if (CustomControl != null)
                    {
                        CustomControl.MouseDown(state);
                    }
                    else
                    {
                        ObjectHolder.MouseDown(state);
                    }
                    return;
                }
                if (PieMenu == null && ActiveEntity != null)
                {
                    VMEntity obj;
                    //get new pie menu, make new pie menu panel for it
                    var tilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y));

                    LotTilePos targetPos = LotTilePos.FromBigTile((short)tilePos.X, (short)tilePos.Y, World.State.Level);
                    if (vm.Context.SolidToAvatars(targetPos).Solid)
                    {
                        targetPos = LotTilePos.OUT_OF_WORLD;
                    }

                    GotoObject.SetPosition(targetPos, Direction.NORTH, vm.Context);

                    bool objSelected = ObjectHover > 0 && InteractionsAvailable;
                    if (objSelected || (GotoObject.Position != LotTilePos.OUT_OF_WORLD && ObjectHover <= 0))
                    {
                        HITVM.Get().PlaySoundEvent(UISounds.PieMenuAppear);
                        if (objSelected)
                        {
                            obj = vm.GetObjectById(ObjectHover);
                        }
                        else
                        {
                            obj = GotoObject;
                        }
                        obj = obj.MultitileGroup.GetInteractionGroupLeader(obj);

                        var menu = obj.GetPieMenu(vm, ActiveEntity, false);
                        if (menu.Count != 0)
                        {
                            PieMenu = new UIPieMenu(menu, obj, ActiveEntity, this);
                            this.Add(PieMenu);
                            PieMenu.X = state.MouseState.X;
                            PieMenu.Y = state.MouseState.Y;
                            PieMenu.UpdateHeadPosition(state.MouseState.X, state.MouseState.Y);
                        }
                    }
                    else
                    {
                        HITVM.Get().PlaySoundEvent(UISounds.Error);
                        state.UIState.TooltipProperties.Show     = true;
                        state.UIState.TooltipProperties.Color    = Color.Black;
                        state.UIState.TooltipProperties.Opacity  = 1;
                        state.UIState.TooltipProperties.Position = new Vector2(state.MouseState.X,
                                                                               state.MouseState.Y);
                        state.UIState.Tooltip = GameFacade.Strings.GetString("159", "0");
                        state.UIState.TooltipProperties.UpdateDead = false;
                        ShowTooltip = true;
                        TipIsError  = true;
                    }
                }
                else
                {
                    if (PieMenu != null)
                    {
                        PieMenu.RemoveSimScene();
                    }
                    this.Remove(PieMenu);
                    PieMenu = null;
                }
            }
            else if (type == UIMouseEventType.MouseUp)
            {
                if (!LiveMode)
                {
                    if (CustomControl != null)
                    {
                        CustomControl.MouseUp(state);
                    }
                    else
                    {
                        ObjectHolder.MouseUp(state);
                    }
                    return;
                }
                state.UIState.TooltipProperties.Show    = false;
                state.UIState.TooltipProperties.Opacity = 0;
                ShowTooltip = false;
                TipIsError  = false;
            }
        }
Exemple #3
0
        private void OnMouse(UIMouseEventType type, UpdateState state)
        {
            if (!vm.Ready)
            {
                return;
            }

            if (type == UIMouseEventType.MouseOver)
            {
                if (QueryPanel.Mode == 1)
                {
                    QueryPanel.Active = false;
                }
                MouseIsOn = true;
            }
            else if (type == UIMouseEventType.MouseOut)
            {
                MouseIsOn = false;
                GameFacade.Cursor.SetCursor(CursorType.Normal);
                Tooltip = null;
            }
            else if (type == UIMouseEventType.MouseDown)
            {
                if (!LiveMode)
                {
                    if (CustomControl != null)
                    {
                        CustomControl.MouseDown(state);
                    }
                    else
                    {
                        ObjectHolder.MouseDown(state);
                    }
                    return;
                }
                if (PieMenu == null && ActiveEntity != null)
                {
                    VMEntity obj;
                    //get new pie menu, make new pie menu panel for it
                    var tilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y) / FSOEnvironment.DPIScaleFactor);

                    LotTilePos targetPos = LotTilePos.FromBigTile((short)tilePos.X, (short)tilePos.Y, World.State.Level);
                    if (vm.Context.SolidToAvatars(targetPos).Solid)
                    {
                        targetPos = LotTilePos.OUT_OF_WORLD;
                    }

                    GotoObject.SetPosition(targetPos, Direction.NORTH, vm.Context);

                    bool objSelected = ObjectHover > 0 && InteractionsAvailable;
                    if (objSelected || (GotoObject.Position != LotTilePos.OUT_OF_WORLD && ObjectHover <= 0))
                    {
                        if (objSelected)
                        {
                            obj = vm.GetObjectById(ObjectHover);
                        }
                        else
                        {
                            obj = GotoObject;
                        }
                        if (obj != null)
                        {
                            obj = obj.MultitileGroup.GetInteractionGroupLeader(obj);
                            if (obj is VMGameObject && ((VMGameObject)obj).Disabled > 0)
                            {
                                var flags = ((VMGameObject)obj).Disabled;

                                if ((flags & VMGameObjectDisableFlags.ForSale) > 0)
                                {
                                    //for sale
                                    var retailPrice = obj.MultitileGroup.Price; //wrong... should get this from catalog
                                    var salePrice   = obj.MultitileGroup.SalePrice;
                                    ShowErrorTooltip(state, 22, true, "$" + retailPrice.ToString("##,#0"), "$" + salePrice.ToString("##,#0"));
                                }
                                else if ((flags & VMGameObjectDisableFlags.LotCategoryWrong) > 0)
                                {
                                    ShowErrorTooltip(state, 21, true); //category wrong
                                }
                                else if ((flags & VMGameObjectDisableFlags.TransactionIncomplete) > 0)
                                {
                                    ShowErrorTooltip(state, 27, true); //transaction not yet complete
                                }
                                else if ((flags & VMGameObjectDisableFlags.ObjectLimitExceeded) > 0)
                                {
                                    ShowErrorTooltip(state, 24, true); //object is temporarily disabled... todo: something more helpful
                                }
                                else if ((flags & VMGameObjectDisableFlags.PendingRoommateDeletion) > 0)
                                {
                                    ShowErrorTooltip(state, 16, true); //pending roommate deletion
                                }
                            }
                            else
                            {
                                HITVM.Get().PlaySoundEvent(UISounds.PieMenuAppear);
                                var menu = obj.GetPieMenu(vm, ActiveEntity, false, true);
                                if (menu.Count != 0)
                                {
                                    PieMenu = new UIPieMenu(menu, obj, ActiveEntity, this);
                                    this.Add(PieMenu);
                                    PieMenu.X = state.MouseState.X / FSOEnvironment.DPIScaleFactor;
                                    PieMenu.Y = state.MouseState.Y / FSOEnvironment.DPIScaleFactor;
                                    PieMenu.UpdateHeadPosition(state.MouseState.X, state.MouseState.Y);
                                }
                            }
                        }
                    }
                    else
                    {
                        ShowErrorTooltip(state, 0, true);
                    }
                }
                else
                {
                    if (PieMenu != null)
                    {
                        PieMenu.RemoveSimScene();
                    }
                    this.Remove(PieMenu);
                    PieMenu = null;
                }
            }
            else if (type == UIMouseEventType.MouseUp)
            {
                if (!LiveMode)
                {
                    if (CustomControl != null)
                    {
                        CustomControl.MouseUp(state);
                    }
                    else
                    {
                        ObjectHolder.MouseUp(state);
                    }
                    return;
                }
                state.UIState.TooltipProperties.Show    = false;
                state.UIState.TooltipProperties.Opacity = 0;
                ShowTooltip = false;
                TipIsError  = false;
            }
        }