DlgConsole.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // DlgConsole.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #ifdef _DEBUG
  16. #undef new
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CDlgConsole dialog
  23. CDlgConsole::CDlgConsole(CWnd* pParent /*=NULL*/)
  24. : CDialog(CDlgConsole::IDD, pParent)
  25. {
  26. //{{AFX_DATA_INIT(CDlgConsole)
  27. m_strConsoleOutput = _T("");
  28. //}}AFX_DATA_INIT
  29. }
  30. void CDlgConsole::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CDlgConsole)
  34. DDX_Control(pDX, IDC_CONSOLE_SYMBOLS, m_ctrConsoleSymbolsCombo);
  35. DDX_Control(pDX, IDC_CONSOLE_INPUT, m_ctrlEditConsole);
  36. DDX_Text(pDX, IDC_CONSOLE_OUTPUT, m_strConsoleOutput);
  37. //}}AFX_DATA_MAP
  38. // if dialog is reciving data
  39. if( pDX->m_bSaveAndValidate == FALSE)
  40. {
  41. //m_strConsoleOutput = "Default output string";
  42. // m_strConsoleOutput = _pConsole->GetBuffer();
  43. m_ctrlEditConsole.SetTextFromConsole();
  44. }
  45. }
  46. BEGIN_MESSAGE_MAP(CDlgConsole, CDialog)
  47. //{{AFX_MSG_MAP(CDlgConsole)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CDlgConsole message handlers
  52. BOOL CDlgConsole::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. // set default console text
  56. //m_ctrlEditConsole.SetWindowText( "Default input string");
  57. m_ctrlEditConsole.SetWindowText( CString(_pGame->gam_strConsoleInputBuffer));
  58. /*
  59. // create application windows font for console
  60. LOGFONT logFont;
  61. CFont fntFont;
  62. memset(&logFont, 0, sizeof(logFont));
  63. if (!::GetSystemMetrics(SM_DBCSENABLED))
  64. {
  65. logFont.lfHeight = -11;
  66. logFont.lfWeight = FW_REGULAR;
  67. logFont.lfPitchAndFamily = FF_ROMAN|FIXED_PITCH;
  68. logFont.lfOrientation = 10;
  69. logFont.lfQuality = PROOF_QUALITY;
  70. logFont.lfItalic = TRUE;
  71. // prepare default font name
  72. CString strDefaultFont;
  73. strDefaultFont.LoadString(IDS_DEFAULT_ARIAL);
  74. lstrcpy(logFont.lfFaceName, strDefaultFont);
  75. // try to create font
  76. if( !fntFont.CreateFontIndirect(&logFont))
  77. TRACE0("Could Not create font for console\n");
  78. }
  79. else
  80. {
  81. fntFont.Attach(::GetStockObject(SYSTEM_FONT));
  82. }
  83. m_ctrlEditConsole.SetFont( &fntFont);
  84. */
  85. // fill symbols combo box
  86. m_ctrConsoleSymbolsCombo.ResetContent();
  87. // for each of symbols in the shell
  88. FOREACHINDYNAMICARRAY(_pShell->sh_assSymbols, CShellSymbol, itss)
  89. {
  90. // if it is not visible to user
  91. if (!(itss->ss_ulFlags&SSF_USER)) {
  92. // skip it
  93. continue;
  94. }
  95. // get completion name for that symbol
  96. CTString strSymbol = itss->GetCompletionString();
  97. // add string to console
  98. m_ctrConsoleSymbolsCombo.AddString( CString(strSymbol));
  99. }
  100. // select first combo member
  101. m_ctrConsoleSymbolsCombo.SetCurSel( 0);
  102. m_ctrlEditConsole.SetSel( -1, 60000);
  103. return TRUE; // return TRUE unless you set the focus to a control
  104. // EXCEPTION: OCX Property Pages should return FALSE
  105. }