More fixes

Update 3ds ptcl.
Update 3ds ptcl for the new UI
Sharc supports SHIFT JIS encoding
Fix build errors
This commit is contained in:
KillzXGaming 2019-08-25 21:11:10 -04:00
parent 27abdb52fb
commit 677de2c525
8 changed files with 70 additions and 10 deletions

View file

@ -215,10 +215,10 @@ namespace FirstPlugin
public override void OnClick(TreeView treeview)
{
EmitterEditor editor = (EmitterEditor)LibraryGUI.GetActiveContent(typeof(EmitterEditor));
EmitterEditorNX editor = (EmitterEditorNX)LibraryGUI.GetActiveContent(typeof(EmitterEditorNX));
if (editor == null)
{
editor = new EmitterEditor();
editor = new EmitterEditorNX();
LibraryGUI.LoadEditor(editor);
}
editor.Text = Text;
@ -280,6 +280,21 @@ namespace FirstPlugin
reader.Seek(pos + 1072, SeekOrigin.Begin);
}
Color0KeyCount = 8;
Alpha0KeyCount = 8;
Color1KeyCount = 8;
Alpha1KeyCount = 8;
Color0Type = ColorType.Random;
Color1Type = ColorType.Random;
Alpha0Type = ColorType.Random;
Alpha1Type = ColorType.Random;
Color0Array = new STColor[8];
Color1Array = new STColor[8];
Color0AlphaArray = new STColor[8];
Color1AlphaArray = new STColor[8];
ColorPosition = reader.Position;
for (int i = 0; i < 8; i++)
{
@ -287,7 +302,12 @@ namespace FirstPlugin
clr.R = reader.ReadSingle();
clr.G = reader.ReadSingle();
clr.B = reader.ReadSingle();
clr.A = reader.ReadSingle();
float A = reader.ReadSingle();
STColor alpha = new STColor();
alpha.R = A;
alpha.G = A;
alpha.B = A;
Color0AlphaArray[i] = alpha;
Color0Array[i] = clr;
}
for (int i = 0; i < 8; i++)
@ -296,7 +316,12 @@ namespace FirstPlugin
clr.R = reader.ReadSingle();
clr.G = reader.ReadSingle();
clr.B = reader.ReadSingle();
clr.A = reader.ReadSingle();
float A = reader.ReadSingle();
STColor alpha = new STColor();
alpha.R = A;
alpha.G = A;
alpha.B = A;
Color1AlphaArray[i] = alpha;
Color1Array[i] = clr;
}
}
@ -334,7 +359,7 @@ namespace FirstPlugin
int size = data.Length;
FTEX ftex = new FTEX();
ftex.ReplaceTexture(FileName, Format, MipCount, SupportedFormats, true, true, true);
ftex.ReplaceTexture(FileName, Format, MipCount, 0, SupportedFormats, true, true, true);
if (ftex.texture != null)
{
byte[] ImageData = ftex.texture.Data;

View file

@ -342,7 +342,7 @@ namespace FirstPlugin
int size = data.Length;
FTEX ftex = new FTEX();
ftex.ReplaceTexture(FileName, Format, MipCount, SupportedFormats, true, true, true);
ftex.ReplaceTexture(FileName, Format, MipCount,0, SupportedFormats, true, true, true);
if (ftex.texture != null)
{
byte[] ImageData = ftex.texture.Data;

View file

@ -379,7 +379,7 @@ namespace FirstPlugin
public override void Replace(string FileName)
{
Bfres.Structs.FTEX ftex = new Bfres.Structs.FTEX();
ftex.ReplaceTexture(FileName, Format, 1, SupportedFormats, true, true, false);
ftex.ReplaceTexture(FileName, Format, 1, 0, SupportedFormats, true, true, false);
if (ftex.texture != null)
{
TextureTGLP.Format = (ushort)ConvertToGx2(ftex.Format);

View file

@ -72,6 +72,11 @@ namespace FirstPlugin
header.Write(new FileWriter(stream));
}
public bool HasLabels
{
get { return header.Label1.Labels.Count > 0; }
}
public class Header
{
public ushort ByteOrderMark;
@ -90,6 +95,10 @@ namespace FirstPlugin
public void Read(FileReader reader)
{
Label1 = new LBL1();
NLI1 = new NLI1();
Text2 = new TXT2();
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
reader.ReadSignature(8, "MsgStdBn");
ByteOrderMark = reader.ReadUInt16();

View file

@ -258,7 +258,7 @@ namespace FirstPlugin
Text = reader.ReadString((int)FileNameLength);
// Code = reader.ReadString((int)CodeLength, Encoding.UTF32);
byte[] CodeData = reader.ReadBytes((int)CodeLength);
Code = Encoding.Unicode.GetString(Encoding.Convert(Encoding.Default, Encoding.Unicode, CodeData));
Code = Encoding.GetEncoding(932).GetString(CodeData);
reader.Seek(SectioSize + pos, System.IO.SeekOrigin.Begin);
}

View file

@ -158,7 +158,7 @@ namespace FirstPlugin
if (ofd.ShowDialog() == DialogResult.OK)
{
FTEX ftex = new FTEX();
ftex.ReplaceTexture(ofd.FileName, Format, 1, SupportedFormats, true, true, false);
ftex.ReplaceTexture(ofd.FileName, Format, 1, 0, SupportedFormats, true, true, false);
if (ftex.texture != null)
{
image.BCLIMFormat = ConvertFormatGenericToBflim(ftex.Format);

View file

@ -44,7 +44,7 @@ namespace FirstPlugin.Forms
if (msbt.header.Text2 != null)
{
if (ShowLabels)
if (ShowLabels && msbt.HasLabels)
{
foreach (var lbl in msbt.header.Label1.Labels)
{

View file

@ -8,11 +8,37 @@ using Toolbox.Library.Security.Cryptography;
using System.Runtime.InteropServices;
using Syroot.BinaryData;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
namespace Toolbox.Library.IO
{
public static class IOExtensions
{
public static byte[] DeserializeToBytes<T>(this T structure) where T : struct
{
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(stream, structure);
stream.Flush();
stream.Seek(0, SeekOrigin.Begin);
return stream.ToArray();
}
}
public static T SerializeToStruct<T>(this byte[] buffer) where T : struct
{
using (MemoryStream stream = new MemoryStream(buffer))
{
BinaryFormatter bf = new BinaryFormatter();
var data = bf.Deserialize(stream);
return (T)data;
}
}
//Structs can be a bit faster and more memory efficent
//From https://github.com/IcySon55/Kuriimu/blob/master/src/Kontract/IO/Extensions.cs
//Read
public static unsafe T BytesToStruct<T>(this byte[] buffer, bool isBigEndian = false, int offset = 0)