home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / ScriptDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  1.9 KB  |  83 lines

  1. // ScriptDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Radiant.h"
  6. #include "ScriptDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CScriptDlg dialog
  16.  
  17.  
  18. CScriptDlg::CScriptDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CScriptDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CScriptDlg)
  22.     m_strScript = _T("");
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26.  
  27. void CScriptDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CScriptDlg)
  31.     DDX_Control(pDX, IDC_LIST_SCRIPTS, m_lstScripts);
  32.     DDX_LBString(pDX, IDC_LIST_SCRIPTS, m_strScript);
  33.     //}}AFX_DATA_MAP
  34. }
  35.  
  36.  
  37. BEGIN_MESSAGE_MAP(CScriptDlg, CDialog)
  38.     //{{AFX_MSG_MAP(CScriptDlg)
  39.     ON_BN_CLICKED(ID_RUN, OnRun)
  40.     ON_LBN_DBLCLK(IDC_LIST_SCRIPTS, OnDblclkListScripts)
  41.     //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CScriptDlg message handlers
  46.  
  47. void CScriptDlg::OnRun() 
  48. {
  49.   UpdateData(TRUE);
  50.   EndDialog(IDOK);
  51.   RunScriptByName(m_strScript.GetBuffer(0), true);
  52. }
  53.  
  54. BOOL CScriptDlg::OnInitDialog() 
  55. {
  56.     CDialog::OnInitDialog();
  57.  
  58.   char* pBuff = new char[16384];
  59.   CString strINI = g_strAppPath;
  60.   strINI += "\\scripts.ini";
  61.   int n = GetPrivateProfileSectionNames(pBuff, 16384, strINI);
  62.  
  63.   // CStringList list;
  64.   m_lstScripts.ResetContent();
  65.   char* pWorkBuff = pBuff;
  66.   while (*pWorkBuff != NULL)
  67.   {
  68.     m_lstScripts.AddString(pWorkBuff);
  69.     pWorkBuff += strlen(pWorkBuff) + 1;
  70.   }
  71.   delete []pBuff;
  72.     return TRUE;  // return TRUE unless you set the focus to a control
  73.                   // EXCEPTION: OCX Property Pages should return FALSE
  74. }
  75.  
  76.  
  77. void CScriptDlg::OnDblclkListScripts() 
  78. {
  79.   UpdateData(TRUE);
  80.   EndDialog(IDOK);
  81.   RunScriptByName(m_strScript.GetBuffer(0), true);
  82. }
  83.