private static void TryFetchLocaleFromRegistry() { try { if (Flags.Language == null) { var textLanguage = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Blizzard Entertainment\Battle.net\Launch Options\Pro", "LOCALE", null); if (ValidLanguages.Contains(textLanguage)) { Flags.Language = textLanguage; } else { Logger.Error("Core", $"Invalid text language found via registry: {textLanguage}. Ignoring."); } } if (Flags.SpeechLanguage == null) { var speechLanguage = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Blizzard Entertainment\Battle.net\Launch Options\Pro", "LOCALE_AUDIO", null); if (ValidLanguages.Contains(speechLanguage)) { Flags.SpeechLanguage = speechLanguage; } else { Logger.Error("Core", $"Invalid speech language found via registry: {speechLanguage}. Ignoring."); } } } catch (Exception) { // Ignored } }
public void Parse(ICLIFlags toolFlags) { var flags = (ExtractFlags)toolFlags; var output = Path.Combine(flags.OutputPath, "Dump", "STU"); if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } var serializers = new Dictionary <Type, IDragonMLSerializer> { { typeof(teStructuredDataAssetRef <>), new teResourceGUIDSerializer() } }; foreach (var type in new ushort[] { 0x3, 0x15, 0x18, 0x1A, 0x1B, 0x1F, 0x20, 0x21, 0x24, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x39, 0x3A, 0x3B, 0x45, 0x49, 0x4C, 0x4E, 0x51, 0x53, 0x54, 0x55, 0x58, 0x5A, 0x5B, 0x5E, 0x5F, 0x62, 0x63, 0x64, 0x65, 0x66, 0x68, 0x70, 0x71, 0x72, 0x75, 0x78, 0x79, 0x7A, 0x7F, 0x81, 0x90, 0x91, 0x95, 0x96, 0x97, 0x98, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA2, 0xA3, 0xA5, 0xA6, 0xA8, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB5, 0xB7, 0xBF, 0xC0, 0xC2, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCC, 0xCE, 0xCF, 0xD0, 0xD4, 0xD5, 0xD6, 0xD7, 0xD9, 0xDC, 0xDF, 0xEB, 0xEC, 0xEE, 0xF8, 0x10D, 0x114, 0x116, 0x11A, 0x122 }) { if (!Directory.Exists(Path.Combine(output, type.ToString("X3")))) { Directory.CreateDirectory(Path.Combine(output, type.ToString("X3"))); } foreach (var guid in Program.TrackedFiles[type]) { try { Logger.Log24Bit(ConsoleSwatch.XTermColor.Purple5, true, Console.Out, null, $"Saving {teResourceGUID.AsString(guid)}"); using (var stu = STUHelper.OpenSTUSafe(guid)) using (Stream f = File.Open(Path.Combine(output, type.ToString("X3"), teResourceGUID.AsString(guid) + ".xml"), FileMode.Create)) using (TextWriter w = new StreamWriter(f)) { w.WriteLine(DragonML.Print(stu?.Instances[0], new DragonMLSettings { TypeSerializers = serializers })); } } catch (Exception e) { Logger.Error("STU", e.ToString()); } } } }
private static void Main() { InitTankSettings(); HookConsole(); var tools = GetTools(); #if DEBUG FlagParser.CheckCollisions(typeof(ToolFlags), (flag, duplicate) => { Logger.Error("Flag", $"The flag \"{flag}\" from {duplicate} is a duplicate!"); }); #endif FlagParser.LoadArgs(); Logger.Info("Core", $"{Assembly.GetExecutingAssembly().GetName().Name} v{Util.GetVersion(typeof(Program).Assembly)}"); Logger.Info("Core", $"CommandLine: [{string.Join(", ", FlagParser.AppArgs.Select(x => $"\"{x}\""))}]"); Flags = FlagParser.Parse <ToolFlags>(full => PrintHelp(full, tools)); if (Flags == null) { return; } Logger.Info("Core", $"CommandLineFile: {FlagParser.ArgFilePath}"); if (Flags.SaveArgs) { FlagParser.AppArgs = FlagParser.AppArgs.Where(x => !x.StartsWith("--arg")).ToArray(); FlagParser.SaveArgs(Flags.OverwatchDirectory); } else if (Flags.ResetArgs || Flags.DeleteArgs) { FlagParser.ResetArgs(); if (Flags.DeleteArgs) { FlagParser.DeleteArgs(); } Logger.Info("Core", $"CommandLineNew: [{string.Join(", ", FlagParser.AppArgs.Select(x => $"\"{x}\""))}]"); Flags = FlagParser.Parse <ToolFlags>(full => PrintHelp(full, tools)); if (Flags == null) { return; } } if (string.IsNullOrWhiteSpace(Flags.OverwatchDirectory) || string.IsNullOrWhiteSpace(Flags.Mode) || Flags.Help) { PrintHelp(false, tools); return; } ITool targetTool = null; ICLIFlags targetToolFlags = null; ToolAttribute targetToolAttributes = null; #region Tool Activation foreach (var type in tools) { var attribute = type.GetCustomAttribute <ToolAttribute>(); if (!string.Equals(attribute.Keyword, Flags.Mode, StringComparison.InvariantCultureIgnoreCase)) { continue; } targetTool = Activator.CreateInstance(type) as ITool; targetToolAttributes = attribute; if (attribute.CustomFlags != null) { var flags = attribute.CustomFlags; if (typeof(ICLIFlags).IsAssignableFrom(flags)) { targetToolFlags = typeof(FlagParser).GetMethod(nameof(FlagParser.Parse), new Type[] { }) ?.MakeGenericMethod(flags) .Invoke(null, null) as ICLIFlags; } } break; } if (targetToolFlags == null && targetTool != null) { return; } if (targetTool == null) { FlagParser.Help <ToolFlags>(false, new Dictionary <string, string>()); PrintHelp(false, tools); return; } #endregion if (!targetToolAttributes.UtilNoArchiveNeeded) { try { InitStorage(Flags.Online); } catch { Logger.Log24Bit(ConsoleSwatch.XTermColor.OrangeRed, true, Console.Error, "CASC", "=================\nError initializing CASC!\n" + "Please Scan & Repair your game, launch it for a minute, and try the tools again before reporting a bug!\n" + "========================"); throw; } //foreach (KeyValuePair<ushort, HashSet<ulong>> type in TrackedFiles.OrderBy(x => x.Key)) { // //Console.Out.WriteLine($"Found type: {type.Key:X4} ({type.Value.Count} files)"); // Console.Out.WriteLine($"Found type: {type.Key:X4}"); //} InitKeys(); InitMisc(); } var stopwatch = new Stopwatch(); Logger.Info("Core", "Tooling..."); stopwatch.Start(); targetTool.Parse(targetToolFlags); stopwatch.Stop(); Logger.Success("Core", $"Execution finished in {stopwatch.Elapsed} seconds"); ShutdownMisc(); }
public static void InitStorage(bool online = false) // turnin offline off again, can cause perf issues with bundle hack // Attempt to load language via registry, if they were already provided via flags then this won't do anything { if (!Flags.NoLanguageRegistry) { TryFetchLocaleFromRegistry(); } Logger.Info("CASC", $"Text Language: {Flags.Language} | Speech Language: {Flags.SpeechLanguage}"); var args = new ClientCreateArgs { SpeechLanguage = Flags.SpeechLanguage, TextLanguage = Flags.Language, HandlerArgs = new ClientCreateArgs_Tank { CacheAPM = Flags.UseCache, ManifestRegion = Flags.RCN ? ProductHandler_Tank.REGION_CN : ProductHandler_Tank.REGION_DEV }, Online = online }; LoadHelper.PreLoad(); Client = new ClientHandler(Flags.OverwatchDirectory, args); LoadHelper.PostLoad(Client); if (args.TextLanguage != "enUS") { Logger.Warn("Core", "Reminder! When extracting data in other languages, the names of the heroes/skins/etc must be in the language you have chosen."); } if (Client.AgentProduct.ProductCode != "pro") { Logger.Warn("Core", $"The branch \"{Client.AgentProduct.ProductCode}\" is not supported!. This might result in failure to load. Proceed with caution."); } var clientLanguages = Client.AgentProduct.Settings.Languages.Select(x => x.Language).ToArray(); if (!clientLanguages.Contains(args.TextLanguage)) { Logger.Warn("Core", "Battle.Net Agent reports that text language {0} is not installed.", args.TextLanguage); } else if (!clientLanguages.Contains(args.SpeechLanguage)) { Logger.Warn("Core", "Battle.Net Agent reports that speech language {0} is not installed.", args.SpeechLanguage); } TankHandler = Client.ProductHandler as ProductHandler_Tank; if (TankHandler == null) { Logger.Error("Core", $"Not a valid Overwatch installation (detected product: {Client.Product})"); return; } BuildVersion = uint.Parse(Client.InstallationInfo.Values["Version"].Split('.').Last()); if (BuildVersion < 39028) { Logger.Error("Core", "DataTool doesn't support Overwatch versions below 1.14. Please use OverTool."); } else if (BuildVersion < ProductHandler_Tank.VERSION_152_PTR) { Logger.Error("Core", "This version of DataTool doesn't support versions of Overwatch below 1.52. Please downgrade DataTool."); } InitTrackedFiles(); }