Esempio n. 1
0
        public World(WSFile ws, string planetName)
        {
            this.ws = ws;
            this.planetName = planetName;
            this.quadtree = new List<WSFile.WSNode>[8, 8];

            oldObjects = new Hashtable();
            ParseOldObjects();

            for (int x = 0; x < 8; x++)
                for (int z = 0; z < 8; z++)
                    quadtree[x, z] = new List<WSFile.WSNode>();

            foreach (WSFile.WSNode n in ws.Nodes)
                AddNode(n);
        }
Esempio n. 2
0
        public FormWSFind(WSFile wsFile)
        {
            InitializeComponent();
              this.m_WSFile = wsFile;

              InitializeDataTable();
              foreach (String type in this.m_WSFile.Types) {
            String ObjectType = FormIFFILFWSEditor.WSObjectType(type);
            this.m_DataTable.Rows.Add(new Object[] { ((ObjectType == String.Empty) ? "Unknown" : ObjectType) , type });
              }

              DataSet dataSet = new DataSet();
              DataSetHelper dataSetHelper = new DataSetHelper(ref dataSet);
              DataTable dataTableTypes = dataSetHelper.SelectDistinct("Types", this.m_DataTable, "Type");

              this.comboBoxTypes.Items.Clear();
              foreach (DataRow dataRow in dataTableTypes.Rows) {
            this.comboBoxTypes.Items.Add(dataRow["Type"]);
              }
              this.comboBoxTypes.SelectedIndex = 0;
        }
Esempio n. 3
0
        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);

              if (!this.Visible) {
            this.m_IFFFile = null;
            this.dataGridViewIff.DataSource = null;
            this.m_ILFFile = null;
            this.m_WSFile = null;
            if (this.m_DynamicByteProviderWS != null) {
              this.m_DynamicByteProviderWS = null;
            }
            if (this.m_DynamicByteProviderIFF != null) {
              this.m_DynamicByteProviderIFF = null;
            }
            this.treeViewIff.Nodes.Clear();
            this.toolStripButtonIffSave.Enabled = false;
            this.toolStripButtonIffSaveAs.Enabled = false;
              } else {
            this.hexBoxIff_Resize(this.hexBoxIff, new EventArgs());
              }
        }
Esempio n. 4
0
        private void WSRecurseNode(WSFile.WSNode[] wsNodes, TreeNode treeBranch)
        {
            foreach (WSFile.WSNode wsNode in wsNodes) {
            String ObjectType = WSObjectType(this.m_WSFile.Types[wsNode.ObjectIndex]);
            TreeNode treeNode = new TreeNode();
            treeNode.Name = wsNode.ID.ToString();
            treeNode.Text = wsNode.ID.ToString() + ((ObjectType != String.Empty) ? " [" + ObjectType + "]" : "");
            treeNode.Tag = wsNode.ObjectIndex;
            if (wsNode.ParentID == 0) {
              treeBranch.Nodes.Add(treeNode);
            } else {
              List<Int32> listID = new List<Int32>();
              WSFile.WSNode tempWSNode = wsNode;
              while ((tempWSNode != null) && (tempWSNode.ParentID != 0)) {
            listID.Add(tempWSNode.ParentID);
            tempWSNode = m_WSFile.FindNodeByID(tempWSNode.ParentID);
              }
              listID.Reverse();
              TreeNode tempTreeNode = this.treeViewIff.Nodes[0];
              foreach (Int32 ID in listID) {
            tempTreeNode = tempTreeNode.Nodes[tempTreeNode.Nodes.IndexOfKey(ID.ToString())];
              }
              tempTreeNode.Nodes.Add(treeNode);
            }

            if (wsNode.Nodes.Count > 0) {
              treeNode.ImageIndex = 1;
              this.WSRecurseNode(wsNode.Nodes.ToArray(), treeNode);
            } else {
              treeNode.ImageIndex = 0;
            }
              }
        }
Esempio n. 5
0
        internal void IFFLoadFile(String filename)
        {
            this.treeViewIff.ContextMenuStrip = null;

              if (filename.ToLower().EndsWith(".ilf")) {
            this.ILFLoadFile(filename);
            return;
              }

              if (filename.ToLower().EndsWith(".ws")) {
            this.WSLoadFile(filename);
            return;
              }

              this.m_ILFFile = null;
              this.m_WSFile = null;

              try {
            try {
              this.m_IFFFile = new IFFFile(filename);
            } catch (Exception exception) {
              MessageBox.Show(exception.Message, "TRE Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
              this.Visible = false;
              return;
            }

            try {
              this.HasChangesChanged -= new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);
            } catch {
            }

            if ((this.m_IFFFile != null) && (this.m_IFFFile.Filename != null) && (this.m_IFFFile.Filename != String.Empty)) {
              if (!this.m_IFFFile.Filename.Contains("\\")) {
            this.m_IFFFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_IFFFile.Filename);
              } else if (this.m_IFFFile.Filename.StartsWith(Path.GetTempPath())) {
            this.m_IFFFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_IFFFile.Filename.Substring(Path.GetTempPath().Length));
              }
            }

            this.splitContainerIff.Visible = false;
            this.dataGridViewIff.Visible = false;
            this.panelIlf.Visible = false;
            this.panelWs.Visible = false;
            this.hexBoxIff.Visible = false;
            this.m_ILFFile = null;
            this.hexBoxIff.ByteProvider = null;
            this.m_DynamicByteProviderIFF = null;
            this.toolStripSeparator3.Visible = false;
            this.toolStripTextBoxSearch.Visible = false;
            this.toolStripButtonSearch.Visible = false;

            if (this.m_IFFFile.IsDataTable) {
              this.dataGridViewIff.DataSource = this.m_IFFFile.DataTable;
              this.dataGridViewIff.Visible = true;
            } else {
              this.treeViewIff.ContextMenuStrip = this.contextMenuStripTreeViewIFF;

              this.treeViewIff.Nodes.Clear();
              IFFRecurseNode(this.m_IFFFile.Node, CreateIFFNode(this.m_IFFFile.Node));

              this.splitContainerIff.Visible = true;
              this.hexBoxIff.Visible = true;

              this.treeViewIff.SelectedNode = this.treeViewIff.Nodes[0];
            }

            this.toolStripButtonIffSaveAs.Enabled = true;

            this.HasChanges = false;
            this.HasChangesChanged += new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);

            this.Focus();
              } catch (Exception exception) {
            MessageBox.Show(exception.Message, "TRE Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            this.Visible = false;
              }
        }
Esempio n. 6
0
        private void WSLoadFile(String filename)
        {
            this.treeViewIff.ContextMenuStrip = null;

              this.splitContainerIff.Visible = false;
              this.dataGridViewIff.Visible = false;
              this.panelIlf.Visible = false;
              this.hexBoxIff.Visible = false;
              this.m_IFFFile = null;
              this.m_ILFFile = null;

              this.m_WSFile = new WSFile(filename);

              try {
            this.HasChangesChanged -= new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);
              } catch {
              }

              if ((this.m_WSFile != null) && (this.m_WSFile.Filename != null) && (this.m_WSFile.Filename != String.Empty)) {
            if (!this.m_WSFile.Filename.Contains("\\")) {
              this.m_WSFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_WSFile.Filename);
            } else if (this.m_WSFile.Filename.StartsWith(Path.GetTempPath())) {
              this.m_WSFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_WSFile.Filename.Substring(Path.GetTempPath().Length));
            }
              }

              this.comboBoxWsObject.SuspendLayout();
              this.comboBoxWsObject.Items.Clear();
              this.comboBoxWsObject.Items.AddRange(this.m_WSFile.Types);
              this.comboBoxWsObject.ResumeLayout(false);

              this.treeViewIff.SuspendLayout();
              this.treeViewIff.Nodes.Clear();
              TreeNode treeNode = new TreeNode();
              treeNode.Name = "WSNPFORM";
              treeNode.Text = "WSNPFORM";
              treeNode.ImageIndex = 1;
              this.treeViewIff.Nodes.Add(treeNode);
              this.WSRecurseNode(m_WSFile.Nodes.ToArray(), this.treeViewIff.Nodes[0]);
              this.treeViewIff.ResumeLayout(false);
              this.splitContainerIff.Visible = true;
              this.panelWs.Visible = true;
              this.toolStripButtonIffManageItems.Visible = true;

              this.toolStripButtonIffSaveAs.Enabled = true;

              this.HasChanges = false;
              this.HasChangesChanged += new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);
        }
Esempio n. 7
0
        private void ILFLoadFile(String filename)
        {
            this.treeViewIff.ContextMenuStrip = null;

              try {
            this.HasChangesChanged -= new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);
              } catch {
              }

              this.splitContainerIff.Visible = false;
              this.dataGridViewIff.Visible = false;
              this.panelIlf.Visible = false;
              this.panelWs.Visible = false;
              this.hexBoxIff.Visible = false;
              this.m_IFFFile = null;
              this.m_WSFile = null;

              try {
            this.m_ILFFile = new ILFFile(filename);

            if ((this.m_ILFFile != null) && (this.m_ILFFile.Filename != null) && (this.m_ILFFile.Filename != String.Empty)) {
              if (!this.m_ILFFile.Filename.Contains("\\")) {
            this.m_ILFFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_ILFFile.Filename);
              } else if (this.m_ILFFile.Filename.StartsWith(Path.GetTempPath())) {
            this.m_ILFFile.Filename = Path.Combine(this.m_FormNotifyIcon.saveFileDialog.InitialDirectory, this.m_ILFFile.Filename.Substring(Path.GetTempPath().Length));
              }
            }

            this.treeViewIff.SuspendLayout();
            this.treeViewIff.Nodes.Clear();
            this.treeViewIff.Nodes.Add("INLYFORM", "INLYFORM");
            this.treeViewIff.Nodes[0].ImageIndex = 1;

            foreach (ILFFile.ILFNode ilfChunk in this.m_ILFFile.Nodes) {
              TreeNode treeNode = new TreeNode(ilfChunk.Object);
              treeNode.Name = ilfChunk.Object;
              treeNode.Tag = ilfChunk.Object;
              this.treeViewIff.Nodes[0].Nodes.Add(treeNode);
            }
            this.treeViewIff.ResumeLayout(false);
            this.splitContainerIff.Visible = true;
            this.panelIlf.Visible = true;

            this.toolStripButtonIffSaveAs.Enabled = true;

            this.HasChanges = false;
            this.HasChangesChanged += new HasChangesChangedEvent(FormIFFILFWSEditor_HasChangesChanged);
              } catch {
              }
        }
Esempio n. 8
0
        private string BuildEntry(WSFile ws, WSFile.WSNode n, int cellIndex)
        {
            StringBuilder b = new StringBuilder();

            // Append values of WS node matching format of buildout
            // tables
            b.Append(n.ID + "\t");
            b.Append(n.ParentID + "\t");
            b.Append(ws.Types[n.ObjectIndex].Replace("shared_", "") + "\t");
            b.Append(cellIndex + "\t");

            // Child objects have local (to parent) coordinates
            bool isContained = n.ParentID != 0;

            b.Append((isContained ? n.X : (n.X + 8192) % 2048) + "\t");
            b.Append((isContained ? n.Y : (n.Y + 8192) % 2048) + "\t");
            b.Append((isContained ? n.Z : (n.Z + 8192) % 2048) + "\t");

            // SWGLib has W and Y quarternion axis switched
            b.Append(n.oY + "\t");
            b.Append(n.oX + "\t");
            b.Append(n.oW + "\t");
            b.Append(n.oZ + "\t");

            // Pull objvars and scripts from old exported snapshots
            if(oldObjects.ContainsKey((long) n.ID))
            {
                ScriptObjvarPair pair = (ScriptObjvarPair) oldObjects[(long) n.ID];
                b.Append(pair.scripts + "\t");
                b.Append(pair.objvars);
            }
            else
            {
                b.Append("\t"); // scripts
                b.Append("$|"); // objvars
            }

            // We've finished building entry for current object
            b.AppendLine();

            // Process children if they exist
            if (n.Nodes.Count > 0)
            {
                int _cellIndex = 1;

                foreach (WSFile.WSNode c in n.Nodes)
                {
                    bool isCell = ws.Types[c.ObjectIndex] == "object/cell/shared_cell.iff";
                    b.Append(BuildEntry(ws, c, isCell ? _cellIndex++ : 0));
                }
            }

            // We've finished building the entry for this WSNode
            // object
            return b.ToString();
        }
Esempio n. 9
0
 private void AddNode(WSFile.WSNode n)
 {
     quadtree[Math.Abs((int)((n.X + 8192) / 2048)), Math.Abs((int)((n.Z + 8192) / 2048))].Add(n);
 }
Esempio n. 10
0
        private String[] SearchNodes(WSFile.WSNode[] wsNodes)
        {
            this.m_DataView.RowFilter = "Name LIKE '%/" + this.comboBoxItemNames.Text + "'";
              String ObjectName = this.m_DataView[0]["Name"].ToString();
              String ObjectType = FormIFFILFWSEditor.WSObjectType(ObjectName);

              List<String> listString = new List<String>();
              foreach (WSFile.WSNode wsNode in wsNodes) {
            if (this.m_WSFile.Types[wsNode.ObjectIndex] == ObjectName) {
              listString.Add(wsNode.ID + ((ObjectType != String.Empty) ? " [" + ObjectType + "]" : ""));
            }
            if (wsNode.Nodes.Count > 0) {
              listString.AddRange(SearchNodes(wsNode.Nodes.ToArray()));
            }
              }
              return listString.ToArray();
        }