public void setValue(string key, string value) { if (this.value != null || childrenIndex == null) { return; } KeyValue child = getChildByKey(key); if (child != null) { child.setValue(value); return; } addChild(key, new KeyValue(key, value)); }
private void createButton_Click(object sender, EventArgs e) { modFolder = textFolder.EditValue.ToString(); Game game = launcher.GetGamesList()[gameName]; string appId = game.GetAppId().ToString(); string mod = modFolder + " (" + modFolder + ")"; string gamePath = game.installPath; string modPath = baseModPath + modFolder; // Copy the mod template string templatePath = AppDomain.CurrentDomain.BaseDirectory + "Templates\\" + game.name + "\\" + gameBranch + "\\"; foreach (string file in Directory.GetFiles(templatePath, "*", SearchOption.AllDirectories)) { string destinationPath = modPath + "\\" + file.Replace(templatePath, string.Empty); string destinationDirectory = new FileInfo(destinationPath).Directory.FullName; Directory.CreateDirectory(destinationDirectory); File.Copy(file, destinationPath); } switch (engine) { case Engine.SOURCE: { File.Move(modPath + "\\resource\\template_english.txt", modPath + "\\resource\\" + modFolder + "_english.txt"); SourceSDK.KeyValue gameInfo = SourceSDK.KeyValue.readChunkfile(modPath + "\\gameinfo.txt"); gameInfo.setValue("game", modFolder); gameInfo.setValue("title", modFolder); SourceSDK.KeyValue.writeChunkFile(modPath + "\\gameinfo.txt", gameInfo, false, new UTF8Encoding(false)); } break; case Engine.SOURCE2: { SourceSDK.KeyValue gameInfo = SourceSDK.KeyValue.readChunkfile(modPath + "\\gameinfo.gi"); gameInfo.setValue("game", modFolder); gameInfo.setValue("title", modFolder); SourceSDK.KeyValue searchPaths = gameInfo.getChildByKey("filesystem").getChildByKey("searchpaths"); searchPaths.clearChildren(); searchPaths.addChild("game", modFolder); searchPaths.addChild("game", "hlvr"); searchPaths.addChild("game", "core"); searchPaths.addChild("mod", modFolder); searchPaths.addChild("write", modFolder); SourceSDK.KeyValue.writeChunkFile(modPath + "\\gameinfo.gi", gameInfo, false, new UTF8Encoding(false)); } break; case Engine.GOLDSRC: { SourceSDK.KeyValue gameInfo = SourceSDK.Config.readChunkfile(modPath + "\\liblist.gam"); gameInfo.setValue("game", modFolder); SourceSDK.Config.writeChunkFile(modPath + "\\liblist.gam", gameInfo, false, new UTF8Encoding(false)); } break; } DialogResult = DialogResult.OK; Close(); }