public static void saveLanguage(string code, string filename, string Author, string Version) { var q = JsonSerializer.Create(); var cMap = ((Dictionary <string, LanguageNode>)map.data)[code]; var w = new LanguageFile() { code = code, data = cMap, author = Author, version = Version }; var wJ = JsonConvert.SerializeObject(w, Formatting.Indented); File.WriteAllText(filename, wJ.ToString()); }
public static void loadQL(string data) { var rom_contents = File.ReadAllLines(data); var Author = "unknown"; var Code = "unknown"; var Version = "unknown"; var meta = false; var cline = 0; while (meta != true) { if (cline >= rom_contents.Length) { Console.WriteLine("Hit EOF no meta indicator"); return; } var line = rom_contents[cline]; if (line.Length > 0) { if (line[0] == '*') { meta = true; continue; } var gx = rom_contents[cline].Split("\t", 2, StringSplitOptions.None); if (gx.Length == 2) // check to see if the length is == 2, a bit redundant but whatever { switch (gx[0]) { case "CODE": Code = gx[1]; break; case "AUTHOR": Author = gx[1]; break; case "VERSION": Version = gx[1]; break; } } } cline++; } while (cline < rom_contents.Length) { var line = rom_contents[cline]; var gx = rom_contents[cline].Split("|", 2, StringSplitOptions.None); if (gx.Length == 2) { gx[1] = gx[1].Replace("\\n", "\n"); Localization.addLanguageString(Code + "/" + gx[0], gx[1]); } cline++; } languageData[Code] = new LanguageFile { author = Author, version = Version, }; Console.WriteLine("Loaded language QL for {0} version {1} by {2}", Code, Version, Author); }