public MKTModMeta(string modPath) { JObject json = MKTCore.LoadJSON(Path.Combine(modPath, "_Meta.json")); this.name = json.Value <string>("Mod"); this.translator = json.Value <string>("Translator"); this.inspector = json.Value <string>("Inspector"); this.modVersion = new Version(json.Value <string>("Version")); this.MKTVersion = new Version(json.Value <string>("MKT") != null? json.Value <string>("MKT"): "0.3.0"); }
public void Load() { // 번역파일 로드 JObject json = MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), true); if (json["items"] != null) { foreach (KeyValuePair <string, JToken> pair in json.Value <JObject>("items")) { ModTranslation translation = mod.CreateTranslation(pair.Key); translation.AddTranslation(Language.ActiveCulture, pair.Value.ToObject <string>()); mod.AddTranslation(translation); } } }
private void LoadUserLocalization() { LanguageManager manager = LanguageManager.Instance; bool trMode = ModContent.GetInstance <Config>().TranslatorMode; if (File.Exists(Path.Combine(MKTCore.translatorPath, "Terraria.mkt")) && trMode == false) { manager.LoadLanguageFromFileText(MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, "Terraria.mkt"), true).ToString()); } else if (File.Exists(Path.Combine(translatorPath, "Translations.json"))) { JObject json = MKTCore.Tr2LangCol3(MKTCore.LoadJSON(Path.Combine(translatorPath, "Translations.json")), false); MKTCore.DumpJSON(Path.Combine(MKTCore.translatorPath, "Terraria.mkt"), json, true); manager.LoadLanguageFromFileText(json.ToString()); } }
public void Compile() { // 번역파일 묶기 JObject json = new JObject(); string[] itemFiles = new string[] { "Items.json", "Prefixes.json", "NPCs.json", "Buffs.json" }; json.Add("meta", MKTCore.LoadJSON(Path.Combine(path, "_Meta.json"))); if (File.Exists(Path.Combine(path, "Translations.json"))) { json.Add("items", CompJSON(MKTCore.LoadJSON(Path.Combine(path, "Translations.json")), true)); } foreach (string file in itemFiles) { if (File.Exists(Path.Combine(path, file))) { json.Value <JObject>("items").Merge(CompJSON(MKTCore.LoadJSON(Path.Combine(path, file)))); } } MKTCore.DumpJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), json, true); }
public MKTMod(Mod mod) { this.mod = mod; this.version = mod.Version; this.path = Path.Combine(MKTCore.translatorPath, "tr_" + mod.Name); this.langs = new Dictionary <string, MKTModLang>(); // 0.3.0 번역호환 if (Directory.Exists(Path.Combine(MKTCore.translatorPath, mod.Name))) { try { Directory.Move(Path.Combine(MKTCore.translatorPath, mod.Name), path); } catch { // 실패시 수동변경 } } if (File.Exists(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt")) && !ModContent.GetInstance <Config>().TranslatorMode) { this.active = true; this.meta = new MKTModMeta(MKTCore.LoadJSON(Path.Combine(MKTCore.translatorPath, $"{mod.Name}.mkt"), true).Value <JObject>("meta")); Load(); } else if (File.Exists(Path.Combine(path, "_Meta.json"))) { this.active = true; this.meta = new MKTModMeta(path); // 번역파일 로드 Compile(); Load(); } else { this.meta = new MKTModMeta(mod); } }
public MKTModLang(string path) { this._json = MKTCore.LoadJSON(path); }