ScriptDlg.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // ScriptDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "Radiant.h"
  22. #include "ScriptDlg.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CScriptDlg dialog
  30. CScriptDlg::CScriptDlg(CWnd* pParent /*=NULL*/)
  31. : CDialog(CScriptDlg::IDD, pParent)
  32. {
  33. //{{AFX_DATA_INIT(CScriptDlg)
  34. m_strScript = _T("");
  35. //}}AFX_DATA_INIT
  36. }
  37. void CScriptDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CScriptDlg)
  41. DDX_Control(pDX, IDC_LIST_SCRIPTS, m_lstScripts);
  42. DDX_LBString(pDX, IDC_LIST_SCRIPTS, m_strScript);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CScriptDlg, CDialog)
  46. //{{AFX_MSG_MAP(CScriptDlg)
  47. ON_BN_CLICKED(ID_RUN, OnRun)
  48. ON_LBN_DBLCLK(IDC_LIST_SCRIPTS, OnDblclkListScripts)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CScriptDlg message handlers
  53. void CScriptDlg::OnRun()
  54. {
  55. UpdateData(TRUE);
  56. EndDialog(IDOK);
  57. RunScriptByName(m_strScript.GetBuffer(0), true);
  58. }
  59. BOOL CScriptDlg::OnInitDialog()
  60. {
  61. CDialog::OnInitDialog();
  62. char* pBuff = new char[16384];
  63. CString strINI = g_strAppPath;
  64. strINI += "\\scripts.ini";
  65. int n = GetPrivateProfileSectionNames(pBuff, 16384, strINI);
  66. // CStringList list;
  67. m_lstScripts.ResetContent();
  68. char* pWorkBuff = pBuff;
  69. while (*pWorkBuff != NULL)
  70. {
  71. m_lstScripts.AddString(pWorkBuff);
  72. pWorkBuff += strlen(pWorkBuff) + 1;
  73. }
  74. delete []pBuff;
  75. return TRUE; // return TRUE unless you set the focus to a control
  76. // EXCEPTION: OCX Property Pages should return FALSE
  77. }
  78. void CScriptDlg::OnDblclkListScripts()
  79. {
  80. UpdateData(TRUE);
  81. EndDialog(IDOK);
  82. RunScriptByName(m_strScript.GetBuffer(0), true);
  83. }