public void MouseUp(UpdateState state) { MouseIsDown = false; if (Holding != null && Holding.Clicked) { if (Holding.CanPlace == VMPlacementError.Success) { //ExecuteEntryPoint(11); //User Placement var putDown = Holding; var pos = Holding.Group.BaseObject.Position; var badCategory = ((Holding.Group.BaseObject as VMGameObject)?.Disabled ?? 0).HasFlag(VMGameObjectDisableFlags.LotCategoryWrong); if (Holding.IsBought) { HITVM.Get().PlaySoundEvent(UISounds.ObjectMovePlace); vm.SendCommand(new VMNetMoveObjectCmd { ObjectID = Holding.MoveTarget, dir = Holding.Dir, level = pos.Level, x = pos.x, y = pos.y }); } else { if (badCategory) { Locked = true; UIAlert.YesNo(GameFacade.Strings.GetString("245", "5"), GameFacade.Strings.GetString("245", (Holding.InventoryPID > 0)?"7":"6"), true, (confirm) => { Locked = false; if (!confirm) return; HITVM.Get().PlaySoundEvent(UISounds.ObjectPlace); if (Holding.InventoryPID > 0) InventoryPlaceHolding(); else BuyHolding(); ClearSelected(); OnPutDown?.Invoke(putDown, state); //call this after so that buy mode etc can produce more. }); return; } else { HITVM.Get().PlaySoundEvent(UISounds.ObjectPlace); if (Holding.InventoryPID > 0) InventoryPlaceHolding(); else BuyHolding(); } } ClearSelected(); OnPutDown?.Invoke(putDown, state); //call this after so that buy mode etc can produce more. } else { } } state.UIState.TooltipProperties.Show = false; state.UIState.TooltipProperties.Opacity = 0; ShowTooltip = false; }
private void MButtonClick(UIElement button) { var controller = FindController <BulletinDialogController>(); //delete UIAlert.YesNo("", GameFacade.Strings.GetString("f120", "21"), true, (answer) => { if (answer) { //delete the message! controller.Delete(ActiveItem.ID); } }); }
private void RButtonClick(UIElement button) { if (AcceptSelections && Opacity == 1) { var controller = FindController <BulletinDialogController>(); if (EditorMode) { UIAlert.YesNo(GameFacade.Strings.GetString("f120", "33"), GameFacade.Strings.GetString("f120", "34"), true, (answer) => { if (answer) { //send the message! controller.MakePost(TitleEdit.CurrentText, BodyText.CurrentText, LotThumbButton.LotId, false); } }); } else { //delete or promote if (FindController <CoreGameScreenController>()?.IsMe(ActiveItem.SenderID) ?? false) { //delete UIAlert.YesNo("", GameFacade.Strings.GetString("f120", "21"), true, (answer) => { if (answer) { //delete the message! controller.Delete(ActiveItem.ID); } }); } else { //promote (should only be visible if post is community and player is mayor) UIAlert.YesNo("", GameFacade.Strings.GetString("f120", "20"), true, (answer) => { if (answer) { //promote the message! controller.Promote(ActiveItem.ID); } }); } } } }
private void GoBack(UIElement button) { if (AcceptSelections && Opacity == 1) { if (EditorMode && (TitleEdit.CurrentText.Length > 0 || BodyText.CurrentText.Length > 0)) { UIAlert.YesNo("", GameFacade.Strings.GetString("f120", "19"), true, (answer) => { if (answer) { OnBack?.Invoke(); } }); } else { OnBack?.Invoke(); } } }
private void DeletePost(UIElement btn) { UIAlert.YesNo("", "Are you sure you want to delete this rating?", true, (del) => { if (del) { var protocol = UIScreen.Current.FindController <CoreGameScreenController>()?.NeighborhoodProtocol; if (protocol != null) { protocol.DeleteRate(RatingID, (code) => { if (code == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS) { uint avaID = 0; if (uint.TryParse(protocol.LastMessage, out avaID) && avaID != 0) { var alert = UIAlert.YesNo("", "Rating deleted. Neighborhood ban the poster? (icon at top left of window)", false, (ban) => { if (ban) { NhoodGameplayBan(avaID); } }); alert.Add(new UIPersonButton() { AvatarId = avaID, FrameSize = UIPersonButtonSize.SMALL, Position = new Vector2(45, 3) }); } else { UIAlert.Alert("", "Rating deleted.", true); } } }); } } }); }
public void ModSetMayor() { UIAlert.Prompt("", "Enter an avatar name to set as the mayor of this Neighborhood.", true, (search) => { if (search == null) { return; } var cont = FSOFacade.Kernel.Get <GenericSearchController>(); cont.Search(search, true, avas => { if (avas == null || avas.Count == 0) { UIAlert.Alert("", "Could not find that avatar.", true); return; } var target = avas[0]; UIAlert.YesNo("", $"This action will replace the current mayor with {target.Result.Name}. Is this OK?", true, (response) => { if (response) { View.FindController <CoreGameScreenController>().NeighborhoodProtocol.SetMayor(NeighId, target.Result.EntityId, (success) => { if (success == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS) { UIAlert.Alert("", $"Successfully set the Mayor to {target.Result.Name}", true); ChangeTopic(); } }); } }); }); }); }
public void ClickLot(int x, int y) { var id = MapCoordinates.Pack((ushort)x, (ushort)y); var occupied = IsTileOccupied(x, y); DataService.Get <Lot>(id).ContinueWith(result => { if (occupied) { GameThread.InUpdate(() => { if (PlacingTownHall) { UIAlert.Alert("", GameFacade.Strings.GetString("f115", "51"), true); } else { Parent.ShowLotPage(id); } }); } else if (!Realestate.IsPurchasable((ushort)x, (ushort)y)) { return; } else if (PlacingTownHall && View.NeighGeom.NhoodNearestDB(x, y) != TownHallNhood) { UIAlert.Alert("", GameFacade.Strings.GetString("f115", "50", new string[] { TownHallNhoodName }), true); return; } else { if (PlacingTownHall) { //we don't particularly care about the price, //all we need to know is if it is in the correct nhood var ourCash = Parent.Screen.VisualBudget; _BuyLot = result.Result; if (ourCash < 2000) { UIAlert.Alert("", GameFacade.Strings.GetString("f115", "90"), true); } else { UIAlert.YesNo("", GameFacade.Strings.GetString("f115", "49"), true, (complete) => { if (complete) { if (!TownHallMove) { //User needs to name the property _LotBuyName = new UILotPurchaseDialog(); UIScreen.GlobalShowDialog(new DialogReference { Dialog = _LotBuyName, Controller = this, Modal = true, }); } else { PurchaseRegulator.Purchase(new Regulators.PurchaseLotRequest { X = _BuyLot.Lot_Location.Location_X, Y = _BuyLot.Lot_Location.Location_Y, Name = "", StartFresh = false, Mayor = true }); } } }); } } else { if (result.Result.Lot_Price == 0) { //We need to request the price DataService.Request(MaskedStruct.MapView_RollOverInfo_Lot_Price, id).ContinueWith(masked => { ShowLotBuyDialog((Lot)masked.Result); }); } else { //Good to show dialog ShowLotBuyDialog(result.Result); } } } }); }
public void Click(int level) { if (ReadOnly) { return; } HITVM.Get().PlaySoundEvent(UISounds.Click); if (level == CurrentUpgrade || level < 0 || level >= Items.Count) { HITVM.Get().PlaySoundEvent(UISounds.Error); return; } if (ActiveEntity.GhostImage) { var item = Items[level]; item.UpdateCanPurchase(); //make sure this is up to date. if (!item.CanPurchase) { HITVM.Get().PlaySoundEvent(UISounds.Error); return; } //object has not been bought yet //instantly switch the upgrade level. Notify the query panel that the level and price has changed. foreach (var obj in ActiveEntity.MultitileGroup.Objects) { var state = obj.PlatformState as VMTSOObjectState; if (state != null) { state.UpgradeLevel = (byte)level; } } var price = item.Price; ActiveEntity.MultitileGroup.InitialPrice = price; // notify the querypanel that it needs to update (Parent.Parent as UIQueryPanel)?.ReloadEntityInfo(false); PopulateUpgrades(); } else { //this upgrade will cost the user money immediately. display a dialog confirming the cost. if (level < CurrentUpgrade) { HITVM.Get().PlaySoundEvent(UISounds.Error); return; } var item = Items[level]; item.UpdateCanPurchase(); //make sure this is up to date. if (!item.CanPurchase) { HITVM.Get().PlaySoundEvent(UISounds.Error); return; } var price = item.TitlePrice.Caption.TrimStart('+'); UIAlert.YesNo( GameFacade.Strings.GetString("f125", "10", new string[] { item.Title.Caption }), GameFacade.Strings.GetString("f125", "11", new string[] { ActiveEntity.ToString(), item.Title.Caption, price }), true, (answer) => { if (answer) { //send the command to the VM! var vm = LotParent.vm; if (vm != null) { HITVM.Get().PlaySoundEvent(UISounds.ObjectPlace); vm.SendCommand( new VMNetUpgradeCmd() { ObjectPID = ActiveEntity.PersistID, TargetUpgradeLevel = (byte)level }); //register our waiting function for reloading vm.OnGenericVMEvent += ReloadUpgrades; } } }); } }
private void Regulator_OnTransition(string state, object data) { var progress = 0; GameThread.InUpdate(() => { switch (state) { case "Idle": if (Callbacks.Count > 0) { ResolveCallbacks(NhoodResponseCode.CANCEL); } if (BlockingDialog != null) { UIScreen.RemoveDialog(BlockingDialog); BlockingDialog = null; } break; case "ActionInput": //show blocking dialog for this action var req = ConnectionReg.CurrentRequest; switch (req.Type) { case NhoodRequestType.CAN_NOMINATE: //nomination dialog //12 - 16 var nomCont = new UINominationSelectContainer(ConnectionReg.CandidateList); BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions() { Title = GameFacade.Strings.GetString("f118", "12"), Message = GameFacade.Strings.GetString("f118", "13", new string[] { "your neighborhood" }), Width = 440, GenericAddition = nomCont, Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, (btn2) => { var newReq = nomCont.GetRequest(req); if (newReq != null) { UIAlert.YesNo( GameFacade.Strings.GetString("f118", "14"), GameFacade.Strings.GetString("f118", "15", new string[] { nomCont.SelectedCandidate.Name }), true, (result) => { if (result) { ConnectionReg.MakeRequest(newReq); } } ); } else { //tell user they should select a nominee } }, GameFacade.Strings.GetString("f118", "20")), new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => { ConnectionReg.AsyncReset(); }) } }, false); BlockingDialog.Opacity = 1; break; case NhoodRequestType.CAN_VOTE: //voting dialog BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions() { Title = GameFacade.Strings.GetString("f118", "2"), Message = GameFacade.Strings.GetString("f118", "3"), Width = 500, Buttons = UIAlertButton.Ok((btn) => { GameScreen.RemoveDialog(BlockingDialog); var votingCont = new UIVoteContainer(ConnectionReg.CandidateList); votingCont.OnVote += (id) => { if (id == 0) { ConnectionReg.AsyncReset(); } else { UIAlert.YesNo( GameFacade.Strings.GetString("f118", "9"), GameFacade.Strings.GetString("f118", "10", new string[] { votingCont.SelectedName }), true, (result) => { if (result) { ConnectionReg.MakeRequest(votingCont.MakeRequest(req)); } } ); } }; BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions() { Title = GameFacade.Strings.GetString("f118", "4"), Message = GameFacade.Strings.GetString("f118", "5"), Width = 600, GenericAddition = votingCont, Buttons = new UIAlertButton[0] }, false); votingCont.InjectClose(); BlockingDialog.Opacity = 1; }) }, true); break; case NhoodRequestType.CAN_RATE: //rating dialog var ratingCont = new UIRatingContainer(true); BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions() { Title = GameFacade.Strings.GetString("f115", "53"), Message = GameFacade.Strings.GetString("f115", "54"), Width = 450, GenericAddition = ratingCont, Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, (btn2) => { ConnectionReg.MakeRequest(ratingCont.GetRequest(req)); }), new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => { ConnectionReg.AsyncReset(); }) } }, true); BlockingDialog.Opacity = 1; break; case NhoodRequestType.CAN_RUN: //run dialog var runCont = new UIRatingContainer(false); BlockingDialog = UIScreen.GlobalShowAlert(new UIAlertOptions() { Title = GameFacade.Strings.GetString("f118", "17"), Message = GameFacade.Strings.GetString("f118", "18"), Width = 450, GenericAddition = runCont, Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, (btn2) => { ConnectionReg.MakeRequest(runCont.GetRunRequest(req)); }), new UIAlertButton(UIAlertButtonType.Cancel, (btn2) => { ConnectionReg.AsyncReset(); }) } }, true); BlockingDialog.Opacity = 1; break; default: //something went terribly wrong - we don't have any dialog to handle this. ConnectionReg.AsyncReset(); break; } break; case "ActionSuccess": LastMessage = ((NhoodResponse)data).Message; ResolveCallbacks(NhoodResponseCode.SUCCESS); break; } }); }