void vm_OnDialog(FSO.SimAntics.Model.VMDialogInfo info) { if (info != null && ((info.DialogID == LastDialogID && info.DialogID != 0 && info.Block))) { return; } //return if same dialog as before, or not ours if ((info == null || info.Block) && BlockingDialog != null) { //cancel current dialog because it's no longer valid UIScreen.RemoveDialog(BlockingDialog); LastDialogID = 0; BlockingDialog = null; } if (info == null) { return; //return if we're just clearing a dialog. } var options = new UIAlertOptions { Title = info.Title, Message = info.Message, Width = 325 + (int)(info.Message.Length / 3.5f), Alignment = TextAlignment.Left, TextSize = 12 }; var b0Event = (info.Block) ? new ButtonClickDelegate(DialogButton0) : null; var b1Event = (info.Block) ? new ButtonClickDelegate(DialogButton1) : null; var b2Event = (info.Block) ? new ButtonClickDelegate(DialogButton2) : null; VMDialogType type = (info.Operand == null) ? VMDialogType.Message : info.Operand.Type; switch (type) { default: case VMDialogType.Message: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) }; break; case VMDialogType.YesNo: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.Yes, b0Event, info.Yes), new UIAlertButton(UIAlertButtonType.No, b1Event, info.No), }; break; case VMDialogType.YesNoCancel: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.Yes, b0Event, info.Yes), new UIAlertButton(UIAlertButtonType.No, b1Event, info.No), new UIAlertButton(UIAlertButtonType.Cancel, b2Event, info.Cancel), }; break; case VMDialogType.TextEntry: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) }; options.TextEntry = true; break; case VMDialogType.NumericEntry: if (!vm.TS1) { goto case VMDialogType.TextEntry; } else { goto case VMDialogType.TS1Neighborhood; } case VMDialogType.TS1Vacation: case VMDialogType.TS1Neighborhood: case VMDialogType.TS1StudioTown: case VMDialogType.TS1Magictown: TS1NeighSelector = new UINeighborhoodSelectionPanel((ushort)VMDialogPrivateStrings.TypeToNeighID[type]); Parent.Add(TS1NeighSelector); ((TS1GameScreen)Parent).Bg.Visible = true; ((TS1GameScreen)Parent).LotControl.Visible = false; TS1NeighSelector.OnHouseSelect += HouseSelected; return; case VMDialogType.TS1PhoneBook: var phone = new UICallNeighborAlert(((VMAvatar)info.Caller).GetPersonData(FSO.SimAntics.Model.VMPersonDataVariable.NeighborId), vm); BlockingDialog = phone; UIScreen.GlobalShowDialog(phone, true); phone.OnResult += (result) => { vm.SendCommand(new VMNetDialogResponseCmd { ActorUID = info.Caller.PersistID, ResponseCode = (byte)((result > 0) ? 1 : 0), ResponseText = result.ToString() }); BlockingDialog = null; }; return; case VMDialogType.TS1PetChoice: case VMDialogType.TS1Clothes: var ts1categories = new string[] { "b", "f", "s", "l", "w", "h" }; var pet = type == VMDialogType.TS1PetChoice; var stackObj = info.Caller.Thread.Stack.Last().StackObject; var skin = new UISelectSkinAlert(pet?null:(info.Caller as VMAvatar), pet?((stackObj as VMAvatar).IsCat?"cat":"dog"):ts1categories[info.Caller.Thread.TempRegisters[0]], vm); BlockingDialog = skin; UIScreen.GlobalShowDialog(skin, true); skin.OnResult += (result) => { vm.SendCommand(new VMNetDialogResponseCmd { ActorUID = info.Caller.PersistID, ResponseCode = (byte)((result > -1)?1:0), ResponseText = result.ToString() }); BlockingDialog = null; }; return; } var alert = new UIMobileAlert(options); UIScreen.GlobalShowDialog(alert, true); if (info.Block) { BlockingDialog = alert; LastDialogID = info.DialogID; } var entity = info.Icon; if (entity is VMGameObject) { var objects = entity.MultitileGroup.Objects; ObjectComponent[] objComps = new ObjectComponent[objects.Count]; for (int i = 0; i < objects.Count; i++) { objComps[i] = (ObjectComponent)objects[i].WorldUI; } var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice); alert.SetIcon(thumb, 256, 256); } }
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 } } }
void vm_OnDialog(FSO.SimAntics.Model.VMDialogInfo info) { if (info != null && ((info.DialogID == LastDialogID && info.DialogID != 0 && info.Block))) { return; } //return if same dialog as before, or not ours if ((info == null || info.Block) && BlockingDialog != null) { //cancel current dialog because it's no longer valid UIScreen.RemoveDialog(BlockingDialog); LastDialogID = 0; BlockingDialog = null; } if (info == null) { return; //return if we're just clearing a dialog. } var options = new UIAlertOptions { Title = info.Title, Message = info.Message, Width = 325 + (int)(info.Message.Length / 3.5f), Alignment = TextAlignment.Left, TextSize = 12 }; var b0Event = (info.Block) ? new ButtonClickDelegate(DialogButton0) : null; var b1Event = (info.Block) ? new ButtonClickDelegate(DialogButton1) : null; var b2Event = (info.Block) ? new ButtonClickDelegate(DialogButton2) : null; VMDialogType type = (info.Operand == null) ? VMDialogType.Message : info.Operand.Type; switch (type) { default: case VMDialogType.Message: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) }; break; case VMDialogType.YesNo: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.Yes, b0Event, info.Yes), new UIAlertButton(UIAlertButtonType.No, b1Event, info.No), }; break; case VMDialogType.YesNoCancel: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.Yes, b0Event, info.Yes), new UIAlertButton(UIAlertButtonType.No, b1Event, info.No), new UIAlertButton(UIAlertButtonType.Cancel, b2Event, info.Cancel), }; break; case VMDialogType.TextEntry: options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) }; options.TextEntry = true; break; case VMDialogType.NumericEntry: if (!vm.TS1) { goto case VMDialogType.TextEntry; } else { goto case VMDialogType.TS1Neighborhood; } case VMDialogType.TS1Vacation: case VMDialogType.TS1Neighborhood: case VMDialogType.TS1StudioTown: case VMDialogType.TS1Magictown: TS1NeighSelector = new UINeighborhoodSelectionPanel((ushort)VMDialogPrivateStrings.TypeToNeighID[type]); Parent.Add(TS1NeighSelector); ((TS1GameScreen)Parent).Bg.Visible = true; ((TS1GameScreen)Parent).LotControl.Visible = false; TS1NeighSelector.OnHouseSelect += HouseSelected; return; } var alert = new UIMobileAlert(options); UIScreen.GlobalShowDialog(alert, true); if (info.Block) { BlockingDialog = alert; LastDialogID = info.DialogID; } var entity = info.Icon; if (entity is VMGameObject) { var objects = entity.MultitileGroup.Objects; ObjectComponent[] objComps = new ObjectComponent[objects.Count]; for (int i = 0; i < objects.Count; i++) { objComps[i] = (ObjectComponent)objects[i].WorldUI; } var thumb = World.GetObjectThumb(objComps, entity.MultitileGroup.GetBasePositions(), GameFacade.GraphicsDevice); alert.SetIcon(thumb, 256, 256); } }