From d1ec1c29a42ff582589e5c1e8a0e9c833c4510a1 Mon Sep 17 00:00:00 2001 From: Perfare Date: Mon, 10 Apr 2017 03:13:08 +0800 Subject: [PATCH] cleanup code --- Unity Studio/7zip/SevenZipHelper.cs | 68 +- Unity Studio/AboutBox.cs | 22 +- Unity Studio/ExportOptions.cs | 14 +- Unity Studio/Unity Classes/AudioClip.cs | 8 +- Unity Studio/Unity Classes/GameObject.cs | 4 +- Unity Studio/Unity Classes/Texture2D.cs | 8 +- .../Unity Studio Classes/AssetPreloadData.cs | 5 +- .../Unity Studio Classes/BundleFile.cs | 16 +- .../Unity Studio Classes/EndianStream.cs | 46 +- .../Unity Studio Classes/Lz4DecoderStream.cs | 721 +++++++++--------- .../Unity Studio Classes/UnityStudio.cs | 37 +- Unity Studio/UnityStudioForm.cs | 70 +- Unity Studio/library/7zip license.txt | 56 -- 13 files changed, 494 insertions(+), 581 deletions(-) delete mode 100644 Unity Studio/library/7zip license.txt diff --git a/Unity Studio/7zip/SevenZipHelper.cs b/Unity Studio/7zip/SevenZipHelper.cs index 6c418c6..34584c8 100644 --- a/Unity Studio/7zip/SevenZipHelper.cs +++ b/Unity Studio/7zip/SevenZipHelper.cs @@ -7,46 +7,46 @@ namespace SevenZip.Compression.LZMA public static class SevenZipHelper { - static int dictionary = 1 << 23; + static int dictionary = 1 << 23; - // static Int32 posStateBits = 2; - // static Int32 litContextBits = 3; // for normal files + // static Int32 posStateBits = 2; + // static Int32 litContextBits = 3; // for normal files // UInt32 litContextBits = 0; // for 32-bit data - // static Int32 litPosBits = 0; + // static Int32 litPosBits = 0; // UInt32 litPosBits = 2; // for 32-bit data - // static Int32 algorithm = 2; - // static Int32 numFastBytes = 128; + // static Int32 algorithm = 2; + // static Int32 numFastBytes = 128; - static bool eos = false; + static bool eos = false; - static CoderPropID[] propIDs = - { - CoderPropID.DictionarySize, - CoderPropID.PosStateBits, - CoderPropID.LitContextBits, - CoderPropID.LitPosBits, - CoderPropID.Algorithm, - CoderPropID.NumFastBytes, - CoderPropID.MatchFinder, - CoderPropID.EndMarker - }; + static CoderPropID[] propIDs = + { + CoderPropID.DictionarySize, + CoderPropID.PosStateBits, + CoderPropID.LitContextBits, + CoderPropID.LitPosBits, + CoderPropID.Algorithm, + CoderPropID.NumFastBytes, + CoderPropID.MatchFinder, + CoderPropID.EndMarker + }; // these are the default properties, keeping it simple for now: - static object[] properties = - { - (Int32)(dictionary), - (Int32)(2), - (Int32)(3), - (Int32)(0), - (Int32)(2), - (Int32)(128), - "bt4", - eos - }; + static object[] properties = + { + (Int32)(dictionary), + (Int32)(2), + (Int32)(3), + (Int32)(0), + (Int32)(2), + (Int32)(128), + "bt4", + eos + }; public static byte[] Compress(byte[] inputBytes) @@ -54,7 +54,7 @@ namespace SevenZip.Compression.LZMA MemoryStream inStream = new MemoryStream(inputBytes); MemoryStream outStream = new MemoryStream(); - SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder(); + Encoder encoder = new Encoder(); encoder.SetCoderProperties(propIDs, properties); encoder.WriteCoderProperties(outStream); long fileSize = inStream.Length; @@ -68,8 +68,8 @@ namespace SevenZip.Compression.LZMA { MemoryStream newInStream = new MemoryStream(inputBytes); - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); - + Decoder decoder = new Decoder(); + newInStream.Seek(0, 0); MemoryStream newOutStream = new MemoryStream(); @@ -97,7 +97,7 @@ namespace SevenZip.Compression.LZMA public static MemoryStream StreamDecompress(MemoryStream newInStream) { - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); + Decoder decoder = new Decoder(); newInStream.Seek(0, 0); MemoryStream newOutStream = new MemoryStream(); @@ -124,7 +124,7 @@ namespace SevenZip.Compression.LZMA 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); MemoryStream newOutStream = new MemoryStream(); diff --git a/Unity Studio/AboutBox.cs b/Unity Studio/AboutBox.cs index 4161b78..1e63e19 100644 --- a/Unity Studio/AboutBox.cs +++ b/Unity Studio/AboutBox.cs @@ -13,12 +13,12 @@ namespace Unity_Studio public AboutBox() { InitializeComponent(); - this.Text = String.Format("About {0}", AssemblyTitle); - this.labelProductName.Text = AssemblyProduct; - this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); - this.labelCopyright.Text = AssemblyCopyright; - this.labelCompanyName.Text = AssemblyCompany; - this.textBoxDescription.Text = AssemblyDescription; + Text = $"About {AssemblyTitle}"; + labelProductName.Text = AssemblyProduct; + labelVersion.Text = $"Version {AssemblyVersion}"; + labelCopyright.Text = AssemblyCopyright; + labelCompanyName.Text = AssemblyCompany; + textBoxDescription.Text = AssemblyDescription; } #region Assembly Attribute Accessors @@ -40,13 +40,7 @@ namespace Unity_Studio } } - public string AssemblyVersion - { - get - { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } - } + public string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString(); public string AssemblyDescription { @@ -103,7 +97,7 @@ namespace Unity_Studio private void okButton_Click(object sender, EventArgs e) { - this.Close(); + Close(); } } } diff --git a/Unity Studio/ExportOptions.cs b/Unity Studio/ExportOptions.cs index a41e143..709deae 100644 --- a/Unity Studio/ExportOptions.cs +++ b/Unity Studio/ExportOptions.cs @@ -27,12 +27,12 @@ namespace Unity_Studio showExpOpt.Checked = (bool)Properties.Settings.Default["showExpOpt"]; converttexture.Checked = (bool)Properties.Settings.Default["convertTexture"]; 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) { if (c.Text == str) { - (c as RadioButton).Checked = true; + ((RadioButton)c).Checked = true; break; } } @@ -57,21 +57,21 @@ namespace Unity_Studio Properties.Settings.Default["convertfsb"] = convertfsb.Checked; foreach (Control c in panel1.Controls) { - if ((c as RadioButton).Checked) + if (((RadioButton)c).Checked) { Properties.Settings.Default["convertType"] = c.Text; break; } } Properties.Settings.Default.Save(); - this.DialogResult = DialogResult.OK; - this.Close(); + DialogResult = DialogResult.OK; + Close(); } private void fbxCancel_Click(object sender, EventArgs e) { - this.DialogResult = DialogResult.Cancel; - this.Close(); + DialogResult = DialogResult.Cancel; + Close(); } private void exportDeformers_CheckedChanged(object sender, EventArgs e) diff --git a/Unity Studio/Unity Classes/AudioClip.cs b/Unity Studio/Unity Classes/AudioClip.cs index f91858c..c254828 100644 --- a/Unity Studio/Unity Classes/AudioClip.cs +++ b/Unity Studio/Unity Classes/AudioClip.cs @@ -94,23 +94,21 @@ namespace Unity_Studio if (readSwitch) { - m_AudioData = new byte[m_Size]; - 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) || File.Exists(m_Source = Path.Combine(Path.GetDirectoryName(sourceFile.filePath), Path.GetFileName(m_Source)))) { BinaryReader reader = new BinaryReader(File.OpenRead(m_Source)); reader.BaseStream.Position = m_Offset; - reader.Read(m_AudioData, 0, (int)m_Size); + m_AudioData = reader.ReadBytes((int)m_Size); reader.Close(); } else { - EndianStream estream = null; + EndianStream estream; if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(m_Source), out estream)) { estream.Position = m_Offset; diff --git a/Unity Studio/Unity Classes/GameObject.cs b/Unity Studio/Unity Classes/GameObject.cs index 335da91..cbbad0f 100644 --- a/Unity Studio/Unity Classes/GameObject.cs +++ b/Unity Studio/Unity Classes/GameObject.cs @@ -58,10 +58,10 @@ namespace Unity_Studio m_Tag = a_Stream.ReadUInt16(); m_IsActive = a_Stream.ReadBoolean(); - base.Text = m_Name; + Text = m_Name; preloadData.Text = m_Name; //name should be unique - base.Name = uniqueID; + Name = uniqueID; } } } diff --git a/Unity Studio/Unity Classes/Texture2D.cs b/Unity Studio/Unity Classes/Texture2D.cs index 84a8d48..2b55edd 100644 --- a/Unity Studio/Unity Classes/Texture2D.cs +++ b/Unity Studio/Unity Classes/Texture2D.cs @@ -168,15 +168,14 @@ namespace Unity_Studio if (File.Exists(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)); reader.BaseStream.Position = offset; - reader.Read(image_data, 0, image_data_size); + image_data = reader.ReadBytes(image_data_size); reader.Close(); } else { - EndianStream estream = null; + EndianStream estream; if (UnityStudio.assetsfileandstream.TryGetValue(Path.GetFileName(path), out estream)) { estream.Position = offset; @@ -186,8 +185,7 @@ namespace Unity_Studio } else { - image_data = new byte[image_data_size]; - a_Stream.Read(image_data, 0, image_data_size); + image_data = a_Stream.ReadBytes(image_data_size); } switch (m_TextureFormat) diff --git a/Unity Studio/Unity Studio Classes/AssetPreloadData.cs b/Unity Studio/Unity Studio Classes/AssetPreloadData.cs index 8fb172e..9775dae 100644 --- a/Unity Studio/Unity Studio Classes/AssetPreloadData.cs +++ b/Unity Studio/Unity Studio Classes/AssetPreloadData.cs @@ -138,10 +138,7 @@ namespace Unity_Studio { return member2; } - else - { - member2.Add(member); - } + member2.Add(member); } return member2; } diff --git a/Unity Studio/Unity Studio Classes/BundleFile.cs b/Unity Studio/Unity Studio Classes/BundleFile.cs index 130a9e3..8b81dfb 100644 --- a/Unity Studio/Unity Studio Classes/BundleFile.cs +++ b/Unity Studio/Unity Studio Classes/BundleFile.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using Lz4; +using SevenZip.Compression.LZMA; namespace Unity_Studio { @@ -97,7 +97,7 @@ namespace Unity_Studio byte[] lzmaBuffer = new byte[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); } @@ -166,15 +166,14 @@ namespace Unity_Studio EndianStream blocksInfo; switch (flag & 0x3F) { - default: - case 0://None + default://None { blocksInfo = new EndianStream(new MemoryStream(blocksInfoBytes), EndianType.BigEndian); break; } 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; } case 2://LZ4 @@ -206,8 +205,7 @@ namespace Unity_Studio var compressedBytes = b_Stream.ReadBytes(compressedSize); switch (flag & 0x3F) { - default: - case 0://None + default://None { assetsDataStream.Write(compressedBytes, 0, compressedSize); break; @@ -217,7 +215,7 @@ namespace Unity_Studio var uncompressedBytes = new byte[uncompressedSize]; 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.Dispose(); } diff --git a/Unity Studio/Unity Studio Classes/EndianStream.cs b/Unity Studio/Unity Studio Classes/EndianStream.cs index 43ce261..3728a6e 100644 --- a/Unity Studio/Unity Studio Classes/EndianStream.cs +++ b/Unity Studio/Unity Studio Classes/EndianStream.cs @@ -20,115 +20,115 @@ namespace Unity_Studio 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() { if (endian == EndianType.BigEndian) { - a16 = base.ReadBytes(2); + a16 = ReadBytes(2); Array.Reverse(a16); return BitConverter.ToInt16(a16, 0); } - else return base.ReadInt16(); + return base.ReadInt16(); } public override int ReadInt32() { if (endian == EndianType.BigEndian) { - a32 = base.ReadBytes(4); + a32 = ReadBytes(4); Array.Reverse(a32); return BitConverter.ToInt32(a32, 0); } - else return base.ReadInt32(); + return base.ReadInt32(); } public override long ReadInt64() { if (endian == EndianType.BigEndian) { - a64 = base.ReadBytes(8); + a64 = ReadBytes(8); Array.Reverse(a64); return BitConverter.ToInt64(a64, 0); } - else return base.ReadInt64(); + return base.ReadInt64(); } public override ushort ReadUInt16() { if (endian == EndianType.BigEndian) { - a16 = base.ReadBytes(2); + a16 = ReadBytes(2); Array.Reverse(a16); return BitConverter.ToUInt16(a16, 0); } - else return base.ReadUInt16(); + return base.ReadUInt16(); } public override uint ReadUInt32() { if (endian == EndianType.BigEndian) { - a32 = base.ReadBytes(4); + a32 = ReadBytes(4); Array.Reverse(a32); return BitConverter.ToUInt32(a32, 0); } - else return base.ReadUInt32(); + return base.ReadUInt32(); } public override ulong ReadUInt64() { if (endian == EndianType.BigEndian) { - a64 = base.ReadBytes(8); + a64 = ReadBytes(8); Array.Reverse(a64); return BitConverter.ToUInt64(a64, 0); } - else return base.ReadUInt64(); + return base.ReadUInt64(); } public override float ReadSingle() { if (endian == EndianType.BigEndian) { - a32 = base.ReadBytes(4); + a32 = ReadBytes(4); Array.Reverse(a32); return BitConverter.ToSingle(a32, 0); } - else return base.ReadSingle(); + return base.ReadSingle(); } public override double ReadDouble() { if (endian == EndianType.BigEndian) { - a64 = base.ReadBytes(8); + a64 = ReadBytes(8); Array.Reverse(a64); return BitConverter.ToUInt64(a64, 0); } - else return base.ReadDouble(); + return base.ReadDouble(); } public string ReadASCII(int length) { - return Encoding.ASCII.GetString(base.ReadBytes(length)); + return Encoding.ASCII.GetString(ReadBytes(length)); } public void AlignStream(int alignment) { - long pos = base.BaseStream.Position; + long pos = BaseStream.Position; //long padding = alignment - pos + (pos / alignment) * alignment; //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) { - 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]; - base.Read(stringData, 0, length); + Read(stringData, 0, length); var result = Encoding.UTF8.GetString(stringData); //must verify strange characters in PS3 /*string result = ""; @@ -142,7 +142,7 @@ namespace Unity_Studio AlignStream(4); return result; } - else { return ""; } + return ""; } public string ReadStringToNull() diff --git a/Unity Studio/Unity Studio Classes/Lz4DecoderStream.cs b/Unity Studio/Unity Studio Classes/Lz4DecoderStream.cs index 6c22838..213bd7a 100644 --- a/Unity Studio/Unity Studio Classes/Lz4DecoderStream.cs +++ b/Unity Studio/Unity Studio Classes/Lz4DecoderStream.cs @@ -7,538 +7,525 @@ using System.IO; namespace Lz4 { - public class Lz4DecoderStream : Stream - { - public Lz4DecoderStream() - { - } + public class Lz4DecoderStream : Stream + { + public Lz4DecoderStream(Stream input, long inputLength = long.MaxValue) + { + Reset(input, inputLength); + } - public Lz4DecoderStream( Stream input, long inputLength = long.MaxValue ) - { - Reset( input, inputLength ); - } + public void Reset(Stream input, long inputLength = long.MaxValue) + { + this.inputLength = inputLength; + this.input = input; - public void Reset( Stream input, long inputLength = long.MaxValue ) - { - this.inputLength = inputLength; - this.input = input; + phase = DecodePhase.ReadToken; - phase = DecodePhase.ReadToken; - - decodeBufferPos = 0; - - litLen = 0; - matLen = 0; - matDst = 0; + decodeBufferPos = 0; - inBufPos = DecBufLen; - inBufEnd = DecBufLen; - } + litLen = 0; + matLen = 0; + matDst = 0; - public override void Close() - { - this.input = null; - } + inBufPos = DecBufLen; + inBufEnd = DecBufLen; + } - private long inputLength; - private Stream input; + public override void Close() + { + input = null; + } - //because we might not be able to match back across invocations, - //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 long inputLength; + private Stream input; - private const int DecBufLen = 0x10000; - private const int DecBufMask = 0xFFFF; + //because we might not be able to match back across invocations, + //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 int decodeBufferPos, inBufPos, inBufEnd; + private const int InBufLen = 128; - //we keep track of which phase we're in so that we can jump right back - //into the correct part of decoding + private byte[] decodeBuffer = new byte[DecBufLen + InBufLen]; + 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 - { - ReadToken, - ReadExLiteralLength, - CopyLiteral, - ReadOffset, - ReadExMatchLength, - CopyMatch, - } + private DecodePhase phase; - //state within interruptable phases and across phase boundaries is - //kept here - again, so that we can punt out and restart freely + private enum DecodePhase + { + 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( buffer == null ) - throw new ArgumentNullException( "buffer" ); - if( offset < 0 || count < 0 || buffer.Length - count < offset ) - throw new ArgumentOutOfRangeException(); + if (buffer == null) + throw new ArgumentNullException("buffer"); + if (offset < 0 || count < 0 || buffer.Length - count < offset) + throw new ArgumentOutOfRangeException(); - if( input == null ) - throw new InvalidOperationException(); + if (input == null) + throw new InvalidOperationException(); #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 - //make it *blindingly* obvious how the state machine transitions - //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 - //and pick up where we left off! + //the stringy gotos are obnoxious, but their purpose is to + //make it *blindingly* obvious how the state machine transitions + //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 + //and pick up where we left off! #if LOCAL_SHADOW var phase = this.phase; var inBufPos = this.inBufPos; var inBufEnd = this.inBufEnd; #endif - switch( phase ) - { - case DecodePhase.ReadToken: - goto readToken; + switch (phase) + { + case DecodePhase.ReadToken: + goto readToken; - case DecodePhase.ReadExLiteralLength: - goto readExLiteralLength; + case DecodePhase.ReadExLiteralLength: + goto readExLiteralLength; - case DecodePhase.CopyLiteral: - goto copyLiteral; + case DecodePhase.CopyLiteral: + goto copyLiteral; - case DecodePhase.ReadOffset: - goto readOffset; + case DecodePhase.ReadOffset: + goto readOffset; - case DecodePhase.ReadExMatchLength: - goto readExMatchLength; + case DecodePhase.ReadExMatchLength: + goto readExMatchLength; - case DecodePhase.CopyMatch: - goto copyMatch; - } + case DecodePhase.CopyMatch: + goto copyMatch; + } - readToken: - int tok; - if( inBufPos < inBufEnd ) - { - tok = decBuf[inBufPos++]; - } - else - { + readToken: + int tok; + if (inBufPos < inBufEnd) + { + tok = decBuf[inBufPos++]; + } + else + { #if LOCAL_SHADOW this.inBufPos = inBufPos; #endif - tok = ReadByteCore(); + tok = ReadByteCore(); #if LOCAL_SHADOW inBufPos = this.inBufPos; inBufEnd = this.inBufEnd; #endif #if CHECK_EOF - if( tok == -1 ) - goto finish; + if (tok == -1) + goto finish; #endif - } + } - litLen = tok >> 4; - matLen = (tok & 0xF) + 4; + litLen = tok >> 4; + matLen = (tok & 0xF) + 4; - switch( litLen ) - { - case 0: - phase = DecodePhase.ReadOffset; - goto readOffset; + switch (litLen) + { + case 0: + phase = DecodePhase.ReadOffset; + goto readOffset; - case 0xF: - phase = DecodePhase.ReadExLiteralLength; - goto readExLiteralLength; + case 0xF: + phase = DecodePhase.ReadExLiteralLength; + goto readExLiteralLength; - default: - phase = DecodePhase.CopyLiteral; - goto copyLiteral; - } + default: + phase = DecodePhase.CopyLiteral; + goto copyLiteral; + } - readExLiteralLength: - int exLitLen; - if( inBufPos < inBufEnd ) - { - exLitLen = decBuf[inBufPos++]; - } - else - { + readExLiteralLength: + int exLitLen; + if (inBufPos < inBufEnd) + { + exLitLen = decBuf[inBufPos++]; + } + else + { #if LOCAL_SHADOW this.inBufPos = inBufPos; #endif - exLitLen = ReadByteCore(); -#if LOCAL_SHADOW + exLitLen = ReadByteCore(); +#if LOCAL_SHADOW inBufPos = this.inBufPos; inBufEnd = this.inBufEnd; #endif #if CHECK_EOF - if( exLitLen == -1 ) - goto finish; + if (exLitLen == -1) + goto finish; #endif - } + } - litLen += exLitLen; - if( exLitLen == 255 ) - goto readExLiteralLength; + litLen += exLitLen; + if (exLitLen == 255) + goto readExLiteralLength; - phase = DecodePhase.CopyLiteral; - goto copyLiteral; + phase = DecodePhase.CopyLiteral; + goto copyLiteral; - copyLiteral: - int nReadLit = litLen < nToRead ? litLen : nToRead; - if( nReadLit != 0 ) - { - if( inBufPos + nReadLit <= inBufEnd ) - { - int ofs = offset; + copyLiteral: + int nReadLit = litLen < nToRead ? litLen : nToRead; + if (nReadLit != 0) + { + if (inBufPos + nReadLit <= inBufEnd) + { + int ofs = offset; - for( int c = nReadLit; c-- != 0; ) - buffer[ofs++] = decBuf[inBufPos++]; + for (int c = nReadLit; c-- != 0;) + buffer[ofs++] = decBuf[inBufPos++]; - nRead = nReadLit; - } - else - { + nRead = nReadLit; + } + else + { #if LOCAL_SHADOW this.inBufPos = inBufPos; #endif - nRead = ReadCore( buffer, offset, nReadLit ); + nRead = ReadCore(buffer, offset, nReadLit); #if LOCAL_SHADOW inBufPos = this.inBufPos; inBufEnd = this.inBufEnd; #endif #if CHECK_EOF - if( nRead == 0 ) - goto finish; + if (nRead == 0) + goto finish; #endif - } + } - offset += nRead; - nToRead -= nRead; + offset += nRead; + nToRead -= nRead; - litLen -= nRead; + litLen -= nRead; - if( litLen != 0 ) - goto copyLiteral; - } + if (litLen != 0) + goto copyLiteral; + } - if( nToRead == 0 ) - goto finish; + if (nToRead == 0) + goto finish; - phase = DecodePhase.ReadOffset; - goto readOffset; + phase = DecodePhase.ReadOffset; + goto readOffset; - readOffset: - if( inBufPos + 1 < inBufEnd ) - { - matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos]; - inBufPos += 2; - } - else - { + readOffset: + if (inBufPos + 1 < inBufEnd) + { + matDst = (decBuf[inBufPos + 1] << 8) | decBuf[inBufPos]; + inBufPos += 2; + } + else + { #if LOCAL_SHADOW this.inBufPos = inBufPos; #endif - matDst = ReadOffsetCore(); + matDst = ReadOffsetCore(); #if LOCAL_SHADOW inBufPos = this.inBufPos; inBufEnd = this.inBufEnd; #endif #if CHECK_EOF - if( matDst == -1 ) - goto finish; + if (matDst == -1) + goto finish; #endif - } + } - if( matLen == 15 + 4 ) - { - phase = DecodePhase.ReadExMatchLength; - goto readExMatchLength; - } - else - { - phase = DecodePhase.CopyMatch; - goto copyMatch; - } + if (matLen == 15 + 4) + { + phase = DecodePhase.ReadExMatchLength; + goto readExMatchLength; + } + else + { + phase = DecodePhase.CopyMatch; + goto copyMatch; + } - readExMatchLength: - int exMatLen; - if( inBufPos < inBufEnd ) - { - exMatLen = decBuf[inBufPos++]; - } - else - { + readExMatchLength: + int exMatLen; + if (inBufPos < inBufEnd) + { + exMatLen = decBuf[inBufPos++]; + } + else + { #if LOCAL_SHADOW this.inBufPos = inBufPos; #endif - exMatLen = ReadByteCore(); + exMatLen = ReadByteCore(); #if LOCAL_SHADOW inBufPos = this.inBufPos; inBufEnd = this.inBufEnd; #endif #if CHECK_EOF - if( exMatLen == -1 ) - goto finish; + if (exMatLen == -1) + goto finish; #endif - } + } - matLen += exMatLen; - if( exMatLen == 255 ) - goto readExMatchLength; + matLen += exMatLen; + if (exMatLen == 255) + goto readExMatchLength; - phase = DecodePhase.CopyMatch; - goto copyMatch; + phase = DecodePhase.CopyMatch; + goto copyMatch; - copyMatch: - int nCpyMat = matLen < nToRead ? matLen : nToRead; - if( nCpyMat != 0 ) - { - nRead = count - nToRead; + copyMatch: + int nCpyMat = matLen < nToRead ? matLen : nToRead; + if (nCpyMat != 0) + { + nRead = count - nToRead; - int bufDst = matDst - nRead; - if( bufDst > 0 ) - { - //offset is fairly far back, we need to pull from the buffer + int bufDst = matDst - nRead; + if (bufDst > 0) + { + //offset is fairly far back, we need to pull from the buffer - int bufSrc = decodeBufferPos - bufDst; - if( bufSrc < 0 ) - bufSrc += DecBufLen; - int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat; + int bufSrc = decodeBufferPos - bufDst; + if (bufSrc < 0) + bufSrc += DecBufLen; + int bufCnt = bufDst < nCpyMat ? bufDst : nCpyMat; - for( int c = bufCnt; c-- != 0; ) - buffer[offset++] = decBuf[bufSrc++ & DecBufMask]; - } - else - { - bufDst = 0; - } + for (int c = bufCnt; c-- != 0;) + buffer[offset++] = decBuf[bufSrc++ & DecBufMask]; + } + else + { + bufDst = 0; + } - int sOfs = offset - matDst; - for( int i = bufDst; i < nCpyMat; i++ ) - buffer[offset++] = buffer[sOfs++]; + int sOfs = offset - matDst; + for (int i = bufDst; i < nCpyMat; i++) + buffer[offset++] = buffer[sOfs++]; - nToRead -= nCpyMat; - matLen -= nCpyMat; - } + nToRead -= nCpyMat; + matLen -= nCpyMat; + } - if( nToRead == 0 ) - goto finish; + if (nToRead == 0) + goto finish; - phase = DecodePhase.ReadToken; - goto readToken; + phase = DecodePhase.ReadToken; + goto readToken; - finish: - nRead = count - nToRead; + finish: + nRead = count - nToRead; - int nToBuf = nRead < DecBufLen ? nRead : DecBufLen; - int repPos = offset - nToBuf; + int nToBuf = nRead < DecBufLen ? nRead : DecBufLen; + int repPos = offset - nToBuf; - if( nToBuf == DecBufLen ) - { - Buffer.BlockCopy( buffer, repPos, decBuf, 0, DecBufLen ); - decodeBufferPos = 0; - } - else - { - int decPos = decodeBufferPos; + if (nToBuf == DecBufLen) + { + Buffer.BlockCopy(buffer, repPos, decBuf, 0, DecBufLen); + decodeBufferPos = 0; + } + else + { + int decPos = decodeBufferPos; - while( nToBuf-- != 0 ) - decBuf[decPos++ & DecBufMask] = buffer[repPos++]; + while (nToBuf-- != 0) + decBuf[decPos++ & DecBufMask] = buffer[repPos++]; - decodeBufferPos = decPos & DecBufMask; - } + decodeBufferPos = decPos & DecBufMask; + } #if LOCAL_SHADOW this.phase = phase; this.inBufPos = inBufPos; #endif - return nRead; - } + return nRead; + } - private int ReadByteCore() - { - var buf = decodeBuffer; + private int ReadByteCore() + { + var buf = decodeBuffer; - if( inBufPos == inBufEnd ) - { - int nRead = input.Read( buf, DecBufLen, - InBufLen < inputLength ? InBufLen : (int)inputLength ); + if (inBufPos == inBufEnd) + { + int nRead = input.Read(buf, DecBufLen, + InBufLen < inputLength ? InBufLen : (int)inputLength); #if CHECK_EOF - if( nRead == 0 ) - return -1; + if (nRead == 0) + return -1; #endif - inputLength -= nRead; + inputLength -= nRead; - inBufPos = DecBufLen; - inBufEnd = DecBufLen + nRead; - } + inBufPos = DecBufLen; + inBufEnd = DecBufLen + nRead; + } - return buf[inBufPos++]; - } + return buf[inBufPos++]; + } - private int ReadOffsetCore() - { - var buf = decodeBuffer; + private int ReadOffsetCore() + { + var buf = decodeBuffer; - if( inBufPos == inBufEnd ) - { - int nRead = input.Read( buf, DecBufLen, - InBufLen < inputLength ? InBufLen : (int)inputLength ); + if (inBufPos == inBufEnd) + { + int nRead = input.Read(buf, DecBufLen, + InBufLen < inputLength ? InBufLen : (int)inputLength); #if CHECK_EOF - if( nRead == 0 ) - return -1; + if (nRead == 0) + return -1; #endif - inputLength -= nRead; + inputLength -= nRead; - inBufPos = DecBufLen; - inBufEnd = DecBufLen + nRead; - } + inBufPos = DecBufLen; + inBufEnd = DecBufLen + nRead; + } - if( inBufEnd - inBufPos == 1 ) - { - buf[DecBufLen] = buf[inBufPos]; + if (inBufEnd - inBufPos == 1) + { + buf[DecBufLen] = buf[inBufPos]; - int nRead = input.Read( buf, DecBufLen + 1, - InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength ); + int nRead = input.Read(buf, DecBufLen + 1, + InBufLen - 1 < inputLength ? InBufLen - 1 : (int)inputLength); #if CHECK_EOF - if( nRead == 0 ) - { - inBufPos = DecBufLen; - inBufEnd = DecBufLen + 1; + if (nRead == 0) + { + inBufPos = DecBufLen; + inBufEnd = DecBufLen + 1; - return -1; - } + return -1; + } #endif - inputLength -= nRead; + inputLength -= nRead; - inBufPos = DecBufLen; - inBufEnd = DecBufLen + nRead + 1; - } + inBufPos = DecBufLen; + inBufEnd = DecBufLen + nRead + 1; + } - int ret = (buf[inBufPos + 1] << 8) | buf[inBufPos]; - inBufPos += 2; + int ret = (buf[inBufPos + 1] << 8) | buf[inBufPos]; + inBufPos += 2; - return ret; - } + return ret; + } - private int ReadCore( byte[] buffer, int offset, int count ) - { - int nToRead = count; + private int ReadCore(byte[] buffer, int offset, int count) + { + int nToRead = count; - var buf = decodeBuffer; - int inBufLen = inBufEnd - inBufPos; + var buf = decodeBuffer; + int inBufLen = inBufEnd - inBufPos; - int fromBuf = nToRead < inBufLen ? nToRead : inBufLen; - if( fromBuf != 0 ) - { - var bufPos = inBufPos; + int fromBuf = nToRead < inBufLen ? nToRead : inBufLen; + if (fromBuf != 0) + { + var bufPos = inBufPos; - for( int c = fromBuf; c-- != 0; ) - buffer[offset++] = buf[bufPos++]; + for (int c = fromBuf; c-- != 0;) + buffer[offset++] = buf[bufPos++]; - inBufPos = bufPos; - nToRead -= fromBuf; - } + inBufPos = bufPos; + nToRead -= fromBuf; + } - if( nToRead != 0 ) - { - int nRead; + if (nToRead != 0) + { + int nRead; - if( nToRead >= InBufLen ) - { - nRead = input.Read( buffer, offset, - nToRead < inputLength ? nToRead : (int)inputLength ); - nToRead -= nRead; - } - else - { - nRead = input.Read( buf, DecBufLen, - InBufLen < inputLength ? InBufLen : (int)inputLength ); + if (nToRead >= InBufLen) + { + nRead = input.Read(buffer, offset, + nToRead < inputLength ? nToRead : (int)inputLength); + nToRead -= nRead; + } + else + { + nRead = input.Read(buf, DecBufLen, + InBufLen < inputLength ? InBufLen : (int)inputLength); - inBufPos = DecBufLen; - inBufEnd = DecBufLen + nRead; + inBufPos = DecBufLen; + 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; ) - buffer[offset++] = buf[bufPos++]; + for (int c = fromBuf; c-- != 0;) + buffer[offset++] = buf[bufPos++]; - inBufPos = bufPos; - nToRead -= fromBuf; - } + inBufPos = bufPos; + nToRead -= fromBuf; + } - inputLength -= nRead; - } + inputLength -= nRead; + } - return count - nToRead; - } + return count - nToRead; + } - #region Stream internals + #region Stream internals - public override bool CanRead - { - get { return true; } - } + public override bool CanRead => true; - public override bool CanSeek - { - get { return false; } - } + public override bool CanSeek => false; - public override bool CanWrite - { - get { return false; } - } + public override bool CanWrite => false; - public override void Flush() - { - } + public override void Flush() + { + } - public override long Length - { - get { throw new NotSupportedException(); } - } + public override long Length + { + get { throw new NotSupportedException(); } + } - public override long Position - { - get { throw new NotSupportedException(); } - set { throw new NotSupportedException(); } - } + public override long Position + { + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } + } - public override long Seek( long offset, SeekOrigin origin ) - { - throw new NotSupportedException(); - } + public override long Seek(long offset, SeekOrigin origin) + { + throw new NotSupportedException(); + } - public override void SetLength( long value ) - { - throw new NotSupportedException(); - } + public override void SetLength(long value) + { + throw new NotSupportedException(); + } - public override void Write( byte[] buffer, int offset, int count ) - { - throw new NotSupportedException(); - } + public override void Write(byte[] buffer, int offset, int count) + { + throw new NotSupportedException(); + } - #endregion - } + #endregion + } } diff --git a/Unity Studio/Unity Studio Classes/UnityStudio.cs b/Unity Studio/Unity Studio Classes/UnityStudio.cs index 45441f2..1c719f1 100644 --- a/Unity Studio/Unity Studio Classes/UnityStudio.cs +++ b/Unity Studio/Unity Studio Classes/UnityStudio.cs @@ -1105,10 +1105,6 @@ namespace Unity_Studio } } } - else - { - //bool stop = true; - } } MeshPD.uniqueID = keepID; @@ -1653,7 +1649,8 @@ namespace Unity_Studio public static bool ExportAudioClip(AssetPreloadData asset, string exportFilename, string 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"; } @@ -1661,7 +1658,7 @@ namespace Unity_Studio if (ExportFileExists(exportFullname)) return false; var m_AudioClip = new AudioClip(asset, true); - if ((bool)Properties.Settings.Default["convertfsb"] && oldextension == ".fsb") + if (convertfsb && oldextension == ".fsb") { FMOD.System system; FMOD.Sound sound; @@ -1769,10 +1766,10 @@ namespace Unity_Studio { 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++) { - vertices[v] = new ManagedFbx.Vector3( + vertices[v] = new Vector3( m_Mesh.m_Vertices[v * count], m_Mesh.m_Vertices[v * count + 1], m_Mesh.m_Vertices[v * count + 2]); @@ -1801,10 +1798,10 @@ namespace Unity_Studio 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++) { - normals[n] = new ManagedFbx.Vector3( + normals[n] = new Vector3( m_Mesh.m_Normals[n * count], m_Mesh.m_Normals[n * count + 1], m_Mesh.m_Normals[n * count + 2]); @@ -1815,20 +1812,20 @@ namespace Unity_Studio #region Colors 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++) { - colors[c] = new ManagedFbx.Colour( + colors[c] = new Colour( 0.5f, 0.5f, 0.5f, 1.0f); } mesh.VertexColours = colors; } 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++) { - colors[c] = new ManagedFbx.Colour( + colors[c] = new Colour( m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 2], @@ -1838,10 +1835,10 @@ namespace Unity_Studio } 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++) { - colors[c] = new ManagedFbx.Colour( + colors[c] = new Colour( m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 2], @@ -1853,19 +1850,19 @@ namespace Unity_Studio #region UV 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++) { - 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; } 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++) { - 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; } diff --git a/Unity Studio/UnityStudioForm.cs b/Unity Studio/UnityStudioForm.cs index c725759..97180c9 100644 --- a/Unity Studio/UnityStudioForm.cs +++ b/Unity Studio/UnityStudioForm.cs @@ -49,9 +49,9 @@ namespace Unity_Studio int vboColors; int vboViewMatrix; int eboElements; - OpenTK.Vector3[] vertexData; - OpenTK.Vector3[] normalData; - OpenTK.Vector4[] colorData; + Vector3[] vertexData; + Vector3[] normalData; + Vector4[] colorData; Matrix4[] viewMatrixData; int[] indiceData; 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 void loadFile_Click(object sender, System.EventArgs e) + private void loadFile_Click(object sender, EventArgs e) { 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(); @@ -274,11 +274,11 @@ namespace Unity_Studio { 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) { - 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) { @@ -596,7 +596,7 @@ namespace Unity_Studio if (treeSearch.Text == " Search ") { treeSearch.Text = ""; - treeSearch.ForeColor = System.Drawing.SystemColors.WindowText; + treeSearch.ForeColor = SystemColors.WindowText; } } @@ -605,7 +605,7 @@ namespace Unity_Studio if (treeSearch.Text == "") { treeSearch.Text = " Search "; - treeSearch.ForeColor = System.Drawing.SystemColors.GrayText; + treeSearch.ForeColor = SystemColors.GrayText; } } @@ -694,7 +694,7 @@ namespace Unity_Studio if (listSearch.Text == " Filter ") { listSearch.Text = ""; - listSearch.ForeColor = System.Drawing.SystemColors.WindowText; + listSearch.ForeColor = SystemColors.WindowText; enableFiltering = true; } } @@ -705,7 +705,7 @@ namespace Unity_Studio { enableFiltering = false; listSearch.Text = " Filter "; - listSearch.ForeColor = System.Drawing.SystemColors.GrayText; + listSearch.ForeColor = SystemColors.GrayText; } } @@ -716,7 +716,7 @@ namespace Unity_Studio assetListView.BeginUpdate(); assetListView.SelectedIndices.Clear(); //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.EndUpdate(); } @@ -742,7 +742,7 @@ namespace Unity_Studio { int xdiff = reverseSort ? b.Text.CompareTo(a.Text) : a.Text.CompareTo(b.Text); 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; case 1: @@ -750,7 +750,7 @@ namespace Unity_Studio { int xdiff = reverseSort ? b.TypeString.CompareTo(a.TypeString) : a.TypeString.CompareTo(b.TypeString); 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; case 2: @@ -758,7 +758,7 @@ namespace Unity_Studio { int xdiff = reverseSort ? b.Size.CompareTo(a.Size) : a.Size.CompareTo(b.Size); 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; } @@ -771,7 +771,7 @@ namespace Unity_Studio private void selectAsset(object sender, ListViewItemSelectionChangedEventArgs e) { previewPanel.BackgroundImage = Properties.Resources.preview; - previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + previewPanel.BackgroundImageLayout = ImageLayout.Center; assetInfoLabel.Visible = false; assetInfoLabel.Text = null; textPreviewBox.Visible = false; @@ -975,10 +975,10 @@ namespace Unity_Studio { 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++) { - vertexData[v] = new OpenTK.Vector3( + vertexData[v] = new Vector3( m_Mesh.m_Vertices[v * count], m_Mesh.m_Vertices[v * count + 1], m_Mesh.m_Vertices[v * count + 2]); @@ -1005,10 +1005,10 @@ namespace Unity_Studio 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++) { - normalData[n] = new OpenTK.Vector3( + normalData[n] = new Vector3( m_Mesh.m_Normals[n * count], m_Mesh.m_Normals[n * count + 1], m_Mesh.m_Normals[n * count + 2]); @@ -1018,19 +1018,19 @@ namespace Unity_Studio #region Colors 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++) { - colorData[c] = new OpenTK.Vector4( + colorData[c] = new Vector4( 0.5f, 0.5f, 0.5f, 1.0f); } } 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++) { - colorData[c] = new OpenTK.Vector4( + colorData[c] = new Vector4( m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 2], @@ -1039,10 +1039,10 @@ namespace Unity_Studio } 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++) { - colorData[c] = new OpenTK.Vector4( + colorData[c] = new Vector4( m_Mesh.m_Colors[c * 4], m_Mesh.m_Colors[c * 4 + 1], m_Mesh.m_Colors[c * 4 + 2], @@ -1375,7 +1375,7 @@ namespace Unity_Studio //Environment.Exit(-1); return true; } - else { return false; } + return false; } private void all3DObjectssplitToolStripMenuItem_Click(object sender, EventArgs e) @@ -1734,24 +1734,24 @@ namespace Unity_Studio 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.BindBuffer(BufferTarget.ArrayBuffer, vboAddress); - GL.BufferData(BufferTarget.ArrayBuffer, - (IntPtr)(data.Length * OpenTK.Vector3.SizeInBytes), + GL.BufferData(BufferTarget.ArrayBuffer, + (IntPtr)(data.Length * Vector3.SizeInBytes), data, BufferUsageHint.StaticDraw); GL.VertexAttribPointer(address, 3, VertexAttribPointerType.Float, false, 0, 0); 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.BindBuffer(BufferTarget.ArrayBuffer, vboAddress); - GL.BufferData(BufferTarget.ArrayBuffer, - (IntPtr)(data.Length * OpenTK.Vector4.SizeInBytes), + GL.BufferData(BufferTarget.ArrayBuffer, + (IntPtr)(data.Length * Vector4.SizeInBytes), data, BufferUsageHint.StaticDraw); 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.Save();*/ - base.Text = "Unity Studio"; + Text = "Unity Studio"; unityFiles.Clear(); assetsfileList.Clear(); @@ -1841,7 +1841,7 @@ namespace Unity_Studio classesListView.Groups.Clear(); previewPanel.BackgroundImage = Properties.Resources.preview; - previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; + previewPanel.BackgroundImageLayout = ImageLayout.Center; assetInfoLabel.Visible = false; assetInfoLabel.Text = null; textPreviewBox.Visible = false; diff --git a/Unity Studio/library/7zip license.txt b/Unity Studio/library/7zip license.txt deleted file mode 100644 index a3cc412..0000000 --- a/Unity Studio/library/7zip license.txt +++ /dev/null @@ -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