public static UIAlert ShowAlert(UIAlertOptions options, bool modal) { var alert = new UIAlert(options); ShowDialog(alert, modal); alert.CenterAround(UIScreen.Current); return alert; }
public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true) { this.m_Options = options; this.Caption = options.Title; this.Opacity = 0.9f; m_TextStyle = TextStyle.DefaultLabel.Clone(); m_TextStyle.Size = 10; /** Determine the size **/ ComputeText(); //32 from either edge var w = options.Width; var h = options.Height; h = Math.Max(h, m_MessageText.BoundingBox.Height + 74); SetSize(w, h); /** Add buttons **/ var buttons = new List<UIButton>(); if (options.Buttons == UIAlertButtons.OK) buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, true)); else if (options.Buttons == UIAlertButtons.OKCancel) { buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, false)); buttons.Add(AddButton(GameFacade.Strings.GetString("142", "cancel button"), UIAlertButtons.Cancel, true)); } else if (options.Buttons == UIAlertButtons.Yes) buttons.Add(AddButton(GameFacade.Strings.GetString("142", "yes button"), UIAlertButtons.Yes, true)); else if(options.Buttons == UIAlertButtons.No) buttons.Add(AddButton(GameFacade.Strings.GetString("142", "no button"), UIAlertButtons.No, true)); else if(options.Buttons == UIAlertButtons.YesNo) { buttons.Add(AddButton(GameFacade.Strings.GetString("142", "yes button"), UIAlertButtons.Yes, false)); buttons.Add(AddButton(GameFacade.Strings.GetString("142", "no button"), UIAlertButtons.No, true)); } /** Position buttons **/ var btnX = (w - ((buttons.Count * 100) + ((buttons.Count - 1) * 45))) / 2; var btnY = h - 58; foreach (UIElement button in buttons) { button.Y = btnY; button.X = btnX; btnX += 150; } }
public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true) { this.m_Options = options; this.Caption = options.Title; this.Opacity = 0.9f; m_TextStyle = TextStyle.DefaultLabel.Clone(); m_TextStyle.Size = 10; /** Determine the size **/ ComputeText(); //32 from either edge var w = options.Width; var h = options.Height; h = Math.Max(h, m_MessageText.BoundingBox.Height + 74); SetSize(w, h); /** Add buttons **/ var buttons = new List <UIButton>(); if (options.Buttons == UIAlertButtons.OK) { buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, true)); } else if (options.Buttons == UIAlertButtons.OKCancel) { buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, false)); buttons.Add(AddButton(GameFacade.Strings.GetString("142", "cancel button"), UIAlertButtons.Cancel, true)); } /** Position buttons **/ var btnX = (w - ((buttons.Count * 100) + ((buttons.Count - 1) * 45))) / 2; var btnY = h - 58; foreach (UIElement button in buttons) { button.Y = btnY; button.X = btnX; btnX += 150; } }
public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true) { this.m_Options = options; this.Caption = options.Title; this.Opacity = 0.9f; m_TextStyle = TextStyle.DefaultLabel.Clone(); m_TextStyle.Size = options.TextSize; Icon = new UIImage(); Icon.Position = new Vector2(32, 32); Icon.SetSize(0, 0); Add(Icon); /** Determine the size **/ ComputeText(); /** Add buttons **/ Buttons = new List<UIButton>(); if (options.Buttons == UIAlertButtons.OK) Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, true)); else if (options.Buttons == UIAlertButtons.OKCancel) { Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK, false)); Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "cancel button"), UIAlertButtons.Cancel, true)); } else if (options.Buttons == UIAlertButtons.Yes) Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "yes button"), UIAlertButtons.Yes, true)); else if(options.Buttons == UIAlertButtons.No) Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "no button"), UIAlertButtons.No, true)); else if(options.Buttons == UIAlertButtons.YesNo) { Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "yes button"), UIAlertButtons.Yes, false)); Buttons.Add(AddButton(GameFacade.Strings.GetString("142", "no button"), UIAlertButtons.No, true)); } /** Position buttons **/ RefreshSize(); }
public UIAlert(UIAlertOptions options) : base(UIDialogStyle.Standard, true) { this.Options = options; this.Caption = options.Title; this.Opacity = 0.9f; TextStyle = TextStyle.DefaultLabel.Clone(); TextStyle.Size = 10; /** Determine the size **/ ComputeText(); //32 from either edge var w = options.Width; var h = options.Height; h = Math.Max(h, MessageText.BoundingBox.Height + 74); SetSize(w, h); /** Add buttons **/ var buttons = new List<UIButton>(); if ((options.Buttons & UIAlertButtons.OK) == UIAlertButtons.OK) { buttons.Add(AddButton(GameFacade.Strings.GetString("142", "ok button"), UIAlertButtons.OK)); } /** Position buttons **/ var btnX = (w - ((buttons.Count * 100) + ((buttons.Count - 1) * 45))) / 2; var btnY = h - 58; foreach (var button in buttons) { button.Y = btnY; button.X = btnX; btnX += 45; } }
private void SendMessage(UIElement button) { if (MessageType != UIMessageType.IM) return; SendMessageButton.Disabled = true; if (MessageTextEdit.CurrentText.Length == 0) return; //if they somehow get past the disabled button or press enter, don't send an empty message. AddMessage("Current User", MessageTextEdit.CurrentText); UIMessageController controller = GameFacade.MessageController; if (!String.IsNullOrEmpty(Author.GUID)) { lock (MessageTextEdit.CurrentText) { controller.SendMessage(MessageTextEdit.CurrentText, Author.GUID); MessageTextEdit.CurrentText = ""; } } else { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "Couldn't find player! Maybe their GUID wasn't sent from the server. Try reopening a chat window to this user."; Options.Title = "Player Offline"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); } }
/// <summary> /// A network error occured - 95% of the time, this will be because /// a connection could not be established. /// </summary> /// <param name="Exception">The exception that occured.</param> private void Controller_OnNetworkError(SocketException Exception) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "Couldn't connect! Server is busy or down."; Options.Title = "Network error"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; }
private void Controller_OnLotPurchaseFailed(Network.Events.TransactionEvent e) { UIAlertOptions AlertOptions = new UIAlertOptions(); AlertOptions.Title = GameFacade.Strings.GetString("246", "1"); if (Events.EventSink.EventQueue[0].ECode == Events.EventCodes.TRANSACTION_PLAYER_OUT_OF_MONEY) { //For now this says "Error! Transaction refused by server", because I couldn't find the right string. AlertOptions.Message = GameFacade.Strings.GetString("224", "16"); //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any //events that may have been added to the end. Events.EventSink.EventQueue.Remove(Events.EventSink.EventQueue[0]); } else { AlertOptions.Message = "General Error"; //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any //events that may have been added to the end. Events.EventSink.EventQueue.Remove(Events.EventSink.EventQueue[0]); } AlertOptions.Buttons = UIAlertButtons.OK; m_LotUnbuildableAlert = UIScreen.ShowAlert(AlertOptions, true); }
public override void Update(UpdateState state) { CoreGameScreen CurrentUIScr = (CoreGameScreen)GameFacade.Screens.CurrentUIScreen; if (Visible) { //if we're not visible, do not update CityRenderer state... m_LastMouseState = m_MouseState; m_MouseState = Mouse.GetState(); m_MouseMove = (m_MouseState.MiddleButton == ButtonState.Pressed); if (m_HandleMouse) { if (m_Zoomed) { m_SelTile = GetHoverSquare(); if (m_CanSend) { Network.UIPacketSenders.SendLotCostRequest(Network.NetworkFacade.Client, (short)m_SelTile[0], (short)m_SelTile[1]); m_CanSend = false; } } if (m_MouseState.MiddleButton == ButtonState.Pressed && m_LastMouseState.MiddleButton == ButtonState.Released) { m_MouseStart = new Vector2(m_MouseState.X, m_MouseState.Y); //if middle mouse button activated, record where we started pressing it (to use for panning) } else if (m_MouseState.LeftButton == ButtonState.Released && m_LastMouseState.LeftButton == ButtonState.Pressed) //if clicked... { if (!m_Zoomed) { m_Zoomed = true; double ResScale = 768.0 / m_ScrHeight; double isoScale = (Math.Sqrt(0.5 * 0.5 * 2) / 5.10) * ResScale; double hb = m_ScrWidth * isoScale; double vb = m_ScrHeight * isoScale; m_TargVOffX = (float)(-hb + m_MouseState.X * isoScale * 2); m_TargVOffY = (float)(vb - m_MouseState.Y * isoScale * 2); //zoom into approximate location of mouse cursor if not zoomed already } else { if (m_SelTile[0] != -1 && m_SelTile[1] != -1) { UIAlertOptions AlertOptions = new UIAlertOptions(); AlertOptions.Title = GameFacade.Strings.GetString("246", "1"); AlertOptions.Message = GameFacade.Strings.GetString("215", "23", new string[] { m_LotCost.ToString(), CurrentUIScr.ucp.MoneyText.Caption }); AlertOptions.Buttons = UIAlertButtons.YesNo; m_BuyPropertyAlert = UIScreen.ShowAlert(AlertOptions, true); m_BuyPropertyAlert.ButtonMap[UIAlertButtons.Yes].OnButtonClick += new ButtonClickDelegate(BuyPropertyAlert_OnButtonClick); } } CurrentUIScr.ucp.UpdateZoomButton(); } } else { m_SelTile = new int[] { -1, -1 }; } //m_SecondsBehind += time.ElapsedGameTime.TotalSeconds; //m_SecondsBehind -= 1 / 60; FixedTimeUpdate(); //SetTimeOfDay(m_DayNightCycle % 1); //calculates sun/moon light colour and position //m_DayNightCycle += 0.001; //adjust the cycle speed here. When ingame, set m_DayNightCycle to to the percentage of time passed through the day. (0 to 1) m_ViewOffX = (m_TargVOffX) * m_ZoomProgress; m_ViewOffY = (m_TargVOffY) * m_ZoomProgress; } }
/// <summary> /// A network error occured - 95% of the time, this will be because /// a connection could not be established. /// </summary> /// <param name="Exception">The exception that occured.</param> private void Controller_OnNetworkError(SocketException Exception) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = GameFacade.Strings.GetString("210", "36 301"); Options.Title = GameFacade.Strings.GetString("210", "40"); Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ //Note: A network error *should* never occur in this screen, so this code should never be called. GameFacade.Controller.ShowPersonSelection(); }
/// <summary> /// A network error occured - 95% of the time, this will be because /// a connection could not be established. /// </summary> /// <param name="Exception">The exception that occured.</param> private void Controller_OnNetworkError(SocketException Exception) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = GameFacade.Strings.GetString("210", "36 301"); Options.Title = GameFacade.Strings.GetString("210", "40"); Options.Buttons = UIAlertButtons.OK; var alert = UI.Framework.UIScreen.ShowAlert(Options, true); alert.ButtonMap[UIAlertButtons.OK].OnButtonClick += new TSOClient.LUI.ButtonClickDelegate(ErrorReturnAlert); /** Reset **/ //Note: A network error *should* never occur in this screen, so this code should never be called. //Note Note: ahahahaha good one you almost had me there }
private void Controller_OnLoginStatus(TSOClient.Network.Events.LoginEvent e) { m_InLogin = false; if (e.Success) { /** Save the username **/ GlobalSettings.Default.LastUser = LoginDialog.Username; GlobalSettings.Default.Save(); /** Go to the select a sim page, make sure we do this in the UIThread **/ GameFacade.Controller.ShowPersonSelection(); } else { if (e.VersionOK) { //EventQueue is static, so shouldn't need to be locked. if (EventSink.EventQueue[0].ECode == EventCodes.BAD_USERNAME || EventSink.EventQueue[0].ECode == EventCodes.BAD_PASSWORD) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = GameFacade.Strings.GetString("210", "26 110"); Options.Title = GameFacade.Strings.GetString("210", "21"); Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any //events that may have been added to the end. EventSink.EventQueue.Remove(EventSink.EventQueue[0]); } else if (EventSink.EventQueue[0].ECode == EventCodes.AUTHENTICATION_FAILURE) { //Restart authentication procedure. NetworkFacade.Controller.InitialConnect(LoginDialog.Username.ToUpper(), LoginDialog.Password.ToUpper()); //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any //events that may have been added to the end. EventSink.EventQueue.Remove(EventSink.EventQueue[0]); } /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; } else { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "Your client was not up to date!"; Options.Title = "Invalid version"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; } } }
/// <summary> /// User clicked the "Retire avatar" button. /// </summary> private void DeleteAvatarButton_OnButtonClick(UIElement button) { UIAlertOptions AlertOptions = new UIAlertOptions(); //These should be imported as strings for localization. AlertOptions.Title = "Are you sure?"; AlertOptions.Message = "Do you want to retire this Sim?"; AlertOptions.Buttons = UIAlertButtons.OKCancel; RetireCharAlert = UIScreen.ShowAlert(AlertOptions, true); RetireCharAlert.ButtonMap[UIAlertButtons.OK].OnButtonClick += new ButtonClickDelegate(PersonSlot_OnButtonClick); }
private void Controller_OnPlayerAlreadyOnline() { UIAlertOptions AlertOptions = new UIAlertOptions(); //These should be imported as strings for localization. AlertOptions.Title = "Character Already Online"; AlertOptions.Message = "You cannot play this character now, as it is already online."; AlertOptions.Buttons = UIAlertButtons.OK; UIScreen.ShowAlert(AlertOptions, false); }
private void Controller_OnLoginStatus(TSOClient.Network.Events.LoginEvent e) { m_InLogin = false; if (e.Success) { /** Go to the select a sim page, make sure we do this in the UIThread **/ GameFacade.Controller.ShowPersonSelection(); } else { if (e.VersionOK) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = GameFacade.Strings.GetString("210", "26 110"); Options.Title = GameFacade.Strings.GetString("210", "21"); Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; } else { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "Your client was not up to date!"; Options.Title = "Invalid version"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; } } }
private void AcceptButton_OnButtonClick(UIElement button) { var sim = new UISim(Guid.NewGuid(), false); sim.Name = NameTextEdit.CurrentText; sim.Sex = System.Enum.GetName(typeof(Gender), Gender); sim.Description = DescriptionTextEdit.CurrentText; sim.Timestamp = DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss", CultureInfo.InvariantCulture); sim.ResidingCity = SelectedCity; var selectedHead = (CollectionItem)((UIGridViewerItem)m_HeadSkinBrowser.SelectedItem).Data; var selectedBody = (CollectionItem)((UIGridViewerItem)m_BodySkinBrowser.SelectedItem).Data; var headPurchasable = Content.Get().AvatarPurchasables.Get(selectedHead.PurchasableOutfitId); var bodyPurchasable = Content.Get().AvatarPurchasables.Get(selectedBody.PurchasableOutfitId); sim.Head = Content.Get().AvatarOutfits.Get(headPurchasable.OutfitID); sim.HeadOutfitID = headPurchasable.OutfitID; sim.Body = Content.Get().AvatarOutfits.Get(bodyPurchasable.OutfitID); sim.BodyOutfitID = bodyPurchasable.OutfitID; sim.Handgroup = Content.Get().AvatarOutfits.Get(bodyPurchasable.OutfitID); sim.Avatar.Appearance = this.AppearanceType; PlayerAccount.CurrentlyActiveSim = sim; if (NetworkFacade.Avatars.Count <= 3) { lock(NetworkFacade.Avatars) NetworkFacade.Avatars.Add(sim); } else { UIAlertOptions Options = new UIAlertOptions(); Options.Message = "You've already created three characters!"; Options.Title = "Too Many Avatars"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); return; } //DateTime.Now.ToString() requires extremely specific formatting. UIPacketSenders.SendCharacterCreate(sim, DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss", CultureInfo.InvariantCulture)); }
/// <summary> /// A network error occured - 95% of the time, this will be because /// a connection could not be established. /// </summary> /// <param name="Exception">The exception that occured.</param> private void Controller_OnNetworkError(SocketException Exception) { UIAlertOptions Options = new UIAlertOptions(); Options.Message = GameFacade.Strings.GetString("210", "36 301"); Options.Title = GameFacade.Strings.GetString("210", "40"); Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); /** Reset **/ LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4"); LoginProgress.Progress = 0; m_InLogin = false; }
/// <summary> /// Received status of character creation from LoginServer. /// </summary> private void Controller_OnCharacterCreationStatus(CharacterCreationStatus CCStatus) { UIAlertOptions Options = new UIAlertOptions(); switch (CCStatus) { case CharacterCreationStatus.Success: GameFacade.Controller.ShowCityTransition(SelectedCity, true); break; case CharacterCreationStatus.NameAlreadyExisted: Options.Message = "Character's name already existed!"; Options.Title = "Name Already Existed"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); break; case CharacterCreationStatus.NameTooLong: Options.Message = "Character's name was too long!"; Options.Title = "Name Too Long"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); break; case CharacterCreationStatus.ExceededCharacterLimit: Options.Message = "You've already created three characters!"; Options.Title = "Too Many Avatars"; Options.Buttons = UIAlertButtons.OK; UI.Framework.UIScreen.ShowAlert(Options, true); break; } }
private void Controller_OnLotUnbuildable() { UIAlertOptions AlertOptions = new UIAlertOptions(); AlertOptions.Title = GameFacade.Strings.GetString("246", "1"); //This isn't exported as a string. WTF Maxis?? AlertOptions.Message = "This property cannot be purchased!\r\n"; AlertOptions.Buttons = UIAlertButtons.OK; m_LotUnbuildableAlert = UIScreen.ShowAlert(AlertOptions, true); }
/// <summary> /// Occurs when the client was not authenticated by the loginserver. /// Called by UILoginDialog.cs. /// </summary> /// <param name="Client">The client that received the packet.</param> /// <param name="Packet">The packet that was received.</param> /// <param name="Screen">A UIScreen instance on which to display a messagebox to inform the player of the /// failure state.</param> public static void OnLoginFailResponse(ref NetworkClient Client, PacketStream Packet) { byte Opcode = (byte)Packet.ReadByte(); switch (Packet.ReadByte()) { case 0x01: UIAlertOptions Options = new UIAlertOptions(); Options.Title = "Network error"; Options.Message = "Invalid username!"; Options.Buttons = UIAlertButtons.OK; UIScreen.ShowAlert(Options, true); break; case 0x02: Options = new UIAlertOptions(); Options.Title = "Network error"; Options.Message = "Invalid password!"; Options.Buttons = UIAlertButtons.OK; UIScreen.ShowAlert(Options, true); break; } Client.Disconnect(); }