diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs index ba652385..7b5f781e 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs @@ -731,7 +731,14 @@ private void importMultipleAssetsToolStripMenuItem_Click(object sender, EventArg private void importModelsToolStripMenuItem_Click(object sender, EventArgs e) { - (List AHDRs, bool overwrite, bool makeSimps, bool ledgeGrabSimps, bool piptVcolors, bool solidSimps, bool jsp) = ImportModel.GetModels(archive.game); + (List AHDRs, + bool overwrite, + bool makeSimps, + bool ledgeGrabSimps, + bool piptVcolors, + bool solidSimps, + bool jsp, + bool placeOnExistingDefaultLayer) = ImportModel.GetModels(archive.game, archive.NoLayers); if (AHDRs != null) { @@ -739,7 +746,7 @@ private void importModelsToolStripMenuItem_Click(object sender, EventArgs e) if (piptVcolors) archive.MakePiptVcolors(assetIDs); if (makeSimps) - assetIDs.AddRange(archive.MakeSimps(assetIDs, solidSimps, ledgeGrabSimps)); + assetIDs.AddRange(archive.MakeSimps(assetIDs, solidSimps, ledgeGrabSimps, placeOnExistingDefaultLayer)); PopulateLayerComboBox(); OnEditorUpdate(); SetSelectedIndices(assetIDs, true); diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs index 05a09aee..df6bc61b 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions_AssetEditing.cs @@ -898,12 +898,32 @@ public void ApplyScale(Vector3 factor, IEnumerable assetTypes = null, RecalculateAllMatrices(); } - public List MakeSimps(List assetIDs, bool solid, bool ledgeGrabSimps) + public List MakeSimps(List assetIDs, bool solid, bool ledgeGrabSimps, bool placeOnExistingDefaultLayer) { if (!NoLayers) { - AddLayer(); - SelectedLayerIndex = Layers.Count - 1; + bool defaultLayerExists = false; + + if (placeOnExistingDefaultLayer) + { + // Check every layer to see whether it is of type default + for (int i = 0; i < Layers.Count; i++) + { + if (Layers[i].Type != LayerType.DEFAULT) continue; + + // If the layer is a default layer, select it. + // Pick the first default layer found. + defaultLayerExists = true; + SelectedLayerIndex = i; + break; + } + } + + if (!placeOnExistingDefaultLayer || !defaultLayerExists) + { + AddLayer(); + SelectedLayerIndex = Layers.Count - 1; + } } List outAssetIDs = new List(); diff --git a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.Designer.cs b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.Designer.cs index f2753610..57dfe07d 100644 --- a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.Designer.cs +++ b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.Designer.cs @@ -45,6 +45,7 @@ private void InitializeComponent() this.checkBoxSolidSimps = new System.Windows.Forms.CheckBox(); this.grpImportSettings = new System.Windows.Forms.GroupBox(); this.grpSIMP = new System.Windows.Forms.GroupBox(); + this.checkBoxUseExistingDefaultLayer = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.grpImportSettings.SuspendLayout(); @@ -163,6 +164,7 @@ private void InitializeComponent() // // grpSIMP // + this.grpSIMP.Controls.Add(this.checkBoxUseExistingDefaultLayer); this.grpSIMP.Controls.Add(this.checkBoxGenSimps); this.grpSIMP.Controls.Add(this.checkBoxSolidSimps); this.grpSIMP.Controls.Add(this.checkBoxLedgeGrab); @@ -170,6 +172,14 @@ private void InitializeComponent() this.grpSIMP.Name = "grpSIMP"; this.grpSIMP.TabStop = false; // + // checkBoxUseExistingDefaultLayer + // + resources.ApplyResources(this.checkBoxUseExistingDefaultLayer, "checkBoxUseExistingDefaultLayer"); + this.checkBoxUseExistingDefaultLayer.Checked = true; + this.checkBoxUseExistingDefaultLayer.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxUseExistingDefaultLayer.Name = "checkBoxUseExistingDefaultLayer"; + this.checkBoxUseExistingDefaultLayer.UseVisualStyleBackColor = true; + // // ImportModel // this.AcceptButton = this.buttonOK; @@ -195,9 +205,10 @@ private void InitializeComponent() this.grpSIMP.ResumeLayout(false); this.grpSIMP.PerformLayout(); this.ResumeLayout(false); - } + private System.Windows.Forms.CheckBox checkBoxUseExistingDefaultLayer; + #endregion private System.Windows.Forms.ComboBox comboBoxAssetTypes; diff --git a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.cs b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.cs index 97b123d4..a86ea35e 100644 --- a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.cs +++ b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.cs @@ -11,7 +11,7 @@ namespace IndustrialPark { public partial class ImportModel : Form { - public ImportModel() + public ImportModel(bool noLayers) { InitializeComponent(); @@ -21,6 +21,7 @@ public ImportModel() comboBoxAssetTypes.Items.Add(AssetType.BSP); // comboBoxAssetTypes.Items.Add(AssetType.JSP); comboBoxAssetTypes.SelectedItem = AssetType.Model; + checkBoxUseExistingDefaultLayer.Visible = !noLayers; } List filePaths = new List(); @@ -66,21 +67,15 @@ private void buttonOK_Click(object sender, EventArgs e) Close(); } - public static (List AHDRs, bool overwrite, bool simps, bool ledgeGrab, bool piptVColors, bool solidSimps, bool jsp) GetModels(Game game) + public static (List AHDRs, bool overwrite, bool simps, bool ledgeGrab, bool piptVColors, bool solidSimps, bool jsp, bool useExistingDefaultLayer) GetModels(Game game, bool noLayers) { - using (ImportModel a = new ImportModel()) + using (ImportModel a = new ImportModel(noLayers)) if (a.ShowDialog() == DialogResult.OK) { List AHDRs = new List(); AssetType assetType = (AssetType)a.comboBoxAssetTypes.SelectedItem; - if (assetType == AssetType.Model) - { - if (a.checkBoxGenSimps.Checked) - MessageBox.Show("a SIMP for each imported MODL will be generated and placed on a new DEFAULT layer."); - } - foreach (string filePath in a.filePaths) { string assetName; @@ -110,7 +105,7 @@ public static (List AHDRs, bool overwrite, bool simps, bool ledgeG "Error Importing Model", MessageBoxButtons.OK, MessageBoxIcon.Error); - return (null, false, false, false, false, false, false); + return (null, false, false, false, false, false, false, false); } catch (Exception) { @@ -118,7 +113,7 @@ public static (List AHDRs, bool overwrite, bool simps, bool ledgeG "Error Importing Model", MessageBoxButtons.OK, MessageBoxIcon.Error); - return (null, false, false, false, false, false, false); + return (null, false, false, false, false, false, false, false); } } else if (assetType == AssetType.BSP) @@ -142,7 +137,7 @@ public static (List AHDRs, bool overwrite, bool simps, bool ledgeG "Error Importing Model", MessageBoxButtons.OK, MessageBoxIcon.Error); - return (null, false, false, false, false, false, false); + return (null, false, false, false, false, false, false, false); } catch (Exception) { @@ -150,7 +145,7 @@ public static (List AHDRs, bool overwrite, bool simps, bool ledgeG "Error Importing Model", MessageBoxButtons.OK, MessageBoxIcon.Error); - return (null, false, false, false, false, false, false); + return (null, false, false, false, false, false, false, false); } } @@ -165,16 +160,24 @@ public static (List AHDRs, bool overwrite, bool simps, bool ledgeG assetData)); } - return (AHDRs, a.checkBoxOverwrite.Checked, a.checkBoxGenSimps.Checked, a.checkBoxLedgeGrab.Checked, a.checkBoxEnableVcolors.Checked, a.checkBoxSolidSimps.Checked, assetType == AssetType.JSP); + return (AHDRs, + a.checkBoxOverwrite.Checked, + a.checkBoxGenSimps.Checked, + a.checkBoxLedgeGrab.Checked, + a.checkBoxEnableVcolors.Checked, + a.checkBoxSolidSimps.Checked, + assetType == AssetType.JSP, + a.checkBoxUseExistingDefaultLayer.Checked); } - return (null, false, false, false, false, false, false); + return (null, false, false, false, false, false, false, false); } private void checkBoxGenSimps_CheckedChanged(object sender, EventArgs e) { checkBoxLedgeGrab.Enabled = checkBoxGenSimps.Checked; checkBoxSolidSimps.Enabled = checkBoxGenSimps.Checked; + checkBoxUseExistingDefaultLayer.Enabled = checkBoxGenSimps.Checked; } private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) diff --git a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.resx b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.resx index 7c2f8710..2b56d6cc 100644 --- a/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.resx +++ b/IndustrialPark/ArchiveEditor/Dialogs/ImportModel.resx @@ -189,7 +189,7 @@ 6 - 295, 231 + 296, 248 92, 23 @@ -213,7 +213,7 @@ 5 - 393, 231 + 394, 248 92, 23 @@ -360,7 +360,7 @@ grpSIMP - 0 + 1 True @@ -444,7 +444,7 @@ grpSIMP - 2 + 3 True @@ -474,7 +474,7 @@ grpSIMP - 1 + 2 225, 68 @@ -500,11 +500,45 @@ 1 + + True + + + False + + + + NoControl + + + 43, 73 + + + 183, 17 + + + 18 + + + Place on existing DEFAULT layer + + + checkBoxUseExistingDefaultLayer + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + grpSIMP + + + 0 + 225, 140 - 261, 82 + 261, 102 19 @@ -531,9 +565,8 @@ 6, 13 - 497, 266 + 497, 283 - CenterScreen