Esempio n. 1
0
        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));
                }
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        private String getOutFileName(String inFileName)
        {
            String fileNameNoExt = Path.GetFileNameWithoutExtension(inFileName);

            if (rbOldEex.Checked || rbNewEex.Checked)
            {
                return(fileNameNoExt + EexFile.getFileExtension(EexFile.EexFileType.TYPE_EEX));
            }
            if (rbEexNew.Checked)
            {
                return(fileNameNoExt + EexFile.getFileExtension(EexFile.EexFileType.TYPE_EEX_NEW));
            }
            if (rbEexJson.Checked)
            {
                return(fileNameNoExt + EexFile.getFileExtension(EexFile.EexFileType.TYPE_EEXJS));
            }
            if (rbXlsxText.Checked)
            {
                return(fileNameNoExt + ".xlsx");
            }
            return(fileNameNoExt + EexFile.getFileExtension(EexFile.EexFileType.TYPE_UNKNOW));
        }
Esempio n. 6
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, "转换完成");
        }