Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <summary>
        /// 给定目录名,返回{ [{文件ID}: {文件名、文件内容}] 。。。}的Hashtable
        /// </summary>
        /// <param name="strPath">目录名</param>
        /// <returns>信息数据表</returns>
        public Hashtable getFileListFromPath(string strPath)
        {
            List<string> fileList = getFileIDsFromPath(strPath);
            ProgressForm pForm = null;

            if (fileList.Count > 0)
            {
                pForm = new ProgressForm(0, fileList.Count);
                pForm.Show(); 
            }                       
            
            Hashtable ht_ret = new Hashtable();
            DataBaseManager dbm = DataBaseManager.GetDataBaseManager();
            DataTable dt = dbm.GetScriptInformation();
            int index = 1;

            foreach(string id in fileList)
            {                
                Hashtable ht_tmp = new Hashtable();
                DataRow[] dr = dt.Select("id = " + id);
                if(dr.Length == 0 ) return null;
                ht_tmp["filename"] = dr[0]["path"];
                ht_tmp["filecontent"] = dbm.GetScriptData(id);
                ht_ret.Add(id, ht_tmp);

                if (pForm != null)
                {
                    pForm.ShowProgress(index, string.Format("遍历{0}...", ht_tmp["filename"] as string));
                }
                
                index++;
            }

            return ht_ret;
        }
Beispiel #3
0
        /// <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();
        }