/// <summary> /// 选择确定 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void bOK_Click(object sender, EventArgs e) { bool coverScript = coverScriptBox.Checked; if (coverScript) { if (MessageBox.Show("确定要覆盖已有脚本吗?", " 导入脚本", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { coverScript = false; } } DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager(); int successCount = 0; scriptList.Clear(); for (int i = 0; i < scriptListBox.Items.Count; i++) { if (scriptListBox.GetItemChecked(i)) { scriptList.Add(scriptListBox.Items[i] as string); } } ProgressForm progressForm = new ProgressForm(0, scriptList.Count); progressForm.Show(); for (int i = 0; i < scriptList.Count; i++) { string scriptName = scriptList[i]; string fileName = Path.Combine(fileFolder, scriptName); string content = Helper.FileToString(fileName); progressForm.ShowProgress(i, string.Format("导入脚本{0}的数据...", scriptName)); if (!string.IsNullOrEmpty(content)) { string dataBasePath = Path.Combine(scriptFolder, scriptName); string id = dataBaseManager.CreateScriptData(dataBasePath, content, coverScript); if (id != null) { createNewNode(rootNode, scriptName, id); successCount++; } } } progressForm.Close(); MessageBox.Show(string.Format("共导入{0}个脚本文件!", successCount), "导入脚本", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 清理并导出所有文件 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void bClearAndExport_Click(object sender, EventArgs e) { List <TreeNode> nodeList = new List <TreeNode>(); foreach (TreeNode node in MainForm.CurrentMainForm.tree.Nodes["scripts"].Nodes) { if (node.Text == "Map") { foreach (TreeNode sceneNode in node.Nodes) { nodeList.Add(sceneNode); } } else { nodeList.Add(node); } } ProgressForm pForm = new ProgressForm(1, nodeList.Count); pForm.Show(); int index = 1; foreach (TreeNode node in nodeList) { string classification = node.Text; bool sceneScript = (node.Parent.Text == "Map"); pForm.ShowProgress(index, string.Format("导出{0}分类下的LS数据表...", classification)); index++; string tableName = "SCENE_STRING_TABLE"; string fileName = string.Format(@"scripts\Map\{0}\include\scenestrings.ls", classification); if (!sceneScript) { tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper()); fileName = string.Format(@"scripts\{0}\include\strings.ls", classification); } DataRow[] lsRows = GetValidStringDataRow(classification, sceneScript); string content = CodeConvert.ConvertLsFileContent(lsRows, tableName); fileName = Path.Combine(Helper.ClientPath, fileName); Helper.WriteStringToFile(content, fileName); } MessageBox.Show("LS文件导出成功!", "导出所有LS文件", MessageBoxButtons.OK, MessageBoxIcon.Information); }
/// <summary> /// 清理并导出所有文件 /// </summary> /// <param name="sender">事件发送者</param> /// <param name="e">事件参数</param> private void bClearAndExport_Click(object sender, EventArgs e) { List<TreeNode> nodeList = new List<TreeNode>(); foreach (TreeNode node in MainForm.CurrentMainForm.tree.Nodes["scripts"].Nodes) { if (node.Text == "Map") { foreach (TreeNode sceneNode in node.Nodes) { nodeList.Add(sceneNode); } } else { nodeList.Add(node); } } ProgressForm pForm = new ProgressForm(1, nodeList.Count); pForm.Show(); int index = 1; foreach (TreeNode node in nodeList) { string classification = node.Text; bool sceneScript = (node.Parent.Text == "Map"); pForm.ShowProgress(index, string.Format("导出{0}分类下的LS数据表...", classification)); index++; string tableName = "SCENE_STRING_TABLE"; string fileName = string.Format(@"scripts\Map\{0}\include\scenestrings.ls", classification); if (!sceneScript) { tableName = string.Format("{0}_STRING_TABLE", classification.ToUpper()); fileName = string.Format(@"scripts\{0}\include\strings.ls", classification); } DataRow[] lsRows = GetValidStringDataRow(classification, sceneScript); string content = CodeConvert.ConvertLsFileContent(lsRows, tableName); fileName = Path.Combine(Helper.ClientPath, fileName); Helper.WriteStringToFile(content, fileName); } MessageBox.Show("LS文件导出成功!", "导出所有LS文件", MessageBoxButtons.OK, MessageBoxIcon.Information); }