From 318c857b6b56e00a72348b6faab8c9528ff670b7 Mon Sep 17 00:00:00 2001 From: igorseabra4 Date: Wed, 5 Dec 2018 18:18:38 -0300 Subject: [PATCH] faster opening/closing of hip, plat preview --- .../AddAsset/AddAssetDialog.Designer.cs | 1 + .../AddMultipleAssetDialog.Designer.cs | 1 + IndustrialPark/ArchiveEditor/ArchiveEditor.cs | 94 ++++--- .../ArchiveEditor/ArchiveEditorFunctions.cs | 154 +++++++---- .../ArchiveEditorFunctions_AssetEditing.cs | 2 +- .../ArchiveEditor/EventEditor.Designer.cs | 135 +++++++--- .../ArchiveEditor/ProgressBar.Designer.cs | 77 ++++++ IndustrialPark/ArchiveEditor/ProgressBar.cs | 37 +++ IndustrialPark/ArchiveEditor/ProgressBar.resx | 120 +++++++++ .../PlaceableAssets/AssetPLAT.cs | 239 +++++++++++++++++- .../Assets/ObjectAssets/DYNA/AssetDYNA.cs | 3 + .../Assets/ObjectAssets/DYNA/DynaType.cs | 6 +- .../DYNA/MovieGame/DynaCrate_MovieGame.cs | 238 +++++++++++++++++ .../Assets/Shared/PlaceableAsset.cs | 44 +++- IndustrialPark/IndustrialPark.csproj | 10 + IndustrialPark/MainForm/AboutBox.Designer.cs | 2 +- IndustrialPark/MainForm/MainForm.Designer.cs | 96 ++++--- IndustrialPark/MainForm/MainForm.cs | 27 +- IndustrialPark/SharpDX/TextureManager.cs | 8 +- 19 files changed, 1111 insertions(+), 183 deletions(-) create mode 100644 IndustrialPark/ArchiveEditor/ProgressBar.Designer.cs create mode 100644 IndustrialPark/ArchiveEditor/ProgressBar.cs create mode 100644 IndustrialPark/ArchiveEditor/ProgressBar.resx create mode 100644 IndustrialPark/Assets/ObjectAssets/DYNA/MovieGame/DynaCrate_MovieGame.cs diff --git a/IndustrialPark/ArchiveEditor/AddAsset/AddAssetDialog.Designer.cs b/IndustrialPark/ArchiveEditor/AddAsset/AddAssetDialog.Designer.cs index da97b1ff..2be17e46 100644 --- a/IndustrialPark/ArchiveEditor/AddAsset/AddAssetDialog.Designer.cs +++ b/IndustrialPark/ArchiveEditor/AddAsset/AddAssetDialog.Designer.cs @@ -286,6 +286,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "AddAssetDialog"; this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Asset Header"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); diff --git a/IndustrialPark/ArchiveEditor/AddAsset/AddMultipleAssetDialog.Designer.cs b/IndustrialPark/ArchiveEditor/AddAsset/AddMultipleAssetDialog.Designer.cs index d112e5f3..a9d30211 100644 --- a/IndustrialPark/ArchiveEditor/AddAsset/AddMultipleAssetDialog.Designer.cs +++ b/IndustrialPark/ArchiveEditor/AddAsset/AddMultipleAssetDialog.Designer.cs @@ -138,6 +138,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "AddMultipleAssetDialog"; this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Add Multiple Assets"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs index 2c4ec3e0..9ec7970e 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs @@ -22,6 +22,9 @@ public ArchiveEditor(string filePath) archive = new ArchiveEditorFunctions(); defaultColor = textBoxFindAsset.BackColor; + textBoxFindAsset.AutoCompleteSource = AutoCompleteSource.CustomSource; + archive.SetTextboxForAutocomplete(textBoxFindAsset); + programIsChangingStuff = true; foreach (LayerType o in Enum.GetValues(typeof(LayerType))) @@ -34,9 +37,6 @@ public ArchiveEditor(string filePath) if (!string.IsNullOrWhiteSpace(filePath)) OpenFile(filePath); - textBoxFindAsset.AutoCompleteSource = AutoCompleteSource.CustomSource; - textBoxFindAsset.AutoCompleteCustomSource = archive.autoCompleteSource; - MainForm.PopulateTemplateMenusAt(addTemplateToolStripMenuItem, TemplateToolStripMenuItem_Click); listViewAssets_SizeChanged(null, null); } @@ -95,8 +95,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e) }; if (openFile.ShowDialog() == DialogResult.OK) { - Thread t = new Thread(() => OpenFile(openFile.FileName)); - t.Start(); + OpenFile(openFile.FileName); } } @@ -104,14 +103,6 @@ private void OpenFile(string fileName) { archive.OpenFile(fileName); - if (!InvokeRequired) - FinishedOpening(fileName); - else - Invoke(new Action(FinishedOpening), fileName); - } - - private void FinishedOpening(string fileName) - { toolStripStatusLabelCurrentFilename.Text = "File: " + fileName; Text = Path.GetFileName(fileName); Program.MainForm.SetToolStripItemName(this, Text); @@ -129,7 +120,7 @@ private void FinishedOpening(string fileName) PopulateLayerComboBox(); PopulateAssetList(); } - + private void saveToolStripMenuItem_Click(object sender, EventArgs e) { Save(); @@ -178,13 +169,13 @@ public void CloseArchiveEditor() { archive.Dispose(); - Program.MainForm.CloseAssetEditor(this); + Program.MainForm.CloseArchiveEditor(this); Close(); } - public void DisposeAll() + public void DisposeForClosing() { - archive.Dispose(); + archive.DisposeForClosing(); } private bool programIsChangingStuff = false; @@ -361,40 +352,44 @@ private void PopulateAssetListAndComboBox() AssetType curType = AssetType.Null; - private void PopulateAssetList(AssetType type = AssetType.Null) + private void PopulateAssetList(AssetType type = AssetType.Null, bool select = false, List selectionAssetIDs = null) { curType = type; listViewAssets.BeginUpdate(); listViewAssets.Items.Clear(); + int ensureVisible = -1; + if (comboBoxLayers.SelectedItem != null) { List assetIDs = archive.DICT.LTOC.LHDRList[comboBoxLayers.SelectedIndex].assetIDlist; + List items = new List(); for (int i = 0; i < assetIDs.Count(); i++) { Asset asset = archive.GetFromAssetID(assetIDs[i]); if (type == AssetType.Null || asset.AHDR.assetType == type) - listViewAssets.Items.Add(new ListViewItem(asset.ToString()) - { Checked = !asset.isInvisible }); - // assetList.Add(new Tuple(!asset.isInvisible, asset.ToString())); - } - - //assetList.Sort(); - - //programIsChangingStuff = true; + { + bool selected = (select == true) && selectionAssetIDs.Contains(asset.AHDR.assetID); + items.Add(new ListViewItem(asset.ToString()) + { + Checked = !asset.isInvisible, + Selected = selected + }); - //foreach (Tuple t in assetList) - //{ - // listViewAssets.Items.Add(new ListViewItem(t.Item2)); - // listViewAssets.Items[listViewAssets.Items.Count - 1].Checked = t.Item1; - //} + if (selected) + ensureVisible = items.Count - 1; + } + } - //programIsChangingStuff = false; + listViewAssets.Items.AddRange(items.ToArray()); } listViewAssets.EndUpdate(); + if (select) + listViewAssets.EnsureVisible(ensureVisible); + toolStripStatusLabelSelectionCount.Text = $"{listViewAssets.SelectedItems.Count}/{listViewAssets.Items.Count} assets selected"; } @@ -792,13 +787,10 @@ public void MouseMoveGeneric(Matrix viewProjection, int deltaX, int deltaY) public void SetSelectedIndices(List assetIDs, bool newlyAddedObjects, bool add = false) { - listViewAssets.BeginUpdate(); - if (assetIDs.Contains(0) && !add) { listViewAssets.SelectedIndices.Clear(); ArchiveEditorFunctions.UpdateGizmoPosition(); - listViewAssets.EndUpdate(); return; } @@ -812,14 +804,13 @@ public void SetSelectedIndices(List assetIDs, bool newlyAddedObjects, bool if (add) assetIDs.AddRange(CurrentlySelectedAssetIDs()); - listViewAssets.SelectedIndices.Clear(); - AssetType assetType = AssetType.Null; foreach (uint u in assetIDs) { assetType = archive.GetFromAssetID(u).AHDR.assetType; - comboBoxLayers.SelectedIndex = archive.GetLayerFromAssetID(u); + if (archive.GetLayerFromAssetID(u) != comboBoxLayers.SelectedIndex) + comboBoxLayers.SelectedIndex = archive.GetLayerFromAssetID(u); break; } @@ -827,28 +818,31 @@ public void SetSelectedIndices(List assetIDs, bool newlyAddedObjects, bool if (archive.GetFromAssetID(u).AHDR.assetType != assetType) { assetType = AssetType.Null; - comboBoxAssetTypes.SelectedIndex = 0; break; } if (curType != assetType || newlyAddedObjects) { - comboBoxAssetTypes.SelectedItem = assetType; - PopulateAssetList(assetType); - } + if (assetType == AssetType.Null) + comboBoxAssetTypes.SelectedIndex = 0; + else + comboBoxAssetTypes.SelectedItem = assetType; - int last = 0; - foreach (uint u in assetIDs) + PopulateAssetList(assetType, true, assetIDs); + return; + } + else { + listViewAssets.SelectedIndices.Clear(); + int last = 0; for (int i = 0; i < listViewAssets.Items.Count; i++) - if (GetAssetIDFromName(listViewAssets.Items[i].Text) == u) + if (assetIDs.Contains(GetAssetIDFromName(listViewAssets.Items[i].Text))) { listViewAssets.SelectedIndices.Add(i); last = i; } + listViewAssets.EnsureVisible(last); } - listViewAssets.EndUpdate(); - listViewAssets.EnsureVisible(last); } System.Drawing.Color defaultColor; @@ -869,10 +863,10 @@ private void textBoxFindAsset_TextChanged(object sender, EventArgs e) if (assetID != 0 && archive.ContainsAsset(assetID)) SetSelectedIndices(new List() { assetID }, false); else - foreach (ListViewItem v in listViewAssets.Items) - if (v.Text.ToLower().Contains(textBoxFindAsset.Text.ToLower()) && (v.Selected == false)) + foreach (Asset a in archive.GetAllAssets()) + if (a.AHDR.ADBG.assetName.ToLower().Contains(textBoxFindAsset.Text.ToLower()) && !a.isSelected) { - SetSelectedIndices(new List() { GetAssetIDFromName(v.Text) }, false); + SetSelectedIndices(new List() { a.AHDR.assetID }, false); return; } } diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs index fd9b3fea..a5753a7e 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Windows.Forms; @@ -30,7 +31,6 @@ public static void AddToRenderingDictionary(uint key, IAssetWithModel value) public Section_PACK PACK; public Section_DICT DICT; public Section_STRM STRM; - public AutoCompleteStringCollection autoCompleteSource = new AutoCompleteStringCollection(); public bool New() { @@ -59,7 +59,7 @@ public bool New() new ChoosePlatformDialog().ShowDialog(); foreach (Section_AHDR AHDR in DICT.ATOC.AHDRList) - AddAssetToDictionary(AHDR); + AddAssetToDictionary(AHDR, true); RecalculateAllMatrices(); } @@ -71,28 +71,49 @@ public void OpenFile(string fileName) allowRender = false; Dispose(); + ProgressBar progressBar = new ProgressBar("Opening Archive"); + progressBar.Show(); + + assetDictionary = new Dictionary(); currentlySelectedAssets = new List(); currentlyOpenFilePath = fileName; - HipSection[] HipFile = HipFileToHipArray(fileName); - foreach (HipSection i in HipFileToHipArray(fileName)) { if (i is Section_HIPA hipa) HIPA = hipa; else if (i is Section_PACK pack) PACK = pack; else if (i is Section_DICT dict) DICT = dict; else if (i is Section_STRM strm) STRM = strm; - else throw new Exception(); + else + { + progressBar.Close(); + throw new Exception(); + } } + progressBar.SetProgressBar(0, DICT.ATOC.AHDRList.Count, 1); + if (currentPlatform == Platform.Unknown) new ChoosePlatformDialog().ShowDialog(); + List autoComplete = new List(); + foreach (Section_AHDR AHDR in DICT.ATOC.AHDRList) - AddAssetToDictionary(AHDR); + { + AddAssetToDictionary(AHDR, true); + + autoComplete.Add(AHDR.ADBG.assetName); + + progressBar.PerformStep(); + } + + autoCompleteSource.AddRange(autoComplete.ToArray()); + RecalculateAllMatrices(); + progressBar.Close(); + allowRender = true; } @@ -134,26 +155,85 @@ public Dictionary.ValueCollection GetAllAssets() public void Dispose() { + autoCompleteSource.Clear(); + List assetList = new List(); assetList.AddRange(assetDictionary.Keys); + if (assetList.Count == 0) + return; + + ProgressBar progressBar = new ProgressBar("Closing Archive"); + progressBar.Show(); + progressBar.SetProgressBar(0, assetList.Count, 1); + foreach (uint assetID in assetList) - RemoveAsset(assetID); + { + DisposeOfAsset(assetID, true); + progressBar.PerformStep(); + } - if (DICT == null) return; HIPA = null; PACK = null; DICT = null; STRM = null; currentlyOpenFilePath = null; + + progressBar.Close(); + } + + public void DisposeForClosing() + { + List assetList = new List(); + assetList.AddRange(assetDictionary.Keys); + + ProgressBar progressBar = new ProgressBar("Closing Archive"); + progressBar.Show(); + progressBar.SetProgressBar(0, assetList.Count, 1); + + foreach (uint assetID in assetList) + { + if (assetDictionary[assetID] is AssetJSP jsp) + jsp.model.Dispose(); + else if (assetDictionary[assetID] is AssetMODL modl) + modl.GetRenderWareModelFile().Dispose(); + + progressBar.PerformStep(); + } + + progressBar.Close(); + } + + public void DisposeOfAsset(uint assetID, bool fast = false) + { + currentlySelectedAssets.Remove(assetDictionary[assetID]); + CloseInternalEditor(assetID); + + renderingDictionary.Remove(assetID); + + if (assetDictionary[assetID] is IRenderableAsset ra) + { + if (renderableAssetSetCommon.Contains(ra)) + renderableAssetSetCommon.Remove(ra); + else if (renderableAssetSetTrans.Contains(ra)) + renderableAssetSetTrans.Remove(ra); + else if (renderableAssetSetJSP.Contains(ra)) + renderableAssetSetJSP.Remove((AssetJSP)ra); + } + + if (assetDictionary[assetID] is AssetJSP jsp) + jsp.model.Dispose(); + + if (assetDictionary[assetID] is AssetMODL modl) + modl.GetRenderWareModelFile().Dispose(); } public static bool allowRender = true; - private void AddAssetToDictionary(Section_AHDR AHDR) + private void AddAssetToDictionary(Section_AHDR AHDR, bool fast = false) { allowRender = false; - + if (assetDictionary.ContainsKey(AHDR.assetID)) { assetDictionary.Remove(AHDR.assetID); @@ -594,12 +674,20 @@ private void AddAssetToDictionary(Section_AHDR AHDR) if (hiddenAssets.Contains(AHDR.assetID)) assetDictionary[AHDR.assetID].isInvisible = true; - if (assetDictionary[AHDR.assetID] is ObjectAsset oa) - autoCompleteSource.Add(AHDR.ADBG.assetName); - + autoCompleteSource.Add(AHDR.ADBG.assetName); + allowRender = true; } + + private AutoCompleteStringCollection autoCompleteSource = new AutoCompleteStringCollection(); + private TextBox textBoxFindAsset; + public void SetTextboxForAutocomplete(TextBox textBoxFindAsset) + { + this.textBoxFindAsset = textBoxFindAsset; + this.textBoxFindAsset.AutoCompleteCustomSource = autoCompleteSource; + } + public void RemoveLayer(int index) { RemoveAsset(DICT.LTOC.LHDRList[index].assetIDlist); @@ -676,41 +764,22 @@ public void RemoveAsset(IEnumerable assetIDs) public void RemoveAsset(uint assetID) { - UnselectAsset(assetID); - CloseInternalEditor(assetID); + DisposeOfAsset(assetID); + autoCompleteSource.Remove(assetDictionary[assetID].AHDR.ADBG.assetName); for (int i = 0; i < DICT.LTOC.LHDRList.Count; i++) DICT.LTOC.LHDRList[i].assetIDlist.Remove(assetID); - renderingDictionary.Remove(assetID); - if (GetFromAssetID(assetID).AHDR.assetType == AssetType.SND | GetFromAssetID(assetID).AHDR.assetType == AssetType.SNDS) RemoveSoundFromSNDI(assetID); - if (assetDictionary[assetID] is IRenderableAsset ra) - { - if (renderableAssetSetCommon.Contains(ra)) - renderableAssetSetCommon.Remove(ra); - else if (renderableAssetSetTrans.Contains(ra)) - renderableAssetSetTrans.Remove(ra); - else if (renderableAssetSetJSP.Contains(ra)) - renderableAssetSetJSP.Remove((AssetJSP)ra); - } - - if (assetDictionary[assetID] is AssetJSP jsp) - jsp.model.Dispose(); - - if (assetDictionary[assetID] is AssetMODL modl) - modl.GetRenderWareModelFile().Dispose(); - DICT.ATOC.AHDRList.Remove(assetDictionary[assetID].AHDR); - autoCompleteSource.Remove(assetDictionary[assetID].AHDR.ADBG.assetName); - assetDictionary.Remove(assetID); } private List currentlySelectedAssets = new List(); + private static List allCurrentlySelectedAssets { get @@ -730,20 +799,7 @@ public bool AssetIsSelected(uint assetID) return false; } - - public void UnselectAsset(uint assetID) - { - for (int i = 0; i < currentlySelectedAssets.Count; i++) - { - if (currentlySelectedAssets[i].AHDR.assetID == assetID) - { - currentlySelectedAssets[i].isSelected = false; - currentlySelectedAssets.RemoveAt(i); - return; - } - } - } - + public void ClearSelectedAssets() { for (int i = 0; i < currentlySelectedAssets.Count; i++) diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs index 396d7f85..bcc6e54e 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs @@ -186,7 +186,7 @@ public List FindWhoTargets(uint assetID) return whoTargets; } - + public void ExportHip(string fileName) { HipSection[] hipFile = SetupStream(ref HIPA, ref PACK, ref DICT, ref STRM); diff --git a/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs b/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs index 0068b9a2..35e862ce 100644 --- a/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs +++ b/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs @@ -53,6 +53,12 @@ private void InitializeComponent() this.comboSendEvent = new System.Windows.Forms.ComboBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.comboRecieveEvent = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBoxEventData.SuspendLayout(); this.groupBox6.SuspendLayout(); @@ -69,7 +75,7 @@ private void InitializeComponent() this.groupBox1.Controls.Add(this.listBoxEvents); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(301, 255); + this.groupBox1.Size = new System.Drawing.Size(310, 255); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Events"; @@ -83,7 +89,7 @@ private void InitializeComponent() this.listBoxEvents.Location = new System.Drawing.Point(6, 19); this.listBoxEvents.Name = "listBoxEvents"; this.listBoxEvents.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxEvents.Size = new System.Drawing.Size(289, 225); + this.listBoxEvents.Size = new System.Drawing.Size(298, 225); this.listBoxEvents.TabIndex = 1; this.listBoxEvents.SelectedIndexChanged += new System.EventHandler(this.listBoxEvents_SelectedIndexChanged); // @@ -134,7 +140,7 @@ private void InitializeComponent() // buttonArrowDown // this.buttonArrowDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonArrowDown.Location = new System.Drawing.Point(319, 59); + this.buttonArrowDown.Location = new System.Drawing.Point(183, 302); this.buttonArrowDown.Name = "buttonArrowDown"; this.buttonArrowDown.Size = new System.Drawing.Size(22, 22); this.buttonArrowDown.TabIndex = 7; @@ -145,7 +151,7 @@ private void InitializeComponent() // buttonArrowUp // this.buttonArrowUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.buttonArrowUp.Location = new System.Drawing.Point(319, 31); + this.buttonArrowUp.Location = new System.Drawing.Point(183, 274); this.buttonArrowUp.Name = "buttonArrowUp"; this.buttonArrowUp.Size = new System.Drawing.Size(22, 22); this.buttonArrowUp.TabIndex = 6; @@ -156,9 +162,9 @@ private void InitializeComponent() // buttonOK // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(355, 299); + this.buttonOK.Location = new System.Drawing.Point(336, 299); this.buttonOK.Name = "buttonOK"; - this.buttonOK.Size = new System.Drawing.Size(104, 23); + this.buttonOK.Size = new System.Drawing.Size(112, 23); this.buttonOK.TabIndex = 18; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; @@ -168,9 +174,9 @@ private void InitializeComponent() // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(465, 299); + this.buttonCancel.Location = new System.Drawing.Point(454, 299); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(104, 23); + this.buttonCancel.Size = new System.Drawing.Size(112, 23); this.buttonCancel.TabIndex = 19; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; @@ -183,15 +189,21 @@ private void InitializeComponent() this.groupBoxEventData.Controls.Add(this.groupBox5); this.groupBoxEventData.Controls.Add(this.groupBox4); this.groupBoxEventData.Controls.Add(this.groupBox3); - this.groupBoxEventData.Location = new System.Drawing.Point(347, 12); + this.groupBoxEventData.Location = new System.Drawing.Point(328, 12); this.groupBoxEventData.Name = "groupBoxEventData"; - this.groupBoxEventData.Size = new System.Drawing.Size(226, 281); + this.groupBoxEventData.Size = new System.Drawing.Size(244, 281); this.groupBoxEventData.TabIndex = 2; this.groupBoxEventData.TabStop = false; this.groupBoxEventData.Text = "Event Data"; // // groupBox6 // + this.groupBox6.Controls.Add(this.label5); + this.groupBox6.Controls.Add(this.label6); + this.groupBox6.Controls.Add(this.label4); + this.groupBox6.Controls.Add(this.label3); + this.groupBox6.Controls.Add(this.label2); + this.groupBox6.Controls.Add(this.label1); this.groupBox6.Controls.Add(this.checkBoxHex); this.groupBox6.Controls.Add(this.textBox5); this.groupBox6.Controls.Add(this.textBox6); @@ -201,7 +213,7 @@ private void InitializeComponent() this.groupBox6.Controls.Add(this.textBox1); this.groupBox6.Location = new System.Drawing.Point(8, 178); this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(214, 99); + this.groupBox6.Size = new System.Drawing.Size(230, 99); this.groupBox6.TabIndex = 4; this.groupBox6.TabStop = false; this.groupBox6.Text = "Arguments"; @@ -209,7 +221,7 @@ private void InitializeComponent() // checkBoxHex // this.checkBoxHex.AutoSize = true; - this.checkBoxHex.Location = new System.Drawing.Point(163, 0); + this.checkBoxHex.Location = new System.Drawing.Point(173, 0); this.checkBoxHex.Name = "checkBoxHex"; this.checkBoxHex.Size = new System.Drawing.Size(45, 17); this.checkBoxHex.TabIndex = 11; @@ -219,54 +231,54 @@ private void InitializeComponent() // // textBox5 // - this.textBox5.Location = new System.Drawing.Point(6, 71); + this.textBox5.Location = new System.Drawing.Point(25, 71); this.textBox5.Name = "textBox5"; - this.textBox5.Size = new System.Drawing.Size(98, 20); + this.textBox5.Size = new System.Drawing.Size(86, 20); this.textBox5.TabIndex = 16; this.textBox5.TextChanged += new System.EventHandler(this.textBox5_TextChanged); this.textBox5.Leave += new System.EventHandler(this.textBox_Leave); // // textBox6 // - this.textBox6.Location = new System.Drawing.Point(110, 71); + this.textBox6.Location = new System.Drawing.Point(136, 71); this.textBox6.Name = "textBox6"; - this.textBox6.Size = new System.Drawing.Size(98, 20); + this.textBox6.Size = new System.Drawing.Size(85, 20); this.textBox6.TabIndex = 17; this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged); this.textBox6.Leave += new System.EventHandler(this.textBox_Leave); // // textBox3 // - this.textBox3.Location = new System.Drawing.Point(6, 45); + this.textBox3.Location = new System.Drawing.Point(25, 45); this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(98, 20); + this.textBox3.Size = new System.Drawing.Size(86, 20); this.textBox3.TabIndex = 14; this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); this.textBox3.Leave += new System.EventHandler(this.textBox_Leave); // // textBox4 // - this.textBox4.Location = new System.Drawing.Point(110, 45); + this.textBox4.Location = new System.Drawing.Point(136, 46); this.textBox4.Name = "textBox4"; - this.textBox4.Size = new System.Drawing.Size(98, 20); + this.textBox4.Size = new System.Drawing.Size(85, 20); this.textBox4.TabIndex = 15; this.textBox4.TextChanged += new System.EventHandler(this.textBox4_TextChanged); this.textBox4.Leave += new System.EventHandler(this.textBox_Leave); // // textBox2 // - this.textBox2.Location = new System.Drawing.Point(110, 19); + this.textBox2.Location = new System.Drawing.Point(136, 19); this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(98, 20); + this.textBox2.Size = new System.Drawing.Size(85, 20); this.textBox2.TabIndex = 13; this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); this.textBox2.Leave += new System.EventHandler(this.textBox_Leave); // // textBox1 // - this.textBox1.Location = new System.Drawing.Point(6, 19); + this.textBox1.Location = new System.Drawing.Point(25, 19); this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(98, 20); + this.textBox1.Size = new System.Drawing.Size(86, 20); this.textBox1.TabIndex = 12; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); this.textBox1.Leave += new System.EventHandler(this.textBox_Leave); @@ -276,7 +288,7 @@ private void InitializeComponent() this.groupBox5.Controls.Add(this.textBoxTargetAsset); this.groupBox5.Location = new System.Drawing.Point(8, 125); this.groupBox5.Name = "groupBox5"; - this.groupBox5.Size = new System.Drawing.Size(214, 47); + this.groupBox5.Size = new System.Drawing.Size(230, 47); this.groupBox5.TabIndex = 3; this.groupBox5.TabStop = false; this.groupBox5.Text = "Target Asset"; @@ -286,7 +298,7 @@ private void InitializeComponent() this.textBoxTargetAsset.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.textBoxTargetAsset.Location = new System.Drawing.Point(6, 19); this.textBoxTargetAsset.Name = "textBoxTargetAsset"; - this.textBoxTargetAsset.Size = new System.Drawing.Size(202, 20); + this.textBoxTargetAsset.Size = new System.Drawing.Size(218, 20); this.textBoxTargetAsset.TabIndex = 10; this.textBoxTargetAsset.TextChanged += new System.EventHandler(this.textBoxTargetAsset_TextChanged); this.textBoxTargetAsset.Leave += new System.EventHandler(this.textBoxTargetAsset_Leave); @@ -296,7 +308,7 @@ private void InitializeComponent() this.groupBox4.Controls.Add(this.comboSendEvent); this.groupBox4.Location = new System.Drawing.Point(8, 72); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(214, 47); + this.groupBox4.Size = new System.Drawing.Size(230, 47); this.groupBox4.TabIndex = 2; this.groupBox4.TabStop = false; this.groupBox4.Text = "Send Event"; @@ -306,7 +318,7 @@ private void InitializeComponent() this.comboSendEvent.FormattingEnabled = true; this.comboSendEvent.Location = new System.Drawing.Point(6, 19); this.comboSendEvent.Name = "comboSendEvent"; - this.comboSendEvent.Size = new System.Drawing.Size(202, 21); + this.comboSendEvent.Size = new System.Drawing.Size(218, 21); this.comboSendEvent.TabIndex = 9; this.comboSendEvent.SelectedIndexChanged += new System.EventHandler(this.comboSendEvent_SelectedIndexChanged); // @@ -315,7 +327,7 @@ private void InitializeComponent() this.groupBox3.Controls.Add(this.comboRecieveEvent); this.groupBox3.Location = new System.Drawing.Point(6, 19); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(214, 47); + this.groupBox3.Size = new System.Drawing.Size(232, 47); this.groupBox3.TabIndex = 1; this.groupBox3.TabStop = false; this.groupBox3.Text = "Recieve Event"; @@ -325,17 +337,71 @@ private void InitializeComponent() this.comboRecieveEvent.FormattingEnabled = true; this.comboRecieveEvent.Location = new System.Drawing.Point(6, 19); this.comboRecieveEvent.Name = "comboRecieveEvent"; - this.comboRecieveEvent.Size = new System.Drawing.Size(204, 21); + this.comboRecieveEvent.Size = new System.Drawing.Size(220, 21); this.comboRecieveEvent.TabIndex = 8; this.comboRecieveEvent.SelectedIndexChanged += new System.EventHandler(this.comboRecieveEvent_SelectedIndexChanged); // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(13, 13); + this.label1.TabIndex = 20; + this.label1.Text = "1"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 48); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(13, 13); + this.label2.TabIndex = 21; + this.label2.Text = "3"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 74); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(13, 13); + this.label3.TabIndex = 22; + this.label3.Text = "5"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(117, 22); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(13, 13); + this.label4.TabIndex = 23; + this.label4.Text = "2"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(117, 74); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(13, 13); + this.label5.TabIndex = 25; + this.label5.Text = "6"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(117, 49); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(13, 13); + this.label6.TabIndex = 24; + this.label6.Text = "4"; + // // EventEditor // this.AcceptButton = this.buttonOK; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(581, 334); + this.ClientSize = new System.Drawing.Size(584, 334); this.Controls.Add(this.groupBoxEventData); this.Controls.Add(this.buttonOK); this.Controls.Add(this.buttonCancel); @@ -350,6 +416,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "EventEditor"; this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Event Editor"; this.groupBox1.ResumeLayout(false); this.groupBoxEventData.ResumeLayout(false); @@ -390,5 +457,11 @@ private void InitializeComponent() private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.CheckBox checkBoxHex; private System.Windows.Forms.TextBox textBoxTargetAsset; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; } } \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/ProgressBar.Designer.cs b/IndustrialPark/ArchiveEditor/ProgressBar.Designer.cs new file mode 100644 index 00000000..354a0f5a --- /dev/null +++ b/IndustrialPark/ArchiveEditor/ProgressBar.Designer.cs @@ -0,0 +1,77 @@ +namespace IndustrialPark +{ + partial class ProgressBar + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.labelLoading = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // progressBar1 + // + this.progressBar1.Location = new System.Drawing.Point(12, 12); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(382, 23); + this.progressBar1.TabIndex = 0; + // + // labelLoading + // + this.labelLoading.AutoSize = true; + this.labelLoading.Location = new System.Drawing.Point(12, 38); + this.labelLoading.Name = "labelLoading"; + this.labelLoading.Size = new System.Drawing.Size(0, 13); + this.labelLoading.TabIndex = 1; + // + // ProgressBar + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(406, 57); + this.ControlBox = false; + this.Controls.Add(this.labelLoading); + this.Controls.Add(this.progressBar1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ProgressBar"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Opening Archive"; + this.TopMost = true; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.Label labelLoading; + } +} \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/ProgressBar.cs b/IndustrialPark/ArchiveEditor/ProgressBar.cs new file mode 100644 index 00000000..63a5e9c3 --- /dev/null +++ b/IndustrialPark/ArchiveEditor/ProgressBar.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace IndustrialPark +{ + public partial class ProgressBar : Form + { + public ProgressBar(string text) + { + InitializeComponent(); + Text = text; + } + + public void SetProgressBar(int min, int max, int step) + { + progressBar1.Minimum = min; + progressBar1.Maximum = max; + progressBar1.Step = step; + progressBar1.Value = 0; + } + + public void PerformStep() + { + progressBar1.PerformStep(); + labelLoading.Text = $"Asset {progressBar1.Value}/{progressBar1.Maximum}"; + if (progressBar1.Value >= progressBar1.Maximum) + Close(); + } + } +} diff --git a/IndustrialPark/ArchiveEditor/ProgressBar.resx b/IndustrialPark/ArchiveEditor/ProgressBar.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/IndustrialPark/ArchiveEditor/ProgressBar.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLAT.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLAT.cs index b6ae11ce..b46948f5 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLAT.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLAT.cs @@ -1,5 +1,6 @@ using HipHopFile; using SharpDX; +using System; using System.ComponentModel; namespace IndustrialPark @@ -26,6 +27,236 @@ public override bool HasReference(uint assetID) return base.HasReference(assetID); } + private enum CurrentMovementAction + { + StartWait, + Going, + EndWait, + GoingBack + } + + public static bool playingPlat = false; + private float localFrameCounter = -1; + private int amountOfMovementsPerformed = 0; + + private CurrentMovementAction currentMovementAction = CurrentMovementAction.StartWait; + + private float StartWaitRange => 60 * (Movement_StartPointWait); + private float GoingRange => StartWaitRange + 60 * Math.Max(MovementMode == 0 ? 0 : MovementRotation_Time, MovementMode != 1 ? MovementTranslation_Time : 0); + private float EndWaitRange => GoingRange + 60 * Movement_EndPointWait; + private float GoingBackRange => EndWaitRange + 60 * Math.Max(MovementMode == 0 ? 0 : MovementRotation_Time, MovementMode != 1 ? MovementTranslation_Time : 0); + + public void Reset() + { + currentMovementAction = CurrentMovementAction.StartWait; + localFrameCounter = -1; + amountOfMovementsPerformed = 0; + } + + private Matrix PlatLocalTranslation() + { + Matrix localWorld = Matrix.Identity; + + if (MovementMode != 1) + { + float translationMultiplier = 0; + + switch (MovementLoopType) + { + case 0: + switch (currentMovementAction) + { + case CurrentMovementAction.StartWait: + translationMultiplier = amountOfMovementsPerformed; + if (localFrameCounter >= StartWaitRange) + currentMovementAction = CurrentMovementAction.Going; + break; + + case CurrentMovementAction.Going: + translationMultiplier = amountOfMovementsPerformed + Math.Min(1f, (localFrameCounter - StartWaitRange) / (60 * MovementTranslation_Time)); + + if (localFrameCounter >= GoingRange) + { + amountOfMovementsPerformed++; + currentMovementAction = CurrentMovementAction.StartWait; + localFrameCounter = 0; + } + break; + } + break; + case 1: + case 2: + switch (currentMovementAction) + { + case CurrentMovementAction.StartWait: + if (localFrameCounter >= StartWaitRange) + currentMovementAction = CurrentMovementAction.Going; + break; + + case CurrentMovementAction.Going: + translationMultiplier = Math.Min(1, (localFrameCounter - StartWaitRange) / (60 * MovementTranslation_Time)); + if (localFrameCounter >= GoingRange) + currentMovementAction = CurrentMovementAction.EndWait; + break; + + case CurrentMovementAction.EndWait: + translationMultiplier = 1; + if (localFrameCounter >= EndWaitRange) + currentMovementAction = CurrentMovementAction.GoingBack; + break; + + case CurrentMovementAction.GoingBack: + translationMultiplier = 1 - Math.Min(1, (localFrameCounter - EndWaitRange) / (60 * MovementTranslation_Time)); + if (localFrameCounter >= GoingBackRange) + { + currentMovementAction = CurrentMovementAction.StartWait; + localFrameCounter = 0; + } + break; + } + break; + } + + switch (MovementTranslation_Direction) + { + case 0: + localWorld *= Matrix.Translation(translationMultiplier * MovementTranslation_Distance_98, 0, 0); + break; + case 1: + localWorld *= Matrix.Translation(0, translationMultiplier * MovementTranslation_Distance_98, 0); + break; + case 2: + localWorld *= Matrix.Translation(0, 0, translationMultiplier * MovementTranslation_Distance_98); + break; + } + } + + return localWorld; + } + + private Matrix PlatLocalRotation() + { + Matrix localWorld = Matrix.Identity; + + if (MovementMode >= 1) + { + float rotationMultiplier = 0; + + switch (MovementLoopType) + { + case 0: + switch (currentMovementAction) + { + case CurrentMovementAction.StartWait: + rotationMultiplier = amountOfMovementsPerformed; + if (localFrameCounter >= StartWaitRange) + currentMovementAction = CurrentMovementAction.Going; + break; + + case CurrentMovementAction.Going: + rotationMultiplier = amountOfMovementsPerformed + Math.Min(1f, (localFrameCounter - StartWaitRange) / (60 * MovementRotation_Time)); + + if (localFrameCounter >= GoingRange) + { + amountOfMovementsPerformed++; + currentMovementAction = CurrentMovementAction.StartWait; + localFrameCounter = 0; + } + break; + } + break; + case 1: + case 2: + switch (currentMovementAction) + { + case CurrentMovementAction.StartWait: + if (localFrameCounter >= StartWaitRange) + currentMovementAction = CurrentMovementAction.Going; + break; + + case CurrentMovementAction.Going: + rotationMultiplier = Math.Min(1, (localFrameCounter - StartWaitRange) / (60 * MovementRotation_Time)); + if (localFrameCounter >= GoingRange) + currentMovementAction = CurrentMovementAction.EndWait; + break; + + case CurrentMovementAction.EndWait: + rotationMultiplier = 1; + if (localFrameCounter >= EndWaitRange) + currentMovementAction = CurrentMovementAction.GoingBack; + break; + + case CurrentMovementAction.GoingBack: + rotationMultiplier = 1 - Math.Min(1, (localFrameCounter - EndWaitRange) / (60 * MovementRotation_Time)); + if (localFrameCounter >= GoingBackRange) + { + currentMovementAction = CurrentMovementAction.StartWait; + localFrameCounter = 0; + } + break; + } + break; + } + + switch (MovementRotation_Direction) + { + case 0: + localWorld = Matrix.RotationX(rotationMultiplier * MathUtil.DegreesToRadians(MovementRotation_Degrees)); + break; + case 1: + localWorld = Matrix.RotationY(rotationMultiplier * MathUtil.DegreesToRadians(MovementRotation_Degrees)); + break; + case 2: + localWorld = Matrix.RotationZ(rotationMultiplier * MathUtil.DegreesToRadians(MovementRotation_Degrees)); + break; + } + } + + return localWorld; + } + + protected override Matrix LocalWorld() + { + if (playingPlat) + { + AssetPLAT driver = FindDrivenByAsset(out bool found); + + if (found) + { + return Matrix.Scaling(_scale) + * PlatLocalRotation() * PlatLocalTranslation() + * Matrix.RotationYawPitchRoll(_yaw, _pitch, _roll) + * Matrix.RotationYawPitchRoll( + (float)Math.Acos(((Vector3)Vector3.Transform(Vector3.UnitX, driver.LocalWorld())).X), + (float)Math.Acos(((Vector3)Vector3.Transform(Vector3.UnitX, driver.LocalWorld())).Y), + (float)Math.Acos(((Vector3)Vector3.Transform(Vector3.UnitZ, driver.LocalWorld())).Y)) + * Matrix.Translation(_position - driver._position) + * Matrix.Translation((Vector3)Vector3.Transform(Vector3.Zero, driver.LocalWorld())); + } + + return Matrix.Scaling(_scale) + * PlatLocalRotation() * PlatLocalTranslation() + * Matrix.RotationYawPitchRoll(_yaw, _pitch, _roll) + * Matrix.Translation(_position); + } + + return world; + } + + public override void Draw(SharpRenderer renderer) + { + if (playingPlat) + localFrameCounter++; + + if (DontRender || isInvisible) + return; + + if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(_modelAssetID)) + ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * _color : _color); + else + renderer.DrawCube(LocalWorld(), isSelected); + } + [Browsable(false)] public override AssetID ReferenceAssetID { @@ -195,28 +426,28 @@ public byte UnknownByte_93 } [Category("Platform")] - public byte UnknownByte_94 + public byte MovementMode { get => ReadByte(0x94 + Offset); set => Write(0x94 + Offset, value); } [Category("Platform")] - public byte UnknownByte_95 + public byte MovementLoopType { get => ReadByte(0x95 + Offset); set => Write(0x95 + Offset, value); } [Category("Platform")] - public byte UnknownByte_96 + public byte MovementTranslation_Direction { get => ReadByte(0x96 + Offset); set => Write(0x96 + Offset, value); } [Category("Platform")] - public byte UnknownByte_97 + public byte MovementRotation_Direction { get => ReadByte(0x97 + Offset); set => Write(0x97 + Offset, value); diff --git a/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs b/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs index ccb8333a..bde64edd 100644 --- a/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs +++ b/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs @@ -94,6 +94,9 @@ private void SetDynaSpecific(bool reset) case DynaType.hud__text: _dynaSpecific = reset ? new DynaHudText() : new DynaHudText(Data.Skip(0x10).Take(EventStartOffset)); break; + case DynaType.movieGame_Crate: + _dynaSpecific = reset ? new DynaCrate_MovieGame() : new DynaCrate_MovieGame(Data.Skip(0x10).Take(EventStartOffset)); + break; default: //System.Windows.Forms.MessageBox.Show("Unknown DYNA type found: [" + ((int)Type).ToString("X8") + "] on asset " + ToString() + "."); _dynaSpecific = reset ? new DynaBase() : new DynaBase(Data.Skip(0x10).Take(EventStartOffset)); diff --git a/IndustrialPark/Assets/ObjectAssets/DYNA/DynaType.cs b/IndustrialPark/Assets/ObjectAssets/DYNA/DynaType.cs index 03939f82..70f33804 100644 --- a/IndustrialPark/Assets/ObjectAssets/DYNA/DynaType.cs +++ b/IndustrialPark/Assets/ObjectAssets/DYNA/DynaType.cs @@ -18,6 +18,10 @@ public enum DynaType : uint hud__model​ = 0xFF5691D2, hud__meter__font​ = 0x8B3E732F, hud__meter__unit​ = 0x8D40B9AC, - hud__text = 0x687ED0B0 + hud__text = 0x687ED0B0, + movieGame_Crate = 0x495BFF9B, + movieGame_Fogger= 0x44EA147A, + movieGame_RingControl = 0x18028CA7, + movieGame_Ring = 0x4D81C1EE } } \ No newline at end of file diff --git a/IndustrialPark/Assets/ObjectAssets/DYNA/MovieGame/DynaCrate_MovieGame.cs b/IndustrialPark/Assets/ObjectAssets/DYNA/MovieGame/DynaCrate_MovieGame.cs new file mode 100644 index 00000000..ca916ad4 --- /dev/null +++ b/IndustrialPark/Assets/ObjectAssets/DYNA/MovieGame/DynaCrate_MovieGame.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using SharpDX; +using static IndustrialPark.ConverterFunctions; + +namespace IndustrialPark +{ + public class DynaCrate_MovieGame : DynaBase + { + public override string Note => "Version is always 2"; + + public DynaCrate_MovieGame() : base() + { + SurfaceAssetID = 0; + ModelAssetID = 0; + Unknown4C = 0; + Unknown50 = 0; + } + + public DynaCrate_MovieGame(IEnumerable enumerable) : base (enumerable) + { + Unknown00 = Switch(BitConverter.ToInt32(Data, 0x0)); + Unknown04 = Data[0x04]; + Unknown05 = Data[0x05]; + Flags06 = Switch(BitConverter.ToInt16(Data, 0x06)); + VisibilityFlag = Data[0x08]; + TypeFlag = Data[0x08]; + UnknownFlag0A = Data[0x08]; + SolidityFlag = Data[0x08]; + SurfaceAssetID = Switch(BitConverter.ToUInt32(Data, 0x0C)); + Yaw = Switch(BitConverter.ToSingle(Data, 0x10)); + Pitch = Switch(BitConverter.ToSingle(Data, 0x14)); + Roll = Switch(BitConverter.ToSingle(Data, 0x18)); + PositionX = Switch(BitConverter.ToSingle(Data, 0x1C)); + PositionY = Switch(BitConverter.ToSingle(Data, 0x20)); + PositionZ = Switch(BitConverter.ToSingle(Data, 0x24)); + ScaleX = Switch(BitConverter.ToSingle(Data, 0x28)); + ScaleY = Switch(BitConverter.ToSingle(Data, 0x2C)); + ScaleZ = Switch(BitConverter.ToSingle(Data, 0x30)); + ColorRed = Switch(BitConverter.ToSingle(Data, 0x34)); + ColorGreen = Switch(BitConverter.ToSingle(Data, 0x38)); + ColorBlue = Switch(BitConverter.ToSingle(Data, 0x3C)); + ColorAlpha = Switch(BitConverter.ToSingle(Data, 0x40)); + UnknownFloat44 = Switch(BitConverter.ToSingle(Data, 0x44)); + ModelAssetID = Switch(BitConverter.ToUInt32(Data, 0x48)); + Unknown4C = Switch(BitConverter.ToUInt32(Data, 0x4C)); + Unknown50 = Switch(BitConverter.ToUInt32(Data, 0x50)); + + CreateTransformMatrix(); + } + + public override bool IsRenderableClickable => true; + + private Matrix world; + private BoundingBox boundingBox; + + public override void CreateTransformMatrix() + { + world = Matrix.Scaling(ScaleX, ScaleY, ScaleZ) + * Matrix.RotationYawPitchRoll(Yaw, Pitch, Roll) + * Matrix.Translation(PositionX, PositionY, PositionZ); + + CreateBoundingBox(); + } + + protected virtual void CreateBoundingBox() + { + List vertexList = new List(); + if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(ModelAssetID) && + ArchiveEditorFunctions.renderingDictionary[ModelAssetID].HasRenderWareModelFile() && + ArchiveEditorFunctions.renderingDictionary[ModelAssetID].GetRenderWareModelFile() != null) + { + CreateBoundingBox(ArchiveEditorFunctions.renderingDictionary[ModelAssetID].GetRenderWareModelFile().vertexListG); + } + else + { + CreateBoundingBox(SharpRenderer.cubeVertices, 0.5f); + } + } + + protected Vector3[] vertices; + protected RenderWareFile.Triangle[] triangles; + + protected void CreateBoundingBox(List vertexList, float multiplier = 1f) + { + vertices = new Vector3[vertexList.Count]; + + for (int i = 0; i < vertexList.Count; i++) + vertices[i] = (Vector3)Vector3.Transform(vertexList[i] * multiplier, world); + + boundingBox = BoundingBox.FromPoints(vertices); + + if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(ModelAssetID)) + { + if (ArchiveEditorFunctions.renderingDictionary[ModelAssetID] is AssetMINF MINF) + { + if (MINF.HasRenderWareModelFile()) + triangles = ArchiveEditorFunctions.renderingDictionary[ModelAssetID].GetRenderWareModelFile().triangleList.ToArray(); + else + triangles = null; + } + else + triangles = ArchiveEditorFunctions.renderingDictionary[ModelAssetID].GetRenderWareModelFile().triangleList.ToArray(); + } + else + triangles = null; + } + + public override void Draw(SharpRenderer renderer, bool isSelected) + { + Vector4 Color = new Vector4(ColorRed, ColorGreen, ColorBlue, ColorAlpha); + if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(ModelAssetID)) + ArchiveEditorFunctions.renderingDictionary[ModelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * Color : Color); + else + renderer.DrawCube(world, isSelected); + } + + public override float? IntersectsWith(Ray ray) + { + if (ray.Intersects(ref boundingBox, out float distance)) + return TriangleIntersection(ray, distance); + return null; + } + + protected float? TriangleIntersection(Ray r, float initialDistance) + { + if (triangles == null) + return initialDistance; + + bool hasIntersected = false; + float smallestDistance = 1000f; + + foreach (RenderWareFile.Triangle t in triangles) + if (r.Intersects(ref vertices[t.vertex1], ref vertices[t.vertex2], ref vertices[t.vertex3], out float distance)) + { + hasIntersected = true; + + if (distance < smallestDistance) + smallestDistance = distance; + } + + if (hasIntersected) + return smallestDistance; + return null; + } + + public override BoundingSphere GetGizmoCenter() + { + BoundingSphere boundingSphere = BoundingSphere.FromBox(boundingBox); + boundingSphere.Radius *= 0.9f; + return boundingSphere; + } + + public override BoundingBox GetBoundingBox() + { + return boundingBox; + } + + public override float GetDistance(Vector3 cameraPosition) + { + return Vector3.Distance(cameraPosition, new Vector3(PositionX, PositionY, PositionZ)); + } + + public override bool HasReference(uint assetID) + { + if (SurfaceAssetID == assetID) + return true; + if (ModelAssetID == assetID) + return true; + if (Unknown4C == assetID) + return true; + if (Unknown50 == assetID) + return true; + + return base.HasReference(assetID); + } + + public override byte[] ToByteArray() + { + List list = new List(); + list.AddRange(BitConverter.GetBytes(Switch(Unknown00))); + list.Add(Unknown04); + list.Add(Unknown05); + list.AddRange(BitConverter.GetBytes(Switch(Flags06))); + list.Add(VisibilityFlag); + list.Add(TypeFlag); + list.Add(UnknownFlag0A); + list.Add(SolidityFlag); + list.AddRange(BitConverter.GetBytes(Switch(SurfaceAssetID))); + list.AddRange(BitConverter.GetBytes(Switch(Yaw))); + list.AddRange(BitConverter.GetBytes(Switch(Pitch))); + list.AddRange(BitConverter.GetBytes(Switch(Roll))); + list.AddRange(BitConverter.GetBytes(Switch(PositionX))); + list.AddRange(BitConverter.GetBytes(Switch(PositionY))); + list.AddRange(BitConverter.GetBytes(Switch(PositionZ))); + list.AddRange(BitConverter.GetBytes(Switch(ScaleX))); + list.AddRange(BitConverter.GetBytes(Switch(ScaleY))); + list.AddRange(BitConverter.GetBytes(Switch(ScaleZ))); + list.AddRange(BitConverter.GetBytes(Switch(ColorRed))); + list.AddRange(BitConverter.GetBytes(Switch(ColorGreen))); + list.AddRange(BitConverter.GetBytes(Switch(ColorBlue))); + list.AddRange(BitConverter.GetBytes(Switch(ColorAlpha))); + list.AddRange(BitConverter.GetBytes(Switch(UnknownFloat44))); + list.AddRange(BitConverter.GetBytes(Switch(ModelAssetID))); + list.AddRange(BitConverter.GetBytes(Switch(Unknown4C))); + list.AddRange(BitConverter.GetBytes(Switch(Unknown50))); + return list.ToArray(); + } + + public int Unknown00 { get; set; } + public byte Unknown04 { get; set; } + public byte Unknown05 { get; set; } + public short Flags06 { get; set; } + public byte VisibilityFlag { get; set; } + public byte TypeFlag { get; set; } + public byte UnknownFlag0A { get; set; } + public byte SolidityFlag { get; set; } + public AssetID SurfaceAssetID { get; set; } + public float Yaw { get; set; } + public float Pitch { get; set; } + public float Roll { get; set; } + public override float PositionX { get; set; } + public override float PositionY { get; set; } + public override float PositionZ { get; set; } + public float ScaleX { get; set; } + public float ScaleY { get; set; } + public float ScaleZ { get; set; } + public float ColorRed { get; set; } + public float ColorGreen { get; set; } + public float ColorBlue { get; set; } + public float ColorAlpha { get; set; } + public float UnknownFloat44 { get; set; } + public AssetID ModelAssetID { get; set; } + public AssetID Unknown4C { get; set; } + public AssetID Unknown50 { get; set; } + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/PlaceableAsset.cs b/IndustrialPark/Assets/Shared/PlaceableAsset.cs index 31e9181a..89c0aaca 100644 --- a/IndustrialPark/Assets/Shared/PlaceableAsset.cs +++ b/IndustrialPark/Assets/Shared/PlaceableAsset.cs @@ -82,14 +82,52 @@ protected void CreateBoundingBox(List vertexList, float multiplier = 1f triangles = null; } + protected AssetPLAT FindDrivenByAsset(out bool found) + { + foreach (AssetEventBFBB assetEvent in EventsBFBB) + if (assetEvent.EventSendID == EventTypeBFBB.Drivenby) + { + uint PlatID = assetEvent.TargetAssetID; + + foreach (ArchiveEditor ae in Program.MainForm.archiveEditors) + if (ae.archive.ContainsAsset(PlatID)) + { + AssetPLAT PLAT = (AssetPLAT)ae.archive.GetFromAssetID(PlatID); + found = true; + return PLAT; + } + } + found = false; + return null; + } + + protected virtual Matrix LocalWorld() + { + if (AssetPLAT.playingPlat) + { + AssetPLAT driver = FindDrivenByAsset(out bool found); + + if (found) + { + return Matrix.Scaling(_scale) + * Matrix.RotationYawPitchRoll(_yaw, _pitch, _roll) + * Matrix.Translation(_position - driver._position) + * Matrix.Translation((Vector3)Vector3.Transform(Vector3.Zero, driver.LocalWorld())); + } + } + + return world; + } + public virtual void Draw(SharpRenderer renderer) { - if (DontRender || isInvisible) return; + if (DontRender || isInvisible) + return; if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(_modelAssetID)) - ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * _color : _color); + ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, LocalWorld(), isSelected ? renderer.selectedObjectColor * _color : _color); else - renderer.DrawCube(world, isSelected); + renderer.DrawCube(LocalWorld(), isSelected); } public virtual float? IntersectsWith(Ray ray) diff --git a/IndustrialPark/IndustrialPark.csproj b/IndustrialPark/IndustrialPark.csproj index 79f9b7d3..ed8022c0 100644 --- a/IndustrialPark/IndustrialPark.csproj +++ b/IndustrialPark/IndustrialPark.csproj @@ -108,6 +108,12 @@ + + Form + + + ProgressBar.cs + @@ -118,6 +124,7 @@ + @@ -313,6 +320,9 @@ EventEditor.cs Designer + + ProgressBar.cs + EventSearch.cs diff --git a/IndustrialPark/MainForm/AboutBox.Designer.cs b/IndustrialPark/MainForm/AboutBox.Designer.cs index ab62a55b..71b796c2 100644 --- a/IndustrialPark/MainForm/AboutBox.Designer.cs +++ b/IndustrialPark/MainForm/AboutBox.Designer.cs @@ -103,7 +103,7 @@ private void InitializeComponent() this.labelVersion.Name = "labelVersion"; this.labelVersion.Size = new System.Drawing.Size(271, 17); this.labelVersion.TabIndex = 0; - this.labelVersion.Text = "Preview 26"; + this.labelVersion.Text = "Preview 27"; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // labelCopyright diff --git a/IndustrialPark/MainForm/MainForm.Designer.cs b/IndustrialPark/MainForm/MainForm.Designer.cs index 7a0ed314..0224f1e5 100644 --- a/IndustrialPark/MainForm/MainForm.Designer.cs +++ b/IndustrialPark/MainForm/MainForm.Designer.cs @@ -47,6 +47,7 @@ private void InitializeComponent() this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addTextureFolderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addTXDArchiveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearTexturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.manageUserTemplatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); @@ -91,6 +92,8 @@ private void InitializeComponent() this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.uIModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.uIModeAutoSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.researchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.eventSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); @@ -107,8 +110,7 @@ private void InitializeComponent() this.toolStripMenuItem_Templates = new System.Windows.Forms.ToolStripMenuItem(); this.userTemplateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripComboBoxUserTemplate = new System.Windows.Forms.ToolStripComboBox(); - this.researchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.eventSearchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pLATPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.contextMenuStripMain.SuspendLayout(); @@ -220,6 +222,7 @@ private void InitializeComponent() this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.viewConfigToolStripMenuItem, this.addTextureFolderToolStripMenuItem, + this.addTXDArchiveToolStripMenuItem, this.clearTexturesToolStripMenuItem, this.manageUserTemplatesToolStripMenuItem, this.toolStripSeparator4, @@ -249,6 +252,13 @@ private void InitializeComponent() this.addTextureFolderToolStripMenuItem.Text = "Add Texture Folder"; this.addTextureFolderToolStripMenuItem.Click += new System.EventHandler(this.addTextureFolderToolStripMenuItem_Click); // + // addTXDArchiveToolStripMenuItem + // + this.addTXDArchiveToolStripMenuItem.Name = "addTXDArchiveToolStripMenuItem"; + this.addTXDArchiveToolStripMenuItem.Size = new System.Drawing.Size(219, 22); + this.addTXDArchiveToolStripMenuItem.Text = "Add TXD Archive"; + this.addTXDArchiveToolStripMenuItem.Click += new System.EventHandler(this.addTXDArchiveToolStripMenuItem_Click); + // // clearTexturesToolStripMenuItem // this.clearTexturesToolStripMenuItem.Name = "clearTexturesToolStripMenuItem"; @@ -420,6 +430,7 @@ private void InitializeComponent() this.uIFTToolStripMenuItem, this.vILToolStripMenuItem, this.toolStripSeparator1, + this.pLATPreviewToolStripMenuItem, this.uIModeToolStripMenuItem, this.uIModeAutoSizeToolStripMenuItem}); this.displayToolStripMenuItem.Name = "displayToolStripMenuItem"; @@ -431,7 +442,7 @@ private void InitializeComponent() this.levelModelToolStripMenuItem.Checked = true; this.levelModelToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.levelModelToolStripMenuItem.Name = "levelModelToolStripMenuItem"; - this.levelModelToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.levelModelToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.levelModelToolStripMenuItem.Text = "BSP/JSP"; this.levelModelToolStripMenuItem.Click += new System.EventHandler(this.levelModelToolStripMenuItem_Click); // @@ -440,7 +451,7 @@ private void InitializeComponent() this.bOULToolStripMenuItem.Checked = true; this.bOULToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.bOULToolStripMenuItem.Name = "bOULToolStripMenuItem"; - this.bOULToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.bOULToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.bOULToolStripMenuItem.Text = "BOUL"; this.bOULToolStripMenuItem.Click += new System.EventHandler(this.bOULToolStripMenuItem_Click); // @@ -449,7 +460,7 @@ private void InitializeComponent() this.bUTNToolStripMenuItem.Checked = true; this.bUTNToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.bUTNToolStripMenuItem.Name = "bUTNToolStripMenuItem"; - this.bUTNToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.bUTNToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.bUTNToolStripMenuItem.Text = "BUTN"; this.bUTNToolStripMenuItem.Click += new System.EventHandler(this.bUTNToolStripMenuItem_Click); // @@ -458,7 +469,7 @@ private void InitializeComponent() this.cAMToolStripMenuItem.Checked = true; this.cAMToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.cAMToolStripMenuItem.Name = "cAMToolStripMenuItem"; - this.cAMToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.cAMToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.cAMToolStripMenuItem.Text = "CAM"; this.cAMToolStripMenuItem.Click += new System.EventHandler(this.cAMToolStripMenuItem_Click); // @@ -467,7 +478,7 @@ private void InitializeComponent() this.dSTRToolStripMenuItem.Checked = true; this.dSTRToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.dSTRToolStripMenuItem.Name = "dSTRToolStripMenuItem"; - this.dSTRToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.dSTRToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.dSTRToolStripMenuItem.Text = "DSTR"; this.dSTRToolStripMenuItem.Click += new System.EventHandler(this.dSTRToolStripMenuItem_Click); // @@ -476,7 +487,7 @@ private void InitializeComponent() this.dYNAToolStripMenuItem.Checked = true; this.dYNAToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.dYNAToolStripMenuItem.Name = "dYNAToolStripMenuItem"; - this.dYNAToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.dYNAToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.dYNAToolStripMenuItem.Text = "DYNA"; this.dYNAToolStripMenuItem.Click += new System.EventHandler(this.dYNAToolStripMenuItem_Click); // @@ -485,7 +496,7 @@ private void InitializeComponent() this.eGENToolStripMenuItem.Checked = true; this.eGENToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.eGENToolStripMenuItem.Name = "eGENToolStripMenuItem"; - this.eGENToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.eGENToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.eGENToolStripMenuItem.Text = "EGEN"; this.eGENToolStripMenuItem.Click += new System.EventHandler(this.eGENToolStripMenuItem_Click); // @@ -494,7 +505,7 @@ private void InitializeComponent() this.hANGToolStripMenuItem.Checked = true; this.hANGToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.hANGToolStripMenuItem.Name = "hANGToolStripMenuItem"; - this.hANGToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.hANGToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.hANGToolStripMenuItem.Text = "HANG"; this.hANGToolStripMenuItem.Click += new System.EventHandler(this.hANGToolStripMenuItem_Click); // @@ -503,7 +514,7 @@ private void InitializeComponent() this.mRKRToolStripMenuItem.Checked = true; this.mRKRToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.mRKRToolStripMenuItem.Name = "mRKRToolStripMenuItem"; - this.mRKRToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.mRKRToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.mRKRToolStripMenuItem.Text = "MRKR"; this.mRKRToolStripMenuItem.Click += new System.EventHandler(this.mRKRToolStripMenuItem_Click); // @@ -512,7 +523,7 @@ private void InitializeComponent() this.mVPTToolStripMenuItem.Checked = true; this.mVPTToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.mVPTToolStripMenuItem.Name = "mVPTToolStripMenuItem"; - this.mVPTToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.mVPTToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.mVPTToolStripMenuItem.Text = "MVPT"; this.mVPTToolStripMenuItem.Click += new System.EventHandler(this.mVPTToolStripMenuItem_Click); // @@ -521,7 +532,7 @@ private void InitializeComponent() this.pENDToolStripMenuItem.Checked = true; this.pENDToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.pENDToolStripMenuItem.Name = "pENDToolStripMenuItem"; - this.pENDToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.pENDToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.pENDToolStripMenuItem.Text = "PEND"; this.pENDToolStripMenuItem.Click += new System.EventHandler(this.pENDToolStripMenuItem_Click); // @@ -530,7 +541,7 @@ private void InitializeComponent() this.pKUPToolStripMenuItem.Checked = true; this.pKUPToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.pKUPToolStripMenuItem.Name = "pKUPToolStripMenuItem"; - this.pKUPToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.pKUPToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.pKUPToolStripMenuItem.Text = "PKUP"; this.pKUPToolStripMenuItem.Click += new System.EventHandler(this.pKUPToolStripMenuItem_Click); // @@ -539,7 +550,7 @@ private void InitializeComponent() this.pLATToolStripMenuItem.Checked = true; this.pLATToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.pLATToolStripMenuItem.Name = "pLATToolStripMenuItem"; - this.pLATToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.pLATToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.pLATToolStripMenuItem.Text = "PLAT"; this.pLATToolStripMenuItem.Click += new System.EventHandler(this.pLATToolStripMenuItem_Click); // @@ -548,7 +559,7 @@ private void InitializeComponent() this.pLYRToolStripMenuItem.Checked = true; this.pLYRToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.pLYRToolStripMenuItem.Name = "pLYRToolStripMenuItem"; - this.pLYRToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.pLYRToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.pLYRToolStripMenuItem.Text = "PLYR"; this.pLYRToolStripMenuItem.Click += new System.EventHandler(this.pLYRToolStripMenuItem_Click); // @@ -557,7 +568,7 @@ private void InitializeComponent() this.sFXToolStripMenuItem.Checked = true; this.sFXToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.sFXToolStripMenuItem.Name = "sFXToolStripMenuItem"; - this.sFXToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.sFXToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.sFXToolStripMenuItem.Text = "SFX"; this.sFXToolStripMenuItem.Click += new System.EventHandler(this.sFXToolStripMenuItem_Click); // @@ -566,7 +577,7 @@ private void InitializeComponent() this.sIMPToolStripMenuItem.Checked = true; this.sIMPToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.sIMPToolStripMenuItem.Name = "sIMPToolStripMenuItem"; - this.sIMPToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.sIMPToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.sIMPToolStripMenuItem.Text = "SIMP"; this.sIMPToolStripMenuItem.Click += new System.EventHandler(this.sIMPToolStripMenuItem_Click); // @@ -575,7 +586,7 @@ private void InitializeComponent() this.tRIGToolStripMenuItem.Checked = true; this.tRIGToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.tRIGToolStripMenuItem.Name = "tRIGToolStripMenuItem"; - this.tRIGToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.tRIGToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.tRIGToolStripMenuItem.Text = "TRIG"; this.tRIGToolStripMenuItem.Click += new System.EventHandler(this.tRIGToolStripMenuItem_Click); // @@ -584,7 +595,7 @@ private void InitializeComponent() this.uIToolStripMenuItem.Checked = true; this.uIToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.uIToolStripMenuItem.Name = "uIToolStripMenuItem"; - this.uIToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.uIToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.uIToolStripMenuItem.Text = "UI"; this.uIToolStripMenuItem.Click += new System.EventHandler(this.uIToolStripMenuItem_Click); // @@ -593,7 +604,7 @@ private void InitializeComponent() this.uIFTToolStripMenuItem.Checked = true; this.uIFTToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.uIFTToolStripMenuItem.Name = "uIFTToolStripMenuItem"; - this.uIFTToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.uIFTToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.uIFTToolStripMenuItem.Text = "UIFT"; this.uIFTToolStripMenuItem.Click += new System.EventHandler(this.uIFTToolStripMenuItem_Click); // @@ -602,29 +613,44 @@ private void InitializeComponent() this.vILToolStripMenuItem.Checked = true; this.vILToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.vILToolStripMenuItem.Name = "vILToolStripMenuItem"; - this.vILToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.vILToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.vILToolStripMenuItem.Text = "VIL"; this.vILToolStripMenuItem.Click += new System.EventHandler(this.vILToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(165, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); // // uIModeToolStripMenuItem // this.uIModeToolStripMenuItem.Name = "uIModeToolStripMenuItem"; - this.uIModeToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.uIModeToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.uIModeToolStripMenuItem.Text = "UI Mode (U)"; this.uIModeToolStripMenuItem.Click += new System.EventHandler(this.uIModeToolStripMenuItem_Click); // // uIModeAutoSizeToolStripMenuItem // this.uIModeAutoSizeToolStripMenuItem.Name = "uIModeAutoSizeToolStripMenuItem"; - this.uIModeAutoSizeToolStripMenuItem.Size = new System.Drawing.Size(168, 22); + this.uIModeAutoSizeToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.uIModeAutoSizeToolStripMenuItem.Text = "UI Mode AutoSize"; this.uIModeAutoSizeToolStripMenuItem.Click += new System.EventHandler(this.uIModeAutoSizeToolStripMenuItem_Click); // + // researchToolStripMenuItem + // + this.researchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.eventSearchToolStripMenuItem}); + this.researchToolStripMenuItem.Name = "researchToolStripMenuItem"; + this.researchToolStripMenuItem.Size = new System.Drawing.Size(66, 20); + this.researchToolStripMenuItem.Text = "Research"; + // + // eventSearchToolStripMenuItem + // + this.eventSearchToolStripMenuItem.Name = "eventSearchToolStripMenuItem"; + this.eventSearchToolStripMenuItem.Size = new System.Drawing.Size(141, 22); + this.eventSearchToolStripMenuItem.Text = "Event Search"; + this.eventSearchToolStripMenuItem.Click += new System.EventHandler(this.eventSearchToolStripMenuItem_Click); + // // statusStrip1 // this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); @@ -753,20 +779,12 @@ private void InitializeComponent() this.toolStripComboBoxUserTemplate.Size = new System.Drawing.Size(160, 23); this.toolStripComboBoxUserTemplate.SelectedIndexChanged += new System.EventHandler(this.toolStripComboBoxUserTemplate_SelectedIndexChanged); // - // researchToolStripMenuItem - // - this.researchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.eventSearchToolStripMenuItem}); - this.researchToolStripMenuItem.Name = "researchToolStripMenuItem"; - this.researchToolStripMenuItem.Size = new System.Drawing.Size(66, 20); - this.researchToolStripMenuItem.Text = "Research"; - // - // eventSearchToolStripMenuItem + // pLATPreviewToolStripMenuItem // - this.eventSearchToolStripMenuItem.Name = "eventSearchToolStripMenuItem"; - this.eventSearchToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.eventSearchToolStripMenuItem.Text = "Event Search"; - this.eventSearchToolStripMenuItem.Click += new System.EventHandler(this.eventSearchToolStripMenuItem_Click); + this.pLATPreviewToolStripMenuItem.Name = "pLATPreviewToolStripMenuItem"; + this.pLATPreviewToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.pLATPreviewToolStripMenuItem.Text = "PLAT Preview"; + this.pLATPreviewToolStripMenuItem.Click += new System.EventHandler(this.pLATPreviewToolStripMenuItem_Click); // // MainForm // @@ -878,6 +896,8 @@ private void InitializeComponent() private ToolStripMenuItem positionLocalToolStripMenuItem; private ToolStripMenuItem researchToolStripMenuItem; private ToolStripMenuItem eventSearchToolStripMenuItem; + private ToolStripMenuItem addTXDArchiveToolStripMenuItem; + private ToolStripMenuItem pLATPreviewToolStripMenuItem; } } diff --git a/IndustrialPark/MainForm/MainForm.cs b/IndustrialPark/MainForm/MainForm.cs index c4ddb5af..6545b380 100644 --- a/IndustrialPark/MainForm/MainForm.cs +++ b/IndustrialPark/MainForm/MainForm.cs @@ -36,6 +36,7 @@ private void MainForm_Load(object sender, EventArgs e) #if !DEBUG researchToolStripMenuItem.Visible = false; + addTXDArchiveToolStripMenuItem.Visible = false; #endif if (File.Exists(pathToSettings)) @@ -545,18 +546,17 @@ public void SetToolStripItemName(ArchiveEditor sender, string newName) archiveEditorToolStripMenuItem.DropDownItems[archiveEditors.IndexOf(sender) + 2].Text = newName; } - public void CloseAssetEditor(ArchiveEditor sender) + public void CloseArchiveEditor(ArchiveEditor sender) { int index = archiveEditors.IndexOf(sender); archiveEditorToolStripMenuItem.DropDownItems.RemoveAt(index + 2); - archiveEditors[index].DisposeAll(); archiveEditors.RemoveAt(index); } public void DisposeAllArchiveEditors() { foreach (ArchiveEditor ae in archiveEditors) - ae.DisposeAll(); + ae.DisposeForClosing(); } private bool UnsavedChanges() @@ -763,6 +763,13 @@ private void addTextureFolderToolStripMenuItem_Click(object sender, EventArgs e) TextureManager.LoadTexturesFromFolder(openFile.FileName); } + private void addTXDArchiveToolStripMenuItem_Click(object sender, EventArgs e) + { + OpenFileDialog openFile = new OpenFileDialog() { Filter = "TXD files|*.txd"}; + if (openFile.ShowDialog() == DialogResult.OK) + TextureManager.LoadTexturesFromTXD(openFile.FileName); + } + private void clearTexturesToolStripMenuItem_Click(object sender, EventArgs e) { TextureManager.ClearTextures(); @@ -905,6 +912,20 @@ private void uIModeToolStripMenuItem_Click(object sender, EventArgs e) mouseMode = false; } + private void pLATPreviewToolStripMenuItem_Click(object sender, EventArgs e) + { + pLATPreviewToolStripMenuItem.Checked = !pLATPreviewToolStripMenuItem.Checked; + AssetPLAT.playingPlat = pLATPreviewToolStripMenuItem.Checked; + + if (AssetPLAT.playingPlat) + { + foreach (ArchiveEditor ae in archiveEditors) + foreach (Asset a in ae.archive.GetAllAssets()) + if (a is AssetPLAT PLAT) + PLAT.Reset(); + } + } + private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { Program.AboutBox.Show(); diff --git a/IndustrialPark/SharpDX/TextureManager.cs b/IndustrialPark/SharpDX/TextureManager.cs index 3474a822..352ae54f 100644 --- a/IndustrialPark/SharpDX/TextureManager.cs +++ b/IndustrialPark/SharpDX/TextureManager.cs @@ -42,10 +42,14 @@ public static ShaderResourceView GetTextureFromDictionary(uint assetID) return SharpRenderer.whiteDefault; } + public static void LoadTexturesFromTXD(string textureFile, string textureName = null) + { + LoadTexturesFromTXD(ReadFileMethods.ReadRenderWareFile(textureFile), textureName); + } + public static void LoadTexturesFromTXD(byte[] txdData, string textureName = null) { - RWSection[] file = ReadFileMethods.ReadRenderWareFile(txdData); - LoadTexturesFromTXD(file, textureName); + LoadTexturesFromTXD(ReadFileMethods.ReadRenderWareFile(txdData), textureName); } public static void LoadTexturesFromTXD(RWSection[] txdFile, string textureName = null)