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); } }
public bool ExportTab(string strTableName, string strDestFile) { string strHeader = string.Empty; string strContent = string.Empty; if (!GenerateString(strTableName, ref strHeader, ref strContent)) { return(false); } try { StringBuilder strFinal = new StringBuilder(); strFinal.Append(strHeader); strFinal.Append(strContent); FileFolderHelper.StringToFile(strFinal.ToString(), strDestFile); return(true); } catch (Exception ex) { string s = string.Format("导出 tab 文件:\r\n {0}\r\n时出现错误。请检查文件名,磁盘空间等。\r\n\r\n错误讯息为:{1}", strDestFile, ex.Message); System.Windows.Forms.MessageBox.Show(s, "Error"); return(false); } }
private void buttonComparer_Click(object sender, EventArgs e) { string DestFolder = FileFolderHelper.BrowserFile(new string[] { "exe" }); if (DestFolder != "") { textBoxXComparer.Text = DestFolder; } }
private void buttonX4_Click(object sender, EventArgs e) { string DestFolder = FileFolderHelper.BrowserFolder("选择KG3DEngine.dll所在路径"); if (DestFolder != "") { textBox3DEnginePath.Text = DestFolder; } }
private void browRootDir_Click(object sender, EventArgs e) { string DestFolder = FileFolderHelper.BrowserFolder("选择设置文件的根路径"); if (DestFolder != "") { txtBoxRootDir.Text = DestFolder; } }
private void buttonX1_Click(object sender, EventArgs e) { string DestFolder = FileFolderHelper.BrowserFolder("选择 skill.tab 的默认保存路径"); if (DestFolder != "") { textBoxX1.Text = DestFolder; } }
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; }
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); } } }
private void buttonOK_Click(object sender, EventArgs e) { string formerConnectionString = Program.ConnetionString; // 旧的连接语句 string strIniFile = Application.StartupPath + "/GameDesingerTools.ini"; string strRemoteFile = Application.StartupPath + "/GameDesingerTools_remote.ini"; FileFolderHelper.WriteIniFile("General", "DefaultStorageDir", textBoxX1.Text, strIniFile); //FileFolderHelper.WriteIniFile("Browsing Base Folder", "Script", textBoxX2.Text, strIniFile); //FileFolderHelper.WriteIniFile("Browsing Base Folder", "Sfx", textBoxX3.Text, strIniFile); FileFolderHelper.WriteIniFile("Advance", "tmrRenderInterval", textBoxX2.Text, strIniFile); FileFolderHelper.WriteIniFile("Advance", "ComparerDir", textBoxXComparer.Text, strIniFile); int iInterval = 50; bool bSuc = int.TryParse(textBoxX2.Text, out iInterval); if (bSuc) { Program.m_3d_tmrRender = iInterval; if (Program.MainForm != null) { Program.MainForm.UpdateAllBaseFormTmrRenderInterval(); } } FileFolderHelper.WriteIniFile("General", "RootDir", txtBoxRootDir.Text, strIniFile); FileFolderHelper.WriteIniFile("General", "3DEnginePath", textBox3DEnginePath.Text, strIniFile); Program.RootDir = txtBoxRootDir.Text.Trim(); Program.EngineDir = textBox3DEnginePath.Text.Trim(); if (comboBox1.SelectedIndex < 0) { string message = "请选择数据库"; MessageBox.Show(message); return; } int index = comboBox1.SelectedIndex; DataBase = mInfoEN[index]; FileFolderHelper.WriteIniFile("Remote", "DataBase", DataBase, strRemoteFile); DialogResult = DialogResult.OK; Close(); }
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); } } }
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); }
private void doInitPreview(int iOption) { int old_wrong_index = this.tabControl1.SelectedTabIndex; int new_right_index = init_preview_index; // new_right_index 是从1 开始的下标。 string strTabIndex = "[" + new_right_index.ToString() + "]"; if (Program.EngineDir.Trim().Length <= 0) { if (!m_bWarning3dEngine) { m_bWarning3dEngine = true; MessageBox.Show("3DEngine 路径为空,不能正常打开预览窗口", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } string strdir = ""; if (Program.EngineDir.Substring(Program.EngineDir.Length - 1) != "\\") { strdir = Program.EngineDir + "\\"; } else { strdir = Program.EngineDir; } if (m_3DEngie == null) { bool bSuc = Helper.RegComDll("atlax.dll"); m_3DEngie = new Test3DEngine(); if (m_3DEngie == null) { MessageBox.Show("3D Engine 初始化失败!m_3DEngie = null。"); return; } m_3DEngie.Init((int)(preview_panels[new_right_index - 1].Handle), Program.EngineDir, Application.StartupPath); // 传给mainform, 让它关闭时uninit 引擎。 ((MainForm)ParentForm).K3DEngine = m_3DEngie; string content = string.Format(@" RegComDll: {0} m_3DEngie: {1} EngineDir: {2} Engine: {3} Enginenull:{4} ", bSuc, m_3DEngie, strdir, m_3DEngie, m_3DEngie == null?"null":"not null"); FileFolderHelper.StringToFile(content, Application.StartupPath + "/GameDesignerTools.log"); } m_lua["EngineDir"] = strdir; m_lua["Engine"] = m_3DEngie; int count; m_3DEngie.GetEditorSceneCount(ModelName + strTabIndex, out count); if (count > 0) { return; } m_3DEngie.AddScene((int)preview_panels[new_right_index - 1].Handle, ModelName + strTabIndex, iOption); //string DirName = strdir; //string PlayerName = DirName + "\\Data\\public\\PlayerCheckTool\\Male\\Normal\\M2.mdl"; //string AniFileName = DirName + "\\data\\source\\player\\M2\\动作\\M2b04ty空手普通待机.ani"; //m_3DEngie.LoadPlayerModel(PlayerName); //m_3DEngie.LoadAni(AniFileName, 1); this.SetTmrRenderInterval(Program.m_3d_tmrRender); tmrRender.Enabled = true; PreviewBar.Visible = true; PreviewBar.RecalcLayout(); this.ResumeLayout(); }
public void InitLuaFile(string exportLuaFileName, string postExportLuaFileName, string uiTableCfgFileName) { m_exportLuaContent = FileFolderHelper.FileToString(exportLuaFileName); m_postExportLuaContent = FileFolderHelper.FileToString(postExportLuaFileName); m_UiTableCfgContent = FileFolderHelper.FileToString(uiTableCfgFileName); }
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); }