Exemplo n.º 1
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.º 2
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.º 3
0
        /// <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();
        }
Exemplo n.º 4
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.º 5
0
        public static UIAlert GlobalShowAlert(UIAlertOptions options, bool modal)
        {
            var alert = new UIAlert(options);

            GlobalShowDialog(alert, modal);
            alert.CenterAround(UIScreen.Current, -(int)UIScreen.Current.X * 2, -(int)UIScreen.Current.Y * 2);
            return(alert);
        }
Exemplo n.º 6
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;
                }
            }
        }
        private void ShowError(ErrorMessage errorMsg)
        {
            /** Error message intended for the user **/
            UIAlertOptions Options = new UIAlertOptions();

            Options.Message = errorMsg.Message;
            Options.Title   = errorMsg.Title;
            Options.Buttons = errorMsg.Buttons;
            UIScreen.GlobalShowAlert(Options, true);
        }
Exemplo n.º 8
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);
        }
        void ShowError(ErrorMessage errorMsg)
        {
            /** Error message intended for the user **/
            var Options = new UIAlertOptions
            {
                Message = errorMsg.Message,
                Title   = errorMsg.Title,
                Buttons = errorMsg.Buttons
            };

            UIScreen.GlobalShowAlert(Options, true);
        }
Exemplo n.º 10
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.º 11
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.º 12
0
        private void ShowNormalLotBuy(string price, string ourCash)
        {
            UIAlertOptions AlertOptions = new UIAlertOptions();

            AlertOptions.Title   = GameFacade.Strings.GetString("246", "1");
            AlertOptions.Message = GameFacade.Strings.GetString("215", "23", new string[] { price, ourCash });
            AlertOptions.Buttons = new UIAlertButton[] {
                new UIAlertButton(UIAlertButtonType.Yes, new ButtonClickDelegate(BuyPropertyAlert_OnButtonClick)),
                new UIAlertButton(UIAlertButtonType.No, BuyPropertyAlert_OnCancel)
            };

            _LotBuyAlert = UIScreen.GlobalShowAlert(AlertOptions, true);
        }
Exemplo n.º 13
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 = UIAlertButtons.OKCancel;

            RetireCharAlert = UIScreen.ShowAlert(AlertOptions, true);
            RetireCharAlert.ButtonMap[UIAlertButtons.OK].OnButtonClick +=
                new ButtonClickDelegate(PersonSlot_OnButtonClick);
        }
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");
            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();
        }
Exemplo n.º 15
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 = "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;
        }
Exemplo n.º 16
0
        /// <summary>
        /// User clicked the "Retire avatar" button.
        /// </summary>
        private void DeleteAvatarButton_OnButtonClick(UIElement button)
        {
            if (Avatar == null)
            {
                return;
            }

            UIAlertOptions AlertOptions = new UIAlertOptions();

            AlertOptions.Title   = GameFacade.Strings.GetString("169", "9");
            AlertOptions.Message = GameFacade.Strings.GetString("169", "10");
            AlertOptions.Buttons = new UIAlertButton[] {
                new UIAlertButton(UIAlertButtonType.OK, new ButtonClickDelegate(PersonSlot_OnButtonClick)),
                new UIAlertButton(UIAlertButtonType.Cancel)
            };

            UIScreen.GlobalShowAlert(AlertOptions, true);
        }
Exemplo n.º 17
0
        private void SelectSimButton_OnButtonClick(UIElement button)
        {
            UIAlert alert   = null;
            var     options = new UIAlertOptions
            {
                Title   = GameFacade.Strings.GetString("185", "6"),
                Message = GameFacade.Strings.GetString("185", "7"),
                Buttons = new UIAlertButton[]
                {
                    new UIAlertButton(UIAlertButtonType.Yes, (btn) => {
                        FSOFacade.Controller.Disconnect();
                        UIScreen.RemoveDialog(alert);
                    }),
                    new UIAlertButton(UIAlertButtonType.No, (btn) => { UIScreen.RemoveDialog(alert); })
                }
            };

            alert = UIScreen.GlobalShowAlert(options, true);
        }
Exemplo n.º 18
0
        private void AuthRegulator_OnError(object error)
        {
            if (error is Exception)
            {
                error = ErrorMessage.FromLiteral(GameFacade.Strings.GetString("210", "17"));
            }

            if (error is ErrorMessage)
            {
                ErrorMessage errorMsg = (ErrorMessage)error;

                /** Error message intended for the user **/
                UIAlertOptions Options = new UIAlertOptions();
                Options.Message = errorMsg.Message;
                Options.Title   = errorMsg.Title;
                Options.Buttons = errorMsg.Buttons;
                GlobalShowAlert(Options, true);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// User clicked the "Retire avatar" button.
        /// </summary>
        private void DeleteAvatarButton_OnButtonClick(UIElement button)
        {
            if (Avatar == null)
            {
                return;
            }

            UIAlertOptions AlertOptions = new UIAlertOptions();
            UIAlert        alert        = null;

            AlertOptions.Title   = GameFacade.Strings.GetString("169", "9");
            AlertOptions.Message = GameFacade.Strings.GetString("169", "10");
            AlertOptions.Buttons = new UIAlertButton[] {
                new UIAlertButton(UIAlertButtonType.OK, (btn) => {
                    FSOFacade.Controller.RetireAvatar(Avatar.ShardName, Avatar.ID);
                }),
                new UIAlertButton(UIAlertButtonType.Cancel)
            };

            alert = UIScreen.GlobalShowAlert(AlertOptions, true);
        }
Exemplo n.º 20
0
        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;
                }
            }
        }
Exemplo n.º 21
0
        private void AuthRegulator_OnError(object error)
        {
            if (error is Exception)
            {
                error = ErrorMessage.FromLiteral(error.ToString());// GameFacade.Strings.GetString("210", "17"));
            }

            if (error is ErrorMessage)
            {
                ErrorMessage errorMsg = (ErrorMessage)error;

                if (errorMsg.Message.StartsWith("INV-110"))
                {
                    LoginDialog.ClearPassword();
                }

                /** Error message intended for the user **/
                UIAlertOptions Options = new UIAlertOptions();
                Options.Message = errorMsg.Message;
                Options.Title   = errorMsg.Title;
                Options.Buttons = errorMsg.Buttons;
                LastAlert       = GlobalShowAlert(Options, true);
            }
        }
Exemplo n.º 22
0
        private void ShowLotBuyDialog(Lot lot)
        {
            GameThread.InUpdate(() =>
            {
                GameFacade.Cursor.SetCursor(Common.Rendering.Framework.CursorType.Hourglass);
                if (_LotBuyAlert != null)
                {
                    return;
                }
                _LotBuyAlert = new UIAlert(new UIAlertOptions()
                {
                    Title = "", Message = ""
                });                                                                            //just fill this space til we spawn the dialog.
                _BuyLot = lot;
                Parent.Screen.CityTooltipHitArea.HideTooltip();

                var price   = lot.Lot_Price;
                var ourCash = Parent.Screen.VisualBudget;


                DataService.Request(MaskedStruct.SimPage_Main, Network.MyCharacter).ContinueWith(x =>
                {
                    var avatar = x.Result as Avatar;
                    if (!x.IsFaulted && avatar != null && avatar.Avatar_LotGridXY != 0)
                    {
                        //we already have a lot. We need to show the right dialog depending on whether or not we're owner.
                        var oldID = avatar.Avatar_LotGridXY;
                        DataService.Request(MaskedStruct.PropertyPage_LotInfo, oldID).ContinueWith(y =>
                        {
                            GameThread.SetTimeout(() => //setting a timeout here because for some reason when the request finishes we might not have all of the data yet...
                            {
                                GameFacade.Cursor.SetCursor(Common.Rendering.Framework.CursorType.Normal);
                                bool canBuy = true;
                                if (!y.IsFaulted && y.Result != null)
                                {
                                    var old = (Lot)y.Result;
                                    UIAlertOptions AlertOptions = new UIAlertOptions();
                                    if (old.Lot_LeaderID == Network.MyCharacter)
                                    {
                                        //we are the owner
                                        var oldVal   = old.Lot_Price;
                                        var moveFee  = 2000;
                                        var moveCost = moveFee + price;

                                        canBuy = (moveCost - oldVal) <= ourCash;
                                        if (old.Lot_RoommateVec.Count > 1)
                                        {
                                            //we have other roommates.
                                            AlertOptions.Title   = GameFacade.Strings.GetString("215", "10");
                                            AlertOptions.Message = GameFacade.Strings.GetString("215", "12",
                                                                                                new string[] { "$" + price.ToString(), "$" + ourCash.ToString(), "$" + moveCost.ToString(), "$" + moveFee.ToString(), "$" + oldVal.ToString() });
                                            AlertOptions.Buttons = new UIAlertButton[] {
                                                new UIAlertButton(UIAlertButtonType.Yes, (button) => { MoveLot(false); }, GameFacade.Strings.GetString("215", "14")),
                                                new UIAlertButton(UIAlertButtonType.Cancel, BuyPropertyAlert_OnCancel)
                                            };
                                        }
                                        else
                                        {
                                            //we live alone
                                            AlertOptions.Title   = GameFacade.Strings.GetString("215", "10");
                                            AlertOptions.Message = GameFacade.Strings.GetString("215", "16",
                                                                                                new string[] { "$" + price.ToString(), "$" + ourCash.ToString(), "$" + moveCost.ToString(), "$" + moveFee.ToString(), "$" + oldVal.ToString() });
                                            AlertOptions.Buttons = new UIAlertButton[] {
                                                new UIAlertButton(UIAlertButtonType.OK, (button) => { MoveLot(false); }, GameFacade.Strings.GetString("215", "17")),
                                                new UIAlertButton(UIAlertButtonType.Yes, (button) => { MoveLot(true); }, GameFacade.Strings.GetString("215", "18")),
                                                new UIAlertButton(UIAlertButtonType.Cancel, BuyPropertyAlert_OnCancel)
                                            };
                                        }
                                    }
                                    else
                                    {
                                        //we are a roommate.
                                        //can leave and start a new lot with no issue.
                                        canBuy               = price <= ourCash;
                                        AlertOptions.Title   = GameFacade.Strings.GetString("215", "10");
                                        AlertOptions.Message = GameFacade.Strings.GetString("215", "20", new string[] { "$" + price.ToString(), "$" + ourCash.ToString() });
                                        AlertOptions.Buttons = new UIAlertButton[] {
                                            new UIAlertButton(UIAlertButtonType.Yes, (btn) => {
                                                UIScreen.RemoveDialog(_LotBuyAlert);
                                                _LotBuyAlert = UIScreen.GlobalShowAlert(new UIAlertOptions()
                                                {
                                                    Message = GameFacade.Strings.GetString("211", "57"),
                                                    Buttons = new UIAlertButton[0]
                                                }, true);
                                                Parent.MoveMeOut(oldID, (result) => {
                                                    if (result)
                                                    {
                                                        BuyPropertyAlert_OnButtonClick(btn);
                                                    }
                                                });
                                            }),
                                            new UIAlertButton(UIAlertButtonType.No, BuyPropertyAlert_OnCancel)
                                        };
                                    }

                                    AlertOptions.Width = 600;
                                    _LotBuyAlert       = UIScreen.GlobalShowAlert(AlertOptions, true);
                                    UIButton toDisable;
                                    if (_LotBuyAlert.ButtonMap.TryGetValue(UIAlertButtonType.OK, out toDisable))
                                    {
                                        toDisable.Disabled = !canBuy;
                                    }
                                    if (_LotBuyAlert.ButtonMap.TryGetValue(UIAlertButtonType.Yes, out toDisable))
                                    {
                                        toDisable.Disabled = !canBuy;
                                    }
                                }
                                else
                                {
                                    canBuy = price <= ourCash;
                                    ShowNormalLotBuy("$" + price.ToString(), "$" + ourCash.ToString());
                                    UIButton toDisable;
                                    if (_LotBuyAlert.ButtonMap.TryGetValue(UIAlertButtonType.Yes, out toDisable))
                                    {
                                        toDisable.Disabled = !canBuy;
                                    }
                                }
                            }, 100);
                        });
                    }
                    else
                    {
                        //we don't have a lot
                        _LotBuyAlert = null;
                        ShowNormalLotBuy("$" + price.ToString(), "$" + ourCash.ToString());
                        var canBuy = price <= ourCash;
                        UIButton toDisable;
                        if (_LotBuyAlert.ButtonMap.TryGetValue(UIAlertButtonType.Yes, out toDisable))
                        {
                            toDisable.Disabled = !canBuy;
                        }
                        GameFacade.Cursor.SetCursor(Common.Rendering.Framework.CursorType.Normal);
                    }
                });
            });
        }
Exemplo n.º 23
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
            };

            if (info.Block && vm.TS1)
            {
                vm.SpeedMultiplier = 0;
            }
            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);
                TS1NeighSelector.OnHouseSelect += HouseSelected;
                return;

            case VMDialogType.FSOColor:
                options.Buttons = new UIAlertButton[] { new UIAlertButton(UIAlertButtonType.OK, b0Event, info.Yes), new UIAlertButton(UIAlertButtonType.Cancel, b1Event, info.Cancel) };
                options.Color   = true;
                break;
            }

            var alert = UIScreen.GlobalShowAlert(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.º 24
0
        public UIMobileAlert(UIAlertOptions options) : base()
        {
            this.m_Options = options;

            m_TextStyle       = TextStyle.DefaultLabel.Clone();
            m_TextStyle.Size  = 19;
            m_TextStyle.Color = Color.White;

            Caption = options.Title;

            Icon          = new UIImage();
            Icon.Visible  = false;
            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", "0");
                        break;

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

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

                    case UIAlertButtonType.Cancel:
                        buttonText = GameFacade.Strings.GetString("142", "1");
                        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);
            }

            /** Position buttons **/
            RefreshSize();
        }
Exemplo n.º 25
0
        public UIGizmo()
        {
            TabV = Tab;

            var ui = this.RenderScript("gizmo.uis");

            BackgroundImageGizmo = ui.Create <UIImage>("BackgroundImageGizmo");
            this.AddAt(0, BackgroundImageGizmo);

            BackgroundImageGizmoPanel = ui.Create <UIImage>("BackgroundImageGizmoPanel");
            this.AddAt(0, BackgroundImageGizmoPanel);

            BackgroundImagePanel = ui.Create <UIImage>("BackgroundImagePanel");
            this.AddAt(0, BackgroundImagePanel);

            UIUtils.MakeDraggable(BackgroundImageGizmo, this);
            UIUtils.MakeDraggable(BackgroundImageGizmoPanel, this);
            UIUtils.MakeDraggable(BackgroundImagePanel, this);

            ButtonContainer = new UIContainer();
            this.Remove(ExpandButton);
            ButtonContainer.Add(ExpandButton);
            this.Remove(ContractButton);
            ButtonContainer.Add(ContractButton);
            this.Remove(FiltersButton);
            ButtonContainer.Add(FiltersButton);
            this.Remove(SearchButton);
            ButtonContainer.Add(SearchButton);
            this.Remove(Top100ListsButton);
            ButtonContainer.Add(Top100ListsButton);
            this.Add(ButtonContainer);

            FiltersProperty         = new UIGizmoPropertyFilters(ui, this);
            FiltersProperty.Visible = false;
            this.Add(FiltersProperty);

            Search         = new UIGizmoSearch(ui, this);
            Search.Visible = false;
            this.Add(Search);

            Top100                    = new UIGizmoTop100(ui, this);
            Top100.Visible            = false;
            Top100.Background.Visible = false;
            this.Add(Top100);

            ExpandButton.OnButtonClick   += new ButtonClickDelegate(ExpandButton_OnButtonClick);
            ContractButton.OnButtonClick += new ButtonClickDelegate(ContractButton_OnButtonClick);

            PeopleTabButton.OnButtonClick += new ButtonClickDelegate(PeopleTabButton_OnButtonClick);
            HousesTabButton.OnButtonClick += new ButtonClickDelegate(HousesTabButton_OnButtonClick);

            FiltersButton.OnButtonClick     += new ButtonClickDelegate(FiltersButton_OnButtonClick);
            SearchButton.OnButtonClick      += new ButtonClickDelegate(SearchButton_OnButtonClick);
            Top100ListsButton.OnButtonClick += new ButtonClickDelegate(Top100ListsButton_OnButtonClick);

            if (PlayerAccount.CurrentlyActiveSim != null)
            {
                SimBox = new UISim(PlayerAccount.CurrentlyActiveSim.GUID.ToString());
            }
            else
            {
                SimBox = new UISim("");
            }

            MessageDialog                 = new UIAlertOptions();
            MessageDialog.Message         = "No avatar has been selected";
            MessageDialog.Title           = "Avatar selectioin";
            MessageDialog.Buttons[0].Type = UIAlertButtonType.OK;


            View = UIGizmoView.Top100;
            SetOpen(true);


            TabV = UIGizmoTab.People;
        }
Exemplo n.º 26
0
        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);
            }
        }
Exemplo n.º 27
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;

            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;
            }

            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.º 28
0
        public override void Update(UpdateState state)
        {
            if (Visible)
            {  //if we're not visible, do not update CityRenderer state...
                CoreGameScreen CurrentUIScr = (CoreGameScreen)GameFacade.Screens.CurrentUIScreen;

                m_LastMouseState = m_MouseState;
                m_MouseState     = Mouse.GetState();

                m_MouseMove = (m_MouseState.RightButton == ButtonState.Pressed);

                if (m_HandleMouse)
                {
                    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 AlertCoords = new UIAlertOptions();
                                AlertCoords.Title = GameFacade.Strings.GetString("246", "1");
                                //AlertOptions.Message = GameFacade.Strings.GetString("215", "23", new string[]
                                //{ m_LotCost.ToString(), CurrentUIScr.ucp.MoneyText.Caption });

                                AlertCoords.Message = m_SelTile[0].ToString() + " " + m_SelTile[1].ToString();


                                foreach (LotTileEntry Lot in m_HousesData.LotTileData)
                                {
                                    if (Lot.x == m_SelTile[0] && Lot.y == m_SelTile[1])
                                    {
                                        m_CurrentLot = Lot;
                                    }
                                }


                                if (m_CurrentLot != null)
                                {
                                    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.Message = m_CurrentLot.x.ToString() + " " + m_CurrentLot.y.ToString();
                                    //AlertOptions.Buttons = UIAlertButtons.YesNo;
                                }
                            }
                        }

                        CurrentUIScr.ucp.UpdateZoomButton();
                    }
                }
                else
                {
                    m_SelTile = new int[] { -1, -1 };
                }

                GameTime time = new GameTime();

                m_SecondsBehind += time.ElapsedGameTime.TotalSeconds;
                m_SecondsBehind -= 1 / 60;
                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;
            }
        }