UIAlert is a messagebox that can be displayed to the user with several different buttons.
Inheritance: FSO.Client.UI.Controls.UIDialog
コード例 #1
0
ファイル: UIScreen.cs プロジェクト: Daribon/FreeSO
 public static UIAlert ShowAlert(UIAlertOptions options, bool modal)
 {
     var alert = new UIAlert(options);
     ShowDialog(alert, modal);
     alert.CenterAround(UIScreen.Current);
     return alert;
 }
コード例 #2
0
        public static void Alert(string title, string message, bool modal)
        {
            UIAlert alert = null;

            alert = UIScreen.GlobalShowAlert(new UIAlertOptions()
            {
                Title   = title,
                Message = message,
                Buttons = UIAlertButton.Ok((btn) => { UIScreen.RemoveDialog(alert); })
            }, modal);
        }
コード例 #3
0
        public static UIAlert YesNo(string title, string message, bool modal, Callback <bool> callback)
        {
            UIAlert alert = null;

            alert = UIScreen.GlobalShowAlert(new UIAlertOptions()
            {
                Title   = title,
                Message = message,
                Buttons = UIAlertButton.YesNo(
                    (btn) => { callback(true); UIScreen.RemoveDialog(alert); },
                    (btn) => { callback(false); UIScreen.RemoveDialog(alert); }
                    )
            }, modal);
            return(alert);
        }
コード例 #4
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);
        }
コード例 #5
0
        public static void Prompt(string title, string message, bool modal, Callback <string> callback)
        {
            UIAlert alert = null;

            alert = UIScreen.GlobalShowAlert(new UIAlertOptions()
            {
                Title     = title,
                Message   = message,
                TextEntry = true,
                Buttons   = UIAlertButton.OkCancel(
                    (btn) => { callback(alert.ResponseText); UIScreen.RemoveDialog(alert); },
                    (btn) => { callback(null); UIScreen.RemoveDialog(alert); }
                    )
            }, modal);
        }
コード例 #6
0
ファイル: Terrain.cs プロジェクト: RHY3756547/FreeSO
 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);
 }
コード例 #7
0
ファイル: Terrain.cs プロジェクト: RHY3756547/FreeSO
        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);
        }
コード例 #8
0
ファイル: UILotControl.cs プロジェクト: RHY3756547/FreeSO
        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);
            }
        }
コード例 #9
0
ファイル: PersonSelection.cs プロジェクト: RHY3756547/FreeSO
        /// <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);
        }
コード例 #10
0
ファイル: UILotControl.cs プロジェクト: RHY3756547/FreeSO
 private void DialogResponse(byte code)
 {
     if (BlockingDialog == null) return;
     UIScreen.RemoveDialog(BlockingDialog);
     LastDialogID = 0;
     vm.SendCommand(new VMNetDialogResponseCmd {
         ActorUID = ActiveEntity.PersistID,
         ResponseCode = code,
         ResponseText = (BlockingDialog.ResponseText == null) ? "" : BlockingDialog.ResponseText
     });
     BlockingDialog = null;
 }
コード例 #11
0
ファイル: UILotControl.cs プロジェクト: RHY3756547/FreeSO
        public override void Update(UpdateState state)
        {
            base.Update(state);
            Cheats.Update(state);

            if (!vm.Ready) return;

            if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID)
            {
                ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected.
                if (ActiveEntity == null) ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);

                if (!FoundMe && ActiveEntity != null)
                {
                    vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y);
                    vm.Context.World.State.ScrollAnchor = null;
                    FoundMe = true;
                }
                Queue.QueueOwner = ActiveEntity;
            }

            if (GotoObject == null) GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0];

            if (ActiveEntity != null && BlockingDialog != null)
            {
                //are we still waiting on a blocking dialog? if not, cancel.
                if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult)))
                {
                    UIScreen.RemoveDialog(BlockingDialog);
                    LastDialogID = 0;
                    BlockingDialog = null;
                }
            }

            if (Visible)
            {
                if (ShowTooltip) state.UIState.TooltipProperties.UpdateDead = false;

                bool scrolled = false;
                if (RMBScroll)
                {
                    World.State.ScrollAnchor = null;
                    Vector2 scrollBy = new Vector2();
                    if (state.TouchMode)
                    {
                        scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y);
                        RMBScrollX = state.MouseState.X;
                        RMBScrollY = state.MouseState.Y;
                        scrollBy /= 128f;
                        scrollBy /= FSOEnvironment.DPIScaleFactor;
                    } else
                    {
                        scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY);
                        scrollBy *= 0.0005f;
                    }
                    World.Scroll(scrollBy);
                    scrolled = true;
                }
                if (MouseIsOn)
                {
                    if (state.MouseState.RightButton == ButtonState.Pressed)
                    {
                        if (RMBScroll == false)
                        {
                            RMBScroll = true;
                            RMBScrollX = state.MouseState.X;
                            RMBScrollY = state.MouseState.Y;
                        }
                    }
                    else
                    {
                        RMBScroll = false;
                        if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) scrolled = World.TestScroll(state);
                    }

                }

                if (LiveMode) LiveModeUpdate(state, scrolled);
                else if (CustomControl != null) CustomControl.Update(state, scrolled);
                else ObjectHolder.Update(state, scrolled);

                //set cutaway around mouse

                if (vm.Context.Blueprint != null)
                {
                    World.State.DynamicCutaway = (WallsMode == 1);
                    //first we need to cycle the rooms that are being cutaway. Keep this up even if we're in all-cut mode.
                    var mouseTilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y) / FSOEnvironment.DPIScaleFactor);
                    var roomHover = vm.Context.GetRoomAt(LotTilePos.FromBigTile((short)(mouseTilePos.X), (short)(mouseTilePos.Y), World.State.Level));
                    var outside = (vm.Context.RoomInfo[roomHover].Room.IsOutside);
                    if (!outside && !CutRooms.Contains(roomHover))
                        CutRooms.Add(roomHover); //outside hover should not persist like with other rooms.
                    while (CutRooms.Count > 3) CutRooms.Remove(CutRooms.ElementAt(0));

                    if (LastWallMode != WallsMode)
                    {
                        if (WallsMode == 0) //walls down
                        {
                            LastCuts = new bool[vm.Context.Architecture.Width * vm.Context.Architecture.Height];
                            vm.Context.Blueprint.Cutaway = LastCuts;
                            vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED));
                            for (int i = 0; i < LastCuts.Length; i++) LastCuts[i] = true;
                        }
                        else if (WallsMode == 1)
                        {
                            MouseCutRect = new Rectangle();
                            LastCutRooms = new HashSet<uint>() { uint.MaxValue }; //must regenerate cuts
                        }
                        else //walls up or roof
                        {
                            LastCuts = new bool[vm.Context.Architecture.Width * vm.Context.Architecture.Height];
                            vm.Context.Blueprint.Cutaway = LastCuts;
                            vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED));
                        }
                        LastWallMode = WallsMode;
                    }

                    if (WallsMode == 1)
                    {
                        int recut = 0;
                        var finalRooms = new HashSet<uint>(CutRooms);

                        var newCut = new Rectangle((int)(mouseTilePos.X - 2.5), (int)(mouseTilePos.Y - 2.5), 5, 5);
                        newCut.X -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][0]*2;
                        newCut.Y -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][1]*2;
                        if (newCut != MouseCutRect)
                        {
                            MouseCutRect = newCut;
                            recut = 1;
                        }

                        if (LastFloor != World.State.Level || LastRotation != World.State.Rotation || !finalRooms.SetEquals(LastCutRooms))
                        {
                            LastCuts = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.Rotation, finalRooms);
                            recut = 2;
                            LastFloor = World.State.Level;
                            LastRotation = World.State.Rotation;
                        }
                        LastCutRooms = finalRooms;

                        if (recut > 0)
                        {
                            var finalCut = new bool[LastCuts.Length];
                            Array.Copy(LastCuts, finalCut, LastCuts.Length);
                            var notableChange = VMArchitectureTools.ApplyCutRectangle(vm.Context.Architecture, World.State.Level, finalCut, MouseCutRect);
                            if (recut > 1 || notableChange || LastRectCutNotable)
                            {
                                vm.Context.Blueprint.Cutaway = finalCut;
                                vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED));
                            }
                            LastRectCutNotable = notableChange;
                        }
                    }
                }
            }
        }
コード例 #12
0
ファイル: Terrain.cs プロジェクト: Daribon/FreeSO
        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;
            }
        }
コード例 #13
0
ファイル: UILotControl.cs プロジェクト: Daribon/FreeSO
        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);
            }
        }
コード例 #14
0
ファイル: UILotControl.cs プロジェクト: Daribon/FreeSO
 private void DialogResponse(byte code)
 {
     if (BlockingDialog == null) return;
     UIScreen.RemoveDialog(BlockingDialog);
     vm.SendCommand(new VMNetDialogResponseCmd {
         CallerID = ActiveEntity.ObjectID,
         ResponseCode = code,
         ResponseText = (BlockingDialog.ResponseText == null) ? "" : BlockingDialog.ResponseText
     });
     BlockingDialog = null;
 }