public static void CreateItemKind(bool writeToFile = true) { const char pad = ' '; var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); // "0xFC275E86" is kind "0x54706054" is number string templatePath = PathHelper.GetFullTemplatePathTo(itemKindRootName); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); int tabCount = countCharsBefore(preClass, "{data}"); List <string> kinds = new List <string>(); foreach (DataRow row in table.Rows) { string extract = row["0xFC275E86"].ToString(); extract = extract.Replace("\0", string.Empty) + ',' + "\r\n"; for (int i = 0; i < tabCount; ++i) { extract = extract + pad; } if (!kinds.Contains(extract)) { kinds.Add(extract); } } kinds.Sort(); string kindAtEnd = kinds[kinds.Count - 1].Split("\r\n")[0]; // remove trails from last item kinds[kinds.Count - 1] = kindAtEnd; preClass = replaceData(preClass, string.Join("", kinds)); if (writeToFile) { writeOutFile(outputPath, preClass); } // keep the itemkind list but remove stuff we don't want ItemKindList = new List <string>(); foreach (string s in kinds) { ItemKindList.Add(s.Split(',')[0]); } // create bytes data if (writeToFile) { string[] itemLines = ItemCreationEngine.ItemLines; byte[] itemKindBytes = new byte[itemLines.Length]; for (int i = 0; i < itemLines.Length; ++i) { DataRow nRow = table.Rows.Find(i.ToString()); if (nRow != null) { string checker = nRow["0xFC275E86"].ToString().Replace("\0", string.Empty) + "\r\n" + "".PadRight(tabCount, pad); itemKindBytes[i] = (byte)ItemKindList.IndexOf(checker.TrimEnd()); } else { itemKindBytes[i] = 0; } } writeOutBytes(PathHelper.OutputPathBytes + Path.DirectorySeparatorChar + itemKindBytesFilename, itemKindBytes); } }
private static List <string> createEnumFillerClass(int id, string bscvPath, string filename, int itemRow, string replaceWithNothing = "", int commentRow = -1, bool sort = false) { var table = TableProcessor.LoadTable(bscvPath, (char)9, id); string templatePath = PathHelper.GetFullTemplatePathTo(filename); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); int tabCount = countCharsBefore(preClass, "{data}"); List <string> kinds = new List <string>(); List <string> rawData = new List <string>(); foreach (DataRow row in table.Rows) { string extract = row[itemRow].ToString(); string extractComment = ""; if (commentRow != -1) { extractComment = @" // " + row[commentRow].ToString().Replace("\0", string.Empty); } string root = extract.Replace("\0", string.Empty); if (root == string.Empty || root == "\0") { continue; } if (replaceWithNothing != "") { root = root.Replace(replaceWithNothing, string.Empty); } if (!sort) { extract = root + " = " + kinds.Count.ToString() + "," + extractComment + "\r\n"; } else { extract = root + "," + extractComment + "\r\n"; } for (int i = 0; i < tabCount; ++i) { extract = extract + ' '; } if (!kinds.Contains(extract)) { kinds.Add(extract); rawData.Add(root); } } if (sort) { kinds.Sort(); rawData.Sort(); } string kindAtEnd = kinds[kinds.Count - 1].Split("\r\n")[0]; // remove trails from last item kinds[kinds.Count - 1] = kindAtEnd; preClass = replaceData(preClass, string.Join("", kinds)); writeOutFile(outputPath, preClass); return(rawData); }