Exemple #1
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine(@" ____                    __                      ");
            Console.WriteLine(@"/\  _`\                 /\ \                     ");
            Console.WriteLine(@"\ \ \/\_\  __  __  _____\ \ \___      __   _ __  ");
            Console.WriteLine(@" \ \ \/_/_/\ \/\ \/\ '__`\ \  _ `\  /'__`\/\`'__\");
            Console.WriteLine(@"  \ \ \L\ \ \ \_\ \ \ \L\ \ \ \ \ \/\  __/\ \ \/ ");
            Console.WriteLine(@"   \ \____/\/`____ \ \ ,__/\ \_\ \_\ \____\\ \_\ ");
            Console.WriteLine(@"    \/___/  `/___/> \ \ \/  \/_/\/_/\/____/ \/_/ ");
            Console.WriteLine(@"               /\___/\ \_\                       ");
            Console.WriteLine(@"               \/__/  \/_/    Core Data Extractor");
            Console.WriteLine("\r");

            baseDirectory = Environment.CurrentDirectory;

            if (args.Length > 0)
            {
                baseDirectory = Path.GetDirectoryName(args[0]);
            }

            PrintInstructions();

            string answer = Console.ReadLine();

            if (answer == "5")
            {
                Environment.Exit(0);
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Initializing CASC library...");
            cascHandler = new CASCHandler(baseDirectory);
            Console.WriteLine("Done.");

            List <Locale> locales          = new List <Locale>();
            var           buildInfoLocales = Regex.Matches(cascHandler.buildInfo["Tags"], " ([A-Za-z]{4}) speech");

            foreach (Match m in buildInfoLocales)
            {
                var localFlag = (Locale)Enum.Parse(typeof(Locale), m.Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]);

                if (!locales.Contains(localFlag))
                {
                    locales.Add(localFlag);
                }
            }

            LocaleMask installedLocalesMask = (LocaleMask)cascHandler.GetInstalledLocalesMask();
            LocaleMask firstInstalledLocale = LocaleMask.None;

            for (Locale i = 0; i < Locale.Total; ++i)
            {
                if (i == Locale.None)
                {
                    continue;
                }

                if (!Convert.ToBoolean(installedLocalesMask & SharedConst.WowLocaleToCascLocaleFlags[(int)i]))
                {
                    continue;
                }

                firstInstalledLocale = SharedConst.WowLocaleToCascLocaleFlags[(int)i];
                break;
            }

            if (firstInstalledLocale < LocaleMask.None)
            {
                Console.WriteLine("No locales detected");
                return;
            }

            uint build = cascHandler.GetBuildNumber();

            if (build == 0)
            {
                Console.WriteLine("No build detected");
                return;
            }

            Console.WriteLine($"Detected client build: {build}");
            Console.WriteLine($"Detected client locale: {firstInstalledLocale}");
            cascHandler.SetLocale(firstInstalledLocale);
            if (!CliDB.LoadFiles(cascHandler))
            {
                return;
            }

            do
            {
                switch (answer)
                {
                case "1":
                    ExtractDbcFiles(firstInstalledLocale, installedLocalesMask);
                    ExtractMaps(build);
                    break;

                case "2":
                    ExtractVMaps();
                    break;

                case "3":
                    ExtractMMaps();
                    break;

                case "4":
                default:
                    ExtractDbcFiles(firstInstalledLocale, installedLocalesMask);
                    ExtractMaps(build);
                    ExtractVMaps();
                    //ExtractMMaps();
                    break;
                }

                PrintInstructions();
            } while ((answer = Console.ReadLine()) != "5");
        }