Moved entity sets checkboxlist to MLO Instance tab on entity panel. Added support for updating/saving MLO instance data. Added support for updating/saving TImeArchetype data.

This commit is contained in:
dexy 2018-12-16 22:32:33 +11:00
parent f738a03eaa
commit 37afa2335c
9 changed files with 500 additions and 58 deletions

View File

@ -599,6 +599,11 @@ namespace CodeWalker.GameFiles
var ent = AllEntities[i]; var ent = AllEntities[i];
if (ent.MloInstance != null) if (ent.MloInstance != null)
{ {
ent.MloInstance.UpdateDefaultEntitySets();
ent.MloInstance._Instance.CEntityDef = ent.CEntityDef; //overwrite with all the updated values..
ent.MloInstance._Instance.defaultEntitySets = mb.AddUintArrayPtr(ent.MloInstance.defaultEntitySets);
ptrs[i] = mb.AddItemPtr(MetaName.CMloInstanceDef, ent.MloInstance.Instance); ptrs[i] = mb.AddItemPtr(MetaName.CMloInstanceDef, ent.MloInstance.Instance);
} }
else else
@ -1003,12 +1008,16 @@ namespace CodeWalker.GameFiles
flags = SetBit(flags, 1); //2 flags = SetBit(flags, 1); //2
break; break;
} }
if (yent.MloInstance != null)
{
contentFlags = SetBit(contentFlags, 3); //8 //(interior instance)
}
} }
} }
if ((CMloInstanceDefs != null) && (CMloInstanceDefs.Length > 0)) if ((CMloInstanceDefs != null) && (CMloInstanceDefs.Length > 0))
{ {
contentFlags = SetBit(contentFlags, 3); //8 contentFlags = SetBit(contentFlags, 3); //8 //(interior instance) //is this still necessary?
} }
if ((physicsDictionaries != null) && (physicsDictionaries.Length > 0)) if ((physicsDictionaries != null) && (physicsDictionaries.Length > 0))
{ {

View File

@ -89,7 +89,7 @@ namespace CodeWalker.GameFiles
public uint TimeFlags { get; set; } public uint TimeFlags { get; set; }
public bool[] ActiveHours { get; set; } public bool[] ActiveHours { get; set; }
public string[] ActiveHoursText { get; set; } public string[] ActiveHoursText { get; set; }
public bool ExtraFlag { get; set; } public bool ExtraFlag { get { return ((TimeFlags >> 24) & 1) == 1; } }
public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch) public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch)
@ -99,18 +99,8 @@ namespace CodeWalker.GameFiles
_TimeArchetypeDef = arch; _TimeArchetypeDef = arch;
TimeFlags = arch.TimeArchetypeDef.timeFlags; TimeFlags = arch.TimeArchetypeDef.timeFlags;
ActiveHours = new bool[24];
ActiveHoursText = new string[24];
for (int i = 0; i < 24; i++)
{
bool v = ((TimeFlags >> i) & 1) == 1;
ActiveHours[i] = v;
int nxth = (i < 23) ? (i + 1) : 0; UpdateActiveHours();
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
}
ExtraFlag = ((TimeFlags >> 24) & 1) == 1;
} }
public override bool IsActive(float hour) public override bool IsActive(float hour)
@ -120,6 +110,35 @@ namespace CodeWalker.GameFiles
if ((h < 0) || (h > 23)) return true; if ((h < 0) || (h > 23)) return true;
return ActiveHours[h]; return ActiveHours[h];
} }
public void UpdateActiveHours()
{
if (ActiveHours == null)
{
ActiveHours = new bool[24];
ActiveHoursText = new string[24];
}
for (int i = 0; i < 24; i++)
{
bool v = ((TimeFlags >> i) & 1) == 1;
ActiveHours[i] = v;
int nxth = (i < 23) ? (i + 1) : 0;
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
}
}
public void SetTimeFlags(uint flags)
{
TimeFlags = flags;
_TimeArchetypeDef._TimeArchetypeDef.timeFlags = flags;
UpdateActiveHours();
}
} }
public class MloArchetype : Archetype public class MloArchetype : Archetype
@ -630,6 +649,27 @@ namespace CodeWalker.GameFiles
Entities = entities.ToArray(); Entities = entities.ToArray();
} }
public void UpdateDefaultEntitySets()
{
var list = new List<uint>();
var mloarch = Owner?.Archetype as MloArchetype;
for (uint i = 0; i < mloarch.entitySets.Length; i++)
{
var entset = mloarch.entitySets[i];
MloInstanceEntitySet instset = null;
EntitySets.TryGetValue(entset._Data.name, out instset);
if (instset != null)
{
if (instset.Visible)
{
list.Add(i);
}
}
}
defaultEntitySets = list.ToArray();
}
} }
[TypeConverter(typeof(ExpandableObjectConverter))] [TypeConverter(typeof(ExpandableObjectConverter))]

View File

@ -2012,6 +2012,10 @@ namespace CodeWalker.GameFiles
} }
public string GetShortNameLower() public string GetShortNameLower()
{ {
if (NameLower == null)
{
NameLower = Name.ToLowerInvariant();
}
int ind = NameLower.LastIndexOf('.'); int ind = NameLower.LastIndexOf('.');
if (ind > 0) if (ind > 0)
{ {

View File

@ -80,11 +80,23 @@
this.EntityPivotRotationNormalizeButton = new System.Windows.Forms.Button(); this.EntityPivotRotationNormalizeButton = new System.Windows.Forms.Button();
this.label94 = new System.Windows.Forms.Label(); this.label94 = new System.Windows.Forms.Label();
this.EntityPivotRotationTextBox = new System.Windows.Forms.TextBox(); this.EntityPivotRotationTextBox = new System.Windows.Forms.TextBox();
this.EntityMiloTabPage = new System.Windows.Forms.TabPage();
this.MiloEntitySetsListBox = new System.Windows.Forms.CheckedListBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.MiloGroupIDTextBox = new System.Windows.Forms.TextBox();
this.MiloFloorIDTextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.MiloNumExitPortalsTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.MiloFlagsTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.EntityTabControl.SuspendLayout(); this.EntityTabControl.SuspendLayout();
this.EntityGeneralTabPage.SuspendLayout(); this.EntityGeneralTabPage.SuspendLayout();
this.EntityLodTabPage.SuspendLayout(); this.EntityLodTabPage.SuspendLayout();
this.EntityExtensionsTabPage.SuspendLayout(); this.EntityExtensionsTabPage.SuspendLayout();
this.EntityPivotTabPage.SuspendLayout(); this.EntityPivotTabPage.SuspendLayout();
this.EntityMiloTabPage.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// EntityTabControl // EntityTabControl
@ -96,6 +108,7 @@
this.EntityTabControl.Controls.Add(this.EntityLodTabPage); this.EntityTabControl.Controls.Add(this.EntityLodTabPage);
this.EntityTabControl.Controls.Add(this.EntityExtensionsTabPage); this.EntityTabControl.Controls.Add(this.EntityExtensionsTabPage);
this.EntityTabControl.Controls.Add(this.EntityPivotTabPage); this.EntityTabControl.Controls.Add(this.EntityPivotTabPage);
this.EntityTabControl.Controls.Add(this.EntityMiloTabPage);
this.EntityTabControl.Location = new System.Drawing.Point(2, 3); this.EntityTabControl.Location = new System.Drawing.Point(2, 3);
this.EntityTabControl.Name = "EntityTabControl"; this.EntityTabControl.Name = "EntityTabControl";
this.EntityTabControl.SelectedIndex = 0; this.EntityTabControl.SelectedIndex = 0;
@ -669,6 +682,115 @@
this.EntityPivotRotationTextBox.TabIndex = 25; this.EntityPivotRotationTextBox.TabIndex = 25;
this.EntityPivotRotationTextBox.TextChanged += new System.EventHandler(this.EntityPivotRotationTextBox_TextChanged); this.EntityPivotRotationTextBox.TextChanged += new System.EventHandler(this.EntityPivotRotationTextBox_TextChanged);
// //
// EntityMiloTabPage
//
this.EntityMiloTabPage.Controls.Add(this.MiloFlagsTextBox);
this.EntityMiloTabPage.Controls.Add(this.label6);
this.EntityMiloTabPage.Controls.Add(this.MiloNumExitPortalsTextBox);
this.EntityMiloTabPage.Controls.Add(this.label5);
this.EntityMiloTabPage.Controls.Add(this.label3);
this.EntityMiloTabPage.Controls.Add(this.MiloGroupIDTextBox);
this.EntityMiloTabPage.Controls.Add(this.MiloFloorIDTextBox);
this.EntityMiloTabPage.Controls.Add(this.label4);
this.EntityMiloTabPage.Controls.Add(this.MiloEntitySetsListBox);
this.EntityMiloTabPage.Controls.Add(this.label2);
this.EntityMiloTabPage.Location = new System.Drawing.Point(4, 22);
this.EntityMiloTabPage.Name = "EntityMiloTabPage";
this.EntityMiloTabPage.Size = new System.Drawing.Size(555, 476);
this.EntityMiloTabPage.TabIndex = 4;
this.EntityMiloTabPage.Text = "MLO Instance";
this.EntityMiloTabPage.UseVisualStyleBackColor = true;
//
// MiloEntitySetsListBox
//
this.MiloEntitySetsListBox.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.MiloEntitySetsListBox.CheckOnClick = true;
this.MiloEntitySetsListBox.FormattingEnabled = true;
this.MiloEntitySetsListBox.Location = new System.Drawing.Point(103, 128);
this.MiloEntitySetsListBox.Name = "MiloEntitySetsListBox";
this.MiloEntitySetsListBox.Size = new System.Drawing.Size(434, 319);
this.MiloEntitySetsListBox.TabIndex = 4;
this.MiloEntitySetsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.MiloEntitySetsListBox_ItemCheck);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 129);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(91, 13);
this.label2.TabIndex = 3;
this.label2.Text = "DefaultEntitySets:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(5, 18);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(50, 13);
this.label3.TabIndex = 36;
this.label3.Text = "GroupID:";
//
// MiloGroupIDTextBox
//
this.MiloGroupIDTextBox.Location = new System.Drawing.Point(101, 15);
this.MiloGroupIDTextBox.Name = "MiloGroupIDTextBox";
this.MiloGroupIDTextBox.Size = new System.Drawing.Size(154, 20);
this.MiloGroupIDTextBox.TabIndex = 37;
this.MiloGroupIDTextBox.TextChanged += new System.EventHandler(this.MiloGroupIDTextBox_TextChanged);
//
// MiloFloorIDTextBox
//
this.MiloFloorIDTextBox.Location = new System.Drawing.Point(101, 41);
this.MiloFloorIDTextBox.Name = "MiloFloorIDTextBox";
this.MiloFloorIDTextBox.Size = new System.Drawing.Size(154, 20);
this.MiloFloorIDTextBox.TabIndex = 39;
this.MiloFloorIDTextBox.TextChanged += new System.EventHandler(this.MiloFloorIDTextBox_TextChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(5, 44);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(44, 13);
this.label4.TabIndex = 38;
this.label4.Text = "FloorID:";
//
// MiloNumExitPortalsTextBox
//
this.MiloNumExitPortalsTextBox.Location = new System.Drawing.Point(101, 67);
this.MiloNumExitPortalsTextBox.Name = "MiloNumExitPortalsTextBox";
this.MiloNumExitPortalsTextBox.Size = new System.Drawing.Size(154, 20);
this.MiloNumExitPortalsTextBox.TabIndex = 41;
this.MiloNumExitPortalsTextBox.TextChanged += new System.EventHandler(this.MiloNumExitPortalsTextBox_TextChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(5, 70);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(81, 13);
this.label5.TabIndex = 40;
this.label5.Text = "NumExitPortals:";
//
// MiloFlagsTextBox
//
this.MiloFlagsTextBox.Location = new System.Drawing.Point(101, 93);
this.MiloFlagsTextBox.Name = "MiloFlagsTextBox";
this.MiloFlagsTextBox.Size = new System.Drawing.Size(154, 20);
this.MiloFlagsTextBox.TabIndex = 43;
this.MiloFlagsTextBox.TextChanged += new System.EventHandler(this.MiloFlagsTextBox_TextChanged);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(5, 96);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(75, 13);
this.label6.TabIndex = 42;
this.label6.Text = "MLOInstFlags:";
//
// EditYmapEntityPanel // EditYmapEntityPanel
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -687,6 +809,8 @@
this.EntityExtensionsTabPage.PerformLayout(); this.EntityExtensionsTabPage.PerformLayout();
this.EntityPivotTabPage.ResumeLayout(false); this.EntityPivotTabPage.ResumeLayout(false);
this.EntityPivotTabPage.PerformLayout(); this.EntityPivotTabPage.PerformLayout();
this.EntityMiloTabPage.ResumeLayout(false);
this.EntityMiloTabPage.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -744,5 +868,16 @@
private System.Windows.Forms.Label label94; private System.Windows.Forms.Label label94;
private System.Windows.Forms.TextBox EntityPivotRotationTextBox; private System.Windows.Forms.TextBox EntityPivotRotationTextBox;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TabPage EntityMiloTabPage;
private System.Windows.Forms.CheckedListBox MiloEntitySetsListBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox MiloGroupIDTextBox;
private System.Windows.Forms.TextBox MiloFloorIDTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox MiloNumExitPortalsTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox MiloFlagsTextBox;
private System.Windows.Forms.Label label6;
} }
} }

View File

@ -119,9 +119,37 @@ namespace CodeWalker.Project.Panels
var cv = ((e.flags & (1u << i)) > 0); var cv = ((e.flags & (1u << i)) > 0);
EntityFlagsCheckedListBox.SetItemCheckState(i, cv ? CheckState.Checked : CheckState.Unchecked); EntityFlagsCheckedListBox.SetItemCheckState(i, cv ? CheckState.Checked : CheckState.Unchecked);
} }
MiloEntitySetsListBox.Items.Clear();
if (CurrentEntity.MloInstance != null)
{
var milo = CurrentEntity.MloInstance._Instance;
MiloGroupIDTextBox.Text = milo.groupId.ToString();
MiloFloorIDTextBox.Text = milo.floorId.ToString();
MiloNumExitPortalsTextBox.Text = milo.numExitPortals.ToString();
MiloFlagsTextBox.Text = milo.MLOInstflags.ToString();
foreach (var sets in CurrentEntity.MloInstance.EntitySets)
{
MloInstanceEntitySet set = sets.Value;
MiloEntitySetsListBox.Items.Add(set.EntitySet.ToString(), set.Visible);
}
}
else
{
MiloGroupIDTextBox.Text = string.Empty;
MiloFloorIDTextBox.Text = string.Empty;
MiloNumExitPortalsTextBox.Text = string.Empty;
MiloFlagsTextBox.Text = string.Empty;
}
populatingui = false; populatingui = false;
UpdateTabVisibility();
ProjectForm.WorldForm?.SelectEntity(CurrentEntity); //hopefully the drawable is already loaded - this will try get from cache ProjectForm.WorldForm?.SelectEntity(CurrentEntity); //hopefully the drawable is already loaded - this will try get from cache
@ -147,6 +175,36 @@ namespace CodeWalker.Project.Panels
} }
private void UpdateTabVisibility()
{
//avoid resetting the tabs if no change is necessary.
bool ok = true;
bool miloTabVis = false;
foreach (var tab in EntityTabControl.TabPages)
{
if (tab == EntityMiloTabPage) miloTabVis = true;
}
if ((CurrentEntity?.MloInstance != null) != miloTabVis) ok = false;
if (ok) return;
var seltab = EntityTabControl.SelectedTab;
EntityTabControl.TabPages.Clear();
EntityTabControl.TabPages.Add(EntityGeneralTabPage);
EntityTabControl.TabPages.Add(EntityLodTabPage);
EntityTabControl.TabPages.Add(EntityExtensionsTabPage);
EntityTabControl.TabPages.Add(EntityPivotTabPage);
if (CurrentEntity?.MloInstance != null) EntityTabControl.TabPages.Add(EntityMiloTabPage);
if (EntityTabControl.TabPages.Contains(seltab))
{
EntityTabControl.SelectedTab = seltab;
}
}
private void EntityArchetypeTextBox_TextChanged(object sender, EventArgs e) private void EntityArchetypeTextBox_TextChanged(object sender, EventArgs e)
{ {
@ -665,5 +723,83 @@ namespace CodeWalker.Project.Panels
Quaternion q = Quaternion.Normalize(new Quaternion(v)); Quaternion q = Quaternion.Normalize(new Quaternion(v));
EntityPivotRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(q.X, q.Y, q.Z, q.W)); EntityPivotRotationTextBox.Text = FloatUtil.GetVector4String(new Vector4(q.X, q.Y, q.Z, q.W));
} }
private void MiloGroupIDTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity?.MloInstance == null) return;
uint groupId = 0;
uint.TryParse(MiloGroupIDTextBox.Text, out groupId);
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity.MloInstance._Instance.groupId != groupId)
{
CurrentEntity.MloInstance._Instance.groupId = groupId;
ProjectItemChanged();
}
}
}
private void MiloFloorIDTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity?.MloInstance == null) return;
uint floorId = 0;
uint.TryParse(MiloFloorIDTextBox.Text, out floorId);
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity.MloInstance._Instance.floorId != floorId)
{
CurrentEntity.MloInstance._Instance.floorId = floorId;
ProjectItemChanged();
}
}
}
private void MiloNumExitPortalsTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity?.MloInstance == null) return;
uint num = 0;
uint.TryParse(MiloNumExitPortalsTextBox.Text, out num);
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity.MloInstance._Instance.numExitPortals != num)
{
CurrentEntity.MloInstance._Instance.numExitPortals = num;
ProjectItemChanged();
}
}
}
private void MiloFlagsTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentEntity?.MloInstance == null) return;
uint flags = 0;
uint.TryParse(MiloFlagsTextBox.Text, out flags);
lock (ProjectForm.ProjectSyncRoot)
{
if (CurrentEntity.MloInstance._Instance.MLOInstflags != flags)
{
CurrentEntity.MloInstance._Instance.MLOInstflags = flags;
ProjectItemChanged();
}
}
}
private void MiloEntitySetsListBox_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (populatingui) return;
var inst = CurrentEntity?.MloInstance;
var mloarch = CurrentEntity?.Archetype as MloArchetype;
if ((inst != null) && (mloarch != null))
{
MloInstanceEntitySet mloInstanceEntitySet = inst.EntitySets[mloarch.entitySets[e.Index]._Data.name];
mloInstanceEntitySet.Visible = e.NewValue == CheckState.Checked;
return;
}
e.NewValue = CheckState.Unchecked;
}
} }
} }

View File

@ -64,14 +64,16 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.TabControl = new System.Windows.Forms.TabControl(); this.TabControl = new System.Windows.Forms.TabControl();
this.MloArchetypeTabPage = new System.Windows.Forms.TabPage(); this.MloArchetypeTabPage = new System.Windows.Forms.TabPage();
this.EntitySetsListBox = new System.Windows.Forms.CheckedListBox(); this.TimeArchetypeTabPage = new System.Windows.Forms.TabPage();
this.TimeFlagsTextBox = new System.Windows.Forms.TextBox();
this.TimeFlagsCheckedListBox = new System.Windows.Forms.CheckedListBox();
this.label15 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label();
this.BaseArchetypeTabPage.SuspendLayout(); this.BaseArchetypeTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.SpecialAttributeNumericUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.SpecialAttributeNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.HDTextureDistNumericUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.HDTextureDistNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.LodDistNumericUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.LodDistNumericUpDown)).BeginInit();
this.TabControl.SuspendLayout(); this.TabControl.SuspendLayout();
this.MloArchetypeTabPage.SuspendLayout(); this.TimeArchetypeTabPage.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// BaseArchetypeTabPage // BaseArchetypeTabPage
@ -526,6 +528,7 @@
// //
this.TabControl.Controls.Add(this.BaseArchetypeTabPage); this.TabControl.Controls.Add(this.BaseArchetypeTabPage);
this.TabControl.Controls.Add(this.MloArchetypeTabPage); this.TabControl.Controls.Add(this.MloArchetypeTabPage);
this.TabControl.Controls.Add(this.TimeArchetypeTabPage);
this.TabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.TabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.TabControl.Location = new System.Drawing.Point(0, 0); this.TabControl.Location = new System.Drawing.Point(0, 0);
this.TabControl.Name = "TabControl"; this.TabControl.Name = "TabControl";
@ -535,8 +538,6 @@
// //
// MloArchetypeTabPage // MloArchetypeTabPage
// //
this.MloArchetypeTabPage.Controls.Add(this.EntitySetsListBox);
this.MloArchetypeTabPage.Controls.Add(this.label15);
this.MloArchetypeTabPage.Location = new System.Drawing.Point(4, 22); this.MloArchetypeTabPage.Location = new System.Drawing.Point(4, 22);
this.MloArchetypeTabPage.Name = "MloArchetypeTabPage"; this.MloArchetypeTabPage.Name = "MloArchetypeTabPage";
this.MloArchetypeTabPage.Padding = new System.Windows.Forms.Padding(3); this.MloArchetypeTabPage.Padding = new System.Windows.Forms.Padding(3);
@ -545,27 +546,79 @@
this.MloArchetypeTabPage.Text = "Mlo Archetype Def"; this.MloArchetypeTabPage.Text = "Mlo Archetype Def";
this.MloArchetypeTabPage.UseVisualStyleBackColor = true; this.MloArchetypeTabPage.UseVisualStyleBackColor = true;
// //
// EntitySetsListBox // TimeArchetypeTabPage
// //
this.EntitySetsListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.TimeArchetypeTabPage.Controls.Add(this.TimeFlagsTextBox);
| System.Windows.Forms.AnchorStyles.Left) this.TimeArchetypeTabPage.Controls.Add(this.TimeFlagsCheckedListBox);
| System.Windows.Forms.AnchorStyles.Right))); this.TimeArchetypeTabPage.Controls.Add(this.label15);
this.EntitySetsListBox.CheckOnClick = true; this.TimeArchetypeTabPage.Location = new System.Drawing.Point(4, 22);
this.EntitySetsListBox.FormattingEnabled = true; this.TimeArchetypeTabPage.Name = "TimeArchetypeTabPage";
this.EntitySetsListBox.Location = new System.Drawing.Point(11, 42); this.TimeArchetypeTabPage.Size = new System.Drawing.Size(631, 479);
this.EntitySetsListBox.Name = "EntitySetsListBox"; this.TimeArchetypeTabPage.TabIndex = 2;
this.EntitySetsListBox.Size = new System.Drawing.Size(603, 319); this.TimeArchetypeTabPage.Text = "Time Archetype Def";
this.EntitySetsListBox.TabIndex = 2; this.TimeArchetypeTabPage.UseVisualStyleBackColor = true;
this.EntitySetsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.EntitySetsListBox_ItemCheck); //
// TimeFlagsTextBox
//
this.TimeFlagsTextBox.Location = new System.Drawing.Point(72, 6);
this.TimeFlagsTextBox.Name = "TimeFlagsTextBox";
this.TimeFlagsTextBox.Size = new System.Drawing.Size(147, 20);
this.TimeFlagsTextBox.TabIndex = 69;
this.TimeFlagsTextBox.TextChanged += new System.EventHandler(this.TimeFlagsTextBox_TextChanged);
//
// TimeFlagsCheckedListBox
//
this.TimeFlagsCheckedListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.TimeFlagsCheckedListBox.CheckOnClick = true;
this.TimeFlagsCheckedListBox.FormattingEnabled = true;
this.TimeFlagsCheckedListBox.Items.AddRange(new object[] {
"1 - 00:00 - 01:00",
"2 - 01:00 - 02:00",
"4 - 02:00 - 03:00",
"8 - 03:00 - 04:00",
"16 - 04:00 - 05:00",
"32 - 05:00 - 06:00",
"64 - 06:00 - 07:00",
"128 - 07:00 - 08:00",
"256 - 08:00 - 09:00",
"512 - 09:00 - 10:00",
"1024 - 10:00 - 11:00",
"2048 - 11:00 - 12:00",
"4096 - 12:00 - 13:00",
"8192 - 13:00 - 14:00",
"16384 - 14:00 - 15:00",
"32768 - 15:00 - 16:00",
"65536 - 16:00 - 17:00",
"131072 - 17:00 - 18:00",
"262144 - 18:00 - 19:00",
"524288 - 19:00 - 20:00",
"1048576 - 20:00 - 21:00",
"2097152 - 21:00 - 22:00",
"4194304 - 22:00 - 23:00",
"8388608 - 23:00 - 00:00",
"16777216 - Unk25",
"33554432 - Unk26",
"67108864 - Unk27",
"134217728 - Unk28",
"268435456 - Unk29",
"536870912 - Unk30",
"1073741824 - Unk31",
"2147483648 - Unk32"});
this.TimeFlagsCheckedListBox.Location = new System.Drawing.Point(18, 32);
this.TimeFlagsCheckedListBox.Name = "TimeFlagsCheckedListBox";
this.TimeFlagsCheckedListBox.Size = new System.Drawing.Size(201, 424);
this.TimeFlagsCheckedListBox.TabIndex = 70;
this.TimeFlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.TimeFlagsCheckedListBox_ItemCheck);
// //
// label15 // label15
// //
this.label15.AutoSize = true; this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(8, 26); this.label15.Location = new System.Drawing.Point(5, 9);
this.label15.Name = "label15"; this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(57, 13); this.label15.Size = new System.Drawing.Size(61, 13);
this.label15.TabIndex = 1; this.label15.TabIndex = 68;
this.label15.Text = "EntitySets:"; this.label15.Text = "Time Flags:";
// //
// EditYtypArchetypePanel // EditYtypArchetypePanel
// //
@ -584,8 +637,8 @@
((System.ComponentModel.ISupportInitialize)(this.HDTextureDistNumericUpDown)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.HDTextureDistNumericUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.LodDistNumericUpDown)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.LodDistNumericUpDown)).EndInit();
this.TabControl.ResumeLayout(false); this.TabControl.ResumeLayout(false);
this.MloArchetypeTabPage.ResumeLayout(false); this.TimeArchetypeTabPage.ResumeLayout(false);
this.MloArchetypeTabPage.PerformLayout(); this.TimeArchetypeTabPage.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -627,7 +680,9 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.TabControl TabControl; private System.Windows.Forms.TabControl TabControl;
private System.Windows.Forms.TabPage MloArchetypeTabPage; private System.Windows.Forms.TabPage MloArchetypeTabPage;
private System.Windows.Forms.CheckedListBox EntitySetsListBox; private System.Windows.Forms.TabPage TimeArchetypeTabPage;
private System.Windows.Forms.TextBox TimeFlagsTextBox;
private System.Windows.Forms.CheckedListBox TimeFlagsCheckedListBox;
private System.Windows.Forms.Label label15; private System.Windows.Forms.Label label15;
} }
} }

View File

@ -59,7 +59,6 @@ namespace CodeWalker.Project.Panels
BSCenterTextBox.Text = FloatUtil.GetVector3String(CurrentArchetype._BaseArchetypeDef.bsCentre); BSCenterTextBox.Text = FloatUtil.GetVector3String(CurrentArchetype._BaseArchetypeDef.bsCentre);
BSRadiusTextBox.Text = CurrentArchetype._BaseArchetypeDef.bsRadius.ToString(CultureInfo.InvariantCulture); BSRadiusTextBox.Text = CurrentArchetype._BaseArchetypeDef.bsRadius.ToString(CultureInfo.InvariantCulture);
EntitySetsListBox.Items.Clear();
if (CurrentArchetype is MloArchetype MloArchetype) if (CurrentArchetype is MloArchetype MloArchetype)
{ {
if (!TabControl.TabPages.Contains(MloArchetypeTabPage)) if (!TabControl.TabPages.Contains(MloArchetypeTabPage))
@ -67,19 +66,25 @@ namespace CodeWalker.Project.Panels
TabControl.TabPages.Add(MloArchetypeTabPage); TabControl.TabPages.Add(MloArchetypeTabPage);
} }
MloInstanceData mloinstance = ProjectForm.TryGetMloInstance(MloArchetype); //MloInstanceData mloinstance = ProjectForm.TryGetMloInstance(MloArchetype);
if (mloinstance != null) //nothing to see here right now
{
EntitySetsListBox.Enabled = true;
foreach (var sets in mloinstance.EntitySets)
{
MloInstanceEntitySet set = sets.Value;
EntitySetsListBox.Items.Add(set.EntitySet.ToString(), set.Visible);
}
}
else EntitySetsListBox.Enabled = false;
} }
else TabControl.TabPages.Remove(MloArchetypeTabPage); else TabControl.TabPages.Remove(MloArchetypeTabPage);
if (CurrentArchetype is TimeArchetype TimeArchetype)
{
if (!TabControl.TabPages.Contains(TimeArchetypeTabPage))
{
TabControl.TabPages.Add(TimeArchetypeTabPage);
}
TimeFlagsTextBox.Text = TimeArchetype.TimeFlags.ToString();
}
else TabControl.TabPages.Remove(TimeArchetypeTabPage);
} }
} }
@ -335,19 +340,69 @@ namespace CodeWalker.Project.Panels
ProjectForm.DeleteArchetype(); ProjectForm.DeleteArchetype();
} }
private void EntitySetsListBox_ItemCheck(object sender, ItemCheckEventArgs e) private void TimeFlagsTextBox_TextChanged(object sender, EventArgs e)
{ {
if (CurrentArchetype is MloArchetype MloArchetype) if (populatingui) return;
if (CurrentArchetype == null) return;
if (CurrentArchetype is TimeArchetype TimeArchetype)
{ {
var inst = ProjectForm.TryGetMloInstance(MloArchetype); uint flags = 0;
if (inst != null) uint.TryParse(TimeFlagsTextBox.Text, out flags);
populatingui = true;
for (int i = 0; i < TimeFlagsCheckedListBox.Items.Count; i++)
{ {
MloInstanceEntitySet mloInstanceEntitySet = inst.EntitySets[MloArchetype.entitySets[e.Index]._Data.name]; var c = ((flags & (1u << i)) > 0);
mloInstanceEntitySet.Visible = e.NewValue == CheckState.Checked; TimeFlagsCheckedListBox.SetItemCheckState(i, c ? CheckState.Checked : CheckState.Unchecked);
return; }
populatingui = false;
lock (ProjectForm.ProjectSyncRoot)
{
if (TimeArchetype.TimeFlags != flags)
{
TimeArchetype.SetTimeFlags(flags);
ProjectForm.SetYtypHasChanged(true);
}
}
}
}
private void TimeFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (populatingui) return;
if (CurrentArchetype == null) return;
if (CurrentArchetype is TimeArchetype TimeArchetype)
{
uint flags = 0;
for (int i = 0; i < TimeFlagsCheckedListBox.Items.Count; i++)
{
if (e.Index == i)
{
if (e.NewValue == CheckState.Checked)
{
flags += (uint)(1 << i);
}
}
else
{
if (TimeFlagsCheckedListBox.GetItemChecked(i))
{
flags += (uint)(1 << i);
}
}
}
populatingui = true;
TimeFlagsTextBox.Text = flags.ToString();
populatingui = false;
lock (ProjectForm.ProjectSyncRoot)
{
if (TimeArchetype.TimeFlags != flags)
{
TimeArchetype.SetTimeFlags(flags);
ProjectForm.SetYtypHasChanged(true);
}
}
} }
}
e.NewValue = CheckState.Unchecked;
} }
} }
} }

View File

@ -4382,11 +4382,15 @@ namespace CodeWalker.Project
for (int i = 0; i < CurrentProjectFile.YmapFiles.Count; i++) for (int i = 0; i < CurrentProjectFile.YmapFiles.Count; i++)
{ {
var ymap = CurrentProjectFile.YmapFiles[i]; var ymap = CurrentProjectFile.YmapFiles[i];
// make sure we're not hiding ymaps that have been added by the end-user.
var isnew = ymap.RpfFileEntry.ShortNameHash == 0;
if (ymap.Loaded) if (ymap.Loaded)
{ {
ymaps[isnew ? JenkHash.GenHash(ymap.Name) : ymap.RpfFileEntry.ShortNameHash] = ymap; // make sure we're replacing ymaps that have been added by the end-user.
if (ymap.RpfFileEntry.ShortNameHash == 0)
{
ymap.RpfFileEntry.ShortNameHash = JenkHash.GenHash(ymap.RpfFileEntry.GetShortNameLower());
}
ymaps[ymap.RpfFileEntry.ShortNameHash] = ymap;
} }
} }

View File

@ -3437,6 +3437,10 @@ namespace CodeWalker
ms.EntityDef = entity; ms.EntityDef = entity;
ms.Archetype = entity?.Archetype; ms.Archetype = entity?.Archetype;
ms.AABB = new BoundingBox(entity.BBMin, entity.BBMax); ms.AABB = new BoundingBox(entity.BBMin, entity.BBMax);
if (entity.MloInstance != null)
{
ms.MloEntityDef = entity;
}
SelectItem(ms); SelectItem(ms);
} }
} }