public static void PrintBdatIndex(BdatStringCollection bdats, string htmlDir) { var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); string name = bdats.Game == Game.XB2 ? "2" : "X"; sb.AppendLine($"<title>Xenoblade {name} Data Tables</title>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); IOrderedEnumerable <IGrouping <string, BdatStringTable> > grouped = bdats.Tables.Values.GroupBy(x => x.Filename).OrderBy(x => x.Key ?? "zzz"); foreach (IGrouping <string, BdatStringTable> group in grouped) { sb.AppendLine($"<h2>{group.Key ?? "Other"}</h2>"); string subDir = group.Key ?? string.Empty; foreach (BdatStringTable table in group.OrderBy(x => x.Name)) { string path = Path.Combine(subDir, table.Name) + ".html"; sb.AppendLine($"<a href=\"{path}\">{table.Name}</a><br/>"); } } sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); string filename = Path.Combine(htmlDir, "index.html"); File.WriteAllText(filename, sb.ToString()); }
public static string Print(BdatCollection tables) { var sb = new Indenter(); BdatTable <FLD_SalvagePointList> pointList = tables.FLD_SalvagePointList; sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine("<title>Xenoblade 2 Salvaging Points</title>"); sb.AppendLine("<style>.tbox td{vertical-align: top;} table.BtnChallenge td,th{border: 1px solid;}table{margin:0;padding:0;border-collapse: collapse;}</style>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); foreach (FLD_SalvagePointList point in pointList.Where(x => x.SalvagePointName > 0)) { PrintPoint(point, sb); } sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); return(sb.ToString()); }
public static void PrintIndex(BdatStringCollection bdats, string htmlDir) { var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine("<title>Xenoblade 2 BDAT Index</title>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); var grouped = bdats.Tables.Values.GroupBy(x => x.Filename).OrderBy(x => x.Key ?? "zzz"); foreach (var group in grouped) { sb.AppendLine($"<h2>{group.Key ?? "Other"}</h2>"); var subDir = Path.Combine("bdat", group.Key ?? string.Empty); foreach (var table in group.OrderBy(x => x.Name)) { var path = Path.Combine(subDir, table.Name) + ".html"; sb.AppendLine($"<a href=\"{path}\">{table.Name}</a><br/>"); } } sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); var filename = Path.Combine(htmlDir, "index.html"); File.WriteAllText(filename, sb.ToString()); }
public static void GenerateSaveCode() { var types = ReadTypes(); var sb = new Indenter(); bool first = true; sb.AppendLine("// ReSharper disable InconsistentNaming RedundantCast MemberCanBePrivate.Global NotAccessedField.Global FieldCanBeMadeReadOnly.Global ForCanBeConvertedToForeach PartialTypeWithSinglePart"); sb.AppendLine(""); sb.AppendLine("using XbTool.Types"); sb.AppendLine(); sb.AppendLine("namespace XbTool.Save"); sb.AppendLineAndIncrease("{"); foreach (var type in types) { if (!first) { sb.AppendLine(); } GenerateClass(type, sb); first = false; } sb.DecreaseAndAppendLine("}"); File.WriteAllText("SaveTypes.cs", sb.ToString()); }
public static void PrintSeparateTables(BdatStringCollection bdats, string htmlDir, IProgressReport progress = null) { progress?.LogMessage("Writing BDAT tables as HTML"); progress?.SetTotal(bdats.Tables.Count); string bdatHtmlDir = Path.Combine(htmlDir, "bdat"); Directory.CreateDirectory(bdatHtmlDir); if (bdats.Game == Game.XB2) { PrintIndex(bdats, htmlDir); } PrintBdatIndex(bdats, bdatHtmlDir); foreach (string tableName in bdats.Tables.Keys) { string outDir = bdatHtmlDir; string tableFilename = bdats[tableName].Filename; string indexPath = tableFilename == null ? "index.html" : "../index.html"; var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine($"<title>{tableName}</title>"); sb.AppendLineAndIncrease("<style>"); sb.AppendLine(CssSticky); sb.AppendLine(CssSortable); sb.DecreaseAndAppendLine("</style>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); sb.AppendLine($"<a href=\"{indexPath}\">Return to BDAT index</a><br/>"); sb.AppendLine("<input type=\"button\" value=\"Open all references\" onclick=\"openAll(true)\" />"); sb.AppendLine("<input type=\"button\" value=\"Close all references\" onclick=\"openAll(false)\" />"); PrintTable(bdats[tableName], sb); sb.AppendLineAndIncrease("<script>"); sb.AppendLine(JsOpenAll); sb.AppendLine(JsSortable); sb.AppendLine(JsAnchor); sb.DecreaseAndAppendLine("</script>"); sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); if (tableFilename != null) { outDir = Path.Combine(outDir, tableFilename); } string filename = Path.Combine(outDir, tableName + ".html"); Directory.CreateDirectory(outDir); File.WriteAllText(filename, sb.ToString()); progress?.ReportAdd(1); } }
public static void PrintIndex(BdatStringCollection bdats, string htmlDir) { var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine("<title>Xenoblade 2</title>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); sb.AppendLine("<h1>Xenoblade 2 data tables</h1>"); sb.AppendLine($"<p>{IndexText}</p>"); sb.AppendLine("<a href=\"chbtlrewards.html\">Challenge Battle Rewards</a><br/>"); sb.AppendLine("<h2><a href=\"bdat\\index.html\">Complete table list</a></h2>"); string prefix = bdats.Game.ToString().ToLower(); if (!File.Exists($"{prefix}_tableDisplay.csv")) { return; } using (var stream = new FileStream($"{prefix}_tableDisplay.csv", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var reader = new StreamReader(stream)) { IEnumerable <BdatFriendlyInfo> csv = new CsvReader(reader).GetRecords <BdatFriendlyInfo>(); IOrderedEnumerable <IGrouping <string, BdatFriendlyInfo> > grouped = csv.GroupBy(x => x.Group).OrderBy(x => x.Key); foreach (IGrouping <string, BdatFriendlyInfo> group in grouped) { sb.AppendLine($"<h2>{group.Key ?? "Other"}</h2>"); foreach (BdatFriendlyInfo tableInfo in group.OrderBy(x => x.Display)) { BdatStringTable table = bdats[tableInfo.TableName]; string path = Path.Combine("bdat", table.Filename ?? "", table.Name) + ".html"; sb.AppendLine($"<a href=\"{path}\">{tableInfo.Display}</a><br/>"); } } } sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); string filename = Path.Combine(htmlDir, "index.html"); File.WriteAllText(filename, sb.ToString()); }
public static string Print(BdatCollection tables) { var sb = new Indenter(); var rewards = new List <RewardSet>(); foreach (var chBtl in tables.BTL_ChBtl) { var a = ReadRewardSet(tables, chBtl.Id); rewards.Add(a); } sb.AppendLine("<!DOCTYPE html>"); sb.AppendLine("<html>"); sb.AppendLine("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine("<title>Xenoblade 2 Challenge Battle Rewards</title>"); sb.AppendLine("</head>"); sb.AppendLine("<body>"); sb.AppendLine("<pre>"); foreach (var chBtl in rewards) { foreach (var set in chBtl.Rewards) { sb.AppendLine($"{chBtl.Name} Treasure Box {set.BoxNum}"); sb.AppendLine($"Need {set.Need} Ether Cubes"); sb.AppendLine($"{set.AppointItem} x{set.AppointCount}"); sb.AppendLine($"{set.MinGold}-{set.MaxGold} gold"); sb.AppendLine($"{set.MinItems}-{set.MaxItems} items:"); var table = new Table("Name", "Prob"); foreach (var item in set.Items) { table.AddRow(item.Name, item.Percent.ToString("P")); } sb.AppendLine(table.Print()); sb.AppendLine(); } } sb.AppendLine("</pre>"); sb.AppendLine("</body>"); sb.AppendLine("</html>"); return(sb.ToString()); }
public static void PrintSeparateTables(BdatStringCollection bdats, BdatInfo info, string htmlDir) { string bdatHtmlDir = Path.Combine(htmlDir, "bdat"); Directory.CreateDirectory(htmlDir); PrintIndex(bdats, htmlDir); foreach (string tableName in bdats.Tables.Keys) { string outDir = bdatHtmlDir; string tableFilename = bdats[tableName].Filename; var indexPath = tableFilename == null ? "../index.html" : "../../index.html"; var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine($"<title>{tableName}</title>"); sb.AppendLineAndIncrease("<script>"); sb.AppendLine(JsOpenAll); sb.DecreaseAndAppendLine("</script>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); sb.AppendLine($"<a href=\"{indexPath}\">Return to BDAT index</a><br/>"); sb.AppendLine("<input type=\"button\" value=\"Open all references\" onclick=\"openAll(true)\" />"); sb.AppendLine("<input type=\"button\" value=\"Close all references\" onclick=\"openAll(false)\" />"); PrintTable(bdats, info, tableName, sb); sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); if (tableFilename != null) { outDir = Path.Combine(outDir, tableFilename); } string filename = Path.Combine(outDir, tableName + ".html"); Directory.CreateDirectory(outDir); File.WriteAllText(filename, sb.ToString()); } }
private static string PrintDropTables(List <Enemy> enemies) { var sb = new Indenter(2); sb.AppendLine("<!DOCTYPE html>"); sb.AppendLineAndIncrease("<html>"); sb.AppendLineAndIncrease("<head>"); sb.AppendLine("<meta charset=\"utf-8\" />"); sb.AppendLine($"<title>Xenoblade 1 Enemy Drop Tables</title>"); sb.DecreaseAndAppendLine("</head>"); sb.AppendLineAndIncrease("<body>"); foreach (var enemy in enemies) { PrintEnemy(enemy, sb); } sb.DecreaseAndAppendLine("</body>"); sb.DecreaseAndAppendLine("</html>"); return(sb.ToString()); }