Exemplo n.º 1
0
 public static UIAlert ShowAlert(UIAlertOptions options, bool modal)
 {
     var alert = new UIAlert(options);
     ShowDialog(alert, modal);
     alert.CenterAround(UIScreen.Current);
     return alert;
 }
Exemplo n.º 2
0
        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>();

            foreach (var button in options.Buttons)
            {
                string buttonText = "";
                if (button.Text != null) buttonText = button.Text;
                else
                {
                    switch (button.Type)
                    {
                        case UIAlertButtonType.OK:
                            buttonText = GameFacade.Strings.GetString("142", "ok button");
                            break;
                        case UIAlertButtonType.Yes:
                            buttonText = GameFacade.Strings.GetString("142", "yes button");
                            break;
                        case UIAlertButtonType.No:
                            buttonText = GameFacade.Strings.GetString("142", "no button");
                            break;
                        case UIAlertButtonType.Cancel:
                            buttonText = GameFacade.Strings.GetString("142", "cancel button");
                            break;
                    }
                }
                var btnElem = AddButton(buttonText, button.Type, button.Handler == null);
                Buttons.Add(btnElem);
                if (button.Handler != null) btnElem.OnButtonClick += button.Handler;
            }

            if (options.TextEntry)
            {
                TextBox = new UITextBox();
                this.Add(TextBox);
            }

            /** Position buttons **/
            RefreshSize();
        }
Exemplo n.º 3
0
        public static void Prompt(UIAlertOptions options, Action <bool, UIAlert> resultBox)
        {
            UIAlert alert = null;

            options.Buttons = UIAlertButton.YesNo((btn) =>
            {
                resultBox(true, alert);
                UIScreen.RemoveDialog(alert);
            }, (btn) =>
            {
                resultBox(false, alert);
                UIScreen.RemoveDialog(alert);
            });
            alert = UIScreen.GlobalShowAlert(options, true);
        }
Exemplo n.º 4
0
 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";
     m_LotUnbuildableAlert = UIScreen.ShowAlert(AlertOptions, true);
 }
Exemplo n.º 5
0
        private void Controller_OnLotPurchaseFailed(Network.Events.TransactionEvent e)
        {
            UIAlertOptions AlertOptions = new UIAlertOptions();
            AlertOptions.Title = GameFacade.Strings.GetString("246", "1");

            if (EventSink.EventQueue[0].ECode == 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.
                EventSink.EventQueue.Remove(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.
                EventSink.EventQueue.Remove(EventSink.EventQueue[0]);
            }
            m_LotUnbuildableAlert = UIScreen.ShowAlert(AlertOptions, true);
        }
Exemplo n.º 6
0
        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";
                UI.Framework.UIScreen.ShowAlert(Options, true);
            }
        }
Exemplo n.º 7
0
        /// <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");
            var alert = UI.Framework.UIScreen.ShowAlert(Options, true);

            alert.ButtonMap[UIAlertButtonType.OK].OnButtonClick += new 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
        }
Exemplo n.º 8
0
        /// <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";
                    UI.Framework.UIScreen.ShowAlert(Options, true);
                    break;
                case CharacterCreationStatus.NameTooLong:
                    Options.Message = "Character's name was too long!";
                    Options.Title = "Name Too Long";
                    UI.Framework.UIScreen.ShowAlert(Options, true);
                    break;
                case CharacterCreationStatus.ExceededCharacterLimit:
                    Options.Message = "You've already created three characters!";
                    Options.Title = "Too Many Avatars";
                    UI.Framework.UIScreen.ShowAlert(Options, true);
                    break;
            }
        }
Exemplo n.º 9
0
        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();

            if (options.ProgressBar)
            {
                _ProgressBar          = new UIProgressBar();
                _ProgressBar.Mode     = ProgressBarMode.Animated;
                _ProgressBar.Position = new Microsoft.Xna.Framework.Vector2(32, 0);
                _ProgressBar.SetSize(options.Width - 64, 26);
                this.Add(_ProgressBar);
            }

            /** Add buttons **/
            Buttons = new List <UIButton>();

            foreach (var button in options.Buttons)
            {
                string buttonText = "";
                if (button.Text != null)
                {
                    buttonText = button.Text;
                }
                else
                {
                    switch (button.Type)
                    {
                    case UIAlertButtonType.OK:
                        buttonText = GameFacade.Strings.GetString("142", "ok button");
                        break;

                    case UIAlertButtonType.Yes:
                        buttonText = GameFacade.Strings.GetString("142", "yes button");
                        break;

                    case UIAlertButtonType.No:
                        buttonText = GameFacade.Strings.GetString("142", "no button");
                        break;

                    case UIAlertButtonType.Cancel:
                        buttonText = GameFacade.Strings.GetString("142", "cancel button");
                        break;
                    }
                }
                var btnElem = AddButton(buttonText, button.Type, button.Handler == null);
                Buttons.Add(btnElem);
                if (button.Handler != null)
                {
                    btnElem.OnButtonClick += button.Handler;
                }
            }

            if (options.TextEntry)
            {
                TextBox          = new UITextBox();
                TextBox.MaxChars = options.MaxChars;
                this.Add(TextBox);
            }

            if (options.Color)
            {
                ColorEntry = new UIColorPicker();
                Add(ColorEntry);
            }

            /** Position buttons **/
            RefreshSize();
        }
Exemplo n.º 10
0
        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.";

            UIScreen.ShowAlert(AlertOptions, false);
        }
Exemplo n.º 11
0
        /// <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 = new UIAlertButton[] {
                new UIAlertButton(UIAlertButtonType.OK, new ButtonClickDelegate(PersonSlot_OnButtonClick)),
                new UIAlertButton(UIAlertButtonType.Cancel)
            };

            RetireCharAlert = UIScreen.ShowAlert(AlertOptions, true);
        }
Exemplo n.º 12
0
        void vm_OnDialog(FSO.SimAntics.Model.VMDialogInfo info)
        {
            if (info != null && ((info.DialogID == LastDialogID && info.DialogID != 0 && info.Block)
                || info.Caller != null && info.Caller != ActiveEntity)) 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:
                case VMDialogType.NumericEntry:
                    options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) };
                    options.TextEntry = true;
                    break;
            }

            var alert = UIScreen.ShowAlert(options, 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, 110, 110);
            }
        }
Exemplo n.º 13
0
        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.RightButton == 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.RightButton == ButtonState.Pressed && m_LastMouseState.RightButton == 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)
                            {
                                m_SelTileTmp[0] = m_SelTile[0];
                                m_SelTileTmp[1] = m_SelTile[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 = new UIAlertButton[] {
                                    new UIAlertButton(UIAlertButtonType.Yes, new ButtonClickDelegate(BuyPropertyAlert_OnButtonClick)),
                                    new UIAlertButton(UIAlertButtonType.No) };

                                m_BuyPropertyAlert = UIScreen.ShowAlert(AlertOptions, true);
                            }
                        }

                        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;
            }
        }
Exemplo n.º 14
0
        /// <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");
            UI.Framework.UIScreen.ShowAlert(Options, true);

            /** Reset **/
            LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
            LoginProgress.Progress = 0;
            m_InLogin = false;
        }
Exemplo n.º 15
0
        private void Controller_OnLoginStatus(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");
                        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";
                    UI.Framework.UIScreen.ShowAlert(Options, true);

                    /** Reset **/
                    LoginProgress.ProgressCaption = GameFacade.Strings.GetString("210", "4");
                    LoginProgress.Progress = 0;
                    m_InLogin = false;
                }
            }
        }
Exemplo n.º 16
0
        void vm_OnDialog(FSO.SimAntics.Model.VMDialogInfo info)
        {
            if (info.Caller != null && info.Caller != ActiveEntity) return;

            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;

            switch (info.Operand.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:
                case VMDialogType.NumericEntry:
                    options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes) };
                    options.TextEntry = true;
                    break;
            }

            var alert = UIScreen.ShowAlert(options, true);

            if (info.Block) BlockingDialog = alert;

            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, 110, 110);
            }
        }