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.toolStripSeparator27 = new System.Windows.Forms.ToolStripSeparator();
this.OptionsAutoCalcYmapFlagsMenu = new System.Windows.Forms.ToolStripMenuItem(); this.OptionsAutoCalcYmapFlagsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsAutoCalcYmapExtentsMenu = 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.MainDockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel();
this.VSExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components); this.VSExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
@ -205,8 +207,7 @@
this.ToolbarSaveButton = new System.Windows.Forms.ToolStripButton(); this.ToolbarSaveButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarSaveAllButton = new System.Windows.Forms.ToolStripButton(); this.ToolbarSaveAllButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.OptionsDisplayEntityIndexesMenu = new System.Windows.Forms.ToolStripMenuItem(); this.YtypNewArchetypeFromYdrMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator28 = new System.Windows.Forms.ToolStripSeparator();
this.MainMenu.SuspendLayout(); this.MainMenu.SuspendLayout();
this.MainToolbar.SuspendLayout(); this.MainToolbar.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@ -680,6 +681,7 @@
this.YtypNameMenu, this.YtypNameMenu,
this.toolStripSeparator13, this.toolStripSeparator13,
this.YtypNewArchetypeMenu, this.YtypNewArchetypeMenu,
this.YtypNewArchetypeFromYdrMenu,
this.YtypMloToolStripMenuItem, this.YtypMloToolStripMenuItem,
this.toolStripSeparator15, this.toolStripSeparator15,
this.YtypAddToProjectMenu, this.YtypAddToProjectMenu,
@ -693,19 +695,19 @@
// //
this.YtypNameMenu.Enabled = false; this.YtypNameMenu.Enabled = false;
this.YtypNameMenu.Name = "YtypNameMenu"; 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)"; this.YtypNameMenu.Text = "(No .ytyp file selected)";
// //
// toolStripSeparator13 // toolStripSeparator13
// //
this.toolStripSeparator13.Name = "toolStripSeparator13"; this.toolStripSeparator13.Name = "toolStripSeparator13";
this.toolStripSeparator13.Size = new System.Drawing.Size(189, 6); this.toolStripSeparator13.Size = new System.Drawing.Size(215, 6);
// //
// YtypNewArchetypeMenu // YtypNewArchetypeMenu
// //
this.YtypNewArchetypeMenu.Enabled = false; this.YtypNewArchetypeMenu.Enabled = false;
this.YtypNewArchetypeMenu.Name = "YtypNewArchetypeMenu"; 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.Text = "New Archetype";
this.YtypNewArchetypeMenu.Click += new System.EventHandler(this.YtypNewArchetypeMenu_Click); this.YtypNewArchetypeMenu.Click += new System.EventHandler(this.YtypNewArchetypeMenu_Click);
// //
@ -718,7 +720,7 @@
this.YtypMloNewEntitySetToolStripMenuItem}); this.YtypMloNewEntitySetToolStripMenuItem});
this.YtypMloToolStripMenuItem.Enabled = false; this.YtypMloToolStripMenuItem.Enabled = false;
this.YtypMloToolStripMenuItem.Name = "YtypMloToolStripMenuItem"; 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"; this.YtypMloToolStripMenuItem.Text = "Mlo";
// //
// YtypMloNewEntityToolStripMenuItem // YtypMloNewEntityToolStripMenuItem
@ -752,13 +754,13 @@
// toolStripSeparator15 // toolStripSeparator15
// //
this.toolStripSeparator15.Name = "toolStripSeparator15"; this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(189, 6); this.toolStripSeparator15.Size = new System.Drawing.Size(215, 6);
// //
// YtypAddToProjectMenu // YtypAddToProjectMenu
// //
this.YtypAddToProjectMenu.Enabled = false; this.YtypAddToProjectMenu.Enabled = false;
this.YtypAddToProjectMenu.Name = "YtypAddToProjectMenu"; 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.Text = "Add to Project";
this.YtypAddToProjectMenu.Click += new System.EventHandler(this.YtypAddToProjectMenu_Click); this.YtypAddToProjectMenu.Click += new System.EventHandler(this.YtypAddToProjectMenu_Click);
// //
@ -766,7 +768,7 @@
// //
this.YtypRemoveFromProjectMenu.Enabled = false; this.YtypRemoveFromProjectMenu.Enabled = false;
this.YtypRemoveFromProjectMenu.Name = "YtypRemoveFromProjectMenu"; 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.Text = "Remove from Project";
this.YtypRemoveFromProjectMenu.Click += new System.EventHandler(this.YtypRemoveFromProjectMenu_Click); this.YtypRemoveFromProjectMenu.Click += new System.EventHandler(this.YtypRemoveFromProjectMenu_Click);
// //
@ -1411,6 +1413,18 @@
this.OptionsAutoCalcYmapExtentsMenu.Text = "Auto Calculate Ymap Extents"; this.OptionsAutoCalcYmapExtentsMenu.Text = "Auto Calculate Ymap Extents";
this.OptionsAutoCalcYmapExtentsMenu.Click += new System.EventHandler(this.OptionsAutoCalcYmapExtentsMenu_Click); 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 // MainDockPanel
// //
this.MainDockPanel.BackColor = System.Drawing.SystemColors.AppWorkspace; this.MainDockPanel.BackColor = System.Drawing.SystemColors.AppWorkspace;
@ -1637,17 +1651,13 @@
this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25); this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
// //
// OptionsDisplayEntityIndexesMenu // YtypNewArchetypeFromYdrMenu
// //
this.OptionsDisplayEntityIndexesMenu.Name = "OptionsDisplayEntityIndexesMenu"; this.YtypNewArchetypeFromYdrMenu.Enabled = false;
this.OptionsDisplayEntityIndexesMenu.Size = new System.Drawing.Size(226, 22); this.YtypNewArchetypeFromYdrMenu.Name = "YtypNewArchetypeFromYdrMenu";
this.OptionsDisplayEntityIndexesMenu.Text = "Display Entity Indexes"; this.YtypNewArchetypeFromYdrMenu.Size = new System.Drawing.Size(218, 22);
this.OptionsDisplayEntityIndexesMenu.Click += new System.EventHandler(this.OptionsDisplayEntityIndexesMenu_Click); this.YtypNewArchetypeFromYdrMenu.Text = "New Archetype from YDR...";
// this.YtypNewArchetypeFromYdrMenu.Click += new System.EventHandler(this.YtypNewArchetypeFromYdrMenu_Click);
// toolStripSeparator28
//
this.toolStripSeparator28.Name = "toolStripSeparator28";
this.toolStripSeparator28.Size = new System.Drawing.Size(223, 6);
// //
// ProjectForm // ProjectForm
// //
@ -1852,5 +1862,6 @@
private System.Windows.Forms.ToolStripMenuItem OptionsAutoCalcYmapExtentsMenu; private System.Windows.Forms.ToolStripMenuItem OptionsAutoCalcYmapExtentsMenu;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator28; private System.Windows.Forms.ToolStripSeparator toolStripSeparator28;
private System.Windows.Forms.ToolStripMenuItem OptionsDisplayEntityIndexesMenu; 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.FilePath = filepath;
CurrentYtypFile.RpfFileEntry.Name = new FileInfo(filepath).Name; CurrentYtypFile.RpfFileEntry.Name = new FileInfo(filepath).Name;
CurrentYtypFile.Name = CurrentYtypFile.RpfFileEntry.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(); data = CurrentYtypFile.Save();
@ -3212,6 +3213,44 @@ namespace CodeWalker.Project
return archetype; 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) public YmapEntityDef NewMloEntity(YmapEntityDef copy = null, bool copyTransform = false, bool selectNew = true)
{ {
if ((CurrentArchetype == null) || !(CurrentArchetype is MloArchetype mloArch)) 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); bool ismlo = ((CurrentEntity != null) && (CurrentEntity.MloParent != null)) || (CurrentMloRoom != null) || (CurrentMloPortal != null) || (CurrentMloEntitySet != null) || (CurrentArchetype is MloArchetype);
YtypNewArchetypeMenu.Enabled = enable && inproj; YtypNewArchetypeMenu.Enabled = enable && inproj;
YtypNewArchetypeFromYdrMenu.Enabled = enable && inproj;
YtypMloToolStripMenuItem.Enabled = enable && inproj && ismlo; YtypMloToolStripMenuItem.Enabled = enable && inproj && ismlo;
YtypMloNewEntityToolStripMenuItem.Enabled = YtypMloToolStripMenuItem.Enabled; YtypMloNewEntityToolStripMenuItem.Enabled = YtypMloToolStripMenuItem.Enabled;
@ -9216,6 +9256,10 @@ namespace CodeWalker.Project
{ {
NewArchetype(); NewArchetype();
} }
private void YtypNewArchetypeFromYdrMenu_Click(object sender, EventArgs e)
{
NewArchetypesFromYdrs();
}
private void YtypMloNewEntityToolStripMenuItem_Click(object sender, EventArgs e) private void YtypMloNewEntityToolStripMenuItem_Click(object sender, EventArgs e)
{ {
NewMloEntity(); NewMloEntity();