diff --git a/CodeWalker.Core/GameFiles/MetaTypes/Archetype.cs b/CodeWalker.Core/GameFiles/MetaTypes/Archetype.cs index 02d51f4..5832bbb 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/Archetype.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/Archetype.cs @@ -261,6 +261,70 @@ namespace CodeWalker.GameFiles return false; } + + public void AddRoom(MCMloRoomDef room) + { + if (room == null) return; + + room.OwnerMlo = this; + room.Index = rooms?.Length ?? 0; + + var newrooms = rooms?.ToList() ?? new List(); + newrooms.Add(room); + rooms = newrooms.ToArray(); + } + public void RemoveRoom(MCMloRoomDef room) + { + if (room == null) return; + + var newrooms = rooms.ToList(); + newrooms.Remove(room); + rooms = newrooms.ToArray(); + } + + public void AddPortal(MCMloPortalDef portal) + { + if (portal == null) return; + + portal.OwnerMlo = this; + portal.Index = portals?.Length ?? 0; + + var newportals = portals?.ToList() ?? new List(); + newportals.Add(portal); + portals = newportals.ToArray(); + } + public void RemovePortal(MCMloPortalDef portal) + { + if (portal == null) return; + + var newportals = portals.ToList(); + newportals.Remove(portal); + portals = newportals.ToArray(); + } + + public void AddEntitySet(MCMloEntitySet set) + { + if (set == null) return; + + set.OwnerMlo = this; + set.Index = entitySets?.Length ?? 0; + + var newsets = entitySets?.ToList() ?? new List(); + newsets.Add(set); + entitySets = newsets.ToArray(); + } + public void RemoveEntitySet(MCMloEntitySet set) + { + if (set == null) return; + + var newsets = entitySets.ToList(); + newsets.Remove(set); + entitySets = newsets.ToArray(); + } + + + + private void FixPortalIndexes(int deletedIndex) { foreach (var portal in portals) diff --git a/CodeWalker.Core/GameFiles/MetaTypes/MetaNames.cs b/CodeWalker.Core/GameFiles/MetaTypes/MetaNames.cs index 7e6a3b5..7f99f23 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/MetaNames.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/MetaNames.cs @@ -9557,7 +9557,8 @@ namespace CodeWalker.GameFiles - + //Carl Johnson: I discovered in zonebind + specialZoneAttribute = 218662697, } diff --git a/CodeWalker.Core/GameFiles/MetaTypes/PsoTypes.cs b/CodeWalker.Core/GameFiles/MetaTypes/PsoTypes.cs index c5afda5..9417efe 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/PsoTypes.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/PsoTypes.cs @@ -13125,7 +13125,7 @@ namespace CodeWalker.GameFiles new PsoStructureEntryInfo((MetaName)1856972365, PsoDataType.Enum, 24, 0, (MetaName)1756502932), new PsoStructureEntryInfo(MetaName.lawResponseTime, PsoDataType.Enum, 28, 0, (MetaName)3204395397), new PsoStructureEntryInfo(MetaName.lawResponseType, PsoDataType.Enum, 32, 0, (MetaName)4286852891), - new PsoStructureEntryInfo((MetaName)218662697, PsoDataType.Enum, 36, 0, (MetaName)4095090001), + new PsoStructureEntryInfo(MetaName.specialZoneAttribute, PsoDataType.Enum, 36, 0, (MetaName)4095090001), new PsoStructureEntryInfo(MetaName.vehDirtMin, PsoDataType.Float, 40, 0, 0), new PsoStructureEntryInfo(MetaName.vehDirtMax, PsoDataType.Float, 44, 0, 0), new PsoStructureEntryInfo(MetaName.vehDirtGrowScale, PsoDataType.Float, 48, 0, 0), diff --git a/CodeWalker.Core/Utils/Xml.cs b/CodeWalker.Core/Utils/Xml.cs index 71e0be9..22c0d0c 100644 --- a/CodeWalker.Core/Utils/Xml.cs +++ b/CodeWalker.Core/Utils/Xml.cs @@ -87,6 +87,10 @@ namespace CodeWalker } public static T GetEnumValue(string val) where T : struct { + if (string.IsNullOrEmpty(val)) + { + return default(T); + } if (val.StartsWith("hash_")) { //convert hash_12ABC to Unk_12345 diff --git a/CodeWalker.csproj b/CodeWalker.csproj index eed92da..812acf4 100644 --- a/CodeWalker.csproj +++ b/CodeWalker.csproj @@ -140,17 +140,17 @@ - + Form - - EditYtypArchetypeMloEntSetPanel.cs + + EditYtypMloEntSetPanel.cs - + Form - - EditYtypArchetypeMloPortalPanel.cs + + EditYtypMloPortalPanel.cs @@ -416,11 +416,11 @@ EditYmapCarGenPanel.cs - + Form - - EditYtypArchetypeMloRoomPanel.cs + + EditYtypMloRoomPanel.cs Form @@ -621,11 +621,11 @@ WorldForm.cs - - EditYtypArchetypeMloEntSetPanel.cs + + EditYtypMloEntSetPanel.cs - - EditYtypArchetypeMloPortalPanel.cs + + EditYtypMloPortalPanel.cs AboutForm.cs @@ -756,8 +756,8 @@ EditYmapCarGenPanel.cs - - EditYtypArchetypeMloRoomPanel.cs + + EditYtypMloRoomPanel.cs EditYmapEntityPanel.cs diff --git a/Project/Panels/EditYtypArchetypeMloPortalPanel.Designer.cs b/Project/Panels/EditYtypArchetypeMloPortalPanel.Designer.cs deleted file mode 100644 index 41cf062..0000000 --- a/Project/Panels/EditYtypArchetypeMloPortalPanel.Designer.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace CodeWalker.Project.Panels -{ - partial class EditYtypArchetypeMloPortalPanel - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypArchetypeMloPortalPanel)); - this.SuspendLayout(); - // - // EditYtypArchetypeMloPortalPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(565, 505); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "EditYtypArchetypeMloPortalPanel"; - this.Text = "Portal"; - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/Project/Panels/EditYtypArchetypeMloPortalPanel.cs b/Project/Panels/EditYtypArchetypeMloPortalPanel.cs deleted file mode 100644 index 05af5bd..0000000 --- a/Project/Panels/EditYtypArchetypeMloPortalPanel.cs +++ /dev/null @@ -1,49 +0,0 @@ -using CodeWalker.GameFiles; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace CodeWalker.Project.Panels -{ - public partial class EditYtypArchetypeMloPortalPanel : ProjectPanel - { - public ProjectForm ProjectForm; - public MCMloPortalDef CurrentPortal { get; set; } - - public EditYtypArchetypeMloPortalPanel(ProjectForm owner) - { - ProjectForm = owner; - InitializeComponent(); - } - - public void SetPortal(MCMloPortalDef portal) - { - CurrentPortal = portal; - Tag = portal; - UpdateFormTitle(); - MloInstanceData instance = ProjectForm.TryGetMloInstance(portal?.OwnerMlo); - //ProjectForm.WorldForm?.SelectMloPortal(portal, instance); - UpdateControls(); - } - - private void UpdateControls() - { - if (CurrentPortal != null) - { - //PortalNameTextBox.Text = CurrentPortal.Name; - } - } - - private void UpdateFormTitle() - { - Text = "Portal " + (CurrentPortal?.Name ?? ""); - } - - } -} diff --git a/Project/Panels/EditYtypArchetypeMloRoomPanel.Designer.cs b/Project/Panels/EditYtypArchetypeMloRoomPanel.Designer.cs deleted file mode 100644 index 0d30f09..0000000 --- a/Project/Panels/EditYtypArchetypeMloRoomPanel.Designer.cs +++ /dev/null @@ -1,173 +0,0 @@ -namespace CodeWalker.Project.Panels -{ - partial class EditYtypArchetypeMloRoomPanel - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypArchetypeMloRoomPanel)); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.MinBoundsTextBox = new CodeWalker.WinForms.TextBoxFix(); - this.MaxBoundsTextBox = new CodeWalker.WinForms.TextBoxFix(); - this.label3 = new System.Windows.Forms.Label(); - this.RoomNameTextBox = new CodeWalker.WinForms.TextBoxFix(); - this.RoomFlagsCheckedListBox = new System.Windows.Forms.CheckedListBox(); - this.RoomFlagsTextBox = new System.Windows.Forms.TextBox(); - this.label14 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(33, 69); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(27, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Min:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(30, 95); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(30, 13); - this.label2.TabIndex = 1; - this.label2.Text = "Max:"; - // - // MinBoundsTextBox - // - this.MinBoundsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MinBoundsTextBox.Location = new System.Drawing.Point(66, 66); - this.MinBoundsTextBox.Name = "MinBoundsTextBox"; - this.MinBoundsTextBox.Size = new System.Drawing.Size(275, 20); - this.MinBoundsTextBox.TabIndex = 2; - this.MinBoundsTextBox.TextChanged += new System.EventHandler(this.MinBoundsTextBox_TextChanged); - // - // MaxBoundsTextBox - // - this.MaxBoundsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MaxBoundsTextBox.Location = new System.Drawing.Point(66, 92); - this.MaxBoundsTextBox.Name = "MaxBoundsTextBox"; - this.MaxBoundsTextBox.Size = new System.Drawing.Size(275, 20); - this.MaxBoundsTextBox.TabIndex = 3; - this.MaxBoundsTextBox.TextChanged += new System.EventHandler(this.MaxBoundsTextBox_TextChanged); - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(19, 43); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(41, 13); - this.label3.TabIndex = 4; - this.label3.Text = "Name: "; - // - // RoomNameTextBox - // - this.RoomNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.RoomNameTextBox.Location = new System.Drawing.Point(66, 40); - this.RoomNameTextBox.Name = "RoomNameTextBox"; - this.RoomNameTextBox.Size = new System.Drawing.Size(275, 20); - this.RoomNameTextBox.TabIndex = 5; - this.RoomNameTextBox.TextChanged += new System.EventHandler(this.RoomNameTextBox_TextChanged); - // - // RoomFlagsCheckedListBox - // - this.RoomFlagsCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.RoomFlagsCheckedListBox.CheckOnClick = true; - this.RoomFlagsCheckedListBox.FormattingEnabled = true; - this.RoomFlagsCheckedListBox.Items.AddRange(new object[] { - "1 - Unk01", - "2 - Unk02", - "4 - Unk03", - "8 - Unk04", - "16 - Unk05", - "32 - Unk06", - "64 - Unk07"}); - this.RoomFlagsCheckedListBox.Location = new System.Drawing.Point(352, 62); - this.RoomFlagsCheckedListBox.Name = "RoomFlagsCheckedListBox"; - this.RoomFlagsCheckedListBox.Size = new System.Drawing.Size(201, 244); - this.RoomFlagsCheckedListBox.TabIndex = 35; - this.RoomFlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.RoomFlagsCheckedListBox_ItemCheck); - // - // RoomFlagsTextBox - // - this.RoomFlagsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.RoomFlagsTextBox.Location = new System.Drawing.Point(406, 36); - this.RoomFlagsTextBox.Name = "RoomFlagsTextBox"; - this.RoomFlagsTextBox.Size = new System.Drawing.Size(147, 20); - this.RoomFlagsTextBox.TabIndex = 34; - this.RoomFlagsTextBox.TextChanged += new System.EventHandler(this.RoomFlagsTextBox_TextChanged); - // - // label14 - // - this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(365, 39); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(35, 13); - this.label14.TabIndex = 33; - this.label14.Text = "Flags:"; - // - // EditYtypArchetypeMloRoomPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(565, 505); - this.Controls.Add(this.RoomFlagsCheckedListBox); - this.Controls.Add(this.RoomFlagsTextBox); - this.Controls.Add(this.label14); - this.Controls.Add(this.RoomNameTextBox); - this.Controls.Add(this.label3); - this.Controls.Add(this.MaxBoundsTextBox); - this.Controls.Add(this.MinBoundsTextBox); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "EditYtypArchetypeMloRoomPanel"; - this.Text = "Room"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private WinForms.TextBoxFix MinBoundsTextBox; - private WinForms.TextBoxFix MaxBoundsTextBox; - private System.Windows.Forms.Label label3; - private WinForms.TextBoxFix RoomNameTextBox; - private System.Windows.Forms.CheckedListBox RoomFlagsCheckedListBox; - private System.Windows.Forms.TextBox RoomFlagsTextBox; - private System.Windows.Forms.Label label14; - } -} \ No newline at end of file diff --git a/Project/Panels/EditYtypArchetypeMloRoomPanel.cs b/Project/Panels/EditYtypArchetypeMloRoomPanel.cs deleted file mode 100644 index 2d2a5e4..0000000 --- a/Project/Panels/EditYtypArchetypeMloRoomPanel.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System; -using System.Windows.Forms; -using CodeWalker.GameFiles; -using SharpDX; - -namespace CodeWalker.Project.Panels -{ - public partial class EditYtypArchetypeMloRoomPanel : ProjectPanel - { - public ProjectForm ProjectForm; - public MCMloRoomDef CurrentRoom { get; set; } - - public EditYtypArchetypeMloRoomPanel(ProjectForm owner) - { - ProjectForm = owner; - InitializeComponent(); - } - - public void SetRoom(MCMloRoomDef room) - { - CurrentRoom = room; - Tag = room; - UpdateFormTitle(); - MloInstanceData instance = ProjectForm.TryGetMloInstance(room?.OwnerMlo); - ProjectForm.WorldForm?.SelectMloRoom(room, instance); - UpdateControls(); - } - - private void UpdateControls() - { - if (CurrentRoom != null) - { - RoomNameTextBox.Text = CurrentRoom.RoomName; - MinBoundsTextBox.Text = FloatUtil.GetVector3String(CurrentRoom.BBMin); - MaxBoundsTextBox.Text = FloatUtil.GetVector3String(CurrentRoom.BBMax); - RoomFlagsTextBox.Text = CurrentRoom._Data.flags.ToString(); - } - } - - private void UpdateFormTitle() - { - Text = CurrentRoom?.RoomName ?? "Room"; - } - - private void RoomNameTextBox_TextChanged(object sender, EventArgs e) - { - if (CurrentRoom == null) return; - - if (CurrentRoom.RoomName != RoomNameTextBox.Text) - { - CurrentRoom.RoomName = RoomNameTextBox.Text; - - TreeNode tn = ProjectForm.ProjectExplorer?.FindMloRoomTreeNode(CurrentRoom); - if (tn != null) - { - tn.Text = CurrentRoom.RoomName; - } - - UpdateFormTitle(); - ProjectForm.SetYtypHasChanged(true); - } - } - - private void MinBoundsTextBox_TextChanged(object sender, EventArgs e) - { - if (CurrentRoom == null) return; - Vector3 bb = FloatUtil.ParseVector3String(MinBoundsTextBox.Text); - if (CurrentRoom._Data.bbMin != bb) - { - CurrentRoom._Data.bbMin = bb; - ProjectForm.SetYtypHasChanged(true); - } - } - - private void MaxBoundsTextBox_TextChanged(object sender, EventArgs e) - { - if (CurrentRoom == null) return; - Vector3 bb = FloatUtil.ParseVector3String(MaxBoundsTextBox.Text); - if (CurrentRoom._Data.bbMax != bb) - { - CurrentRoom._Data.bbMax = bb; - ProjectForm.SetYtypHasChanged(true); - } - } - - private void RoomFlagsTextBox_TextChanged(object sender, EventArgs e) - { - if (CurrentRoom == null) return; - uint.TryParse(RoomFlagsTextBox.Text, out uint flags); - for (int i = 0; i < RoomFlagsCheckedListBox.Items.Count; i++) - { - var c = ((flags & (1u << i)) > 0); - RoomFlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked); - } - lock (ProjectForm.ProjectSyncRoot) - { - if (CurrentRoom._Data.flags != flags) - { - CurrentRoom._Data.flags = flags; - ProjectForm.SetYtypHasChanged(true); - } - } - } - - private void RoomFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) - { - if (CurrentRoom == null) return; - uint flags = 0; - for (int i = 0; i < RoomFlagsCheckedListBox.Items.Count; i++) - { - if (e.Index == i) - { - if (e.NewValue == CheckState.Checked) - { - flags += (uint)(1 << i); - } - } - else - { - if (RoomFlagsCheckedListBox.GetItemChecked(i)) - { - flags += (uint)(1 << i); - } - } - } - RoomFlagsTextBox.Text = flags.ToString(); - lock (ProjectForm.ProjectSyncRoot) - { - if (CurrentRoom._Data.flags != flags) - { - CurrentRoom._Data.flags = flags; - ProjectForm.SetYtypHasChanged(true); - } - } - } - } -} diff --git a/Project/Panels/EditYtypArchetypeMloEntSetPanel.Designer.cs b/Project/Panels/EditYtypMloEntSetPanel.Designer.cs similarity index 96% rename from Project/Panels/EditYtypArchetypeMloEntSetPanel.Designer.cs rename to Project/Panels/EditYtypMloEntSetPanel.Designer.cs index f5a2857..e5c7625 100644 --- a/Project/Panels/EditYtypArchetypeMloEntSetPanel.Designer.cs +++ b/Project/Panels/EditYtypMloEntSetPanel.Designer.cs @@ -1,6 +1,6 @@ namespace CodeWalker.Project.Panels { - partial class EditYtypArchetypeMloEntSetPanel + partial class EditYtypMloEntSetPanel { /// /// Required designer variable. @@ -28,17 +28,17 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypArchetypeMloEntSetPanel)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypMloEntSetPanel)); this.EntitySetNameTextBox = new CodeWalker.WinForms.TextBoxFix(); this.label3 = new System.Windows.Forms.Label(); this.ForceVisibleCheckBox = new System.Windows.Forms.CheckBox(); this.label1 = new System.Windows.Forms.Label(); this.LocationsListBox = new System.Windows.Forms.ListBox(); this.SelectedLocationGroupBox = new System.Windows.Forms.GroupBox(); - this.label2 = new System.Windows.Forms.Label(); - this.SelectedLocationEntityLabel = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); this.SelectedLocationRoomCombo = new System.Windows.Forms.ComboBox(); + this.label4 = new System.Windows.Forms.Label(); + this.SelectedLocationEntityLabel = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); this.SelectedLocationGroupBox.SuspendLayout(); this.SuspendLayout(); // @@ -46,7 +46,7 @@ // this.EntitySetNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.EntitySetNameTextBox.Location = new System.Drawing.Point(72, 40); + this.EntitySetNameTextBox.Location = new System.Drawing.Point(72, 15); this.EntitySetNameTextBox.Name = "EntitySetNameTextBox"; this.EntitySetNameTextBox.Size = new System.Drawing.Size(269, 20); this.EntitySetNameTextBox.TabIndex = 7; @@ -55,7 +55,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(19, 43); + this.label3.Location = new System.Drawing.Point(19, 18); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(41, 13); this.label3.TabIndex = 6; @@ -65,7 +65,7 @@ // this.ForceVisibleCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.ForceVisibleCheckBox.AutoSize = true; - this.ForceVisibleCheckBox.Location = new System.Drawing.Point(403, 42); + this.ForceVisibleCheckBox.Location = new System.Drawing.Point(403, 17); this.ForceVisibleCheckBox.Name = "ForceVisibleCheckBox"; this.ForceVisibleCheckBox.Size = new System.Drawing.Size(125, 17); this.ForceVisibleCheckBox.TabIndex = 8; @@ -76,7 +76,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 76); + this.label1.Location = new System.Drawing.Point(12, 51); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(56, 13); this.label1.TabIndex = 9; @@ -87,9 +87,9 @@ this.LocationsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.LocationsListBox.FormattingEnabled = true; - this.LocationsListBox.Location = new System.Drawing.Point(72, 75); + this.LocationsListBox.Location = new System.Drawing.Point(72, 50); this.LocationsListBox.Name = "LocationsListBox"; - this.LocationsListBox.Size = new System.Drawing.Size(200, 342); + this.LocationsListBox.Size = new System.Drawing.Size(200, 433); this.LocationsListBox.TabIndex = 10; this.LocationsListBox.SelectedIndexChanged += new System.EventHandler(this.LocationsListBox_SelectedIndexChanged); // @@ -101,7 +101,7 @@ this.SelectedLocationGroupBox.Controls.Add(this.label4); this.SelectedLocationGroupBox.Controls.Add(this.SelectedLocationEntityLabel); this.SelectedLocationGroupBox.Controls.Add(this.label2); - this.SelectedLocationGroupBox.Location = new System.Drawing.Point(278, 76); + this.SelectedLocationGroupBox.Location = new System.Drawing.Point(278, 51); this.SelectedLocationGroupBox.Name = "SelectedLocationGroupBox"; this.SelectedLocationGroupBox.Size = new System.Drawing.Size(275, 83); this.SelectedLocationGroupBox.TabIndex = 11; @@ -109,33 +109,6 @@ this.SelectedLocationGroupBox.Text = "Selected Location"; this.SelectedLocationGroupBox.Visible = false; // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 25); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(36, 13); - this.label2.TabIndex = 10; - this.label2.Text = "Entity:"; - // - // SelectedLocationEntityLabel - // - this.SelectedLocationEntityLabel.AutoSize = true; - this.SelectedLocationEntityLabel.Location = new System.Drawing.Point(48, 25); - this.SelectedLocationEntityLabel.Name = "SelectedLocationEntityLabel"; - this.SelectedLocationEntityLabel.Size = new System.Drawing.Size(10, 13); - this.SelectedLocationEntityLabel.TabIndex = 11; - this.SelectedLocationEntityLabel.Text = "-"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(6, 48); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(38, 13); - this.label4.TabIndex = 12; - this.label4.Text = "Room:"; - // // SelectedLocationRoomCombo // this.SelectedLocationRoomCombo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -147,7 +120,34 @@ this.SelectedLocationRoomCombo.TabIndex = 13; this.SelectedLocationRoomCombo.SelectedIndexChanged += new System.EventHandler(this.SelectedLocationRoomCombo_SelectedIndexChanged); // - // EditYtypArchetypeMloEntSetPanel + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 48); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(38, 13); + this.label4.TabIndex = 12; + this.label4.Text = "Room:"; + // + // SelectedLocationEntityLabel + // + this.SelectedLocationEntityLabel.AutoSize = true; + this.SelectedLocationEntityLabel.Location = new System.Drawing.Point(48, 25); + this.SelectedLocationEntityLabel.Name = "SelectedLocationEntityLabel"; + this.SelectedLocationEntityLabel.Size = new System.Drawing.Size(10, 13); + this.SelectedLocationEntityLabel.TabIndex = 11; + this.SelectedLocationEntityLabel.Text = "-"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 25); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(36, 13); + this.label2.TabIndex = 10; + this.label2.Text = "Entity:"; + // + // EditYtypMloEntSetPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -159,7 +159,7 @@ this.Controls.Add(this.EntitySetNameTextBox); this.Controls.Add(this.label3); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "EditYtypArchetypeMloEntSetPanel"; + this.Name = "EditYtypMloEntSetPanel"; this.Text = "Entity Set"; this.SelectedLocationGroupBox.ResumeLayout(false); this.SelectedLocationGroupBox.PerformLayout(); diff --git a/Project/Panels/EditYtypArchetypeMloEntSetPanel.cs b/Project/Panels/EditYtypMloEntSetPanel.cs similarity index 89% rename from Project/Panels/EditYtypArchetypeMloEntSetPanel.cs rename to Project/Panels/EditYtypMloEntSetPanel.cs index 6037218..a241d9f 100644 --- a/Project/Panels/EditYtypArchetypeMloEntSetPanel.cs +++ b/Project/Panels/EditYtypMloEntSetPanel.cs @@ -11,14 +11,15 @@ using System.Windows.Forms; namespace CodeWalker.Project.Panels { - public partial class EditYtypArchetypeMloEntSetPanel : ProjectPanel + public partial class EditYtypMloEntSetPanel : ProjectPanel { public ProjectForm ProjectForm; public MCMloEntitySet CurrentEntitySet { get; set; } + private bool populatingui = false; private bool SelectingLocation = false; - public EditYtypArchetypeMloEntSetPanel(ProjectForm owner) + public EditYtypMloEntSetPanel(ProjectForm owner) { ProjectForm = owner; InitializeComponent(); @@ -39,11 +40,19 @@ namespace CodeWalker.Project.Panels if (CurrentEntitySet != null) { + populatingui = true; EntitySetNameTextBox.Text = CurrentEntitySet.Name; ForceVisibleCheckBox.Checked = CurrentEntitySet.ForceVisible; - SelectedLocationGroupBox.Visible = false; UpdateSelectedLocationRoomCombo(); + populatingui = false; + } + else + { + EntitySetNameTextBox.Text = string.Empty; + ForceVisibleCheckBox.Checked = false; + SelectedLocationGroupBox.Visible = false; + SelectedLocationRoomCombo.Items.Clear(); } UpdateLocationsListBox(); @@ -51,7 +60,7 @@ namespace CodeWalker.Project.Panels private void UpdateLocationsListBox() { LocationsListBox.Items.Clear(); - if (CurrentEntitySet.Locations != null) + if (CurrentEntitySet?.Locations != null) { for (int i = 0; i < CurrentEntitySet.Locations.Length; i++) { @@ -65,7 +74,7 @@ namespace CodeWalker.Project.Panels private void UpdateSelectedLocationRoomCombo() { SelectedLocationRoomCombo.Items.Clear(); - if (CurrentEntitySet.OwnerMlo?.rooms != null) + if (CurrentEntitySet?.OwnerMlo?.rooms != null) { foreach (var room in CurrentEntitySet.OwnerMlo.rooms) { @@ -81,6 +90,7 @@ namespace CodeWalker.Project.Panels private void EntitySetNameTextBox_TextChanged(object sender, EventArgs e) { + if (populatingui) return; if (CurrentEntitySet == null) return; var str = EntitySetNameTextBox.Text; diff --git a/Project/Panels/EditYtypArchetypeMloEntSetPanel.resx b/Project/Panels/EditYtypMloEntSetPanel.resx similarity index 100% rename from Project/Panels/EditYtypArchetypeMloEntSetPanel.resx rename to Project/Panels/EditYtypMloEntSetPanel.resx diff --git a/Project/Panels/EditYtypMloPortalPanel.Designer.cs b/Project/Panels/EditYtypMloPortalPanel.Designer.cs new file mode 100644 index 0000000..2f9e54e --- /dev/null +++ b/Project/Panels/EditYtypMloPortalPanel.Designer.cs @@ -0,0 +1,244 @@ +namespace CodeWalker.Project.Panels +{ + partial class EditYtypMloPortalPanel + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypMloPortalPanel)); + this.FlagsTextBox = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.RoomFromTextBox = new System.Windows.Forms.TextBox(); + this.RoomToTextBox = new System.Windows.Forms.TextBox(); + this.MirrorPriorityTextBox = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.OpacityTextBox = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.AudioOcclusionTextBox = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.CornersTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label6 = new System.Windows.Forms.Label(); + this.FlagsCheckedListBox = new System.Windows.Forms.CheckedListBox(); + this.SuspendLayout(); + // + // FlagsTextBox + // + this.FlagsTextBox.Location = new System.Drawing.Point(107, 67); + this.FlagsTextBox.Name = "FlagsTextBox"; + this.FlagsTextBox.Size = new System.Drawing.Size(172, 20); + this.FlagsTextBox.TabIndex = 6; + this.FlagsTextBox.TextChanged += new System.EventHandler(this.FlagsTextBox_TextChanged); + // + // label14 + // + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(12, 70); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(35, 13); + this.label14.TabIndex = 5; + this.label14.Text = "Flags:"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 18); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(67, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Room From: "; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 44); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(57, 13); + this.label1.TabIndex = 3; + this.label1.Text = "Room To: "; + // + // RoomFromTextBox + // + this.RoomFromTextBox.Location = new System.Drawing.Point(107, 15); + this.RoomFromTextBox.Name = "RoomFromTextBox"; + this.RoomFromTextBox.Size = new System.Drawing.Size(172, 20); + this.RoomFromTextBox.TabIndex = 2; + this.RoomFromTextBox.TextChanged += new System.EventHandler(this.RoomFromTextBox_TextChanged); + // + // RoomToTextBox + // + this.RoomToTextBox.Location = new System.Drawing.Point(107, 41); + this.RoomToTextBox.Name = "RoomToTextBox"; + this.RoomToTextBox.Size = new System.Drawing.Size(172, 20); + this.RoomToTextBox.TabIndex = 4; + this.RoomToTextBox.TextChanged += new System.EventHandler(this.RoomToTextBox_TextChanged); + // + // MirrorPriorityTextBox + // + this.MirrorPriorityTextBox.Location = new System.Drawing.Point(107, 93); + this.MirrorPriorityTextBox.Name = "MirrorPriorityTextBox"; + this.MirrorPriorityTextBox.Size = new System.Drawing.Size(172, 20); + this.MirrorPriorityTextBox.TabIndex = 8; + this.MirrorPriorityTextBox.TextChanged += new System.EventHandler(this.MirrorPriorityTextBox_TextChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 96); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(73, 13); + this.label2.TabIndex = 7; + this.label2.Text = "Mirror Priority: "; + // + // OpacityTextBox + // + this.OpacityTextBox.Location = new System.Drawing.Point(107, 119); + this.OpacityTextBox.Name = "OpacityTextBox"; + this.OpacityTextBox.Size = new System.Drawing.Size(172, 20); + this.OpacityTextBox.TabIndex = 10; + this.OpacityTextBox.TextChanged += new System.EventHandler(this.OpacityTextBox_TextChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(12, 122); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(49, 13); + this.label4.TabIndex = 9; + this.label4.Text = "Opacity: "; + // + // AudioOcclusionTextBox + // + this.AudioOcclusionTextBox.Location = new System.Drawing.Point(107, 145); + this.AudioOcclusionTextBox.Name = "AudioOcclusionTextBox"; + this.AudioOcclusionTextBox.Size = new System.Drawing.Size(172, 20); + this.AudioOcclusionTextBox.TabIndex = 12; + this.AudioOcclusionTextBox.TextChanged += new System.EventHandler(this.AudioOcclusionTextBox_TextChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(12, 148); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(90, 13); + this.label5.TabIndex = 11; + this.label5.Text = "Audio Occlusion: "; + // + // CornersTextBox + // + this.CornersTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.CornersTextBox.Location = new System.Drawing.Point(107, 243); + this.CornersTextBox.Multiline = true; + this.CornersTextBox.Name = "CornersTextBox"; + this.CornersTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.CornersTextBox.Size = new System.Drawing.Size(336, 112); + this.CornersTextBox.TabIndex = 14; + this.CornersTextBox.WordWrap = false; + this.CornersTextBox.TextChanged += new System.EventHandler(this.CornersTextBox_TextChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(12, 246); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(49, 13); + this.label6.TabIndex = 13; + this.label6.Text = "Corners: "; + // + // FlagsCheckedListBox + // + this.FlagsCheckedListBox.CheckOnClick = true; + this.FlagsCheckedListBox.FormattingEnabled = true; + this.FlagsCheckedListBox.Items.AddRange(new object[] { + "1 - Hide from outside", + "2 - Unk02", + "4 - Mirror", + "8 - Extra bloom", + "16 - Unk05", + "32 - Unk06", + "64 - Hide when door closed", + "128 - Unk08", + "256 - Render sky light", + "512 - Unk10", + "1024 - Render exterior", + "2048 - Unk12", + "4096 - Unk13", + "8192 - Unk14"}); + this.FlagsCheckedListBox.Location = new System.Drawing.Point(318, 15); + this.FlagsCheckedListBox.Name = "FlagsCheckedListBox"; + this.FlagsCheckedListBox.Size = new System.Drawing.Size(184, 214); + this.FlagsCheckedListBox.TabIndex = 36; + this.FlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.FlagsCheckedListBox_ItemCheck); + // + // EditYtypMloPortalPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(565, 505); + this.Controls.Add(this.FlagsCheckedListBox); + this.Controls.Add(this.label6); + this.Controls.Add(this.CornersTextBox); + this.Controls.Add(this.AudioOcclusionTextBox); + this.Controls.Add(this.label5); + this.Controls.Add(this.OpacityTextBox); + this.Controls.Add(this.label4); + this.Controls.Add(this.MirrorPriorityTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.RoomToTextBox); + this.Controls.Add(this.RoomFromTextBox); + this.Controls.Add(this.label1); + this.Controls.Add(this.label3); + this.Controls.Add(this.FlagsTextBox); + this.Controls.Add(this.label14); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "EditYtypMloPortalPanel"; + this.Text = "Portal"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox FlagsTextBox; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox RoomFromTextBox; + private System.Windows.Forms.TextBox RoomToTextBox; + private System.Windows.Forms.TextBox MirrorPriorityTextBox; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox OpacityTextBox; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox AudioOcclusionTextBox; + private System.Windows.Forms.Label label5; + private WinForms.TextBoxFix CornersTextBox; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.CheckedListBox FlagsCheckedListBox; + } +} \ No newline at end of file diff --git a/Project/Panels/EditYtypMloPortalPanel.cs b/Project/Panels/EditYtypMloPortalPanel.cs new file mode 100644 index 0000000..325a2d1 --- /dev/null +++ b/Project/Panels/EditYtypMloPortalPanel.cs @@ -0,0 +1,256 @@ +using CodeWalker.GameFiles; +using SharpDX; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CodeWalker.Project.Panels +{ + public partial class EditYtypMloPortalPanel : ProjectPanel + { + public ProjectForm ProjectForm; + public MCMloPortalDef CurrentPortal { get; set; } + + private bool populatingui = false; + + public EditYtypMloPortalPanel(ProjectForm owner) + { + ProjectForm = owner; + InitializeComponent(); + } + + public void SetPortal(MCMloPortalDef portal) + { + CurrentPortal = portal; + Tag = portal; + UpdateFormTitle(); + MloInstanceData instance = ProjectForm.TryGetMloInstance(portal?.OwnerMlo); + //ProjectForm.WorldForm?.SelectMloPortal(portal, instance); + UpdateControls(); + } + + private void UpdateControls() + { + if (CurrentPortal != null) + { + populatingui = true; + RoomFromTextBox.Text = CurrentPortal._Data.roomFrom.ToString(); + RoomToTextBox.Text = CurrentPortal._Data.roomTo.ToString(); + FlagsTextBox.Text = CurrentPortal._Data.flags.ToString(); + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + var c = ((CurrentPortal._Data.flags & (1u << i)) > 0); + FlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked); + } + MirrorPriorityTextBox.Text = CurrentPortal._Data.mirrorPriority.ToString(); + OpacityTextBox.Text = CurrentPortal._Data.opacity.ToString(); + AudioOcclusionTextBox.Text = CurrentPortal._Data.audioOcclusion.ToString(); + + var sb = new StringBuilder(); + if (CurrentPortal.Corners != null) + { + foreach (var corner in CurrentPortal.Corners) + { + if (sb.Length > 0) sb.AppendLine(); + sb.Append(FloatUtil.GetVector3String(corner.XYZ())); + } + } + CornersTextBox.Text = sb.ToString(); + populatingui = false; + } + else + { + RoomFromTextBox.Text = string.Empty; + RoomToTextBox.Text = string.Empty; + FlagsTextBox.Text = string.Empty; + MirrorPriorityTextBox.Text = string.Empty; + OpacityTextBox.Text = string.Empty; + AudioOcclusionTextBox.Text = string.Empty; + CornersTextBox.Text = string.Empty; + } + } + + private void UpdateFormTitle() + { + Text = "Portal " + (CurrentPortal?.Name ?? ""); + } + + private void UpdateProjectExplorer() + { + TreeNode tn = ProjectForm.ProjectExplorer?.FindMloPortalTreeNode(CurrentPortal); + if (tn != null) + { + tn.Text = CurrentPortal.Name; + } + } + + + private void RoomFromTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(RoomFromTextBox.Text, out u); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.roomFrom != u) + { + CurrentPortal._Data.roomFrom = u; + ProjectForm.SetYtypHasChanged(true); + } + } + + UpdateFormTitle(); + UpdateProjectExplorer(); + } + + private void RoomToTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(RoomToTextBox.Text, out u); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.roomTo != u) + { + CurrentPortal._Data.roomTo = u; + ProjectForm.SetYtypHasChanged(true); + } + } + + UpdateFormTitle(); + UpdateProjectExplorer(); + } + + private void FlagsTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(FlagsTextBox.Text, out u); + + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + var c = ((u & (1u << i)) > 0); + FlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked); + } + + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.flags != u) + { + CurrentPortal._Data.flags = u; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void FlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint flags = 0; + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + if (e.Index == i) + { + if (e.NewValue == CheckState.Checked) + { + flags += (uint)(1 << i); + } + } + else + { + if (FlagsCheckedListBox.GetItemChecked(i)) + { + flags += (uint)(1 << i); + } + } + } + FlagsTextBox.Text = flags.ToString(); + } + + private void MirrorPriorityTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(MirrorPriorityTextBox.Text, out u); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.mirrorPriority != u) + { + CurrentPortal._Data.mirrorPriority = u; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void OpacityTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(OpacityTextBox.Text, out u); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.opacity != u) + { + CurrentPortal._Data.opacity = u; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void AudioOcclusionTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + uint u = 0; + uint.TryParse(AudioOcclusionTextBox.Text, out u); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentPortal._Data.audioOcclusion != u) + { + CurrentPortal._Data.audioOcclusion = u; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void CornersTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentPortal == null) return; + + var corners = new List(); + var strs = CornersTextBox.Text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); + foreach (var str in strs) + { + var tstr = str.Trim(); + if (string.IsNullOrEmpty(tstr)) continue; + var c = FloatUtil.ParseVector3String(tstr); + corners.Add(new Vector4(c, float.NaN)); + } + lock (ProjectForm.ProjectSyncRoot) + { + CurrentPortal.Corners = corners.ToArray(); + ProjectForm.SetYtypHasChanged(true); + } + } + } +} diff --git a/Project/Panels/EditYtypArchetypeMloPortalPanel.resx b/Project/Panels/EditYtypMloPortalPanel.resx similarity index 100% rename from Project/Panels/EditYtypArchetypeMloPortalPanel.resx rename to Project/Panels/EditYtypMloPortalPanel.resx diff --git a/Project/Panels/EditYtypMloRoomPanel.Designer.cs b/Project/Panels/EditYtypMloRoomPanel.Designer.cs new file mode 100644 index 0000000..7915d8a --- /dev/null +++ b/Project/Panels/EditYtypMloRoomPanel.Designer.cs @@ -0,0 +1,325 @@ +namespace CodeWalker.Project.Panels +{ + partial class EditYtypMloRoomPanel + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditYtypMloRoomPanel)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.MinBoundsTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.MaxBoundsTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label3 = new System.Windows.Forms.Label(); + this.NameTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.FlagsCheckedListBox = new System.Windows.Forms.CheckedListBox(); + this.FlagsTextBox = new System.Windows.Forms.TextBox(); + this.label14 = new System.Windows.Forms.Label(); + this.BlendTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label4 = new System.Windows.Forms.Label(); + this.TimecycleTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label5 = new System.Windows.Forms.Label(); + this.Timecycle2TextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label6 = new System.Windows.Forms.Label(); + this.PortalCountTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label7 = new System.Windows.Forms.Label(); + this.FloorIDTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label8 = new System.Windows.Forms.Label(); + this.ExteriorVisDepthTextBox = new CodeWalker.WinForms.TextBoxFix(); + this.label9 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(60, 44); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 13); + this.label1.TabIndex = 0; + this.label1.Text = "BB Min:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(57, 70); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(47, 13); + this.label2.TabIndex = 1; + this.label2.Text = "BB Max:"; + // + // MinBoundsTextBox + // + this.MinBoundsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MinBoundsTextBox.Location = new System.Drawing.Point(110, 41); + this.MinBoundsTextBox.Name = "MinBoundsTextBox"; + this.MinBoundsTextBox.Size = new System.Drawing.Size(231, 20); + this.MinBoundsTextBox.TabIndex = 2; + this.MinBoundsTextBox.TextChanged += new System.EventHandler(this.MinBoundsTextBox_TextChanged); + // + // MaxBoundsTextBox + // + this.MaxBoundsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MaxBoundsTextBox.Location = new System.Drawing.Point(110, 67); + this.MaxBoundsTextBox.Name = "MaxBoundsTextBox"; + this.MaxBoundsTextBox.Size = new System.Drawing.Size(231, 20); + this.MaxBoundsTextBox.TabIndex = 3; + this.MaxBoundsTextBox.TextChanged += new System.EventHandler(this.MaxBoundsTextBox_TextChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(63, 18); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(41, 13); + this.label3.TabIndex = 4; + this.label3.Text = "Name: "; + // + // NameTextBox + // + this.NameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.NameTextBox.Location = new System.Drawing.Point(110, 15); + this.NameTextBox.Name = "NameTextBox"; + this.NameTextBox.Size = new System.Drawing.Size(231, 20); + this.NameTextBox.TabIndex = 5; + this.NameTextBox.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged); + // + // FlagsCheckedListBox + // + this.FlagsCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.FlagsCheckedListBox.CheckOnClick = true; + this.FlagsCheckedListBox.FormattingEnabled = true; + this.FlagsCheckedListBox.Items.AddRange(new object[] { + "1 - Unk01", + "2 - Unk02", + "4 - Unk03", + "8 - Unk04", + "16 - Unk05", + "32 - Unk06", + "64 - Unk07", + "128 - Unk08", + "256 - Unk09", + "512 - Unk10"}); + this.FlagsCheckedListBox.Location = new System.Drawing.Point(352, 41); + this.FlagsCheckedListBox.Name = "FlagsCheckedListBox"; + this.FlagsCheckedListBox.Size = new System.Drawing.Size(201, 154); + this.FlagsCheckedListBox.TabIndex = 35; + this.FlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.FlagsCheckedListBox_ItemCheck); + // + // FlagsTextBox + // + this.FlagsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.FlagsTextBox.Location = new System.Drawing.Point(406, 15); + this.FlagsTextBox.Name = "FlagsTextBox"; + this.FlagsTextBox.Size = new System.Drawing.Size(147, 20); + this.FlagsTextBox.TabIndex = 34; + this.FlagsTextBox.TextChanged += new System.EventHandler(this.FlagsTextBox_TextChanged); + // + // label14 + // + this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label14.AutoSize = true; + this.label14.Location = new System.Drawing.Point(365, 18); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(35, 13); + this.label14.TabIndex = 33; + this.label14.Text = "Flags:"; + // + // BlendTextBox + // + this.BlendTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.BlendTextBox.Location = new System.Drawing.Point(110, 93); + this.BlendTextBox.Name = "BlendTextBox"; + this.BlendTextBox.Size = new System.Drawing.Size(231, 20); + this.BlendTextBox.TabIndex = 37; + this.BlendTextBox.TextChanged += new System.EventHandler(this.BlendTextBox_TextChanged); + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(67, 96); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(37, 13); + this.label4.TabIndex = 36; + this.label4.Text = "Blend:"; + // + // TimecycleTextBox + // + this.TimecycleTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.TimecycleTextBox.Location = new System.Drawing.Point(110, 119); + this.TimecycleTextBox.Name = "TimecycleTextBox"; + this.TimecycleTextBox.Size = new System.Drawing.Size(231, 20); + this.TimecycleTextBox.TabIndex = 39; + this.TimecycleTextBox.TextChanged += new System.EventHandler(this.TimecycleTextBox_TextChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(46, 122); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(58, 13); + this.label5.TabIndex = 38; + this.label5.Text = "Timecycle:"; + // + // Timecycle2TextBox + // + this.Timecycle2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Timecycle2TextBox.Location = new System.Drawing.Point(110, 145); + this.Timecycle2TextBox.Name = "Timecycle2TextBox"; + this.Timecycle2TextBox.Size = new System.Drawing.Size(231, 20); + this.Timecycle2TextBox.TabIndex = 41; + this.Timecycle2TextBox.TextChanged += new System.EventHandler(this.Timecycle2TextBox_TextChanged); + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(37, 148); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(67, 13); + this.label6.TabIndex = 40; + this.label6.Text = "Timecycle 2:"; + // + // PortalCountTextBox + // + this.PortalCountTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.PortalCountTextBox.Location = new System.Drawing.Point(110, 171); + this.PortalCountTextBox.Name = "PortalCountTextBox"; + this.PortalCountTextBox.Size = new System.Drawing.Size(231, 20); + this.PortalCountTextBox.TabIndex = 43; + this.PortalCountTextBox.TextChanged += new System.EventHandler(this.PortalCountTextBox_TextChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(36, 174); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(68, 13); + this.label7.TabIndex = 42; + this.label7.Text = "Portal Count:"; + // + // FloorIDTextBox + // + this.FloorIDTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.FloorIDTextBox.Location = new System.Drawing.Point(110, 197); + this.FloorIDTextBox.Name = "FloorIDTextBox"; + this.FloorIDTextBox.Size = new System.Drawing.Size(231, 20); + this.FloorIDTextBox.TabIndex = 45; + this.FloorIDTextBox.TextChanged += new System.EventHandler(this.FloorIDTextBox_TextChanged); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(57, 200); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(47, 13); + this.label8.TabIndex = 44; + this.label8.Text = "Floor ID:"; + // + // ExteriorVisDepthTextBox + // + this.ExteriorVisDepthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ExteriorVisDepthTextBox.Location = new System.Drawing.Point(110, 223); + this.ExteriorVisDepthTextBox.Name = "ExteriorVisDepthTextBox"; + this.ExteriorVisDepthTextBox.Size = new System.Drawing.Size(231, 20); + this.ExteriorVisDepthTextBox.TabIndex = 47; + this.ExteriorVisDepthTextBox.TextChanged += new System.EventHandler(this.ExteriorVisDepthTextBox_TextChanged); + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(10, 226); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(94, 13); + this.label9.TabIndex = 46; + this.label9.Text = "Exterior Vis Depth:"; + // + // EditYtypMloRoomPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(565, 505); + this.Controls.Add(this.ExteriorVisDepthTextBox); + this.Controls.Add(this.label9); + this.Controls.Add(this.FloorIDTextBox); + this.Controls.Add(this.label8); + this.Controls.Add(this.PortalCountTextBox); + this.Controls.Add(this.label7); + this.Controls.Add(this.Timecycle2TextBox); + this.Controls.Add(this.label6); + this.Controls.Add(this.TimecycleTextBox); + this.Controls.Add(this.label5); + this.Controls.Add(this.BlendTextBox); + this.Controls.Add(this.label4); + this.Controls.Add(this.FlagsCheckedListBox); + this.Controls.Add(this.FlagsTextBox); + this.Controls.Add(this.label14); + this.Controls.Add(this.NameTextBox); + this.Controls.Add(this.label3); + this.Controls.Add(this.MaxBoundsTextBox); + this.Controls.Add(this.MinBoundsTextBox); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "EditYtypMloRoomPanel"; + this.Text = "Room"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private WinForms.TextBoxFix MinBoundsTextBox; + private WinForms.TextBoxFix MaxBoundsTextBox; + private System.Windows.Forms.Label label3; + private WinForms.TextBoxFix NameTextBox; + private System.Windows.Forms.CheckedListBox FlagsCheckedListBox; + private System.Windows.Forms.TextBox FlagsTextBox; + private System.Windows.Forms.Label label14; + private WinForms.TextBoxFix BlendTextBox; + private System.Windows.Forms.Label label4; + private WinForms.TextBoxFix TimecycleTextBox; + private System.Windows.Forms.Label label5; + private WinForms.TextBoxFix Timecycle2TextBox; + private System.Windows.Forms.Label label6; + private WinForms.TextBoxFix PortalCountTextBox; + private System.Windows.Forms.Label label7; + private WinForms.TextBoxFix FloorIDTextBox; + private System.Windows.Forms.Label label8; + private WinForms.TextBoxFix ExteriorVisDepthTextBox; + private System.Windows.Forms.Label label9; + } +} \ No newline at end of file diff --git a/Project/Panels/EditYtypMloRoomPanel.cs b/Project/Panels/EditYtypMloRoomPanel.cs new file mode 100644 index 0000000..32674ed --- /dev/null +++ b/Project/Panels/EditYtypMloRoomPanel.cs @@ -0,0 +1,266 @@ +using System; +using System.Windows.Forms; +using CodeWalker.GameFiles; +using SharpDX; + +namespace CodeWalker.Project.Panels +{ + public partial class EditYtypMloRoomPanel : ProjectPanel + { + public ProjectForm ProjectForm; + public MCMloRoomDef CurrentRoom { get; set; } + + private bool populatingui = false; + + public EditYtypMloRoomPanel(ProjectForm owner) + { + ProjectForm = owner; + InitializeComponent(); + } + + public void SetRoom(MCMloRoomDef room) + { + CurrentRoom = room; + Tag = room; + UpdateFormTitle(); + MloInstanceData instance = ProjectForm.TryGetMloInstance(room?.OwnerMlo); + ProjectForm.WorldForm?.SelectMloRoom(room, instance); + UpdateControls(); + } + + private void UpdateControls() + { + if (CurrentRoom != null) + { + populatingui = true; + NameTextBox.Text = CurrentRoom.RoomName; + MinBoundsTextBox.Text = FloatUtil.GetVector3String(CurrentRoom.BBMin); + MaxBoundsTextBox.Text = FloatUtil.GetVector3String(CurrentRoom.BBMax); + FlagsTextBox.Text = CurrentRoom._Data.flags.ToString(); + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + var c = ((CurrentRoom._Data.flags & (1u << i)) > 0); + FlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked); + } + BlendTextBox.Text = FloatUtil.ToString(CurrentRoom._Data.blend); + TimecycleTextBox.Text = CurrentRoom._Data.timecycleName.ToCleanString(); + Timecycle2TextBox.Text = CurrentRoom._Data.secondaryTimecycleName.ToCleanString(); + PortalCountTextBox.Text = CurrentRoom._Data.portalCount.ToString(); + FloorIDTextBox.Text = CurrentRoom._Data.floorId.ToString(); + ExteriorVisDepthTextBox.Text = CurrentRoom._Data.exteriorVisibiltyDepth.ToString(); + populatingui = false; + } + else + { + NameTextBox.Text = string.Empty; + MinBoundsTextBox.Text = string.Empty; + MaxBoundsTextBox.Text = string.Empty; + FlagsTextBox.Text = string.Empty; + BlendTextBox.Text = string.Empty; + TimecycleTextBox.Text = string.Empty; + Timecycle2TextBox.Text = string.Empty; + PortalCountTextBox.Text = string.Empty; + FloorIDTextBox.Text = string.Empty; + ExteriorVisDepthTextBox.Text = string.Empty; + } + } + + private void UpdateFormTitle() + { + Text = CurrentRoom?.RoomName ?? "Room"; + } + + private void NameTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + if (CurrentRoom.RoomName != NameTextBox.Text) + { + CurrentRoom.RoomName = NameTextBox.Text; + + TreeNode tn = ProjectForm.ProjectExplorer?.FindMloRoomTreeNode(CurrentRoom); + if (tn != null) + { + tn.Text = CurrentRoom.RoomName; + } + + UpdateFormTitle(); + ProjectForm.SetYtypHasChanged(true); + } + } + + private void MinBoundsTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + Vector3 bb = FloatUtil.ParseVector3String(MinBoundsTextBox.Text); + if (CurrentRoom._Data.bbMin != bb) + { + CurrentRoom._Data.bbMin = bb; + CurrentRoom.BBMin_CW = bb; + ProjectForm.SetYtypHasChanged(true); + } + } + + private void MaxBoundsTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + Vector3 bb = FloatUtil.ParseVector3String(MaxBoundsTextBox.Text); + if (CurrentRoom._Data.bbMax != bb) + { + CurrentRoom._Data.bbMax = bb; + CurrentRoom.BBMax_CW = bb; + ProjectForm.SetYtypHasChanged(true); + } + } + + private void FlagsTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + uint.TryParse(FlagsTextBox.Text, out uint flags); + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + var c = ((flags & (1u << i)) > 0); + FlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked); + } + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.flags != flags) + { + CurrentRoom._Data.flags = flags; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void FlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + uint flags = 0; + for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++) + { + if (e.Index == i) + { + if (e.NewValue == CheckState.Checked) + { + flags += (uint)(1 << i); + } + } + else + { + if (FlagsCheckedListBox.GetItemChecked(i)) + { + flags += (uint)(1 << i); + } + } + } + FlagsTextBox.Text = flags.ToString(); + } + + private void BlendTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + FloatUtil.TryParse(BlendTextBox.Text, out float blend); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.blend != blend) + { + CurrentRoom._Data.blend = blend; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void TimecycleTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + var hash = JenkHash.GenHash(TimecycleTextBox.Text); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.timecycleName != hash) + { + CurrentRoom._Data.timecycleName = hash; + ProjectForm.SetYtypHasChanged(true); + JenkIndex.Ensure(TimecycleTextBox.Text); + } + } + } + + private void Timecycle2TextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + var hash = JenkHash.GenHash(Timecycle2TextBox.Text); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.secondaryTimecycleName != hash) + { + CurrentRoom._Data.secondaryTimecycleName = hash; + ProjectForm.SetYtypHasChanged(true); + JenkIndex.Ensure(Timecycle2TextBox.Text); + } + } + } + + private void PortalCountTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + uint.TryParse(PortalCountTextBox.Text, out uint count); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.portalCount != count) + { + CurrentRoom._Data.portalCount = count; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void FloorIDTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + int.TryParse(FloorIDTextBox.Text, out int floor); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.floorId != floor) + { + CurrentRoom._Data.floorId = floor; + ProjectForm.SetYtypHasChanged(true); + } + } + } + + private void ExteriorVisDepthTextBox_TextChanged(object sender, EventArgs e) + { + if (populatingui) return; + if (CurrentRoom == null) return; + + int.TryParse(ExteriorVisDepthTextBox.Text, out int depth); + lock (ProjectForm.ProjectSyncRoot) + { + if (CurrentRoom._Data.exteriorVisibiltyDepth != depth) + { + CurrentRoom._Data.exteriorVisibiltyDepth = depth; + ProjectForm.SetYtypHasChanged(true); + } + } + } + } +} diff --git a/Project/Panels/EditYtypArchetypeMloRoomPanel.resx b/Project/Panels/EditYtypMloRoomPanel.resx similarity index 100% rename from Project/Panels/EditYtypArchetypeMloRoomPanel.resx rename to Project/Panels/EditYtypMloRoomPanel.resx diff --git a/Project/Panels/ProjectExplorerPanel.cs b/Project/Panels/ProjectExplorerPanel.cs index d54a400..f963f64 100644 --- a/Project/Panels/ProjectExplorerPanel.cs +++ b/Project/Panels/ProjectExplorerPanel.cs @@ -1340,6 +1340,36 @@ namespace CodeWalker.Project.Panels } } } + public void TrySelectMloPortalTreeNode(MCMloPortalDef portal) + { + TreeNode portalnode = FindMloPortalTreeNode(portal); + if (portalnode != null) + { + if (ProjectTreeView.SelectedNode == portalnode) + { + OnItemSelected?.Invoke(portal); + } + else + { + ProjectTreeView.SelectedNode = portalnode; + } + } + } + public void TrySelectMloEntitySetTreeNode(MCMloEntitySet set) + { + TreeNode setnode = FindMloEntitySetTreeNode(set); + if (setnode != null) + { + if (ProjectTreeView.SelectedNode == setnode) + { + OnItemSelected?.Invoke(set); + } + else + { + ProjectTreeView.SelectedNode = setnode; + } + } + } public void TrySelectArchetypeTreeNode(Archetype archetype) { TreeNode archetypenode = FindArchetypeTreeNode(archetype); diff --git a/Project/ProjectForm.Designer.cs b/Project/ProjectForm.Designer.cs index f96e4f9..83454d4 100644 --- a/Project/ProjectForm.Designer.cs +++ b/Project/ProjectForm.Designer.cs @@ -173,6 +173,9 @@ this.ToolbarSaveButton = new System.Windows.Forms.ToolStripButton(); this.ToolbarSaveAllButton = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.YtypMloNewRoomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.YtypMloNewPortalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.YtypMloNewEntitySetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainMenu.SuspendLayout(); this.MainToolbar.SuspendLayout(); this.SuspendLayout(); @@ -508,14 +511,14 @@ // ViewProjectExplorerMenu // this.ViewProjectExplorerMenu.Name = "ViewProjectExplorerMenu"; - this.ViewProjectExplorerMenu.Size = new System.Drawing.Size(156, 22); + this.ViewProjectExplorerMenu.Size = new System.Drawing.Size(157, 22); this.ViewProjectExplorerMenu.Text = "Project Explorer"; this.ViewProjectExplorerMenu.Click += new System.EventHandler(this.ViewProjectExplorerMenu_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(153, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(154, 6); // // ViewThemeMenu // @@ -524,7 +527,7 @@ this.ViewThemeLightMenu, this.ViewThemeDarkMenu}); this.ViewThemeMenu.Name = "ViewThemeMenu"; - this.ViewThemeMenu.Size = new System.Drawing.Size(156, 22); + this.ViewThemeMenu.Size = new System.Drawing.Size(157, 22); this.ViewThemeMenu.Text = "Theme"; // // ViewThemeBlueMenu @@ -661,7 +664,10 @@ // YtypMloToolStripMenuItem // this.YtypMloToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.YtypMloNewEntityToolStripMenuItem}); + this.YtypMloNewEntityToolStripMenuItem, + this.YtypMloNewRoomToolStripMenuItem, + this.YtypMloNewPortalToolStripMenuItem, + this.YtypMloNewEntitySetToolStripMenuItem}); this.YtypMloToolStripMenuItem.Enabled = false; this.YtypMloToolStripMenuItem.Name = "YtypMloToolStripMenuItem"; this.YtypMloToolStripMenuItem.Size = new System.Drawing.Size(192, 22); @@ -670,7 +676,7 @@ // YtypMloNewEntityToolStripMenuItem // this.YtypMloNewEntityToolStripMenuItem.Name = "YtypMloNewEntityToolStripMenuItem"; - this.YtypMloNewEntityToolStripMenuItem.Size = new System.Drawing.Size(131, 22); + this.YtypMloNewEntityToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.YtypMloNewEntityToolStripMenuItem.Text = "New Entity"; this.YtypMloNewEntityToolStripMenuItem.Click += new System.EventHandler(this.YtypMloNewEntityToolStripMenuItem_Click); // @@ -815,7 +821,7 @@ this.TrainsAddToProjectMenu, this.TrainsRemoveFromProjectMenu}); this.TrainsMenu.Name = "TrainsMenu"; - this.TrainsMenu.Size = new System.Drawing.Size(50, 20); + this.TrainsMenu.Size = new System.Drawing.Size(49, 20); this.TrainsMenu.Text = "Trains"; this.TrainsMenu.Visible = false; // @@ -1069,7 +1075,7 @@ this.toolStripSeparator2, this.ToolsImportMenyooXmlMenu}); this.ToolsMenu.Name = "ToolsMenu"; - this.ToolsMenu.Size = new System.Drawing.Size(47, 20); + this.ToolsMenu.Size = new System.Drawing.Size(46, 20); this.ToolsMenu.Text = "Tools"; // // ToolsManifestGeneratorMenu @@ -1342,6 +1348,27 @@ this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); // + // YtypMloNewRoomToolStripMenuItem + // + this.YtypMloNewRoomToolStripMenuItem.Name = "YtypMloNewRoomToolStripMenuItem"; + this.YtypMloNewRoomToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.YtypMloNewRoomToolStripMenuItem.Text = "New Room"; + this.YtypMloNewRoomToolStripMenuItem.Click += new System.EventHandler(this.YtypMloNewRoomToolStripMenuItem_Click); + // + // YtypMloNewPortalToolStripMenuItem + // + this.YtypMloNewPortalToolStripMenuItem.Name = "YtypMloNewPortalToolStripMenuItem"; + this.YtypMloNewPortalToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.YtypMloNewPortalToolStripMenuItem.Text = "New Portal"; + this.YtypMloNewPortalToolStripMenuItem.Click += new System.EventHandler(this.YtypMloNewPortalToolStripMenuItem_Click); + // + // YtypMloNewEntitySetToolStripMenuItem + // + this.YtypMloNewEntitySetToolStripMenuItem.Name = "YtypMloNewEntitySetToolStripMenuItem"; + this.YtypMloNewEntitySetToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.YtypMloNewEntitySetToolStripMenuItem.Text = "New Entity Set"; + this.YtypMloNewEntitySetToolStripMenuItem.Click += new System.EventHandler(this.YtypMloNewEntitySetToolStripMenuItem_Click); + // // ProjectForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1511,5 +1538,8 @@ private System.Windows.Forms.ToolStripMenuItem AudioNewInteriorMenu; private System.Windows.Forms.ToolStripMenuItem AudioNewInteriorRoomMenu; private System.Windows.Forms.ToolStripMenuItem ToolsLODLightsGeneratorMenu; + private System.Windows.Forms.ToolStripMenuItem YtypMloNewRoomToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem YtypMloNewPortalToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem YtypMloNewEntitySetToolStripMenuItem; } } \ No newline at end of file diff --git a/Project/ProjectForm.cs b/Project/ProjectForm.cs index df608d3..d163748 100644 --- a/Project/ProjectForm.cs +++ b/Project/ProjectForm.cs @@ -457,24 +457,24 @@ namespace CodeWalker.Project (panel) => { panel.SetScenarioNode(CurrentScenarioNode); }, //updateFunc (panel) => { return panel.CurrentScenarioNode == CurrentScenarioNode; }); //findFunc } - public void ShowEditYtypArchetypeMloRoomPanel(bool promote) + public void ShowEditYtypMloRoomPanel(bool promote) { ShowPanel(promote, - () => { return new EditYtypArchetypeMloRoomPanel(this); }, //createFunc + () => { return new EditYtypMloRoomPanel(this); }, //createFunc (panel) => { panel.SetRoom(CurrentMloRoom); }, //updateFunc (panel) => { return panel.CurrentRoom == CurrentMloRoom; }); //findFunc } - public void ShowEditYtypArchetypeMloPortalPanel(bool promote) + public void ShowEditYtypMloPortalPanel(bool promote) { ShowPanel(promote, - () => { return new EditYtypArchetypeMloPortalPanel(this); }, //createFunc + () => { return new EditYtypMloPortalPanel(this); }, //createFunc (panel) => { panel.SetPortal(CurrentMloPortal); }, //updateFunc (panel) => { return panel.CurrentPortal == CurrentMloPortal; }); //findFunc } - public void ShowEditYtypArchetypeMloEntSetPanel(bool promote) + public void ShowEditYtypMloEntSetPanel(bool promote) { ShowPanel(promote, - () => { return new EditYtypArchetypeMloEntSetPanel(this); }, //createFunc + () => { return new EditYtypMloEntSetPanel(this); }, //createFunc (panel) => { panel.SetEntitySet(CurrentMloEntitySet); }, //updateFunc (panel) => { return panel.CurrentEntitySet == CurrentMloEntitySet; }); //findFunc } @@ -536,15 +536,15 @@ namespace CodeWalker.Project } else if (CurrentMloRoom != null) { - ShowEditYtypArchetypeMloRoomPanel(promote); + ShowEditYtypMloRoomPanel(promote); } else if (CurrentMloPortal != null) { - ShowEditYtypArchetypeMloPortalPanel(promote); + ShowEditYtypMloPortalPanel(promote); } else if (CurrentMloEntitySet != null) { - ShowEditYtypArchetypeMloEntSetPanel(promote); + ShowEditYtypMloEntSetPanel(promote); } else if (CurrentEntity != null) { @@ -733,6 +733,18 @@ namespace CodeWalker.Project { CurrentYmapFile = CurrentGrassBatch.Ymap; } + if (CurrentMloRoom != null) + { + CurrentArchetype = CurrentMloRoom.OwnerMlo; + } + if (CurrentMloPortal != null) + { + CurrentArchetype = CurrentMloPortal.OwnerMlo; + } + if (CurrentMloEntitySet != null) + { + CurrentArchetype = CurrentMloEntitySet.OwnerMlo; + } if (CurrentArchetype != null) { CurrentYtypFile = CurrentEntity?.MloParent?.Archetype?.Ytyp ?? CurrentArchetype?.Ytyp; @@ -2315,7 +2327,7 @@ namespace CodeWalker.Project { if ((CurrentArchetype == null) || !(CurrentArchetype is MloArchetype mloArch)) { - var arch = CurrentEntity?.MloParent.Archetype ?? CurrentMloRoom?.OwnerMlo; + var arch = CurrentEntity?.MloParent.Archetype ?? CurrentMloRoom?.OwnerMlo ?? CurrentMloPortal?.OwnerMlo ?? CurrentMloEntitySet?.OwnerMlo; if (arch == null) return; @@ -2428,6 +2440,93 @@ namespace CodeWalker.Project CurrentEntity = outEnt; CurrentYtypFile = CurrentEntity.MloParent?.Archetype?.Ytyp; } + public void NewMloRoom(MCMloRoomDef copy = null) + { + var mlo = CurrentMloRoom?.OwnerMlo ?? CurrentMloPortal?.OwnerMlo ?? CurrentMloEntitySet?.OwnerMlo ?? (CurrentEntity?.MloParent.Archetype as MloArchetype); + if (mlo == null) return; + + if (copy == null) + { + copy = CurrentMloRoom; + } + + var room = new MCMloRoomDef(); + if (copy != null) + { + room._Data = copy._Data; + room.RoomName = copy.RoomName; + } + else + { + room._Data.flags = 96; + room._Data.blend = 1.0f; + room._Data.exteriorVisibiltyDepth = -1; + room.RoomName = "NewRoom"; + } + + mlo.AddRoom(room); + + LoadProjectTree(); + ProjectExplorer?.TrySelectMloRoomTreeNode(room); + CurrentMloRoom = room; + CurrentYtypFile = room?.OwnerMlo?.Ytyp; + } + public void NewMloPortal(MCMloPortalDef copy = null) + { + var mlo = CurrentMloRoom?.OwnerMlo ?? CurrentMloPortal?.OwnerMlo ?? CurrentMloEntitySet?.OwnerMlo ?? (CurrentEntity?.MloParent.Archetype as MloArchetype); + if (mlo == null) return; + + if (copy == null) + { + copy = CurrentMloPortal; + } + + var portal = new MCMloPortalDef(); + if (copy != null) + { + portal._Data = copy._Data; + portal.Corners = (Vector4[])copy.Corners.Clone(); + } + else + { + portal._Data.roomFrom = 1; + portal._Data.roomTo = 0; + } + + mlo.AddPortal(portal); + + LoadProjectTree(); + ProjectExplorer?.TrySelectMloPortalTreeNode(portal); + CurrentMloPortal = portal; + CurrentYtypFile = portal?.OwnerMlo?.Ytyp; + } + public void NewMloEntitySet(MCMloEntitySet copy = null) + { + var mlo = CurrentMloRoom?.OwnerMlo ?? CurrentMloPortal?.OwnerMlo ?? CurrentMloEntitySet?.OwnerMlo ?? (CurrentEntity?.MloParent.Archetype as MloArchetype); + if (mlo == null) return; + + if (copy == null) + { + copy = CurrentMloEntitySet; + } + + var set = new MCMloEntitySet(); + if (copy != null) + { + set._Data.name = copy._Data.name; + } + else + { + + } + + mlo.AddEntitySet(set); + + LoadProjectTree(); + ProjectExplorer?.TrySelectMloEntitySetTreeNode(set); + CurrentMloEntitySet = set; + CurrentYtypFile = set?.OwnerMlo?.Ytyp; + } private bool DeleteMloArchetypeEntity() { if (CurrentEntity?.MloParent?.Archetype?.Ytyp == null) return false; @@ -6849,6 +6948,18 @@ namespace CodeWalker.Project { NewMloEntity(); } + private void YtypMloNewRoomToolStripMenuItem_Click(object sender, EventArgs e) + { + NewMloRoom(); + } + private void YtypMloNewPortalToolStripMenuItem_Click(object sender, EventArgs e) + { + NewMloPortal(); + } + private void YtypMloNewEntitySetToolStripMenuItem_Click(object sender, EventArgs e) + { + NewMloEntitySet(); + } private void YndNewNodeMenu_Click(object sender, EventArgs e) { @@ -7070,6 +7181,5 @@ namespace CodeWalker.Project { SaveAll(); } - } } diff --git a/WorldForm.cs b/WorldForm.cs index d903922..f96aa90 100644 --- a/WorldForm.cs +++ b/WorldForm.cs @@ -1464,6 +1464,11 @@ namespace CodeWalker } } } + if (selectionItem.MloRoomDef != null) + { + camrel += ori.Multiply(selectionItem.BBOffset); + ori = ori * selectionItem.BBOrientation; + } if ((selectionItem.ArchetypeExtension != null) || (selectionItem.EntityExtension != null) || (selectionItem.CollisionBounds != null)) { bbmin = selectionItem.AABB.Minimum; @@ -3551,9 +3556,9 @@ namespace CodeWalker { MapSelection ms = new MapSelection(); ms.MloRoomDef = room; - Vector3 min = instance.Owner.Position + instance.Owner.Orientation.Multiply(room.BBMin_CW); - Vector3 max = instance.Owner.Position + instance.Owner.Orientation.Multiply(room.BBMax_CW); - ms.AABB = new BoundingBox(min, max); + ms.AABB = new BoundingBox(room.BBMin_CW, room.BBMax_CW); + ms.BBOffset = instance.Owner.Position; + ms.BBOrientation = instance.Owner.Orientation; SelectItem(ms); } }