public void ClosePie() { if (PieMenu != null) { PieMenu.RemoveSimScene(); Queue.PieMenuClickPos = PieMenu.Position; this.Remove(PieMenu); PieMenu = null; } }
public override void Update(UpdateState state) { base.Update(state); if (!vm.Ready || vm.Context.Architecture == null) { return; } //handling smooth scaled zoom var camType = World.State.Cameras.ActiveType; Touch._3D = camType != FSO.LotView.Utils.Camera.CameraControllerType._2D; if (World.State.Cameras.ActiveType == FSO.LotView.Utils.Camera.CameraControllerType._3D) { if (World.BackbufferScale != 1) { World.BackbufferScale = 1; } var s3d = World.State.Cameras.Camera3D; if (TargetZoom < -0.25f) { TargetZoom -= (TargetZoom - 0.25f) * (1f - (float)Math.Pow(0.975f, 60f / FSOEnvironment.RefreshRate)); } s3d.Zoom3D += ((9.75f - (TargetZoom - 0.25f) * 5.7f) - s3d.Zoom3D) / 10; } else if (World.State.Cameras.ActiveType == FSO.LotView.Utils.Camera.CameraControllerType._2D) { if (World.State.Zoom != LastZoom) { //zoom has been changed by something else. inherit the value SetTargetZoom(World.State.Zoom); LastZoom = World.State.Zoom; } float BaseScale; WorldZoom targetZoom; if (TargetZoom < 0.5f) { targetZoom = WorldZoom.Far; BaseScale = 0.25f; } else if (TargetZoom < 1f) { targetZoom = WorldZoom.Medium; BaseScale = 0.5f; } else { targetZoom = WorldZoom.Near; BaseScale = 1f; } World.BackbufferScale = TargetZoom / BaseScale; if (World.State.Zoom != targetZoom) { World.State.Zoom = targetZoom; } WorldConfig.Current.SmoothZoom = false; } if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. //if (ActiveEntity == null) ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); vm.Context.World.State.ScrollAnchor = null; FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } //update plumbbob var plumb = Content.Get().RCMeshes.Get("arrow.fsom"); foreach (VMAvatar avatar in vm.Context.ObjectQueries.Avatars) { if (avatar.Avatar == null) { continue; } var isActive = (avatar == ActiveEntity); if ((avatar.Avatar.HeadObject == plumb) != isActive) { avatar.Avatar.HeadObject = (avatar == ActiveEntity) ? plumb : null; avatar.Avatar.HeadObjectSpeedyVel = 0.2f; } avatar.Avatar.HeadObjectRotation += 3f / FSOEnvironment.RefreshRate; if (isActive) { avatar.Avatar.HeadObjectRotation += avatar.Avatar.HeadObjectSpeedyVel; avatar.Avatar.HeadObjectSpeedyVel *= 0.98f; } else if (avatar.GetValue(FSO.SimAntics.Model.VMStackObjectVariable.Category) == 87) { avatar.Avatar.HeadObject = Content.Get().RCMeshes.Get("star.fsom"); } } /* * if (ActiveEntity != null && BlockingDialog != null) * { * //are we still waiting on a blocking dialog? if not, cancel. * if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult))) * { * BlockingDialog.Close(); * LastDialogID = 0; * BlockingDialog = null; * } * }*/ if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (RMBScroll) { World.State.ScrollAnchor = null; Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; scrollBy /= FSOEnvironment.DPIScaleFactor; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4; angle += 8; angle %= 8; CursorType type = CursorType.ArrowUp; switch ((int)Math.Round(angle)) { case 0: type = CursorType.ArrowUp; break; case 1: type = CursorType.ArrowUpRight; break; case 2: type = CursorType.ArrowRight; break; case 3: type = CursorType.ArrowDownRight; break; case 4: type = CursorType.ArrowDown; break; case 5: type = CursorType.ArrowDownLeft; break; case 6: type = CursorType.ArrowLeft; break; case 7: type = CursorType.ArrowUpLeft; break; } GameFacade.Cursor.SetCursor(type); } World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate)); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (state.MouseState.RightButton != ButtonState.Pressed) { if (RMBScroll) { GameFacade.Cursor.SetCursor(CursorType.Normal); } RMBScroll = false; } if (!LiveMode && PieMenu != null) { PieMenu.RemoveSimScene(); this.Remove(PieMenu); PieMenu = null; } if (state.NewKeys.Contains(Keys.F11)) { var utils = new FSO.SimAntics.Test.CollisionTestUtils(); utils.VerifyAllCollision(vm); } if (state.NewKeys.Contains(Keys.F8)) { UIMobileAlert alert = null; alert = new UIMobileAlert(new UIAlertOptions() { Title = "Debug Lot Thumbnail", Message = "Arch Value: " + VMArchitectureStats.GetArchValue(vm.Context.Architecture), Buttons = UIAlertButton.Ok((btn) => UIScreen.RemoveDialog(alert)) }); Texture2D roofless = null; var thumb = World.GetLotThumb(GameFacade.GraphicsDevice, (tex) => roofless = FSO.Common.Utils.TextureUtils.Decimate(tex, GameFacade.GraphicsDevice, 2, false)); thumb = FSO.Common.Utils.TextureUtils.Decimate(thumb, GameFacade.GraphicsDevice, 2, false); alert.SetIcon(thumb, thumb.Width, thumb.Height); UIScreen.GlobalShowDialog(alert, true); } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { if (FSOEnvironment.SoftwareKeyboard) { CustomControl.MousePosition = new Point(UIScreen.Current.ScreenWidth / 2, UIScreen.Current.ScreenHeight / 2); } else { CustomControl.Modifiers = 0; if (state.CtrlDown) { CustomControl.Modifiers |= UILotControlModifiers.CTRL; } if (state.ShiftDown) { CustomControl.Modifiers |= UILotControlModifiers.SHIFT; } CustomControl.MousePosition = state.MouseState.Position; } CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse UpdateCutaway(state); if (RMBScrollX == int.MinValue) { Dummy(); //cannon fodder for mono AOT compilation: never called but gives these constructors a meaning in life } } }
public void ShowPieMenu(Point pt, UpdateState state) { if (!LiveMode) { /* * if (CustomControl != null) CustomControl.MouseDown(state); * else ObjectHolder.MouseDown(state); */ if (FSOEnvironment.SoftwareKeyboard && ObjectHolder.Holding == null) { 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.EstTileAtPosWithScroll(new Vector2(pt.X, pt.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); var newHover = World.GetObjectIDAtScreenPos(pt.X, pt.Y, GameFacade.GraphicsDevice); ObjectHover = newHover; bool objSelected = ObjectHover > 0; if (objSelected || (GotoObject.Position != LotTilePos.OUT_OF_WORLD && ObjectHover <= 0)) { if (objSelected) { obj = vm.GetObjectById(ObjectHover); } else { obj = GotoObject; } if (obj is VMAvatar && state.CtrlDown) { //debug switch to avatar vm.SendCommand(new VMNetChangeControlCmd() { TargetID = obj.ObjectID }); } else 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 { var menu = obj.GetPieMenu(vm, ActiveEntity, false, true); if (menu.Count != 0) { HITVM.Get().PlaySoundEvent(UISounds.PieMenuAppear); 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; } }
public override void Update(UpdateState state) { base.Update(state); if (!vm.Ready || vm.Context.Architecture == null) { return; } //handling smooth scaled zoom if (FSOEnvironment.Enable3D) { var s3d = ((WorldStateRC)World.State); s3d.Zoom3D += ((9.75f - (TargetZoom - 0.25f) * 10) - s3d.Zoom3D) / 10; } else { float BaseScale; WorldZoom targetZoom; if (TargetZoom < 0.5f) { targetZoom = WorldZoom.Far; BaseScale = 0.25f; } else if (TargetZoom < 1f) { targetZoom = WorldZoom.Medium; BaseScale = 0.5f; } else { targetZoom = WorldZoom.Near; BaseScale = 1f; } World.BackbufferScale = TargetZoom / BaseScale; if (World.State.Zoom != targetZoom) { World.State.Zoom = targetZoom; } WorldConfig.Current.SmoothZoom = false; } //Cheats.Update(state); //AvatarDS.Update(); if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. //if (ActiveEntity == null) ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); vm.Context.World.State.ScrollAnchor = null; FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } /* * if (ActiveEntity != null && BlockingDialog != null) * { * //are we still waiting on a blocking dialog? if not, cancel. * if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult))) * { * BlockingDialog.Close(); * LastDialogID = 0; * BlockingDialog = null; * } * }*/ if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (RMBScroll) { World.State.ScrollAnchor = null; Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; scrollBy /= FSOEnvironment.DPIScaleFactor; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4; angle += 8; angle %= 8; CursorType type = CursorType.ArrowUp; switch ((int)Math.Round(angle)) { case 0: type = CursorType.ArrowUp; break; case 1: type = CursorType.ArrowUpRight; break; case 2: type = CursorType.ArrowRight; break; case 3: type = CursorType.ArrowDownRight; break; case 4: type = CursorType.ArrowDown; break; case 5: type = CursorType.ArrowDownLeft; break; case 6: type = CursorType.ArrowLeft; break; case 7: type = CursorType.ArrowUpLeft; break; } GameFacade.Cursor.SetCursor(type); } World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate)); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (state.MouseState.RightButton != ButtonState.Pressed) { if (RMBScroll) { GameFacade.Cursor.SetCursor(CursorType.Normal); } RMBScroll = false; } if (!LiveMode && PieMenu != null) { PieMenu.RemoveSimScene(); this.Remove(PieMenu); PieMenu = null; } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { if (FSOEnvironment.SoftwareKeyboard) { CustomControl.MousePosition = new Point(UIScreen.Current.ScreenWidth / 2, UIScreen.Current.ScreenHeight / 2); } else { CustomControl.Modifiers = 0; if (state.CtrlDown) { CustomControl.Modifiers |= UILotControlModifiers.CTRL; } if (state.ShiftDown) { CustomControl.Modifiers |= UILotControlModifiers.SHIFT; } CustomControl.MousePosition = state.MouseState.Position; } CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse UpdateCutaway(state); if (RMBScrollX == int.MinValue) { Dummy(); //cannon fodder for mono AOT compilation: never called but gives these constructors a meaning in life } } }