1
0
mirror of synced 2024-12-11 23:36:01 +01:00

A few more fixes.

Fix material copying for wii u bfres.
Add batch bflim exporting.
This commit is contained in:
KillzXGaming 2019-06-25 20:03:50 -04:00
parent b6078e1432
commit 53b15c1f7b
12 changed files with 157 additions and 52 deletions

Binary file not shown.

View File

@ -39,8 +39,9 @@ namespace FirstPlugin
} }
} }
public List<SarcEntry> Files = new List<SarcEntry>();
public Dictionary<string, byte[]> OpenedFiles = new Dictionary<string, byte[]>(); public Dictionary<string, byte[]> OpenedFiles = new Dictionary<string, byte[]>();
public Dictionary<string, byte[]> Files = new Dictionary<string, byte[]>();
public SarcData sarcData; public SarcData sarcData;
public string SarcHash; public string SarcHash;
@ -61,7 +62,7 @@ namespace FirstPlugin
Text = FileName; Text = FileName;
ContextMenuStrip = new STContextMenuStrip(); ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Save", null, Save, Keys.Control | Keys.S)); ContextMenuStrip.Items.Add(new STToolStipMenuItem("Save",null, Save, Keys.Control | Keys.S));
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Rename Actor Files (Odyssey)", null, RenameActors, Keys.Control | Keys.S)); ContextMenuStrip.Items.Add(new STToolStipMenuItem("Rename Actor Files (Odyssey)", null, RenameActors, Keys.Control | Keys.S));
// ContextMenuStrip.Items.Add(new STToolStipMenuItem("Unpack to Folder", null, UnpackToFolder, Keys.Control | Keys.E)); // ContextMenuStrip.Items.Add(new STToolStipMenuItem("Unpack to Folder", null, UnpackToFolder, Keys.Control | Keys.E));
@ -113,8 +114,7 @@ namespace FirstPlugin
} }
private void Delete(object sender, EventArgs args) private void Delete(object sender, EventArgs args) {
{
Unload(); Unload();
var editor = LibraryGUI.Instance.GetObjectEditor(); var editor = LibraryGUI.Instance.GetObjectEditor();
if (editor != null) if (editor != null)
@ -127,16 +127,20 @@ namespace FirstPlugin
TreeView.Sort(); TreeView.Sort();
} }
public class FolderEntry : TreeNode public class FolderEntry : TreeNode, IContextMenuNode
{ {
public FolderEntry(string text, int imageIndex, int selectedImageIndex) public FolderEntry(string text, int imageIndex, int selectedImageIndex)
{ {
Text = text; Text = text;
ImageIndex = imageIndex; ImageIndex = imageIndex;
SelectedImageIndex = selectedImageIndex; SelectedImageIndex = selectedImageIndex;
}
ContextMenu = new ContextMenu(); public ToolStripItem[] GetContextMenuItems()
ContextMenu.MenuItems.Add(new MenuItem("Sort Childern", SortChildern)); {
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Sort Childern", null, SortChildern, Keys.Control | Keys.W));
return Items.ToArray();
} }
private void SortChildern(object sender, EventArgs args) private void SortChildern(object sender, EventArgs args)
@ -328,7 +332,7 @@ namespace FirstPlugin
} }
} }
public class SarcEntry : TreeNodeCustom public class SarcEntry : TreeNodeCustom, IContextMenuNode
{ {
public SARC sarc; //Sarc file the entry is located in public SARC sarc; //Sarc file the entry is located in
public byte[] Data; public byte[] Data;
@ -338,17 +342,22 @@ namespace FirstPlugin
{ {
ImageKey = "fileBlank"; ImageKey = "fileBlank";
SelectedImageKey = "fileBlank"; SelectedImageKey = "fileBlank";
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Export Raw Data", null, Export, Keys.Control | Keys.E));
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Export Raw Data to File Location", null, ExportToFileLoc, Keys.Control | Keys.F));
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Replace Raw Data", null, Replace, Keys.Control | Keys.R));
ContextMenuStrip.Items.Add(new STToolStripSeparator());
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Open With Text Editor", null, OpenTextEditor, Keys.Control | Keys.T));
ContextMenuStrip.Items.Add(new STToolStripSeparator());
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Remove", null, Remove, Keys.Control | Keys.Delete));
ContextMenuStrip.Items.Add(new STToolStipMenuItem("Rename", null, Rename, Keys.Control | Keys.N));
} }
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new STToolStipMenuItem("Export Raw Data", null, Export, Keys.Control | Keys.E));
Items.Add(new STToolStipMenuItem("Export Raw Data to File Location", null, ExportToFileLoc, Keys.Control | Keys.F));
Items.Add(new STToolStipMenuItem("Replace Raw Data", null, Replace, Keys.Control | Keys.R));
Items.Add(new STToolStripSeparator());
Items.Add(new STToolStipMenuItem("Open With Text Editor", null, OpenTextEditor, Keys.Control | Keys.T));
Items.Add(new STToolStripSeparator());
Items.Add(new STToolStipMenuItem("Remove", null, Remove, Keys.Control | Keys.Delete));
Items.Add(new STToolStipMenuItem("Rename", null, Rename, Keys.Control | Keys.N));
return Items.ToArray();
}
public override void OnClick(TreeView treeView) public override void OnClick(TreeView treeView)
{ {
UpdateHexView(); UpdateHexView();
@ -596,7 +605,7 @@ namespace FirstPlugin
sarcEntry.sarc = this; sarcEntry.sarc = this;
sarcEntry.Data = data; sarcEntry.Data = data;
Files.Add(fullName, data); Files.Add(sarcEntry);
string ext = Path.GetExtension(name); string ext = Path.GetExtension(name);
string SarcEx = SARCExt.SARC.GuessFileExtension(data); string SarcEx = SARCExt.SARC.GuessFileExtension(data);

View File

@ -419,6 +419,8 @@ namespace Bfres.Structs
} }
private void SetCopiedMaterialData(CopyMaterialMenu menu, private void SetCopiedMaterialData(CopyMaterialMenu menu,
FMAT selectedMaterial, FMAT targetMaterial) FMAT selectedMaterial, FMAT targetMaterial)
{
if (targetMaterial.Material != null)
{ {
targetMaterial.Material.Flags = selectedMaterial.Material.Flags; targetMaterial.Material.Flags = selectedMaterial.Material.Flags;
targetMaterial.Material.UserDatas = selectedMaterial.Material.UserDatas; targetMaterial.Material.UserDatas = selectedMaterial.Material.UserDatas;
@ -450,6 +452,34 @@ namespace Bfres.Structs
} }
targetMaterial.ReadMaterial(targetMaterial.Material); targetMaterial.ReadMaterial(targetMaterial.Material);
} }
else
{
targetMaterial.MaterialU.Flags = selectedMaterial.MaterialU.Flags;
targetMaterial.MaterialU.UserData = selectedMaterial.MaterialU.UserData;
if (menu.chkBoxRenderInfo.Checked)
{
targetMaterial.MaterialU.RenderState = selectedMaterial.MaterialU.RenderState;
targetMaterial.MaterialU.RenderInfos = selectedMaterial.MaterialU.RenderInfos;
}
if (menu.chkBoxShaderOptions.Checked)
{
targetMaterial.MaterialU.ShaderAssign = selectedMaterial.MaterialU.ShaderAssign;
}
if (menu.chkBoxShaderParams.Checked)
{
targetMaterial.MaterialU.ShaderParamData = selectedMaterial.MaterialU.ShaderParamData;
targetMaterial.MaterialU.ShaderParams = selectedMaterial.MaterialU.ShaderParams;
targetMaterial.MaterialU.VolatileFlags = selectedMaterial.MaterialU.VolatileFlags;
}
if (menu.chkBoxTextures.Checked)
{
targetMaterial.MaterialU.Samplers = selectedMaterial.MaterialU.Samplers;
targetMaterial.MaterialU.TextureRefs = selectedMaterial.MaterialU.TextureRefs;
}
targetMaterial.ReadMaterial(targetMaterial.MaterialU);
}
}
private void TransformTool() private void TransformTool()
{ {
TransformMeshTool transform = new TransformMeshTool(); TransformMeshTool transform = new TransformMeshTool();

View File

@ -960,7 +960,7 @@ namespace Bfres.Structs
List<string> BonesNotMatched = new List<string>(); List<string> BonesNotMatched = new List<string>();
if (ForceSkinCount && !ob.HasIndices) if (ForceSkinCount && !ob.HasIndices && VertexSkinCount != 0)
{ {
var attributeIndex = new FSHP.VertexAttribute(); var attributeIndex = new FSHP.VertexAttribute();
attributeIndex.Format = ResGFX.AttribFormat.Format_8_8_8_8_UInt; attributeIndex.Format = ResGFX.AttribFormat.Format_8_8_8_8_UInt;

View File

@ -155,7 +155,7 @@ namespace FirstPlugin
{ {
public STToolStripItem[] NewFileMenuExtensions => null; public STToolStripItem[] NewFileMenuExtensions => null;
public STToolStripItem[] NewFromFileMenuExtensions => newFileExt; public STToolStripItem[] NewFromFileMenuExtensions => newFileExt;
public STToolStripItem[] ToolsMenuExtensions => null; public STToolStripItem[] ToolsMenuExtensions => toolExt;
public STToolStripItem[] TitleBarExtensions => null; public STToolStripItem[] TitleBarExtensions => null;
public STToolStripItem[] CompressionMenuExtensions => null; public STToolStripItem[] CompressionMenuExtensions => null;
public STToolStripItem[] ExperimentalMenuExtensions => null; public STToolStripItem[] ExperimentalMenuExtensions => null;
@ -163,11 +163,77 @@ namespace FirstPlugin
public ToolStripButton[] IconButtonMenuExtensions => null; public ToolStripButton[] IconButtonMenuExtensions => null;
STToolStripItem[] newFileExt = new STToolStripItem[1]; STToolStripItem[] newFileExt = new STToolStripItem[1];
STToolStripItem[] toolExt = new STToolStripItem[1];
public MenuExt() public MenuExt()
{ {
toolExt[0] = new STToolStripItem("Textures");
toolExt[0].DropDownItems.Add(new STToolStripItem("Batch Export (BFLIM)", Export));
newFileExt[0] = new STToolStripItem("BFLIM From Image", CreateNew); newFileExt[0] = new STToolStripItem("BFLIM From Image", CreateNew);
} }
private void Export(object sender, EventArgs args)
{
string formats = FileFilters.GTX;
string[] forms = formats.Split('|');
List<string> Formats = new List<string>();
for (int i = 0; i < forms.Length; i++)
{
if (i > 1 || i == (forms.Length - 1)) //Skip lines with all extensions
{
if (!forms[i].StartsWith("*"))
Formats.Add(forms[i]);
}
}
BatchFormatExport form = new BatchFormatExport(Formats);
if (form.ShowDialog() == DialogResult.OK)
{
string Extension = form.GetSelectedExtension();
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = Utils.GetAllFilters(typeof(BFLIM));
if (ofd.ShowDialog() == DialogResult.OK)
{
FolderSelectDialog folderDialog = new FolderSelectDialog();
if (folderDialog.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
{
var FileFormat = STFileLoader.OpenFileFormat(file);
if (FileFormat == null)
continue;
SearchBinary(FileFormat, folderDialog.SelectedPath, Extension);
}
}
}
}
}
private void SearchBinary(IFileFormat FileFormat, string Folder, string Extension)
{
if (FileFormat is SARC)
{
foreach (var file in ((SARC)FileFormat).Files)
{
var archiveFile = STFileLoader.OpenFileFormat(file.FullName, file.Data);
if (archiveFile == null)
continue;
SearchBinary(archiveFile, Folder, Extension);
}
}
if (FileFormat is BFLIM)
{
((BFLIM)FileFormat).Export(Folder + FileFormat.FileName + Extension);
}
FileFormat.Unload();
}
public void CreateNew(object sender, EventArgs args) public void CreateNew(object sender, EventArgs args)
{ {

View File

@ -298,6 +298,7 @@ namespace FirstPlugin
} }
} }
} }
public uint unk; public uint unk;
public int unk2; public int unk2;

View File

@ -213,10 +213,10 @@ namespace FirstPlugin
{ {
foreach (var file in ((SARC)FileFormat).Files) foreach (var file in ((SARC)FileFormat).Files)
{ {
string ext = System.IO.Path.GetExtension(file.Key); string ext = System.IO.Path.GetExtension(file.FullName);
if (ext == ".bfres") if (ext == ".bfres")
{ {
bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.Key, file.Value)); bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.FullName, file.Data));
} }
} }
} }

View File

@ -247,7 +247,6 @@ namespace Switch_Toolbox.Library.Forms
if (ActiveObjects.Count <= 0 || ActiveMaterial == null || Runtime.OpenTKInitialized == false) if (ActiveObjects.Count <= 0 || ActiveMaterial == null || Runtime.OpenTKInitialized == false)
return; return;
SetupRendering(1); SetupRendering(1);
gL_ControlLegacy2D1.MakeCurrent(); gL_ControlLegacy2D1.MakeCurrent();