mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 15:14:55 +00:00
Some fixes
Fixed some byaml editor issues with applying changes. Fixed some editors updating within iarchives if files are switched. Fixed l8 textures displaying wrong.
This commit is contained in:
parent
e76d0c4c48
commit
4e63b2f5a4
10 changed files with 59 additions and 6 deletions
|
@ -118,6 +118,8 @@ namespace FirstPlugin
|
|||
CanSave = true;
|
||||
IFileInfo.UseEditMenu = true;
|
||||
|
||||
PluginRuntime.SarcArchives.Add(this);
|
||||
|
||||
var SzsFiles = SARCExt.SARC.UnpackRamN(stream);
|
||||
sarcData = new SarcData();
|
||||
sarcData.HashOnly = SzsFiles.HashOnly;
|
||||
|
@ -223,6 +225,9 @@ namespace FirstPlugin
|
|||
|
||||
files.Clear();
|
||||
|
||||
if (PluginRuntime.SarcArchives.Contains(this))
|
||||
PluginRuntime.SarcArchives.Remove(this);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -162,15 +162,22 @@ namespace FirstPlugin
|
|||
|
||||
public ByamlEditor OpenForm()
|
||||
{
|
||||
ByamlEditor editor = new ByamlEditor(data.RootNode, data.SupportPaths, data.Version, data.byteOrder, IsDialog, this);
|
||||
ByamlEditor editor = new ByamlEditor();
|
||||
editor.FileFormat = this;
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void UpdateByamlRoot(dynamic root)
|
||||
{
|
||||
if (data != null)
|
||||
data.RootNode = root;
|
||||
}
|
||||
|
||||
public void FillEditor(UserControl control)
|
||||
{
|
||||
((ByamlEditor)control).UpdateByaml(data.RootNode, data.SupportPaths, data.Version, data.byteOrder, IsDialog, this);
|
||||
}
|
||||
|
||||
public void Load(Stream stream)
|
||||
|
|
|
@ -48,7 +48,6 @@ namespace FirstPlugin
|
|||
BffntEditor form = new BffntEditor();
|
||||
form.Text = "BFFNT Editor";
|
||||
form.Dock = DockStyle.Fill;
|
||||
form.LoadFontFile(this);
|
||||
return form;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ namespace FirstPlugin
|
|||
public MSBTEditor OpenForm()
|
||||
{
|
||||
MSBTEditor editor = new MSBTEditor();
|
||||
editor.LoadMSBT(this);
|
||||
editor.Text = FileName;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
return editor;
|
||||
|
|
|
@ -38,12 +38,33 @@ namespace FirstPlugin
|
|||
bool useMuunt = true;
|
||||
|
||||
private TextEditor xmlEditor;
|
||||
|
||||
public ByamlEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
Reload();
|
||||
}
|
||||
|
||||
public ByamlEditor(System.Collections.IEnumerable by, bool _pathSupport, ushort _ver, ByteOrder defaultOrder = ByteOrder.LittleEndian, bool IsSaveDialog = false, BYAML byaml = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
Reload();
|
||||
|
||||
UpdateByaml(by, _pathSupport, _ver, defaultOrder, IsSaveDialog, byaml);
|
||||
}
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
||||
treeView1.Nodes.Clear();
|
||||
}
|
||||
|
||||
public void UpdateByaml(System.Collections.IEnumerable by, bool _pathSupport, ushort _ver, ByteOrder defaultOrder = ByteOrder.LittleEndian, bool IsSaveDialog = false, BYAML byaml = null)
|
||||
{
|
||||
FileFormat = byaml;
|
||||
|
||||
treeView1.Nodes.Clear();
|
||||
|
||||
stTabControl1.myBackColor = FormThemes.BaseTheme.FormBackColor;
|
||||
|
||||
|
@ -646,6 +667,9 @@ namespace FirstPlugin
|
|||
byte[] TextData = Encoding.Unicode.GetBytes(xmlEditor.GetText());
|
||||
StreamReader t = new StreamReader(new MemoryStream(TextData), Encoding.GetEncoding(932));
|
||||
byml = XmlConverter.ToByml(t.ReadToEnd()).RootNode;
|
||||
|
||||
if (FileFormat != null)
|
||||
((BYAML)FileFormat).UpdateByamlRoot(byml);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace FirstPlugin
|
|||
{
|
||||
public class PluginRuntime
|
||||
{
|
||||
public static List<SARC> SarcArchives = new List<SARC>();
|
||||
|
||||
public class MaterialReplace
|
||||
{
|
||||
public static bool SwapShaderParams = true;
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace Toolbox.Library
|
|||
byte[] compSel = new byte[4] {0,1,2,3 };
|
||||
|
||||
if (format == TEX_FORMAT.L8 || format == TEX_FORMAT.LA8)
|
||||
compSel = new byte[4] { 1, 1, 1, 3 };
|
||||
compSel = new byte[4] { 0, 0, 0, 1 };
|
||||
|
||||
|
||||
for (int Y = 0; Y < height; Y++)
|
||||
|
|
|
@ -122,8 +122,15 @@ namespace Toolbox.Library
|
|||
{
|
||||
filesExtracted.Add($"{path}");
|
||||
|
||||
File.WriteAllBytes($"{path}",
|
||||
if (((ArchiveFileWrapper)file).ArchiveFileInfo.FileDataStream != null)
|
||||
{
|
||||
((ArchiveFileWrapper)file).ArchiveFileInfo.FileDataStream.ExportToFile(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
File.WriteAllBytes($"{path}",
|
||||
((ArchiveFileWrapper)file).ArchiveFileInfo.FileData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,11 @@ namespace Toolbox.Library.IO
|
|||
return Names;
|
||||
}
|
||||
|
||||
public string ReadString(int length, bool removeSpaces)
|
||||
{
|
||||
return ReadString(length).Replace("\0", string.Empty);
|
||||
}
|
||||
|
||||
public string ReadZeroTerminatedString(Encoding encoding = null)
|
||||
{
|
||||
return ReadString(BinaryStringFormat.ZeroTerminated, encoding ?? Encoding);
|
||||
|
|
|
@ -969,6 +969,7 @@ namespace Toolbox.Library
|
|||
private void OpenControlDialog(IFileFormat fileFormat)
|
||||
{
|
||||
UserControl form = GetEditorControl(fileFormat);
|
||||
|
||||
form.Text = (((IFileFormat)fileFormat).FileName);
|
||||
|
||||
var parentForm = LibraryGUI.GetActiveForm();
|
||||
|
@ -1013,7 +1014,11 @@ namespace Toolbox.Library
|
|||
if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IEditor<>))
|
||||
{
|
||||
System.Reflection.MethodInfo method = objectType.GetMethod("OpenForm");
|
||||
return (UserControl)method.Invoke(fileFormat, new object[0]);
|
||||
System.Reflection.MethodInfo methodFill = fileFormat.GetType().GetMethod("FillEditor");
|
||||
|
||||
var control = (UserControl)method.Invoke(fileFormat, new object[0]);
|
||||
methodFill.Invoke(fileFormat, new object[1] { control });
|
||||
return control;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue