예제 #1
0
파일: FormMain.cs 프로젝트: droidsde/game
        private void 另存为AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ScriptRoot sr = scriptRoot[m_cur_index];

            if (sr == null)
            {
                MessageBox.Show(this, "未加载,无法保存");
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title  = "保存剧本文件";
            sfd.Filter = "eex new剧本文件(*.eex_new)|*.eex_new";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                EexFile.saveFile(sr, sfd.FileName);
            }
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ScriptRoot sr = scriptRoot;

            if (sr == null)
            {
                MessageBox.Show(this, "json未加载,无法保存");
                return;
            }

            /*
             * try
             * {
             *  sr = EexFile.jsonText2ScriptRoot(tbContent.Text);
             * }
             * catch (Exception)
             * {
             *  MessageBox.Show(this, "json格式错误,无法保存");
             *  return;
             * }
             * */

            buildTreeView(sr);
            String readString = sr.toJsonObject().ToString(Newtonsoft.Json.Formatting.Indented);

            tbContent.Text = readString;
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title  = "保存剧本文件";
            sfd.Filter = "旧版本eex剧本文件(*.eex)|*.eex|新版本eex剧本文件(*.eex)|*.eex|eex new剧本文件(*.eex_new)|*.eex_new|eex json剧本文件(*.eexjs)|*.eexjs";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int group = 0;
                if (sfd.FilterIndex <= 2)
                {
                    group = sfd.FilterIndex - 1;
                }
                EexFile.saveFile(sr, sfd.FileName, group);
            }
        }
예제 #3
0
        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, "转换完成");
        }