Beispiel #1
0
        private void Export_button_Click(object sender, EventArgs e)
        {
            StringBuilder strRootDir = new StringBuilder(255);
            FileFolderHelper.ReadIniFile("General", "DefaultStorageDir", "", strRootDir, 255, Application.StartupPath + "/GameDesingerTools.ini");
            if (strRootDir.Length <= 0)
            {
                MessageBox.Show("您的工具选项中导出数据页中没有设置导出的根路径,请先为导出文件设置根目录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.checkedListBox1.Items.Count == 0)
                return;

            LuaExporter luaExporter = new LuaExporter();
            string exportLuaFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\export.lua";
            string postExportLuaFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\post_export.lua";
            string UiTableCfgFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\UITableConfig.ini";
            luaExporter.InitLuaFile(exportLuaFile, postExportLuaFile, UiTableCfgFile);

            string strResult = "";
            for (int i = 0; i < checkedListBox1.Items.Count; ++i)
            {
                bool bRetCode = checkedListBox1.GetItemChecked(i);
                if (!bRetCode)
                    continue;

                DataRow row = m_ExportTable.Rows.Find(m_anTableID[i]);

                if (row == null)
                    return;

                string strTableName = row["tablename"].ToString().Trim();
                string strFilePath = row["filepath"].ToString().Trim();   // 相对路径
                if (strFilePath.Length > 0)
                {
                    StringBuilder sb = new StringBuilder(strRootDir.ToString());
                    if (strFilePath[0] != '\\' && sb[sb.Length - 1] != '\\')
                    {
                        sb.Append('\\');
                    }
                    strFilePath = sb.Append(strFilePath).ToString();          // 绝对路径
                }
                
                //这里开始作脚本扩展
                bool bExclusive = false;
                if (luaExporter.IsInterestedIn(strTableName, true))
                {
                    bExclusive = CallLuaExport(strTableName, ref strResult);
                }
                if (!bExclusive)
                {
                    bRetCode = ExportTab(strTableName, strFilePath);
                }

                // 导出过后有post-export的脚本扩展
                bool bSucPostExport = CallLuaPostExport(strTableName, strFilePath);

                if (bRetCode && bSucPostExport)
                {
                    strResult += string.Format("成功导出数据表{0}到{1}\r\n", strTableName, strFilePath);
                }
            }
            
            if (strResult != "")
            {                
                MessageBox.Show(strResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            string strmsg = string.Format("结果为:{0}", strResult);
            log.Log(TimeLog.enumLogType.ltend, null, null, strmsg);
        }
Beispiel #2
0
        private void Export_button_Click(object sender, EventArgs e)
        {
            StringBuilder strRootDir = new StringBuilder(255);

            FileFolderHelper.ReadIniFile("General", "DefaultStorageDir", "", strRootDir, 255, Application.StartupPath + "/GameDesingerTools.ini");
            if (strRootDir.Length <= 0)
            {
                MessageBox.Show("您的工具选项中导出数据页中没有设置导出的根路径,请先为导出文件设置根目录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.checkedListBox1.Items.Count == 0)
            {
                return;
            }

            LuaExporter luaExporter       = new LuaExporter();
            string      exportLuaFile     = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\export.lua";
            string      postExportLuaFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\post_export.lua";
            string      UiTableCfgFile    = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\UITableConfig.ini";

            luaExporter.InitLuaFile(exportLuaFile, postExportLuaFile, UiTableCfgFile);

            string strResult = "";

            for (int i = 0; i < checkedListBox1.Items.Count; ++i)
            {
                bool bRetCode = checkedListBox1.GetItemChecked(i);
                if (!bRetCode)
                {
                    continue;
                }

                DataRow row = m_ExportTable.Rows.Find(m_anTableID[i]);

                if (row == null)
                {
                    return;
                }

                string strTableName = row["tablename"].ToString().Trim();
                string strFilePath  = row["filepath"].ToString().Trim();  // 相对路径
                if (strFilePath.Length > 0)
                {
                    StringBuilder sb = new StringBuilder(strRootDir.ToString());
                    if (strFilePath[0] != '\\' && sb[sb.Length - 1] != '\\')
                    {
                        sb.Append('\\');
                    }
                    strFilePath = sb.Append(strFilePath).ToString();          // 绝对路径
                }

                //这里开始作脚本扩展
                bool bExclusive = false;
                if (luaExporter.IsInterestedIn(strTableName, true))
                {
                    bExclusive = CallLuaExport(strTableName, ref strResult);
                }
                if (!bExclusive)
                {
                    bRetCode = ExportTab(strTableName, strFilePath);
                }

                // 导出过后有post-export的脚本扩展
                bool bSucPostExport = CallLuaPostExport(strTableName, strFilePath);

                if (bRetCode && bSucPostExport)
                {
                    strResult += string.Format("成功导出数据表{0}到{1}\r\n", strTableName, strFilePath);
                }
            }

            if (strResult != "")
            {
                MessageBox.Show(strResult, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            string strmsg = string.Format("结果为:{0}", strResult);

            log.Log(TimeLog.enumLogType.ltend, null, null, strmsg);
        }