diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs index 1d2c5d28..ae133e6b 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.Designer.cs @@ -56,8 +56,9 @@ private void InitializeComponent() this.buttonRemoveLayer = new System.Windows.Forms.Button(); this.buttonAddLayer = new System.Windows.Forms.Button(); this.comboBoxLayers = new System.Windows.Forms.ComboBox(); - this.listBoxAssets = new System.Windows.Forms.ListBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.listViewAssets = new System.Windows.Forms.ListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.labelTemplateFocus = new System.Windows.Forms.Label(); this.buttonCopy = new System.Windows.Forms.Button(); this.buttonPaste = new System.Windows.Forms.Button(); @@ -73,6 +74,7 @@ private void InitializeComponent() this.comboBoxAssetTypes = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); this.contextMenuStrip_ListBoxAssets = new System.Windows.Forms.ContextMenuStrip(this.components); + this.addTemplateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem_Add = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem_AddMulti = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem_Duplicate = new System.Windows.Forms.ToolStripMenuItem(); @@ -84,8 +86,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.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.addTemplateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -121,14 +121,14 @@ private void InitializeComponent() // newToolStripMenuItem // this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(143, 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(180, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.openToolStripMenuItem.Text = "Open"; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // @@ -136,7 +136,7 @@ private void InitializeComponent() // this.saveToolStripMenuItem.Enabled = false; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.saveToolStripMenuItem.Text = "Save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // @@ -144,26 +144,26 @@ private void InitializeComponent() // this.saveAsToolStripMenuItem.Enabled = false; this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(143, 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(177, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(140, 6); // // hideButtonsToolStripMenuItem // this.hideButtonsToolStripMenuItem.Name = "hideButtonsToolStripMenuItem"; - this.hideButtonsToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.hideButtonsToolStripMenuItem.Size = new System.Drawing.Size(143, 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(180, 22); + this.closeToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.closeToolStripMenuItem.Text = "Close"; this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click); // @@ -293,9 +293,9 @@ private void InitializeComponent() // this.comboBoxLayerTypes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxLayerTypes.FormattingEnabled = true; - this.comboBoxLayerTypes.Location = new System.Drawing.Point(320, 19); + this.comboBoxLayerTypes.Location = new System.Drawing.Point(296, 19); this.comboBoxLayerTypes.Name = "comboBoxLayerTypes"; - this.comboBoxLayerTypes.Size = new System.Drawing.Size(91, 21); + this.comboBoxLayerTypes.Size = new System.Drawing.Size(115, 21); this.comboBoxLayerTypes.TabIndex = 3; this.comboBoxLayerTypes.SelectedIndexChanged += new System.EventHandler(this.comboBoxLayerTypes_SelectedIndexChanged); // @@ -303,7 +303,7 @@ private void InitializeComponent() // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(280, 22); + this.label1.Location = new System.Drawing.Point(256, 23); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(34, 13); this.label1.TabIndex = 3; @@ -340,30 +340,16 @@ private void InitializeComponent() this.comboBoxLayers.FormattingEnabled = true; this.comboBoxLayers.Location = new System.Drawing.Point(6, 19); this.comboBoxLayers.Name = "comboBoxLayers"; - this.comboBoxLayers.Size = new System.Drawing.Size(268, 21); + this.comboBoxLayers.Size = new System.Drawing.Size(244, 21); this.comboBoxLayers.TabIndex = 3; this.comboBoxLayers.SelectedIndexChanged += new System.EventHandler(this.comboBoxLayers_SelectedIndexChanged); // - // listBoxAssets - // - this.listBoxAssets.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.listBoxAssets.FormattingEnabled = true; - this.listBoxAssets.Location = new System.Drawing.Point(6, 40); - this.listBoxAssets.Name = "listBoxAssets"; - this.listBoxAssets.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; - this.listBoxAssets.Size = new System.Drawing.Size(507, 290); - this.listBoxAssets.TabIndex = 3; - this.listBoxAssets.SelectedIndexChanged += new System.EventHandler(this.listBoxAssets_SelectedIndexChanged); - this.listBoxAssets.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBoxAssets_KeyDown); - this.listBoxAssets.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listBoxAssets_MouseDown); - // // groupBox2 // this.groupBox2.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.groupBox2.Controls.Add(this.listViewAssets); this.groupBox2.Controls.Add(this.labelTemplateFocus); this.groupBox2.Controls.Add(this.buttonCopy); this.groupBox2.Controls.Add(this.buttonPaste); @@ -378,7 +364,6 @@ private void InitializeComponent() this.groupBox2.Controls.Add(this.buttonAddAsset); this.groupBox2.Controls.Add(this.comboBoxAssetTypes); this.groupBox2.Controls.Add(this.label2); - this.groupBox2.Controls.Add(this.listBoxAssets); this.groupBox2.Location = new System.Drawing.Point(12, 80); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(600, 336); @@ -386,6 +371,28 @@ private void InitializeComponent() this.groupBox2.TabStop = false; this.groupBox2.Text = "Assets"; // + // listViewAssets + // + this.listViewAssets.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.listViewAssets.CheckBoxes = true; + this.listViewAssets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1}); + this.listViewAssets.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.listViewAssets.HideSelection = false; + this.listViewAssets.Location = new System.Drawing.Point(6, 40); + this.listViewAssets.Name = "listViewAssets"; + this.listViewAssets.Size = new System.Drawing.Size(507, 289); + this.listViewAssets.TabIndex = 22; + this.listViewAssets.UseCompatibleStateImageBehavior = false; + this.listViewAssets.View = System.Windows.Forms.View.SmallIcon; + this.listViewAssets.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBoxAssets_ItemCheck); + this.listViewAssets.SelectedIndexChanged += new System.EventHandler(this.checkedListBoxAssets_SelectedIndexChanged); + this.listViewAssets.SizeChanged += new System.EventHandler(this.listViewAssets_SizeChanged); + this.listViewAssets.KeyDown += new System.Windows.Forms.KeyEventHandler(this.checkedListBoxAssets_KeyDown); + this.listViewAssets.MouseDown += new System.Windows.Forms.MouseEventHandler(this.checkedListBoxAssets_MouseDown); + // // labelTemplateFocus // this.labelTemplateFocus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -426,9 +433,9 @@ private void InitializeComponent() // textBoxFindAsset // this.textBoxFindAsset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxFindAsset.Location = new System.Drawing.Point(366, 13); + this.textBoxFindAsset.Location = new System.Drawing.Point(296, 13); this.textBoxFindAsset.Name = "textBoxFindAsset"; - this.textBoxFindAsset.Size = new System.Drawing.Size(147, 20); + this.textBoxFindAsset.Size = new System.Drawing.Size(217, 20); this.textBoxFindAsset.TabIndex = 17; this.textBoxFindAsset.TextChanged += new System.EventHandler(this.textBoxFindAsset_TextChanged); // @@ -436,11 +443,11 @@ private void InitializeComponent() // this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(301, 16); + this.label3.Location = new System.Drawing.Point(260, 16); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(59, 13); + this.label3.Size = new System.Drawing.Size(30, 13); this.label3.TabIndex = 16; - this.label3.Text = "Find Asset:"; + this.label3.Text = "Find:"; // // buttonInternalEdit // @@ -531,9 +538,9 @@ private void InitializeComponent() this.comboBoxAssetTypes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.comboBoxAssetTypes.FormattingEnabled = true; - this.comboBoxAssetTypes.Location = new System.Drawing.Point(90, 13); + this.comboBoxAssetTypes.Location = new System.Drawing.Point(46, 13); this.comboBoxAssetTypes.Name = "comboBoxAssetTypes"; - this.comboBoxAssetTypes.Size = new System.Drawing.Size(205, 21); + this.comboBoxAssetTypes.Size = new System.Drawing.Size(204, 21); this.comboBoxAssetTypes.TabIndex = 5; this.comboBoxAssetTypes.SelectedIndexChanged += new System.EventHandler(this.comboBoxAssetTypes_SelectedIndexChanged); // @@ -542,9 +549,9 @@ private void InitializeComponent() this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(6, 16); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(78, 13); + this.label2.Size = new System.Drawing.Size(34, 13); this.label2.TabIndex = 4; - this.label2.Text = "Show by Type:"; + this.label2.Text = "Type:"; // // contextMenuStrip_ListBoxAssets // @@ -560,10 +567,15 @@ private void InitializeComponent() this.toolStripMenuItem_View, this.toolStripMenuItem_Export, this.toolStripMenuItem_EditHeader, - this.toolStripMenuItem_EditData, - this.toolStripSeparator3}); + this.toolStripMenuItem_EditData}); this.contextMenuStrip_ListBoxAssets.Name = "contextMenuStrip_ListBoxAssets"; - this.contextMenuStrip_ListBoxAssets.Size = new System.Drawing.Size(189, 280); + this.contextMenuStrip_ListBoxAssets.Size = new System.Drawing.Size(189, 252); + // + // addTemplateToolStripMenuItem + // + this.addTemplateToolStripMenuItem.Name = "addTemplateToolStripMenuItem"; + this.addTemplateToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.addTemplateToolStripMenuItem.Text = "Add Template"; // // toolStripMenuItem_Add // @@ -640,17 +652,6 @@ private void InitializeComponent() this.toolStripMenuItem_EditData.Text = "Edit Data (Ctrl + G)"; this.toolStripMenuItem_EditData.Click += new System.EventHandler(this.toolStripMenuItem_EditData_Click); // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(185, 6); - // - // addTemplateToolStripMenuItem - // - this.addTemplateToolStripMenuItem.Name = "addTemplateToolStripMenuItem"; - this.addTemplateToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.addTemplateToolStripMenuItem.Text = "Add Template"; - // // ArchiveEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -696,7 +697,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox comboBoxLayers; private System.Windows.Forms.ComboBox comboBoxLayerTypes; private System.Windows.Forms.Label label1; - private System.Windows.Forms.ListBox listBoxAssets; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Button buttonAddAsset; private System.Windows.Forms.ComboBox comboBoxAssetTypes; @@ -737,7 +737,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSelectionCount; private System.Windows.Forms.ToolStripMenuItem hideButtonsToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem addTemplateToolStripMenuItem; + private System.Windows.Forms.ListView listViewAssets; + private System.Windows.Forms.ColumnHeader columnHeader1; } } \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs index 52a0a1f0..8e127fd7 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs @@ -51,7 +51,7 @@ private void newToolStripMenuItem_Click(object sender, EventArgs e) if (archive.UnsavedChanges) { DialogResult result = MessageBox.Show("You have unsaved changes. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); - + if (result == DialogResult.Cancel) return; if (result == DialogResult.Yes) archive.Save(); } @@ -78,7 +78,7 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e) if (archive.UnsavedChanges) { DialogResult result = MessageBox.Show("You have unsaved changes. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); - + if (result == DialogResult.Cancel) return; if (result == DialogResult.Yes) archive.Save(); } @@ -160,7 +160,7 @@ private void closeToolStripMenuItem_Click(object sender, EventArgs e) if (archive.UnsavedChanges) { DialogResult result = MessageBox.Show("You have unsaved changes. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); - + if (result == DialogResult.Cancel) return; if (result == DialogResult.Yes) archive.Save(); } @@ -221,6 +221,8 @@ private void PopulateLayerComboBox() private void comboBoxLayers_SelectedIndexChanged(object sender, EventArgs e) { + if (programIsChangingStuff) return; + programIsChangingStuff = true; comboBoxLayerTypes.SelectedItem = archive.DICT.LTOC.LHDRList[comboBoxLayers.SelectedIndex].layerType.ToString(); @@ -301,7 +303,7 @@ private void buttonRemoveLayer_Click(object sender, EventArgs e) comboBoxLayerTypes.SelectedItem = null; comboBoxAssetTypes.Items.Clear(); - listBoxAssets.Items.Clear(); + listViewAssets.Items.Clear(); buttonAddAsset.Enabled = false; buttonPaste.Enabled = false; @@ -337,8 +339,6 @@ private void buttonArrowDown_Click(object sender, EventArgs e) private void PopulateAssetListAndComboBox() { - PopulateAssetList(); - programIsChangingStuff = true; List assetIDs = archive.DICT.LTOC.LHDRList[comboBoxLayers.SelectedIndex].assetIDlist; @@ -355,32 +355,54 @@ private void PopulateAssetListAndComboBox() comboBoxAssetTypes.Items.AddRange(assetTypeList.ToArray().Cast().ToArray()); comboBoxAssetTypes.SelectedIndex = 0; + PopulateAssetList(); programIsChangingStuff = false; } + AssetType curType = AssetType.Null; + private void PopulateAssetList(AssetType type = AssetType.Null) { - listBoxAssets.Items.Clear(); + curType = type; + listViewAssets.BeginUpdate(); + listViewAssets.Items.Clear(); + if (comboBoxLayers.SelectedItem == null) return; List assetIDs = archive.DICT.LTOC.LHDRList[comboBoxLayers.SelectedIndex].assetIDlist; - List assetList = new List(); + List> assetList = new List>(); for (int i = 0; i < assetIDs.Count(); i++) { + Asset asset = archive.GetFromAssetID(assetIDs[i]); if (type == AssetType.Null) - assetList.Add(archive.GetFromAssetID(assetIDs[i]).ToString()); + assetList.Add(new Tuple(!asset.isInvisible, asset.ToString())); else { - if (archive.GetFromAssetID(assetIDs[i]).AHDR.assetType == type) - assetList.Add(archive.GetFromAssetID(assetIDs[i]).ToString()); + if (asset.AHDR.assetType == type) + assetList.Add(new Tuple(!asset.isInvisible, asset.ToString())); } } assetList.Sort(); - listBoxAssets.Items.AddRange(assetList.ToArray()); - toolStripStatusLabelSelectionCount.Text = $"{listBoxAssets.SelectedItems.Count}/{listBoxAssets.Items.Count} assets selected"; + programIsChangingStuff = true; + + foreach (Tuple t in assetList) + { + listViewAssets.Items.Add(new ListViewItem(t.Item2)); + listViewAssets.Items[listViewAssets.Items.Count - 1].Checked = t.Item1; + } + listViewAssets.EndUpdate(); + + programIsChangingStuff = false; + + toolStripStatusLabelSelectionCount.Text = $"{listViewAssets.SelectedItems.Count}/{listViewAssets.Items.Count} assets selected"; + } + + private void checkedListBoxAssets_ItemCheck(object sender, ItemCheckEventArgs e) + { + archive.GetFromAssetID(GetAssetIDFromName(listViewAssets.Items[e.Index].Text)).isInvisible = e.NewValue != CheckState.Checked; } private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) @@ -391,6 +413,8 @@ private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) PopulateAssetList(); else PopulateAssetList((AssetType)comboBoxAssetTypes.SelectedItem); + + listViewAssets.Refresh(); } } @@ -413,8 +437,8 @@ private void buttonAddAsset_Click(object sender, EventArgs e) archive.SetAssetPositionToView(AHDR.assetID); comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); - PopulateAssetListAndComboBox(); - SetSelectedIndexes(new List() { AHDR.assetID }); + //PopulateAssetListAndComboBox(); + SetSelectedIndices(new List() { AHDR.assetID }, true); } catch (Exception ex) { @@ -455,9 +479,9 @@ private void importMultipleAssetsToolStripMenuItem_Click(object sender, EventArg } comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); - PopulateAssetListAndComboBox(); + //PopulateAssetListAndComboBox(); - SetSelectedIndexes(assetIDs); + SetSelectedIndices(assetIDs, true); } catch (Exception ex) { @@ -468,7 +492,7 @@ private void importMultipleAssetsToolStripMenuItem_Click(object sender, EventArg private void buttonDuplicate_Click(object sender, EventArgs e) { - if (listBoxAssets.SelectedIndex < 0) return; + if (listViewAssets.SelectedItems.Count == 0) return; archive.UnsavedChanges = true; @@ -484,14 +508,13 @@ private void buttonDuplicate_Click(object sender, EventArgs e) } comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); - PopulateAssetListAndComboBox(); - SetSelectedIndexes(finalIndexes); + SetSelectedIndices(finalIndexes, true); } private void buttonCopy_Click(object sender, EventArgs e) { - if (listBoxAssets.SelectedIndex < 0) return; + if (listViewAssets.SelectedItems.Count == 0) return; List copiedAHDRs = new List(); @@ -561,41 +584,55 @@ private void buttonPaste_Click(object sender, EventArgs e) } comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); - PopulateAssetListAndComboBox(); - - SetSelectedIndexes(assetIDs); + + SetSelectedIndices(assetIDs, true); } private void ButtonRemoveAsset_Click(object sender, EventArgs e) { - if (listBoxAssets.SelectedIndex < 0) return; + if (listViewAssets.SelectedItems.Count == 0) return; + + programIsChangingStuff = true; AssetType a = AssetType.Null; if (comboBoxAssetTypes.SelectedIndex > 0) a = (AssetType)comboBoxAssetTypes.SelectedItem; - int prevIndex = listBoxAssets.SelectedIndex; + var prevIndex = listViewAssets.SelectedIndices[0]; archive.RemoveAsset(CurrentlySelectedAssetIDs()); + comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); archive.UnsavedChanges = true; - listBoxAssets.Items.Remove(listBoxAssets.SelectedItem); + foreach (ListViewItem v in listViewAssets.SelectedItems) + listViewAssets.Items.Remove(v); - comboBoxAssetTypes.SelectedItem = a; + programIsChangingStuff = false; - if (listBoxAssets.Items.Count > 0) - try { listBoxAssets.SelectedIndex = prevIndex; } - catch - { - try { listBoxAssets.SelectedIndex = prevIndex - 1; } - catch { } - } + if (a != curType) + comboBoxAssetTypes.SelectedItem = a; + else + { + for (int i = 0; i < listViewAssets.Items.Count; i++) + listViewAssets.Items[i].Selected = false; + + if (listViewAssets.Items.Count > 0) + try { listViewAssets.Items[prevIndex].Selected = true; } + catch + { + try { listViewAssets.Items[prevIndex - 1].Selected = true; } + catch { } + } + } + + if (listViewAssets.Items.Count == 0) + PopulateAssetListAndComboBox(); } private void buttonView_Click(object sender, EventArgs e) { - if (listBoxAssets.SelectedIndex < 0) return; + if (listViewAssets.SelectedItems.Count == 0) return; if (archive.GetFromAssetID(CurrentlySelectedAssetIDs()[0]) is AssetCAM cam) Program.MainForm.renderer.Camera.SetPositionCamera(cam); @@ -625,8 +662,8 @@ private void buttonEditAsset_Click(object sender, EventArgs e) if (setPosition) archive.SetAssetPositionToView(AHDR.assetID); - PopulateAssetListAndComboBox(); - SetSelectedIndexes(new List() { AHDR.assetID }); + //PopulateAssetListAndComboBox(); + SetSelectedIndices(new List() { AHDR.assetID }, true); } } catch (Exception ex) @@ -648,12 +685,13 @@ public void OpenInternalEditors() public void DeleteSelectedAssets() { ButtonRemoveAsset_Click(null, null); - listBoxAssets.SelectedIndex = -1; + foreach (ListViewItem v in listViewAssets.Items) + v.Selected = false; } private void buttonExportRaw_Click(object sender, EventArgs e) { - if (listBoxAssets.SelectedItem == null) + if (listViewAssets.SelectedItems.Count == 0) return; if (CurrentlySelectedAssetIDs().Count == 1) @@ -694,8 +732,8 @@ private void buttonExportRaw_Click(object sender, EventArgs e) private List CurrentlySelectedAssetIDs() { List list = new List(); - foreach (object i in listBoxAssets.SelectedItems) - list.Add(GetAssetIDFromName(i as string)); + foreach (ListViewItem v in listViewAssets.SelectedItems) + list.Add(GetAssetIDFromName(v.Text)); return list; } @@ -704,15 +742,18 @@ private uint GetAssetIDFromName(string name) return Convert.ToUInt32(name.Substring(name.IndexOf('[') + 1, 8), 16); } - private void listBoxAssets_SelectedIndexChanged(object sender, EventArgs e) + private void checkedListBoxAssets_SelectedIndexChanged(object sender, EventArgs e) { - toolStripStatusLabelSelectionCount.Text = $"{listBoxAssets.SelectedItems.Count}/{listBoxAssets.Items.Count} assets selected"; + if (programIsChangingStuff) + return; + + toolStripStatusLabelSelectionCount.Text = $"{listViewAssets.SelectedItems.Count}/{listViewAssets.Items.Count} assets selected"; archive.ClearSelectedAssets(); - foreach (string s in listBoxAssets.SelectedItems) - archive.SelectAsset(GetAssetIDFromName(s), true); + foreach (ListViewItem v in listViewAssets.SelectedItems) + archive.SelectAsset(GetAssetIDFromName(v.Text), true); - if (listBoxAssets.SelectedItems.Count == 0) + if (listViewAssets.SelectedItems.Count == 0) { buttonCopy.Enabled = false; buttonDuplicate.Enabled = false; @@ -729,7 +770,7 @@ private void listBoxAssets_SelectedIndexChanged(object sender, EventArgs e) buttonInternalEdit.Enabled = true; } - if (listBoxAssets.SelectedItems.Count == 1) + if (listViewAssets.SelectedItems.Count == 1) { buttonEditAsset.Enabled = true; @@ -758,49 +799,63 @@ public void MouseMoveGeneric(Matrix viewProjection, int deltaX, int deltaY) archive.MouseMoveForPositionLocal(viewProjection, deltaX, deltaY); } - public void SetSelectedIndexes(List assetIDs, bool add = false) + public void SetSelectedIndices(List assetIDs, bool newlyAddedObjects, bool add = false) { + listViewAssets.BeginUpdate(); if (assetIDs.Contains(0) && !add) { - listBoxAssets.SelectedIndices.Clear(); + listViewAssets.SelectedIndices.Clear(); ArchiveEditorFunctions.UpdateGizmoPosition(); + listViewAssets.EndUpdate(); return; } + foreach (uint u in assetIDs) + if (!archive.ContainsAsset(u)) + { + listViewAssets.EndUpdate(); + return; + } + if (add) assetIDs.AddRange(CurrentlySelectedAssetIDs()); - listBoxAssets.SelectedIndices.Clear(); + listViewAssets.SelectedIndices.Clear(); AssetType assetType = AssetType.Null; foreach (uint u in assetIDs) - if (archive.ContainsAsset(u)) - { - assetType = archive.GetFromAssetID(u).AHDR.assetType; - comboBoxLayers.SelectedIndex = archive.GetLayerFromAssetID(u); - break; - } + { + assetType = archive.GetFromAssetID(u).AHDR.assetType; + comboBoxLayers.SelectedIndex = archive.GetLayerFromAssetID(u); + break; + } foreach (uint u in assetIDs) - if (archive.ContainsAsset(u) && archive.GetFromAssetID(u).AHDR.assetType != assetType) + if (archive.GetFromAssetID(u).AHDR.assetType != assetType) { assetType = AssetType.Null; break; } - comboBoxAssetTypes.SelectedItem = assetType; - PopulateAssetList(assetType); + if (curType != assetType || newlyAddedObjects) + { + comboBoxAssetTypes.SelectedItem = assetType; + PopulateAssetList(assetType); + } + int last = 0; foreach (uint u in assetIDs) { - if (!archive.ContainsAsset(u)) - continue; - - for (int i = 0; i < listBoxAssets.Items.Count; i++) - if (GetAssetIDFromName(listBoxAssets.Items[i] as string) == u) - listBoxAssets.SelectedIndices.Add(i); + for (int i = 0; i < listViewAssets.Items.Count; i++) + if (GetAssetIDFromName(listViewAssets.Items[i].Text) == u) + { + listViewAssets.SelectedIndices.Add(i); + last = i; + } } + listViewAssets.EndUpdate(); + listViewAssets.EnsureVisible(last); } System.Drawing.Color defaultColor; @@ -812,12 +867,14 @@ private void textBoxFindAsset_TextChanged(object sender, EventArgs e) { textBoxFindAsset.BackColor = defaultColor; assetID = AssetIDTypeConverter.AssetIDFromString(textBoxFindAsset.Text); - SetSelectedIndexes(new List() { assetID }); } catch { textBoxFindAsset.BackColor = System.Drawing.Color.Red; } + + if (assetID != 0 & archive.ContainsAsset(assetID)) + SetSelectedIndices(new List() { assetID }, false); } private void hipHopToolExportToolStripMenuItem_Click(object sender, EventArgs e) @@ -907,7 +964,7 @@ private void toolStripMenuItem_AddMulti_Click(object sender, EventArgs e) importMultipleAssetsToolStripMenuItem_Click(null, null); } - private void listBoxAssets_KeyDown(object sender, KeyEventArgs e) + private void checkedListBoxAssets_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.I && e.Modifiers == Keys.Control) { @@ -946,7 +1003,7 @@ private void listBoxAssets_KeyDown(object sender, KeyEventArgs e) } } - private void listBoxAssets_MouseDown(object sender, MouseEventArgs e) + private void checkedListBoxAssets_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { @@ -962,7 +1019,7 @@ private void listBoxAssets_MouseDown(object sender, MouseEventArgs e) toolStripMenuItem_EditData.Enabled = buttonInternalEdit.Enabled; addTemplateToolStripMenuItem.Enabled = buttonAddAsset.Enabled; - contextMenuStrip_ListBoxAssets.Show(listBoxAssets.PointToScreen(e.Location)); + contextMenuStrip_ListBoxAssets.Show(listViewAssets.PointToScreen(e.Location)); } } @@ -999,9 +1056,9 @@ public void PlaceTemplate(Vector3 position, AssetTemplate template = AssetTempla archive.UnsavedChanges = true; comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); - PopulateAssetListAndComboBox(); + //PopulateAssetListAndComboBox(); - SetSelectedIndexes(assetIDs); + SetSelectedIndices(assetIDs, true); } } @@ -1052,12 +1109,17 @@ private void hideButtonsToolStripMenuItem_Click(object sender, EventArgs e) if (hideButtonsToolStripMenuItem.Checked) { - listBoxAssets.Size = new System.Drawing.Size(listBoxAssets.Size.Width + 81, listBoxAssets.Size.Height); + listViewAssets.Size = new System.Drawing.Size(listViewAssets.Size.Width + 81, listViewAssets.Size.Height); } else { - listBoxAssets.Size = new System.Drawing.Size(listBoxAssets.Size.Width - 81, listBoxAssets.Size.Height); + listViewAssets.Size = new System.Drawing.Size(listViewAssets.Size.Width - 81, listViewAssets.Size.Height); } } + + private void listViewAssets_SizeChanged(object sender, EventArgs e) + { + columnHeader1.Width = listViewAssets.Width - 28; + } } } \ No newline at end of file diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs index c87cd78e..1e497779 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs @@ -591,6 +591,9 @@ private void AddAssetToDictionary(Section_AHDR AHDR) throw new Exception("Unknown asset type: " + AHDR.assetType); } + if (hiddenAssets.Contains(AHDR.assetID)) + assetDictionary[AHDR.assetID].isInvisible = true; + allowRender = true; } diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs index c48241c2..ba40bb9b 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs @@ -13,6 +13,18 @@ namespace IndustrialPark { public partial class ArchiveEditorFunctions { + public static List hiddenAssets = new List(); + + public List GetHiddenAssets() + { + List hiddenAssets = new List(); + foreach (Asset a in assetDictionary.Values) + if (a.isInvisible) + hiddenAssets.Add(a.AHDR.assetID); + + return hiddenAssets; + } + private List internalEditors = new List(); public void CloseInternalEditor(IInternalEditor i) @@ -31,8 +43,10 @@ public void OpenInternalEditor(List list, bool openAnyway) { bool willOpen = true; if (list.Count > 15 && !openAnyway) + { willOpen = MessageBox.Show($"Warning: you're going to open {list.Count} Asset Data Editor windows. Are you sure you want to do that?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes; - + } + if (willOpen) foreach (uint u in list) if (assetDictionary.ContainsKey(u)) diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs index 2f455bb3..bd072e18 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs @@ -49,7 +49,7 @@ protected void CreateBoundingBox() public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; if (ray.Intersects(ref boundingBox, out float distance)) @@ -84,7 +84,7 @@ protected void CreateBoundingBox() public void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; renderer.DrawCube(world, isSelected); } diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs index 65b32741..927da8b8 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs @@ -47,7 +47,7 @@ protected void CreateBoundingBox() public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; if (ray.Intersects(ref boundingBox, out float distance)) @@ -82,7 +82,7 @@ protected void CreateBoundingBox() public void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; renderer.DrawPyramid(world, isSelected, 1f); } diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs index 5bd75089..b3e24a98 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs @@ -75,7 +75,7 @@ protected void CreateBoundingBox() public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; if (ray.Intersects(ref boundingSphere)) @@ -114,7 +114,7 @@ protected void CreateBoundingBox() public void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; if (_distanceICanSeeYou == -1f) renderer.DrawPyramid(world, isSelected, 1f); diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetSFX.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetSFX.cs index 8102ac6e..b32ba019 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetSFX.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetSFX.cs @@ -57,7 +57,7 @@ protected void CreateBoundingBox() public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; if (ray.Intersects(ref boundingSphere)) @@ -92,7 +92,7 @@ protected void CreateBoundingBox() public void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; renderer.DrawSphere(world, isSelected, renderer.sfxColor); diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPKUP.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPKUP.cs index ffe7a231..9f371543 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPKUP.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPKUP.cs @@ -31,7 +31,7 @@ public override bool HasReference(uint assetID) protected override float? TriangleIntersection(Ray r, float initialDistance) { - if (dontRender) + if (dontRender || isInvisible) return null; uint _modelAssetId; @@ -78,7 +78,7 @@ public override bool HasReference(uint assetID) public override void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; if (AssetPICK.pickEntries.ContainsKey(_pickEntryID)) if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(AssetPICK.pickEntries[_pickEntryID])) { diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLYR.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLYR.cs index acda1a36..26e3e7bc 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLYR.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetPLYR.cs @@ -66,7 +66,7 @@ protected override void CreateBoundingBox() public override void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; renderer.DrawPyramid(world, isSelected, 1f); } diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs index e6bdeafd..320c400a 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs @@ -86,7 +86,7 @@ protected override void CreateBoundingBox() public override void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; if (Shape == TriggerShape.Box) renderer.DrawCube(world, isSelected, 1f); @@ -96,7 +96,7 @@ public override void Draw(SharpRenderer renderer) public override float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; if (Shape == TriggerShape.Box) diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetUI.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetUI.cs index 98159825..9e380f79 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetUI.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetUI.cs @@ -65,7 +65,7 @@ protected override void CreateBoundingBox() public override void Draw(SharpRenderer renderer) { - if (DontRender) + if (DontRender || isInvisible) return; if (_textureAssetID == 0) diff --git a/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs b/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs index 50cf9a2f..cfde1cbd 100644 --- a/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs +++ b/IndustrialPark/Assets/ObjectAssets/DYNA/AssetDYNA.cs @@ -163,7 +163,7 @@ public DynaBase DynaBase public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; return _dynaSpecific.IntersectsWith(ray); @@ -181,7 +181,7 @@ public void CreateTransformMatrix() public void Draw(SharpRenderer renderer) { - if (dontRender) + if (dontRender || isInvisible) return; _dynaSpecific.Draw(renderer, isSelected); diff --git a/IndustrialPark/Assets/Renderable/AssetJSP.cs b/IndustrialPark/Assets/Renderable/AssetJSP.cs index 021c03b9..a85b03a7 100644 --- a/IndustrialPark/Assets/Renderable/AssetJSP.cs +++ b/IndustrialPark/Assets/Renderable/AssetJSP.cs @@ -50,14 +50,14 @@ public float GetDistance(Vector3 cameraPosition) public void Draw(SharpRenderer renderer) { - if (dontRender) return; + if (dontRender || isInvisible) return; model.Render(renderer, Matrix.Identity, isSelected ? renderer.selectedObjectColor : Vector4.One); } public float? IntersectsWith(Ray ray) { - if (dontRender) + if (dontRender || isInvisible) return null; return TriangleIntersection(ray); diff --git a/IndustrialPark/Assets/Shared/Asset.cs b/IndustrialPark/Assets/Shared/Asset.cs index d98fd00f..95c4ef3b 100644 --- a/IndustrialPark/Assets/Shared/Asset.cs +++ b/IndustrialPark/Assets/Shared/Asset.cs @@ -12,6 +12,7 @@ public class Asset public Section_AHDR AHDR; public bool isSelected; + public bool isInvisible = false; public Asset(Section_AHDR AHDR) { diff --git a/IndustrialPark/Assets/Shared/PlaceableAsset.cs b/IndustrialPark/Assets/Shared/PlaceableAsset.cs index 8db27a99..31e9181a 100644 --- a/IndustrialPark/Assets/Shared/PlaceableAsset.cs +++ b/IndustrialPark/Assets/Shared/PlaceableAsset.cs @@ -84,7 +84,7 @@ protected void CreateBoundingBox(List vertexList, float multiplier = 1f public virtual void Draw(SharpRenderer renderer) { - if (DontRender) return; + if (DontRender || isInvisible) return; if (ArchiveEditorFunctions.renderingDictionary.ContainsKey(_modelAssetID)) ArchiveEditorFunctions.renderingDictionary[_modelAssetID].Draw(renderer, world, isSelected ? renderer.selectedObjectColor * _color : _color); @@ -94,7 +94,7 @@ public virtual void Draw(SharpRenderer renderer) public virtual float? IntersectsWith(Ray ray) { - if (DontRender) + if (DontRender || isInvisible) return null; if (ray.Intersects(ref boundingBox, out float distance)) diff --git a/IndustrialPark/MainForm/AboutBox.Designer.cs b/IndustrialPark/MainForm/AboutBox.Designer.cs index fde93365..e1f2b5b4 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 23"; + this.labelVersion.Text = "Preview 24"; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // labelCopyright diff --git a/IndustrialPark/MainForm/Json/ProjectJson.cs b/IndustrialPark/MainForm/Json/ProjectJson.cs index 1b257a68..7530b532 100644 --- a/IndustrialPark/MainForm/Json/ProjectJson.cs +++ b/IndustrialPark/MainForm/Json/ProjectJson.cs @@ -7,6 +7,7 @@ public class ProjectJson { public List hipPaths; public List TextureFolderPaths; + public List hiddenAssets; public Vector3 CamPos; public float Yaw; @@ -54,6 +55,7 @@ public ProjectJson() { hipPaths = new List(); TextureFolderPaths = new List(); + hiddenAssets = new List(); CamPos = new Vector3(); Yaw = 0; @@ -101,10 +103,10 @@ public ProjectJson() public ProjectJson(List hipPaths, List textureFolderPaths, Vector3 camPos, float yaw, float pitch, float speed, float speedRot, float fieldOfView, float farPlane, bool noCulling, bool wireframe, Color4 backgroundColor, Vector4 widgetColor, Vector4 trigColor, - Vector4 mvptColor, Vector4 sfxColor, bool useLegacyAssetIDFormat, bool alternateNameDisplayMode, bool isDrawingUI, bool dontRenderLevelModel, - bool dontRenderBOUL, bool dontRenderBUTN, bool dontRenderCAM, bool dontRenderDSTR, bool dontRenderDYNA, bool dontRenderEGEN, bool dontRenderHANG, - bool dontRenderMRKR, bool dontRenderMVPT, bool dontRenderPEND, bool dontRenderPKUP, bool dontRenderPLAT, bool dontRenderPLYR, bool dontRenderSFX, - bool dontRenderSIMP, bool dontRenderTRIG, bool dontRenderUI, bool dontRenderUIFT, bool dontRenderVIL) + Vector4 mvptColor, Vector4 sfxColor, bool useLegacyAssetIDFormat, bool alternateNameDisplayMode, List hiddenAssets, bool isDrawingUI, + bool dontRenderLevelModel, bool dontRenderBOUL, bool dontRenderBUTN, bool dontRenderCAM, bool dontRenderDSTR, bool dontRenderDYNA, bool dontRenderEGEN, + bool dontRenderHANG, bool dontRenderMRKR, bool dontRenderMVPT, bool dontRenderPEND, bool dontRenderPKUP, bool dontRenderPLAT, bool dontRenderPLYR, + bool dontRenderSFX, bool dontRenderSIMP, bool dontRenderTRIG, bool dontRenderUI, bool dontRenderUIFT, bool dontRenderVIL) { this.hipPaths = hipPaths; TextureFolderPaths = textureFolderPaths; @@ -124,6 +126,7 @@ public ProjectJson(List hipPaths, List textureFolderPaths, Vecto SfxColor = sfxColor; UseLegacyAssetIDFormat = useLegacyAssetIDFormat; AlternateNameDisplayMode = alternateNameDisplayMode; + this.hiddenAssets = hiddenAssets; this.isDrawingUI = isDrawingUI; this.dontRenderLevelModel = dontRenderLevelModel; this.dontRenderBOUL = dontRenderBOUL; diff --git a/IndustrialPark/MainForm/MainForm.cs b/IndustrialPark/MainForm/MainForm.cs index 56bf2ea1..feff4ec6 100644 --- a/IndustrialPark/MainForm/MainForm.cs +++ b/IndustrialPark/MainForm/MainForm.cs @@ -68,7 +68,9 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (UnsavedChanges()) { + TopMost = true; DialogResult result = MessageBox.Show("You appear to have unsaved changes in one of your Archive Editors. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + TopMost = false; if (result == DialogResult.Yes) SaveAllChanges(); else if (result == DialogResult.Cancel) @@ -101,7 +103,9 @@ private void MainForm_DragDrop(object sender, DragEventArgs e) } catch (Exception ex) { + TopMost = true; MessageBox.Show("Error opening file: " + ex.Message); + TopMost = true; } } @@ -115,8 +119,10 @@ private void newToolStripMenuItem1_Click(object sender, EventArgs e) { if (UnsavedChanges()) { + TopMost = true; DialogResult result = MessageBox.Show("You appear to have unsaved changes in one of your Archive Editors. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); - if (result == DialogResult.Yes) + TopMost = false; + if (result == DialogResult.Yes) SaveAllChanges(); else if (result == DialogResult.Cancel) return; @@ -131,7 +137,9 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (UnsavedChanges()) { + TopMost = true; DialogResult result = MessageBox.Show("You appear to have unsaved changes in one of your Archive Editors. Do you wish to save them before closing?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + TopMost = false; if (result == DialogResult.Yes) SaveAllChanges(); else if (result == DialogResult.Cancel) @@ -189,13 +197,18 @@ private void autoSaveOnClosingToolStripMenuItem_Click(object sender, EventArgs e public ProjectJson FromCurrentInstance() { List hips = new List(); + List hiddenAssets = new List(); + foreach (ArchiveEditor ae in archiveEditors) + { hips.Add(ae.GetCurrentlyOpenFileName()); + hiddenAssets.AddRange(ae.archive.GetHiddenAssets()); + } return new ProjectJson(hips, TextureManager.OpenTextureFolders.ToList(), renderer.Camera.Position, renderer.Camera.Yaw, renderer.Camera.Pitch, renderer.Camera.Speed, renderer.Camera.SpeedRot, renderer.Camera.FieldOfView,renderer.Camera.FarPlane, noCullingCToolStripMenuItem.Checked, wireframeFToolStripMenuItem.Checked, renderer.backgroundColor, renderer.normalColor, renderer.trigColor, - renderer.mvptColor, renderer.sfxColor, useLegacyAssetIDFormatToolStripMenuItem.Checked, alternateNamingMode, renderer.isDrawingUI, + renderer.mvptColor, renderer.sfxColor, useLegacyAssetIDFormatToolStripMenuItem.Checked, alternateNamingMode, hiddenAssets, renderer.isDrawingUI, AssetJSP.dontRender, AssetBOUL.dontRender, AssetBUTN.dontRender, AssetCAM.dontRender, AssetDSTR.dontRender, AssetDYNA.dontRender, AssetEGEN.dontRender, AssetHANG.dontRender, AssetMRKR.dontRender, AssetMVPT.dontRender, AssetPEND.dontRender, AssetPLAT.dontRender, AssetPLAT.dontRender, AssetPLYR.dontRender, AssetSFX.dontRender, AssetSIMP.dontRender, AssetTRIG.dontRender, AssetUI.dontRender, AssetUIFT.dontRender, AssetVIL.dontRender); @@ -216,13 +229,19 @@ private void ApplySettings(ProjectJson ipSettings) if (Directory.Exists(s)) TextureManager.LoadTexturesFromFolder(s); else + { + TopMost = true; MessageBox.Show("Error loading textures from " + s + ": folder not found"); + TopMost = false; + } List aeList = new List(); aeList.AddRange(archiveEditors); foreach (ArchiveEditor ae in aeList) ae.CloseArchiveEditor(); + ArchiveEditorFunctions.hiddenAssets = ipSettings.hiddenAssets; + foreach (string s in ipSettings.hipPaths) if (s == "Empty") AddArchiveEditor(); @@ -231,9 +250,15 @@ private void ApplySettings(ProjectJson ipSettings) if (File.Exists(s)) AddArchiveEditor(s); else + { + TopMost = true; MessageBox.Show("Error opening " + s + ": file not found"); + TopMost = false; + } } + ArchiveEditorFunctions.hiddenAssets.Clear(); + renderer.Camera.SetPosition(ipSettings.CamPos); renderer.Camera.Yaw = ipSettings.Yaw; renderer.Camera.Pitch = ipSettings.Pitch; @@ -712,7 +737,7 @@ private void renderPanel_MouseLeave(object sender, EventArgs e) public void SetSelectedIndex(uint assetID) { foreach (ArchiveEditor ae in archiveEditors) - ae.SetSelectedIndexes(new List() { assetID }, PressedKeys.Contains(Keys.ControlKey) || PressedKeys.Contains(Keys.Control)); + ae.SetSelectedIndices(new List() { assetID }, false, PressedKeys.Contains(Keys.ControlKey) || PressedKeys.Contains(Keys.Control)); } private void OpenInternalEditors() @@ -899,7 +924,11 @@ public void FindWhoTargets(uint assetID) bool willOpen = true; if (whoTargets.Count > 15) + { + TopMost = true; willOpen = MessageBox.Show($"Warning: you're going to open {whoTargets.Count} Asset Data Editor windows. Are you sure you want to do that?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes; + TopMost = false; + } if (willOpen) foreach (ArchiveEditor archiveEditor in archiveEditors) @@ -1087,7 +1116,9 @@ private void TemplateToolStripItemClick(object sender, EventArgs e) } } + TopMost = true; MessageBox.Show("There was a problem setting your template for placement"); + TopMost = false; } private void userTemplateToolStripMenuItem_Click(object sender, EventArgs e)