private void RateSwitch(UIElement button) { if (MayorIsMe || GameFacade.EnableMod) { CurrentMayorTab = UINeighMayorTabMode.Actions; Redraw(); } else { FindController <CoreGameScreenController>()?.NeighborhoodProtocol?.BeginRating (CurrentNeigh.Value?.Id ?? 0, CurrentNeigh.Value?.Neighborhood_MayorID ?? 0, (success) => { if (success == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS) { UIAlert.Alert("", GameFacade.Strings.GetString("f115", "97"), true); } GameThread.SetTimeout(() => { RefreshMayor(); }, 500); }); } }
private void SpecialResult(NhoodResponseCode code) { SpecialButton.Disabled = false; if (code == NhoodResponseCode.SUCCESS) { string title = GameFacade.Strings.GetString("f118", "1"); string message = ""; switch (SpecialType) { case MessageSpecialType.Nominate: message = GameFacade.Strings.GetString("f118", "16"); break; case MessageSpecialType.Vote: message = GameFacade.Strings.GetString("f118", "11"); break; case MessageSpecialType.AcceptNomination: message = GameFacade.Strings.GetString("f118", "19"); break; } UIAlert.Alert(title, message, true); } }
public void MakePost(string title, string message, uint lotID, bool system) { View.Post.Lock(); Actions?.MakePost(NhoodID, title, message, lotID, system, (result) => { if (result == BulletinResponseType.SUCCESS) { var posts = Actions.BulletinBoard; if (posts != null && Actions.CreatedMessage != null) { var newPosts = posts.ToList(); newPosts.Insert(0, Actions.CreatedMessage); posts = newPosts.ToArray(); Actions.BulletinBoard = posts; View.Board.InitBulletinItems(posts); } UIAlert.Alert("", GameFacade.Strings.GetString("f121", "3", new string[] { View.Post.IsMayor ? "1" : "3" }), true); View.Return(); } else { View.Post.Unlock(); } }); }
private void HandleLoadErrors() { UIAlert.Alert("Lot Load Error", $"An error occurred loading lot state. It is not recommended that you continue, as you will desync from the server repeatedly. \n\n" + $"Errors: \n{String.Join("\n", vm.LoadErrors.Select(x => x.ToString()))}\n\n" + $"Your best bet is reinstalling FreeSO or The Sims Online. If this appears repeatedly, you definitely have an issue. You should also post this message on discord.", true); vm.LoadErrors.Clear(); }
public void ChangeCategory(UIElement elem) { SeatingButton.Selected = false; SurfacesButton.Selected = false; DecorativeButton.Selected = false; ElectronicsButton.Selected = false; AppliancesButton.Selected = false; SkillButton.Selected = false; LightingButton.Selected = false; MiscButton.Selected = false; PetsButton.Selected = false; InventoryButton.Selected = false; UIButton button = (UIButton)elem; button.Selected = true; SetMode((elem == InventoryButton) ? 2 : 1); if (elem == InventoryButton) { if (CurrentCategory != CurrentInventory && LotController.ObjectHolder.DonateMode) { UIAlert.Alert(GameFacade.Strings.GetString("f114", "2"), GameFacade.Strings.GetString("f114", "3"), true); } CurrentCategory = CurrentInventory; } else { if (!CategoryMap.ContainsKey(button)) { return; } CurrentCategory = UICatalog.Catalog[CategoryMap[button]]; } Catalog.SetCategory(CurrentCategory); int total = Catalog.TotalPages(); OldSelection = -1; ProductCatalogSlider.MaxValue = total - 1; ProductCatalogSlider.Value = 0; InventoryCatalogRoommateSlider.MaxValue = total - 1; InventoryCatalogRoommateSlider.Value = 0; InventoryCatalogVisitorSlider.MaxValue = total - 1; InventoryCatalogVisitorSlider.Value = 0; ProductCatalogNextPageButton.Disabled = (total == 1); InventoryCatalogRoommateNextPageButton.Disabled = (total == 1); InventoryCatalogVisitorNextPageButton.Disabled = (total == 1); ProductCatalogPreviousPageButton.Disabled = true; InventoryCatalogRoommatePreviousPageButton.Disabled = true; InventoryCatalogVisitorPreviousPageButton.Disabled = true; return; }
public override void ChangeCategory(UIElement elem) { foreach (var btn in CategoryMap.Keys) { btn.Selected = false; } InventoryButton.Selected = false; UIButton button = (UIButton)elem; button.Selected = true; SetMode((elem == InventoryButton) ? 2 : 1); if (elem == InventoryButton) { if (CurrentCategory != CurrentInventory && LotController.ObjectHolder.DonateMode) { UIAlert.Alert(GameFacade.Strings.GetString("f114", "2"), GameFacade.Strings.GetString("f114", "3"), true); } CurrentCategory = CurrentInventory; } else { if (!CategoryMap.ContainsKey(button)) { return; } CurrentCategory = UICatalog.Catalog[CategoryMap[button]]; } Catalog.SetCategory(CurrentCategory); int total = Catalog.TotalPages(); OldSelection = -1; ProductCatalogSlider.MaxValue = total - 1; ProductCatalogSlider.Value = 0; InventoryCatalogRoommateSlider.MaxValue = total - 1; InventoryCatalogRoommateSlider.Value = 0; InventoryCatalogVisitorSlider.MaxValue = total - 1; InventoryCatalogVisitorSlider.Value = 0; ProductCatalogNextPageButton.Disabled = (total == 1); InventoryCatalogRoommateNextPageButton.Disabled = (total == 1); InventoryCatalogVisitorNextPageButton.Disabled = (total == 1); ProductCatalogPreviousPageButton.Disabled = true; InventoryCatalogRoommatePreviousPageButton.Disabled = true; InventoryCatalogVisitorPreviousPageButton.Disabled = true; return; }
public override void Update(UpdateState state) { base.Update(state); if (state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F1)) { FSOFacade.Controller.ToggleDebugMenu(); } if (state.ShiftDown && state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F10)) { GlobalSettings.Default.ClientVersion = "bad/version-23"; UIAlert.Alert("Update Force", "Holding shift and pressing F10 will force the next login to re-update. Useful for fixing weird issues! Try log in now.", true); } }
private void VMShutdown(VMCloseNetReason reason) { if (reason == VMCloseNetReason.NetException || reason == VMCloseNetReason.NetExceptionDirect) { UIAlert.Alert("Fatal Networking Error", Driver.CloseString, true); } var controller = FindController <CoreGameScreenController>(); if (controller != null) { controller.HandleVMShutdown(reason); } }
public TSOVersionPatchScreen() : base() { Background = new UISetupBackground(); Add(Background); Version = Content.Content.Get().VersionString; CanUpdate = Version == Patchable; GameThread.NextUpdate((state) => { UIAlert.Alert(GameFacade.Strings.GetString("f101", "14"), GameFacade.Strings.GetString("f101", "15", new string[] { Version, GameFacade.Strings.GetString("f101", CanUpdate ? "16" : "17") }), true); }); }
public void PlaceTownHall(bool move, uint nhoodID, string nhoodName) { if (PlacingTownHall) { return; } PlacingTownHall = true; TownHallMove = move; TownHallNhood = nhoodID; TownHallNhoodName = nhoodName; Parent.Screen.Title.SetOverrideMode( GameFacade.Strings.GetString("f115", move ? "47" : "46", new string[] { nhoodName }), () => { EndTownHall(); }); UIAlert.Alert("", GameFacade.Strings.GetString("f115", "91", new string[] { nhoodName }), true); }
public void MessageReceived(AriesClient client, object message) { if (client == City) { if (message is FindLotResponse) { AsyncProcessMessage(message); } } else if (client == Client) { if (message is RequestClientSession || message is HostOnlinePDU || message is FSOVMTickBroadcast || message is FSOVMDirectToClient || message is ServerByePDU) { if (message is ServerByePDU) { } //force in order this.SyncProcessMessage(message); } if (message is FSOVMProtocolMessage) { var msg = (FSOVMProtocolMessage)message; GameThread.InUpdate(() => { if (msg.UseCst) { if (msg.Title != "") { msg.Title = GameFacade.Strings.GetString("223", msg.Title); } msg.Message = GameFacade.Strings.GetString("223", msg.Message); } UIAlert.Alert(msg.Title, msg.Message, true); }); } } }
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); } } }); } } }); }
private void NhoodGameplayBan(uint avatarID) { var controller = UIScreen.Current.FindController <FSO.Client.Controllers.CoreGameScreenController>(); UIAlert.Prompt("Neighborhood Gameplay Ban", "Ban this user for how long? (in days, 0 for perma)", true, (result) => { if (result == null) { return; } uint dayCount; if (!uint.TryParse(result, out dayCount)) { UIAlert.Alert("Neighborhood Gameplay Ban", "Invalid number of days. Please try again.", true); } uint untilDate = (dayCount == 0) ? uint.MaxValue : ClientEpoch.Now + dayCount * 60 * 60 * 24; UIAlert.Prompt("Neighborhood Gameplay Ban", "What message do you want to leave? (optional)", true, (result2) => { if (result2 == null) { return; } if (controller != null) { controller.NeighborhoodProtocol.BanUser(avatarID, untilDate, result2, (code) => { //response if (code == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS) { UIAlert.Alert("Neighborhood Gameplay Ban", "Ban has been submitted. Note that if you ban someone twice your second ban will overwrite the first.", 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 override void Update(UpdateState state) { var objCount = LotController.vm.Context.ObjectQueries.NumUserObjects; if (LastObjCount != objCount || LastDonator != LotController.ObjectHolder.DonateMode) { if (LastDonator != LotController.ObjectHolder.DonateMode) { if (CurrentInventory != null && CurrentCategory == CurrentInventory && LotController.ObjectHolder.DonateMode) { UIAlert.Alert(GameFacade.Strings.GetString("f114", "2"), GameFacade.Strings.GetString("f114", "3"), true); } Catalog.SetPage(Catalog.Page); //update prices } if (LotController.ObjectHolder.DonateMode) { ObjLimitLabel.Caption = GameFacade.Strings.GetString("f114", "4"); ObjLimitLabel.CaptionStyle.Color = new Color(255, 201, 38); } else { var limit = LotController.vm.TSOState.ObjectLimit; ObjLimitLabel.Caption = objCount + "/" + limit + " Objects"; var lerp = objCount / (float)limit; if (lerp < 0.5) { ObjLimitLabel.CaptionStyle.Color = Color.White; } if (lerp < 0.75) { ObjLimitLabel.CaptionStyle.Color = Color.Lerp(Color.White, new Color(255, 201, 38), lerp * 4 - 2); } else { ObjLimitLabel.CaptionStyle.Color = Color.Lerp(new Color(255, 201, 38), Color.Red, lerp * 4 - 3); } } LastObjCount = objCount; LastDonator = LotController.ObjectHolder.DonateMode; } if (LotController.ActiveEntity != null) { Catalog.Budget = (int)LotController.Budget; bool refreshInventory = false; var inventory = LotController.vm.MyInventory; if (LastInventory != null) { if (LastInventory.Count != inventory.Count) { refreshInventory = true; } else { for (int i = 0; i < inventory.Count; i++) { if (LastInventory[i] != inventory[i]) { refreshInventory = true; break; } } } } else { refreshInventory = true; } if (refreshInventory) { var lastCatPage = Catalog.GetPage(); LastInventory = new List <VMInventoryItem>(inventory); if (CurrentInventory == null) { CurrentInventory = new List <UICatalogElement>(); } CurrentInventory.Clear(); foreach (var item in inventory) { var catItem = Content.Content.Get().WorldCatalog.GetItemByGUID(item.GUID); if (catItem == null) { catItem = GenCatItem(item.GUID); } var obj = catItem.Value; //note that catalog items are structs, so we can modify their properties freely without affecting the permanant store. //todo: what if this is null? it shouldn't be, but still obj.Name = (item.Name == "")?obj.Name:item.Name; obj.Price = 0; //todo: make icon for correct graphic. CurrentInventory.Add(new UICatalogElement { Item = obj, Attributes = item.Attributes ?? new List <int>(), Count = (item.AttributeMode == 2 && (item.Attributes?.Count ?? 0) > 0) ? item.Attributes[0] : (int?)null }); } if (Mode == 2) { ChangeCategory(InventoryButton); //refresh display SetPage(Math.Min(Catalog.TotalPages() - 1, lastCatPage)); } } } base.Update(state); }
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 UIModMenu() : base(UIDialogStyle.Tall | UIDialogStyle.Close, true) { SetSize(380, 300); Caption = "Do what to this user?"; Position = new Microsoft.Xna.Framework.Vector2( (GlobalSettings.Default.GraphicsWidth / 2.0f) - (480 / 2), (GlobalSettings.Default.GraphicsHeight / 2.0f) - 150 ); IPBanButton = new UIButton(); IPBanButton.Caption = "IP Ban"; IPBanButton.Position = new Microsoft.Xna.Framework.Vector2(40, 50); IPBanButton.Width = 300; IPBanButton.OnButtonClick += x => { var controller = FindController <FSO.Client.Controllers.CoreGameScreenController>(); if (controller != null) { controller.ModRequest(AvatarID, ModerationRequestType.IPBAN_USER); } UIScreen.RemoveDialog(this); }; Add(IPBanButton); var BanButton = new UIButton(); BanButton.Caption = "Ban User"; BanButton.Position = new Microsoft.Xna.Framework.Vector2(40, 90); BanButton.Width = 300; BanButton.OnButtonClick += x => { var controller = FindController <FSO.Client.Controllers.CoreGameScreenController>(); if (controller != null) { controller.ModRequest(AvatarID, ModerationRequestType.BAN_USER); } UIScreen.RemoveDialog(this); }; Add(BanButton); var kickButton = new UIButton(); kickButton.Caption = "Kick Avatar"; kickButton.Position = new Microsoft.Xna.Framework.Vector2(40, 130); kickButton.Width = 300; kickButton.OnButtonClick += x => { var controller = FindController <FSO.Client.Controllers.CoreGameScreenController>(); if (controller != null) { controller.ModRequest(AvatarID, ModerationRequestType.KICK_USER); } UIScreen.RemoveDialog(this); }; Add(kickButton); var nhoodBanButton = new UIButton(); nhoodBanButton.Caption = "Nhood Ban"; nhoodBanButton.Position = new Microsoft.Xna.Framework.Vector2(40, 170); nhoodBanButton.Width = 300; nhoodBanButton.OnButtonClick += x => { var controller = FindController <FSO.Client.Controllers.CoreGameScreenController>(); UIAlert.Prompt("Neighborhood Gameplay Ban", "Ban this user for how long? (in days, 0 for perma)", true, (result) => { if (result == null) { return; } uint dayCount; if (!uint.TryParse(result, out dayCount)) { UIAlert.Alert("Neighborhood Gameplay Ban", "Invalid number of days. Please try again.", true); } uint untilDate = (dayCount == 0) ? uint.MaxValue : ClientEpoch.Now + dayCount * 60 * 60 * 24; UIAlert.Prompt("Neighborhood Gameplay Ban", "What message do you want to leave? (optional)", true, (result2) => { if (result2 == null) { return; } if (controller != null) { controller.NeighborhoodProtocol.BanUser(AvatarID, untilDate, result2, (code) => { //response if (code == Server.Protocol.Electron.Packets.NhoodResponseCode.SUCCESS) { UIAlert.Alert("Neighborhood Gameplay Ban", "Ban has been submitted. Note that if you ban someone twice your second ban will overwrite the first.", true); } }); } }); }); }; Add(nhoodBanButton); //*MENTORS var changeMentorStatusButton = new UIButton(); changeMentorStatusButton.Caption = "Toggle Mentor Status"; changeMentorStatusButton.Position = new Microsoft.Xna.Framework.Vector2(40, 210); changeMentorStatusButton.Width = 300; changeMentorStatusButton.OnButtonClick += x => { var controller = FindController <FSO.Client.Controllers.CoreGameScreenController>(); if (controller != null) { controller.ModRequest(AvatarID, ModerationRequestType.CHANGE_MENTOR_STATUS); } UIScreen.RemoveDialog(this); }; Add(changeMentorStatusButton); CloseButton.OnButtonClick += CloseButton_OnButtonClick; }
public override void Update(FSO.Common.Rendering.Framework.Model.UpdateState state) { GameFacade.Game.IsFixedTimeStep = (vm == null || vm.Ready); Visible = World?.Visible == true && World?.State.Cameras.HideUI == false; GameFacade.Game.IsMouseVisible = Visible; if (state.WindowFocused && state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F1) && state.CtrlDown) { FSOFacade.Controller.ToggleDebugMenu(); } base.Update(state); if (state.WindowFocused && state.InputManager.GetFocus() == null) { if (state.NewKeys.Contains(Keys.D1) || (state.KeyboardState.NumLock && state.NewKeys.Contains(Keys.NumPad1))) { ChangeSpeedTo(1); } else if (state.NewKeys.Contains(Keys.D2) || (state.KeyboardState.NumLock && state.NewKeys.Contains(Keys.NumPad2))) { ChangeSpeedTo(2); } else if (state.NewKeys.Contains(Keys.D3) || (state.KeyboardState.NumLock && state.NewKeys.Contains(Keys.NumPad3))) { ChangeSpeedTo(3); } else if (state.NewKeys.Contains(Keys.P) || state.NewKeys.Contains(Keys.D0) || (state.KeyboardState.NumLock && state.NewKeys.Contains(Keys.NumPad0))) { ChangeSpeedTo(0); } } if (World != null) { //stub smooth zoom? if (state.NewKeys.Contains(Keys.F11)) { //render lot thumbnail test var thumb = World.GetLotThumb(GameFacade.GraphicsDevice, null); var alert = UIAlert.Alert("Thumbnail Test", ".", false); alert.SetIcon(thumb, thumb.Width, thumb.Height); alert.SetSize(thumb.Width + 100, thumb.Height + 100); } } lock (StateChanges) { while (StateChanges.Count > 0) { var e = StateChanges.Dequeue(); ClientStateChangeProcess(e.State, e.Progress); } } if (SwitchLot > 0) { InitializeLot(Path.Combine(Content.Content.Get().TS1BasePath, "UserData/Houses/House" + SwitchLot.ToString().PadLeft(2, '0') + ".iff"), false); SwitchLot = -1; } if (vm != null) { vm.Update(); } if (state.NewKeys.Contains(Microsoft.Xna.Framework.Input.Keys.F12) && GraphicsModeControl.Mode != GlobalGraphicsMode.Full2D) { GraphicsModeControl.ChangeMode((GraphicsModeControl.Mode == GlobalGraphicsMode.Full3D) ? GlobalGraphicsMode.Hybrid2D : GlobalGraphicsMode.Full3D); } }