Пример #1
0
        public UIUpgradeList(UILotControl parent)
        {
            LotParent = parent;
            var ui = Content.Content.Get().CustomUI;
            var gd = GameFacade.GraphicsDevice;

            Background   = new UIImage(ui.Get("up_background.png").Get(gd)).With9Slice(0, 0, 40, 90);
            Background.X = 191;
            Background.BlockInput();
            Add(Background);

            TitleLabel              = new UILabel();
            TitleLabel.Caption      = "Congratulations! This object is fully upgraded.";
            TitleLabel.CaptionStyle = TextStyle.Create(Color.White, 12, true);
            TitleLabel.Position     = new Vector2(557, 16);
            TitleLabel.Size         = new Vector2(1, 1);
            TitleLabel.Alignment    = TextAlignment.Right | TextAlignment.Top;
            Add(TitleLabel);

            Thermometer                 = new UIUpgradeThermo();
            Thermometer.Position        = new Vector2(549, -73);
            Thermometer.OnHoveredLevel += Hover;
            Thermometer.OnClickedLevel += Click;
            Add(Thermometer);

            BackgroundHeight = 110;
            HidePct          = 1;
        }
Пример #2
0
        public UIArchTouchHelper(UILotControl parent)
        {
            Owner = parent;
            var ui = Content.Get().CustomUI;
            var gd = GameFacade.GraphicsDevice;

            ClickButton = new UITwoStateButton(ui.Get("touch_tool.png").Get(gd));
            Add(ClickButton);
            ClickButton.OnButtonDown  += (b) => Owner.SimulateMD(LastState);
            ClickButton.OnButtonClick += (b) => Owner.SimulateMU(LastState);
            ShiftClickButton           = new UITwoStateButton(ui.Get("touch_tools.png").Get(gd));
            Add(ShiftClickButton);
            ShiftClickButton.OnButtonDown  += (b) => { Owner.AddModifier(UILotControlModifiers.SHIFT); Owner.SimulateMD(LastState); };
            ShiftClickButton.OnButtonClick += (b) => { Owner.SimulateMU(LastState); Owner.RemoveModifier(UILotControlModifiers.SHIFT); };
            CtrlClickButton = new UITwoStateButton(ui.Get("touch_toolc.png").Get(gd));
            Add(CtrlClickButton);
            CtrlClickButton.OnButtonDown  += (b) => { Owner.AddModifier(UILotControlModifiers.CTRL); Owner.SimulateMD(LastState); };
            CtrlClickButton.OnButtonClick += (b) => { Owner.SimulateMU(LastState); Owner.RemoveModifier(UILotControlModifiers.CTRL); };

            RotateCWButton = new UITwoStateButton(ui.Get("touch_rotcw.png").Get(gd));
            Add(RotateCWButton);
            RotateCWButton.OnButtonClick += (b) => { parent.ObjectHolder.RotateObject(2); };
            RotateCCWButton = new UITwoStateButton(ui.Get("touch_rotccw.png").Get(gd));
            RotateCCWButton.OnButtonClick += (b) => { parent.ObjectHolder.RotateObject(-2); };
            Add(RotateCCWButton);

            Cross = ui.Get("touch_cross.png").Get(gd);

            GameResized();
        }
Пример #3
0
 public UIRoofer(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
 {
     vm.SendCommand(new VMNetSetRoofCmd()
     {
         Pitch = vm.Context.Architecture.RoofPitch,
         Style = (uint)parameters[0]
     });
 }
Пример #4
0
        public UIGrassPaint(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            this.vm    = vm;
            World      = parent.World;
            Parent     = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x2F39B7A6, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
        }
Пример #5
0
        public void InitializeLot()
        {
            CleanupLastWorld();

            if (FSOEnvironment.Enable3D)
            {
                var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
                rc.SetSurroundingWorld(CityRenderer);
                World = rc;
            }
            else
            {
                World = new World(GameFacade.GraphicsDevice);
            }

            WorldLoaded   = false;
            World.Opacity = 0;
            GameFacade.Scenes.Add(World);
            Driver = new VMClientDriver(ClientStateChange);
            Driver.OnClientCommand += VMSendCommand;
            Driver.OnShutdown      += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider())
            {
                FSOVDoAsyncLoad = true
            };
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            AddAt(1, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;
        }
Пример #6
0
        public UIFloorPainter(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World = parent.World;
            Parent = parent;

            Commands = new List<VMArchitectureCommand>();
        }
Пример #7
0
        public UIFloorPainter(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World   = parent.World;
            Parent  = parent;

            Commands = new List <VMArchitectureCommand>();
        }
Пример #8
0
        public UITerrainFlatten(VM vm, World world, UILotControl parent, List <int> parameters)
        {
            this.vm     = vm;
            World       = parent.World;
            Parent      = parent;
            WallCursor  = vm.Context.CreateObjectInstance(0x2F39B7A6, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
            WallCursor2 = vm.Context.CreateObjectInstance(0x2F39B7A6, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic  = true;
            ((ObjectComponent)WallCursor2.Objects[0].WorldUI).ForceDynamic = true;
        }
Пример #9
0
        public void InitializeLot()
        {
            CleanupLastWorld();

            if (FSOEnvironment.Enable3D)
            {
                World = new FSO.LotView.RC.WorldRC(GameFacade.GraphicsDevice);
            }
            else
            {
                World = new FSO.LotView.World(GameFacade.GraphicsDevice);
            }

            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var globalLink = new VMTSOGlobalLinkStub();

            Driver = new VMServerDriver(globalLink);

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);
            Frontend = new UISimitoneFrontend(this);
            this.Add(Frontend);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh += VMRefreshed;
            //vm.OnEODMessage += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;
        }
Пример #10
0
        public UIWallPainter(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World = parent.World;
            Parent = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
            Commands = new List<VMArchitectureCommand>();

            SetCursorGraphic(2);
        }
Пример #11
0
        public UIWallPainter(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm    = vm;
            World      = parent.World;
            Parent     = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
            Commands = new List <VMArchitectureCommand>();

            SetCursorGraphic(2);
        }
Пример #12
0
        public UIUpgradeItem(UILotControl parent, VMEntity ent, int level)
        {
            LotParent = parent;
            var ui = Content.Content.Get().CustomUI;
            var gd = GameFacade.GraphicsDevice;

            Entity = ent;
            Level  = level;

            Background = new UIImage(ui.Get(((level % 2) == 0) ? "up_item_panel.png" : "up_item_panel_alt.png").Get(gd));
            Add(Background);

            Title              = new UILabel();
            Title.Alignment    = TextAlignment.Right | TextAlignment.Top;
            Title.CaptionStyle = TextStyle.Create(Color.White, 12, true);
            Title.Position     = new Vector2(512, 12);
            Title.Size         = Vector2.One;
            Add(Title);

            TitlePrice              = new UILabel();
            TitlePrice.Position     = new Microsoft.Xna.Framework.Vector2(512, 12);
            TitlePrice.CaptionStyle = TextStyle.Create(new Color(115, 255, 115), 12, true);
            TitlePrice.Alignment    = TextAlignment.Right | TextAlignment.Top;
            TitlePrice.Size         = Vector2.One;
            Add(TitlePrice);

            Description              = new UILabel();
            Description.Position     = new Vector2(512, 31);
            Description.CaptionStyle = TextStyle.Create(TextStyle.DefaultLabel.Color, 9, true);
            Description.Alignment    = TextAlignment.Right | TextAlignment.Top;
            Description.Size         = Vector2.One;
            Add(Description);

            Ads              = new UILabel();
            Ads.Position     = new Vector2(512, 47);
            Ads.CaptionStyle = TextStyle.Create(Color.White, 9, true);
            Ads.Alignment    = TextAlignment.Right | TextAlignment.Top;
            Ads.Size         = Vector2.One;
            Add(Ads);

            UpgradedTick          = new UIImage(ui.Get("up_tick.png").Get(gd));
            UpgradedTick.Position = new Vector2(494, 12);
            Add(UpgradedTick);

            Render();
            Size = new Vector2(Background.Width, Background.Height);

            ClickHandler = ListenForMouse(new Rectangle(6, 6, (int)Background.Width - 12, (int)Background.Height - 12), MouseHandler);
        }
Пример #13
0
        public UIDonatorDialog(UILotControl panel) : base(UIDialogStyle.Standard, false)
        {
            LotParent = panel;
            var modeHBox = new UIHBoxContainer();

            modeHBox.Spacing = 20;

            for (int i = 0; i < 2; i++)
            {
                var hbox  = new UIHBoxContainer();
                var radio = new UIRadioButton();
                radio.RadioGroup = "donateMode";
                radio.RadioData  = false;
                radio.Selected   = (i == 0);
                radio.Tooltip    = ModeNames[i];
                var donate = (i > 0);
                radio.OnButtonClick += (btn) =>
                {
                    SetDonate(donate);
                };
                ModeButtons[i] = radio;

                hbox.Add(radio);
                hbox.Add(new UILabel
                {
                    Caption = ModeNames[i]
                });
                modeHBox.Add(hbox);
            }

            modeHBox.AutoSize();
            modeHBox.Position = new Vector2((400 - modeHBox.Size.X) / 2, 35);
            Add(modeHBox);

            SetSize(400, 100);

            Add(SummaryLabel = new UILabel()
            {
                Caption   = "(100/100) Mayor Objects, (1999/2000) Donated Objects",
                Position  = new Vector2(200, 70),
                Size      = Vector2.One,
                Alignment = TextAlignment.Center | TextAlignment.Middle
            });

            GameResized();

            Caption = "Community Lot Buy Mode";
        }
        public LotDebugScreen()
        {
            var lotInfo = XmlHouseData.Parse(GameFacade.GameFilePath("housedata/blueprints/restaurant01_00.xml"));

            World = new World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            vm = new TSO.Simantics.VM(new VMContext(World));
            vm.Init();

            var activator = new VMWorldActivator(vm, World);
            var blueprint = activator.LoadFromXML(lotInfo);

            World.InitBlueprint(blueprint);
            vm.Context.Blueprint = blueprint;

            var sim = activator.CreateAvatar();

            //sim.Position = new Vector3(31.5f, 55.5f, 0.0f);
            sim.Position = new Vector3(26.5f, 41.5f, 0.0f);

            VMDebug = new UIButton()
            {
                Caption = "Simantics",
                Y       = 45,
                Width   = 100,
                X       = GlobalSettings.Default.GraphicsWidth - 110
            };
            VMDebug.OnButtonClick += new ButtonClickDelegate(VMDebug_OnButtonClick);
            this.Add(VMDebug);

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            ucp   = new UIUCP(this);
            ucp.Y = ScreenHeight - 210;
            ucp.SetInLot(true);
            ucp.SetMode(UIUCP.UCPMode.LotMode);
            ucp.SelectedAvatar = sim;
            ucp.SetPanel(1);

            //ucp.ZoomLevel = 1;
            //ucp.OnZoomChanged += new UCPZoomChangeEvent(ucp_OnZoomChanged);
            //ucp.OnRotateChanged += new UCPRotateChangeEvent(ucp_OnRotateChanged);
            this.Add(ucp);
        }
Пример #15
0
        //listbox
        //smallThumb | avatarName | buildCheckbox | deleteButton

        public UIManageDonatorDialog(UILotControl lotControl) : base(UIDialogStyle.Standard | UIDialogStyle.OK, true)
        {
            this.LotControl = lotControl;
            Community       = lotControl.vm.TSOState.CommunityLot;

            BuildIcon = new UIImage();
            var ui     = RenderScript("fsodonatorlist.uis");
            var listBg = ui.Create <UIImage>("ListBoxBackground");

            AddAt(4, listBg);
            listBg.With9Slice(25, 25, 25, 25);
            listBg.Width  += 110;
            listBg.Height += 50;

            Dropdown           = ui.Create <UIInboxDropdown>("PullDownMenuSetup");
            Dropdown.OnSearch += (query) =>
            {
                FindController <GenericSearchController>()?.Search(query, false, (results) =>
                {
                    Dropdown.SetResults(results);
                });
            };
            Dropdown.OnSelect += AddDonator;
            Add(Dropdown);

            RoommateListSlider.AttachButtons(RoommateListScrollUpButton, RoommateScrollDownButton, 1);
            RoommateListBox.AttachSlider(RoommateListSlider);
            RoommateListBox.Columns[1].Alignment = Framework.TextAlignment.Left | Framework.TextAlignment.Middle;

            Caption = GameFacade.Strings.GetString("f114", (Community)?"6":"12");
            SetSize(405, 400);

            DonatorsLabel.CaptionStyle        = DonatorsLabel.CaptionStyle.Clone();
            DonatorsLabel.CaptionStyle.Shadow = true;
            DonatorsLabel.Caption             = GameFacade.Strings.GetString("f114", (Community) ? "5" : "13");
            AddAt(5, BuildIcon);

            var ctr = ControllerUtils.BindController <GenericSearchController>(this);

            UpdateDonatorList();
            OKButton.OnButtonClick += (btn) =>
            {
                UIScreen.RemoveDialog(this);
            };
        }
Пример #16
0
        public UIWallPlacer(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];
            Style = (ushort)parameters[1];
            if (Style == 1)
            {
                DrawPattern = 255;
                DrawStyle = 255;
            } else
            {
                DrawPattern = Pattern;
                DrawStyle = Style;
            }

            this.vm = vm;
            World = parent.World;
            Parent = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
        }
Пример #17
0
        public UIWallPlacer(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            Pattern = (ushort)parameters[0];
            Style   = (ushort)parameters[1];
            if (Style == 1)
            {
                DrawPattern = 255;
                DrawStyle   = 255;
            }
            else
            {
                DrawPattern = Pattern;
                DrawStyle   = Style;
            }

            this.vm    = vm;
            World      = parent.World;
            Parent     = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
        }
Пример #18
0
        public void InitializeLot()
        {
            CleanupLastWorld();
            World = new FSO.LotView.World(GameFacade.GraphicsDevice);

            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var globalLink = new VMTS1GlobalLinkStub();

            Driver = new VMServerDriver(globalLink);

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh += VMRefreshed;
            //vm.OnEODMessage += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;
        }
Пример #19
0
        public void InitTestLot()
        {
            var lotInfo = XmlHouseData.Parse(GameFacade.GameFilePath("housedata/blueprints/restaurant08_00.xml"));

            World = new World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            vm = new TSO.Simantics.VM(new VMContext(World));
            vm.Init();

            var activator = new VMWorldActivator(vm, World);
            var blueprint = activator.LoadFromXML(lotInfo);

            World.InitBlueprint(blueprint);
            vm.Context.Blueprint = blueprint;

            var sim = activator.CreateAvatar();

            sim.Position = new Vector3(26.5f, 41.5f, 0.0f);

            var sim2 = activator.CreateAvatar();

            sim2.Position = new Vector3(27.5f, 41.5f, 0.0f);

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 6;

            ucp.SelectedAvatar = sim;
            ucp.SetInLot(true);
            if (m_ZoomLevel > 3)
            {
                World.Visible = false;
            }
        }
Пример #20
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            var recording = lotName.ToLowerInvariant().EndsWith(".fsor");

            CleanupLastWorld();

            Content.Content.Get().Upgrades.LoadJSONTuning();

            if (FSOEnvironment.Enable3D)
            {
                var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
                World = rc;
            }
            else
            {
                World = new World(GameFacade.GraphicsDevice);
            }
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var settings = GlobalSettings.Default;
            var myState  = new VMNetAvatarPersistState()
            {
                Name         = settings.LastUser,
                DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                BodyOutfit   = settings.DebugBody,
                HeadOutfit   = settings.DebugHead,
                PersistID    = (uint)(new Random()).Next(),
                SkinTone     = (byte)settings.DebugSkin,
                Gender       = (short)(settings.DebugGender ? 0 : 1),
                Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                //CustomGUID = 0x396CD3D1,
                Budget = 1000000,
            };

            if (recording)
            {
                var stream = new FileStream(lotName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var rd     = new VMFSORDriver(stream);
                Driver = rd;
            }
            else if (external)
            {
                var cd = new VMClientDriver(ClientStateChange);
                SandCli             = new FSOSandboxClient();
                cd.OnClientCommand += (msg) => { SandCli.Write(new VMNetMessage(VMNetMessageType.Command, msg)); };
                cd.OnShutdown      += (reason) => SandCli.Disconnect();
                SandCli.OnMessage  += cd.ServerMessage;
                SandCli.Connect(lotName);
                Driver = cd;

                var dat = new MemoryStream();
                var str = new BinaryWriter(dat);
                myState.SerializeInto(str);
                var ava = new VMNetMessage(VMNetMessageType.AvatarData, dat.ToArray());
                dat.Close();
                SandCli.OnConnectComplete += () =>
                {
                    SandCli.Write(ava);
                };
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                globalLink.Database = new SimAntics.Engine.TSOGlobalLink.VMTSOStandaloneDatabase();
                var sd = new VMServerDriver(globalLink);
                SandServer = new FSOSandboxServer();

                Driver                   = sd;
                sd.OnDropClient         += SandServer.ForceDisconnect;
                sd.OnTickBroadcast      += SandServer.Broadcast;
                sd.OnDirectMessage      += SandServer.SendMessage;
                SandServer.OnConnect    += sd.ConnectClient;
                SandServer.OnDisconnect += sd.DisconnectClient;
                SandServer.OnMessage    += sd.HandleMessage;

                SandServer.Start((ushort)37564);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external && !recording)
            {
                if (!Downtown && ActiveFamily != null)
                {
                    ActiveFamily.SelectWholeFamily();
                    vm.TS1State.ActivateFamily(vm, ActiveFamily);
                }
                BlueprintReset(lotName);

                var experimentalTuning = new Common.Model.DynamicTuning(new List <Common.Model.DynTuningEntry> {
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 15, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 5, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 6, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 7, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 8, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 9, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "feature", tuning_table = 0, tuning_index = 0, value = 1
                    },                                                                                                            //ts1/tso engine animation timings (1.2x faster)
                });
                vm.ForwardCommand(new VMNetTuningCmd {
                    Tuning = experimentalTuning
                });

                vm.TSOState.PropertyCategory = 255; //11 is community
                vm.TSOState.ActivateValidator(vm);
                vm.Context.Clock.Hours = 0;
                vm.TSOState.Size      &= unchecked ((int)0xFFFF0000);
                vm.TSOState.Size      |= (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();

                if (vm.GetGlobalValue(11) > -1)
                {
                    for (int y = 0; y < 3; y++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            vm.TSOState.Terrain.Roads[x, y] = 0xF; //crossroads everywhere
                        }
                    }
                    VMLotTerrainRestoreTools.RestoreTerrain(vm);
                }

                var myClient = new VMNetClient
                {
                    PersistID   = myState.PersistID,
                    RemoteIP    = "local",
                    AvatarState = myState
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
            vm.MyUID  = myState.PersistID;
            ZoomLevel = 1;
        }
Пример #21
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            var recording = lotName.ToLowerInvariant().EndsWith(".fsor");

            CleanupLastWorld();

            if (FSOEnvironment.Enable3D)
            {
                var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
                World = rc;
            }
            else
            {
                World = new World(GameFacade.GraphicsDevice);
            }
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var settings = GlobalSettings.Default;
            var myState  = new VMNetAvatarPersistState()
            {
                Name         = settings.LastUser,
                DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                BodyOutfit   = settings.DebugBody,
                HeadOutfit   = settings.DebugHead,
                PersistID    = (uint)(new Random()).Next(),
                SkinTone     = (byte)settings.DebugSkin,
                Gender       = (short)(settings.DebugGender ? 0 : 1),
                Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                Budget       = 1000000,
            };

            if (recording)
            {
                var stream = new FileStream(lotName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var rd     = new VMFSORDriver(stream);
                Driver = rd;
            }
            else if (external)
            {
                var cd = new VMClientDriver(ClientStateChange);
                SandCli             = new FSOSandboxClient();
                cd.OnClientCommand += (msg) => { SandCli.Write(new VMNetMessage(VMNetMessageType.Command, msg)); };
                cd.OnShutdown      += (reason) => SandCli.Disconnect();
                SandCli.OnMessage  += cd.ServerMessage;
                SandCli.Connect(lotName);
                Driver = cd;

                var dat = new MemoryStream();
                var str = new BinaryWriter(dat);
                myState.SerializeInto(str);
                var ava = new VMNetMessage(VMNetMessageType.AvatarData, dat.ToArray());
                dat.Close();
                SandCli.OnConnectComplete += () =>
                {
                    SandCli.Write(ava);
                };
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                var sd         = new VMServerDriver(globalLink);
                SandServer = new FSOSandboxServer();

                Driver                   = sd;
                sd.OnDropClient         += SandServer.ForceDisconnect;
                sd.OnTickBroadcast      += SandServer.Broadcast;
                sd.OnDirectMessage      += SandServer.SendMessage;
                SandServer.OnConnect    += sd.ConnectClient;
                SandServer.OnDisconnect += sd.DisconnectClient;
                SandServer.OnMessage    += sd.HandleMessage;

                SandServer.Start((ushort)37564);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external && !recording)
            {
                if (!Downtown && ActiveFamily != null)
                {
                    ActiveFamily.SelectWholeFamily();
                    vm.ActivateFamily(ActiveFamily);
                }
                BlueprintReset(lotName);

                vm.TSOState.PropertyCategory = 255;
                vm.Context.Clock.Hours       = 0;
                vm.TSOState.Size             = (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();
                var myClient = new VMNetClient
                {
                    PersistID   = myState.PersistID,
                    RemoteIP    = "local",
                    AvatarState = myState
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
            vm.MyUID  = myState.PersistID;
            ZoomLevel = 1;
        }
 public UIAvatarDataServiceUpdater(UILotControl owner)
 {
     Control = owner;
 }
Пример #23
0
        public void InitTestLot(string path, bool host)
        {
            if (Connecting)
            {
                return;
            }

            if (vm != null)
            {
                CleanupLastWorld();
            }

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            VMNetDriver driver;

            if (host)
            {
                driver = new VMServerDriver(37564, null);
            }
            else
            {
                Connecting       = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption         = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }

            vm = new VM(new VMContext(World), driver, new UIHeadlineRendererProvider());
            vm.Init();
            vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are

            if (host)
            {
                //check: do we have an fsov to try loading from?

                string filename = Path.GetFileName(path);
                try
                {
                    using (var file = new BinaryReader(File.OpenRead("Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov")))
                    {
                        var marshal = new SimAntics.Marshals.VMMarshal();
                        marshal.Deserialize(file);
                        vm.Load(marshal);
                        vm.Reset();
                    }
                }
                catch (Exception) {
                    short jobLevel = -1;

                    //quick hack to find the job level from the chosen blueprint
                    //the final server will know this from the fact that it wants to create a job lot in the first place...

                    try
                    {
                        if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
                        {
                            jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
                        }
                    }
                    catch (Exception) { }

                    vm.SendCommand(new VMBlueprintRestoreCmd
                    {
                        JobLevel = jobLevel,
                        XMLData  = File.ReadAllBytes(path)
                    });
                }
            }

            uint simID = (uint)(new Random()).Next();

            vm.MyUID = simID;

            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID = simID,
                HeadID   = GlobalSettings.Default.DebugHead,
                BodyID   = GlobalSettings.Default.DebugBody,
                SkinTone = (byte)GlobalSettings.Default.DebugSkin,
                Gender   = !GlobalSettings.Default.DebugGender,
                Name     = GlobalSettings.Default.LastUser
            });

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 10;
            if (m_ZoomLevel > 3)
            {
                World.Visible         = false;
                LotController.Visible = false;
            }

            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            }
            else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh += VMRefreshed;
            vm.OnChatEvent   += Vm_OnChatEvent;
            vm.OnEODMessage  += LotController.EODs.OnEODMessage;
        }
Пример #24
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            CleanupLastWorld();

            World         = new LotView.World(GameFacade.GraphicsDevice);
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            if (external)
            {
                //external not yet implemented
                Driver = new VMClientDriver(ClientStateChange);
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                Driver = new VMServerDriver(globalLink);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external)
            {
                vm.ActivateFamily(ActiveFamily);
                BlueprintReset(lotName);

                vm.Context.Clock.Hours = 0;
                vm.TSOState.Size       = (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();
                vm.MyUID = 1;
                var settings = GlobalSettings.Default;
                var myClient = new VMNetClient
                {
                    PersistID   = 1,
                    RemoteIP    = "local",
                    AvatarState = new VMNetAvatarPersistState()
                    {
                        Name         = settings.LastUser,
                        DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                        BodyOutfit   = settings.DebugBody,
                        HeadOutfit   = settings.DebugHead,
                        PersistID    = 1,
                        SkinTone     = (byte)settings.DebugSkin,
                        Gender       = (short)(settings.DebugGender ? 1 : 0),
                        Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                        Budget       = 100000
                    }
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
        }
        public void InitTestLot(string path, bool host)
        {
            if (Connecting)
            {
                return;
            }

            lotName = path;



            Characters = new List <XmlCharacter>();

            SaveHouseButton.Visible = true;
            CreateChar.Visible      = false;

            if (vm != null)
            {
                CleanupLastWorld();
            }

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);



            vm = new VM(new VMContext(World), new UIHeadlineRendererProvider());
            vm.Init();
            vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are


            var DirectoryInfo = new DirectoryInfo(Path.Combine(FSOEnvironment.UserDir, "Characters/"));

            for (int i = 0; i <= DirectoryInfo.GetFiles().Count() - 1; i++)
            {
                var file = DirectoryInfo.GetFiles()[i];
                CharacterInfos[i] = Path.GetFileNameWithoutExtension(file.FullName);

                if (CharacterInfos[i] != null && CharacterInfos[i] != gizmo.SelectedCharInfo.Name)
                {
                    Characters.Add(XmlCharacter.Parse(file.FullName));
                }
            }


            VMNetDriver driver;

            if (host)
            {
                driver = new VMServerDriver(37564, null);
            }
            else
            {
                Connecting       = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption         = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }


            vm.VM_SetDriver(driver);



            if (host)
            {
                //check: do we have an fsov to try loading from?

                string filename = Path.GetFileName(path);
                try
                {
                    using (var file = new BinaryReader(File.OpenRead(Path.Combine(FSOEnvironment.UserDir, "Houses/") + filename.Substring(0, filename.Length - 4) + ".fsov")))
                    {
                        var marshal = new SimAntics.Marshals.VMMarshal();
                        marshal.Deserialize(file);
                        vm.Load(marshal);
                        vm.Reset();
                    }
                }
                catch (Exception)
                {
                    short jobLevel = -1;

                    //quick hack to find the job level from the chosen blueprint
                    //the final server will know this from the fact that it wants to create a job lot in the first place...

                    try
                    {
                        if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
                        {
                            jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
                        }
                    }
                    catch (Exception) { }

                    vm.SendCommand(new VMBlueprintRestoreCmd
                    {
                        JobLevel   = jobLevel,
                        XMLData    = File.ReadAllBytes(path),
                        Characters = Characters
                    });
                }
            }

            //Check the clients loaded;
            List <VMAvatar> Clients = new List <VMAvatar>();

            foreach (VMEntity entity in vm.Entities)
            {
                if (entity is VMAvatar && entity.PersistID > 0)
                {
                    Clients.Add((VMAvatar)entity);
                }
            }


            if (Clients.Count == 0)
            {
                Permissions = true;
            }

            uint simID = (uint)(new Random()).Next();

            vm.MyUID = simID;


            var headPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(gizmo.SelectedCharInfo.Head, 16));
            var bodyPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(gizmo.SelectedCharInfo.Body, 16));
            var HeadID          = headPurchasable != null ? headPurchasable.OutfitID :
                                  Convert.ToUInt64(gizmo.SelectedCharInfo.Head, 16);
            var BodyID = bodyPurchasable != null ? bodyPurchasable.OutfitID :
                         Convert.ToUInt64(gizmo.SelectedCharInfo.Body, 16);

            AppearanceType type;

            Enum.TryParse(gizmo.SelectedCharInfo.Appearance, out type);
            bool Male = (gizmo.SelectedCharInfo.Gender == "male") ? true:false;

            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID    = simID,
                HeadID      = HeadID,
                BodyID      = BodyID,
                SkinTone    = (byte)type,
                Gender      = Male,
                Name        = gizmo.SelectedCharInfo.Name,
                Permissions = (Permissions == true) ?
                              VMTSOAvatarPermissions.Owner : VMTSOAvatarPermissions.Visitor
            });

            VMWorldActivator activator = new VMWorldActivator(vm, World);

            if (host)
            {
            }
            else
            {
                foreach (XmlCharacter Char in Characters)
                {
                    uint vsimID = (uint)(new Random()).Next();
                    Enum.TryParse(Char.Appearance, out type);

                    var vheadPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Head, 16));
                    var vbodyPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Body, 16));
                    var vHeadID          = vheadPurchasable != null ? vheadPurchasable.OutfitID :
                                           Convert.ToUInt64(Char.Head, 16);
                    var vBodyID = vbodyPurchasable != null ? vbodyPurchasable.OutfitID :
                                  Convert.ToUInt64(Char.Body, 16);

                    VMEntity vEntity = vm.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0x7FD96B54 && x.Name == Char.Name));

                    if (vEntity != null)
                    {
                        ((VMAvatar)vEntity).SetAvatarData(Char);
                    }
                }
            }

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 10;

            if (m_ZoomLevel > 3)
            {
                World.Visible         = false;
                LotController.Visible = false;
            }


            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            }
            else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            vm.OnFullRefresh += VMRefreshed;
            vm.OnChatEvent   += Vm_OnChatEvent;
            vm.OnEODMessage  += LotController.EODs.OnEODMessage;
        }
Пример #26
0
 public UIEODController(UILotControl lot)
 {
     Lot = lot;
 }
Пример #27
0
 public UIEODController(UILotControl lot)
 {
     Lot = lot;
 }
Пример #28
0
 public UICheatHandler(UILotControl owner)
 {
     Control = owner;
 }
Пример #29
0
 public UICheatHandler(UILotControl owner)
 {
     Control = owner;
 }