cleanup code

This commit is contained in:
Perfare 2017-04-10 03:13:08 +08:00
parent a928660dd3
commit d1ec1c29a4
13 changed files with 494 additions and 581 deletions

View File

@ -7,46 +7,46 @@ namespace SevenZip.Compression.LZMA
public static class SevenZipHelper public static class SevenZipHelper
{ {
static int dictionary = 1 << 23; static int dictionary = 1 << 23;
// static Int32 posStateBits = 2; // static Int32 posStateBits = 2;
// static Int32 litContextBits = 3; // for normal files // static Int32 litContextBits = 3; // for normal files
// UInt32 litContextBits = 0; // for 32-bit data // UInt32 litContextBits = 0; // for 32-bit data
// static Int32 litPosBits = 0; // static Int32 litPosBits = 0;
// UInt32 litPosBits = 2; // for 32-bit data // UInt32 litPosBits = 2; // for 32-bit data
// static Int32 algorithm = 2; // static Int32 algorithm = 2;
// static Int32 numFastBytes = 128; // static Int32 numFastBytes = 128;
static bool eos = false; static bool eos = false;
static CoderPropID[] propIDs = static CoderPropID[] propIDs =
{ {
CoderPropID.DictionarySize, CoderPropID.DictionarySize,
CoderPropID.PosStateBits, CoderPropID.PosStateBits,
CoderPropID.LitContextBits, CoderPropID.LitContextBits,
CoderPropID.LitPosBits, CoderPropID.LitPosBits,
CoderPropID.Algorithm, CoderPropID.Algorithm,
CoderPropID.NumFastBytes, CoderPropID.NumFastBytes,
CoderPropID.MatchFinder, CoderPropID.MatchFinder,
CoderPropID.EndMarker CoderPropID.EndMarker
}; };
// these are the default properties, keeping it simple for now: // these are the default properties, keeping it simple for now:
static object[] properties = static object[] properties =
{ {
(Int32)(dictionary), (Int32)(dictionary),
(Int32)(2), (Int32)(2),
(Int32)(3), (Int32)(3),
(Int32)(0), (Int32)(0),
(Int32)(2), (Int32)(2),
(Int32)(128), (Int32)(128),
"bt4", "bt4",
eos eos
}; };
public static byte[] Compress(byte[] inputBytes) public static byte[] Compress(byte[] inputBytes)
@ -54,7 +54,7 @@ namespace SevenZip.Compression.LZMA
MemoryStream inStream = new MemoryStream(inputBytes); MemoryStream inStream = new MemoryStream(inputBytes);
MemoryStream outStream = new MemoryStream(); MemoryStream outStream = new MemoryStream();
SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder(); Encoder encoder = new Encoder();
encoder.SetCoderProperties(propIDs, properties); encoder.SetCoderProperties(propIDs, properties);
encoder.WriteCoderProperties(outStream); encoder.WriteCoderProperties(outStream);
long fileSize = inStream.Length; long fileSize = inStream.Length;
@ -68,8 +68,8 @@ namespace SevenZip.Compression.LZMA
{ {
MemoryStream newInStream = new MemoryStream(inputBytes); MemoryStream newInStream = new MemoryStream(inputBytes);
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); Decoder decoder = new Decoder();
newInStream.Seek(0, 0); newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream(); MemoryStream newOutStream = new MemoryStream();
@ -97,7 +97,7 @@ namespace SevenZip.Compression.LZMA
public static MemoryStream StreamDecompress(MemoryStream newInStream) public static MemoryStream StreamDecompress(MemoryStream newInStream)
{ {
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); Decoder decoder = new Decoder();
newInStream.Seek(0, 0); newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream(); MemoryStream newOutStream = new MemoryStream();
@ -124,7 +124,7 @@ namespace SevenZip.Compression.LZMA
public static MemoryStream StreamDecompress(MemoryStream newInStream, long outSize) public static MemoryStream StreamDecompress(MemoryStream newInStream, long outSize)
{ {
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); Decoder decoder = new Decoder();
newInStream.Seek(0, 0); newInStream.Seek(0, 0);
MemoryStream newOutStream = new MemoryStream(); MemoryStream newOutStream = new MemoryStream();

View File

@ -13,12 +13,12 @@ namespace Unity_Studio
public AboutBox() public AboutBox()
{ {
InitializeComponent(); InitializeComponent();
this.Text = String.Format("About {0}", AssemblyTitle); Text = $"About {AssemblyTitle}";
this.labelProductName.Text = AssemblyProduct; labelProductName.Text = AssemblyProduct;
this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); labelVersion.Text = $"Version {AssemblyVersion}";
this.labelCopyright.Text = AssemblyCopyright; labelCopyright.Text = AssemblyCopyright;
this.labelCompanyName.Text = AssemblyCompany; labelCompanyName.Text = AssemblyCompany;
this.textBoxDescription.Text = AssemblyDescription; textBoxDescription.Text = AssemblyDescription;
} }
#region Assembly Attribute Accessors #region Assembly Attribute Accessors
@ -40,13 +40,7 @@ namespace Unity_Studio
} }
} }
public string AssemblyVersion public string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
{
get
{
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
}
}
public string AssemblyDescription public string AssemblyDescription
{ {
@ -103,7 +97,7 @@ namespace Unity_Studio
private void okButton_Click(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e)
{ {
this.Close(); Close();
} }
} }
} }

View File

@ -27,12 +27,12 @@ namespace Unity_Studio
showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"]; showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"];
converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"]; converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"];
convertfsb.Checked = (bool)Properties.Settings.Default["convertfsb"]; convertfsb.Checked = (bool)Properties.Settings.Default["convertfsb"];
string str = Properties.Settings.Default["convertType"] as string; var str = (string)Properties.Settings.Default["convertType"];
foreach (Control c in panel1.Controls) foreach (Control c in panel1.Controls)
{ {
if (c.Text == str) if (c.Text == str)
{ {
(c as RadioButton).Checked = true; ((RadioButton)c).Checked = true;
break; break;
} }
} }
@ -57,21 +57,21 @@ namespace Unity_Studio
Properties.Settings.Default["convertfsb"] = convertfsb.Checked; Properties.Settings.Default["convertfsb"] = convertfsb.Checked;
foreach (Control c in panel1.Controls) foreach (Control c in panel1.Controls)
{ {
if ((c as RadioButton).Checked) if (((RadioButton)c).Checked)
{ {
Properties.Settings.Default["convertType"] = c.Text; Properties.Settings.Default["convertType"] = c.Text;
break; break;
} }
} }
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
this.DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
this.Close(); Close();
} }
private void fbxCancel_Click(object sender, EventArgs e) private void fbxCancel_Click(object sender, EventArgs e)
{ {
this.DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
this.Close(); Close();
} }
private void exportDeformers_CheckedChanged(object sender, EventArgs e) private void exportDeformers_CheckedChanged(object sender, EventArgs e)

View File

@ -94,23 +94,21 @@ namespace Unity_Studio
if (readSwitch) if (readSwitch)
{ {
m_AudioData = new byte[m_Size];
if (m_Source == null) if (m_Source == null)
{ {
a_Stream.Read(m_AudioData, 0, (int)m_Size); m_AudioData = a_Stream.ReadBytes((int)m_Size);
} }
else if (File.Exists(m_Source) || else if (File.Exists(m_Source) ||
File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source)))) File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source))))
{ {
BinaryReader reader = new BinaryReader(File.OpenRead(m_Source)); BinaryReader reader = new BinaryReader(File.OpenRead(m_Source));
reader.BaseStream.Position = m_Offset; reader.BaseStream.Position = m_Offset;
reader.Read(m_AudioData, 0, (int)m_Size); m_AudioData = reader.ReadBytes((int)m_Size);
reader.Close(); reader.Close();
} }
else else
{ {
EndianStream estream = null; EndianStream estream;
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out estream)) if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out estream))
{ {
estream.Position = m_Offset; estream.Position = m_Offset;

View File

@ -58,10 +58,10 @@ namespace Unity_Studio
m_Tag = a_Stream.ReadUInt16(); m_Tag = a_Stream.ReadUInt16();
m_IsActive = a_Stream.ReadBoolean(); m_IsActive = a_Stream.ReadBoolean();
base.Text = m_Name; Text = m_Name;
preloadData.Text = m_Name; preloadData.Text = m_Name;
//name should be unique //name should be unique
base.Name = uniqueID; Name = uniqueID;
} }
} }
} }

View File

@ -168,15 +168,14 @@ namespace Unity_Studio
if (File.Exists(path) || if (File.Exists(path) ||
File.Exists(path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(path)))) File.Exists(path = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(path))))
{ {
image_data = new byte[image_data_size];
BinaryReader reader = new BinaryReader(File.OpenRead(path)); BinaryReader reader = new BinaryReader(File.OpenRead(path));
reader.BaseStream.Position = offset; reader.BaseStream.Position = offset;
reader.Read(image_data, 0, image_data_size); image_data = reader.ReadBytes(image_data_size);
reader.Close(); reader.Close();
} }
else else
{ {
EndianStream estream = null; EndianStream estream;
if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(path), out estream)) if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(path), out estream))
{ {
estream.Position = offset; estream.Position = offset;
@ -186,8 +185,7 @@ namespace Unity_Studio
} }
else else
{ {
image_data = new byte[image_data_size]; image_data = a_Stream.ReadBytes(image_data_size);
a_Stream.Read(image_data, 0, image_data_size);
} }
switch (m_TextureFormat) switch (m_TextureFormat)

View File

@ -138,10 +138,7 @@ namespace Unity_Studio
{ {
return member2; return member2;
} }
else member2.Add(member);
{
member2.Add(member);
}
} }
return member2; return member2;
} }

View File

@ -1,7 +1,7 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.IO; using System.IO;
using Lz4; using Lz4;
using SevenZip.Compression.LZMA;
namespace Unity_Studio namespace Unity_Studio
{ {
@ -97,7 +97,7 @@ namespace Unity_Studio
byte[] lzmaBuffer = new byte[lzmaSize]; byte[] lzmaBuffer = new byte[lzmaSize];
b_Stream.Read(lzmaBuffer, 0, lzmaSize); b_Stream.Read(lzmaBuffer, 0, lzmaSize);
using (var lzmaStream = new EndianStream(SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(new MemoryStream(lzmaBuffer)), EndianType.BigEndian)) using (var lzmaStream = new EndianStream(SevenZipHelper.StreamDecompress(new MemoryStream(lzmaBuffer)), EndianType.BigEndian))
{ {
getFiles(lzmaStream, 0); getFiles(lzmaStream, 0);
} }
@ -166,15 +166,14 @@ namespace Unity_Studio
EndianStream blocksInfo; EndianStream blocksInfo;
switch (flag & 0x3F) switch (flag & 0x3F)
{ {
default: default://None
case 0://None
{ {
blocksInfo = new EndianStream(new MemoryStream(blocksInfoBytes), EndianType.BigEndian); blocksInfo = new EndianStream(new MemoryStream(blocksInfoBytes), EndianType.BigEndian);
break; break;
} }
case 1://LZMA case 1://LZMA
{ {
blocksInfo = new EndianStream(SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(new MemoryStream(blocksInfoBytes)), EndianType.BigEndian); blocksInfo = new EndianStream(SevenZipHelper.StreamDecompress(new MemoryStream(blocksInfoBytes)), EndianType.BigEndian);
break; break;
} }
case 2://LZ4 case 2://LZ4
@ -206,8 +205,7 @@ namespace Unity_Studio
var compressedBytes = b_Stream.ReadBytes(compressedSize); var compressedBytes = b_Stream.ReadBytes(compressedSize);
switch (flag & 0x3F) switch (flag & 0x3F)
{ {
default: default://None
case 0://None
{ {
assetsDataStream.Write(compressedBytes, 0, compressedSize); assetsDataStream.Write(compressedBytes, 0, compressedSize);
break; break;
@ -217,7 +215,7 @@ namespace Unity_Studio
var uncompressedBytes = new byte[uncompressedSize]; var uncompressedBytes = new byte[uncompressedSize];
using (var mstream = new MemoryStream(compressedBytes)) using (var mstream = new MemoryStream(compressedBytes))
{ {
var decoder = SevenZip.Compression.LZMA.SevenZipHelper.StreamDecompress(mstream, uncompressedSize); var decoder = SevenZipHelper.StreamDecompress(mstream, uncompressedSize);
decoder.Read(uncompressedBytes, 0, uncompressedSize); decoder.Read(uncompressedBytes, 0, uncompressedSize);
decoder.Dispose(); decoder.Dispose();
} }

View File

@ -20,115 +20,115 @@ namespace Unity_Studio
public EndianStream(Stream stream, EndianType endian) : base(stream) { } public EndianStream(Stream stream, EndianType endian) : base(stream) { }
public long Position { get { return base.BaseStream.Position; } set { base.BaseStream.Position = value; } } public long Position { get { return BaseStream.Position; } set { BaseStream.Position = value; } }
public override short ReadInt16() public override short ReadInt16()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a16 = base.ReadBytes(2); a16 = ReadBytes(2);
Array.Reverse(a16); Array.Reverse(a16);
return BitConverter.ToInt16(a16, 0); return BitConverter.ToInt16(a16, 0);
} }
else return base.ReadInt16(); return base.ReadInt16();
} }
public override int ReadInt32() public override int ReadInt32()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a32 = base.ReadBytes(4); a32 = ReadBytes(4);
Array.Reverse(a32); Array.Reverse(a32);
return BitConverter.ToInt32(a32, 0); return BitConverter.ToInt32(a32, 0);
} }
else return base.ReadInt32(); return base.ReadInt32();
} }
public override long ReadInt64() public override long ReadInt64()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a64 = base.ReadBytes(8); a64 = ReadBytes(8);
Array.Reverse(a64); Array.Reverse(a64);
return BitConverter.ToInt64(a64, 0); return BitConverter.ToInt64(a64, 0);
} }
else return base.ReadInt64(); return base.ReadInt64();
} }
public override ushort ReadUInt16() public override ushort ReadUInt16()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a16 = base.ReadBytes(2); a16 = ReadBytes(2);
Array.Reverse(a16); Array.Reverse(a16);
return BitConverter.ToUInt16(a16, 0); return BitConverter.ToUInt16(a16, 0);
} }
else return base.ReadUInt16(); return base.ReadUInt16();
} }
public override uint ReadUInt32() public override uint ReadUInt32()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a32 = base.ReadBytes(4); a32 = ReadBytes(4);
Array.Reverse(a32); Array.Reverse(a32);
return BitConverter.ToUInt32(a32, 0); return BitConverter.ToUInt32(a32, 0);
} }
else return base.ReadUInt32(); return base.ReadUInt32();
} }
public override ulong ReadUInt64() public override ulong ReadUInt64()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a64 = base.ReadBytes(8); a64 = ReadBytes(8);
Array.Reverse(a64); Array.Reverse(a64);
return BitConverter.ToUInt64(a64, 0); return BitConverter.ToUInt64(a64, 0);
} }
else return base.ReadUInt64(); return base.ReadUInt64();
} }
public override float ReadSingle() public override float ReadSingle()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a32 = base.ReadBytes(4); a32 = ReadBytes(4);
Array.Reverse(a32); Array.Reverse(a32);
return BitConverter.ToSingle(a32, 0); return BitConverter.ToSingle(a32, 0);
} }
else return base.ReadSingle(); return base.ReadSingle();
} }
public override double ReadDouble() public override double ReadDouble()
{ {
if (endian == EndianType.BigEndian) if (endian == EndianType.BigEndian)
{ {
a64 = base.ReadBytes(8); a64 = ReadBytes(8);
Array.Reverse(a64); Array.Reverse(a64);
return BitConverter.ToUInt64(a64, 0); return BitConverter.ToUInt64(a64, 0);
} }
else return base.ReadDouble(); return base.ReadDouble();
} }
public string ReadASCII(int length) public string ReadASCII(int length)
{ {
return Encoding.ASCII.GetString(base.ReadBytes(length)); return Encoding.ASCII.GetString(ReadBytes(length));
} }
public void AlignStream(int alignment) public void AlignStream(int alignment)
{ {
long pos = base.BaseStream.Position; long pos = BaseStream.Position;
//long padding = alignment - pos + (pos / alignment) * alignment; //long padding = alignment - pos + (pos / alignment) * alignment;
//if (padding != alignment) { base.BaseStream.Position += padding; } //if (padding != alignment) { base.BaseStream.Position += padding; }
if ((pos % alignment) != 0) { base.BaseStream.Position += alignment - (pos % alignment); } if ((pos % alignment) != 0) { BaseStream.Position += alignment - (pos % alignment); }
} }
public string ReadAlignedString(int length) public string ReadAlignedString(int length)
{ {
if (length > 0 && length < (base.BaseStream.Length - base.BaseStream.Position))//crude failsafe if (length > 0 && length < (BaseStream.Length - BaseStream.Position))//crude failsafe
{ {
byte[] stringData = new byte[length]; byte[] stringData = new byte[length];
base.Read(stringData, 0, length); Read(stringData, 0, length);
var result = Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3 var result = Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3
/*string result = ""; /*string result = "";
@ -142,7 +142,7 @@ namespace Unity_Studio
AlignStream(4); AlignStream(4);
return result; return result;
} }
else { return ""; } return "";
} }
public string ReadStringToNull() public string ReadStringToNull()

View File

@ -7,538 +7,525 @@ using System.IO;
namespace Lz4 namespace Lz4
{ {
public class Lz4DecoderStream : Stream public class Lz4DecoderStream : Stream
{ {
public Lz4DecoderStream() public Lz4DecoderStream(Stream input, long inputLength = long.MaxValue)
{ {
} Reset(input, inputLength);
}
public Lz4DecoderStream( Stream input, long inputLength = long.MaxValue ) public void Reset(Stream input, long inputLength = long.MaxValue)
{ {
Reset( input, inputLength ); this.inputLength = inputLength;
} this.input = input;
public void Reset( Stream input, long inputLength = long.MaxValue ) phase = DecodePhase.ReadToken;
{
this.inputLength = inputLength;
this.input = input;
phase = DecodePhase.ReadToken; decodeBufferPos = 0;
decodeBufferPos = 0;
litLen = 0;
matLen = 0;
matDst = 0;
inBufPos = DecBufLen; litLen = 0;
inBufEnd = DecBufLen; matLen = 0;
} matDst = 0;
public override void Close() inBufPos = DecBufLen;
{ inBufEnd = DecBufLen;
this.input = null; }
}
private long inputLength; public override void Close()
private Stream input; {
input = null;
}
//because we might not be able to match back across invocations, private long inputLength;
//we have to keep the last window's worth of bytes around for reuse private Stream input;
//we use a circular buffer for this - every time we write into this
//buffer, we also write the same into our output buffer
private const int DecBufLen = 0x10000; //because we might not be able to match back across invocations,
private const int DecBufMask = 0xFFFF; //we have to keep the last window's worth of bytes around for reuse
//we use a circular buffer for this - every time we write into this
//buffer, we also write the same into our output buffer
private const int InBufLen = 128; private const int DecBufLen = 0x10000;
private const int DecBufMask = 0xFFFF;
private byte[] decodeBuffer = new byte[DecBufLen + InBufLen]; private const int InBufLen = 128;
private int decodeBufferPos, inBufPos, inBufEnd;
//we keep track of which phase we're in so that we can jump right back private byte[] decodeBuffer = new byte[DecBufLen + InBufLen];
//into the correct part of decoding private int decodeBufferPos, inBufPos, inBufEnd;
private DecodePhase phase; //we keep track of which phase we're in so that we can jump right back
//into the correct part of decoding
private enum DecodePhase private DecodePhase phase;
{
ReadToken,
ReadExLiteralLength,
CopyLiteral,
ReadOffset,
ReadExMatchLength,
CopyMatch,
}
//state within interruptable phases and across phase boundaries is private enum DecodePhase
//kept here - again, so that we can punt out and restart freely {
ReadToken,
ReadExLiteralLength,
CopyLiteral,
ReadOffset,
ReadExMatchLength,
CopyMatch,
}
private int litLen, matLen, matDst; //state within interruptable phases and across phase boundaries is
//kept here - again, so that we can punt out and restart freely
public override int Read( byte[] buffer, int offset, int count ) private int litLen, matLen, matDst;
{
public override int Read(byte[] buffer, int offset, int count)
{
#if CHECK_ARGS #if CHECK_ARGS
if( buffer == null ) if (buffer == null)
throw new ArgumentNullException( "buffer" ); throw new ArgumentNullException("buffer");
if( offset < 0 || count < 0 || buffer.Length - count < offset ) if (offset < 0 || count < 0 || buffer.Length - count < offset)
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
if( input == null ) if (input == null)
throw new InvalidOperationException(); throw new InvalidOperationException();
#endif #endif
int nRead, nToRead = count; int nRead, nToRead = count;
var decBuf = decodeBuffer; var decBuf = decodeBuffer;
//the stringy gotos are obnoxious, but their purpose is to //the stringy gotos are obnoxious, but their purpose is to
//make it *blindingly* obvious how the state machine transitions //make it *blindingly* obvious how the state machine transitions
//back and forth as it reads - remember, we can yield out of //back and forth as it reads - remember, we can yield out of
//this routine in several places, and we must be able to re-enter //this routine in several places, and we must be able to re-enter
//and pick up where we left off! //and pick up where we left off!
#if LOCAL_SHADOW #if LOCAL_SHADOW
var phase = this.phase; var phase = this.phase;
var inBufPos = this.inBufPos; var inBufPos = this.inBufPos;
var inBufEnd = this.inBufEnd; var inBufEnd = this.inBufEnd;
#endif #endif
switch( phase ) switch (phase)
{ {
case DecodePhase.ReadToken: case DecodePhase.ReadToken:
goto readToken; goto readToken;
case DecodePhase.ReadExLiteralLength: case DecodePhase.ReadExLiteralLength:
goto readExLiteralLength; goto readExLiteralLength;
case DecodePhase.CopyLiteral: case DecodePhase.CopyLiteral:
goto copyLiteral; goto copyLiteral;
case DecodePhase.ReadOffset: case DecodePhase.ReadOffset:
goto readOffset; goto readOffset;
case DecodePhase.ReadExMatchLength: case DecodePhase.ReadExMatchLength:
goto readExMatchLength; goto readExMatchLength;
case DecodePhase.CopyMatch: case DecodePhase.CopyMatch:
goto copyMatch; goto copyMatch;
} }
readToken: readToken:
int tok; int tok;
if( inBufPos < inBufEnd ) if (inBufPos < inBufEnd)
{ {
tok = decBuf[inBufPos++]; tok = decBuf[inBufPos++];
} }
else else
{ {
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
tok = ReadByteCore(); tok = ReadByteCore();
#if LOCAL_SHADOW #if LOCAL_SHADOW
inBufPos = this.inBufPos; inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd; inBufEnd = this.inBufEnd;
#endif #endif
#if CHECK_EOF #if CHECK_EOF
if( tok == -1 ) if (tok == -1)
goto finish; goto finish;
#endif #endif
} }
litLen = tok >> 4; litLen = tok >> 4;
matLen = (tok & 0xF) + 4; matLen = (tok & 0xF) + 4;
switch( litLen ) switch (litLen)
{ {
case 0: case 0:
phase = DecodePhase.ReadOffset; phase = DecodePhase.ReadOffset;
goto readOffset; goto readOffset;
case 0xF: case 0xF:
phase = DecodePhase.ReadExLiteralLength; phase = DecodePhase.ReadExLiteralLength;
goto readExLiteralLength; goto readExLiteralLength;
default: default:
phase = DecodePhase.CopyLiteral; phase = DecodePhase.CopyLiteral;
goto copyLiteral; goto copyLiteral;
} }
readExLiteralLength: readExLiteralLength:
int exLitLen; int exLitLen;
if( inBufPos < inBufEnd ) if (inBufPos < inBufEnd)
{ {
exLitLen = decBuf[inBufPos++]; exLitLen = decBuf[inBufPos++];
} }
else else
{ {
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
exLitLen = ReadByteCore(); exLitLen = ReadByteCore();
#if LOCAL_SHADOW #if LOCAL_SHADOW
inBufPos = this.inBufPos; inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd; inBufEnd = this.inBufEnd;
#endif #endif
#if CHECK_EOF #if CHECK_EOF
if( exLitLen == -1 ) if (exLitLen == -1)
goto finish; goto finish;
#endif #endif
} }
litLen += exLitLen; litLen += exLitLen;
if( exLitLen == 255 ) if (exLitLen == 255)
goto readExLiteralLength; goto readExLiteralLength;
phase = DecodePhase.CopyLiteral; phase = DecodePhase.CopyLiteral;
goto copyLiteral; goto copyLiteral;
copyLiteral: copyLiteral:
int nReadLit = litLen < nToRead ? litLen : nToRead; int nReadLit = litLen < nToRead ? litLen : nToRead;
if( nReadLit != 0 ) if (nReadLit != 0)
{ {
if( inBufPos + nReadLit <= inBufEnd ) if (inBufPos + nReadLit <= inBufEnd)
{ {
int ofs = offset; int ofs = offset;
for( int c = nReadLit; c-- != 0; ) for (int c = nReadLit; c-- != 0;)
buffer[ofs++] = decBuf[inBufPos++]; buffer[ofs++] = decBuf[inBufPos++];
nRead = nReadLit; nRead = nReadLit;
} }
else else
{ {
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
nRead = ReadCore( buffer, offset, nReadLit ); nRead = ReadCore(buffer, offset, nReadLit);
#if LOCAL_SHADOW #if LOCAL_SHADOW
inBufPos = this.inBufPos; inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd; inBufEnd = this.inBufEnd;
#endif #endif
#if CHECK_EOF #if CHECK_EOF
if( nRead == 0 ) if (nRead == 0)
goto finish; goto finish;
#endif #endif
} }
offset += nRead; offset += nRead;
nToRead -= nRead; nToRead -= nRead;
litLen -= nRead; litLen -= nRead;
if( litLen != 0 ) if (litLen != 0)
goto copyLiteral; goto copyLiteral;
} }
if( nToRead == 0 ) if (nToRead == 0)
goto finish; goto finish;
phase = DecodePhase.ReadOffset; phase = DecodePhase.ReadOffset;
goto readOffset; goto readOffset;
readOffset: readOffset:
if( inBufPos + 1 < inBufEnd ) if (inBufPos + 1 < inBufEnd)
{ {
matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos]; matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos];
inBufPos += 2; inBufPos += 2;
} }
else else
{ {
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
matDst = ReadOffsetCore(); matDst = ReadOffsetCore();
#if LOCAL_SHADOW #if LOCAL_SHADOW
inBufPos = this.inBufPos; inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd; inBufEnd = this.inBufEnd;
#endif #endif
#if CHECK_EOF #if CHECK_EOF
if( matDst == -1 ) if (matDst == -1)
goto finish; goto finish;
#endif #endif
} }
if( matLen == 15 + 4 ) if (matLen == 15 + 4)
{ {
phase = DecodePhase.ReadExMatchLength; phase = DecodePhase.ReadExMatchLength;
goto readExMatchLength; goto readExMatchLength;
} }
else else
{ {
phase = DecodePhase.CopyMatch; phase = DecodePhase.CopyMatch;
goto copyMatch; goto copyMatch;
} }
readExMatchLength: readExMatchLength:
int exMatLen; int exMatLen;
if( inBufPos < inBufEnd ) if (inBufPos < inBufEnd)
{ {
exMatLen = decBuf[inBufPos++]; exMatLen = decBuf[inBufPos++];
} }
else else
{ {
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
exMatLen = ReadByteCore(); exMatLen = ReadByteCore();
#if LOCAL_SHADOW #if LOCAL_SHADOW
inBufPos = this.inBufPos; inBufPos = this.inBufPos;
inBufEnd = this.inBufEnd; inBufEnd = this.inBufEnd;
#endif #endif
#if CHECK_EOF #if CHECK_EOF
if( exMatLen == -1 ) if (exMatLen == -1)
goto finish; goto finish;
#endif #endif
} }
matLen += exMatLen; matLen += exMatLen;
if( exMatLen == 255 ) if (exMatLen == 255)
goto readExMatchLength; goto readExMatchLength;
phase = DecodePhase.CopyMatch; phase = DecodePhase.CopyMatch;
goto copyMatch; goto copyMatch;
copyMatch: copyMatch:
int nCpyMat = matLen < nToRead ? matLen : nToRead; int nCpyMat = matLen < nToRead ? matLen : nToRead;
if( nCpyMat != 0 ) if (nCpyMat != 0)
{ {
nRead = count - nToRead; nRead = count - nToRead;
int bufDst = matDst - nRead; int bufDst = matDst - nRead;
if( bufDst > 0 ) if (bufDst > 0)
{ {
//offset is fairly far back, we need to pull from the buffer //offset is fairly far back, we need to pull from the buffer
int bufSrc = decodeBufferPos - bufDst; int bufSrc = decodeBufferPos - bufDst;
if( bufSrc < 0 ) if (bufSrc < 0)
bufSrc += DecBufLen; bufSrc += DecBufLen;
int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat; int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat;
for( int c = bufCnt; c-- != 0; ) for (int c = bufCnt; c-- != 0;)
buffer[offset++] = decBuf[bufSrc++ & DecBufMask]; buffer[offset++] = decBuf[bufSrc++ & DecBufMask];
} }
else else
{ {
bufDst = 0; bufDst = 0;
} }
int sOfs = offset - matDst; int sOfs = offset - matDst;
for( int i = bufDst; i < nCpyMat; i++ ) for (int i = bufDst; i < nCpyMat; i++)
buffer[offset++] = buffer[sOfs++]; buffer[offset++] = buffer[sOfs++];
nToRead -= nCpyMat; nToRead -= nCpyMat;
matLen -= nCpyMat; matLen -= nCpyMat;
} }
if( nToRead == 0 ) if (nToRead == 0)
goto finish; goto finish;
phase = DecodePhase.ReadToken; phase = DecodePhase.ReadToken;
goto readToken; goto readToken;
finish: finish:
nRead = count - nToRead; nRead = count - nToRead;
int nToBuf = nRead < DecBufLen ? nRead : DecBufLen; int nToBuf = nRead < DecBufLen ? nRead : DecBufLen;
int repPos = offset - nToBuf; int repPos = offset - nToBuf;
if( nToBuf == DecBufLen ) if (nToBuf == DecBufLen)
{ {
Buffer.BlockCopy( buffer, repPos, decBuf, 0, DecBufLen ); Buffer.BlockCopy(buffer, repPos, decBuf, 0, DecBufLen);
decodeBufferPos = 0; decodeBufferPos = 0;
} }
else else
{ {
int decPos = decodeBufferPos; int decPos = decodeBufferPos;
while( nToBuf-- != 0 ) while (nToBuf-- != 0)
decBuf[decPos++ & DecBufMask] = buffer[repPos++]; decBuf[decPos++ & DecBufMask] = buffer[repPos++];
decodeBufferPos = decPos & DecBufMask; decodeBufferPos = decPos & DecBufMask;
} }
#if LOCAL_SHADOW #if LOCAL_SHADOW
this.phase = phase; this.phase = phase;
this.inBufPos = inBufPos; this.inBufPos = inBufPos;
#endif #endif
return nRead; return nRead;
} }
private int ReadByteCore() private int ReadByteCore()
{ {
var buf = decodeBuffer; var buf = decodeBuffer;
if( inBufPos == inBufEnd ) if (inBufPos == inBufEnd)
{ {
int nRead = input.Read( buf, DecBufLen, int nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength ); InBufLen < inputLength ? InBufLen : (int)inputLength);
#if CHECK_EOF #if CHECK_EOF
if( nRead == 0 ) if (nRead == 0)
return -1; return -1;
#endif #endif
inputLength -= nRead; inputLength -= nRead;
inBufPos = DecBufLen; inBufPos = DecBufLen;
inBufEnd = DecBufLen + nRead; inBufEnd = DecBufLen + nRead;
} }
return buf[inBufPos++]; return buf[inBufPos++];
} }
private int ReadOffsetCore() private int ReadOffsetCore()
{ {
var buf = decodeBuffer; var buf = decodeBuffer;
if( inBufPos == inBufEnd ) if (inBufPos == inBufEnd)
{ {
int nRead = input.Read( buf, DecBufLen, int nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength ); InBufLen < inputLength ? InBufLen : (int)inputLength);
#if CHECK_EOF #if CHECK_EOF
if( nRead == 0 ) if (nRead == 0)
return -1; return -1;
#endif #endif
inputLength -= nRead; inputLength -= nRead;
inBufPos = DecBufLen; inBufPos = DecBufLen;
inBufEnd = DecBufLen + nRead; inBufEnd = DecBufLen + nRead;
} }
if( inBufEnd - inBufPos == 1 ) if (inBufEnd - inBufPos == 1)
{ {
buf[DecBufLen] = buf[inBufPos]; buf[DecBufLen] = buf[inBufPos];
int nRead = input.Read( buf, DecBufLen + 1, int nRead = input.Read(buf, DecBufLen + 1,
InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength ); InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength);
#if CHECK_EOF #if CHECK_EOF
if( nRead == 0 ) if (nRead == 0)
{ {
inBufPos = DecBufLen; inBufPos = DecBufLen;
inBufEnd = DecBufLen + 1; inBufEnd = DecBufLen + 1;
return -1; return -1;
} }
#endif #endif
inputLength -= nRead; inputLength -= nRead;
inBufPos = DecBufLen; inBufPos = DecBufLen;
inBufEnd = DecBufLen + nRead + 1; inBufEnd = DecBufLen + nRead + 1;
} }
int ret = (buf[inBufPos + 1] << 8) | buf[inBufPos]; int ret = (buf[inBufPos + 1] << 8) | buf[inBufPos];
inBufPos += 2; inBufPos += 2;
return ret; return ret;
} }
private int ReadCore( byte[] buffer, int offset, int count ) private int ReadCore(byte[] buffer, int offset, int count)
{ {
int nToRead = count; int nToRead = count;
var buf = decodeBuffer; var buf = decodeBuffer;
int inBufLen = inBufEnd - inBufPos; int inBufLen = inBufEnd - inBufPos;
int fromBuf = nToRead < inBufLen ? nToRead : inBufLen; int fromBuf = nToRead < inBufLen ? nToRead : inBufLen;
if( fromBuf != 0 ) if (fromBuf != 0)
{ {
var bufPos = inBufPos; var bufPos = inBufPos;
for( int c = fromBuf; c-- != 0; ) for (int c = fromBuf; c-- != 0;)
buffer[offset++] = buf[bufPos++]; buffer[offset++] = buf[bufPos++];
inBufPos = bufPos; inBufPos = bufPos;
nToRead -= fromBuf; nToRead -= fromBuf;
} }
if( nToRead != 0 ) if (nToRead != 0)
{ {
int nRead; int nRead;
if( nToRead >= InBufLen ) if (nToRead >= InBufLen)
{ {
nRead = input.Read( buffer, offset, nRead = input.Read(buffer, offset,
nToRead < inputLength ? nToRead : (int)inputLength ); nToRead < inputLength ? nToRead : (int)inputLength);
nToRead -= nRead; nToRead -= nRead;
} }
else else
{ {
nRead = input.Read( buf, DecBufLen, nRead = input.Read(buf, DecBufLen,
InBufLen < inputLength ? InBufLen : (int)inputLength ); InBufLen < inputLength ? InBufLen : (int)inputLength);
inBufPos = DecBufLen; inBufPos = DecBufLen;
inBufEnd = DecBufLen + nRead; inBufEnd = DecBufLen + nRead;
fromBuf = nToRead < nRead ? nToRead : nRead; fromBuf = nToRead < nRead ? nToRead : nRead;
var bufPos = inBufPos; var bufPos = inBufPos;
for( int c = fromBuf; c-- != 0; ) for (int c = fromBuf; c-- != 0;)
buffer[offset++] = buf[bufPos++]; buffer[offset++] = buf[bufPos++];
inBufPos = bufPos; inBufPos = bufPos;
nToRead -= fromBuf; nToRead -= fromBuf;
} }
inputLength -= nRead; inputLength -= nRead;
} }
return count - nToRead; return count - nToRead;
} }
#region Stream internals #region Stream internals
public override bool CanRead public override bool CanRead => true;
{
get { return true; }
}
public override bool CanSeek public override bool CanSeek => false;
{
get { return false; }
}
public override bool CanWrite public override bool CanWrite => false;
{
get { return false; }
}
public override void Flush() public override void Flush()
{ {
} }
public override long Length public override long Length
{ {
get { throw new NotSupportedException(); } get { throw new NotSupportedException(); }
} }
public override long Position public override long Position
{ {
get { throw new NotSupportedException(); } get { throw new NotSupportedException(); }
set { throw new NotSupportedException(); } set { throw new NotSupportedException(); }
} }
public override long Seek( long offset, SeekOrigin origin ) public override long Seek(long offset, SeekOrigin origin)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public override void SetLength( long value ) public override void SetLength(long value)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
public override void Write( byte[] buffer, int offset, int count ) public override void Write(byte[] buffer, int offset, int count)
{ {
throw new NotSupportedException(); throw new NotSupportedException();
} }
#endregion #endregion
} }
} }

View File

@ -1105,10 +1105,6 @@ namespace Unity_Studio
} }
} }
} }
else
{
//bool stop = true;
}
} }
MeshPD.uniqueID = keepID; MeshPD.uniqueID = keepID;
@ -1653,7 +1649,8 @@ namespace Unity_Studio
public static bool ExportAudioClip(AssetPreloadData asset, string exportFilename, string exportFileextension) public static bool ExportAudioClip(AssetPreloadData asset, string exportFilename, string exportFileextension)
{ {
var oldextension = exportFileextension; var oldextension = exportFileextension;
if ((bool)Properties.Settings.Default["convertfsb"] && exportFileextension == ".fsb") var convertfsb = (bool)Properties.Settings.Default["convertfsb"];
if (convertfsb && exportFileextension == ".fsb")
{ {
exportFileextension = ".wav"; exportFileextension = ".wav";
} }
@ -1661,7 +1658,7 @@ namespace Unity_Studio
if (ExportFileExists(exportFullname)) if (ExportFileExists(exportFullname))
return false; return false;
var m_AudioClip = new AudioClip(asset, true); var m_AudioClip = new AudioClip(asset, true);
if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb") if (convertfsb && oldextension == ".fsb")
{ {
FMOD.System system; FMOD.System system;
FMOD.Sound sound; FMOD.Sound sound;
@ -1769,10 +1766,10 @@ namespace Unity_Studio
{ {
count = 4; count = 4;
} }
var vertices = new ManagedFbx.Vector3[m_Mesh.m_VertexCount]; var vertices = new Vector3[m_Mesh.m_VertexCount];
for (int v = 0; v < m_Mesh.m_VertexCount; v++) for (int v = 0; v < m_Mesh.m_VertexCount; v++)
{ {
vertices[v] = new ManagedFbx.Vector3( vertices[v] = new Vector3(
m_Mesh.m_Vertices[v * count], m_Mesh.m_Vertices[v * count],
m_Mesh.m_Vertices[v * count + 1], m_Mesh.m_Vertices[v * count + 1],
m_Mesh.m_Vertices[v * count + 2]); m_Mesh.m_Vertices[v * count + 2]);
@ -1801,10 +1798,10 @@ namespace Unity_Studio
count = 4; count = 4;
} }
var normals = new ManagedFbx.Vector3[m_Mesh.m_VertexCount]; var normals = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++) for (int n = 0; n < m_Mesh.m_VertexCount; n++)
{ {
normals[n] = new ManagedFbx.Vector3( normals[n] = new Vector3(
m_Mesh.m_Normals[n * count], m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1], m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]); m_Mesh.m_Normals[n * count + 2]);
@ -1815,20 +1812,20 @@ namespace Unity_Studio
#region Colors #region Colors
if (m_Mesh.m_Colors == null) if (m_Mesh.m_Colors == null)
{ {
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount]; var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colors[c] = new ManagedFbx.Colour( colors[c] = new Colour(
0.5f, 0.5f, 0.5f, 1.0f); 0.5f, 0.5f, 0.5f, 1.0f);
} }
mesh.VertexColours = colors; mesh.VertexColours = colors;
} }
else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3) else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3)
{ {
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount]; var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colors[c] = new ManagedFbx.Colour( colors[c] = new Colour(
m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2], m_Mesh.m_Colors[c * 4 + 2],
@ -1838,10 +1835,10 @@ namespace Unity_Studio
} }
else else
{ {
var colors = new ManagedFbx.Colour[m_Mesh.m_VertexCount]; var colors = new Colour[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colors[c] = new ManagedFbx.Colour( colors[c] = new Colour(
m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2], m_Mesh.m_Colors[c * 4 + 2],
@ -1853,19 +1850,19 @@ namespace Unity_Studio
#region UV #region UV
if (m_Mesh.m_UV1 != null && m_Mesh.m_UV1.Length == m_Mesh.m_VertexCount * 2) if (m_Mesh.m_UV1 != null && m_Mesh.m_UV1.Length == m_Mesh.m_VertexCount * 2)
{ {
var uv = new ManagedFbx.Vector2[m_Mesh.m_VertexCount]; var uv = new Vector2[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
uv[c] = new ManagedFbx.Vector2(m_Mesh.m_UV1[c * 2], m_Mesh.m_UV1[c * 2 + 1]); uv[c] = new Vector2(m_Mesh.m_UV1[c * 2], m_Mesh.m_UV1[c * 2 + 1]);
} }
mesh.TextureCoords = uv; mesh.TextureCoords = uv;
} }
else if (m_Mesh.m_UV2 != null && m_Mesh.m_UV2.Length == m_Mesh.m_VertexCount * 2) else if (m_Mesh.m_UV2 != null && m_Mesh.m_UV2.Length == m_Mesh.m_VertexCount * 2)
{ {
var uv = new ManagedFbx.Vector2[m_Mesh.m_VertexCount]; var uv = new Vector2[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
uv[c] = new ManagedFbx.Vector2(m_Mesh.m_UV2[c * 2], m_Mesh.m_UV2[c * 2 + 1]); uv[c] = new Vector2(m_Mesh.m_UV2[c * 2], m_Mesh.m_UV2[c * 2 + 1]);
} }
mesh.TextureCoords = uv; mesh.TextureCoords = uv;
} }

View File

@ -49,9 +49,9 @@ namespace Unity_Studio
int vboColors; int vboColors;
int vboViewMatrix; int vboViewMatrix;
int eboElements; int eboElements;
OpenTK.Vector3[] vertexData; Vector3[] vertexData;
OpenTK.Vector3[] normalData; Vector3[] normalData;
OpenTK.Vector4[] colorData; Vector4[] colorData;
Matrix4[] viewMatrixData; Matrix4[] viewMatrixData;
int[] indiceData; int[] indiceData;
bool wireFrameView; bool wireFrameView;
@ -73,7 +73,7 @@ namespace Unity_Studio
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts); private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, IntPtr pdv, [In] ref uint pcFonts);
private void loadFile_Click(object sender, System.EventArgs e) private void loadFile_Click(object sender, EventArgs e)
{ {
if (openFileDialog1.ShowDialog() == DialogResult.OK) if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ {
@ -118,7 +118,7 @@ namespace Unity_Studio
} }
} }
private void loadFolder_Click(object sender, System.EventArgs e) private void loadFolder_Click(object sender, EventArgs e)
{ {
/*FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); /*FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
@ -274,11 +274,11 @@ namespace Unity_Studio
{ {
if (productName != "") if (productName != "")
{ {
this.Text = "Unity Studio - " + productName + " - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr; Text = "Unity Studio - " + productName + " - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
} }
else if (assetsfileList.Count > 0) else if (assetsfileList.Count > 0)
{ {
this.Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr; Text = "Unity Studio - no productName - " + assetsfileList[0].m_Version + " - " + assetsfileList[0].platformStr;
} }
if (!dontLoadAssetsMenuItem.Checked) if (!dontLoadAssetsMenuItem.Checked)
{ {
@ -596,7 +596,7 @@ namespace Unity_Studio
if (treeSearch.Text == " Search ") if (treeSearch.Text == " Search ")
{ {
treeSearch.Text = ""; treeSearch.Text = "";
treeSearch.ForeColor = System.Drawing.SystemColors.WindowText; treeSearch.ForeColor = SystemColors.WindowText;
} }
} }
@ -605,7 +605,7 @@ namespace Unity_Studio
if (treeSearch.Text == "") if (treeSearch.Text == "")
{ {
treeSearch.Text = " Search "; treeSearch.Text = " Search ";
treeSearch.ForeColor = System.Drawing.SystemColors.GrayText; treeSearch.ForeColor = SystemColors.GrayText;
} }
} }
@ -694,7 +694,7 @@ namespace Unity_Studio
if (listSearch.Text == " Filter ") if (listSearch.Text == " Filter ")
{ {
listSearch.Text = ""; listSearch.Text = "";
listSearch.ForeColor = System.Drawing.SystemColors.WindowText; listSearch.ForeColor = SystemColors.WindowText;
enableFiltering = true; enableFiltering = true;
} }
} }
@ -705,7 +705,7 @@ namespace Unity_Studio
{ {
enableFiltering = false; enableFiltering = false;
listSearch.Text = " Filter "; listSearch.Text = " Filter ";
listSearch.ForeColor = System.Drawing.SystemColors.GrayText; listSearch.ForeColor = SystemColors.GrayText;
} }
} }
@ -716,7 +716,7 @@ namespace Unity_Studio
assetListView.BeginUpdate(); assetListView.BeginUpdate();
assetListView.SelectedIndices.Clear(); assetListView.SelectedIndices.Clear();
//visibleListAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.StartsWith(ListSearch.Text, System.StringComparison.CurrentCultureIgnoreCase)); //visibleListAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.StartsWith(ListSearch.Text, System.StringComparison.CurrentCultureIgnoreCase));
visibleAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.IndexOf(listSearch.Text, System.StringComparison.CurrentCultureIgnoreCase) >= 0); visibleAssets = exportableAssets.FindAll(ListAsset => ListAsset.Text.IndexOf(listSearch.Text, StringComparison.CurrentCultureIgnoreCase) >= 0);
assetListView.VirtualListSize = visibleAssets.Count; assetListView.VirtualListSize = visibleAssets.Count;
assetListView.EndUpdate(); assetListView.EndUpdate();
} }
@ -742,7 +742,7 @@ namespace Unity_Studio
{ {
int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text); int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
else return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Size.CompareTo(b.Size); return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Size.CompareTo(b.Size);
}); });
break; break;
case 1: case 1:
@ -750,7 +750,7 @@ namespace Unity_Studio
{ {
int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString); int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
else return secondSortColumn == 2 ? a.Size.CompareTo(b.Size) : a.Text.CompareTo(b.Text); return secondSortColumn == 2 ? a.Size.CompareTo(b.Size) : a.Text.CompareTo(b.Text);
}); });
break; break;
case 2: case 2:
@ -758,7 +758,7 @@ namespace Unity_Studio
{ {
int xdiff = reverseSort ? b.Size.CompareTo(a.Size) : a.Size.CompareTo(b.Size); int xdiff = reverseSort ? b.Size.CompareTo(a.Size) : a.Size.CompareTo(b.Size);
if (xdiff != 0) return xdiff; if (xdiff != 0) return xdiff;
else return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text); return secondSortColumn == 1 ? a.TypeString.CompareTo(b.TypeString) : a.Text.CompareTo(b.Text);
}); });
break; break;
} }
@ -771,7 +771,7 @@ namespace Unity_Studio
private void selectAsset(object sender, ListViewItemSelectionChangedEventArgs e) private void selectAsset(object sender, ListViewItemSelectionChangedEventArgs e)
{ {
previewPanel.BackgroundImage = Properties.Resources.preview; previewPanel.BackgroundImage = Properties.Resources.preview;
previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; previewPanel.BackgroundImageLayout = ImageLayout.Center;
assetInfoLabel.Visible = false; assetInfoLabel.Visible = false;
assetInfoLabel.Text = null; assetInfoLabel.Text = null;
textPreviewBox.Visible = false; textPreviewBox.Visible = false;
@ -975,10 +975,10 @@ namespace Unity_Studio
{ {
count = 4; count = 4;
} }
vertexData = new OpenTK.Vector3[m_Mesh.m_VertexCount]; vertexData = new Vector3[m_Mesh.m_VertexCount];
for (int v = 0; v < m_Mesh.m_VertexCount; v++) for (int v = 0; v < m_Mesh.m_VertexCount; v++)
{ {
vertexData[v] = new OpenTK.Vector3( vertexData[v] = new Vector3(
m_Mesh.m_Vertices[v * count], m_Mesh.m_Vertices[v * count],
m_Mesh.m_Vertices[v * count + 1], m_Mesh.m_Vertices[v * count + 1],
m_Mesh.m_Vertices[v * count + 2]); m_Mesh.m_Vertices[v * count + 2]);
@ -1005,10 +1005,10 @@ namespace Unity_Studio
count = 4; count = 4;
} }
normalData = new OpenTK.Vector3[m_Mesh.m_VertexCount]; normalData = new Vector3[m_Mesh.m_VertexCount];
for (int n = 0; n < m_Mesh.m_VertexCount; n++) for (int n = 0; n < m_Mesh.m_VertexCount; n++)
{ {
normalData[n] = new OpenTK.Vector3( normalData[n] = new Vector3(
m_Mesh.m_Normals[n * count], m_Mesh.m_Normals[n * count],
m_Mesh.m_Normals[n * count + 1], m_Mesh.m_Normals[n * count + 1],
m_Mesh.m_Normals[n * count + 2]); m_Mesh.m_Normals[n * count + 2]);
@ -1018,19 +1018,19 @@ namespace Unity_Studio
#region Colors #region Colors
if (m_Mesh.m_Colors == null) if (m_Mesh.m_Colors == null)
{ {
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount]; colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colorData[c] = new OpenTK.Vector4( colorData[c] = new Vector4(
0.5f, 0.5f, 0.5f, 1.0f); 0.5f, 0.5f, 0.5f, 1.0f);
} }
} }
else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3) else if (m_Mesh.m_Colors.Length == m_Mesh.m_VertexCount * 3)
{ {
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount]; colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colorData[c] = new OpenTK.Vector4( colorData[c] = new Vector4(
m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2], m_Mesh.m_Colors[c * 4 + 2],
@ -1039,10 +1039,10 @@ namespace Unity_Studio
} }
else else
{ {
colorData = new OpenTK.Vector4[m_Mesh.m_VertexCount]; colorData = new Vector4[m_Mesh.m_VertexCount];
for (int c = 0; c < m_Mesh.m_VertexCount; c++) for (int c = 0; c < m_Mesh.m_VertexCount; c++)
{ {
colorData[c] = new OpenTK.Vector4( colorData[c] = new Vector4(
m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4],
m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 1],
m_Mesh.m_Colors[c * 4 + 2], m_Mesh.m_Colors[c * 4 + 2],
@ -1375,7 +1375,7 @@ namespace Unity_Studio
//Environment.Exit(-1); //Environment.Exit(-1);
return true; return true;
} }
else { return false; } return false;
} }
private void all3DObjectssplitToolStripMenuItem_Click(object sender, EventArgs e) private void all3DObjectssplitToolStripMenuItem_Click(object sender, EventArgs e)
@ -1734,24 +1734,24 @@ namespace Unity_Studio
GL.DeleteShader(address); GL.DeleteShader(address);
} }
private void createVBO(out int vboAddress, OpenTK.Vector3[] data, int address) private void createVBO(out int vboAddress, Vector3[] data, int address)
{ {
GL.GenBuffers(1, out vboAddress); GL.GenBuffers(1, out vboAddress);
GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress); GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress);
GL.BufferData<OpenTK.Vector3>(BufferTarget.ArrayBuffer, GL.BufferData<Vector3>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * OpenTK.Vector3.SizeInBytes), (IntPtr)(data.Length * Vector3.SizeInBytes),
data, data,
BufferUsageHint.StaticDraw); BufferUsageHint.StaticDraw);
GL.VertexAttribPointer(address, 3, VertexAttribPointerType.Float, false, 0, 0); GL.VertexAttribPointer(address, 3, VertexAttribPointerType.Float, false, 0, 0);
GL.EnableVertexAttribArray(address); GL.EnableVertexAttribArray(address);
} }
private void createVBO(out int vboAddress, OpenTK.Vector4[] data, int address) private void createVBO(out int vboAddress, Vector4[] data, int address)
{ {
GL.GenBuffers(1, out vboAddress); GL.GenBuffers(1, out vboAddress);
GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress); GL.BindBuffer(BufferTarget.ArrayBuffer, vboAddress);
GL.BufferData<OpenTK.Vector4>(BufferTarget.ArrayBuffer, GL.BufferData<Vector4>(BufferTarget.ArrayBuffer,
(IntPtr)(data.Length * OpenTK.Vector4.SizeInBytes), (IntPtr)(data.Length * Vector4.SizeInBytes),
data, data,
BufferUsageHint.StaticDraw); BufferUsageHint.StaticDraw);
GL.VertexAttribPointer(address, 4, VertexAttribPointerType.Float, false, 0, 0); GL.VertexAttribPointer(address, 4, VertexAttribPointerType.Float, false, 0, 0);
@ -1823,7 +1823,7 @@ namespace Unity_Studio
Properties.Settings.Default["displayInfo"] = displayAssetInfoMenuItem.Checked; Properties.Settings.Default["displayInfo"] = displayAssetInfoMenuItem.Checked;
Properties.Settings.Default.Save();*/ Properties.Settings.Default.Save();*/
base.Text = "Unity Studio"; Text = "Unity Studio";
unityFiles.Clear(); unityFiles.Clear();
assetsfileList.Clear(); assetsfileList.Clear();
@ -1841,7 +1841,7 @@ namespace Unity_Studio
classesListView.Groups.Clear(); classesListView.Groups.Clear();
previewPanel.BackgroundImage = Properties.Resources.preview; previewPanel.BackgroundImage = Properties.Resources.preview;
previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; previewPanel.BackgroundImageLayout = ImageLayout.Center;
assetInfoLabel.Visible = false; assetInfoLabel.Visible = false;
assetInfoLabel.Text = null; assetInfoLabel.Text = null;
textPreviewBox.Visible = false; textPreviewBox.Visible = false;

View File

@ -1,56 +0,0 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7-Zip Copyright (C) 1999-2015 Igor Pavlov.
Licenses for files are:
1) 7z.dll: GNU LGPL + unRAR restriction
2) All other files: GNU LGPL
The GNU LGPL + unRAR restriction means that you must follow both
GNU LGPL rules and unRAR restriction rules.
Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.
GNU LGPL information
--------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
unRAR restriction
-----------------
The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.
The license for original unRAR code has the following restriction:
The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.
--
Igor Pavlov