From 1ecdda52581bde22861d6396f75a9097a208657e Mon Sep 17 00:00:00 2001 From: igorseabra4 Date: Tue, 4 Dec 2018 21:57:37 -0300 Subject: [PATCH] event editor, incredibles events --- .../ArchiveEditor/ArchiveEditor.Designer.cs | 37 +- IndustrialPark/ArchiveEditor/ArchiveEditor.cs | 8 +- .../ArchiveEditor/ArchiveEditorFunctions.cs | 7 +- .../ArchiveEditorFunctions_AssetTemplates.cs | 93 ++ .../ArchiveEditor/EventEditor.Designer.cs | 394 +++++++++ IndustrialPark/ArchiveEditor/EventEditor.cs | 594 +++++++++++++ IndustrialPark/ArchiveEditor/EventEditor.resx | 120 +++ .../ArchiveEditor/EventListEditor.cs | 52 ++ .../ArchiveEditor/Other/AssetTemplate.cs | 5 + .../ObjectAssets/DYNA/DynaBoulderGen.cs | 8 + .../Assets/Shared/AssetEventIncredibles.cs | 21 + .../Enums/{EventType.cs => EventTypeBFBB.cs} | 0 .../Shared/Enums/EventTypeIncredibles.cs | 823 ++++++++++++++++++ IndustrialPark/Assets/Shared/ObjectAsset.cs | 37 +- IndustrialPark/IndustrialPark.csproj | 24 +- IndustrialPark/MainForm/AboutBox.Designer.cs | 2 +- IndustrialPark/MainForm/MainForm.Designer.cs | 38 +- IndustrialPark/MainForm/MainForm.cs | 11 + IndustrialPark/Program.cs | 2 + .../Research/EventSearch.Designer.cs | 231 +++++ IndustrialPark/Research/EventSearch.cs | 166 ++++ IndustrialPark/Research/EventSearch.resx | 120 +++ 22 files changed, 2748 insertions(+), 45 deletions(-) create mode 100644 IndustrialPark/ArchiveEditor/EventEditor.Designer.cs create mode 100644 IndustrialPark/ArchiveEditor/EventEditor.cs create mode 100644 IndustrialPark/ArchiveEditor/EventEditor.resx create mode 100644 IndustrialPark/ArchiveEditor/EventListEditor.cs create mode 100644 IndustrialPark/Assets/Shared/AssetEventIncredibles.cs rename IndustrialPark/Assets/Shared/Enums/{EventType.cs => EventTypeBFBB.cs} (100%) create mode 100644 IndustrialPark/Assets/Shared/Enums/EventTypeIncredibles.cs create mode 100644 IndustrialPark/Research/EventSearch.Designer.cs create mode 100644 IndustrialPark/Research/EventSearch.cs create mode 100644 IndustrialPark/Research/EventSearch.resx diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs index 1461039d..02e17871 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs @@ -39,6 +39,7 @@ private void InitializeComponent() this.hideButtonsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.collapseLayersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.hipHopToolExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importHIPArchiveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importMultipleAssetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -86,7 +87,6 @@ private void InitializeComponent() this.toolStripMenuItem_Export = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem_EditHeader = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem_EditData = new System.Windows.Forms.ToolStripMenuItem(); - this.collapseLayersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -122,14 +122,14 @@ private void InitializeComponent() // newToolStripMenuItem // this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.newToolStripMenuItem.Text = "New"; this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.openToolStripMenuItem.Text = "Open"; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // @@ -137,7 +137,7 @@ private void InitializeComponent() // this.saveToolStripMenuItem.Enabled = false; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.saveToolStripMenuItem.Text = "Save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // @@ -145,26 +145,26 @@ private void InitializeComponent() // this.saveAsToolStripMenuItem.Enabled = false; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.saveAsToolStripMenuItem.Text = "Save As..."; this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(140, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); // // hideButtonsToolStripMenuItem // this.hideButtonsToolStripMenuItem.Name = "hideButtonsToolStripMenuItem"; - this.hideButtonsToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.hideButtonsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.hideButtonsToolStripMenuItem.Text = "Hide Buttons"; this.hideButtonsToolStripMenuItem.Click += new System.EventHandler(this.hideButtonsToolStripMenuItem_Click); // // closeToolStripMenuItem // this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; - this.closeToolStripMenuItem.Size = new System.Drawing.Size(143, 22); + this.closeToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.closeToolStripMenuItem.Text = "Close"; this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click); // @@ -181,6 +181,14 @@ private void InitializeComponent() this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); this.editToolStripMenuItem.Text = "Edit"; // + // collapseLayersToolStripMenuItem + // + this.collapseLayersToolStripMenuItem.Enabled = false; + this.collapseLayersToolStripMenuItem.Name = "collapseLayersToolStripMenuItem"; + this.collapseLayersToolStripMenuItem.Size = new System.Drawing.Size(193, 22); + this.collapseLayersToolStripMenuItem.Text = "Collapse Layers"; + this.collapseLayersToolStripMenuItem.Click += new System.EventHandler(this.collapseLayersToolStripMenuItem_Click); + // // hipHopToolExportToolStripMenuItem // this.hipHopToolExportToolStripMenuItem.Enabled = false; @@ -275,7 +283,7 @@ private void InitializeComponent() this.buttonArrowDown.Name = "buttonArrowDown"; this.buttonArrowDown.Size = new System.Drawing.Size(22, 22); this.buttonArrowDown.TabIndex = 6; - this.buttonArrowDown.Text = "↓"; + this.buttonArrowDown.Text = "▼"; this.buttonArrowDown.UseVisualStyleBackColor = true; this.buttonArrowDown.Click += new System.EventHandler(this.buttonArrowDown_Click); // @@ -287,7 +295,7 @@ private void InitializeComponent() this.buttonArrowUp.Name = "buttonArrowUp"; this.buttonArrowUp.Size = new System.Drawing.Size(22, 22); this.buttonArrowUp.TabIndex = 5; - this.buttonArrowUp.Text = "↑"; + this.buttonArrowUp.Text = "▲"; this.buttonArrowUp.UseVisualStyleBackColor = true; this.buttonArrowUp.Click += new System.EventHandler(this.buttonArrowUp_Click); // @@ -436,6 +444,7 @@ private void InitializeComponent() // textBoxFindAsset // this.textBoxFindAsset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxFindAsset.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.textBoxFindAsset.Location = new System.Drawing.Point(296, 13); this.textBoxFindAsset.Name = "textBoxFindAsset"; this.textBoxFindAsset.Size = new System.Drawing.Size(217, 20); @@ -655,14 +664,6 @@ private void InitializeComponent() this.toolStripMenuItem_EditData.Text = "Edit Data (Ctrl + G)"; this.toolStripMenuItem_EditData.Click += new System.EventHandler(this.toolStripMenuItem_EditData_Click); // - // collapseLayersToolStripMenuItem - // - this.collapseLayersToolStripMenuItem.Enabled = false; - this.collapseLayersToolStripMenuItem.Name = "collapseLayersToolStripMenuItem"; - this.collapseLayersToolStripMenuItem.Size = new System.Drawing.Size(193, 22); - this.collapseLayersToolStripMenuItem.Text = "Collapse Layers"; - this.collapseLayersToolStripMenuItem.Click += new System.EventHandler(this.collapseLayersToolStripMenuItem_Click); - // // ArchiveEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs index ae25de9d..2c4ec3e0 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs @@ -34,6 +34,9 @@ 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); } @@ -867,8 +870,11 @@ private void textBoxFindAsset_TextChanged(object sender, EventArgs e) SetSelectedIndices(new List() { assetID }, false); else foreach (ListViewItem v in listViewAssets.Items) - if (v.Text.ToLower().Contains(textBoxFindAsset.Text.ToLower())) + if (v.Text.ToLower().Contains(textBoxFindAsset.Text.ToLower()) && (v.Selected == false)) + { SetSelectedIndices(new List() { GetAssetIDFromName(v.Text) }, false); + return; + } } private void collapseLayersToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs index 1e497779..fd9b3fea 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Windows.Forms; using HipHopFile; -using SharpDX; using static HipHopFile.Functions; namespace IndustrialPark @@ -31,6 +30,7 @@ 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() { @@ -594,6 +594,9 @@ 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); + allowRender = true; } @@ -702,6 +705,8 @@ public void RemoveAsset(uint assetID) DICT.ATOC.AHDRList.Remove(assetDictionary[assetID].AHDR); + autoCompleteSource.Remove(assetDictionary[assetID].AHDR.ADBG.assetName); + assetDictionary.Remove(assetID); } diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetTemplates.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetTemplates.cs index d8c74eb6..05f80a6a 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetTemplates.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetTemplates.cs @@ -116,6 +116,7 @@ public uint PlaceTemplate(Vector3 position, int layerIndex, out bool success, re case AssetTemplate.BusStop_DYNA: case AssetTemplate.DuplicatotronSettings: case AssetTemplate.TeleportBox: + case AssetTemplate.Checkpoint_Talkbox: newAssetType = AssetType.DYNA; break; case AssetTemplate.ElectricArc_Generic: @@ -184,6 +185,7 @@ public uint PlaceTemplate(Vector3 position, int layerIndex, out bool success, re case AssetTemplate.ThrowFruit: case AssetTemplate.ThrowFruitBase: case AssetTemplate.FreezyFruit: + case AssetTemplate.Checkpoint_SIMP: newAssetType = AssetType.SIMP; break; case AssetTemplate.SoundInfo: @@ -192,12 +194,15 @@ public uint PlaceTemplate(Vector3 position, int layerIndex, out bool success, re break; case AssetTemplate.SphereTrigger: case AssetTemplate.BusStop_Trigger: + case AssetTemplate.Checkpoint: + case AssetTemplate.Checkpoint_Invisible: newAssetType = AssetType.TRIG; break; case AssetTemplate.Text: newAssetType = AssetType.TEXT; break; case AssetTemplate.Timer: + case AssetTemplate.Checkpoint_Timer: newAssetType = AssetType.TIMR; break; case AssetTemplate.WoodenTiki: @@ -819,6 +824,94 @@ public uint PlaceTemplate(Vector3 position, int layerIndex, out bool success, re ((AssetSIMP)asset).ModelAssetID = BKDRHash("fruit_throw_base"); ((AssetSIMP)asset).Unknown_5C = 0; break; + case AssetTemplate.Checkpoint: + case AssetTemplate.Checkpoint_Invisible: + { + ((AssetTRIG)asset).Position1X_Radius = 6f; + uint checkpointDisp = BKDRHash("CHECKPOINT_DISP_00"); ; + if (!ContainsAsset(checkpointDisp)) + checkpointDisp = PlaceTemplate(position, layerIndex, out success, ref assetIDs, "CHECKPOINT_DISP", AssetTemplate.Dispatcher); + + List events = new List + { + new AssetEventBFBB + { + Arguments_Hex = new AssetID[] { 0, 0, 0, 0, PlaceTemplate(position, layerIndex, out success, ref assetIDs, "CHECKPOINT_MRKR", AssetTemplate.Marker), 0 }, + TargetAssetID = checkpointDisp, + EventReceiveID = EventTypeBFBB.EnterPlayer, + EventSendID = EventTypeBFBB.SetCheckPoint + } + }; + + if (template == AssetTemplate.Checkpoint) + events.Add(new AssetEventBFBB + { + Arguments_Float = new float[6], + TargetAssetID = PlaceTemplate(position, layerIndex, out success, ref assetIDs, "CHECKPOINT_TIMER", AssetTemplate.Checkpoint_Timer), + EventReceiveID = EventTypeBFBB.EnterPlayer, + EventSendID = EventTypeBFBB.Run + }); + + ((AssetTRIG)asset).EventsBFBB = events.ToArray(); + break; + } + case AssetTemplate.Checkpoint_Timer: + { + ((AssetTIMR)asset).Time = 0.5f; + uint checkpointSimp = PlaceTemplate(new Vector3(position.X + 2f, position.Y, position.Z), layerIndex, out success, ref assetIDs, "CHECKPOINT_SIMP", AssetTemplate.Checkpoint_SIMP); + uint checkpointTalkbox = BKDRHash("CHECKPOINT_TALKBOX_00"); ; + if (!ContainsAsset(checkpointTalkbox)) + checkpointTalkbox = PlaceTemplate(position, layerIndex, out success, ref assetIDs, "CHECKPOINT_TALKBOX", AssetTemplate.Checkpoint_Talkbox); + ((AssetTIMR)asset).EventsBFBB = new AssetEventBFBB[] { + new AssetEventBFBB + { + Arguments_Float = new float[] { 2, 0, 0, 0, 0, 0}, + TargetAssetID = checkpointSimp, + EventReceiveID = EventTypeBFBB.Run, + EventSendID = EventTypeBFBB.AnimPlayLoop + }, + new AssetEventBFBB + { + Arguments_Hex = new AssetID[] { BKDRHash("checkpoint_text"), 0, 0, 0, 0, 0}, + TargetAssetID = checkpointTalkbox, + EventReceiveID = EventTypeBFBB.Run, + EventSendID = EventTypeBFBB.StartConversation + }, + new AssetEventBFBB + { + Arguments_Float = new float[] { 3, 0, 0, 0, 0, 0}, + TargetAssetID = checkpointSimp, + EventReceiveID = EventTypeBFBB.Expired, + EventSendID = EventTypeBFBB.AnimPlayLoop + }, + new AssetEventBFBB + { + Arguments_Float = new float[6], + TargetAssetID = asset.AHDR.assetID, + EventReceiveID = EventTypeBFBB.Expired, + EventSendID = EventTypeBFBB.Disable + }, + }; + break; + } + case AssetTemplate.Checkpoint_SIMP: + ((AssetSIMP)asset).ScaleX = 0.75f; + ((AssetSIMP)asset).ScaleY = 0.75f; + ((AssetSIMP)asset).ScaleZ = 0.75f; + ((AssetSIMP)asset).ModelAssetID = BKDRHash("checkpoint_bind"); + ((AssetSIMP)asset).AnimationAssetID = BKDRHash("CHECKPOINT_ANIMLIST_01"); + break; + case AssetTemplate.Checkpoint_Talkbox: + ((AssetDYNA)asset).Flags = 0x1D; + ((AssetDYNA)asset).Version = 11; + ((AssetDYNA)asset).Type = DynaType.game_object__talk_box; + ((AssetDYNA)asset).DynaBase = new DynaTalkBox() + { + TextBoxID1 = 0x9BC49154, + Flags5 = 1, + UnknownFloat = 2f + }; + break; } assetIDs.Add(asset.AHDR.assetID); diff --git a/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs b/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs new file mode 100644 index 00000000..0068b9a2 --- /dev/null +++ b/IndustrialPark/ArchiveEditor/EventEditor.Designer.cs @@ -0,0 +1,394 @@ +namespace IndustrialPark +{ + partial class EventEditor + { + /// + /// 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.groupBox1 = new System.Windows.Forms.GroupBox(); + this.listBoxEvents = new System.Windows.Forms.ListBox(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.buttonRemove = new System.Windows.Forms.Button(); + this.buttonPaste = new System.Windows.Forms.Button(); + this.buttonCopy = new System.Windows.Forms.Button(); + this.buttonArrowDown = new System.Windows.Forms.Button(); + this.buttonArrowUp = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.groupBoxEventData = new System.Windows.Forms.GroupBox(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.checkBoxHex = new System.Windows.Forms.CheckBox(); + this.textBox5 = new System.Windows.Forms.TextBox(); + this.textBox6 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.textBox4 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.textBoxTargetAsset = new System.Windows.Forms.TextBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.comboSendEvent = new System.Windows.Forms.ComboBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.comboRecieveEvent = new System.Windows.Forms.ComboBox(); + this.groupBox1.SuspendLayout(); + this.groupBoxEventData.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + 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.TabIndex = 0; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Events"; + // + // listBoxEvents + // + this.listBoxEvents.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.listBoxEvents.FormattingEnabled = true; + 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.TabIndex = 1; + this.listBoxEvents.SelectedIndexChanged += new System.EventHandler(this.listBoxEvents_SelectedIndexChanged); + // + // buttonAdd + // + this.buttonAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonAdd.Location = new System.Drawing.Point(18, 273); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(75, 23); + this.buttonAdd.TabIndex = 2; + this.buttonAdd.Text = "Add"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + // + // buttonRemove + // + this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonRemove.Location = new System.Drawing.Point(99, 273); + this.buttonRemove.Name = "buttonRemove"; + this.buttonRemove.Size = new System.Drawing.Size(75, 23); + this.buttonRemove.TabIndex = 3; + this.buttonRemove.Text = "Remove"; + this.buttonRemove.UseVisualStyleBackColor = true; + this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); + // + // buttonPaste + // + this.buttonPaste.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonPaste.Location = new System.Drawing.Point(99, 302); + this.buttonPaste.Name = "buttonPaste"; + this.buttonPaste.Size = new System.Drawing.Size(75, 23); + this.buttonPaste.TabIndex = 5; + this.buttonPaste.Text = "Paste"; + this.buttonPaste.UseVisualStyleBackColor = true; + this.buttonPaste.Click += new System.EventHandler(this.buttonPaste_Click); + // + // buttonCopy + // + this.buttonCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCopy.Location = new System.Drawing.Point(18, 302); + this.buttonCopy.Name = "buttonCopy"; + this.buttonCopy.Size = new System.Drawing.Size(75, 23); + this.buttonCopy.TabIndex = 4; + this.buttonCopy.Text = "Copy"; + this.buttonCopy.UseVisualStyleBackColor = true; + this.buttonCopy.Click += new System.EventHandler(this.buttonCopy_Click); + // + // 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.Name = "buttonArrowDown"; + this.buttonArrowDown.Size = new System.Drawing.Size(22, 22); + this.buttonArrowDown.TabIndex = 7; + this.buttonArrowDown.Text = "▼"; + this.buttonArrowDown.UseVisualStyleBackColor = true; + this.buttonArrowDown.Click += new System.EventHandler(this.buttonArrowDown_Click); + // + // 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.Name = "buttonArrowUp"; + this.buttonArrowUp.Size = new System.Drawing.Size(22, 22); + this.buttonArrowUp.TabIndex = 6; + this.buttonArrowUp.Text = "▲"; + this.buttonArrowUp.UseVisualStyleBackColor = true; + this.buttonArrowUp.Click += new System.EventHandler(this.buttonArrowUp_Click); + // + // 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.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(104, 23); + this.buttonOK.TabIndex = 18; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + 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.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(104, 23); + this.buttonCancel.TabIndex = 19; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // groupBoxEventData + // + this.groupBoxEventData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBoxEventData.Controls.Add(this.groupBox6); + 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.Name = "groupBoxEventData"; + this.groupBoxEventData.Size = new System.Drawing.Size(226, 281); + this.groupBoxEventData.TabIndex = 2; + this.groupBoxEventData.TabStop = false; + this.groupBoxEventData.Text = "Event Data"; + // + // groupBox6 + // + this.groupBox6.Controls.Add(this.checkBoxHex); + this.groupBox6.Controls.Add(this.textBox5); + this.groupBox6.Controls.Add(this.textBox6); + this.groupBox6.Controls.Add(this.textBox3); + this.groupBox6.Controls.Add(this.textBox4); + this.groupBox6.Controls.Add(this.textBox2); + 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.TabIndex = 4; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "Arguments"; + // + // checkBoxHex + // + this.checkBoxHex.AutoSize = true; + this.checkBoxHex.Location = new System.Drawing.Point(163, 0); + this.checkBoxHex.Name = "checkBoxHex"; + this.checkBoxHex.Size = new System.Drawing.Size(45, 17); + this.checkBoxHex.TabIndex = 11; + this.checkBoxHex.Text = "Hex"; + this.checkBoxHex.UseVisualStyleBackColor = true; + this.checkBoxHex.CheckedChanged += new System.EventHandler(this.checkBoxHex_CheckedChanged); + // + // textBox5 + // + this.textBox5.Location = new System.Drawing.Point(6, 71); + this.textBox5.Name = "textBox5"; + this.textBox5.Size = new System.Drawing.Size(98, 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.Name = "textBox6"; + this.textBox6.Size = new System.Drawing.Size(98, 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.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(98, 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.Name = "textBox4"; + this.textBox4.Size = new System.Drawing.Size(98, 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.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(98, 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.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(98, 20); + this.textBox1.TabIndex = 12; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); + this.textBox1.Leave += new System.EventHandler(this.textBox_Leave); + // + // groupBox5 + // + 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.TabIndex = 3; + this.groupBox5.TabStop = false; + this.groupBox5.Text = "Target Asset"; + // + // textBoxTargetAsset + // + 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.TabIndex = 10; + this.textBoxTargetAsset.TextChanged += new System.EventHandler(this.textBoxTargetAsset_TextChanged); + this.textBoxTargetAsset.Leave += new System.EventHandler(this.textBoxTargetAsset_Leave); + // + // groupBox4 + // + 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.TabIndex = 2; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "Send Event"; + // + // comboSendEvent + // + 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.TabIndex = 9; + this.comboSendEvent.SelectedIndexChanged += new System.EventHandler(this.comboSendEvent_SelectedIndexChanged); + // + // groupBox3 + // + 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.TabIndex = 1; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Recieve Event"; + // + // comboRecieveEvent + // + 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.TabIndex = 8; + this.comboRecieveEvent.SelectedIndexChanged += new System.EventHandler(this.comboRecieveEvent_SelectedIndexChanged); + // + // 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.Controls.Add(this.groupBoxEventData); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonArrowDown); + this.Controls.Add(this.buttonArrowUp); + this.Controls.Add(this.buttonPaste); + this.Controls.Add(this.buttonCopy); + this.Controls.Add(this.buttonRemove); + this.Controls.Add(this.buttonAdd); + this.Controls.Add(this.groupBox1); + this.KeyPreview = true; + this.MaximizeBox = false; + this.Name = "EventEditor"; + this.ShowIcon = false; + this.Text = "Event Editor"; + this.groupBox1.ResumeLayout(false); + this.groupBoxEventData.ResumeLayout(false); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); + this.groupBox5.ResumeLayout(false); + this.groupBox5.PerformLayout(); + this.groupBox4.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.ListBox listBoxEvents; + private System.Windows.Forms.Button buttonAdd; + private System.Windows.Forms.Button buttonRemove; + private System.Windows.Forms.Button buttonPaste; + private System.Windows.Forms.Button buttonCopy; + private System.Windows.Forms.Button buttonArrowDown; + private System.Windows.Forms.Button buttonArrowUp; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.GroupBox groupBoxEventData; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.ComboBox comboRecieveEvent; + private System.Windows.Forms.GroupBox groupBox5; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.ComboBox comboSendEvent; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.TextBox textBox5; + private System.Windows.Forms.TextBox textBox6; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.TextBox textBox4; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.CheckBox checkBoxHex; + private System.Windows.Forms.TextBox textBoxTargetAsset; + } +} \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/EventEditor.cs b/IndustrialPark/ArchiveEditor/EventEditor.cs new file mode 100644 index 00000000..0a912bb9 --- /dev/null +++ b/IndustrialPark/ArchiveEditor/EventEditor.cs @@ -0,0 +1,594 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Windows.Forms; + +namespace IndustrialPark +{ + public partial class EventEditor : Form + { + private enum EventType + { + BFBB, + TSSM, + Incredibles + } + + private EventType eventType; + + private EventEditor() + { + InitializeComponent(); + TopMost = true; + + bgColor = textBoxTargetAsset.BackColor; + + groupBoxEventData.Enabled = false; + + AutoCompleteStringCollection source = new AutoCompleteStringCollection(); + + foreach (ArchiveEditor ae in Program.MainForm.archiveEditors) + foreach (Asset a in ae.archive.GetAllAssets()) + if (a is ObjectAsset oa) + source.Add(oa.AHDR.ADBG.assetName); + + textBoxTargetAsset.AutoCompleteSource = AutoCompleteSource.CustomSource; + textBoxTargetAsset.AutoCompleteCustomSource = source; + } + + private EventEditor(AssetEventBFBB[] events) : this() + { + eventType = EventType.BFBB; + foreach (EventTypeBFBB o in Enum.GetValues(typeof(EventTypeBFBB))) + { + comboRecieveEvent.Items.Add(o); + comboSendEvent.Items.Add(o); + } + + foreach (AssetEventBFBB assetEvent in events) + listBoxEvents.Items.Add(assetEvent); + } + + private EventEditor(AssetEventTSSM[] events) : this() + { + eventType = EventType.TSSM; + foreach (EventTypeTSSM o in Enum.GetValues(typeof(EventTypeTSSM))) + { + comboRecieveEvent.Items.Add(o); + comboSendEvent.Items.Add(o); + } + + foreach (AssetEventTSSM assetEvent in events) + listBoxEvents.Items.Add(assetEvent); + } + + private EventEditor(AssetEventIncredibles[] events) : this() + { + eventType = EventType.Incredibles; + foreach (EventTypeIncredibles o in Enum.GetValues(typeof(EventTypeIncredibles))) + { + comboRecieveEvent.Items.Add(o); + comboSendEvent.Items.Add(o); + } + + foreach (AssetEventIncredibles assetEvent in events) + listBoxEvents.Items.Add(assetEvent); + } + + private bool OK = false; + + private Color bgColor; + private bool ProgramIsChangingStuff = false; + private bool ListBoxShouldUpdate = true; + + private string GetAssetName(AssetID assetID) + { + if (AssetIDTypeConverter.Legacy) + return assetID.ToString("X8"); + return Program.MainForm.GetAssetNameFromID(assetID); + } + + private AssetID GetAssetID(string assetName) + { + if (AssetIDTypeConverter.Legacy) + return Convert.ToUInt32(assetName, 16); + return AssetIDTypeConverter.AssetIDFromString(assetName); + } + + public static AssetEventBFBB[] GetEvents(AssetEventBFBB[] events, out bool success) + { + EventEditor eventEditor = new EventEditor(events); + eventEditor.ShowDialog(); + + success = eventEditor.OK; + + List assetEventBFBBs = new List(); + foreach (AssetEventBFBB assetEvent in eventEditor.listBoxEvents.Items) + assetEventBFBBs.Add(assetEvent); + + return assetEventBFBBs.ToArray(); + } + + public static AssetEventTSSM[] GetEvents(AssetEventTSSM[] events, out bool success) + { + EventEditor eventEditor = new EventEditor(events); + eventEditor.ShowDialog(); + + success = eventEditor.OK; + + List assetEventBFBBs = new List(); + foreach (AssetEventTSSM assetEvent in eventEditor.listBoxEvents.Items) + assetEventBFBBs.Add(assetEvent); + + return assetEventBFBBs.ToArray(); + } + + public static AssetEventIncredibles[] GetEvents(AssetEventIncredibles[] events, out bool success) + { + EventEditor eventEditor = new EventEditor(events); + eventEditor.ShowDialog(); + + success = eventEditor.OK; + + List assetEventBFBBs = new List(); + foreach (AssetEventIncredibles assetEvent in eventEditor.listBoxEvents.Items) + assetEventBFBBs.Add(assetEvent); + + return assetEventBFBBs.ToArray(); + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + switch (eventType) + { + case EventType.BFBB: + listBoxEvents.Items.Add(new AssetEventBFBB()); + break; + case EventType.TSSM: + listBoxEvents.Items.Add(new AssetEventTSSM()); + break; + case EventType.Incredibles: + listBoxEvents.Items.Add(new AssetEventIncredibles()); + break; + } + listBoxEvents.SelectedIndices.Clear(); + listBoxEvents.SelectedIndex = listBoxEvents.Items.Count - 1; + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + int prev = listBoxEvents.SelectedIndex; + for (int i = 0; i < listBoxEvents.Items.Count; i++) + if (listBoxEvents.SelectedItems.Contains(listBoxEvents.Items[i])) + { + listBoxEvents.Items.RemoveAt(i); + i--; + } + + listBoxEvents.SelectedIndices.Clear(); + listBoxEvents.SelectedIndex = Math.Max(-1, prev - 1); + } + + private void buttonCopy_Click(object sender, EventArgs e) + { + List assetEventBFBBs = new List(); + foreach (AssetEvent assetEvent in listBoxEvents.SelectedItems) + assetEventBFBBs.Add(assetEvent.ToByteArray()); + + Clipboard.SetText(JsonConvert.SerializeObject(assetEventBFBBs)); + } + + private void buttonPaste_Click(object sender, EventArgs e) + { + List assetEvents; + try + { + assetEvents = JsonConvert.DeserializeObject>(Clipboard.GetText()); + } + catch (Exception ex) + { + MessageBox.Show("Unable to paste events: " + ex.Message + ". Are you sure you have events copied?"); + return; + } + + listBoxEvents.SelectedIndices.Clear(); + foreach (byte[] data in assetEvents) + { + switch (eventType) + { + case EventType.BFBB: + listBoxEvents.Items.Add(new AssetEventBFBB(data, 0)); + break; + case EventType.TSSM: + listBoxEvents.Items.Add(new AssetEventTSSM(data, 0)); + break; + case EventType.Incredibles: + listBoxEvents.Items.Add(new AssetEventIncredibles(data, 0)); + break; + } + listBoxEvents.SetSelected(listBoxEvents.Items.Count - 1, true); + } + } + + private void listBoxEvents_SelectedIndexChanged(object sender, EventArgs e) + { + if (ListBoxShouldUpdate) + { + if (listBoxEvents.SelectedItems.Count == 1) + { + if (!groupBoxEventData.Enabled) + groupBoxEventData.Enabled = true; + ProgramIsChangingStuff = true; + + AssetEvent assetEvent = null; + + switch (eventType) + { + case EventType.BFBB: + assetEvent = (AssetEventBFBB)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + comboRecieveEvent.SelectedItem = ((AssetEventBFBB)assetEvent).EventReceiveID; + comboSendEvent.SelectedItem = ((AssetEventBFBB)assetEvent).EventSendID; + break; + case EventType.TSSM: + assetEvent = (AssetEventTSSM)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + comboRecieveEvent.SelectedItem = ((AssetEventTSSM)assetEvent).EventReceiveID; + comboSendEvent.SelectedItem = ((AssetEventTSSM)assetEvent).EventSendID; + break; + case EventType.Incredibles: + assetEvent = (AssetEventIncredibles)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + comboRecieveEvent.SelectedItem = ((AssetEventIncredibles)assetEvent).EventReceiveID; + comboSendEvent.SelectedItem = ((AssetEventIncredibles)assetEvent).EventSendID; + break; + } + + textBoxTargetAsset.Text = GetAssetName(assetEvent.TargetAssetID); + + checkBoxHex_CheckedChanged(null, null); + + ProgramIsChangingStuff = false; + } + else + { + groupBoxEventData.Enabled = false; + } + } + } + + private void buttonArrowUp_Click(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1) + { + int previndex = listBoxEvents.SelectedIndex; + + if (previndex > 0) + { + switch (eventType) + { + case EventType.BFBB: + { + AssetEventBFBB previous = (AssetEventBFBB)listBoxEvents.Items[previndex - 1]; + listBoxEvents.Items[previndex - 1] = (AssetEventBFBB)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = previous; + break; + } + case EventType.TSSM: + { + AssetEventTSSM previous = (AssetEventTSSM)listBoxEvents.Items[previndex - 1]; + listBoxEvents.Items[previndex - 1] = (AssetEventTSSM)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = previous; + break; + } + case EventType.Incredibles: + { + AssetEventIncredibles previous = (AssetEventIncredibles)listBoxEvents.Items[previndex - 1]; + listBoxEvents.Items[previndex - 1] = (AssetEventIncredibles)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = previous; + break; + } + } + } + + listBoxEvents.SelectedIndices.Clear(); + listBoxEvents.SelectedIndex = Math.Max(previndex - 1, 0); + } + } + + private void buttonArrowDown_Click(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1) + { + int previndex = listBoxEvents.SelectedIndex; + + if (previndex < listBoxEvents.Items.Count - 1) + { + switch (eventType) + { + case EventType.BFBB: + { + AssetEventBFBB post = (AssetEventBFBB)listBoxEvents.Items[previndex + 1]; + listBoxEvents.Items[previndex + 1] = (AssetEventBFBB)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = post; + break; + } + case EventType.TSSM: + { + AssetEventTSSM post = (AssetEventTSSM)listBoxEvents.Items[previndex + 1]; + listBoxEvents.Items[previndex + 1] = (AssetEventTSSM)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = post; + break; + } + case EventType.Incredibles: + { + AssetEventIncredibles post = (AssetEventIncredibles)listBoxEvents.Items[previndex + 1]; + listBoxEvents.Items[previndex + 1] = (AssetEventIncredibles)listBoxEvents.Items[previndex]; + listBoxEvents.Items[previndex] = post; + break; + } + } + } + + listBoxEvents.SelectedIndices.Clear(); + listBoxEvents.SelectedIndex = Math.Min(previndex + 1, listBoxEvents.Items.Count - 1); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + OK = true; + Close(); + } + + private void comboRecieveEvent_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + switch (eventType) + { + case EventType.BFBB: + ((AssetEventBFBB)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventReceiveID = (EventTypeBFBB)comboRecieveEvent.SelectedItem; + break; + case EventType.TSSM: + ((AssetEventTSSM)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventReceiveID = (EventTypeTSSM)comboRecieveEvent.SelectedItem; + break; + case EventType.Incredibles: + ((AssetEventIncredibles)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventReceiveID = (EventTypeIncredibles)comboRecieveEvent.SelectedItem; + break; + } + SetListBoxUpdate(); + } + } + + private void comboSendEvent_SelectedIndexChanged(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + switch (eventType) + { + case EventType.BFBB: + ((AssetEventBFBB)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventSendID = (EventTypeBFBB)comboSendEvent.SelectedItem; + break; + case EventType.TSSM: + ((AssetEventTSSM)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventSendID = (EventTypeTSSM)comboSendEvent.SelectedItem; + break; + case EventType.Incredibles: + ((AssetEventIncredibles)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventSendID = (EventTypeIncredibles)comboSendEvent.SelectedItem; + break; + } + SetListBoxUpdate(); + } + } + + private void textBoxTargetAsset_TextChanged(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + textBoxTargetAsset.BackColor = bgColor; + + try + { + ((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).TargetAssetID = GetAssetID(textBoxTargetAsset.Text); + SetListBoxUpdate(); + } + catch + { + textBoxTargetAsset.BackColor = Color.Red; + } + } + } + + private void SetListBoxUpdate() + { + ListBoxShouldUpdate = false; + + switch (eventType) + { + case EventType.BFBB: + listBoxEvents.Items[listBoxEvents.SelectedIndex] = (AssetEventBFBB)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + break; + case EventType.TSSM: + listBoxEvents.Items[listBoxEvents.SelectedIndex] = (AssetEventTSSM)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + break; + case EventType.Incredibles: + listBoxEvents.Items[listBoxEvents.SelectedIndex] = (AssetEventIncredibles)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + ((AssetEventIncredibles)listBoxEvents.Items[listBoxEvents.SelectedIndex]).EventSendID = (EventTypeIncredibles)comboSendEvent.SelectedItem; + break; + } + + ListBoxShouldUpdate = true; + } + + private void textBoxTargetAsset_Leave(object sender, EventArgs e) + { + if (listBoxEvents.SelectedItems.Count == 1) + { + ProgramIsChangingStuff = true; + textBoxTargetAsset.Text = GetAssetName(((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).TargetAssetID); + ProgramIsChangingStuff = false; + } + } + + private void checkBoxHex_CheckedChanged(object sender, EventArgs e) + { + ProgramIsChangingStuff = true; + + AssetEvent assetEvent = (AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]; + if (checkBoxHex.Checked) + { + textBox1.Text = GetAssetName(assetEvent.Arguments_Hex[0]); + textBox2.Text = GetAssetName(assetEvent.Arguments_Hex[1]); + textBox3.Text = GetAssetName(assetEvent.Arguments_Hex[2]); + textBox4.Text = GetAssetName(assetEvent.Arguments_Hex[3]); + textBox5.Text = GetAssetName(assetEvent.Arguments_Hex[4]); + textBox6.Text = GetAssetName(assetEvent.Arguments_Hex[5]); + } + else + { + textBox1.Text = assetEvent.Arguments_Float[0].ToString("0.0000"); + textBox2.Text = assetEvent.Arguments_Float[1].ToString("0.0000"); + textBox3.Text = assetEvent.Arguments_Float[2].ToString("0.0000"); + textBox4.Text = assetEvent.Arguments_Float[3].ToString("0.0000"); + textBox5.Text = assetEvent.Arguments_Float[4].ToString("0.0000"); + textBox6.Text = assetEvent.Arguments_Float[5].ToString("0.0000"); + } + + ProgramIsChangingStuff = false; + } + + private void SetArgument(int index, string text) + { + if (checkBoxHex.Checked) + { + AssetID[] Arguments_Hex = ((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).Arguments_Hex; + Arguments_Hex[index] = GetAssetID(text); + ((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).Arguments_Hex = Arguments_Hex; + } + else + { + float[] Arguments_Float = ((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).Arguments_Float; + Arguments_Float[index] = float.Parse(text); + ((AssetEvent)listBoxEvents.Items[listBoxEvents.SelectedIndex]).Arguments_Float = Arguments_Float; + } + + SetListBoxUpdate(); + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + textBox1.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(0, textBox1.Text); + SetListBoxUpdate(); + } + catch + { + textBox1.BackColor = Color.Red; + } + } + } + + private void textBox2_TextChanged(object sender, EventArgs e) + { + textBox2.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(1, textBox2.Text); + SetListBoxUpdate(); + } + catch + { + textBox2.BackColor = Color.Red; + } + } + } + + private void textBox3_TextChanged(object sender, EventArgs e) + { + textBox3.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(2, textBox3.Text); + SetListBoxUpdate(); + } + catch + { + textBox3.BackColor = Color.Red; + } + } + } + + private void textBox4_TextChanged(object sender, EventArgs e) + { + textBox4.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(3, textBox4.Text); + SetListBoxUpdate(); + } + catch + { + textBox4.BackColor = Color.Red; + } + } + } + + private void textBox5_TextChanged(object sender, EventArgs e) + { + textBox5.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(4, textBox5.Text); + SetListBoxUpdate(); + } + catch + { + textBox5.BackColor = Color.Red; + } + } + } + + private void textBox6_TextChanged(object sender, EventArgs e) + { + textBox5.BackColor = bgColor; + + if (listBoxEvents.SelectedItems.Count == 1 && !ProgramIsChangingStuff) + { + try + { + SetArgument(5, textBox6.Text); + SetListBoxUpdate(); + } + catch + { + textBox6.BackColor = Color.Red; + } + } + } + + private void textBox_Leave(object sender, EventArgs e) + { + checkBoxHex_CheckedChanged(null, null); + } + } +} \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/EventEditor.resx b/IndustrialPark/ArchiveEditor/EventEditor.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/IndustrialPark/ArchiveEditor/EventEditor.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/ArchiveEditor/EventListEditor.cs b/IndustrialPark/ArchiveEditor/EventListEditor.cs new file mode 100644 index 00000000..67aa331c --- /dev/null +++ b/IndustrialPark/ArchiveEditor/EventListEditor.cs @@ -0,0 +1,52 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; + +namespace IndustrialPark +{ + public class EventListEditor : UITypeEditor + { + private IWindowsFormsEditorService service; + + public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) + { + return UITypeEditorEditStyle.Modal; + } + + public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) + { + if (provider != null) + service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); + + if (service != null) + { + if (value is AssetEventBFBB[]) + { + AssetEventBFBB[] events = EventEditor.GetEvents((AssetEventBFBB[])value, out bool success); + + if (success) + value = events; + } + else if (value is AssetEventTSSM[]) + { + AssetEventTSSM[] events = EventEditor.GetEvents((AssetEventTSSM[])value, out bool success); + + if (success) + value = events; + } + else if (value is AssetEventIncredibles[]) + { + AssetEventIncredibles[] events = EventEditor.GetEvents((AssetEventIncredibles[])value, out bool success); + + if (success) + value = events; + } + } + + return value; + } + } +} diff --git a/IndustrialPark/ArchiveEditor/Other/AssetTemplate.cs b/IndustrialPark/ArchiveEditor/Other/AssetTemplate.cs index c8625394..2b6ef912 100644 --- a/IndustrialPark/ArchiveEditor/Other/AssetTemplate.cs +++ b/IndustrialPark/ArchiveEditor/Other/AssetTemplate.cs @@ -67,6 +67,8 @@ public enum AssetTemplate PressurePlate, TaxiStand, TexasHitch, + Checkpoint, + Checkpoint_Invisible, BusStop, TeleportBox, ThrowFruit, @@ -80,6 +82,9 @@ public enum AssetTemplate BusStop_Lights, BusStop_Trigger, ThrowFruitBase, + Checkpoint_Timer, + Checkpoint_Talkbox, + Checkpoint_SIMP, // Placeable Marker, diff --git a/IndustrialPark/Assets/ObjectAssets/DYNA/DynaBoulderGen.cs b/IndustrialPark/Assets/ObjectAssets/DYNA/DynaBoulderGen.cs index 73fd5e3c..60940974 100644 --- a/IndustrialPark/Assets/ObjectAssets/DYNA/DynaBoulderGen.cs +++ b/IndustrialPark/Assets/ObjectAssets/DYNA/DynaBoulderGen.cs @@ -14,6 +14,14 @@ public DynaBoulderGen() : base() Unknown_ID = 0; } + public override bool HasReference(uint assetID) + { + if (Unknown_ID == assetID) + return true; + + return base.HasReference(assetID); + } + public DynaBoulderGen(IEnumerable enumerable) : base (enumerable) { Unknown_ID = Switch(BitConverter.ToUInt32(Data, 0x0)); diff --git a/IndustrialPark/Assets/Shared/AssetEventIncredibles.cs b/IndustrialPark/Assets/Shared/AssetEventIncredibles.cs new file mode 100644 index 00000000..65ad91ab --- /dev/null +++ b/IndustrialPark/Assets/Shared/AssetEventIncredibles.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; + +namespace IndustrialPark +{ + public class AssetEventIncredibles : AssetEvent + { + [DisplayName("Receive Event")] + public EventTypeIncredibles EventReceiveID { get => (EventTypeIncredibles)_eventReceiveID; set => _eventReceiveID = (ushort)value; } + [DisplayName("Send Event")] + public EventTypeIncredibles EventSendID { get => (EventTypeIncredibles)_eventSendID; set => _eventSendID = (ushort)value; } + + public AssetEventIncredibles() : base() { } + + public AssetEventIncredibles(byte[] data, int offset) : base(data, offset) { } + + public override string ToString() + { + return $"{EventReceiveID.ToString()} => {EventSendID.ToString()} => {Program.MainForm.GetAssetNameFromID(TargetAssetID)}"; + } + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/Enums/EventType.cs b/IndustrialPark/Assets/Shared/Enums/EventTypeBFBB.cs similarity index 100% rename from IndustrialPark/Assets/Shared/Enums/EventType.cs rename to IndustrialPark/Assets/Shared/Enums/EventTypeBFBB.cs diff --git a/IndustrialPark/Assets/Shared/Enums/EventTypeIncredibles.cs b/IndustrialPark/Assets/Shared/Enums/EventTypeIncredibles.cs new file mode 100644 index 00000000..9f98ab07 --- /dev/null +++ b/IndustrialPark/Assets/Shared/Enums/EventTypeIncredibles.cs @@ -0,0 +1,823 @@ +namespace IndustrialPark +{ + public enum EventTypeIncredibles : ushort + { + Unknown = 0, + Enable = 1, + Disable = 2, + Visible = 3, + Invisible = 4, + EnterPlayer = 5, + ExitPlayer = 6, + TouchPlayer = 7, + ControlOff = 8, + ControlOn = 9, + Reset = 10, + Increment = 11, + Decrement = 12, + Open = 13, + Close = 14, + Toggle = 15, + TeleportPlayer = 16, + OutOfBounds = 17, + Run = 18, + Stop = 19, + Expired = 20, + Move = 21, + Destroy = 22, + Pause = 23, + Play = 24, + PlayOne = 25, + PlayMaybe = 26, + RoomStart = 27, + Invalidate = 28, + Tilt = 29, + Untilt = 30, + Arrive = 31, + Mount = 32, + Dismount = 33, + Break = 34, + Pickup = 35, + Death = 35, + Kill = 37, + Off = 38, + PatrolOn = 39, + PatrolOff = 40, + WanderOn = 41, + WanderOff = 42, + DetectPlayerOn = 43, + DetectPlayerOff = 44, + ChasePlayerOn = 45, + ChasePlayerOff = 46, + GoToSleep = 47, + WakeUpVillain = 48, + Respawn = 49, + PlayerDeath = 50, + GiveChance = 51, + GiveShinyObjects = 52, + GiveHealth = 53, + ButtonPress = 54, + ButtonUnpress = 55, + ArriveHalfway = 56, + Hit = 57, + ButtonPressAction = 58, + Evaluate = 59, + True = 60, + False = 61, + PadPressX = 62, + PadPressSquare = 63, + PadPressO = 64, + PadPressTriangle = 65, + PadPressL1 = 66, + PadPressL2 = 67, + PadPressR1 = 68, + PadPressR2 = 69, + PadPressStart = 70, + PadPressSelect = 71, + PadPressUp = 72, + PadPressDown = 73, + PadPressRight = 74, + PadPressLeft = 75, + FontBackdropOn = 76, + FontBackdropOff = 77, + UISelect = 78, + UIUnselect = 79, + UIFocusOn = 80, + UIFocusOff = 81, + CollisionOn = 82, + CollisionOff = 83, + CollisionVisibleOn = 84, + CollisionVisibleOff = 85, + ScenePrepare = 86, + SceneFinish = 87, + RoomPrepare = 88, + RoomFinish = 89, + LobMasterShoot = 90, + LobMasterReset = 91, + FallToDeath = 92, + UIFocusOnSelect = 93, + UIFocusOffUnselect = 94, + SetPadConfigtoPresetA = 95, + SetPadConfigtoPresetB = 96, + SetPadConfigtoPresetC = 97, + SetPadConfigtoPresetD = 98, + PadVibrateOn = 99, + PadVibrateOff = 100, + MonoSound = 101, + StereoSound = 102, + IncreaseMasterVolume = 103, + DecreaseMasterVolume = 104, + IncreaseMusicVolume = 105, + DecreaseMusicVolume = 106, + IncreaseSFXVolume = 107, + DecreaseSFXVolume = 108, + IntroState_Sony = 109, + IntroState_Publisher = 110, + IntroState_Developer = 111, + IntroState_License = 112, + IntroState_Count = 113, + TitleState_Start = 114, + TitleState_Attract = 115, + TitleState_Count = 116, + LoadState_SelectMemCard = 117, + LoadState_SelectSlot = 118, + LoadState_Loading = 119, + LoadState_Count = 120, + OptionsState_Options = 121, + OptionsState_Count = 122, + SaveState_SelectMemCard = 123, + SaveState_SelectSlot = 124, + SaveState_Saving = 125, + SaveState_Count = 126, + PauseState_Pause = 127, + PauseState_Options = 128, + PauseState_Count = 129, + GameState_FirstTime = 130, + GameState_Play = 131, + GameState_LoseChance = 132, + GameState_GameOver = 133, + GameState_SceneSwitch = 134, + GameState_Dead = 135, + SetIntroState_Sony = 136, + SetIntroState_Publisher = 137, + SetIntroState_Developer = 138, + SetIntroState_License = 139, + SetIntroState_Count = 140, + SetTitleState_Start = 141, + SetTitleState_Attract = 142, + SetTitleState_Count = 143, + SetLoadState_SelectMemCard = 144, + SetLoadState_SelectSlot = 145, + SetLoadState_Loading = 146, + SetLoadState_Count = 147, + SetOptionsState_Options = 148, + SetOptionsState_Count = 149, + SetSaveState_SelectMemCard = 150, + SetSaveState_SelectSlot = 151, + SetSaveState_Saving = 152, + SetSaveState_Count = 153, + SetPauseState_Pause = 154, + SetPauseState_Options = 155, + SetPauseState_Count = 156, + SetGameState_FirstTime = 157, + SetGameState_Play = 158, + SetGameState_LoseChance = 159, + SetGameState_GameOver = 160, + SetGameState_SceneSwitch = 161, + SetGameState_Dead = 162, + Digup = 163, + GameState_Exit = 164, + SetGameState_Exit = 165, + LobMasterShootFromWidget = 166, + Back = 167, + Cancel = 168, + Retry = 169, + SelectCard = 170, + SelectSlot = 171, + OK = 172, + VilHurtBoss = 173, + Attack = 174, + AttackOn = 175, + AttackOff = 176, + Droppickup = 177, + UIAddChar = 178, + UIDelChar = 179, + UIStringEmpty = 180, + UIStringFull = 181, + UIStringSendAsCheat = 182, + UISetMaxChars = 183, + UICheatOK = 184, + UICheatBad = 185, + VilReport_StartingChase = 186, + VilReport_StartingAttack = 187, + VilReport_StartingRetreat = 188, + Preload = 189, + Done = 190, + Arcto = 191, + DigupReaction = 192, + SetCheckPoint = 193, + AnimPlay = 194, + AnimPlayLoop = 195, + AnimStop = 196, + AnimPause = 197, + AnimResume = 198, + AnimTogglePause = 199, + AnimPlayRandom = 200, + AnimPlayMaybe = 201, + SetSpeed = 202, + Accelerate = 203, + MoveToTarget = 204, + SwingerFollow = 205, + Impact = 206, + StartTimer = 207, + FinishedTimer = 208, + UIReset = 209, + SetScaleFactor = 210, + EnterEntity = 211, + ExitEntity = 212, + ENTERFLAGGEDDONOTUSE = 213, + EXITFLAGGEDDONOTUSE = 214, + Drivenby = 215, + FollowTarget = 216, + FaceTarget = 217, + WatchTarget = 218, + CarChangeLaneRight = 219, + CarChangeLaneLeft = 220, + CarStart = 221, + CarSetSwerveMode = 222, + IncreaseSpeed = 223, + DecreaseSpeed = 224, + StartMoving = 225, + StopMoving = 226, + Swoosh = 227, + TurretDestroyed = 228, + NPCSpeakStop = 229, + StartRumbleEffect = 230, + NavigateTo = 231, + NPCSpeakStart = 232, + NPCAlert = 233, + NPCPatrolDelay = 234, + NPCScrambleActionEnd = 235, + VilFakeChaseOff = 236, + BossMMPushButton = 237, + VilReport_DecayComplete = 238, + VilGuardWidget = 239, + TextureAnimateOn = 240, + TextureAnimateOff = 241, + TextureAnimateToggle = 242, + ColorEffectOn = 243, + ColorEffectOff = 244, + ColorEffectToggle = 245, + SetTextureAnimGroup = 246, + SetTextureAnimSpeed = 247, + TextureAnimateStep = 248, + Emit = 249, + Emitted = 250, + TranslucentOn = 251, + TranslucentOff = 252, + TranslucentToggle = 253, + ZipLineEnvDamage = 254, + VilGangTalkOff = 255, + GivePowerUp = 256, + RaceTimerReset = 257, + FireCruiseBubble = 258, + CarSuccessAnimPlay = 259, + CarFailureAnimPlay = 260, + DisableGroupContents = 261, + NPCCharge = 262, + OccludeOn = 263, + OccludeOff = 264, + RaceTimerPause = 265, + RaceTimerResume = 266, + RaceTimerSetBestTime = 267, + RaceTimerWarning1 = 268, + RaceTimerWarning2 = 269, + RaceTimerWarning3 = 270, + RingChallengeStart = 271, + CarStop = 272, + RingChallengeRun = 273, + RingChallengeReset = 274, + RingChallengeSuccess = 275, + RingChallengeFailed = 276, + FormationChanged = 277, + ChargeResume = 278, + ChargePause = 279, + NPCChargeStop = 280, + NPCChargeCompleted = 281, + FormationChargeStart = 282, + SituationPlayerSuccess = 283, + SituationPlayerFailure = 284, + ShowHud = 285, + HideHud = 286, + FADEOUT = 287, + SetRain = 288, + SetSnow = 289, + ScriptNoOp = 290, + ScriptReset = 291, + WaitForInput = 292, + PlayMovie = 293, + CelebrationAnimPlay = 294, + MusicTrackReplace = 295, + UnknownUnused = 296, + Forward = 297, + Reverse = 298, + RumbleTestOBSOLETE = 299, + RumbleLightOBSOLETE = 300, + RumbleMediumOBSOLETE = 301, + RumbleHeavyOBSOLETE = 302, + ScreenAdjustmentON = 303, + ScreenAdjustmentOFF = 304, + SetasSkydome = 305, + Connect_IOwnYou = 306, + Duplotron_WaveBegin = 307, + Duplotron_WaveComplete = 308, + Duplotron_NPCBorn = 309, + Duplotron_NPCKilled = 310, + Duplotron_MaxNPCExpired = 311, + Duplotron_Pause = 312, + Duplotron_Resume = 313, + SetasGoo = 314, + NPCScript_ScriptBegin = 315, + NPCScript_ScriptEnd = 316, + NPCScript_ScriptReady = 317, + NPCScript_Halt = 318, + NPCScript_SetPos = 319, + NPCScript_SetDir = 320, + NPCScript_LookNormal = 321, + NPCScript_LookAlert = 322, + NPCScript_FaceWidget = 323, + NPCScript_FaceWidgetDone = 324, + NPCScript_GotoWidget = 325, + NPCScript_GotoWidgetDone = 326, + NPCScript_AttackWidget = 327, + NPCScript_AttackWidgetDone = 328, + NPCScript_FollowWidget = 329, + NPCScript_PlayAnim = 330, + NPCScript_PlayAnimDone = 331, + NPCScript_LeadPlayer = 332, + SetText = 333, + StartConversation = 334, + EndConversation = 335, + Switch = 336, + AddText = 337, + ClearText = 338, + OpenTeleportBox = 339, + CloseTeleportBox = 340, + OnSignal0 = 341, + OnSignal1 = 342, + OnSignal2 = 343, + OnSignal3 = 344, + OnSignal4 = 345, + OnSignal5 = 346, + OnSignal6 = 347, + OnSignal7 = 348, + OnSignal8 = 349, + OnSignal9 = 350, + StopWait = 351, + OnConversationStart = 352, + OnConversationEnd = 353, + HitMelee = 354, + HitBubbleBounce = 355, + HitBubbleBash = 356, + HitBubbleBowl = 357, + HitPatrickSlam = 358, + HitByThrowable = 359, + PaddleHitLeft = 360, + PaddleHitRight = 361, + InitiateTask = 362, + SetSuccess = 363, + SetFailure = 364, + OnAccept = 365, + OnDecline = 366, + OnComplete = 367, + GenerateBoulder = 368, + LaunchBoulderAtWidget = 369, + LaunchBoulderAtPoint = 370, + LaunchBoulderAtPlayer = 371, + Duplotron_SuperDuperDone = 372, + Duplotron_DuperIsDoner = 373, + BusSwitchCharacter = 374, + GroupUpdateTogether = 375, + SetUpdateDistance = 376, + TranslateLocalX = 377, + TranslateLocalY = 378, + TranslateLocalZ = 379, + TranslateWorldX = 380, + TranslateWorldY = 381, + TranslateWorldZ = 382, + RotateLocalX = 383, + RotateLocalY = 384, + RotateLocalZ = 385, + RotateWorldX = 386, + RotateWorldY = 387, + RotateWorldZ = 388, + TranslateLocalXDone = 389, + TranslateLocalYDone = 390, + TranslateLocalZDone = 391, + TranslateWorldXDone = 392, + TranslateWorldYDone = 393, + TranslateWorldZDone = 394, + RotateLocalXDone = 395, + RotateLocalYDone = 396, + RotateLocalZDone = 397, + RotateWorldXDone = 398, + RotateWorldYDone = 399, + RotateWorldZDone = 400, + Count1 = 401, + Count2 = 402, + Count3 = 403, + Count4 = 404, + Count5 = 405, + Count6 = 406, + Count7 = 407, + Count8 = 408, + Count9 = 409, + Count10 = 410, + Count11 = 411, + Count12 = 412, + Count13 = 413, + Count14 = 414, + Count15 = 415, + Count16 = 416, + Count17 = 417, + Count18 = 418, + Count19 = 419, + Count20 = 420, + SetState = 421, + EnterSpongeBob = 422, + EnterPatrick = 423, + EnterSandy = 424, + ExitSpongeBob = 425, + ExitPatrick = 426, + ExitSandy = 427, + NPCSpecial_PlatformSnap = 428, + NPCSpecial_PlatformFall = 429, + Goosetwarbcoeffs = 430, + Goosetfreezeduration = 431, + Goomelt = 432, + SetStateRange = 433, + SetStateDelay = 434, + SetTransitionDelay = 435, + NPCFightOn = 436, + NPCFightOff = 437, + NPCPatrolSplineOn = 438, + NPCPatrolSplineOff = 439, + NPCKillQuietly = 440, + HitGeneral = 441, + HitHead = 442, + HitLeftArm = 443, + HitRightArm = 444, + HitLeftLeg = 445, + HitRightLeg = 446, + HitLowerBody = 447, + GiveSockscurrentlevel = 448, + GiveCollectablescurrentlevel = 449, + SetSockscurrentlevel = 450, + SetCollectablescurrentlevel = 451, + OnAnswerYes = 452, + OnAnswerNo = 453, + HitCruiseBubble = 454, + Duplotron_KillKids = 455, + OnSignal10 = 456, + OnSignal11 = 457, + OnSignal12 = 458, + OnSignal13 = 459, + OnSignal14 = 460, + OnSignal15 = 461, + OnSignal16 = 462, + OnSignal17 = 463, + OnSignal18 = 464, + OnSignal19 = 465, + SpongeballOn = 466, + SpongeballOff = 467, + LaunchShrapnel = 468, + NPCHPIncremented = 469, + NPCHPDecremented = 470, + NPCSetActiveOn = 471, + NPCSetActiveOff = 472, + SwitchPlayerCharacter = 473, + LevelBegin = 474, + SceneResetdeath = 475, + SceneEnter = 476, + DestroyedTiki = 477, + DestroyedRobot = 478, + SeeWoodTiki = 479, + SeeLoveyTiki = 480, + SeeShhhTiki = 481, + SeeThunderTiki = 482, + SeeStoneTiki = 483, + SeeFodder = 484, + SeeHammer = 485, + SeeTarTar = 486, + SeeGLove = 487, + SeeMonsoon = 488, + SeeSleepyTime = 489, + SeeArf = 490, + SeeTubelets = 491, + SeeSlick = 492, + SeeKingJellyfish = 493, + SeePrawn = 494, + SeeDutchman = 495, + SeeSandyBoss = 496, + SeePatrickBoss = 497, + SeeSpongeBobBoss = 498, + SeeRobotPlankton = 499, + ChangeTextureofUI = 500, + NPCCheerForMe = 501, + FastVisible = 502, + FastInvisible = 503, + ZipLineMount = 504, + ZipLineDismount = 505, + Target = 506, + Fire = 507, + CameraFXShake = 508, + BulletTime = 509, + Thrown = 510, + NPCPatrol = 511, + EnterCruise = 512, + ExitCruise = 513, + CruiseFired = 514, + CruiseDied = 515, + CruiseAddLife = 516, + CruiseSetLife = 517, + CruiseResetLife = 518, + CameraCollideOff = 519, + CameraCollideOn = 520, + SlideOn = 521, + SlideOff = 522, + TimerSet = 523, + TimerAdd = 524, + NPCForceConversation = 525, + MakeASplash = 526, + Creditsstart = 527, + Creditsstop = 528, + Creditsended = 529, + BubbleWipe = 530, + SetLightkit = 531, + SetOpacity = 532, + SetSoundEffect = 533, + Scale = 534, + SetReference = 535, + WarpSetWorld = 536, + WarpSetTask = 537, + WarpGo = 538, + SetCount = 539, + GetDashSpeed = 540, + DashTrip = 541, + DashBurst = 542, + DashFast = 543, + DashNormal = 544, + DashSlow = 545, + TakeSocks = 546, + DebugBREAK = 547, + Born = 548, + PlatformPause = 549, + PlatformUnpause = 550, + StoreOptions = 551, + RestoreOptions = 552, + UISetMotion = 553, + UIMotionFinished = 554, + UIMotionLoop = 555, + Destructiblelaunch = 556, + Destructiblerespawn = 557, + KaboomStart = 558, + KaboomStop = 559, + NPCAttack = 560, + NPCDefend = 561, + TrainSetSpeed = 562, + TrainJunctOut1 = 563, + TrainJunctOut2 = 564, + TrainJunctToggle = 565, + TrainJunctPassed = 566, + TrainCarDetach = 567, + TrainCarExplode = 568, + XboxInitializeNETAPI = 569, + XboxUpdateConnection = 570, + XboxUpdateOnlineTask = 571, + XboxUpdateAccountList = 572, + XboxCheckfornewcontent = 573, + XboxSelectDevice = 574, + XboxSelectContent = 575, + XboxVerifyContent = 576, + XboxRemoveContent = 577, + XboxSelectDeviceafterremove = 578, + XboxConfirmusecontentidx = 579, + XboxConfirmnousecontentidx = 580, + XboxNocontentisinstalled = 581, + XboxNonewcontentisavailable = 582, + XboxNewcontentisavailable = 583, + EnableSceneDrawing = 584, + DisableSceneDrawing = 585, + LightningStart = 586, + LightningStop = 587, + ChangeBossUIStage = 588, + Startstaticcamera = 589, + Endstaticcamera = 590, + SetCameraStartOrientation = 591, + NPCSetMovepointPath = 592, + NPCScareBegin = 593, + NPCScareSkip = 594, + NPCSetMovepointGroup = 595, + VentSetStateIdle = 596, + VentSetStateWarn = 597, + VentSetStateDamage = 598, + VentSetStateOff = 599, + WaterhoseStart = 600, + WaterhoseStop = 601, + WaterhoseSetLength = 602, + Carried = 603, + Explode = 604, + JumpTo = 605, + JumponSpawn = 606, + PlayerHit = 607, + StartFade = 608, + FadeDownDone = 609, + FadeUpDone = 610, + Bounce = 611, + LaunchNPC = 612, + UpgradePowerUp = 613, + BulletStreak = 614, + SetFollowCameraOrientation = 615, + HighDynamicRangeFade = 616, + Start = 617, + Success = 618, + Failure = 619, + EnableRestore = 620, + DisableRestore = 621, + NPCSpawn = 622, + NPCSpawnDone = 623, + SpawnedNPCKilled = 624, + SpawnedNPCNoHealth = 625, + SpawnedNPCsAllKilled = 626, + SpawnedNPCsAllNoHealth = 627, + SetDashTimer = 628, + DashNotOutofTime = 629, + DashOutofTime = 630, + ForceSceneReset = 631, + NPCActive = 632, + NPCInactive = 633, + DuplicatorActivate = 634, + DuplicatorDeactivate = 635, + DashEnterTunnel = 636, + DashExitTunnel = 637, + StopRumbleEffect = 638, + DashChaseLasersOn = 639, + DashChaseLasersOff = 640, + RandomJumponSpawn = 641, + HitPatrickCartwheel = 642, + UIVisibleFocusOnSelect = 643, + UIFocusOffUnselectInvisible = 644, + CopyReference = 645, + UIMotionInFinished = 646, + UIMotionOutFinished = 647, + UISignalActivateScreen = 648, + UISignalDeactivateScreen = 649, + UISignalActivatedScreen = 650, + UISignalSwitchScreens = 651, + UISignalStartFadeOut = 652, + UISignalStartFadeIn = 653, + UISignalScreenMotionInDone = 654, + UISignalScreenMotionOutDone = 655, + UISignalMainBoxInDone = 656, + UISignalMainBoxOutDone = 657, + UIResetMotion = 658, + UIEnableHDR = 659, + UIDisableHDR = 660, + UIBrighten = 661, + UIUnbrighten = 662, + UISignalDeactivatedScreen = 663, + NPCDetectAlways = 664, + NPCDetectNever = 665, + NPCDetectNormal = 666, + NPCFightDefault = 667, + CameraCollidePartial = 668, + MusicTrackPlayTemporary = 669, + EvaluateCounterValue = 670, + Count0 = 671, + RotatetoAbsoluteX = 672, + RotatetoAbsoluteY = 673, + RotatetoAbsoluteZ = 674, + PlayTriggerAnimation = 675, + TriggeredAnimationDone = 676, + UISignalMore = 677, + UISignalNoMore = 678, + UISignalLess = 679, + UISignalNoLess = 680, + UISignalUp = 681, + UISignalDown = 682, + UISignalSyncToCurrent = 683, + UISignalEffect = 684, + FreezePlayer = 685, + UnfreezePlayer = 686, + UISignalMapStart = 687, + UISignalMapEnd = 688, + TranslatetoAbsoluteX = 689, + TranslatetoAbsoluteY = 690, + TranslatetoAbsoluteZ = 691, + JSPVisibilityIncrement = 692, + JSPVisibilityDecrement = 693, + EnterCamera = 694, + ExitCamera = 695, + PadPressEGCZorXBOXBlack = 696, + DashSetJumpParamters = 697, + ViperFacePlayer = 698, + ViperFaceMovement = 699, + RequestStart = 700, + UIAutoMenuRun = 701, + UIAutoMenuRunUp = 702, + UIAutoMenuRunDown = 703, + UIAutoMenuRunLeft = 704, + UIAutoMenuRunRight = 705, + IncrementSuccess = 706, + DecrementSuccess = 707, + IncrementFailed = 708, + DecrementFailed = 709, + MusicTrackStopTemporaryMusic = 710, + NPCScrambleActionBegin = 711, + NPCScrambleAlert = 712, + NPCTurretSetAttackRadius = 713, + GooFreezeStart = 714, + GooMeltStart = 715, + NPCNotice = 716, + BossStageSet = 717, + BossStageBegan = 718, + BossStageEnded = 719, + BossStageABegan = 720, + BossStageAEnded = 721, + BossStageBBegan = 722, + BossStageBEnded = 723, + BossStageCBegan = 724, + BossStageCEnded = 725, + VisibilityCullOn = 726, + VisibilityCullOff = 727, + Startrbandcamera = 728, + Endrbandcamera = 729, + MindyStart = 730, + MindyEnd = 731, + FlamethrowerStart = 732, + FlamethrowerStop = 733, + FlamethrowerSetLength = 734, + NPCTakeNoDamageOn = 735, + NPCTakeNoDamageOff = 736, + StartStaticCAMFOVfilter = 737, + RestoreStaticCAMFOV = 738, + XBOXDEMOexittolauncher = 739, + Spawn = 740, + Spawned = 741, + Creditssetdest = 742, + AllowAttractMode = 743, + DisallowAttractMode = 744, + RocketAttack = 745, + CollisionReset = 746, + AutoSave = 747, + OpenBonus = 748, + FlagLevel = 749, + LevelEnd = 750, + GetLocalContent = 751, + PauseGameSafe = 752, + OverrideFrequency = 753, + ResetFrequency = 754, + SetShotDelay = 755, + SetShotsInGroup = 756, + UserSelectYes = 757, + UserSelectNo = 758, + UserSelectBack = 759, + LaunchFireWorks = 760, + Resetsuserselection = 761, + SetasBounceBack = 762, + ResetUnlockables = 763, + UISysMsgWaitResponse = 764, + UISysMsgWaitConfirm = 765, + UISysMsgConfirm = 766, + UISysMsgAccept = 767, + UISysMsgDecline = 768, + SetasNOTBounceBack = 769, + PauseGameNow = 770, + PattyWagonStartEngine = 771, + PattyWagonStopEngine = 772, + BubbleSpawnOn = 773, + BubbleSpawnOff = 774, + XBLiveToggleSignIn = 775, + XBLiveManageFriends = 776, + ApplyOnResetOn = 777, + ApplyOnResetOff = 778, + SnapTo = 779, + Throw = 780, + FirstZipLine = 781, + FirstLedgeGrab = 782, + FirstIncredimeterPickup = 783, + UISparkTrail = 784, + UIGetBattleScenes = 785, + UIBattleScenesAvailable = 786, + UIBattleScenesNotAvailable = 787, + XBLiveToggleAppearOnline = 788, + UIReturntopreviousscreen = 789, + UIEmptyEvent = 790, + SubtitlesEnabled = 791, + SubtitlesDisabled = 792, + UISetBoxMappingforUVs = 793, + PlayerEjected = 794, + DamagePlayer = 795, + FirstHealthPickup = 796, + TokenPickupComplete = 797, + Promptisdead = 798, + UIFlipVisibility = 799, + XBLiveRebootToDashboard = 800, + FirstPowerupPoint = 801, + UIIsBattleScene = 802, + UIBattleSceneYes = 803, + UIBattleSceneNo = 804, + UILockelement = 805, + UIUnlockelement = 806, + DrivenbyOff = 807, + DrivenbyOn = 808, + UISignalCreditCode = 809, + UISignalHILogo = 810, + DisableAutoSave = 811, + UISignalEnlargeWindow = 812, + PromptExiting = 813, + PromptForceExit = 814, + UISysMessageActionConfirmed = 815, + UISysMessageActionDeclined = 816 + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/ObjectAsset.cs b/IndustrialPark/Assets/Shared/ObjectAsset.cs index e306256a..6b671c42 100644 --- a/IndustrialPark/Assets/Shared/ObjectAsset.cs +++ b/IndustrialPark/Assets/Shared/ObjectAsset.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing.Design; using System.Linq; namespace IndustrialPark @@ -29,10 +30,7 @@ public ObjectAssetType AssetType } [Category("Object Base"), ReadOnly(true)] - public byte AmountOfEvents - { - get => ReadByte(0x5); - } + public byte AmountOfEvents => ReadByte(0x5); [Category("Object Base"), TypeConverter(typeof(HexShortTypeConverter))] public short Flags @@ -78,38 +76,49 @@ public bool ReceiveShadows protected virtual int EventStartOffset => Data.Length - AmountOfEvents * AssetEvent.sizeOfStruct; - [Category("Object Base")] + [Category("Object Base"), Editor(typeof(EventListEditor), typeof(UITypeEditor))] public AssetEventBFBB[] EventsBFBB { get { - byte amount = ReadByte(0x05); - AssetEventBFBB[] events = new AssetEventBFBB[amount]; + AssetEventBFBB[] events = new AssetEventBFBB[AmountOfEvents]; - for (int i = 0; i < amount; i++) + for (int i = 0; i < AmountOfEvents; i++) events[i] = new AssetEventBFBB(Data, EventStartOffset + i * AssetEvent.sizeOfStruct); return events; } set => WriteEvents(value); } - - [Category("Object Base")] + [Category("Object Base"), Editor(typeof(EventListEditor), typeof(UITypeEditor))] public AssetEventTSSM[] EventsTSSM { get { - byte amount = ReadByte(0x05); - AssetEventTSSM[] events = new AssetEventTSSM[amount]; + AssetEventTSSM[] events = new AssetEventTSSM[AmountOfEvents]; - for (int i = 0; i < amount; i++) + for (int i = 0; i < AmountOfEvents; i++) events[i] = new AssetEventTSSM(Data, EventStartOffset + i * AssetEvent.sizeOfStruct); return events; } set => WriteEvents(value); } - + [Category("Object Base"), Editor(typeof(EventListEditor), typeof(UITypeEditor))] + public AssetEventIncredibles[] EventsIncredibles + { + get + { + AssetEventIncredibles[] events = new AssetEventIncredibles[AmountOfEvents]; + + for (int i = 0; i < AmountOfEvents; i++) + events[i] = new AssetEventIncredibles(Data, EventStartOffset + i * AssetEvent.sizeOfStruct); + + return events; + } + set => WriteEvents(value); + } + protected void WriteEvents(AssetEvent[] value) { List newData = Data.Take(EventStartOffset).ToList(); diff --git a/IndustrialPark/IndustrialPark.csproj b/IndustrialPark/IndustrialPark.csproj index ee470635..79f9b7d3 100644 --- a/IndustrialPark/IndustrialPark.csproj +++ b/IndustrialPark/IndustrialPark.csproj @@ -75,9 +75,16 @@ + + Form + + + EventEditor.cs + + Form @@ -111,6 +118,9 @@ + + + @@ -256,7 +266,6 @@ - @@ -300,6 +309,13 @@ + + EventEditor.cs + Designer + + + EventSearch.cs + PreserveNewest @@ -372,6 +388,12 @@ PreserveNewest + + Form + + + EventSearch.cs + diff --git a/IndustrialPark/MainForm/AboutBox.Designer.cs b/IndustrialPark/MainForm/AboutBox.Designer.cs index 5d05430c..ab62a55b 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 25.1"; + this.labelVersion.Text = "Preview 26"; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // labelCopyright diff --git a/IndustrialPark/MainForm/MainForm.Designer.cs b/IndustrialPark/MainForm/MainForm.Designer.cs index 3770c499..7a0ed314 100644 --- a/IndustrialPark/MainForm/MainForm.Designer.cs +++ b/IndustrialPark/MainForm/MainForm.Designer.cs @@ -107,6 +107,8 @@ 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.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.contextMenuStripMain.SuspendLayout(); @@ -119,7 +121,8 @@ private void InitializeComponent() this.archiveEditorToolStripMenuItem, this.projectToolStripMenuItem, this.optionsToolStripMenuItem, - this.displayToolStripMenuItem}); + this.displayToolStripMenuItem, + this.researchToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1263, 24); @@ -686,7 +689,7 @@ private void InitializeComponent() this.toolStripMenuItem_Templates, this.userTemplateToolStripMenuItem}); this.contextMenuStripMain.Name = "contextMenuStripMain"; - this.contextMenuStripMain.Size = new System.Drawing.Size(181, 92); + this.contextMenuStripMain.Size = new System.Drawing.Size(150, 70); // // gizmoToolStripMenuItem // @@ -696,7 +699,7 @@ private void InitializeComponent() this.scaleToolStripMenuItem, this.positionLocalToolStripMenuItem}); this.gizmoToolStripMenuItem.Name = "gizmoToolStripMenuItem"; - this.gizmoToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.gizmoToolStripMenuItem.Size = new System.Drawing.Size(149, 22); this.gizmoToolStripMenuItem.Text = "Gizmo (V)"; // // positionToolStripMenuItem @@ -704,35 +707,35 @@ private void InitializeComponent() this.positionToolStripMenuItem.Checked = true; this.positionToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.positionToolStripMenuItem.Name = "positionToolStripMenuItem"; - this.positionToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.positionToolStripMenuItem.Size = new System.Drawing.Size(156, 22); this.positionToolStripMenuItem.Text = "Position"; this.positionToolStripMenuItem.Click += new System.EventHandler(this.positionToolStripMenuItem_Click); // // rotationToolStripMenuItem // this.rotationToolStripMenuItem.Name = "rotationToolStripMenuItem"; - this.rotationToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.rotationToolStripMenuItem.Size = new System.Drawing.Size(156, 22); this.rotationToolStripMenuItem.Text = "Rotation"; this.rotationToolStripMenuItem.Click += new System.EventHandler(this.rotationToolStripMenuItem_Click); // // scaleToolStripMenuItem // this.scaleToolStripMenuItem.Name = "scaleToolStripMenuItem"; - this.scaleToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.scaleToolStripMenuItem.Size = new System.Drawing.Size(156, 22); this.scaleToolStripMenuItem.Text = "Scale"; this.scaleToolStripMenuItem.Click += new System.EventHandler(this.scaleToolStripMenuItem_Click); // // positionLocalToolStripMenuItem // this.positionLocalToolStripMenuItem.Name = "positionLocalToolStripMenuItem"; - this.positionLocalToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.positionLocalToolStripMenuItem.Size = new System.Drawing.Size(156, 22); this.positionLocalToolStripMenuItem.Text = "Position (Local)"; this.positionLocalToolStripMenuItem.Click += new System.EventHandler(this.positionLocalToolStripMenuItem_Click); // // toolStripMenuItem_Templates // this.toolStripMenuItem_Templates.Name = "toolStripMenuItem_Templates"; - this.toolStripMenuItem_Templates.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem_Templates.Size = new System.Drawing.Size(149, 22); this.toolStripMenuItem_Templates.Text = "Template"; // // userTemplateToolStripMenuItem @@ -740,7 +743,7 @@ private void InitializeComponent() this.userTemplateToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripComboBoxUserTemplate}); this.userTemplateToolStripMenuItem.Name = "userTemplateToolStripMenuItem"; - this.userTemplateToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.userTemplateToolStripMenuItem.Size = new System.Drawing.Size(149, 22); this.userTemplateToolStripMenuItem.Text = "User Template"; this.userTemplateToolStripMenuItem.Click += new System.EventHandler(this.userTemplateToolStripMenuItem_Click); // @@ -750,6 +753,21 @@ 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 + // + 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); + // // MainForm // this.AllowDrop = true; @@ -858,6 +876,8 @@ private void InitializeComponent() private ToolStripMenuItem rotationToolStripMenuItem; private ToolStripMenuItem scaleToolStripMenuItem; private ToolStripMenuItem positionLocalToolStripMenuItem; + private ToolStripMenuItem researchToolStripMenuItem; + private ToolStripMenuItem eventSearchToolStripMenuItem; } } diff --git a/IndustrialPark/MainForm/MainForm.cs b/IndustrialPark/MainForm/MainForm.cs index 832b92c8..c4ddb5af 100644 --- a/IndustrialPark/MainForm/MainForm.cs +++ b/IndustrialPark/MainForm/MainForm.cs @@ -34,6 +34,10 @@ private void MainForm_Load(object sender, EventArgs e) { UpdateUserTemplateComboBox(); +#if !DEBUG + researchToolStripMenuItem.Visible = false; +#endif + if (File.Exists(pathToSettings)) { IPSettings settings = JsonConvert.DeserializeObject(File.ReadAllText(pathToSettings)); @@ -1053,6 +1057,8 @@ public static void PopulateTemplateMenusAt(ToolStripMenuItem menu, EventHandler { new ToolStripMenuItem(AssetTemplate.Button_Red.ToString()), new ToolStripMenuItem(AssetTemplate.PressurePlate.ToString()), + new ToolStripMenuItem(AssetTemplate.Checkpoint.ToString()), + new ToolStripMenuItem(AssetTemplate.Checkpoint_Invisible.ToString()), new ToolStripMenuItem(AssetTemplate.BusStop.ToString()), new ToolStripMenuItem(AssetTemplate.TeleportBox.ToString()), new ToolStripMenuItem(AssetTemplate.ThrowFruit.ToString()), @@ -1196,5 +1202,10 @@ private void positionLocalToolStripMenuItem_Click(object sender, EventArgs e) { ToggleGizmoType(GizmoMode.PositionLocal); } + + private void eventSearchToolStripMenuItem_Click(object sender, EventArgs e) + { + Program.EventSearch.Show(); + } } } diff --git a/IndustrialPark/Program.cs b/IndustrialPark/Program.cs index 018b738d..ae5b03c3 100644 --- a/IndustrialPark/Program.cs +++ b/IndustrialPark/Program.cs @@ -10,6 +10,7 @@ static class Program public static ViewConfig ViewConfig; public static AboutBox AboutBox; public static UserTemplateManager UserTemplateManager; + public static EventSearch EventSearch; /// /// Ponto de entrada principal para o aplicativo. @@ -30,6 +31,7 @@ static void Main() ViewConfig = new ViewConfig(); AboutBox = new AboutBox(); UserTemplateManager = new UserTemplateManager(); + EventSearch = new EventSearch(); Application.Run(MainForm); } diff --git a/IndustrialPark/Research/EventSearch.Designer.cs b/IndustrialPark/Research/EventSearch.Designer.cs new file mode 100644 index 00000000..c1fb8fe7 --- /dev/null +++ b/IndustrialPark/Research/EventSearch.Designer.cs @@ -0,0 +1,231 @@ +namespace IndustrialPark +{ + partial class EventSearch + { + /// + /// 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.buttonChooseRoot = new System.Windows.Forms.Button(); + this.labelRootDir = new System.Windows.Forms.Label(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.comboSenderAsset = new System.Windows.Forms.ComboBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.comboRecieveEvent = new System.Windows.Forms.ComboBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.comboTargetEvent = new System.Windows.Forms.ComboBox(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.comboTargetAsset = new System.Windows.Forms.ComboBox(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.buttonPerform = new System.Windows.Forms.Button(); + this.richTextBox2 = new System.Windows.Forms.RichTextBox(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.groupBox4.SuspendLayout(); + this.SuspendLayout(); + // + // buttonChooseRoot + // + this.buttonChooseRoot.Location = new System.Drawing.Point(18, 129); + this.buttonChooseRoot.Name = "buttonChooseRoot"; + this.buttonChooseRoot.Size = new System.Drawing.Size(188, 23); + this.buttonChooseRoot.TabIndex = 0; + this.buttonChooseRoot.Text = "Choose Root Directory"; + this.buttonChooseRoot.UseVisualStyleBackColor = true; + this.buttonChooseRoot.Click += new System.EventHandler(this.buttonChooseRoot_Click); + // + // labelRootDir + // + this.labelRootDir.AutoSize = true; + this.labelRootDir.Location = new System.Drawing.Point(12, 9); + this.labelRootDir.Name = "labelRootDir"; + this.labelRootDir.Size = new System.Drawing.Size(107, 13); + this.labelRootDir.TabIndex = 1; + this.labelRootDir.Text = "Root Directory: None"; + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.comboSenderAsset); + this.groupBox1.Location = new System.Drawing.Point(12, 25); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(200, 46); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Sender Asset Filter"; + // + // comboSenderAsset + // + this.comboSenderAsset.FormattingEnabled = true; + this.comboSenderAsset.Location = new System.Drawing.Point(6, 19); + this.comboSenderAsset.Name = "comboSenderAsset"; + this.comboSenderAsset.Size = new System.Drawing.Size(188, 21); + this.comboSenderAsset.TabIndex = 3; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.comboRecieveEvent); + this.groupBox2.Location = new System.Drawing.Point(12, 77); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(200, 46); + this.groupBox2.TabIndex = 4; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Recieve Event Filter"; + // + // comboRecieveEvent + // + this.comboRecieveEvent.FormattingEnabled = true; + this.comboRecieveEvent.Location = new System.Drawing.Point(6, 19); + this.comboRecieveEvent.Name = "comboRecieveEvent"; + this.comboRecieveEvent.Size = new System.Drawing.Size(188, 21); + this.comboRecieveEvent.TabIndex = 3; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.comboTargetEvent); + this.groupBox3.Location = new System.Drawing.Point(218, 77); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(200, 46); + this.groupBox3.TabIndex = 6; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Target Event Filter"; + // + // comboTargetEvent + // + this.comboTargetEvent.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.comboTargetEvent.FormattingEnabled = true; + this.comboTargetEvent.Location = new System.Drawing.Point(6, 19); + this.comboTargetEvent.Name = "comboTargetEvent"; + this.comboTargetEvent.Size = new System.Drawing.Size(188, 21); + this.comboTargetEvent.TabIndex = 3; + // + // groupBox4 + // + this.groupBox4.Controls.Add(this.comboTargetAsset); + this.groupBox4.Location = new System.Drawing.Point(218, 25); + this.groupBox4.Name = "groupBox4"; + this.groupBox4.Size = new System.Drawing.Size(200, 46); + this.groupBox4.TabIndex = 5; + this.groupBox4.TabStop = false; + this.groupBox4.Text = "Target Asset Filter"; + // + // comboTargetAsset + // + this.comboTargetAsset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.comboTargetAsset.FormattingEnabled = true; + this.comboTargetAsset.Location = new System.Drawing.Point(6, 19); + this.comboTargetAsset.Name = "comboTargetAsset"; + this.comboTargetAsset.Size = new System.Drawing.Size(188, 21); + this.comboTargetAsset.TabIndex = 3; + // + // richTextBox1 + // + this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBox1.Location = new System.Drawing.Point(12, 187); + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.Size = new System.Drawing.Size(402, 269); + this.richTextBox1.TabIndex = 7; + this.richTextBox1.Text = ""; + // + // buttonPerform + // + this.buttonPerform.Location = new System.Drawing.Point(224, 129); + this.buttonPerform.Name = "buttonPerform"; + this.buttonPerform.Size = new System.Drawing.Size(188, 23); + this.buttonPerform.TabIndex = 8; + this.buttonPerform.Text = "Perform Search"; + this.buttonPerform.UseVisualStyleBackColor = true; + this.buttonPerform.Click += new System.EventHandler(this.buttonPerform_Click); + // + // richTextBox2 + // + this.richTextBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBox2.Location = new System.Drawing.Point(12, 462); + this.richTextBox2.Name = "richTextBox2"; + this.richTextBox2.Size = new System.Drawing.Size(402, 99); + this.richTextBox2.TabIndex = 9; + this.richTextBox2.Text = ""; + // + // progressBar1 + // + this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.progressBar1.Location = new System.Drawing.Point(12, 158); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Size = new System.Drawing.Size(400, 23); + this.progressBar1.TabIndex = 10; + // + // EventSearch + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(426, 573); + this.Controls.Add(this.progressBar1); + this.Controls.Add(this.richTextBox2); + this.Controls.Add(this.buttonPerform); + this.Controls.Add(this.richTextBox1); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox4); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.labelRootDir); + this.Controls.Add(this.buttonChooseRoot); + this.MaximizeBox = false; + this.Name = "EventSearch"; + this.ShowIcon = false; + this.Text = "Event Search"; + this.TopMost = true; + this.Load += new System.EventHandler(this.EventSearch_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.groupBox4.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonChooseRoot; + private System.Windows.Forms.Label labelRootDir; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.ComboBox comboSenderAsset; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.ComboBox comboRecieveEvent; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.ComboBox comboTargetEvent; + private System.Windows.Forms.GroupBox groupBox4; + private System.Windows.Forms.ComboBox comboTargetAsset; + private System.Windows.Forms.RichTextBox richTextBox1; + private System.Windows.Forms.Button buttonPerform; + private System.Windows.Forms.RichTextBox richTextBox2; + private System.Windows.Forms.ProgressBar progressBar1; + } +} \ No newline at end of file diff --git a/IndustrialPark/Research/EventSearch.cs b/IndustrialPark/Research/EventSearch.cs new file mode 100644 index 00000000..c57901c3 --- /dev/null +++ b/IndustrialPark/Research/EventSearch.cs @@ -0,0 +1,166 @@ +using HipHopFile; +using Microsoft.WindowsAPICodePack.Dialogs; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace IndustrialPark +{ + public partial class EventSearch : Form + { + public EventSearch() + { + InitializeComponent(); + } + + private void EventSearch_Load(object sender, EventArgs e) + { + foreach (AssetType o in Enum.GetValues(typeof(AssetType))) + { + comboSenderAsset.Items.Add(o); + comboTargetAsset.Items.Add(o); + } + foreach (EventTypeBFBB o in Enum.GetValues(typeof(EventTypeBFBB))) + { + comboRecieveEvent.Items.Add(o); + comboTargetEvent.Items.Add(o); + } + } + + protected override void OnFormClosing(FormClosingEventArgs e) + { + if (e.CloseReason == CloseReason.WindowsShutDown) return; + if (e.CloseReason == CloseReason.FormOwnerClosing) return; + + e.Cancel = true; + Hide(); + } + + private string rootDir; + + private void buttonChooseRoot_Click(object sender, EventArgs e) + { + CommonOpenFileDialog openFile = new CommonOpenFileDialog() { IsFolderPicker = true }; + if (openFile.ShowDialog() == CommonFileDialogResult.Ok) + { + rootDir = openFile.FileName; + labelRootDir.Text = "Root Directory: " + rootDir; + } + } + + AssetType senderAssetType; + AssetType recieverAssetType; + EventTypeBFBB recieveEventType; + EventTypeBFBB targetEventType; + + HashSet senders = new HashSet(); + HashSet recievers = new HashSet(); + HashSet recievedEvents = new HashSet(); + HashSet sentEvents = new HashSet(); + + int total = 0; + + private void buttonPerform_Click(object sender, EventArgs e) + { + senderAssetType = (AssetType)comboSenderAsset.SelectedItem; + recieverAssetType = (AssetType)comboTargetAsset.SelectedItem; + recieveEventType = (EventTypeBFBB)comboRecieveEvent.SelectedItem; + targetEventType = (EventTypeBFBB)comboTargetEvent.SelectedItem; + + senders = new HashSet(); + recievers = new HashSet(); + recievedEvents = new HashSet(); + sentEvents = new HashSet(); + + total = 0; + richTextBox1.Clear(); + + AddFolder(rootDir); + + richTextBox2.Text = $"Found a total of {total} events sent by {senders.Count} different asset types: "; + foreach (AssetType type in senders) + richTextBox2.Text += type.ToString() + ", "; + richTextBox2.Text += $"to {recievers.Count} different asset types: "; + foreach (AssetType type in recievers) + richTextBox2.Text += type.ToString() + ", "; + richTextBox2.Text += $"the recieved events are of {recievedEvents.Count} different event types: "; + foreach (EventTypeBFBB type in recievedEvents) + richTextBox2.Text += type.ToString() + ", "; + richTextBox2.Text += $"and the sent events are of {sentEvents.Count} different event types: "; + foreach (EventTypeBFBB type in sentEvents) + richTextBox2.Text += type.ToString() + ", "; + } + + private void AddFolder(string folderPath) + { + foreach (string s in Directory.GetFiles(folderPath)) + { + if (Path.GetExtension(s).ToLower() == ".hip" || Path.GetExtension(s).ToLower() == ".hop") + { + ArchiveEditorFunctions archive = new ArchiveEditorFunctions(); + archive.OpenFile(s); + WriteWhatIFound(archive); + archive.Dispose(); + } + } + foreach (string s in Directory.GetDirectories(folderPath)) + AddFolder(s); + } + + private void WriteWhatIFound(ArchiveEditorFunctions archive) + { + progressBar1.Minimum = 0; + progressBar1.Maximum = archive.GetAllAssets().Count; + progressBar1.Step = 1; + + foreach (Asset asset in archive.GetAllAssets()) + { + progressBar1.PerformStep(); + + if (senderAssetType != AssetType.Null && asset.AHDR.assetType != senderAssetType) + continue; + + if (asset is ObjectAsset objectAsset) + foreach (AssetEventBFBB assetEvent in objectAsset.EventsBFBB) + { + if (recieveEventType != EventTypeBFBB.Unknown && assetEvent.EventReceiveID != recieveEventType) + continue; + if (targetEventType != EventTypeBFBB.Unknown && assetEvent.EventSendID != targetEventType) + continue; + + Asset targetAsset = null; + + if (archive.ContainsAsset(assetEvent.TargetAssetID)) + targetAsset = archive.GetFromAssetID(assetEvent.TargetAssetID); + + if (targetAsset != null && recieverAssetType != AssetType.Null && targetAsset.AHDR.assetType != recieverAssetType) + continue; + + if (targetAsset == null && recieverAssetType != AssetType.Null) + continue; + + string eventName; + if (targetAsset == null) + eventName = $"{objectAsset.AHDR.ADBG.assetName} ({assetEvent.EventReceiveID.ToString()}) => {assetEvent.EventSendID.ToString()} => {assetEvent.TargetAssetID.ToString()} [{assetEvent.Arguments_Float[0]}, {assetEvent.Arguments_Float[1]}, {assetEvent.Arguments_Float[2]}, {assetEvent.Arguments_Float[3]}, {assetEvent.Arguments_Hex[4].ToString()}, {assetEvent.Arguments_Hex[5].ToString()}]"; + else + eventName = $"{objectAsset.AHDR.ADBG.assetName} ({assetEvent.EventReceiveID.ToString()}) => {assetEvent.EventSendID.ToString()} => {targetAsset.AHDR.ADBG.assetName} [{ assetEvent.Arguments_Float[0]}, { assetEvent.Arguments_Float[1]}, { assetEvent.Arguments_Float[2]}, { assetEvent.Arguments_Float[3]}, { assetEvent.Arguments_Hex[4].ToString()}, { assetEvent.Arguments_Hex[5].ToString()}]"; + + richTextBox1.AppendText(eventName + "\n"); + senders.Add(objectAsset.AHDR.assetType); + if (targetAsset != null) + recievers.Add(targetAsset.AHDR.assetType); + recievedEvents.Add(assetEvent.EventReceiveID); + sentEvents.Add(assetEvent.EventSendID); + total++; + } + } + } + } +} diff --git a/IndustrialPark/Research/EventSearch.resx b/IndustrialPark/Research/EventSearch.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/IndustrialPark/Research/EventSearch.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