diff --git a/CSGO Advanced Item Parser.sln b/CSGO Advanced Item Parser.sln new file mode 100644 index 0000000..07fc3a1 --- /dev/null +++ b/CSGO Advanced Item Parser.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSGO Advanced Item Parser", "CSGO Advanced Item Parser\CSGO Advanced Item Parser.csproj", "{B7116EA5-BA92-483D-A623-8879E32B6008}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B7116EA5-BA92-483D-A623-8879E32B6008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7116EA5-BA92-483D-A623-8879E32B6008}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7116EA5-BA92-483D-A623-8879E32B6008}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7116EA5-BA92-483D-A623-8879E32B6008}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B315ABA3-7742-428A-A1C9-4180C679F4F4} + EndGlobalSection +EndGlobal diff --git a/CSGO Advanced Item Parser/App.config b/CSGO Advanced Item Parser/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/CSGO Advanced Item Parser/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj b/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj new file mode 100644 index 0000000..5be61a2 --- /dev/null +++ b/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj @@ -0,0 +1,99 @@ + + + + + Debug + AnyCPU + {B7116EA5-BA92-483D-A623-8879E32B6008} + Exe + CSGO_Advanced_Item_Parser + CSGO Advanced Item Parser + v4.7.2 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + LocalIntranet + + + false + + + Properties\app.manifest + + + gas_mask_YZV_icon.ico + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + \ No newline at end of file diff --git a/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj.user b/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj.user new file mode 100644 index 0000000..a29b1fd --- /dev/null +++ b/CSGO Advanced Item Parser/CSGO Advanced Item Parser.csproj.user @@ -0,0 +1,19 @@ + + + + Project + + + publish\ + + + + + + en-US + false + + + false + + \ No newline at end of file diff --git a/CSGO Advanced Item Parser/Program.cs b/CSGO Advanced Item Parser/Program.cs new file mode 100644 index 0000000..1539a66 --- /dev/null +++ b/CSGO Advanced Item Parser/Program.cs @@ -0,0 +1,250 @@ +using System.IO; +using System.Text; +using System.Diagnostics; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using System; +using System.Linq; +using System.Threading; + +namespace CSGO_Advanced_Item_Parser +{ + public class Program + { + //Natural sort method + public static IEnumerable NaturalSort(IEnumerable list) + { + int maxLen = list.Select(s => s.Length).Max(); + Func PaddingChar = s => char.IsDigit(s[0]) ? ' ' : char.MaxValue; + + return list + .Select(s => + new + { + OrgStr = s, + SortStr = Regex.Replace(s, @"(\d+)|(\D+)", m => m.Value.PadLeft(maxLen, PaddingChar(m.Value))) + }) + .OrderBy(x => x.SortStr) + .Select(x => x.OrgStr); + } + + //Getting the CS:GO directory + private static string getcsgoPath() + { + var value = ""; + foreach (var process in Process.GetProcessesByName("csgo")) + { + value = Path.GetDirectoryName(process.MainModule.FileName); + } + return value.ToString(); + } + + //Creating cool ASCII text :D + private static void createAscii() + { + string a1 = " ____ __ _ __ ____ "; + string a2 = @" / __ \___ ____ ___ _____ _____/ /| |/ / / __ \___ _ __"; + string a3 = @" / /_/ / _ \/ __ `/ / / / _ \/ ___/ __| / / / / / _ | | / /"; + string a4 = @" / _, _/ __/ /_/ / /_/ / __(__ / /_/ | / /_/ / __| |/ _ "; + string a5 = @"/_/ |_|\___/\__, /\__,_/\___/____/\__/_/|_| /_____/\___/|___(_)"; + string a6 = ""; + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a1.Length / 2)) + "}", a1), Console.ForegroundColor = ConsoleColor.DarkRed); + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a2.Length / 2)) + "}", a2), Console.ForegroundColor = ConsoleColor.DarkRed); + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a3.Length / 2)) + "}", a3), Console.ForegroundColor = ConsoleColor.DarkRed); + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a4.Length / 2)) + "}", a4), Console.ForegroundColor = ConsoleColor.DarkRed); + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a5.Length / 2)) + "}", a5), Console.ForegroundColor = ConsoleColor.DarkRed); + Console.WriteLine(String.Format("{0," + ((Console.WindowWidth / 2) + (a6.Length / 2)) + "}", a6), Console.ForegroundColor = ConsoleColor.DarkRed); + } + + //Main + public static void Main(string[] args) + { + //Variable #1 - Lists + List skinsID = new List(); + List skinsTag = new List(); + List skinsName = new List(); + List skinsName_cdn = new List(); + List skinsName_cdn2 = new List(); + List skinsImage = new List(); + List skinsRarity = new List(); + List skinWpnName = new List(); + + //Variable #2 - Regex options + RegexOptions options = RegexOptions.Multiline; + RegexOptions options2 = RegexOptions.Multiline | RegexOptions.IgnoreCase; + + //Variable #3 - Strings + string pattern = @"""([\d]*)""[\s]*{[\s]*""name""[\s]*""(.*)""[\s]*""description_[\w]+""[\s]*""#(.*)""[\s]*""description_[\w]+""[\s]*""#(.*)"""; + string pattern2 = @"}[\s]*""([\d]+)""[\s]*{[\s]*""name""[\s]*""([a-zA-Z0-9_]+)""[\s]*""prefab"; + + //Part #1 - First Process + Console.Title = "CS:GO | Advanced Item Parser v1.0"; + createAscii(); + Console.WriteLine("Waiting for CS:GO to open...\n".PadLeft(1), Console.ForegroundColor = ConsoleColor.Yellow, Console.BackgroundColor = ConsoleColor.DarkMagenta); + Console.ResetColor(); + + //Part #2 - Check game is opened + while (true) + { + Process[] processes = Process.GetProcessesByName("csgo"); + if (processes.Length != 0) + { + Console.Clear(); + createAscii(); + Console.WriteLine("Process started.. Please wait for process finish.\n".PadLeft(1), Console.ForegroundColor = ConsoleColor.Yellow, Console.BackgroundColor = ConsoleColor.DarkMagenta); + Console.ResetColor(); + break; + } + } + + //Variable #4 - Extra Strings + string _itemsFileLocation = File.ReadAllText(getcsgoPath() + @"\csgo\scripts\items\items_game.txt"); + string _englishFileLocation = File.ReadAllText(getcsgoPath() + @"\csgo\resource\csgo_english.txt"); + string _itemscdnFileLocation = File.ReadAllText(getcsgoPath() + @"\csgo\scripts\items\items_game_cdn.txt"); + + //Part #3 - Get Items cdn name, id and Tag + foreach (Match m in Regex.Matches(_itemsFileLocation, pattern)) + { + if (!m.Groups[4].Value.Contains("Default")) + { + for (int i = 1; i < Regex.Matches(_itemscdnFileLocation, "_" + m.Groups[2].Value + "=").Count + 1; i++) + { + skinsTag.Add(m.Groups[4].Value); + } + } + if (!m.Groups[2].Value.Contains("default")) + { + skinsName_cdn.Add(m.Groups[2].Value); + } + + if (!m.Groups[2].Value.Contains("default")) + { + for (int i = 1; i < Regex.Matches(_itemscdnFileLocation, "_" + m.Groups[2].Value + "=").Count + 1; i++) + { + skinsName_cdn2.Add(m.Groups[2].Value); + } + } + + if (m.Groups[1].Value != "0") + { + for (int i = 1; i < Regex.Matches(_itemscdnFileLocation, "_" + m.Groups[2].Value + "=").Count + 1; i++) + { + skinsID.Add(m.Groups[1].Value); + } + } + } + + //Part #4 - Get Items tag translations + foreach (var translation in skinsTag) + { + string blankTranslation = null; + Match m = Regex.Match(_englishFileLocation, @"""" + translation + @""".*""(.*)""", options); + if (m.Groups[1].Value == string.Empty) + { + blankTranslation = translation; + Match m2 = Regex.Match(_englishFileLocation, @"""" + blankTranslation + @""".*""(.*)""", options2); + skinsName.Add(m2.Groups[1].Value); + } + else + { + skinsName.Add(m.Groups[1].Value); + } + } + + //Part #5 - Get Items image links + foreach (var links in skinsName_cdn) + { + string blankLink = null; + + foreach (Match m in Regex.Matches(_itemscdnFileLocation, links + @"=(.*)", options)) + { + if (m.Groups[1].Value == string.Empty) + { + blankLink = links; + + Match m2 = Regex.Match(_itemscdnFileLocation, blankLink + @"=(.*)", options2); + skinsImage.Add(m2.Groups[1].Value); + } + else + { + skinsImage.Add(m.Groups[1].Value); + } + } + } + + //Part #6 - Get Items rarity + foreach (var rarity in skinsName_cdn) + { + foreach (Match m in Regex.Matches(_itemsFileLocation, @"""" + rarity + @"""\t\t""(.*)""", options)) + { + for (int i = 1; i < Regex.Matches(_itemscdnFileLocation, "_" + rarity + "=").Count + 1; i++) + { + skinsRarity.Add(m.Groups[1].Value); + } + } + } + + //Part #7 - Zip all list + var total = skinsID.Zip(skinsName, (first, second) => first + ": " + second); + var total2 = total.Zip(skinsImage, (first, second) => first + ": " + second.Trim()); + var total3 = total2.Zip(skinsRarity, (first, second) => first + " (" + second + ")"); + + //Part #8- Get Items real name + foreach (var wpnNames in skinsName_cdn) + { + foreach (var total4_h in total3) + { + foreach (Match m in Regex.Matches(total4_h, @"http:..media.steampowered.com.apps.730.icons.econ.default_generated.(.{0,35}" + wpnNames + "_light_large" + ")")) + { + if (m.Groups[1].Value == string.Empty) + { + skinWpnName.Add("??"); + } + else + { + skinWpnName.Add(m.Groups[1].Value.Replace("_" + wpnNames, "").Replace("_light_large", "").Replace("weapon_", "").ToUpper().Replace("İ", "I").Replace("_", " ")); + } + } + } + } + + //Part #9- Zip finish list + var total4 = total3.Zip(skinWpnName, (first, second) => first + " | " + second); + + //Part #10 - Create save file text + StringBuilder saveText = new StringBuilder(); + foreach (var item in total4) + { + saveText.AppendLine(item); + } + + //Part #11 - Get sorted save file text + List items = new List(saveText.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); + var sortedList1 = NaturalSort(items).ToArray(); + + //Part #12 - Get Items ID + StringBuilder itemsID = new StringBuilder(); + foreach (Match m in Regex.Matches(_itemsFileLocation, pattern2, options)) + { + itemsID.AppendLine(m.Groups[1].Value + ": " + m.Groups[2].Value); + } + + //Part #13 - Finish process + Console.BackgroundColor = ConsoleColor.Black; + Console.ForegroundColor = ConsoleColor.Gray; + Console.Clear(); + saveText.Clear(); + foreach (var item in sortedList1) + { + saveText.AppendLine(item); + } + File.WriteAllText("items_parsed.txt", saveText.ToString().TrimEnd()); + File.WriteAllText("items_definitions.txt", itemsID.ToString()); + createAscii(); + Console.WriteLine("Process finished. Files saved to " + Directory.GetCurrentDirectory() + " directory.".PadRight(1), Console.ForegroundColor = ConsoleColor.Yellow, Console.BackgroundColor = ConsoleColor.DarkMagenta); + Console.ResetColor(); + Console.WriteLine("\nPress enter to continue..."); + Console.ReadKey(); + } + } +} \ No newline at end of file diff --git a/CSGO Advanced Item Parser/Properties/AssemblyInfo.cs b/CSGO Advanced Item Parser/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ad3458b --- /dev/null +++ b/CSGO Advanced Item Parser/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CSGO - Advanced Item Parser")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("RequestX | International Developer Group")] +[assembly: AssemblyProduct("CSGO - Advanced Item Parser")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b7116ea5-ba92-483d-a623-8879e32b6008")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0")] +[assembly: AssemblyFileVersion("1.0")] diff --git a/CSGO Advanced Item Parser/Properties/app.manifest b/CSGO Advanced Item Parser/Properties/app.manifest new file mode 100644 index 0000000..ae6d090 --- /dev/null +++ b/CSGO Advanced Item Parser/Properties/app.manifest @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CSGO Advanced Item Parser/gas_mask_YZV_icon.ico b/CSGO Advanced Item Parser/gas_mask_YZV_icon.ico new file mode 100644 index 0000000..7a68c07 Binary files /dev/null and b/CSGO Advanced Item Parser/gas_mask_YZV_icon.ico differ