private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "打开剧本文件"; ofd.Filter = "旧版本eex剧本文件(*.eex)|*.eex|新版本eex剧本文件(*.eex)|*.eex|eex new剧本文件(*.eex_new)|*.eex_new|eex json剧本文件(*.eexjs)|*.eexjs"; ofd.Multiselect = false; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { int group = 0; if (ofd.FilterIndex == 2) { group = 1; } ScriptRoot sr = EexFile.loadFile(ofd.FileName, group); buildTreeView(sr); String readString = sr.toJsonObject().ToString(Newtonsoft.Json.Formatting.Indented); tbContent.Text = readString; scriptRoot = sr; } catch (EexReaderException exception) { MessageBox.Show(this, String.Format("文件{0},解析指令0x{1:x}出错,内部信息为:{2}", ofd.FileName, exception.CommandId, exception.Message)); } } }
private void 打开OToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "打开剧本文件"; ofd.Filter = "eex new剧本文件(*.eex_new)|*.eex_new"; ofd.Multiselect = true; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ScriptRoot sr = null; for (int i = 0; i < ofd.FileNames.Length; i++) { bool isExist = false; for (int j = 0; j < scriptRoot.Count; j++) { if (scriptRoot[j].m_path == ofd.FileNames[i]) { isExist = true; sr = scriptRoot[j]; m_cur_index = j; tabControl1.SelectTab(m_cur_index); break; } } if (!isExist) { try { TabPage Page = new TabPage(); Page.Name = "Page1"; Page.Text = ofd.FileNames[i].Substring(ofd.FileNames[i].LastIndexOf("\\") + 1, ofd.FileNames[i].Length - 1 - ofd.FileNames[i].LastIndexOf("\\")); Page.BackColor = Color.White; tabControl1.Controls.Add(Page); sr = EexFile.loadFile(ofd.FileNames[i]); scriptRoot.Add(sr); tabControl1.SelectedIndex = tabControl1.Controls.Count - 1; } catch (EexReaderException exception) { MessageBox.Show(this, String.Format("文件{0},解析指令0x{1:x}出错,内部信息为:{2}", ofd.FileName[i], exception.CommandId, exception.Message)); } } } buildTreeView(sr); } }
private void btnOpen_Click(object sender, EventArgs e) { int commandId = -1; if (tbCommand.Enabled) { try { commandId = Convert.ToInt32(tbCommand.Text, 16); if (commandId < 0) { MessageBox.Show(this, "指令格式必须为16进制的数字"); tbCommand.Focus(); return; } } catch (Exception) { MessageBox.Show(this, "指令格式必须为16进制的数字"); tbCommand.Focus(); return; } } OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "打开剧本文件"; ofd.Multiselect = true; ofd.Filter = "旧版本eex剧本文件(*.eex)|*.eex|新版本eex剧本文件(*.eex)|*.eex|eex new剧本文件(*.eex_new)|*.eex_new|eex json剧本文件(*.eexjs)|*.eexjs"; ofd.Multiselect = true; if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } string loadExcelPath = ""; if (cbLoadExcel.Checked) { FolderBrowserDialog fbdLoad = new FolderBrowserDialog(); fbdLoad.Description = "选择Excel翻译文件目录"; if (fbdLoad.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } loadExcelPath = fbdLoad.SelectedPath; } FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "选择输出文件目录"; if (fbd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } int inGroup = 0; if (ofd.FilterIndex == 2) { inGroup = 1; } int outGroup = 0; if (rbNewEex.Checked) { outGroup = 1; } foreach (string inFilePath in ofd.FileNames) { try { ScriptRoot sr = EexFile.loadFile(inFilePath, inGroup); if (commandId >= 0 && !sr.containCommand(commandId)) { continue; } if (!String.IsNullOrEmpty(loadExcelPath)) { string excelPath = Path.Combine(loadExcelPath, Path.GetFileNameWithoutExtension(inFilePath) + ".xlsx"); if (File.Exists(excelPath)) { bool result = EexFile.loadStringFromExcel(sr, excelPath); if (!result) { MessageBox.Show(this, String.Format("加载文件{0}出错,行数太少", excelPath)); return; } } } if (rbXlsxText.Checked) { EexFile.saveStringToExcel(sr, Path.Combine(fbd.SelectedPath, getOutFileName(inFilePath))); } else { EexFile.saveFile(sr, Path.Combine(fbd.SelectedPath, getOutFileName(inFilePath)), outGroup); } } catch (EexReaderException exception) { MessageBox.Show(this, String.Format("文件{0},解析指令0x{1:x}出错,内部信息为:{2}", inFilePath, exception.CommandId, exception.Message)); return; } } MessageBox.Show(this, "转换完成"); }