Пример #1
0
        private bool LastRectCutNotable = false; //set if the last rect cut made a noticable change to the cuts array. If true refresh regardless of new cut effect.

        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm    = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt     = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                                                                                     GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            Touch        = new UILotControlTouchHelper(this);
            Add(Touch);
            SetupQuery();

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp

            vm.OnChatEvent  += Vm_OnChatEvent;
            vm.OnDialog     += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            this.Add(Cheats);
            AvatarDS = new UIAvatarDataServiceUpdater(this);
            EODs     = new UIEODController(this);
        }
Пример #2
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm    = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt     = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                                                                                     GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel   = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 177;
            QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228;
            this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            vm.OnChatEvent  += Vm_OnChatEvent;
            vm.OnDialog     += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            EODs   = new UIEODController(this);
        }
Пример #3
0
 public UIPersonGrid(VM vm)
 {
     this.vm = vm;
     Page = 0;
     Display = new HashSet<VMAvatar>();
     CurrentIcons = new List<UIPersonIcon>();
     UpdatePeople();
 }
Пример #4
0
        public UIPersonIcon(VMAvatar ava, VM vm, bool small)
        {
            Avatar = ava;
            this.vm = vm;

            Small = small;
            UpdateAvatarState(((VMTSOAvatarState)Avatar.TSOState).Permissions);
            OnButtonClick += CenterPerson;
        }
Пример #5
0
        public UIChatPanel(VM vm, UILotControl owner)
        {
            this.vm = vm;
            this.Owner = owner;

            if (FSOEnvironment.SoftwareKeyboard)
            {
                //need a button to initiate chat history
                var btn = new UIButton();
                btn.Caption = "Chat";
                btn.Position = new Vector2(10, 10);
                btn.OnButtonClick += (state) =>
                {
                    HistoryDialog.Visible = !HistoryDialog.Visible;
                };
                Add(btn);
            }

            Style = TextStyle.DefaultTitle.Clone();
            Style.Size = 16;
            Style.Shadow = true;
            Labels = new List<UIChatBalloon>();

            TextBox = new UITextBox();
            TextBox.Visible = false;
            Add(TextBox);
            TextBox.Position = new Vector2(25, 25);
            TextBox.SetSize(GlobalSettings.Default.GraphicsWidth - 50, 25);

            TextBox.OnEnterPress += SendMessageElem;

            SelectionFillColor = new Color(0, 25, 70);

            //-- populate invalid areas --
            //chat bubbles will be pushed out of these areas
            //when this happens, they will also begin displaying the name of the speaking avatar.

            InvalidAreas = new List<Rectangle>();
            InvalidAreas.Add(new Rectangle(-100000, -100000, 100020, 200000 + GlobalSettings.Default.GraphicsHeight)); //left
            InvalidAreas.Add(new Rectangle(-100000, -100000, 200000 + GlobalSettings.Default.GraphicsWidth, 100020)); //top
            InvalidAreas.Add(new Rectangle(GlobalSettings.Default.GraphicsWidth-20, -100000, 100020, 200000 + GlobalSettings.Default.GraphicsHeight)); //right
            InvalidAreas.Add(new Rectangle(-100000, GlobalSettings.Default.GraphicsHeight - 20, 200000 +GlobalSettings.Default.GraphicsWidth, 100020)); //bottom
            InvalidAreas.Add(new Rectangle(-100000, GlobalSettings.Default.GraphicsHeight - 230, 100230, 100230)); //ucp

            HistoryDialog = new UIChatDialog();
            HistoryDialog.Position = new Vector2(20, 20);
            HistoryDialog.Visible = false;
            HistoryDialog.Opacity = 0.75f;
            HistoryDialog.OnSendMessage += SendMessage;
            this.Add(HistoryDialog);

            PropertyLog = new UIPropertyLog();
            PropertyLog.Position = new Vector2(400, 20);
            PropertyLog.Visible = false;
            PropertyLog.Opacity = 0.75f;
            this.Add(PropertyLog);
        }
Пример #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 void ResetVM()
        {
            VMNetDriver driver;
            driver = new VMServerDriver(Port, NetClosed);

            var vm = new VM(new VMContext(null), driver, new VMNullHeadlineProvider());
            state = vm;
            vm.Init();
            vm.OnChatEvent += Vm_OnChatEvent;

            var path = Settings.Default.GamePath + "housedata/blueprints/" + Settings.Default.DebugLot;
            string filename = Path.GetFileName(path);
            try
            {
                //try to load from FSOV first.
                LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov");
            }
            catch (Exception)
            {
                try
                {
                    Console.WriteLine("Failed FSOV load... Trying Backup");
                    LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + "_backup.fsov");
                }
                catch (Exception)
                {
                    Console.WriteLine("CRITICAL::: Failed FSOV load... Trying Blueprint (first run or something went wrong)");
                    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)
                    });

                    vm.Context.Clock.Hours = 10;
                }
            }
            vm.MyUID = uint.MaxValue-1;
            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID = uint.MaxValue - 1,
                Name = "server"
            });
        }
Пример #8
0
 public void IDEBreakpointHit(VM vm, VMEntity targetEnt)
 {
     new Thread(() =>
     {
         if (MainWindow.Instance == null) return;
         MainWindow.Instance.Invoke(new MainWindowDelegate(() =>
         {
             MainWindow.Instance.BHAVManager.OpenTracer(vm, targetEnt);
         }), null);
     }).Start();
 }
Пример #9
0
 public void LoadState(VM vm, string path)
 {
     using (var file = new BinaryReader(File.OpenRead(path)))
     {
         var marshal = new VMMarshal();
         marshal.Deserialize(file);
         vm.Load(marshal);
         CleanLot();
         vm.Reset();
     }
 }
Пример #10
0
        public Simantics(VM vm)
        {
            this.vm = vm;
            InitializeComponent();

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);

            aq = new ActionQueue();
            aq.Show();
            aq.target = ActiveEntity;
        }
Пример #11
0
        public void InjectIDEInto(UIScreen screen, VM vm, BHAV targetBhav, GameObject targetObj)
        {
            EditorResource.Get().Init(GameFacade.GraphicsDevice);
            EditorScope.Behaviour = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/behavior.iff"));
            EditorScope.Globals = FSO.Content.Content.Get().WorldObjectGlobals.Get("global");

            new Thread(() =>
            {
                var editor = new BHAVEditor(targetBhav, new EditorScope(targetObj, targetBhav));
                Application.Run(editor);
            }).Start();
        }
Пример #12
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);
        }
Пример #13
0
        public void StartIDE(VM vm)
        {
            EditorResource.Get().Init(GameFacade.GraphicsDevice);
            EditorScope.Behaviour = new Files.Formats.IFF.IffFile(Content.Content.Get().GetPath("objectdata/globals/behavior.iff"));
            EditorScope.Globals = FSO.Content.Content.Get().WorldObjectGlobals.Get("global");

            var t = new Thread(() =>
            {
                var editor = new MainWindow();
                editor.Test(vm);
                Application.Run(editor);
            });

            //t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
Пример #14
0
        public CVMInstance(int port)
        {
            VM.UseWorld = false;
            VMNetDriver driver;
            driver = new VMServerDriver(port);

            var vm = new VM(new VMContext(null), driver);
            vm.Init();

            vm.SendCommand(new VMBlueprintRestoreCmd
            {
                XMLData = File.ReadAllBytes(Path.Combine(Settings.Default.GamePath+"housedata/blueprints/"+Settings.Default.DebugLot))
            });
            vm.Context.Clock.Hours = 10;

            state = vm;
        }
Пример #15
0
 /// <summary>
 /// A UICheatTextbox with text
 /// </summary>
 /// <param name="initialText"></param>
 public UICheatTextbox(FSO.SimAntics.VM vm, string initialText)
 {
     ts1VM       = vm;
     baseTextbox = new UITextBox()
     {
         CurrentText  = initialText,
         FlashOnEmpty = true,
         MaxLines     = 1,
         //Tooltip = "Cheaters never win",
         //FrameColor = Color.Transparent,
         ID = "UICheatTextboxBase",
     };
     baseTexture = new Texture2D(GameFacade.GraphicsDevice, 1, 1);
     baseTexture.SetData(new Color[] { new Color((byte)67, (byte)93, (byte)90, (byte)255) });
     baseTextbox.SetBackgroundTexture(baseTexture, 0, 0, 0, 0);
     Size = new Vector2(200, 23);
     baseTextbox.SetSize(200, 23);
     Add(baseTextbox);
 }
Пример #16
0
        public BHAVEditor OpenTracer(VM vm, VMEntity entity)
        {
            BHAVEditor window;
            if (Tracers.ContainsKey(entity))
            {
                window = Tracers[entity];
                window.UpdateDebugger();
                var form = (Form)window;
                if (form.WindowState == FormWindowState.Minimized) form.WindowState = FormWindowState.Normal;
                window.Activate();
                return window;
            }

            window = new BHAVEditor(vm, entity);
            window.Show();
            window.Activate();
            Tracers.Add(entity, window);
            return window;
        }
Пример #17
0
        public UIChatPanel(VM vm, UILotControl owner)
        {
            this.vm = vm;
            this.Owner = owner;

            Style = TextStyle.DefaultTitle.Clone();
            Style.Size = 16;
            Style.Shadow = true;
            Labels = new List<UILabel>();

            TextBox = new UITextBox();
            TextBox.Visible = false;
            Add(TextBox);
            TextBox.Position = new Vector2(25, 25);
            TextBox.SetSize(GlobalSettings.Default.GraphicsWidth - 50, 25);

            TextBox.OnEnterPress += SendMessage;

            SelectionFillColor = new Color(0, 25, 70);
        }
Пример #18
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;
        }
Пример #19
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, FSO.LotView.World World)
        {
            this.vm    = vm;
            this.World = World;

            MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                                                                                 GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            Touch        = new UILotControlTouchHelper(this);
            Add(Touch);
            ArchTouch = new UIArchTouchHelper(this);
            Add(ArchTouch);
            SetupQuery();


            RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp

            vm.OnDialog     += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;
        }
Пример #20
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;
        }
Пример #21
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);
            }
            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);
            vm.Init();

            if (host)
            {
                vm.SendCommand(new VMBlueprintRestoreCmd
                {
                    XMLData = File.ReadAllBytes(path)
                });
            }

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

            vm.SendCommand(new VMNetSimJoinCmd
            {
                SimID = 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);
            LotController.SelectedSimID = simID;
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 8;
            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;
        }
Пример #22
0
        public List<VMPieMenuInteraction> GetPieMenu(VM vm, VMEntity caller, bool includeHidden)
        {
            var pie = new List<VMPieMenuInteraction>();
            if (TreeTable == null) return pie;

            for (int i = 0; i < TreeTable.Interactions.Length; i++)
            {
                var id = TreeTable.Interactions[i].TTAIndex;
                var action = GetAction((int)id, caller, vm.Context);

                caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] = 0;
                if (action != null) action.Flags &= ~TTABFlags.MustRun;
                var actionStrings = caller.Thread.CheckAction(action);
                if (caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] == 1 && !includeHidden) continue;

                if (actionStrings != null)
                {
                    if (actionStrings.Count > 0)
                    {
                        foreach (var actionS in actionStrings)
                        {
                            actionS.ID = (byte)id;
                            actionS.Entry = TreeTable.Interactions[i];
                            pie.Add(actionS);
                        }
                    }
                    else
                    {
                        if (TreeTableStrings != null)
                        {
                            pie.Add(new VMPieMenuInteraction()
                            {
                                Name = TreeTableStrings.GetString((int)id),
                                ID = (byte)id,
                                Entry = TreeTable.Interactions[i]
                            });
                        }
                    }
                }
            }

            return pie;
        }
Пример #23
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);
            testimg = new UIImage();
            testimg.X = 20;
            testimg.Y = 20;
            this.Add(testimg);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 177;
            QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228;
            this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            vm.OnDialog += vm_OnDialog;
        }
Пример #24
0
 public void ChangeVM(VM target)
 {
     HookedVM = target;
     RefreshView();
 }
Пример #25
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 0;
            QueryPanel.Y = -114;
            //this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp

            vm.OnChatEvent += Vm_OnChatEvent;
            vm.OnDialog += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            EODs = new UIEODController(this);
        }
Пример #26
0
        // End Container SLOTs interface
        public List<VMPieMenuInteraction> GetPieMenu(VM vm, VMEntity caller)
        {
            var pie = new List<VMPieMenuInteraction>();
            if (TreeTable == null) return pie;

            for (int i = 0; i < TreeTable.Interactions.Length; i++)
            {
                var action = TreeTable.Interactions[i];

                bool CanRun = false;
                if (action.TestFunction != 0 && (((TTABFlags)action.Flags & TTABFlags.Debug) != TTABFlags.Debug))
                {
                    caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] = 0;
                    var Behavior = GetBHAVWithOwner(action.TestFunction, vm.Context);
                    CanRun = (VMThread.EvaluateCheck(vm.Context, caller, new VMQueuedAction()
                    {
                        Callee = this,
                        CodeOwner = Behavior.owner,
                        StackObject = this,
                        Routine = vm.Assemble(Behavior.bhav),
                    }) == VMPrimitiveExitCode.RETURN_TRUE);
                    if (caller.ObjectData[(int)VMStackObjectVariable.HideInteraction] == 1) CanRun = false;
                }
                else
                {
                    CanRun = true;
                }

                if (CanRun) pie.Add(new VMPieMenuInteraction()
                {
                    Name = TreeTableStrings.GetString((int)action.TTAIndex),
                    ID = (byte)action.TTAIndex
                });
            }

            return pie;
        }
        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;
        }
Пример #28
0
        public void SetGUIDLocal(uint id, VM TempVM)
        {
            oldGUID = id;
            GUID = id;
            if (TempVM != null)
            {
                if (TargetOBJ != null) TargetOBJ.Delete(TempVM.Context);
                //create our master, center camera on target object
                var objDefinition = FSO.Content.Content.Get().WorldObjects.Get(GUID);

                if (objDefinition != null)
                {
                    var masterID = id;
                    var notMaster = objDefinition.OBJ.MasterID != 0 && objDefinition.OBJ.SubIndex != -1;
                    if (notMaster)
                    {
                        //find the master
                        var master = objDefinition.Resource.List<OBJD>().FirstOrDefault(x => x.MasterID == objDefinition.OBJ.MasterID && x.SubIndex == -1);
                        if (master != null) masterID = master.GUID;
                    }
                    TargetOBJ = TempVM.Context.CreateObjectInstance(masterID, LotTilePos.OUT_OF_WORLD, Direction.SOUTH, true);
                    TargetOBJ.SetVisualPosition(new Vector3(0.5f, 0.5f, 0f), Direction.SOUTH, TempVM.Context);
                    TempVM.Entities = TargetOBJ.Objects;
                    if (TargetOBJ == null) return;
                    TargetTile = TargetOBJ.Objects.FirstOrDefault(x => x.Object.OBJ.GUID == id);
                    if (TargetTile == null) TargetTile = TargetOBJ.BaseObject;
                    var tile = TargetTile.VisualPosition;
                    TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - new Vector2(2.5f, 2.5f);
                    foreach (var obj in TargetOBJ.Objects)
                    {
                        if (obj is VMGameObject) ((ObjectComponent)obj.WorldUI).renderInfo.Layer = LotView.WorldObjectRenderLayer.DYNAMIC;
                        if (notMaster && obj.Object.OBJ.GUID != id) obj.SetRoom(2);
                    }
                }
            }
        }
Пример #29
0
        public override void Update(UpdateState state)
        {
            base.Update(state);
            if (TempVM == null && GUID != 0)
            {
                var world = new ExternalWorld(GameFacade.GraphicsDevice);
                world.Initialize(GameFacade.Scenes);
                var context = new VMContext(world);

                TempVM = new VM(context, new VMServerDriver(37565, null), new VMNullHeadlineProvider());
                TempVM.Init();

                var blueprint = new Blueprint(32, 32);
                blueprint.Light = new RoomLighting[]
                {
                    new RoomLighting() { OutsideLight = 100 },
                    new RoomLighting() { OutsideLight = 100 },
                    new RoomLighting() { OutsideLight = 100 },
                };
                blueprint.OutsideColor = Color.White;
                blueprint.GenerateRoomLights();
                blueprint.RoomColors[2].A /= 2;
                world.State._2D.AmbientLight.SetData(blueprint.RoomColors);

                world.InitBlueprint(blueprint);
                context.Blueprint = blueprint;
                context.Architecture = new VMArchitecture(1, 1, blueprint, TempVM.Context);
            }

            if (GUID != oldGUID)
            {
                SetGUIDLocal(GUID, TempVM);
                state.SharedData["ExternalDraw"] = true;
            }

            if (ForceRedraw)
            {
                state.SharedData["ExternalDraw"] = true;
                ForceRedraw = false;
            }

            if (TempVM != null) TempVM.Update();
        }
Пример #30
0
 public void Test(VM vm)
 {
     ObjectRegistry.Init();
     this.HookedVM = vm;
     entityInspector1.ChangeVM(vm);
     Browser.RefreshTree();
 }
Пример #31
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(Path.Combine(FSOEnvironment.UserDir, "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;
        }
Пример #32
0
        public override void Update(UpdateState state)
        {
            base.Update(state);
            if (TempVM == null && GUID != 0)
            {
                var world = new ExternalWorld(GameFacade.GraphicsDevice);
                world.Initialize(GameFacade.Scenes);
                var context = new VMContext(world);

                TempVM = new VM(context, new VMServerDriver(37565, null), new VMNullHeadlineProvider());
                TempVM.Init();

                var blueprint = new Blueprint(1, 1);
                world.InitBlueprint(blueprint);
                context.Blueprint = blueprint;
                context.Architecture = new VMArchitecture(1, 1, blueprint, TempVM.Context);
            }

            if (GUID != oldGUID)
            {
                SetGUIDLocal(GUID);
                state.SharedData["ExternalDraw"] = true;
            }
        }
Пример #33
0
        public BHAVEditor(VM vm, VMEntity entity)
            : this()
        {
            DebugMode = true;
            DebugEntity = entity;
            Text = "Tracer - " + entity.ToString() + " (ID " + entity.ObjectID + ")";

            UpdateStack();
            Editor.DisableDebugger += DisableDebugger;
        }
Пример #34
0
 public UIInteractionQueue(VMEntity QueueOwner, VM vm)
 {
     this.vm = vm;
     this.QueueOwner = QueueOwner;
     QueueItems = new List<UIIQTrackEntry>();
 }
Пример #35
0
 public UIObjectHolder(VM vm, LotView.World World, UILotControl parent)
 {
     this.vm = vm;
     this.World = World;
     ParentControl = parent;
 }
Пример #36
0
 /// <summary>
 /// An empty UICheatTextbox
 /// </summary>
 public UICheatTextbox(FSO.SimAntics.VM vm) : this(vm, "")
 {
 }