Example #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));
                }
            }
        }
Example #2
0
        public static String scriptRoot2JsonText(ScriptRoot sr)
        {
            JObject jo   = sr.toJsonObject();
            String  text = jo.ToString(Newtonsoft.Json.Formatting.Indented);

            return(text);
        }
Example #3
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);
            }
        }
Example #4
0
        private void buildTreeView(ScriptRoot root)
        {
            treeContent.Clear();

            treeViewRoot.BeginUpdate();

            treeViewRoot.Nodes.Clear();
            TreeNode tnRoot = new TreeNode(root.getNodeText());

            tnRoot.Tag          = root;
            treeContent[tnRoot] = root.toJsonObject().ToString(Newtonsoft.Json.Formatting.Indented);

            foreach (ScriptScene item in root.SceneList)
            {
                TreeNode tnScene = new TreeNode(item.getNodeText());
                tnScene.Tag          = item;
                treeContent[tnScene] = item.toJsonObject().ToString(Newtonsoft.Json.Formatting.Indented);

                foreach (ScriptSection section in item.SectionList)
                {
                    TreeNode tnSection = new TreeNode(section.getNodeText());
                    tnSection.Tag          = section;
                    treeContent[tnSection] = section.toJsonObject().ToString(Newtonsoft.Json.Formatting.Indented);

                    addScriptCommand(tnSection, section.CommandList);

                    tnSection.Expand();
                    tnScene.Nodes.Add(tnSection);
                }

                tnScene.Expand();
                tnRoot.Nodes.Add(tnScene);
            }

            tnRoot.Expand();
            treeViewRoot.Nodes.Add(tnRoot);

            treeViewRoot.EndUpdate();
        }