public void Rebuild(string str) { string origPath = Utility.GetFullPath(str); string rebuildPath = "rebuild_" + Path.GetFileName(str); GMD gmd = new GMD(origPath); gmd.Save(rebuildPath); if (!Utility.CheckFilesAreSame(origPath, rebuildPath)) { Assert.Fail("Hash doesn't match!"); } }
public void Rebuild__q00503_eng() { string origPath = Utility.GetFullPath(@"chunk0/common/text/quest/q00503_eng.gmd"); string rebuildPath = "rebuild__q00503_eng.gmd"; GMD gmd = new GMD(origPath); gmd.Save(rebuildPath); if (!Utility.CheckFilesAreSame(origPath, rebuildPath)) { Assert.Fail("Hash doesn't match!"); } }
public void Rebuild__action_trial_eng() { // Uses skipInvalidMessages, rebuild file will not be the same since it removes the "Invalid Message" strings string origPath = Utility.GetFullPath(@"chunk0/common/text/action_trial_eng.gmd"); string rebuildPath = "rebuild__action_trial_eng.gmd"; GMD gmd = new GMD(origPath); gmd.Save(rebuildPath); if (!Utility.CheckFilesAreSame(origPath, rebuildPath)) { Assert.Fail("Hash doesn't match!"); } }
public void ReaddString__w_sword_eng() { // This won't display correctly in game, because the string order DOES matter string origPath = Utility.GetFullPath(@"common/text/steam/w_sword_eng.gmd"); string newPath = "removestring__w_sword_eng.gmd"; string readdPath = "readdstring__w_sword_eng.gmd"; GMD gmd = new GMD(origPath); gmd.RemoveString("WP_WSWD_044_NAME"); gmd.Save(newPath); GMD newGmd = new GMD(newPath); newGmd.AddString("WP_WSWD_044_NAME", "My new string"); newGmd.Save(readdPath); }
public void AddString__q00503_eng() { string newPath = "addstring__q00503_eng.gmd"; GMD gmd = new GMD(Utility.GetFullPath(@"common/text/quest/q00503_eng.gmd")); gmd.AddString("MY_NEW_STRING", "New string text...."); gmd.Save(newPath); GMD oldGmd = new GMD(Utility.GetFullPath(@"common/text/quest/q00503_eng.gmd")); GMD newGmd = new GMD(newPath); Assert.IsTrue(oldGmd.Header.KeyCount < newGmd.Header.KeyCount); Assert.IsTrue(oldGmd.Header.KeyBlockSize < newGmd.Header.KeyBlockSize); Assert.IsTrue(oldGmd.Header.StringCount < newGmd.Header.StringCount); Assert.IsTrue(oldGmd.Header.StringBlockSize < newGmd.Header.StringBlockSize); Assert.IsNotNull(newGmd.Entries.FirstOrDefault(x => x.Value == "New string text....")); }
public override void Save(string path) { // Replace all GMD entries with the new/edited ones _context.Entries.Clear(); foreach (GMDEntryViewModel vm in Entries) { _context.Entries.Add(vm.Entry); } try { _context.Save(path); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
public void AddStringAt__armor_eng() { string newPath = "addstringat__armor_eng.gmd"; GMD gmd = new GMD(Utility.GetFullPath(@"common/text/steam/armor_eng.gmd")); // Find index var entryToFind = gmd.Entries.OfType <GMD_Entry>().FirstOrDefault(x => x.Key == "AM_ACCE001_NAME"); int idx = gmd.Entries.IndexOf(entryToFind); gmd.AddString("AM_ACCE001_EXP", "Description for AM_ACCE001_NAME", idx + 1); gmd.Save(newPath); GMD oldGmd = new GMD(Utility.GetFullPath(@"common/text/quest/q00503_eng.gmd")); GMD newGmd = new GMD(newPath); Assert.IsTrue(oldGmd.Header.KeyCount < newGmd.Header.KeyCount); Assert.IsTrue(oldGmd.Header.KeyBlockSize < newGmd.Header.KeyBlockSize); Assert.IsTrue(oldGmd.Header.StringCount < newGmd.Header.StringCount); Assert.IsTrue(oldGmd.Header.StringBlockSize < newGmd.Header.StringBlockSize); Assert.IsNotNull(newGmd.Entries.FirstOrDefault(x => x.Value == "Description for AM_ACCE001_NAME")); }
private static void InsertMaDecorationLevel(String input, String output, String style, Boolean showVerbose) { if (output == null) { output = input + ".mdl"; if (showVerbose) { Console.WriteLine("No explicated output. Use the default output."); } } GMD gmd = new GMD(input); if (style == null) { var language = gmd.Header.Language; if (language == 8 /* chS */ || language == 7 /* chT */ || language == 0 /* jpn */ || language == 6 /* kor */) { style = "%s<STYL MOJI_YELLOW_DEFAULT>(%d)</STYL>"; } else { style = "%s <STYL MOJI_YELLOW_DEFAULT>(%d)</STYL>"; } if (showVerbose) { Console.WriteLine("No explicated style. Use the default style."); } } if (showVerbose) { Console.WriteLine($"input = {input}"); Console.WriteLine($"output = {output}"); Console.WriteLine($"style = {style}"); } // Records which decoration has been modified var record = Data.MAX_DECORATION_LEVEL_MAP.Keys.ToDictionary(key => key, key => false); var recordCount = 0; var list = gmd.Entries.OfType <GMD_Entry>().ToList().FindAll(x => x.Key.StartsWith("JU_") && x.Key.EndsWith("_NAME")); foreach (var item in list) { if (!item.Value.Equals("Invalid Message")) { if (Data.MAX_DECORATION_LEVEL_MAP.ContainsKey(item.Key)) { var oldValue = item.Value; item.Value = style.Replace("%s", item.Value).Replace("%d", Data.MAX_DECORATION_LEVEL_MAP[item.Key].ToString()); var newValue = item.Value; if (showVerbose) { Console.WriteLine("Insert max decoration level:"); Console.WriteLine($"> Key = {item.Key}"); Console.WriteLine($"> Old Value = {oldValue}"); Console.WriteLine($"> New Value = {newValue}"); } if (record[item.Key] == false) { record[item.Key] = true; recordCount++; } } else if (!Data.INVALID_DECORATION_LIST.Contains(item.Key)) { Console.WriteLine("Unknown decoration:"); Console.WriteLine($"> Key = {item.Key}"); Console.WriteLine($"> Value = {item.Value}"); } } } // Show warning if not all decorations are modified if (recordCount != record.Count) { Console.WriteLine("Some decorations are missing:"); foreach (var item in record) { if (item.Value == false) { Console.WriteLine($"> {item.Key}"); } } } gmd.Save(output); }
private static int Replace(ReplaceOptions opts) { string[] files = Directory.GetFiles(opts.Input, "*.gmd", SearchOption.AllDirectories); int itemCount = files.Length; int processedCount = 0; int changedFilesCount = 0; int changedValuesCount = 0; var sw = Stopwatch.StartNew(); Console.WriteLine("Total files: " + itemCount); Console.WriteLine("Preview mode: " + opts.Preview); foreach (var file in files) { try { var changes = new List <UpdatedEntry>(); var gmd = new GMD(file); foreach (var entry in gmd.Entries) { string val = Regex.Replace(entry.Value, opts.Search, opts.ReplaceWith); if (entry.Value != val) { string key = "(NO_KEY)"; if (entry as GMD_Entry is var x && x != null) { key = x.Key; } changes.Add(new UpdatedEntry(key, entry.Value, val)); entry.Value = val; } } if (changes.Count > 0) { string relPath = Path.GetRelativePath(opts.Input, file); string dest = Path.Join(opts.Output, relPath); Colorful.Console.Write(file, Color.Red); Console.Write(" -> "); Colorful.Console.WriteLine(dest, Color.LightGreen); Colorful.Console.WriteLine("Changes: " + changes.Count, Color.Yellow); foreach (var change in changes) { Colorful.Console.WriteLine(change.Key, Color.Cyan); Colorful.Console.Write(change.OldValue, Color.Orange); Console.Write(" -> "); Colorful.Console.WriteLine(change.NewValue, Color.Green); Console.WriteLine(); } if (!opts.Preview) { string?dir = Path.GetDirectoryName(dest); if (dir != null) { Directory.CreateDirectory(dir); } gmd.Save(dest); } } } catch (Exception ex) { Console.WriteLine($"Error {ex} in '{file}'"); } Interlocked.Increment(ref processedCount); } sw.Stop(); Console.WriteLine(); Console.WriteLine("Finished!"); Console.WriteLine("Processed: " + processedCount); Console.WriteLine("Changed files: " + changedFilesCount); Console.WriteLine("Changed values: " + changedValuesCount); Console.WriteLine("Elapsed: " + sw.Elapsed); return(0); }