diff --git a/FModel/Converter/UnrealEngineDataToOGG.cs b/FModel/Converter/UnrealEngineDataToOGG.cs index 2143562f..410add53 100644 --- a/FModel/Converter/UnrealEngineDataToOGG.cs +++ b/FModel/Converter/UnrealEngineDataToOGG.cs @@ -7,10 +7,10 @@ namespace FModel.Converter { class UnrealEngineDataToOgg { - static byte[] _oggFind = { 0x4F, 0x67, 0x67, 0x53 }; - static byte[] _oggNoHeader = { 0x4F, 0x67, 0x67, 0x53 }; - static byte[] _uexpToDelete = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00 }; - static byte[] _oggOutNewArray; + private static byte[] _oggFind = { 0x4F, 0x67, 0x67, 0x53 }; + private static byte[] _uexpToDelete = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00 }; + private static byte[] _oggOutNewArray; + private static string oggPattern = "OggS"; private static List SearchBytePattern(byte[] pattern, byte[] bytes) { List positions = new List(); @@ -56,30 +56,36 @@ namespace FModel.Converter } return false; } + private static byte[] Combine(params byte[][] arrays) + { + byte[] rv = new byte[arrays.Sum(a => a.Length)]; + int offset = 0; + foreach (byte[] array in arrays) + { + Buffer.BlockCopy(array, 0, rv, offset, array.Length); + offset += array.Length; + } + return rv; + } + public static string ConvertToOgg(string file) { var isUbulkFound = new DirectoryInfo(Path.GetDirectoryName(file) ?? throw new InvalidOperationException()).GetFiles(Path.GetFileNameWithoutExtension(file) + "*.ubulk", SearchOption.AllDirectories).FirstOrDefault(); if (isUbulkFound == null) { - string oggPattern = "OggS"; if (File.ReadAllText(file).Contains(oggPattern)) { byte[] src = File.ReadAllBytes(file); - TryFindAndReplace(src, _oggFind, _oggNoHeader, out _oggOutNewArray); - File.WriteAllBytes(Path.GetFileNameWithoutExtension(file) + ".temp", _oggOutNewArray); + TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - FileInfo fi = new FileInfo(Path.GetFileNameWithoutExtension(file) + ".temp"); - FileStream fs = fi.Open(FileMode.Open); - long bytesToDelete = 4; - fs.SetLength(Math.Max(0, fi.Length - bytesToDelete)); - fs.Close(); + byte[] tmp = new byte[_oggOutNewArray.Length]; + Array.Copy(_oggOutNewArray, tmp, Math.Max(0, _oggOutNewArray.Length - 4)); //DELETE LAST 4 BYTES - byte[] srcFinal = File.ReadAllBytes(Path.GetFileNameWithoutExtension(file) + ".temp"); - int i = srcFinal.Length - 7; - while (srcFinal[i] == 0) + int i = tmp.Length - 7; + while (tmp[i] == 0) --i; byte[] bar = new byte[i + 1]; - Array.Copy(srcFinal, bar, i + 1); + Array.Copy(tmp, bar, i + 1); //DELETE EMPTY BYTES AT THE END File.WriteAllBytes(App.DefaultOutputPath + "\\Sounds\\" + Path.GetFileNameWithoutExtension(file) + ".ogg", bar); File.Delete(Path.GetFileNameWithoutExtension(file) + ".temp"); @@ -87,43 +93,26 @@ namespace FModel.Converter } else { - string oggPattern = "OggS"; if (File.ReadAllText(file).Contains(oggPattern)) { byte[] src = File.ReadAllBytes(file); + byte[] srcUbulk = File.ReadAllBytes(Path.GetDirectoryName(file) + "\\" + isUbulkFound); + List positions = SearchBytePattern(_uexpToDelete, src); - - TryFindAndReplace(src, _oggFind, _oggNoHeader, out _oggOutNewArray); - File.WriteAllBytes(Path.GetFileNameWithoutExtension(file) + ".temp", _oggOutNewArray); - int lengthToDelete = src.Length - positions[0]; - FileInfo fi = new FileInfo(Path.GetFileNameWithoutExtension(file) + ".temp"); - FileStream fs = fi.Open(FileMode.Open); - long bytesToDelete = lengthToDelete; - fs.SetLength(Math.Max(0, fi.Length - bytesToDelete)); - fs.Close(); + TryFindAndReplace(src, _oggFind, _oggFind, out _oggOutNewArray); //MAKE THE ARRAY START AT PATTERN POSITION - byte[] src44 = File.ReadAllBytes(Path.GetFileNameWithoutExtension(file) + ".temp"); - byte[] srcUbulk = File.ReadAllBytes(Path.GetDirectoryName(file) + "\\" + isUbulkFound); - byte[] buffer = new byte[srcUbulk.Length]; - using (FileStream fs1 = new FileStream(Path.GetDirectoryName(file) + "\\" + isUbulkFound, FileMode.Open, FileAccess.ReadWrite)) - { - fs1.Read(buffer, 0, buffer.Length); + byte[] tmp = new byte[_oggOutNewArray.Length]; + Array.Copy(_oggOutNewArray, tmp, Math.Max(0, _oggOutNewArray.Length - lengthToDelete)); //DELETE LAST BYTES WHEN _uexpToDelete IS FOUND - FileStream fs2 = new FileStream(Path.GetFileNameWithoutExtension(file) + ".temp", FileMode.Open, FileAccess.ReadWrite); - fs2.Position = src44.Length; - fs2.Write(buffer, 0, buffer.Length); - fs2.Close(); - fs1.Close(); - } + byte[] tmp2 = Combine(tmp, srcUbulk); //ADD UBULK ARRAY TO UEXP ARRAY - byte[] srcFinal = File.ReadAllBytes(Path.GetFileNameWithoutExtension(file) + ".temp"); - int i = srcFinal.Length - 1; - while (srcFinal[i] == 0) + int i = tmp2.Length - 1; + while (tmp2[i] == 0) --i; byte[] bar = new byte[i + 1]; - Array.Copy(srcFinal, bar, i + 1); + Array.Copy(tmp2, bar, i + 1); //DELETE EMPTY BYTES AT THE END File.WriteAllBytes(App.DefaultOutputPath + "\\Sounds\\" + Path.GetFileNameWithoutExtension(file) + ".ogg", bar); File.Delete(Path.GetFileNameWithoutExtension(file) + ".temp"); diff --git a/FModel/CurrentCommit.txt b/FModel/CurrentCommit.txt deleted file mode 100644 index 820bc14a..00000000 --- a/FModel/CurrentCommit.txt +++ /dev/null @@ -1 +0,0 @@ -4d81e3a diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index ceb0f72f..45da7b48 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -219,7 +219,6 @@ Always - Always @@ -268,6 +267,7 @@ - git rev-parse --short HEAD > "$(ProjectDir)\CurrentCommit.txt" + + \ No newline at end of file diff --git a/FModel/Forms/About.Designer.cs b/FModel/Forms/About.Designer.cs index 136dd1f2..8a3b7c02 100644 --- a/FModel/Forms/About.Designer.cs +++ b/FModel/Forms/About.Designer.cs @@ -38,8 +38,6 @@ this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); - this.commitHash = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -140,30 +138,6 @@ this.label6.Text = "• FireMonkey"; this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // commitHash - // - this.commitHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.commitHash.AutoSize = true; - this.commitHash.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.commitHash.Location = new System.Drawing.Point(415, 124); - this.commitHash.Name = "commitHash"; - this.commitHash.Size = new System.Drawing.Size(40, 12); - this.commitHash.TabIndex = 9; - this.commitHash.Text = "1234567"; - this.commitHash.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // label7 - // - this.label7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label7.AutoSize = true; - this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label7.Location = new System.Drawing.Point(370, 123); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(44, 13); - this.label7.TabIndex = 10; - this.label7.Text = "Commit:"; - this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // label8 // this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -182,8 +156,6 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(467, 145); this.Controls.Add(this.label8); - this.Controls.Add(this.label7); - this.Controls.Add(this.commitHash); this.Controls.Add(this.label6); this.Controls.Add(this.label5); this.Controls.Add(this.label4); @@ -217,8 +189,6 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label commitHash; - private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label8; } } \ No newline at end of file diff --git a/FModel/Forms/About.cs b/FModel/Forms/About.cs index 22057861..352ba04b 100644 --- a/FModel/Forms/About.cs +++ b/FModel/Forms/About.cs @@ -1,4 +1,5 @@ -using System.Windows.Forms; +using System.IO; +using System.Windows.Forms; namespace FModel.Forms { @@ -9,7 +10,6 @@ namespace FModel.Forms InitializeComponent(); label2.Text += @" " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5); - commitHash.Text = Properties.Resources.CurrentCommit; } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/FModel/Properties/Resources.Designer.cs b/FModel/Properties/Resources.Designer.cs index 4b2ab967..951cb282 100644 --- a/FModel/Properties/Resources.Designer.cs +++ b/FModel/Properties/Resources.Designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Ce code a été généré par un outil. +// Version du runtime :4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si +// le code est régénéré. // //------------------------------------------------------------------------------ @@ -13,13 +13,13 @@ namespace FModel.Properties { /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder + // à l'aide d'un outil, tel que ResGen ou Visual Studio. + // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen + // avec l'option /str ou régénérez votre projet VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -33,7 +33,7 @@ namespace FModel.Properties { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { @@ -47,8 +47,8 @@ namespace FModel.Properties { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Remplace la propriété CurrentUICulture du thread actuel pour toutes + /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -61,7 +61,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap BG512 { get { @@ -71,7 +71,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Byte[]. + /// Recherche une ressource localisée de type System.Byte[]. /// internal static byte[] BurbankBigCondensed_Black { get { @@ -81,7 +81,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Byte[]. + /// Recherche une ressource localisée de type System.Byte[]. /// internal static byte[] BurbankBigCondensed_Bold { get { @@ -91,7 +91,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap C512 { get { @@ -101,7 +101,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap Challenges_Slider { get { @@ -111,17 +111,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized string similar to 71e11bb - ///. - /// - internal static string CurrentCommit { - get { - return ResourceManager.GetString("CurrentCommit", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap E512 { get { @@ -131,7 +121,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// Recherche une ressource localisée de type System.Drawing.Icon semblable à (Icône). /// internal static System.Drawing.Icon FModel { get { @@ -141,7 +131,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap FModel_Logo { get { @@ -151,7 +141,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap folder_16x { get { @@ -161,7 +151,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap folder_Closed_16xLG { get { @@ -171,7 +161,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap L512 { get { @@ -181,7 +171,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap M512 { get { @@ -191,7 +181,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap Marvel512 { get { @@ -201,7 +191,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap properties_16xLG { get { @@ -211,7 +201,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap Quest { get { @@ -221,7 +211,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap R512 { get { @@ -231,7 +221,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap StatusAnnotations_Information_16xLG_color { get { @@ -241,7 +231,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_FNBR_BattlePoints_L { get { @@ -251,7 +241,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_FNBR_SeasonalXP_L { get { @@ -261,7 +251,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Adaptive_64 { get { @@ -271,7 +261,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Animated_64 { get { @@ -281,7 +271,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Pets_64 { get { @@ -291,7 +281,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Quests_64 { get { @@ -301,7 +291,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Traversal_64 { get { @@ -311,7 +301,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Icon_Variant_64 { get { @@ -321,7 +311,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T_Items_MTX_L { get { @@ -331,7 +321,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap T512 { get { @@ -341,7 +331,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap U512 { get { @@ -351,7 +341,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap unknown512 { get { @@ -361,7 +351,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap wTemplate { get { @@ -371,7 +361,7 @@ namespace FModel.Properties { } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. + /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// internal static System.Drawing.Bitmap wTemplateF { get { diff --git a/FModel/Properties/Resources.resx b/FModel/Properties/Resources.resx index 0097387b..af9b14ea 100644 --- a/FModel/Properties/Resources.resx +++ b/FModel/Properties/Resources.resx @@ -211,7 +211,4 @@ ..\Resources\Challenges_Slider.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\CurrentCommit.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - \ No newline at end of file