상속: System.Windows.Forms.Form
예제 #1
0
        private void buttonLocateInstances_Click(object sender, EventArgs e)
        {
            if (!File.Exists(WorldImport.Instance.WorldFile))
            {
                MessageBox.Show("Need a valid world to search from.");
                return;
            }
            List <WorldImport.ObjectInstance> list = WorldImport.Instance.FindInstances(this.m_currentEntry.IdString);

            if (list.Count == 0)
            {
                MessageBox.Show("No instance of this entry could be found.");
                return;
            }
            using (WorldLocateInstanceForm worldLocateInstanceForm = new WorldLocateInstanceForm())
            {
                worldLocateInstanceForm.Instances = list;
                if (worldLocateInstanceForm.ShowDialog(this) == DialogResult.OK)
                {
                    WorldImport.ObjectInstance selectedInstance = worldLocateInstanceForm.SelectedInstance;
                    if (selectedInstance != null)
                    {
                        int num  = selectedInstance.sectorX - 3;
                        int num2 = selectedInstance.sectorY - 3;
                        if (WorldImport.Instance.ImportWorld(num, num2, (!string.IsNullOrEmpty(selectedInstance.layer)) ? new string[]
                        {
                            selectedInstance.layer
                        } : new string[0]))
                        {
                            Vec3 v = new Vec3(selectedInstance.localX, selectedInstance.localY, selectedInstance.localZ);
                            v.X += (float)((selectedInstance.sectorX - num) * 64);
                            v.Y += (float)((selectedInstance.sectorY - num2) * 64);
                            foreach (EditorObject current in ObjectManager.GetObjects())
                            {
                                if (current.IsValid && current.Entry.Id == this.m_currentEntry.Id)
                                {
                                    Vec3 position = current.Position;
                                    if ((position - v).Length <= 0.1f)
                                    {
                                        MainForm.Instance.CurrentTool = ToolObject.Instance;
                                        ToolObject.Instance.SwitchMode(ToolObject.Instance.MoveModeObj);
                                        EditorObjectSelection selection = EditorObjectSelection.Create();
                                        selection.AddObject(current);
                                        ToolObject.Instance.SetSelection(selection, current);
                                        Camera.Focus(current);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
 private void buttonLocateInstances_Click(object sender, EventArgs e)
 {
     if (!File.Exists(WorldImport.Instance.WorldFile))
     {
         MessageBox.Show("Need a valid world to search from.");
         return;
     }
     List<WorldImport.ObjectInstance> list = WorldImport.Instance.FindInstances(this.m_currentEntry.IdString);
     if (list.Count == 0)
     {
         MessageBox.Show("No instance of this entry could be found.");
         return;
     }
     using (WorldLocateInstanceForm worldLocateInstanceForm = new WorldLocateInstanceForm())
     {
         worldLocateInstanceForm.Instances = list;
         if (worldLocateInstanceForm.ShowDialog(this) == DialogResult.OK)
         {
             WorldImport.ObjectInstance selectedInstance = worldLocateInstanceForm.SelectedInstance;
             if (selectedInstance != null)
             {
                 int num = selectedInstance.sectorX - 3;
                 int num2 = selectedInstance.sectorY - 3;
                 if (WorldImport.Instance.ImportWorld(num, num2, (!string.IsNullOrEmpty(selectedInstance.layer)) ? new string[]
                 {
                     selectedInstance.layer
                 } : new string[0]))
                 {
                     Vec3 v = new Vec3(selectedInstance.localX, selectedInstance.localY, selectedInstance.localZ);
                     v.X += (float)((selectedInstance.sectorX - num) * 64);
                     v.Y += (float)((selectedInstance.sectorY - num2) * 64);
                     foreach (EditorObject current in ObjectManager.GetObjects())
                     {
                         if (current.IsValid && current.Entry.Id == this.m_currentEntry.Id)
                         {
                             Vec3 position = current.Position;
                             if ((position - v).Length <= 0.1f)
                             {
                                 MainForm.Instance.CurrentTool = ToolObject.Instance;
                                 ToolObject.Instance.SwitchMode(ToolObject.Instance.MoveModeObj);
                                 EditorObjectSelection selection = EditorObjectSelection.Create();
                                 selection.AddObject(current);
                                 ToolObject.Instance.SetSelection(selection, current);
                                 Camera.Focus(current);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
 }