コード例 #1
0
 public void Read(byte[] bytes)
 {
     using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
         CancelStringID   = io.ReadByte();
         IconNameStringID = io.ReadByte();
         MessageStringID  = io.ReadByte();
         YesStringID      = io.ReadByte();
         NoStringID       = io.ReadByte();
         Type             = (VMDialogType)io.ReadByte();
         TitleStringID    = io.ReadByte();
         Flags            = (VMDialogFlags)io.ReadByte();
     }
 }
コード例 #2
0
        public byte YesStringID; //button 1

        #endregion Fields

        #region Methods

        public void Read(byte[] bytes)
        {
            using (var io = IoBuffer.FromBytes(bytes, ByteOrder.LITTLE_ENDIAN)){
                CancelStringID = io.ReadByte();
                IconNameStringID = io.ReadByte();
                MessageStringID = io.ReadByte();
                YesStringID = io.ReadByte();
                NoStringID = io.ReadByte();
                Type = (VMDialogType)io.ReadByte();
                TitleStringID = io.ReadByte();
                Flags = (VMDialogFlags)io.ReadByte();
            }
        }
コード例 #3
0
        public VMDialogType Type; //used for input sanitization

        #endregion Fields

        #region Methods

        public override void Deserialize(BinaryReader reader)
        {
            base.Deserialize(reader);
            Timeout = reader.ReadInt32();
            ResponseCode = reader.ReadByte();
            ResponseText = reader.ReadString();
            Type = (VMDialogType)reader.ReadByte();
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
0
        public VMDialogType Type; //used for input sanitization

        #endregion Fields

        #region Methods

        public void Deserialize(BinaryReader reader)
        {
            Timeout = reader.ReadInt32();
            Responded = reader.ReadBoolean();
            ResponseCode = reader.ReadByte();
            ResponseText = reader.ReadString();
            Type = (VMDialogType)reader.ReadByte();
        }
コード例 #7
0
ファイル: UILotControl.cs プロジェクト: riperiperi/Simitone
        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);
            }
        }