Added Edit Archetype button on Entity Editor, improved Archetype editing hash parsing

This commit is contained in:
dexy 2018-12-17 01:26:23 +11:00
parent 439d10e23a
commit 34a29a5faa
5 changed files with 146 additions and 92 deletions

View File

@ -81,16 +81,17 @@
this.label94 = new System.Windows.Forms.Label();
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.MiloFlagsTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.MiloNumExitPortalsTextBox = new System.Windows.Forms.TextBox();
this.label5 = 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.MiloEntitySetsListBox = new System.Windows.Forms.CheckedListBox();
this.label2 = new System.Windows.Forms.Label();
this.EntityEditArchetypeButton = new System.Windows.Forms.Button();
this.EntityTabControl.SuspendLayout();
this.EntityGeneralTabPage.SuspendLayout();
this.EntityLodTabPage.SuspendLayout();
@ -117,6 +118,7 @@
//
// EntityGeneralTabPage
//
this.EntityGeneralTabPage.Controls.Add(this.EntityEditArchetypeButton);
this.EntityGeneralTabPage.Controls.Add(this.EntityFlagsCheckedListBox);
this.EntityGeneralTabPage.Controls.Add(this.label13);
this.EntityGeneralTabPage.Controls.Add(this.label28);
@ -701,27 +703,39 @@
this.EntityMiloTabPage.Text = "MLO Instance";
this.EntityMiloTabPage.UseVisualStyleBackColor = true;
//
// MiloEntitySetsListBox
// MiloFlagsTextBox
//
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);
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);
//
// label2
// label6
//
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:";
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:";
//
// 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:";
//
// label3
//
@ -757,39 +771,38 @@
this.label4.TabIndex = 38;
this.label4.Text = "FloorID:";
//
// MiloNumExitPortalsTextBox
// MiloEntitySetsListBox
//
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);
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);
//
// label5
// label2
//
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:";
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:";
//
// MiloFlagsTextBox
// EntityEditArchetypeButton
//
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:";
this.EntityEditArchetypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.EntityEditArchetypeButton.Location = new System.Drawing.Point(454, 59);
this.EntityEditArchetypeButton.Name = "EntityEditArchetypeButton";
this.EntityEditArchetypeButton.Size = new System.Drawing.Size(95, 23);
this.EntityEditArchetypeButton.TabIndex = 35;
this.EntityEditArchetypeButton.Text = "Edit Archetype...";
this.EntityEditArchetypeButton.UseVisualStyleBackColor = true;
this.EntityEditArchetypeButton.Click += new System.EventHandler(this.EntityEditArchetypeButton_Click);
//
// EditYmapEntityPanel
//
@ -879,5 +892,6 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox MiloFlagsTextBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button EntityEditArchetypeButton;
}
}

View File

@ -801,5 +801,14 @@ namespace CodeWalker.Project.Panels
}
e.NewValue = CheckState.Unchecked;
}
private void EntityEditArchetypeButton_Click(object sender, EventArgs e)
{
if (ProjectForm != null)
{
ProjectForm.SetCurrentArchetype(CurrentEntity?.Archetype);
ProjectForm.ShowEditArchetypePanel(true);
}
}
}
}

View File

@ -338,9 +338,9 @@
"536870912 - Unk30",
"1073741824 - Unk31",
"2147483648 - Unk32"});
this.EntityFlagsCheckedListBox.Location = new System.Drawing.Point(422, 38);
this.EntityFlagsCheckedListBox.Location = new System.Drawing.Point(441, 38);
this.EntityFlagsCheckedListBox.Name = "EntityFlagsCheckedListBox";
this.EntityFlagsCheckedListBox.Size = new System.Drawing.Size(201, 274);
this.EntityFlagsCheckedListBox.Size = new System.Drawing.Size(182, 274);
this.EntityFlagsCheckedListBox.TabIndex = 67;
this.EntityFlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ArchetypeFlagsCheckedListBox_ItemCheck);
//

View File

@ -162,7 +162,11 @@ namespace CodeWalker.Project.Panels
return;
}
var hash = JenkHash.GenHash(TextureDictTextBox.Text);
var hash = 0u;
if (!uint.TryParse(TextureDictTextBox.Text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(TextureDictTextBox.Text);
}
if (CurrentArchetype._BaseArchetypeDef.textureDictionary != hash)
{
@ -173,10 +177,10 @@ namespace CodeWalker.Project.Panels
ProjectForm.SetYtypHasChanged(true);
return;
}
TextureDictHashLabel.Text = "Hash: " + hash.ToString();
CurrentArchetype._BaseArchetypeDef.textureDictionary = hash;
ProjectForm.SetYtypHasChanged(true);
}
TextureDictHashLabel.Text = "Hash: " + hash.ToString();
}
}
@ -197,7 +201,11 @@ namespace CodeWalker.Project.Panels
return;
}
var hash = JenkHash.GenHash(PhysicsDictionaryTextBox.Text);
var hash = 0u;
if (!uint.TryParse(PhysicsDictionaryTextBox.Text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(PhysicsDictionaryTextBox.Text);
}
if (CurrentArchetype._BaseArchetypeDef.physicsDictionary != hash)
{
@ -208,17 +216,20 @@ namespace CodeWalker.Project.Panels
ProjectForm.SetYtypHasChanged(true);
return;
}
PhysicsDictHashLabel.Text = "Hash: " + hash.ToString();
CurrentArchetype._BaseArchetypeDef.physicsDictionary = hash;
ProjectForm.SetYtypHasChanged(true);
}
PhysicsDictHashLabel.Text = "Hash: " + hash.ToString();
}
}
private void ArchetypeNameTextBox_TextChanged(object sender, EventArgs e)
{
var hash = JenkHash.GenHash(ArchetypeNameTextBox.Text);
var hash = 0u;
if (!uint.TryParse(ArchetypeNameTextBox.Text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(ArchetypeNameTextBox.Text);
}
if (CurrentArchetype._BaseArchetypeDef.name != hash)
{
@ -235,7 +246,11 @@ namespace CodeWalker.Project.Panels
private void AssetNameTextBox_TextChanged(object sender, EventArgs e)
{
var hash = JenkHash.GenHash(AssetNameTextBox.Text);
var hash = 0u;
if (!uint.TryParse(AssetNameTextBox.Text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(AssetNameTextBox.Text);
}
if (CurrentArchetype._BaseArchetypeDef.assetName != hash)
{
@ -246,7 +261,11 @@ namespace CodeWalker.Project.Panels
private void ClipDictionaryTextBox_TextChanged(object sender, EventArgs e)
{
var hash = JenkHash.GenHash(ClipDictionaryTextBox.Text);
var hash = 0u;
if (!uint.TryParse(ClipDictionaryTextBox.Text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(ClipDictionaryTextBox.Text);
}
if (CurrentArchetype._BaseArchetypeDef.clipDictionary != hash)
{

View File

@ -231,12 +231,12 @@ namespace CodeWalker.Project
}
return null;
}
private void ShowDefaultPanels()
public void ShowDefaultPanels()
{
ShowProjectExplorer();
ShowWelcomePanel();
}
private void ShowProjectExplorer()
public void ShowProjectExplorer()
{
if ((ProjectExplorer == null) || (ProjectExplorer.IsDisposed) || (ProjectExplorer.Disposing))
{
@ -251,11 +251,11 @@ namespace CodeWalker.Project
ProjectExplorer.Show();
}
}
private void ShowWelcomePanel()
public void ShowWelcomePanel()
{
ShowPreviewPanel(() => { return new WelcomePanel(); });
}
private void ShowPreviewPanel<T>(Func<T> createFunc, Action<T> updateAction = null) where T : ProjectPanel
public void ShowPreviewPanel<T>(Func<T> createFunc, Action<T> updateAction = null) where T : ProjectPanel
{
if ((PreviewPanel != null) && (PreviewPanel is T))
{
@ -276,11 +276,15 @@ namespace CodeWalker.Project
PreviewPanel = panel;
}
}
private void ShowPanel<T>(bool promote, Func<T> createFunc, Action<T> updateAction, Func<T,bool> findFunc) where T : ProjectPanel
public void ShowPanel<T>(bool promote, Func<T> createFunc, Action<T> updateAction, Func<T,bool> findFunc) where T : ProjectPanel
{
T found = FindPanel(findFunc);
if ((found != null) && (found != PreviewPanel))
{
if (found.IsHidden)
{
found.Show();
}
found.BringToFront();//.Show();
updateAction?.Invoke(found);
}
@ -306,159 +310,159 @@ namespace CodeWalker.Project
}
}
}
private void ShowEditProjectPanel(bool promote)
public void ShowEditProjectPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditProjectPanel(this); }, //createFunc
(panel) => { panel.SetProject(CurrentProjectFile); }, //updateFunc
(panel) => { return true; }); //findFunc
}
private void ShowEditProjectManifestPanel(bool promote)
public void ShowEditProjectManifestPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditProjectManifestPanel(this); }, //createFunc
(panel) => { panel.SetProject(CurrentProjectFile); }, //updateFunc
(panel) => { return true; }); //findFunc
}
private void ShowGenerateNavMeshPanel(bool promote)
public void ShowGenerateNavMeshPanel(bool promote)
{
ShowPanel(promote,
() => { return new GenerateNavMeshPanel(this); }, //createFunc
(panel) => { panel.SetProject(CurrentProjectFile); }, //updateFunc
(panel) => { return true; }); //findFunc
}
private void ShowEditYmapPanel(bool promote)
public void ShowEditYmapPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYmapPanel(this); }, //createFunc
(panel) => { panel.SetYmap(CurrentYmapFile); }, //updateFunc
(panel) => { return panel.Ymap == CurrentYmapFile; }); //findFunc
}
private void ShowEditYmapEntityPanel(bool promote)
public void ShowEditYmapEntityPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYmapEntityPanel(this); }, //createFunc
(panel) => { panel.SetEntity(CurrentEntity); }, //updateFunc
(panel) => { return panel.CurrentEntity == CurrentEntity; }); //findFunc
}
private void ShowEditYmapCarGenPanel(bool promote)
public void ShowEditYmapCarGenPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYmapCarGenPanel(this); }, //createFunc
(panel) => { panel.SetCarGen(CurrentCarGen); }, //updateFunc
(panel) => { return panel.CurrentCarGen == CurrentCarGen; }); //findFunc
}
private void ShowEditYmapGrassBatchPanel(bool promote)
public void ShowEditYmapGrassBatchPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYmapGrassPanel(this); }, //createFunc
(panel) => { panel.SetBatch(CurrentGrassBatch); }, //updateFunc
(panel) => { return panel.CurrentBatch == CurrentGrassBatch; }); //findFunc
}
private void ShowEditYtypPanel(bool promote)
public void ShowEditYtypPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYtypPanel(this); }, //createFunc
(panel) => { panel.SetYtyp(CurrentYtypFile); }, //updateFunc
(panel) => { return panel.Ytyp == CurrentYtypFile; }); //findFunc
}
private void ShowEditArchetypePanel(bool promote)
public void ShowEditArchetypePanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYtypArchetypePanel(this); }, //createFunc
(panel) => { panel.SetArchetype(CurrentArchetype); }, //updateFunc
(panel) => { return panel.CurrentArchetype == CurrentArchetype; }); //findFunc
}
private void ShowEditYndPanel(bool promote)
public void ShowEditYndPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYndPanel(this); }, //createFunc
(panel) => { panel.SetYnd(CurrentYndFile); }, //updateFunc
(panel) => { return panel.Ynd == CurrentYndFile; }); //findFunc
}
private void ShowEditYndNodePanel(bool promote)
public void ShowEditYndNodePanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYndNodePanel(this); }, //createFunc
(panel) => { panel.SetPathNode(CurrentPathNode); }, //updateFunc
(panel) => { return panel.CurrentPathNode == CurrentPathNode; }); //findFunc
}
private void ShowEditYnvPanel(bool promote)
public void ShowEditYnvPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPanel(this); }, //createFunc
(panel) => { panel.SetYnv(CurrentYnvFile); }, //updateFunc
(panel) => { return panel.Ynv == CurrentYnvFile; }); //findFunc
}
private void ShowEditYnvPolyPanel(bool promote)
public void ShowEditYnvPolyPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPolyPanel(this); }, //createFunc
(panel) => { panel.SetYnvPoly(CurrentNavPoly); }, //updateFunc
(panel) => { return panel.YnvPoly == CurrentNavPoly; }); //findFunc
}
private void ShowEditYnvPointPanel(bool promote)
public void ShowEditYnvPointPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPointPanel(this); }, //createFunc
(panel) => { panel.SetYnvPoint(CurrentNavPoint); }, //updateFunc
(panel) => { return panel.YnvPoint == CurrentNavPoint; }); //findFunc
}
private void ShowEditYnvPortalPanel(bool promote)
public void ShowEditYnvPortalPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYnvPortalPanel(this); }, //createFunc
(panel) => { panel.SetYnvPortal(CurrentNavPortal); }, //updateFunc
(panel) => { return panel.YnvPortal == CurrentNavPortal; }); //findFunc
}
private void ShowEditTrainTrackPanel(bool promote)
public void ShowEditTrainTrackPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditTrainTrackPanel(this); }, //createFunc
(panel) => { panel.SetTrainTrack(CurrentTrainTrack); }, //updateFunc
(panel) => { return panel.Track == CurrentTrainTrack; }); //findFunc
}
private void ShowEditTrainNodePanel(bool promote)
public void ShowEditTrainNodePanel(bool promote)
{
ShowPanel(promote,
() => { return new EditTrainNodePanel(this); }, //createFunc
(panel) => { panel.SetTrainNode(CurrentTrainNode); }, //updateFunc
(panel) => { return panel.TrainNode == CurrentTrainNode; }); //findFunc
}
private void ShowEditScenarioYmtPanel(bool promote)
public void ShowEditScenarioYmtPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditScenarioYmtPanel(this); }, //createFunc
(panel) => { panel.SetScenarioYmt(CurrentScenario); }, //updateFunc
(panel) => { return panel.CurrentScenario == CurrentScenario; }); //findFunc
}
private void ShowEditScenarioNodePanel(bool promote)
public void ShowEditScenarioNodePanel(bool promote)
{
ShowPanel(promote,
() => { return new EditScenarioNodePanel(this); }, //createFunc
(panel) => { panel.SetScenarioNode(CurrentScenarioNode); }, //updateFunc
(panel) => { return panel.CurrentScenarioNode == CurrentScenarioNode; }); //findFunc
}
private void ShowEditYtypArchetypeMloRoomPanel(bool promote)
public void ShowEditYtypArchetypeMloRoomPanel(bool promote)
{
ShowPanel(promote,
() => { return new EditYtypArchetypeMloRoomPanel(this); }, //createFunc
(panel) => { panel.SetRoom(CurrentMloRoom); }, //updateFunc
(panel) => { return panel.CurrentRoom == CurrentMloRoom; }); //findFunc
}
private void ShowEditAudioFilePanel(bool promote) //TODO
public void ShowEditAudioFilePanel(bool promote) //TODO
{
}
private void ShowEditAudioZonePanel(bool promote) //TODO
public void ShowEditAudioZonePanel(bool promote) //TODO
{
}
private void ShowEditAudioEmitterPanel(bool promote) //TODO
public void ShowEditAudioEmitterPanel(bool promote) //TODO
{
}
private void ShowEditAudioZoneListPanel(bool promote) //TODO
public void ShowEditAudioZoneListPanel(bool promote) //TODO
{
}
private void ShowEditAudioEmitterListPanel(bool promote) //TODO
public void ShowEditAudioEmitterListPanel(bool promote) //TODO
{
}
@ -692,6 +696,14 @@ namespace CodeWalker.Project
RefreshUI();
}
public void SetCurrentArchetype(Archetype arch)
{
CurrentArchetype = arch;
if (CurrentArchetype != null)
{
CurrentYtypFile = CurrentEntity?.MloParent?.Archetype?.Ytyp ?? CurrentArchetype?.Ytyp;
}
}
private void ClosePanel<T>(Func<T,bool> findFunc) where T : ProjectPanel
{