public override bool Execute(List<string> args) { if (args.Count != 2) return false; var type = args[0]; var outDir = args[1]; TagLayoutWriter writer; switch (type) { case "csharp": writer = new CSharpLayoutWriter(); break; case "cpp": writer = new CppLayoutWriter(); break; default: return false; } Directory.CreateDirectory(outDir); var count = 0; using (var stream = _info.OpenCacheRead()) { foreach (var groupTag in _cache.Tags.NonNull().Select(t => t.Group.Tag).Distinct()) { TagLayoutGuess layout = null; TagInstance lastTag = null; foreach (var tag in _cache.Tags.FindAllInGroup(groupTag)) { Console.Write("Analyzing "); TagPrinter.PrintTagShort(tag); lastTag = tag; var analyzer = new TagAnalyzer(_cache); var data = _cache.ExtractTag(stream, tag); var tagLayout = analyzer.Analyze(data); if (layout != null) layout.Merge(tagLayout); else layout = tagLayout; } if (layout != null && lastTag != null) { Console.WriteLine("Writing {0} layout", groupTag); var name = _info.StringIds.GetString(lastTag.Group.Name); var tagLayout = LayoutGuessFinalizer.MakeLayout(layout, name, groupTag); var path = Path.Combine(outDir, writer.GetSuggestedFileName(tagLayout)); writer.WriteLayout(tagLayout, path); count++; } } } Console.WriteLine("Successfully generated {0} layouts!", count); return true; }
public override bool Execute(List<string> args) { if (args.Count != 2) return false; var outDir = args[1]; ITagLayoutWriter writer; switch (args[0]) { case "csharp": writer = new CSharpClassWriter(_stringIds, outDir); break; case "cpp": writer = new CppStructWriter(_stringIds, outDir); break; default: return false; } Directory.CreateDirectory(outDir); var count = 0; using (var stream = _fileInfo.OpenRead()) { foreach (var tagClass in _cache.TagClasses) { TagLayoutGuess layout = null; HaloTag lastTag = null; foreach (var tag in _cache.Tags.FindAllByClass(tagClass)) { Console.Write("Analyzing "); TagPrinter.PrintTagShort(tag); lastTag = tag; var analyzer = new TagAnalyzer(_cache, tag); var data = _cache.ExtractTag(stream, tag); var tagLayout = analyzer.Analyze(data); if (layout != null) layout.Merge(tagLayout); else layout = tagLayout; } if (layout != null && lastTag != null) { Console.WriteLine("Writing {0} layout", tagClass); LayoutGuessWriter.Write(lastTag, layout, writer); count++; } } } Console.WriteLine("Successfully generated {0} layouts!", count); return true; }