public static void CreateRecipeUtil() { var table = TableProcessor.LoadTable(PathHelper.BCSVRecipeItem, (char)9, 20); // ascending key string templatePath = PathHelper.GetFullTemplatePathTo(itemRecipeRootName); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); int tabCount = countCharsBefore(preClass, "{data}"); List <string> varIndexes = new List <string>(); foreach (DataRow row in table.Rows) { string extract = row[20].ToString(); // index string extractItemId = row[12].ToString(); int recipeIndex = int.Parse(extract); extract = "0x" + recipeIndex.ToString("X3"); string inserter = "{" + extract + ", " + extractItemId.PadLeft(5, '0') + @"}, // " + ItemCreationEngine.ItemLines[int.Parse(extractItemId) + 1]; for (int i = 0; i < tabCount; ++i) { inserter = inserter + ' '; } varIndexes.Add(inserter); } string varAtEnd = varIndexes[varIndexes.Count - 1].Split("\r\n")[0]; // remove trails from last item varIndexes[varIndexes.Count - 1] = varAtEnd; preClass = replaceData(preClass, string.Join("", varIndexes)); writeOutFile(outputPath, preClass); }
public static void CreateRemakeInfoData(bool writeToFile = true) { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamRemakeItem, (char)9, 20); string templatePath = PathHelper.GetFullTemplatePathTo(itemRemakeRootName); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); int tabCount = countCharsBefore(preClass, "{data}"); List <string> remakeRow = new List <string>(); ItemRemakePointer = new Dictionary <string, string>(); foreach (DataRow row in table.Rows) { string extract = buildDicEntryFromDataRow(row, 18, 20, 38, 22, 39, 41); ItemRemakePointer.Add(row[20].ToString(), row[18].ToString()); extract = extract.Replace("\0", string.Empty);// + "\r\n"; we don't need rn because the item list has it at the end of each entry and we use it to comment for (int i = 0; i < tabCount; ++i) { extract = extract + ' '; } remakeRow.Add(extract); } string remakeAtEnd = remakeRow[remakeRow.Count - 1].Split("\r\n")[0]; // remove trails from last item remakeRow[remakeRow.Count - 1] = remakeAtEnd; preClass = replaceData(preClass, string.Join("", remakeRow)); if (writeToFile) { writeOutFile(outputPath, preClass); } }
// Example functions static void ShowNMTType() // show the type of an nmt in the item parameter table { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, 69); //69 DataRow nmt = table.Rows.Find("5851"); Console.WriteLine(nmt[80] + " " + nmt[80].ToString().Length); }
static void ShowNMTFile() // shows filename of model data { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, 69); DataRow nmt = table.Rows.Find("5851"); string val = nmt[91].ToString(); // or 89 Console.WriteLine(val); }
public static void CreateReaction() { var table = TableProcessor.LoadTable(PathHelper.BCSVHumanAnimItem, (char)9, 3); MSBT loadedMSBT = TableProcessor.LoadMSBT(PathHelper.GetReactionNameItem(PathHelper.Languages["en"])); string templatePath = PathHelper.GetFullTemplatePathTo(itemReactionRootName); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); // player animations only Dictionary <int, string> tableEntries = new Dictionary <int, string>(); foreach (DataRow row in table.Rows) { if (row["0x2C447591"].ToString().StartsWith("MaRe")) { tableEntries.Add(int.Parse(row["0x54706054"].ToString()), row["0x2C447591"].ToString()); } } var dicSort = tableEntries.OrderBy(a => a.Key).ToList(); tableEntries = new Dictionary <int, string>(); foreach (var kvp in dicSort) { tableEntries.Add(kvp.Key, kvp.Value); } List <string> entries = new List <string>(); // fill with empties for (int i = 0; i < tableEntries.Count + 1; ++i) { entries.Add(string.Format("\t\tUNUSED_{0},\r\n", i)); } // now instert with correct indexes for (int i = 0; i < loadedMSBT.LBL1.Labels.Count; ++i) { var currLabel = loadedMSBT.LBL1.Labels[i]; string comment = currLabel.ToString(); var find = tableEntries.First(x => x.Value.Replace("MaRe", "").TrimEnd('\0') == comment); int index = tableEntries.ToList().IndexOf(find); string enumVal = loadedMSBT.FileEncoding.GetString(currLabel.Value); enumVal = new string(enumVal.Where(c => char.IsLetterOrDigit(c)).ToArray()); entries[index] = string.Format("\t\t{0}, // {1} \r\n", enumVal, comment); } entries[0] = "\t\tNone,\r\n"; preClass = replaceData(preClass, string.Join("", entries.ToArray())); writeOutFile(outputPath, preClass); }
// functions that were used to bruteforce, are no longer required public static void DoItemSearchOld() { Dictionary <string, string> ItemHexPath = new Dictionary <string, string>(); // load the itemparam table var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); // "0x54706054" is item number, 91 is possible and 89 is always var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemMenuIconItem, (char)9, 2); List <string> allPossibleItemName = new List <string>(Directory.GetDirectories(PathHelper.ModelPath, "Layout*", SearchOption.TopDirectoryOnly)); // Layouts are icons allPossibleItemName.RemoveAll(x => x.Contains("ClosetIcon")); // Bigger textures that aren't needed for now foreach (DataRow row in table.Rows) { string itemNamePossible = row[91].ToString().Replace("\0", string.Empty); string itemNameExists = row[89].ToString().Replace("\0", string.Empty); List <string> hits = new List <string>(); if (row["0x54706054"].ToString() == "2750") { string f = "?"; // hacky breakpoint checking } // try to find this as filename if (itemNamePossible != string.Empty) { hits.AddRange(allPossibleItemName.FindAll(x => x.Contains(itemNamePossible))); } if (itemNameExists != string.Empty) { hits.AddRange(allPossibleItemName.FindAll(x => x.Contains(itemNameExists))); } //remove doubles //TODO if (hits.Count == 0) { StringBuilder notFoundItem = new StringBuilder(row["0x54706054"].ToString()); notFoundItem.Append(string.Format(" ({0}) ", ItemCreationEngine.ItemLines[int.Parse(row["0x54706054"].ToString()) + 1].Split("\r\n")[0])); notFoundItem.Append("Not found"); Console.WriteLine(notFoundItem.ToString()); } else { ItemHexPath.Add(row["0x54706054"].ToString(), hits[0]); } } Console.WriteLine("Found {0} paths for sprites.", ItemHexPath.Count); }
public static void GenerateUnitIconPointer() { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemUnitIconItem, (char)9, 2); var unitIconMap = getUnitIconMap(); var pointerMap = getMap(PathHelper.AdditionalFlowerMapName); Dictionary <string, string> itemIdPathMap = new Dictionary <string, string>(); foreach (DataRow row in table.Rows) { string itemId = row["0x54706054"].ToString(); ushort idDec = ushort.Parse(itemId); if (!pointerMap.ContainsKey(idDec.ToString("X"))) { // get the menu icon hash string iconHash = row[47].ToString().Replace("\0", string.Empty); int rowNum = unitIconMap[iconHash]; var unitIconRowNeeded = menuIconTable.Rows[rowNum]; string unitIconFilename = unitIconRowNeeded[4].ToString().Replace("\0", string.Empty); itemIdPathMap.Add(idDec.ToString("X"), unitIconFilename); } else { itemIdPathMap.Add(idDec.ToString("X"), pointerMap[idDec.ToString("X")]); } } // create pointer file using (StreamWriter file = new StreamWriter(PathHelper.OutputPathBeriUnitPointerFile, false)) foreach (var wf in itemIdPathMap) { Console.WriteLine("writing {0} as {1}.", wf.Key, wf.Value); file.WriteLine("{0},{1}", wf.Key, wf.Value); } Console.WriteLine("Generated pointer file at: {0}", PathHelper.OutputPathBeriUnitPointerFile); }
public static void CreateRemakeUtil(bool writeToFile = true) { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); // "0xFC275E86" is kind "0x54706054" is number string templatePath = PathHelper.GetFullTemplatePathTo(itemRemakeUtilRootName); string outputPath = PathHelper.GetFullOutputPathTo(templatePath); string preClass = File.ReadAllText(templatePath); int tabCount = countCharsBefore(preClass, "{data}"); List <string> varIndexes = new List <string>(); ItemRemakeHash = new Dictionary <string, string>(); foreach (DataRow row in table.Rows) { string extract = row["0xCB5EB33F"].ToString(); // index of variation if (extract == "-1") { continue; } string extractItemId = row["0x54706054"].ToString(); ItemRemakeHash.Add(extractItemId, extract); string inserter = "{" + extractItemId.PadLeft(5, '0') + ", " + extract.PadLeft(4, '0') + @"}, // " + ItemCreationEngine.ItemLines[int.Parse(extractItemId) + 1]; for (int i = 0; i < tabCount; ++i) { inserter = inserter + ' '; } varIndexes.Add(inserter); } string varAtEnd = varIndexes[varIndexes.Count - 1].Split("\r\n")[0]; // remove trails from last item varIndexes[varIndexes.Count - 1] = varAtEnd; preClass = replaceData(preClass, string.Join("", varIndexes)); if (writeToFile) { writeOutFile(outputPath, preClass); } }
public static void ExportParam(string csvPath, string outPath, string keyrow1, string keyrow2, string rowKey) { DataTable dt = TableProcessor.LoadTable(csvPath, '\t', rowKey); Dictionary <string, string> paramAsText = new Dictionary <string, string>(); int currLargestLength = 0; foreach (DataRow row in dt.Rows) { var r1 = "'" + row[keyrow1].ToString().Replace("\0", string.Empty) + "'"; var r2 = "'" + row[keyrow2].ToString().Replace("\0", string.Empty) + "'"; if (r1.Length > currLargestLength) { currLargestLength = r1.Length; } paramAsText.Add(r1, r2); } using (StreamWriter file = new StreamWriter(outPath, false)) foreach (var wf in paramAsText) { file.WriteLine($"\t({wf.Key.PadRight(currLargestLength, ' ')}, {wf.Value}),"); } }
public static void CreateUshortDataMenuIcon() { var list = CreateMenuIcon(); var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemMenuIconItem, (char)9, 2); var menuIconMap = SpriteCreationEngine.getMainIconMap(); string[] itemLines = ItemCreationEngine.ItemLines; ushort[] toWrite = new ushort[itemLines.Length]; for (int i = 0; i < itemLines.Length; ++i) { DataRow nRow = table.Rows.Find(i.ToString()); if (nRow != null) { string iconHash = nRow[28].ToString().Replace("\0", string.Empty); int rowNum = menuIconMap[iconHash]; var menuIconRowNeeded = menuIconTable.Rows[rowNum]; string menuIconFilename = menuIconRowNeeded[3].ToString().Replace("\0", string.Empty); var toAdd = (ushort)list.IndexOf(menuIconFilename.TrimEnd()); toWrite[i] = toAdd; if (i == 6691) { break; } } else { toWrite[i] = 0; } } byte[] bytes = new byte[toWrite.Length * 2]; Buffer.BlockCopy(toWrite, 0, bytes, 0, toWrite.Length * 2); File.WriteAllBytes(PathHelper.OutputPathBytes + Path.DirectorySeparatorChar + itemMenuIconFilename, bytes); Console.WriteLine("Wrote {0} to {1}.", itemMenuIconFilename, PathHelper.OutputPathBytes + Path.DirectorySeparatorChar + itemMenuIconFilename); }
public static void DoItemSearchUnitIcon() { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemUnitIconItem, (char)9, 2); var unitIconMap = getUnitIconMap(); List <string> allPossibleItemName = new List <string>(Directory.GetDirectories(PathHelper.ModelPath, "UnitIcon*", SearchOption.TopDirectoryOnly)); // UnitIcons are models // variations don't matter with unit icons Dictionary <ItemTextureVariation, string> itemIdPathMap = new Dictionary <ItemTextureVariation, string>(); foreach (DataRow row in table.Rows) { string itemId = row["0x54706054"].ToString(); // get the menu icon hash string iconHash = row[47].ToString().Replace("\0", string.Empty); int rowNum = unitIconMap[iconHash]; var unitIconRowNeeded = menuIconTable.Rows[rowNum]; string unitIconFilename = unitIconRowNeeded[5].ToString().Replace("\0", string.Empty) + "."; string fullPath = allPossibleItemName.Find(x => x.Contains(unitIconFilename)); string variationNumber = unitIconRowNeeded[3].ToString(); ItemTextureVariation toAdd = new ItemTextureVariation(ushort.Parse(itemId), byte.Parse(variationNumber)); itemIdPathMap.Add(toAdd, fullPath); } // new pointer map Dictionary <string, List <ItemTextureVariation> > pointerMap = new Dictionary <string, List <ItemTextureVariation> >(); foreach (var iPath in itemIdPathMap) { // create item name to file relation if (pointerMap.ContainsKey(iPath.Value)) { // add us to the list of people that want this image var thisList = pointerMap[iPath.Value]; thisList.Add(iPath.Key); } else { // create a relation var newListWithUs = new List <ItemTextureVariation>(); newListWithUs.Add(iPath.Key); pointerMap.Add(iPath.Value, newListWithUs); } } // create the files, naming them the first thing in the list if (Directory.Exists(PathHelper.OutputPathUnitModelsMain)) { Directory.Delete(PathHelper.OutputPathUnitModelsMain, true); // we are copying files here so this needs to go } Directory.CreateDirectory(PathHelper.OutputPathUnitModelsMain); Dictionary <string, List <ItemTextureVariation> > writtenFileMap = new Dictionary <string, List <ItemTextureVariation> >(); foreach (var pm in pointerMap) { // get the file if (pm.Key == string.Empty) { continue; } string[] files = Directory.GetFiles(pm.Key, "*.bfres", SearchOption.AllDirectories); string fileWanted = new List <string>(files).Find(x => x.Contains("output.bfres", StringComparison.OrdinalIgnoreCase)); // copy file to output directory string newFileName = pm.Value[0].ToString(); string newFilePath = PathHelper.OutputPathUnitModelsMain + Path.DirectorySeparatorChar + newFileName + ".bfres"; File.Copy(fileWanted, newFilePath); Console.WriteLine("Copied {0} to {1}", fileWanted, newFilePath); // add to map writtenFileMap.Add(newFileName, pm.Value); } // create pointer file using (StreamWriter file = new StreamWriter(PathHelper.OutputPathUnitPointerFile, false)) foreach (var wf in writtenFileMap) { foreach (var s in wf.Value) { file.WriteLine("{0},{1}", s.ToString().Split('_')[0], wf.Key); } } Console.WriteLine("Generated pointer file at: {0}", PathHelper.OutputPathUnitPointerFile); }
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); }
public static void GenerateMenuIconList() { var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemMenuIconItem, (char)9, 2); var menuIconMap = getMainIconMap(); List <string> allPossibleItemName = new List <string>(Directory.GetDirectories(PathHelper.ModelPath, MenuSpriteFileRoot + "*", SearchOption.TopDirectoryOnly)); // Layouts are icons // variations don't matter with menu icons Dictionary <int, string> itemIdPathMap = new Dictionary <int, string>(); Dictionary <string, string> menuIconEnumPathMap = new Dictionary <string, string>(); foreach (DataRow row in table.Rows) { string itemId = row["0x54706054"].ToString(); // get the menu icon hash string iconHash = row[28].ToString().Replace("\0", string.Empty); int rowNum = menuIconMap[iconHash]; var menuIconRowNeeded = menuIconTable.Rows[rowNum]; string menuIconFilename = MenuSpriteFileRoot + menuIconRowNeeded[3].ToString().Replace("\0", string.Empty) + "."; string fullPath = allPossibleItemName.Find(x => x.Contains(menuIconFilename)); itemIdPathMap.Add(int.Parse(itemId), fullPath); if (!menuIconEnumPathMap.ContainsKey(menuIconRowNeeded[1].ToString().Replace("\0", string.Empty))) { menuIconEnumPathMap.Add(menuIconRowNeeded[1].ToString().Replace("\0", string.Empty), fullPath); } } // new pointer map Dictionary <string, List <int> > pointerMap = new Dictionary <string, List <int> >(); foreach (var iPath in itemIdPathMap) { // create item name to file relation if (pointerMap.ContainsKey(iPath.Value)) { // add us to the list of people that want this image var thisList = pointerMap[iPath.Value]; thisList.Add(iPath.Key); } else { // create a relation var newListWithUs = new List <int>(); newListWithUs.Add(iPath.Key); pointerMap.Add(iPath.Value, newListWithUs); } } // create the files, naming them the first thing in the list if (Directory.Exists(PathHelper.OutputPathMenuSpritesMain)) { Directory.Delete(PathHelper.OutputPathMenuSpritesMain, true); // we are copying files here so this needs to go } Directory.CreateDirectory(PathHelper.OutputPathMenuSpritesMain); Dictionary <string, List <int> > writtenFileMap = new Dictionary <string, List <int> >(); foreach (var pm in pointerMap) { // get the file if (pm.Key == string.Empty) { continue; } string[] files = Directory.GetFiles(pm.Key, "*.bfres", SearchOption.AllDirectories); string fileWanted = new List <string>(files).Find(x => x.Contains("output.bfres", StringComparison.OrdinalIgnoreCase)); // copy file to output directory string newFileName = pm.Value[0].ToString("X"); string newFilePath = PathHelper.OutputPathMenuSpritesMain + Path.DirectorySeparatorChar + newFileName + ".bfres"; File.Copy(fileWanted, newFilePath); Console.WriteLine("Copied {0} to {1}", fileWanted, newFilePath); // add to map writtenFileMap.Add(newFileName, pm.Value); } // for NHSE if (!Directory.Exists(PathHelper.OutputPathMenuSpritesMain + Path.DirectorySeparatorChar + "OriginalNames")) { Directory.CreateDirectory(PathHelper.OutputPathMenuSpritesMain + Path.DirectorySeparatorChar + "OriginalNames"); } foreach (var iPath in itemIdPathMap) { if (iPath.Value == string.Empty) { continue; } string[] files = Directory.GetFiles(iPath.Value, "*.bfres", SearchOption.AllDirectories); string fileWanted = new List <string>(files).Find(x => x.Contains("output.bfres", StringComparison.OrdinalIgnoreCase)); string nameToUse = menuIconEnumPathMap.FirstOrDefault(x => x.Value == iPath.Value).Key; if (nameToUse == null) { continue; } string outputPath = PathHelper.OutputPathMenuSpritesMain + Path.DirectorySeparatorChar + "OriginalNames" + Path.DirectorySeparatorChar + nameToUse + ".bfres"; if (File.Exists(outputPath)) { continue; } File.Copy(fileWanted, outputPath); Console.WriteLine("Copied {0} to {1}", fileWanted, outputPath); } // create pointer file using (StreamWriter file = new StreamWriter(PathHelper.OutputPathMenuPointerFile, false)) foreach (var wf in writtenFileMap) { foreach (var s in wf.Value) { file.WriteLine("{0},{1}", s.ToString("X"), wf.Key); } } Console.WriteLine("Generated pointer file at: {0}", PathHelper.OutputPathMenuPointerFile); }
public static void DoItemSearch(bool includeMenuItemMap = true) { Dictionary <string, string> ItemHexPath = new Dictionary <string, string>(); // load the itemparam table var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); // "0x54706054" is item number, "0x3FEBC642" is ftricon var menuIconTable = TableProcessor.LoadTable(PathHelper.BCSVItemMenuIconItem, (char)9, 2); var menuIconMap = getMainIconMap(); List <string> allPossibleItemName = new List <string>(Directory.GetDirectories(PathHelper.ModelPath, LayoutRoot + "*", SearchOption.TopDirectoryOnly)); // Layouts are icons var itemHexes = getAllItemHexes(table); foreach (string itemName in itemHexes) { if (itemName == "\0" || itemName == string.Empty) { continue; } string[] split = itemName.Split("_"); string filename = getSpriteFilename(table, "0x3FEBC642", split[0], itemName, allPossibleItemName, menuIconMap, menuIconTable, split.Length > 1); Console.WriteLine("{0} located at {1}", itemName, filename); ItemHexPath.Add(itemName, filename); } // generate pointer map Dictionary <string, List <string> > pointerMap = new Dictionary <string, List <string> >(); foreach (var ihx in ItemHexPath) { // create item name to file relation if (pointerMap.ContainsKey(ihx.Value)) { // add us to the list of people that want this image var thisList = pointerMap[ihx.Value]; thisList.Add(stringDecToHex(ihx.Key)); } else { // create a relation List <string> newListWithUs = new List <string>(); newListWithUs.Add(stringDecToHex(ihx.Key)); pointerMap.Add(ihx.Value, newListWithUs); } } // create the files, naming them the first thing in the list if (Directory.Exists(PathHelper.OutputPathSpritesMain)) { Directory.Delete(PathHelper.OutputPathSpritesMain, true); // we are copying files here so this needs to go } Directory.CreateDirectory(PathHelper.OutputPathSpritesMain); Dictionary <string, List <string> > writtenFileMap = new Dictionary <string, List <string> >(); foreach (var pm in pointerMap) { // get the file if (pm.Key == string.Empty) { continue; } string[] files = Directory.GetFiles(pm.Key, "*.bfres", SearchOption.AllDirectories); string fileWanted = new List <string>(files).Find(x => x.Contains("output.bfres", StringComparison.OrdinalIgnoreCase)); // copy file to output directory string newFileName = pm.Value[0]; string newFilePath = PathHelper.OutputPathSpritesMain + Path.DirectorySeparatorChar + newFileName + ".bfres"; File.Copy(fileWanted, newFilePath); Console.WriteLine("Copied {0} to {1}", fileWanted, newFilePath); // add to map writtenFileMap.Add(newFileName, pm.Value); } // create pointer file using (StreamWriter file = new StreamWriter(PathHelper.OutputPathPointerFile, false)) foreach (var wf in writtenFileMap) { foreach (var s in wf.Value) { file.WriteLine("{0},{1}", s, wf.Key); } } Console.WriteLine("Generated pointer file at: {0}", PathHelper.OutputPathPointerFile); if (includeMenuItemMap) { GenerateMenuIconList(); } }
public static string[] CreateItemList(string language, bool writeToFile = true) { string rootPath = PathHelper.GetItemDirectory(PathHelper.Languages[language]); List <MSBT> loadedItemsEng = new List <MSBT>(TableProcessor.LoadAllMSBTs(rootPath)); Dictionary <int, string> ID_ItemTable = new Dictionary <int, string>(getOutfits(language)); //preload with outfits // Add stuff not available ID_ItemTable.Add(0, string.Format("({0})", PathHelper.NoneNames[language])); // nothing ID_ItemTable.Add(5795, "DIY recipe\r\n"); // diy recipe int padAmount = PathHelper.LangPadAmount[language]; foreach (MSBT loaded in loadedItemsEng) { for (int i = 0; i < loaded.LBL1.Labels.Count; ++i) { string keyLabel = loaded.LBL1.Labels[i].ToString(); if (keyLabel.keyLabelShouldBeDiscarded()) { continue; } string[] keyVars = keyLabel.Split('_', StringSplitOptions.RemoveEmptyEntries); // item name string itemName = loaded.FileEncoding.GetString(loaded.LBL1.Labels[i].Value); itemName = itemName.processString(keyVars[0], language, padAmount); itemName += "\r\n"; // item index string itemIndex = keyVars[1]; int itemNumber = int.Parse(itemIndex); itemNumber += 1; // to match file line number ID_ItemTable.Add(itemNumber, itemName); } } // how big should we make our text file? int largestNumber = 0; foreach (var kvpItem in ID_ItemTable) { if (kvpItem.Key > largestNumber) { largestNumber = kvpItem.Key; } } // write to file using empties where there are no items // but first get everything we didn't find from the ItemParam table var table = TableProcessor.LoadTable(PathHelper.BCSVItemParamItem, (char)9, "0x54706054"); Dictionary <int, string> itemNameJapNameDic = new Dictionary <int, string>(); Dictionary <int, string> translationTypes = new Dictionary <int, string>(); foreach (DataRow row in table.Rows) { string itemId = row["0x54706054"].ToString(); int itemAsId = int.Parse(itemId) + 1; // get jap name string japName = row["0xB8CC232C"].ToString().Replace("\0", string.Empty); itemNameJapNameDic.Add(itemAsId, japName); //get type string type = row["0xFC275E86"].ToString().Replace("\0", string.Empty); translationTypes.Add(itemAsId, type); } int paramLargestNumber = itemNameJapNameDic.ElementAt(itemNameJapNameDic.Count - 1).Key; largestNumber = Math.Max(largestNumber, paramLargestNumber); // load the translation master string[] translationMaster = File.ReadAllLines(PathHelper.MasterTranslator); string[] lines = new string[largestNumber + 1]; List <string> translationsTemp = new List <string>(); List <string> translationsTempWithType = new List <string>(); List <string> translationsHexes = new List <string>(); // this can and should be cleaned up int translationRequests = 0; for (int i = 0; i < largestNumber + 1; ++i) { if (ID_ItemTable.ContainsKey(i)) { if (i < translationMaster.Length) { // the below if statement is incorrect (indexes are wrong) but I haven't had time to clean it up if (i != 0 && ID_ItemTable[i].JapanesePercentage() > 0.3f && translationMaster[i - 1] != string.Empty && (language != "jp" && language != "zht" && language != "zhs" && language != "ko")) { // this is probably japanese in the msbt string n = translationMaster[i - 1]; if (!n.EndsWith("(internal)", StringComparison.OrdinalIgnoreCase)) { n += " (internal)"; } lines[i] = n + "\r\n"; translationsTemp.Add(n + ", " + (i - 1).ToString("X").PadLeft(4, '0') + " \r\n"); translationsHexes.Add((i - 1).ToString("X") + "\r\n"); translationsTempWithType.Add(n.PadRight(60, ' ') + (char)2 + itemNameJapNameDic[i].PadRight(30, ' ') + (char)2 + translationTypes[i].PadRight(25, ' ') + (char)2 + (i - 1).ToString("X").PadLeft(4, '0') + (char)2 + (i - 1).ToString().PadLeft(5, '0') + " \r\n"); // char 2 is easier to split } else { lines[i] = ID_ItemTable[i]; } } else { lines[i] = ID_ItemTable[i]; } } else if (itemNameJapNameDic.ContainsKey(i)) { if (i < translationMaster.Length) { if (translationMaster[i - 1] != string.Empty && (language != "jp" && language != "zht" && language != "zhs" && language != "ko")) { string n = translationMaster[i - 1]; if (!n.EndsWith("(internal)", StringComparison.OrdinalIgnoreCase)) { n += " (internal)"; } lines[i] = n + "\r\n"; translationsTemp.Add(n + ", " + (i - 1).ToString("X").PadLeft(4, '0') + " \r\n"); translationsHexes.Add((i - 1).ToString("X") + "\r\n"); translationsTempWithType.Add(n.PadRight(60, ' ') + (char)2 + itemNameJapNameDic[i].PadRight(30, ' ') + (char)2 + translationTypes[i].PadRight(25, ' ') + (char)2 + (i - 1).ToString("X").PadLeft(4, '0') + (char)2 + (i - 1).ToString().PadLeft(5, '0') + " \r\n"); // char 2 is easier to split } else { lines[i] = itemNameJapNameDic[i] + "\r\n"; } } else { lines[i] = itemNameJapNameDic[i] + "\r\n"; } translationRequests++; } else { lines[i] = "\r\n"; } } Console.WriteLine("{0} translation requests: {1}", language, translationRequests); // sort by name then type translationsTempWithType = translationsTempWithType.OrderBy(x => x.Split((char)2)[0]).ToList(); translationsTempWithType = translationsTempWithType.OrderBy(x => x.Split((char)2)[2]).ToList(); for (int i = 0; i < translationsTempWithType.Count; ++i) { translationsTempWithType[i] = "| " + translationsTempWithType[i].Replace(((char)2).ToString(), " | ").Replace("\r\n", " |\r\n"); // github markdown } if (writeToFile) { WriteOutFile(PathHelper.OutputPath, language, itemListRootName + language + ".txt", string.Join("", lines)); } if (language == "en") { WriteOutFile(PathHelper.OutputPath, "strings", "InternalItemList.txt", string.Join("", translationsTemp)); WriteOutFile(PathHelper.OutputPath, "strings", "InternalHexList.txt", string.Join("", translationsHexes)); WriteOutFile(PathHelper.OutputPath, "strings", "InternalItemListSorted.txt", string.Join("", translationsTempWithType)); } if (language == "en") { itemLines = lines; } return(lines); }