Added create archetype from YDR option in project window, manual merge and fix of PR118

This commit is contained in:
dexy 2021-11-10 04:04:19 +11:00
parent a036d1673a
commit 1c31bd4a4f
2 changed files with 75 additions and 20 deletions

View File

@ -177,6 +177,8 @@
this.toolStripSeparator27 = new System.Windows.Forms.ToolStripSeparator();
this.OptionsAutoCalcYmapFlagsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsAutoCalcYmapExtentsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator28 = new System.Windows.Forms.ToolStripSeparator();
this.OptionsDisplayEntityIndexesMenu = new System.Windows.Forms.ToolStripMenuItem();
this.MainDockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel();
this.VSExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
@ -205,8 +207,7 @@
this.ToolbarSaveButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarSaveAllButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.OptionsDisplayEntityIndexesMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator28 = new System.Windows.Forms.ToolStripSeparator();
this.YtypNewArchetypeFromYdrMenu = new System.Windows.Forms.ToolStripMenuItem();
this.MainMenu.SuspendLayout();
this.MainToolbar.SuspendLayout();
this.SuspendLayout();
@ -680,6 +681,7 @@
this.YtypNameMenu,
this.toolStripSeparator13,
this.YtypNewArchetypeMenu,
this.YtypNewArchetypeFromYdrMenu,
this.YtypMloToolStripMenuItem,
this.toolStripSeparator15,
this.YtypAddToProjectMenu,
@ -693,19 +695,19 @@
//
this.YtypNameMenu.Enabled = false;
this.YtypNameMenu.Name = "YtypNameMenu";
this.YtypNameMenu.Size = new System.Drawing.Size(192, 22);
this.YtypNameMenu.Size = new System.Drawing.Size(218, 22);
this.YtypNameMenu.Text = "(No .ytyp file selected)";
//
// toolStripSeparator13
//
this.toolStripSeparator13.Name = "toolStripSeparator13";
this.toolStripSeparator13.Size = new System.Drawing.Size(189, 6);
this.toolStripSeparator13.Size = new System.Drawing.Size(215, 6);
//
// YtypNewArchetypeMenu
//
this.YtypNewArchetypeMenu.Enabled = false;
this.YtypNewArchetypeMenu.Name = "YtypNewArchetypeMenu";
this.YtypNewArchetypeMenu.Size = new System.Drawing.Size(192, 22);
this.YtypNewArchetypeMenu.Size = new System.Drawing.Size(218, 22);
this.YtypNewArchetypeMenu.Text = "New Archetype";
this.YtypNewArchetypeMenu.Click += new System.EventHandler(this.YtypNewArchetypeMenu_Click);
//
@ -718,7 +720,7 @@
this.YtypMloNewEntitySetToolStripMenuItem});
this.YtypMloToolStripMenuItem.Enabled = false;
this.YtypMloToolStripMenuItem.Name = "YtypMloToolStripMenuItem";
this.YtypMloToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.YtypMloToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
this.YtypMloToolStripMenuItem.Text = "Mlo";
//
// YtypMloNewEntityToolStripMenuItem
@ -752,13 +754,13 @@
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(189, 6);
this.toolStripSeparator15.Size = new System.Drawing.Size(215, 6);
//
// YtypAddToProjectMenu
//
this.YtypAddToProjectMenu.Enabled = false;
this.YtypAddToProjectMenu.Name = "YtypAddToProjectMenu";
this.YtypAddToProjectMenu.Size = new System.Drawing.Size(192, 22);
this.YtypAddToProjectMenu.Size = new System.Drawing.Size(218, 22);
this.YtypAddToProjectMenu.Text = "Add to Project";
this.YtypAddToProjectMenu.Click += new System.EventHandler(this.YtypAddToProjectMenu_Click);
//
@ -766,7 +768,7 @@
//
this.YtypRemoveFromProjectMenu.Enabled = false;
this.YtypRemoveFromProjectMenu.Name = "YtypRemoveFromProjectMenu";
this.YtypRemoveFromProjectMenu.Size = new System.Drawing.Size(192, 22);
this.YtypRemoveFromProjectMenu.Size = new System.Drawing.Size(218, 22);
this.YtypRemoveFromProjectMenu.Text = "Remove from Project";
this.YtypRemoveFromProjectMenu.Click += new System.EventHandler(this.YtypRemoveFromProjectMenu_Click);
//
@ -1411,6 +1413,18 @@
this.OptionsAutoCalcYmapExtentsMenu.Text = "Auto Calculate Ymap Extents";
this.OptionsAutoCalcYmapExtentsMenu.Click += new System.EventHandler(this.OptionsAutoCalcYmapExtentsMenu_Click);
//
// toolStripSeparator28
//
this.toolStripSeparator28.Name = "toolStripSeparator28";
this.toolStripSeparator28.Size = new System.Drawing.Size(223, 6);
//
// OptionsDisplayEntityIndexesMenu
//
this.OptionsDisplayEntityIndexesMenu.Name = "OptionsDisplayEntityIndexesMenu";
this.OptionsDisplayEntityIndexesMenu.Size = new System.Drawing.Size(226, 22);
this.OptionsDisplayEntityIndexesMenu.Text = "Display Entity Indexes";
this.OptionsDisplayEntityIndexesMenu.Click += new System.EventHandler(this.OptionsDisplayEntityIndexesMenu_Click);
//
// MainDockPanel
//
this.MainDockPanel.BackColor = System.Drawing.SystemColors.AppWorkspace;
@ -1637,17 +1651,13 @@
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
//
// OptionsDisplayEntityIndexesMenu
// YtypNewArchetypeFromYdrMenu
//
this.OptionsDisplayEntityIndexesMenu.Name = "OptionsDisplayEntityIndexesMenu";
this.OptionsDisplayEntityIndexesMenu.Size = new System.Drawing.Size(226, 22);
this.OptionsDisplayEntityIndexesMenu.Text = "Display Entity Indexes";
this.OptionsDisplayEntityIndexesMenu.Click += new System.EventHandler(this.OptionsDisplayEntityIndexesMenu_Click);
//
// toolStripSeparator28
//
this.toolStripSeparator28.Name = "toolStripSeparator28";
this.toolStripSeparator28.Size = new System.Drawing.Size(223, 6);
this.YtypNewArchetypeFromYdrMenu.Enabled = false;
this.YtypNewArchetypeFromYdrMenu.Name = "YtypNewArchetypeFromYdrMenu";
this.YtypNewArchetypeFromYdrMenu.Size = new System.Drawing.Size(218, 22);
this.YtypNewArchetypeFromYdrMenu.Text = "New Archetype from YDR...";
this.YtypNewArchetypeFromYdrMenu.Click += new System.EventHandler(this.YtypNewArchetypeFromYdrMenu_Click);
//
// ProjectForm
//
@ -1852,5 +1862,6 @@
private System.Windows.Forms.ToolStripMenuItem OptionsAutoCalcYmapExtentsMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator28;
private System.Windows.Forms.ToolStripMenuItem OptionsDisplayEntityIndexesMenu;
private System.Windows.Forms.ToolStripMenuItem YtypNewArchetypeFromYdrMenu;
}
}

View File

@ -3114,7 +3114,8 @@ namespace CodeWalker.Project
CurrentYtypFile.FilePath = filepath;
CurrentYtypFile.RpfFileEntry.Name = new FileInfo(filepath).Name;
CurrentYtypFile.Name = CurrentYtypFile.RpfFileEntry.Name;
CurrentYtypFile._CMapTypes.name = new MetaHash(JenkHash.GenHash(newname));
CurrentYtypFile.NameHash = JenkHash.GenHash(newname);
CurrentYtypFile._CMapTypes.name = CurrentYtypFile.NameHash;
}
data = CurrentYtypFile.Save();
@ -3212,6 +3213,44 @@ namespace CodeWalker.Project
return archetype;
}
public void NewArchetypesFromYdrs()
{
if (CurrentYtypFile == null) return;
string[] files = ShowOpenDialogMulti("Ydr files|*.ydr", string.Empty);
if (files == null) return;
if (files.Length == 0) return;
Archetype archetype = null;
foreach (var file in files)
{
archetype = CurrentYtypFile.AddArchetype();
YdrFile ydr = new YdrFile();
RpfFile.LoadResourceFile(ydr, File.ReadAllBytes(file), 165);
var name = Path.GetFileNameWithoutExtension(file);
var hash = JenkHash.GenHash(name);
archetype._BaseArchetypeDef.name = hash;
archetype._BaseArchetypeDef.assetName = hash;
archetype._BaseArchetypeDef.assetType = rage__fwArchetypeDef__eAssetType.ASSET_TYPE_DRAWABLE;
archetype._BaseArchetypeDef.specialAttribute = 0;
archetype._BaseArchetypeDef.flags = 32;
archetype._BaseArchetypeDef.bbMin = ydr.Drawable.BoundingBoxMin;
archetype._BaseArchetypeDef.bbMax = ydr.Drawable.BoundingBoxMax;
archetype._BaseArchetypeDef.bsCentre = ydr.Drawable.BoundingCenter;
archetype._BaseArchetypeDef.bsRadius = ydr.Drawable.BoundingSphereRadius;
archetype._BaseArchetypeDef.hdTextureDist = 60.0f;
archetype._BaseArchetypeDef.lodDist = 60.0f;
if (ydr.Drawable.ShaderGroup.TextureDictionary != null) archetype._BaseArchetypeDef.textureDictionary = hash;
if (ydr.Drawable.Bound != null) archetype._BaseArchetypeDef.physicsDictionary = hash;
AddProjectArchetype(archetype);
}
LoadProjectTree();
ProjectExplorer?.TrySelectArchetypeTreeNode(archetype);
CurrentArchetype = archetype;
}
public YmapEntityDef NewMloEntity(YmapEntityDef copy = null, bool copyTransform = false, bool selectNew = true)
{
if ((CurrentArchetype == null) || !(CurrentArchetype is MloArchetype mloArch))
@ -8717,6 +8756,7 @@ namespace CodeWalker.Project
bool ismlo = ((CurrentEntity != null) && (CurrentEntity.MloParent != null)) || (CurrentMloRoom != null) || (CurrentMloPortal != null) || (CurrentMloEntitySet != null) || (CurrentArchetype is MloArchetype);
YtypNewArchetypeMenu.Enabled = enable && inproj;
YtypNewArchetypeFromYdrMenu.Enabled = enable && inproj;
YtypMloToolStripMenuItem.Enabled = enable && inproj && ismlo;
YtypMloNewEntityToolStripMenuItem.Enabled = YtypMloToolStripMenuItem.Enabled;
@ -9216,6 +9256,10 @@ namespace CodeWalker.Project
{
NewArchetype();
}
private void YtypNewArchetypeFromYdrMenu_Click(object sender, EventArgs e)
{
NewArchetypesFromYdrs();
}
private void YtypMloNewEntityToolStripMenuItem_Click(object sender, EventArgs e)
{
NewMloEntity();