示例#1
0
        public void Init()
        {
            try
            {
                StringBuilder sb = new StringBuilder(255);
                FileFolderHelper.ReadIniFile("Rights", "AllowSave", "1", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                RightsSettings.AllowSave         = Convert.ToInt32(sb.ToString()) == 1 ? true : false;
                RightsSettings.AllowModifyValue  = RightsSettings.AllowSave;
                RightsSettings.AllowModifyTree   = RightsSettings.AllowSave;
                RightsSettings.AllowModifyScript = RightsSettings.AllowSave;

                CheckACL();
            }
            catch (Exception ex)
            {
                string strExtMsg   = "附加信息:\n";
                string strHostName = Helper.GetHostName().ToLower();
                strExtMsg += "机器名:" + strHostName + "\n";
                strExtMsg += "IP地址:";
                System.Net.IPAddress[] ips = Helper.GetIPAddresses();
                foreach (System.Net.IPAddress ip in ips)
                {
                    string strip = ip.ToString();
                    strExtMsg += strip + "\n";
                }

                throw new Exception("权限系统初始化失败!\n" + strExtMsg + "\r\n错误信息为:\r\n" + ex.Message);
            }
        }
示例#2
0
        public AppOptionsForm()
        {
            InitializeComponent();
            string        strIniFile    = Application.StartupPath + "/GameDesingerTools.ini";
            string        strRemoteFile = Application.StartupPath + "/GameDesingerTools_remote.ini";
            StringBuilder sb            = new StringBuilder(255);

            FileFolderHelper.ReadIniFile("General", "DefaultStorageDir", "", sb, 255, strIniFile);
            textBoxX1.Text = sb.ToString();


            //FileFolderHelper.ReadIniFile("General", "RootDir", "", sb, 255, strIniFile);
            txtBoxRootDir.Text = Program.RootDir;
            //txtBoxConnStr.Text = Program.ConnetionString;
            textBox3DEnginePath.Text = Program.EngineDir;

            FileFolderHelper.ReadIniFile("Advance", "tmrRenderInterval", "50", sb, 255, strIniFile);
            textBoxX2.Text = sb.ToString();

            FileFolderHelper.ReadIniFile("Advance", "ComparerDir", "", sb, 255, strIniFile);
            this.textBoxXComparer.Text = sb.ToString();

            FileFolderHelper.ReadIniFile("Remote", "DBInfo", "", sb, 255, strRemoteFile);
            string dbinfo = sb.ToString().Trim();

            mInfoEN = dbinfo.Split(new char[] { ' ' });

            FileFolderHelper.ReadIniFile("Remote", "DBInfoCHN", "", sb, 255, strRemoteFile);
            string cnInfo = sb.ToString().Trim();

            mInfoCN = cnInfo.Split(new char[] { ' ' });
            comboBox1.Items.AddRange(mInfoCN);

            FileFolderHelper.ReadIniFile("Remote", "DataBase", "", sb, 255, strRemoteFile);
            string database = sb.ToString().Trim();

            if (database != string.Empty)
            {
                for (int index = 0; index < mInfoCN.Length; ++index)
                {
                    if (database == mInfoEN[index])
                    {
                        comboBox1.SelectedIndex = index;
                    }
                }
            }

            tabItem4.Parent.SelectedTab = tabItem4;
        }
示例#3
0
        private void btOpenExportedFile_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;
            }

            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 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();                     // 绝对路径
                    int nIndex = strFilePath.LastIndexOf('\\');
                    strFilePath = strFilePath.Replace('/', '\\').Replace("\\\\", "\\");; //去掉多余的\\
                    System.Diagnostics.Process.Start(strFilePath);
                }
            }
        }
示例#4
0
        public override void SetValue(object component, object value)
        {
            try
            {
                SetValueCommand cmd = new SetValueCommand();
                cmd.Execute();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                throw;
            }

            if (component is CustomClass)
            {
                CustomClass o = (CustomClass)component;
                if (m_Property.ValueType == enumValueType.vtCombo)
                {
                    o.OnDataValidate(m_Property, m_Property.ComboValues[value], value);
                }
                else
                {
                    o.OnDataValidate(m_Property, value, value);
                }
            }

            if (m_Property.ValueType == enumValueType.vtFileNameScript)
            {
                string strFullPath = (string)value;

                // to 相对路径
                string strBase = null;
                if (System.IO.File.Exists(Application.StartupPath + "\\GameDesingerTools.ini"))
                {
                    StringBuilder sb = new StringBuilder(255);
                    FileFolderHelper.ReadIniFile("Browsing Base Folder", "Script", "", sb, 255, Application.StartupPath + "\\GameDesingerTools.ini");
                    strBase = sb.ToString();
                }
                string strConverted = strFullPath.Replace(strBase + "\\", "");

                // '\' -> '/'
                strConverted     = strConverted.Replace("\\", "/");
                m_Property.Value = strConverted;
            }
            else if (m_Property.ValueType == enumValueType.vtExpandNode && m_Property.Value is DBCustomClass)
            {
                //((DBCustomClass)m_Property.Value).Value = value;
                //((DBCustomClass)m_Property.Value).ReinitData();
                //((DBCustomClass)m_Property.Value).GetDynamicClass(new object[]{value});
                //m_Property.Value = (DBCustomClass)m_Property.Value;
                //m_Property.ValueType = enumValueType.vtExpandNode;
            }
            else
            {
                //if (m_Property.IsClearDisplayValue) //仅在 oneditvalue 时会被置 false, 用于设置显示值,不影响保存的值
                //    m_Property.DisplayValue = null;
                //m_Property.IsClearDisplayValue = true;
                m_Property.Value = value;
            }

            if (component is CustomClass)
            {
                CustomClass o = (CustomClass)component;
                if (m_Property.ValueType == enumValueType.vtCombo)
                {
                    o.OnAfterDataValidate(m_Property, m_Property.ComboValues[value], value);
                }
                else
                {
                    o.OnAfterDataValidate(m_Property, value, value);
                }
            }
        }
示例#5
0
        private static bool InitSettings()
        {
            m_strrootdir   = string.Empty;
            m_strconnstr   = string.Empty;
            m_strEngineDir = string.Empty;

            StringBuilder sb   = new StringBuilder(255);
            bool          bRet = false;

            while (m_strrootdir.Length <= 0)
            {
                FileFolderHelper.ReadIniFile("General", "RootDir", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strrootdir = sb.ToString();
                m_strrootdir = m_strrootdir.Trim();
                if (m_strrootdir.Length <= 0)
                {
                    MessageBox.Show("设置文件根目录不能为空,请设置您的本地设置文件存在的根目录。如:E:\\work\\Sword3\\sword3DesignBase\\commit_swap)", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            if (EnableRemoting)
            {
                while (Database == string.Empty)
                {
                    FileFolderHelper.ReadIniFile("Remote", "DataBase", "", sb, 255, Application.StartupPath + "/GameDesingerTools_remote.ini");
                    Database = sb.ToString().Trim();
                    if (Database == string.Empty && Database.Length == 0)
                    {
                        AppOptionsForm frm = new AppOptionsForm();
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            Database = frm.DataBase;
                            frm.Update();
                            break;
                        }
                        else
                        {
                            bRet = false;
                            MessageBox.Show("连接数据库名不能为空,请设置数据库。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }

                bRet = true;
            }


            m_strconnstr = Database;

            while (m_strconnstr.Length <= 0 && bRet)
            {
//                 // crypt
//                 string myString = @"[General]
// ConnString=Server = jx3web; DataBase = s3design_debug; Uid = s3design; Password = davidbowie;
// ";
//
//                 Misc.SymmetricMethod _sm = new Misc.SymmetricMethod();
//                 string c = _sm.Encrypto(myString);
//                 c = _sm.Decrypto(c);

                bRet = false;



                if (!System.IO.File.Exists(Application.StartupPath + "\\GameDesingerTools_Public.ini"))
                {
                    MessageBox.Show("GameDesingerTools_Public.ini 不存在,程序不能启动!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }


                string filename         = Application.StartupPath + "/GameDesingerTools_Public.ini";
                string content          = FileFolderHelper.FileToString(filename);
                Misc.SymmetricMethod sm = new Misc.SymmetricMethod();
                content = sm.Decrypto(content);
                Misc.IniStructure m_inis = new Misc.IniStructure();
                m_inis       = Misc.IniStructure.ReadIniWithContent(content);
                m_strconnstr = m_inis.GetValue("General", "ConnString");



                if (m_bLoadBackupDB) // 强制读取策划备份库的信息
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design-1-0-8-1380-new; Uid = s3design; Password = davidbowie;";
                }
                if (m_bSkillBranch) // 技能系统组分支2009-5-11
                {
                    m_strconnstr = "Server = jx3web; DataBase = s3design_skill_branch; Uid = s3design; Password = davidbowie;";
                }

                if (m_strconnstr.Length <= 0)
                {
                    MessageBox.Show("连接字符串不能为空,请设置数据库连接。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            while (m_strEngineDir.Length <= 0 && bRet)
            {
                bRet = false;
                FileFolderHelper.ReadIniFile("General", "3DEnginePath", "", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
                m_strEngineDir = sb.ToString();
                m_strEngineDir = m_strEngineDir.Trim();
                if (m_strEngineDir.Length <= 0)
                {
                    MessageBox.Show("3DEngine 路径设置不能为空,请设置 KG3DEngine.DLL 所在的路径", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    AppOptionsForm fm = null;
                    fm = new AppOptionsForm();
                    if (fm.ShowDialog() == DialogResult.OK)
                    {
                        fm.Update();
                    }
                    else
                    {
                        break;
                    }
                }
                bRet = true;
            }

            if (bRet)
            {
                MainForm.InitConn();
                m_rightmgr.Init();
            }

            // 读3d时钟参数
            FileFolderHelper.ReadIniFile("Advance", "tmrRenderInterval", "50", sb, 255, Application.StartupPath + "/GameDesingerTools.ini");
            int iInterval = 50;

            if (int.TryParse(sb.ToString(), out iInterval))
            {
                Program.m_3d_tmrRender = iInterval;
            }

            return(bRet);
        }
示例#6
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);
        }