1
0
mirror of synced 2024-11-27 17:00:50 +01:00

More format additions and fixes.

Fixed MKAGPDX models a bit so they aren't all missing mesh data. Skinned ones are still buggy!
 BMD wip support using SuperBMDLib.
 Adjusted gui loading a little bit.
This commit is contained in:
KillzXGaming 2019-07-11 17:22:59 -04:00
parent e5b0b71eaa
commit 5081e39414
82 changed files with 640 additions and 297 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
.vs/Switch_Toolbox/v15/Server/sqlite3/db.lock
*NodeEditorWinforms-master
*GL_EditorFramework-master
*SuperBMD-master
*Assimp
*.resources
Debug/

Binary file not shown.

View File

@ -107,11 +107,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;

View File

@ -178,13 +178,13 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadProperties(this.GenericProperties);
@ -253,11 +253,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Dock = DockStyle.Fill;
editor.LoadData(FileData);

View File

@ -95,11 +95,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeView)
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;

View File

@ -116,7 +116,7 @@ namespace FirstPlugin
private void Delete(object sender, EventArgs args) {
Unload();
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor != null)
editor.ResetControls();
}
@ -370,11 +370,11 @@ namespace FirstPlugin
private void UpdateHexView()
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -411,7 +411,7 @@ namespace FirstPlugin
UserControl form = GetEditorForm(fileFormat);
form.Text = (((IFileFormat)fileFormat).FileName);
var parentForm = LibraryGUI.Instance.GetActiveForm();
var parentForm = LibraryGUI.GetActiveForm();
GenericEditorForm editorForm = new GenericEditorForm(true, form);
editorForm.FormClosing += (sender, e) => FormClosing(sender, e, fileFormat);
@ -492,11 +492,11 @@ namespace FirstPlugin
private void OpenTextEditor(object sender, EventArgs args)
{
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;

View File

@ -46,11 +46,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
var prop = new BarsProperty(bars);
@ -165,11 +165,11 @@ namespace FirstPlugin
var audioFile = new VGAdudioFile();
audioFile.LoadAudio(new MemoryStream(Data), new BFWAV());
AudioPlayerPanel editor = (AudioPlayerPanel)LibraryGUI.Instance.GetActiveContent(typeof(AudioPlayerPanel));
AudioPlayerPanel editor = (AudioPlayerPanel)LibraryGUI.GetActiveContent(typeof(AudioPlayerPanel));
if (editor == null)
{
editor = new AudioPlayerPanel();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -178,11 +178,11 @@ namespace FirstPlugin
private void ShowHexView()
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -203,11 +203,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;

View File

@ -103,13 +103,13 @@ namespace FirstPlugin
private bool DrawablesLoaded;
public void LoadEditors(TreeNode Wrapper, Action OnPropertyChanged)
{
BcresEditor bcresEditor = (BcresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BcresEditor));
BcresEditor bcresEditor = (BcresEditor)LibraryGUI.GetActiveContent(typeof(BcresEditor));
bool HasModels = RenderedBcres.Models.Count > 0;
if (bcresEditor == null)
{
bcresEditor = new BcresEditor(HasModels);
bcresEditor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(bcresEditor);
LibraryGUI.LoadEditor(bcresEditor);
}
if (!DrawablesLoaded)

View File

@ -45,12 +45,12 @@ namespace FirstPlugin
private void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
Properties prop = new Properties();

View File

@ -85,7 +85,7 @@ namespace FirstPlugin
{
BFRES file = null;
ObjectEditor editor = (ObjectEditor)LibraryGUI.Instance.GetActiveForm();
ObjectEditor editor = (ObjectEditor)LibraryGUI.GetActiveForm();
if (editor != null)
{
file = (BFRES)editor.GetActiveFile();
@ -118,7 +118,7 @@ namespace FirstPlugin
ObjectEditor editor = new ObjectEditor(bfres);
editor.Text = "Untitled-" + 0;
LibraryGUI.Instance.CreateMdiWindow(editor);
LibraryGUI.CreateMdiWindow(editor);
}
private void NewSwitchBfres(object sender, EventArgs args)
{
@ -130,7 +130,7 @@ namespace FirstPlugin
ObjectEditor editor = new ObjectEditor(bfres);
editor.Text = "Untitled-" + 0;
LibraryGUI.Instance.CreateMdiWindow(editor);
LibraryGUI.CreateMdiWindow(editor);
}
private void DebugInfo(object sender, EventArgs args)
{
@ -267,7 +267,7 @@ namespace FirstPlugin
{
Text = resFileU.Name;
}
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor != null)
editor.Refresh();
@ -289,7 +289,7 @@ namespace FirstPlugin
public void LoadSimpleMode()
{
ObjectEditor editor = (ObjectEditor)LibraryGUI.Instance.GetActiveForm();
ObjectEditor editor = (ObjectEditor)LibraryGUI.GetActiveForm();
if (editor == null)
return;
@ -390,7 +390,7 @@ namespace FirstPlugin
private bool DrawablesLoaded = false;
public void LoadEditors(object SelectedSection)
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
bool HasModels = false;
bool hasShapes = HasShapes();
@ -400,7 +400,7 @@ namespace FirstPlugin
bfresEditor = new BfresEditor(HasModels);
bfresEditor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(bfresEditor);
LibraryGUI.LoadEditor(bfresEditor);
}
bool ViewportToggled = bfresEditor.DisplayViewport;
@ -480,12 +480,12 @@ namespace FirstPlugin
if (SelectedSection is ExternalFileData)
{
ArchiveFilePanel editor = (ArchiveFilePanel)LibraryGUI.Instance.GetActiveContent(typeof(ArchiveFilePanel));
ArchiveFilePanel editor = (ArchiveFilePanel)LibraryGUI.GetActiveContent(typeof(ArchiveFilePanel));
if (editor == null)
{
editor = new ArchiveFilePanel();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.LoadFile(((ExternalFileData)SelectedSection).ArchiveFileInfo);

View File

@ -570,7 +570,7 @@ namespace Bfres.Structs
if (Type == BRESGroupType.Models)
{
((BFRES)Parent).BFRESRender.UpdateModelList();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}
}

View File

@ -77,7 +77,7 @@ namespace Bfres.Structs
UserControl form = GetEditorForm(fileFormat);
form.Text = (((IFileFormat)fileFormat).FileName);
var parentForm = LibraryGUI.Instance.GetActiveForm();
var parentForm = LibraryGUI.GetActiveForm();
GenericEditorForm editorForm = new GenericEditorForm(true, form);
editorForm.FormClosing += (sender, e) => FormClosing(sender, e, fileFormat);

View File

@ -128,7 +128,7 @@ namespace Bfres.Structs
Nodes.Clear();
((BFRESGroupNode)Parent).RemoveChild(this);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
Unload();
}
@ -415,7 +415,7 @@ namespace Bfres.Structs
}
}
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}
private void SetCopiedMaterialData(CopyMaterialMenu menu,

View File

@ -70,7 +70,7 @@ namespace Bfres.Structs
}
}
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void Import()

View File

@ -172,7 +172,7 @@ namespace Bfres.Structs
private STSkeleton GetActiveSkeleton()
{
var viewport = LibraryGUI.Instance.GetActiveViewport();
var viewport = LibraryGUI.GetActiveViewport();
if (viewport != null)
{
foreach (var drawable in viewport.scene.objects)

View File

@ -99,7 +99,7 @@ namespace Bfres.Structs
public override void Delete()
{
((BFRESGroupNode)Parent).RemoveChild(this);
LibraryGUI.Instance.UpdateViewport(); //Update texture display
LibraryGUI.UpdateViewport(); //Update texture display
}
public override void Export(string FileName) => Export(FileName);
@ -245,7 +245,7 @@ namespace Bfres.Structs
IsReplaced = true;
Read(texture);
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}
else
@ -269,7 +269,7 @@ namespace Bfres.Structs
IsReplaced = true;
Read(texture);
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
else
{
@ -499,7 +499,7 @@ namespace Bfres.Structs
IsEdited = true;
Read(texture);
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{
@ -715,7 +715,7 @@ namespace Bfres.Structs
private bool IsEditorActive()
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
if (bfresEditor != null)
{
var imageEditor = bfresEditor.GetActiveEditor(typeof(ImageEditorBase));
@ -723,7 +723,7 @@ namespace Bfres.Structs
}
else
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
return editor != null;
}
}
@ -740,13 +740,13 @@ namespace Bfres.Structs
return;
}
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadProperties(this.texture, OnPropertyChanged);

View File

@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using SuperBMDLib;
using System.Drawing;
namespace FirstPlugin
{
public class BMD : TreeNodeFile, IFileFormat, IContextMenuNode
{
public FileType FileType { get; set; } = FileType.Layout;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "Gamecube/Wii Binary Model (BMD/BDL)" };
public string[] Extension { get; set; } = new string[] { "*.bmd", "*.bdl" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Switch_Toolbox.Library.IO.FileReader(stream, true))
{
reader.SetByteOrder(true);
bool IsBMD = reader.ReadUInt32() == 0x4A334432;
reader.Position = 0;
return IsBMD;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public Model BMDFile;
private TreeNode TextureFolder;
private TreeNode ShapeFolder;
public void Load(System.IO.Stream stream)
{
Text = FileName;
CanSave = true;
ShapeFolder = new TreeNode("Shapes");
TextureFolder = new TreeNode("Textures");
Nodes.Add(ShapeFolder);
Nodes.Add(TextureFolder);
BMDFile = Model.Load(stream);
for (int i = 0; i < BMDFile.Shapes.Shapes.Count; i++)
{
var shpWrapper = new BMDShapeWrapper(BMDFile.Shapes.Shapes[i]);
shpWrapper.Text = $"Shape {i}";
ShapeFolder.Nodes.Add(shpWrapper);
}
for (int i = 0; i < BMDFile.Textures.Textures.Count; i++)
{
var texWrapper = new BMDTextureWrapper(BMDFile.Textures.Textures[i]);
TextureFolder.Nodes.Add(texWrapper);
}
}
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new STToolStipMenuItem("Save", null, SaveAction, Keys.Control | Keys.S));
return Items.ToArray();
}
private void SaveAction(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(this);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
public void Unload()
{
}
public byte[] Save()
{
var mem = new System.IO.MemoryStream();
BMDFile.ExportBMD(mem);
return mem.ToArray();
}
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using SuperBMDLib.Geometry;
namespace FirstPlugin
{
public class BMDShapeWrapper : STGenericObject
{
Shape BMDShape;
public BMDShapeWrapper(Shape shape)
{
BMDShape = shape;
}
public override void OnClick(TreeView treeView)
{
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
editor.LoadProperty(BMDShape, null);
}
}
}

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using SuperBMDLib;
namespace FirstPlugin
{
public class BMDTextureWrapper : STGenericTexture
{
public override bool CanEdit { get; set; } = false;
public override TEX_FORMAT[] SupportedFormats => throw new NotImplementedException();
SuperBMDLib.Materials.BinaryTextureImage TextureImage;
public BMDTextureWrapper(SuperBMDLib.Materials.BinaryTextureImage Image)
{
TextureImage = Image;
Text = TextureImage.Name;
Format = TEX_FORMAT.R8G8B8A8_UNORM_SRGB;
Width = TextureImage.Width;
Height = TextureImage.Height;
MipCount = TextureImage.MipMapCount;
ImageKey = "texture";
SelectedImageKey = ImageKey;
}
public override void OnClick(TreeView treeview)
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadProperties(TextureImage);
editor.LoadImage(this);
}
public override byte[] GetImageData(int ArrayLevel = 0, int MipLevel = 0)
{
return ImageUtilty.ConvertBgraToRgba(TextureImage.RGBAImageData);
}
public override void SetImageData(Bitmap bitmap, int ArrayLevel)
{
TextureImage.EncodeData();
}
}
}

View File

@ -143,7 +143,7 @@ namespace FirstPlugin
ObjectEditor editor = new ObjectEditor(kcl);
editor.Text = name;
LibraryGUI.Instance.CreateMdiWindow(editor);
LibraryGUI.CreateMdiWindow(editor);
}
}
@ -299,12 +299,12 @@ namespace FirstPlugin
{
get
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}
@ -328,7 +328,7 @@ namespace FirstPlugin
}
viewport.ReloadDrawables(DrawableContainer);
LibraryGUI.Instance.LoadEditor(viewport);
LibraryGUI.LoadEditor(viewport);
viewport.Text = Text;
}
@ -514,7 +514,7 @@ namespace FirstPlugin
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void DrawGlobalOctree()

View File

@ -424,11 +424,11 @@ namespace FirstPlugin
{
if (BinaryData is Emitter || Signature == "EMTR")
{
EmitterEditor editor = (EmitterEditor)LibraryGUI.Instance.GetActiveContent(typeof(EmitterEditor));
EmitterEditor editor = (EmitterEditor)LibraryGUI.GetActiveContent(typeof(EmitterEditor));
if (editor == null)
{
editor = new EmitterEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -809,12 +809,12 @@ namespace FirstPlugin
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -215,11 +215,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
EmitterEditor editor = (EmitterEditor)LibraryGUI.Instance.GetActiveContent(typeof(EmitterEditor));
EmitterEditor editor = (EmitterEditor)LibraryGUI.GetActiveContent(typeof(EmitterEditor));
if (editor == null)
{
editor = new EmitterEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -393,12 +393,12 @@ namespace FirstPlugin
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -208,11 +208,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
EmitterEditor editor = (EmitterEditor)LibraryGUI.Instance.GetActiveContent(typeof(EmitterEditor));
EmitterEditor editor = (EmitterEditor)LibraryGUI.GetActiveContent(typeof(EmitterEditor));
if (editor == null)
{
editor = new EmitterEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -372,12 +372,12 @@ namespace FirstPlugin
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -446,12 +446,12 @@ namespace FirstPlugin
private void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
Properties prop = new Properties();

View File

@ -50,12 +50,12 @@ namespace FirstPlugin
{
get
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}
@ -78,7 +78,7 @@ namespace FirstPlugin
}
viewport.ReloadDrawables(DrawableContainer);
LibraryGUI.Instance.LoadEditor(viewport);
LibraryGUI.LoadEditor(viewport);
viewport.Text = Text;
}

View File

@ -44,12 +44,12 @@ namespace FirstPlugin
{
get
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}
@ -72,7 +72,7 @@ namespace FirstPlugin
}
viewport.ReloadDrawables(DrawableContainer);
LibraryGUI.Instance.LoadEditor(viewport);
LibraryGUI.LoadEditor(viewport);
viewport.Text = Text;
}

View File

@ -192,8 +192,9 @@ namespace FirstPlugin
DrawableContainer = null;
header.Materials.Clear();
header.TextureMaps.Clear();
header.LowerNodes.Clear();
header.UpperNodes.Clear();
header.TotalNodes.Clear();
header.BoneList.Clear();
header.LinkNodes.Clear();
Nodes.Clear();
header = null;
}
@ -206,12 +207,12 @@ namespace FirstPlugin
{
get
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}
@ -234,7 +235,7 @@ namespace FirstPlugin
}
viewport.ReloadDrawables(DrawableContainer);
LibraryGUI.Instance.LoadEditor(viewport);
LibraryGUI.LoadEditor(viewport);
viewport.Text = Text;
}
@ -249,9 +250,9 @@ namespace FirstPlugin
public List<Material> Materials = new List<Material>();
public List<string> TextureMaps = new List<string>();
public List<Node> UpperNodes = new List<Node>();
public Tuple<Node, Node> LinkNodes; //Links two nodes for some reason
public List<Node> LowerNodes = new List<Node>();
public List<Node> BoneList = new List<Node>();
public List<Tuple<Node, Node>> LinkNodes = new List<Tuple<Node, Node>>(); //Links two nodes. Possbily a mesh to bones for example
public List<Node> TotalNodes = new List<Node>();
public STSkeleton Skeleton { get; set; }
GenericModelRenderer DrawableRenderer { get; set; }
@ -287,18 +288,19 @@ namespace FirstPlugin
uint TextureMapsCount = reader.ReadUInt32();
uint TextureMapsOffset = reader.ReadUInt32();
//Seems to be a node based structure. Not %100 sure what decides which gets put into which
uint UpperLevelNodeCount = reader.ReadUInt32();
uint UpperLevelNodeOffset = reader.ReadUInt32();
uint BoneCount = reader.ReadUInt32();
uint BoneOffset = reader.ReadUInt32();
uint FirstNodeOffset = reader.ReadUInt32(); //Either an offset or the total size of section up to the node
uint LinkNodeCount = reader.ReadUInt32();
uint LinkNodeOffset = reader.ReadUInt32();
uint LowerLevelNodeCount = reader.ReadUInt32();
uint LowerLevelNodeOffset = reader.ReadUInt32();
uint TotalNodeCount = reader.ReadUInt32();
uint TotalNodeOffset = reader.ReadUInt32();
uint Padding2 = reader.ReadUInt32();
uint[] Unknowns = reader.ReadUInt32s(10);
root.Nodes.Add("Materials");
root.Nodes.Add("Root");
root.Nodes.Add("All Nodes");
long pos = reader.Position;
@ -339,14 +341,15 @@ namespace FirstPlugin
}
}
root.Nodes[0].Nodes.Add(genericMat);
root.Nodes[0].Nodes.Add(genericMat);
}
if (LowerLevelNodeCount != 0)
if (TotalNodeCount != 0)
{
for (int i = 0; i < LowerLevelNodeCount; i++)
for (int i = 0; i < TotalNodeCount; i++)
{
reader.SeekBegin(LowerLevelNodeOffset + (i * 8));
reader.SeekBegin(TotalNodeOffset + (i * 8));
string NodeName = reader.ReadNameOffset(false, typeof(uint));
uint Offset = reader.ReadUInt32();
@ -357,46 +360,121 @@ namespace FirstPlugin
Node node = new Node();
node.Name = NodeName;
node.Read(reader);
LowerNodes.Add(node);
TotalNodes.Add(node);
}
}
}
if (BoneCount != 0)
{
for (int i = 0; i < BoneCount; i++)
{
reader.SeekBegin(BoneOffset + (i * 8));
string NodeName = reader.ReadNameOffset(false, typeof(uint));
uint Offset = reader.ReadUInt32();
if (Offset != 0)
{
reader.SeekBegin(Offset);
Node node = new Node();
node.Name = NodeName;
node.Read(reader);
BoneList.Add(node); //This list is for mapping to meshes
}
}
}
foreach (var node in TotalNodes)
{
// TreeNode lowerWrapper = new TreeNode($"{node.Name}");
// root.Nodes[3].Nodes.Add(lowerWrapper);
LoadChildern(TotalNodes, node, root.Nodes[2]);
}
if (FirstNodeOffset != 0)
{
reader.SeekBegin(FirstNodeOffset);
uint NodeOffset = reader.ReadUInt32();
reader.SeekBegin(NodeOffset);
Node node = new Node();
node.Name = GetNodeName(LowerNodes, node);
node.Name = GetNodeName(TotalNodes, node);
node.Read(reader);
LoadChildern(LowerNodes, node, root);
LoadBones(TotalNodes, node, root.Nodes[1]);
}
if (LinkNodeCount != 0)
{
root.Nodes.Add("Links");
for (int i = 0; i < LinkNodeCount; i++)
{
TreeNode linkWrapper = new TreeNode($"Link {i}");
root.Nodes[3].Nodes.Add(linkWrapper);
reader.SeekBegin(LinkNodeOffset + (i * 12));
uint NodeOffset1 = reader.ReadUInt32();
uint NodeOffset2 = reader.ReadUInt32();
uint Index = reader.ReadUInt32();
reader.SeekBegin(NodeOffset1);
Node node1 = new Node();
node1.Name = GetNodeName(TotalNodes, node1);
node1.Read(reader);
reader.SeekBegin(NodeOffset2);
Node node2 = new Node();
node2.Name = GetNodeName(TotalNodes, node1);
node2.Read(reader);
// LoadChildern(TotalNodes, node1, linkWrapper);
// LoadChildern(TotalNodes, node2, linkWrapper);
LinkNodes.Add(Tuple.Create(node1, node2));
}
}
Skeleton.update();
Skeleton.reset();
}
private void LoadChildern(List<Node> NodeLookup, Node Node, TreeNode root)
{
var NewNode = SetWrapperNode(Node);
root.Nodes.Add(NewNode);
var NewNode = SetWrapperNode(Node, root);
for (int i = 0; i < Node.Children.Count; i++)
{
Node.Children[i].Name = GetNodeName(NodeLookup, Node.Children[i]);
var newChild = SetWrapperNode(Node.Children[i]);
NewNode.Nodes.Add(newChild);
var newChild = SetWrapperNode(Node.Children[i], NewNode);
LoadChildern(NodeLookup, Node.Children[i], newChild);
}
}
private TreeNode SetWrapperNode(Node Node)
private List<SubMesh> AddedMeshes = new List<SubMesh>();
private void LoadBones(List<Node> NodeLookup, Node Node, TreeNode root)
{
var NewNode = SetBoneNode(Node, root);
for (int i = 0; i < Node.Children.Count; i++)
{
Node.Children[i].Name = GetNodeName(NodeLookup, Node.Children[i]);
var newChild = SetBoneNode(Node.Children[i], NewNode);
LoadBones(NodeLookup, Node.Children[i], newChild);
}
}
private TreeNode SetBoneNode(Node Node, TreeNode parentNode)
{
if (Node.IsBone)
{
@ -420,54 +498,62 @@ namespace FirstPlugin
if (Node.IsBone)
Skeleton.bones.Add(boneNode);
parentNode.Nodes.Add(boneNode);
return boneNode;
}
else if (Node.IsMesh)
return new TreeNode(Node.Name);
}
private TreeNode SetWrapperNode(Node Node, TreeNode parentNode)
{
if (Node.IsMesh)
{
GenericRenderedObject meshNode = new GenericRenderedObject();
meshNode.ImageKey = "mesh";
meshNode.SelectedImageKey = "mesh";
List<TreeNode> MeshNodes = new List<TreeNode>();
int i = 0;
meshNode.lodMeshes = new List<GenericRenderedObject.LOD_Mesh>();
var msh = new GenericRenderedObject.LOD_Mesh();
msh.PrimitiveType = STPolygonType.Triangle;
msh.FirstVertex = 0;
msh.faces = Node.SubMeshes[0].Faces;
meshNode.vertices = Node.SubMeshes[0].Vertices;
meshNode.lodMeshes.Add(msh);
foreach (SubMesh subMesh in Node.SubMeshes)
{
if (i > 0)
{
GenericRenderedObject subMeshNode = new GenericRenderedObject();
subMeshNode.ImageKey = "mesh";
subMeshNode.SelectedImageKey = "mesh";
GenericRenderedObject subMeshNode = new GenericRenderedObject();
subMeshNode.ImageKey = "mesh";
subMeshNode.SelectedImageKey = "mesh";
subMeshNode.Checked = true;
subMeshNode.Text = $"{Node.Name} {i}";
subMeshNode.lodMeshes = new List<GenericRenderedObject.LOD_Mesh>();
var submsh = new GenericRenderedObject.LOD_Mesh();
submsh.PrimitiveType = STPolygonType.Triangle;
submsh.FirstVertex = 0;
submsh.faces = subMesh.Faces;
subMeshNode.lodMeshes.Add(submsh);
subMeshNode.lodMeshes = new List<GenericRenderedObject.LOD_Mesh>();
var submsh = new GenericRenderedObject.LOD_Mesh();
submsh.PrimitiveType = STPolygonType.Triangle;
submsh.FirstVertex = 0;
submsh.faces = subMesh.Faces;
subMeshNode.lodMeshes.Add(submsh);
subMeshNode.vertices = subMesh.Vertices;
subMeshNode.vertices = subMesh.Vertices;
//Check duplicate models being rendered
if (!AddedMeshes.Contains(subMesh))
DrawableRenderer.Meshes.Add(subMeshNode);
}
AddedMeshes.Add(subMesh);
if (i == 0)
parentNode.Nodes.Add(subMeshNode);
else
parentNode.Nodes[0].Nodes.Add(subMeshNode);
MeshNodes.Add(subMeshNode);
i++;
}
meshNode.Checked = true;
meshNode.Text = Node.Name;
DrawableRenderer.Meshes.Add(meshNode);
var FirstNode = MeshNodes[0];
MeshNodes.Clear();
return meshNode;
return FirstNode;
}
else
return new TreeNode(Node.Name);
{
var NewNode = new TreeNode(Node.Name);
parentNode.Nodes.Add(NewNode);
return NewNode;
}
}
private static string GetNodeName(List<Node> NodeLookup, Node node)
@ -558,13 +644,14 @@ namespace FirstPlugin
uint UnknownOffset = reader.ReadUInt32();
uint TexCoord0Offset = reader.ReadUInt32();
uint TexCoord1Offset = reader.ReadUInt32();
uint Unknown1Offset = reader.ReadUInt32();
uint Unknown2Offset = reader.ReadUInt32();
uint TexCoord2Offset = reader.ReadUInt32();
uint TexCoord3Offset = reader.ReadUInt32();
uint FaceOffset = reader.ReadUInt32();
uint SkinCount = reader.ReadUInt32(); //Unsure
uint Unknown = reader.ReadUInt32(); //Something related to count
uint WeightOffset = reader.ReadUInt32();
uint Unknown2 = reader.ReadUInt32();
uint Unknown2 = reader.ReadUInt32();
for (int i = 0; i < VertexCount; i++)
{
@ -588,6 +675,20 @@ namespace FirstPlugin
reader.SeekBegin(TexCoord0Offset + (i * 8));
vertex.uv0 = reader.ReadVec2();
}
if (TexCoord1Offset != 0)
{
reader.SeekBegin(TexCoord1Offset + (i * 8));
vertex.uv1 = reader.ReadVec2();
}
if (TexCoord2Offset != 0)
{
reader.SeekBegin(TexCoord2Offset + (i * 8));
vertex.uv2 = reader.ReadVec2();
}
if (TexCoord3Offset != 0)
{
reader.SeekBegin(TexCoord3Offset + (i * 8));
}
}
reader.SeekBegin(FaceOffset);

View File

@ -69,11 +69,11 @@ namespace FirstPlugin
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -113,7 +113,7 @@ namespace FirstPlugin
MethodInfo method = objectType.GetMethod("OpenForm");
var form = (STForm)method.Invoke(fileFormat, new object[0]);
form.Text = text;
LibraryGUI.Instance.CreateMdiWindow(form, true);
LibraryGUI.CreateMdiWindow(form, true);
HasEditorActive = true;
}
@ -126,7 +126,7 @@ namespace FirstPlugin
//ObjectEditor is for treenode types. Editors will be on the right side, treenodes on the left
ObjectEditor editor = new ObjectEditor((IFileFormat)fileFormat);
editor.Text = text;
LibraryGUI.Instance.CreateMdiWindow(editor, true);
LibraryGUI.CreateMdiWindow(editor, true);
}
}

View File

@ -119,12 +119,12 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -300,12 +300,12 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
@ -372,12 +372,12 @@ namespace FirstPlugin
}
public override void OnClick(TreeView treeview)
{
ShaderBinaryDisplay editor = (ShaderBinaryDisplay)LibraryGUI.Instance.GetActiveContent(typeof(ShaderBinaryDisplay));
ShaderBinaryDisplay editor = (ShaderBinaryDisplay)LibraryGUI.GetActiveContent(typeof(ShaderBinaryDisplay));
if (editor == null)
{
editor = new ShaderBinaryDisplay();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -166,12 +166,12 @@ namespace FirstPlugin
{
bool IsSuccess = TryDecompileBinary();
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -147,11 +147,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
ShaderEditor editor = (ShaderEditor)LibraryGUI.Instance.GetActiveContent(typeof(ShaderEditor));
ShaderEditor editor = (ShaderEditor)LibraryGUI.GetActiveContent(typeof(ShaderEditor));
if (editor == null)
{
editor = new ShaderEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
@ -234,11 +234,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -189,11 +189,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
ShaderEditor editor = (ShaderEditor)LibraryGUI.Instance.GetActiveContent(typeof(ShaderEditor));
ShaderEditor editor = (ShaderEditor)LibraryGUI.GetActiveContent(typeof(ShaderEditor));
if (editor == null)
{
editor = new ShaderEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
@ -245,11 +245,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -78,11 +78,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
ShaderEditor editor = (ShaderEditor)LibraryGUI.Instance.GetActiveContent(typeof(ShaderEditor));
ShaderEditor editor = (ShaderEditor)LibraryGUI.GetActiveContent(typeof(ShaderEditor));
if (editor == null)
{
editor = new ShaderEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;

View File

@ -409,7 +409,7 @@ namespace FirstPlugin
IsEdited = true;
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{

View File

@ -302,7 +302,7 @@ namespace FirstPlugin
bflim.ImageData = ftex.texture.Data;
var form = new GenericEditorForm(false, bflim.OpenForm());
LibraryGUI.Instance.CreateMdiWindow(form);
LibraryGUI.CreateMdiWindow(form);
bflim.UpdateForm();
}
@ -593,7 +593,7 @@ namespace FirstPlugin
IsEdited = true;
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{

View File

@ -85,7 +85,7 @@ namespace FirstPlugin
ObjectEditor editor = new ObjectEditor(bntx);
editor.Text = "Untitled-" + 0;
LibraryGUI.Instance.CreateMdiWindow(editor);
LibraryGUI.CreateMdiWindow(editor);
}
private void Export(object sender, EventArgs args)
@ -437,7 +437,7 @@ namespace FirstPlugin
{
Nodes.Remove(textureData);
Textures.Remove(textureData.Text);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public override UserControl GetEditor()
@ -461,11 +461,11 @@ namespace FirstPlugin
return;
}
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -601,7 +601,7 @@ namespace FirstPlugin
Nodes.Add(setting.textureData);
Textures.Add(setting.textureData.Text, setting.textureData);
setting.textureData.LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
else
{
@ -1261,7 +1261,7 @@ namespace FirstPlugin
private bool IsEditorActive()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
return false;
else
@ -1276,12 +1276,12 @@ namespace FirstPlugin
return;
}
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
if (Texture.UserData != null)
{
@ -1409,7 +1409,7 @@ namespace FirstPlugin
}
private void UpdateTextureMapping()
{
var viewport = LibraryGUI.Instance.GetActiveViewport();
var viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
@ -1480,7 +1480,7 @@ namespace FirstPlugin
Texture.TextureData[ArrayLevel][0] = combinedMips;
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{

View File

@ -405,11 +405,11 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
HexEditor editor = (HexEditor)LibraryGUI.Instance.GetActiveContent(typeof(HexEditor));
HexEditor editor = (HexEditor)LibraryGUI.GetActiveContent(typeof(HexEditor));
if (editor == null)
{
editor = new HexEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -651,7 +651,7 @@ namespace FirstPlugin
ApplySurface(NewSurface);
IsEdited = true;
LoadOpenGLTexture();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
catch (Exception ex)
{
@ -735,7 +735,7 @@ namespace FirstPlugin
MipCount = surface.numMips;
ArrayCount = surface.numArray;
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor != null)
UpdateEditor();
@ -748,13 +748,13 @@ namespace FirstPlugin
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
var tex = FTEX.FromGx2Surface(surface, Text);

View File

@ -183,12 +183,12 @@ namespace FirstPlugin
private void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
Properties prop = new Properties();

View File

@ -149,12 +149,12 @@ namespace FirstPlugin
private void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
Properties prop = new Properties();

View File

@ -153,13 +153,13 @@ namespace FirstPlugin
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadProperties(properties);

View File

@ -470,13 +470,13 @@ namespace FirstPlugin
}
public void UpdateEditor()
{
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.Instance.GetActiveContent(typeof(ImageEditorBase));
ImageEditorBase editor = (ImageEditorBase)LibraryGUI.GetActiveContent(typeof(ImageEditorBase));
if (editor == null)
{
editor = new ImageEditorBase();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.LoadImage(this);

View File

@ -79,7 +79,7 @@ namespace FirstPlugin
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void UpdateTextureMaps()
@ -96,7 +96,7 @@ namespace FirstPlugin
}
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public ShaderProgram defaultShaderProgram;

View File

@ -844,7 +844,7 @@ namespace FirstPlugin
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
Loaded = true;
}
@ -865,7 +865,7 @@ namespace FirstPlugin
}
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void UpdateTextureMaps()
{

View File

@ -87,7 +87,7 @@ namespace FirstPlugin
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void UpdateTextureMaps()
@ -95,7 +95,7 @@ namespace FirstPlugin
if (!Runtime.OpenTKInitialized)
return;
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public ShaderProgram defaultShaderProgram;

View File

@ -63,12 +63,12 @@ namespace FirstPlugin.Forms
if (!Runtime.UseOpenGL || !DisplayViewport)
return null;
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}

View File

@ -63,12 +63,12 @@ namespace FirstPlugin.Forms
if (!Runtime.UseOpenGL || !DisplayViewport)
return null;
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
return editor.GetViewport();
}
set
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
editor.LoadViewport(value);
}
}

View File

@ -244,7 +244,7 @@ namespace FirstPlugin.Forms
private void chkboxVisible_CheckedChanged(object sender, EventArgs e)
{
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void textureRefListView_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -216,7 +216,7 @@ namespace FirstPlugin.Forms
ActiveMatTexture.magFilter = 0;
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void textureRefListView_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -170,7 +170,7 @@ namespace FirstPlugin
materialIndexUD.Value = materialComboBox1.SelectedIndex;
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void ReloadMaterialList()
@ -201,7 +201,7 @@ namespace FirstPlugin
boneIndexUD.Value = bonesCB.SelectedIndex;
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void valueUD_ValueChanged(object sender, EventArgs e)
@ -265,7 +265,7 @@ namespace FirstPlugin
{
activeShape.DisplayLODIndex = lodDisplayCB.SelectedIndex;
activeShape.UpdateVertexData();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}

View File

@ -193,7 +193,7 @@ namespace FirstPlugin
// for (int s = 0; s < Model.shapes.Count; s++)
// Model.shapes[s].TransformBindedBone(activeBone.Text);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void stDropDownPanel1_Load(object sender, EventArgs e)
@ -217,7 +217,7 @@ namespace FirstPlugin
SetBoneTransform(activeBone);
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void boneInfoPanel1_Load(object sender, EventArgs e)

View File

@ -44,7 +44,7 @@ namespace FirstPlugin
}
private void visibleChk_CheckedChanged(object sender, EventArgs e) {
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}
}

View File

@ -106,7 +106,7 @@ namespace FirstPlugin.Forms
ActiveMatTexture.magFilter = 0;
}
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
private void stTextBox2_TextChanged(object sender, EventArgs e)

View File

@ -228,7 +228,7 @@ namespace FirstPlugin
if (editor == null)
{
editor = new ObjectEditor();
LibraryGUI.Instance.CreateMdiWindow(editor);
LibraryGUI.CreateMdiWindow(editor);
}
if (MainCostume == null && bfresFiles.Count > 0)
@ -244,7 +244,7 @@ namespace FirstPlugin
private void FrameBfres()
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
bfresEditor.FrameCamera(MainCostume.BFRESRender);
MainCostume = null;
@ -252,7 +252,7 @@ namespace FirstPlugin
private void DiableLoadCheck()
{
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.Instance.GetActiveContent(typeof(BfresEditor));
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
bfresEditor.IsLoaded = false;
bfresEditor.DisplayAllDDrawables();
}
@ -336,9 +336,10 @@ namespace FirstPlugin
Formats.Add(typeof(ME01));
Formats.Add(typeof(LM2_DICT));
Formats.Add(typeof(GMX));
// Formats.Add(typeof(GCDisk));
// Formats.Add(typeof(TPL));
// Formats.Add(typeof(GFA));
Formats.Add(typeof(BMD));
Formats.Add(typeof(GCDisk));
Formats.Add(typeof(TPL));
// Formats.Add(typeof(GFA));
//Unfinished wip formats not ready for use
if (Runtime.DEVELOPER_DEBUG_MODE)

View File

@ -40,7 +40,7 @@ namespace FirstPlugin.NodeWrappers
public override void Delete()
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor != null)
{
editor.RemoveFile(this);

View File

@ -140,6 +140,10 @@
<Reference Include="SharpYaml">
<HintPath>..\Toolbox\Lib\SharpYaml.dll</HintPath>
</Reference>
<Reference Include="SuperBMDLib">
<HintPath>..\Toolbox\Lib\SuperBMDLib.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Syroot.BinaryData">
<HintPath>..\Toolbox\Lib\Syroot.BinaryData.dll</HintPath>
<Private>False</Private>
@ -238,13 +242,16 @@
<Compile Include="FileFormats\BFRES\gfxEnum.cs" />
<Compile Include="FileFormats\BFRES\GLEnumConverter.cs" />
<Compile Include="FileFormats\Bin\KartParts.cs" />
<Compile Include="FileFormats\BMD\BMD.cs" />
<Compile Include="FileFormats\BMD\BMDShapeWrapper.cs" />
<Compile Include="FileFormats\BMD\BMDTextureWrapper.cs" />
<Compile Include="FileFormats\Collision\KclFile.cs" />
<Compile Include="FileFormats\Effects\EFCF.cs" />
<Compile Include="FileFormats\Effects\PTCL_3DS.cs" />
<Compile Include="FileFormats\Effects\PTCL_WiiU.cs" />
<Compile Include="FileFormats\Font\BFFNT.cs" />
<Compile Include="FileFormats\Audio\Archives\BFGRP.cs" />
<Compile Include="FileFormats\Gamecube\TPL.cs" />
<Compile Include="FileFormats\Texture\TPL.cs" />
<Compile Include="FileFormats\Rom\GCDisk.cs" />
<Compile Include="libWiiSharp\TPL.cs" />
<Compile Include="FileFormats\GFBMDL\GFBMDL.cs" />
@ -1283,7 +1290,6 @@
<None Include="Resources\ViewportIconDisable.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="FileFormats\BMD\" />
<Folder Include="FileFormats\EvemtFlow\" />
</ItemGroup>
<ItemGroup>

View File

@ -47,11 +47,11 @@ namespace Switch_Toolbox.Library
var Editor = GetEditor();
Editor.Dock = DockStyle.Fill;
var ActiveEditor = LibraryGUI.Instance.GetActiveContent(Editor.GetType());
var ActiveEditor = LibraryGUI.GetActiveContent(Editor.GetType());
if (ActiveEditor != null)
Editor = ActiveEditor;
else
LibraryGUI.Instance.LoadEditor(Editor);
LibraryGUI.LoadEditor(Editor);
FillEditor(Editor);
}
@ -68,7 +68,7 @@ namespace Switch_Toolbox.Library
private void Delete(object sender, EventArgs args)
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor != null)
{
editor.RemoveFile(this);

View File

@ -86,7 +86,7 @@ namespace Switch_Toolbox.Library
public void ResetModels()
{
var viewport = LibraryGUI.Instance.GetActiveViewport();
var viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
if (viewport.scene == null)
@ -232,7 +232,7 @@ namespace Switch_Toolbox.Library
if (IsDisposed)
return;
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
@ -306,7 +306,7 @@ namespace Switch_Toolbox.Library
if (currentAnimation == null)
return;
var viewport = LibraryGUI.Instance.GetActiveViewport();
var viewport = LibraryGUI.GetActiveViewport();
if (viewport == null || viewport.scene == null)
return;
@ -383,7 +383,7 @@ namespace Switch_Toolbox.Library
private void AnimationPanel_Load(object sender, EventArgs e)
{
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport != null)
{
if (viewport.GL_ControlLegacy != null)

View File

@ -390,7 +390,7 @@ namespace Switch_Toolbox.Library.Forms
if (image != null)
{
{/*
if (ChannelIndex == 1)
BitmapExtension.SetChannel(image, STChannelType.Red, STChannelType.Red, STChannelType.Red, STChannelType.One);
else if (ChannelIndex == 2)
@ -425,7 +425,7 @@ namespace Switch_Toolbox.Library.Forms
BitmapExtension.SetChannel(image, STChannelType.Red, STChannelType.Green, STChannelType.Blue, AlphaDisplay);
}
}
}
}*/
DecodeProcessFinished = true;

View File

@ -87,7 +87,7 @@ namespace Switch_Toolbox.Library.Forms
private void OnPropertyEditorChanged()
{
imageEditor.UpdateMipDisplay();
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void UpdateProperties()

View File

@ -125,7 +125,7 @@ namespace Switch_Toolbox.Library.Forms
public static List<DrawableContainer> GetDrawableContainers()
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor == null)
return new List<DrawableContainer>();
@ -134,7 +134,7 @@ namespace Switch_Toolbox.Library.Forms
public static void AddContainer(DrawableContainer drawable)
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor == null)
return;
@ -143,7 +143,7 @@ namespace Switch_Toolbox.Library.Forms
public static void RemoveContainer(DrawableContainer drawable)
{
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor == null)
return;
@ -173,7 +173,7 @@ namespace Switch_Toolbox.Library.Forms
private void ObjectEditor_FormClosed(object sender, FormClosedEventArgs e)
{
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport != null)
viewport.FormClosing();

View File

@ -179,7 +179,7 @@ namespace Switch_Toolbox.Library.Forms
//Check if it is renderable for updating the viewport
if (IsRenderable(node))
{
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
RenderedObjectWasSelected = true;
}
else
@ -188,7 +188,7 @@ namespace Switch_Toolbox.Library.Forms
//This will disable selection view and other things
if (RenderedObjectWasSelected)
{
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
RenderedObjectWasSelected = false;
}
}
@ -271,7 +271,7 @@ namespace Switch_Toolbox.Library.Forms
{
if (Node is Animation)
{
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
@ -323,9 +323,9 @@ namespace Switch_Toolbox.Library.Forms
}
}
if (LibraryGUI.Instance.GetAnimationPanel() != null)
if (LibraryGUI.GetAnimationPanel() != null)
{
LibraryGUI.Instance.GetAnimationPanel().CurrentAnimation = running;
LibraryGUI.GetAnimationPanel().CurrentAnimation = running;
}
}
}
@ -370,7 +370,7 @@ namespace Switch_Toolbox.Library.Forms
if (UpdateViewport)
{
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
}

View File

@ -31,7 +31,7 @@ namespace Switch_Toolbox.Library
private void selectItem(object sender, TreeNodeMouseClickEventArgs e)
{
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
@ -85,10 +85,10 @@ namespace Switch_Toolbox.Library
}
}
if (LibraryGUI.Instance.GetAnimationPanel() != null)
if (LibraryGUI.GetAnimationPanel() != null)
{
Console.WriteLine("running" + running.Text);
LibraryGUI.Instance.GetAnimationPanel().CurrentAnimation = running;
LibraryGUI.GetAnimationPanel().CurrentAnimation = running;
}
}
}
@ -158,7 +158,7 @@ namespace Switch_Toolbox.Library
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
if (e.Node is STGenericModel)
{

View File

@ -352,7 +352,7 @@ namespace Switch_Toolbox.Library
private void resetPoseToolStripMenuItem_Click(object sender, EventArgs e)
{
var animationPanel1 = LibraryGUI.Instance.GetAnimationPanel();
var animationPanel1 = LibraryGUI.GetAnimationPanel();
if (animationPanel1 != null)
{

View File

@ -16,13 +16,7 @@ namespace Switch_Toolbox.Library
{
public class LibraryGUI
{
private static LibraryGUI _instance;
public static LibraryGUI Instance { get { return _instance == null ? _instance = new LibraryGUI() : _instance; } }
public List<EditableObject> editableObjects = new List<EditableObject>();
public Viewport GetActiveViewport()
public static Viewport GetActiveViewport()
{
var viewport = GetActiveContent();
@ -42,7 +36,7 @@ namespace Switch_Toolbox.Library
return null;
}
public AnimationPanel GetAnimationPanel()
public static AnimationPanel GetAnimationPanel()
{
var editor = GetActiveContent();
if (editor != null && editor is IViewportContainer)
@ -52,24 +46,24 @@ namespace Switch_Toolbox.Library
return null;
}
public void UpdateViewport()
public static void UpdateViewport()
{
Viewport viewport = GetActiveViewport();
if (viewport != null)
viewport.UpdateViewport();
}
public Form GetActiveForm()
public static Form GetActiveForm()
{
return Runtime.MainForm.ActiveMdiChild;
}
public void CreateMdiWindow(STForm form, bool Show = true)
public static void CreateMdiWindow(STForm form, bool Show = true)
{
var mainform = Application.OpenForms[0];
((IMdiContainer)mainform).AddChildContainer(form);
}
public ObjectEditor GetObjectEditor()
public static ObjectEditor GetObjectEditor()
{
if (Runtime.MainForm.ActiveMdiChild is ObjectEditor)
{
@ -77,7 +71,7 @@ namespace Switch_Toolbox.Library
}
return null;
}
public void LoadViewportEditor(Control control)
public static void LoadViewportEditor(Control control)
{
control.Dock = DockStyle.Fill;
@ -100,14 +94,14 @@ namespace Switch_Toolbox.Library
((ViewportDivider)activeContent).editorPanel.Controls.Add(control);
}
}
public void LoadEditor(Control control)
public static void LoadEditor(Control control)
{
if (Runtime.MainForm.ActiveMdiChild is ObjectEditor)
{
((ObjectEditor)Runtime.MainForm.ActiveMdiChild).LoadEditor(control);
}
}
public UserControl GetActiveContent(Type type = null)
public static UserControl GetActiveContent(Type type = null)
{
if (Runtime.MainForm.ActiveMdiChild == null)
return null;
@ -154,7 +148,7 @@ namespace Switch_Toolbox.Library
}
return null;
}
public void LoadViewport(Viewport viewport)
public static void LoadViewport(Viewport viewport)
{
}

View File

@ -308,7 +308,7 @@ namespace Switch_Toolbox.Library
{ TEX_FORMAT.D24_UNORM_S8_UINT, new FormatInfo(4, 1, 1, 1, TargetBuffer.Depth) },
{ TEX_FORMAT.D32_FLOAT, new FormatInfo(4, 1, 1, 1, TargetBuffer.Depth) },
{ TEX_FORMAT.D32_FLOAT_S8X24_UINT, new FormatInfo(8, 1, 1, 1,TargetBuffer.DepthStencil) }
};
};
/// <summary>
/// A Surface contains mip levels of compressed/uncompressed texture data
@ -371,6 +371,8 @@ namespace Switch_Toolbox.Library
uint width = Math.Max(1, Width >> MipLevel);
uint height = Math.Max(1, Height >> MipLevel);
byte[] data = GetImageData(ArrayLevel, MipLevel);
if (data.Length == 0)
return new Bitmap(1,1);
try
{
@ -614,41 +616,47 @@ namespace Switch_Toolbox.Library
astc.Load(new FileStream(path, FileMode.Open));
}
public override string ExportFilter
{
get
{
if (IsAtscFormat(Format))
{
return "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff;*.astc|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"ASTC |*.astc|" +
"All files(*.*)|*.*";
}
else
{
return "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
}
}
}
public void ExportImage()
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = "dds";
if (IsAtscFormat(Format))
{
sfd.DefaultExt = "astc";
sfd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff;*.astc|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"ASTC |*.astc|" +
"All files(*.*)|*.*";
}
else
{
sfd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
}
sfd.Filter = ExportFilter;
if (sfd.ShowDialog() == DialogResult.OK)
{
Export(sfd.FileName);
}
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
{
@ -965,7 +973,7 @@ namespace Switch_Toolbox.Library
{
DisposeRenderable();
var editor = LibraryGUI.Instance.GetObjectEditor();
var editor = LibraryGUI.GetObjectEditor();
if (editor != null)
{
editor.RemoveFile(this);

View File

@ -261,11 +261,11 @@ namespace Switch_Toolbox.Library
public override void OnClick(TreeView treeView)
{
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -454,11 +454,11 @@ namespace Switch_Toolbox.Library
public override void OnClick(TreeView treeView)
{
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.Instance.GetActiveContent(typeof(STPropertyGrid));
STPropertyGrid editor = (STPropertyGrid)LibraryGUI.GetActiveContent(typeof(STPropertyGrid));
if (editor == null)
{
editor = new STPropertyGrid();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -618,11 +618,11 @@ namespace Switch_Toolbox.Library
private void OpenTextEditorAction(object sender, EventArgs args)
{
TextEditor editor = (TextEditor)LibraryGUI.Instance.GetActiveContent(typeof(TextEditor));
TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));
if (editor == null)
{
editor = new TextEditor();
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
editor.Dock = DockStyle.Fill;
@ -683,7 +683,7 @@ namespace Switch_Toolbox.Library
UserControl form = GetEditorForm(fileFormat);
form.Text = (((IFileFormat)fileFormat).FileName);
var parentForm = LibraryGUI.Instance.GetActiveForm();
var parentForm = LibraryGUI.GetActiveForm();
GenericEditorForm editorForm = new GenericEditorForm(true, form);
editorForm.FormClosing += (sender, e) => FormClosing(sender, e, fileFormat);
@ -723,12 +723,12 @@ namespace Switch_Toolbox.Library
public void UpdateEditor()
{
ArchiveFilePanel editor = (ArchiveFilePanel)LibraryGUI.Instance.GetActiveContent(typeof(ArchiveFilePanel));
ArchiveFilePanel editor = (ArchiveFilePanel)LibraryGUI.GetActiveContent(typeof(ArchiveFilePanel));
if (editor == null)
{
editor = new ArchiveFilePanel();
editor.Dock = DockStyle.Fill;
LibraryGUI.Instance.LoadEditor(editor);
LibraryGUI.LoadEditor(editor);
}
editor.LoadFile(ArchiveFileInfo);

View File

@ -99,7 +99,7 @@ namespace Switch_Toolbox.Library.Rendering
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
GL.BufferData<int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw);
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public void UpdateTextureMaps()
@ -107,7 +107,7 @@ namespace Switch_Toolbox.Library.Rendering
if (!Runtime.OpenTKInitialized)
return;
LibraryGUI.Instance.UpdateViewport();
LibraryGUI.UpdateViewport();
}
public ShaderProgram defaultShaderProgram;
@ -216,7 +216,13 @@ namespace Switch_Toolbox.Library.Rendering
private static void SetUniforms(STGenericMaterial mat, ShaderProgram shader, STGenericObject m)
{
//UV Scale
shader.SetFloat("ColorUVScaleU", 1);
shader.SetFloat("ColorUVScaleV", 1);
//UV Translate
shader.SetFloat("ColorUVTranslateU", 0);
shader.SetFloat("ColorUVTranslateV", 0);
}
private static void SetUniformData(STGenericMaterial mat, ShaderProgram shader, string propertyName)

View File

@ -722,6 +722,7 @@
<Compile Include="STToolStipMenuItem.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Swizzling\Decode_Gamecube.cs" />
<Compile Include="Swizzling\Swizzle_3DS.cs" />
<Compile Include="Swizzling\GX2.cs" />
<Compile Include="Swizzling\NewSwizzleCodeBackup.cs" />

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Switch_Toolbox
{
public class Decode_Gamecube
{
}
}

View File

@ -211,7 +211,7 @@ namespace Toolbox
if (IsStartup)
return;
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;
@ -305,7 +305,7 @@ namespace Toolbox
if (IsStartup)
return;
Viewport viewport = LibraryGUI.Instance.GetActiveViewport();
Viewport viewport = LibraryGUI.GetActiveViewport();
if (viewport == null)
return;

Binary file not shown.

BIN
Toolbox/Lib/SuperBMDLib.dll Normal file

Binary file not shown.

BIN
Toolbox/Lib/SuperBMDLib.pdb Normal file

Binary file not shown.

View File

@ -275,7 +275,7 @@ namespace Toolbox
SetFormatSettings((IFileFormat)file);
//Check for active object editors
Form editor = (Form)LibraryGUI.Instance.GetActiveForm();
Form editor = (Form)LibraryGUI.GetActiveForm();
bool useActiveEditor = false;
@ -956,9 +956,9 @@ namespace Toolbox
private void ResetAnimPanel()
{
if (LibraryGUI.Instance.GetAnimationPanel() != null)
if (LibraryGUI.GetAnimationPanel() != null)
{
LibraryGUI.Instance.GetAnimationPanel().CurrentAnimation = null;
LibraryGUI.GetAnimationPanel().CurrentAnimation = null;
}
}

View File

@ -364,6 +364,9 @@
<Content Include="Lib\EditorCoreCommon.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\EndianBinaryStreams.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\Extensions.Data.xxHash.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -459,6 +462,9 @@
<Content Include="Lib\SharpYaml.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\SuperBMDLib.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\Syroot.BinaryData.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>