Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

CommandsDlg.cpp (3260B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 GNU General Public License for more details.
     16 
     17 You should have received a copy of the GNU General Public License
     18 along with Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 // CommandsDlg.cpp : implementation file
     23 //
     24 
     25 #include "stdafx.h"
     26 #include "Radiant.h"
     27 #include "CommandsDlg.h"
     28 #include "MainFrm.h"
     29 
     30 #ifdef _DEBUG
     31 #define new DEBUG_NEW
     32 #undef THIS_FILE
     33 static char THIS_FILE[] = __FILE__;
     34 #endif
     35 
     36 /////////////////////////////////////////////////////////////////////////////
     37 // CCommandsDlg dialog
     38 
     39 
     40 CCommandsDlg::CCommandsDlg(CWnd* pParent /*=NULL*/)
     41 	: CDialog(CCommandsDlg::IDD, pParent)
     42 {
     43 	//{{AFX_DATA_INIT(CCommandsDlg)
     44 		// NOTE: the ClassWizard will add member initialization here
     45 	//}}AFX_DATA_INIT
     46 }
     47 
     48 
     49 void CCommandsDlg::DoDataExchange(CDataExchange* pDX)
     50 {
     51 	CDialog::DoDataExchange(pDX);
     52 	//{{AFX_DATA_MAP(CCommandsDlg)
     53 	DDX_Control(pDX, IDC_LIST_COMMANDS, m_lstCommands);
     54 	//}}AFX_DATA_MAP
     55 }
     56 
     57 
     58 BEGIN_MESSAGE_MAP(CCommandsDlg, CDialog)
     59 	//{{AFX_MSG_MAP(CCommandsDlg)
     60 	//}}AFX_MSG_MAP
     61 END_MESSAGE_MAP()
     62 
     63 /////////////////////////////////////////////////////////////////////////////
     64 // CCommandsDlg message handlers
     65 
     66 BOOL CCommandsDlg::OnInitDialog() 
     67 {
     68 	CDialog::OnInitDialog();
     69   m_lstCommands.SetTabStops(96);
     70   int nCount = g_nCommandCount;
     71 
     72   CFile fileout;
     73   fileout.Open("c:/commandlist.txt", CFile::modeCreate | CFile::modeWrite);
     74   for (int n = 0; n < nCount; n++)
     75   {
     76     CString strLine;
     77     char c = g_Commands[n].m_nKey;
     78     CString strKeys = c;
     79     for (int k = 0; k < g_nKeyCount; k++)
     80     {
     81       if (g_Keys[k].m_nVKKey == g_Commands[n].m_nKey)
     82       {
     83         strKeys = g_Keys[k].m_strName;
     84         break;
     85       }
     86     }
     87     CString strMod("");
     88     if (g_Commands[n].m_nModifiers & RAD_SHIFT)
     89       strMod = "Shift";
     90     if (g_Commands[n].m_nModifiers & RAD_ALT)
     91       strMod += (strMod.GetLength() > 0) ? " + Alt" : "Alt";
     92     if (g_Commands[n].m_nModifiers & RAD_CONTROL)
     93       strMod += (strMod.GetLength() > 0) ? " + Control" : "Control";
     94     if (strMod.GetLength() > 0)
     95     {
     96       strMod += " + ";
     97     }
     98     strLine.Format("%s \t%s%s", g_Commands[n].m_strCommand, strMod, strKeys);
     99     m_lstCommands.AddString(strLine);
    100 
    101     strLine.Format("%s \t\t\t%s%s", g_Commands[n].m_strCommand, strMod, strKeys);
    102 
    103     fileout.Write(strLine, strLine.GetLength());
    104     fileout.Write("\r\n", 2);
    105   }
    106 	fileout.Close();
    107 	return TRUE;  // return TRUE unless you set the focus to a control
    108 	              // EXCEPTION: OCX Property Pages should return FALSE
    109 }