private void MenuImportEnglish_Click(object sender, EventArgs e) { if (MessageBox.Show("Import the English translation into all languages?", "Import English", MessageBoxButtons.YesNo) == DialogResult.No) { return; } Application.UseWaitCursor = true; try { Exporters.Exporter englishExporter = null; foreach (ListItem item in ContentList.Items) { STBLListItem stblItem = item as STBLListItem; if (stblItem == null) { continue; } if (STBL.GetPrefix(stblItem.Instance) == "00") { englishExporter = stblItem.GetExporter(); break; } } foreach (ListItem item in ContentList.Items) { STBLListItem stblItem = item as STBLListItem; if (stblItem == null) { continue; } if (!ImportFile(stblItem, englishExporter)) { return; } } foreach (ListItem item in ContentList.Items) { STBLListItem stblItem = item as STBLListItem; if (stblItem == null) { continue; } stblItem.Test(sMainForm.CurrentPackage); } ExportLog(); } finally { Application.UseWaitCursor = false; } }
private void ExportAllSTBL_Click(object sender, EventArgs e) { if (MessageBox.Show("Export all STBL ? Doing so will overwrite any existing files.", "Export", MessageBoxButtons.YesNo) == DialogResult.No) { return; } foreach (ListItem item in ContentList.Items) { STBLListItem stblItem = item as STBLListItem; if (stblItem == null) { continue; } switch (STBL.GetPrefix(stblItem.Instance)) { case "00": case "17": continue; } stblItem.Export(true, false); } // Do the English separately to ensure that it was not overwritten by another export foreach (ListItem item in ContentList.Items) { STBLListItem stblItem = item as STBLListItem; if (stblItem == null) { continue; } if (STBL.GetPrefix(stblItem.Instance) != "00") { continue; } stblItem.Export(true, false); } MessageBox.Show("Exported"); }
private void MenuRenameSTBL_Click(object sender, EventArgs e) { string scriptName = null; foreach (ListItem item in ContentList.Items) { if (item is S3SAListItem) { scriptName = item.Text; break; } } TextInput dialog = new TextInput("HashName and Prefix", scriptName); if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } string[] results = dialog.Result.Split(' '); ulong result = FNV64.GetHash(results[0]); string orig = result.ToString("X16"); int origValue = int.Parse(orig.Substring(0, 2), System.Globalization.NumberStyles.HexNumber, null); if (origValue < STBL.Count) { result++; orig = result.ToString("X16"); } string part = orig.Substring(2); string prefix = null; if (results.Length > 1) { prefix = results[1] + " "; } foreach (string aPrefix in STBL.Keys) { ulong instance = Convert.ToUInt64("0x" + aPrefix + part, 16); bool found = false; foreach (IResourceIndexEntry entry in CurrentPackage.FindAll(key => ((key.ResourceType == (uint)ResourceType.STBL)))) { string instanceStr = entry["Instance"]; if (instanceStr.Substring(2, 2) == aPrefix) { found = true; break; } } if (!found) { STBLListItem stblItem = new STBLListItem(); if (stblItem.AddNew(instance, CurrentPackage, true)) { ContentList.Items.Add(stblItem); } } } foreach (ListItem item in ContentList.Items) { if (!(item is STBLListItem)) { continue; } item.Instance = "0x" + STBL.GetPrefix(item.Instance) + part; item.Name = "Strings " + prefix + STBL.GetProperName(item.Instance); sChanged = true; } }