InspectorDialog.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. #include "Radiant.h"
  24. #include "GLWidget.h"
  25. #include "ConsoleDlg.h"
  26. #include "InspectorDialog.h"
  27. #include "TabsDlg.h"
  28. CInspectorDialog *g_Inspectors = NULL;
  29. // CInspectorDialog dialog
  30. void InspectorsDockingCallback ( bool docked , int ID , CWnd* wnd )
  31. {
  32. g_Inspectors->SetDockedTabs( docked , ID );
  33. }
  34. // CInspectorDialog dialog
  35. //IMPLEMENT_DYNAMIC(CInspectorDialog,CTabsDlg)
  36. CInspectorDialog::CInspectorDialog(CWnd* pParent /*=NULL*/)
  37. : CTabsDlg(CInspectorDialog::IDD, pParent)
  38. {
  39. initialized = false;
  40. dockedTabs = W_CONSOLE | W_TEXTURE | W_MEDIA;
  41. }
  42. CInspectorDialog::~CInspectorDialog()
  43. {
  44. }
  45. BEGIN_MESSAGE_MAP(CInspectorDialog, CTabsDlg)
  46. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_INSPECTOR, OnTcnSelchange )
  47. ON_WM_SIZE()
  48. ON_WM_DESTROY()
  49. ON_WM_CLOSE()
  50. END_MESSAGE_MAP()
  51. // CInspectorDialog message handlers
  52. BOOL CInspectorDialog::OnInitDialog()
  53. {
  54. CTabsDlg::OnInitDialog();
  55. ASSERT ( m_Tabs.GetSafeHwnd() );
  56. LoadWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
  57. consoleWnd.Create(IDD_DIALOG_CONSOLE, this);
  58. texWnd.Create(TEXTURE_WINDOW_CLASS, "", QE3_SPLITTER_STYLE, CRect(5, 5, 10, 10), this, 1299);
  59. mediaDlg.Create(IDD_DIALOG_TEXTURELIST, this);
  60. entityDlg.Create(IDD_DIALOG_ENTITY, this);
  61. dockedTabs = GetCvarInt ( "radiant_InspectorDockedDialogs" , W_CONSOLE | W_TEXTURE | W_MEDIA );
  62. AddDockedWindow ( &consoleWnd , W_CONSOLE , 1 , "Console" , (dockedTabs & W_CONSOLE ) != 0 , InspectorsDockingCallback );
  63. AddDockedWindow ( &texWnd , W_TEXTURE , 2 , "Textures" , (dockedTabs & W_TEXTURE ) != 0 , InspectorsDockingCallback );
  64. AddDockedWindow ( &mediaDlg , W_MEDIA , 3 , "Media" , (dockedTabs & W_MEDIA ) != 0 , InspectorsDockingCallback );
  65. AddDockedWindow ( &entityDlg , W_ENTITY , 4 , "Entity" , (dockedTabs & W_ENTITY ) != 0 , InspectorsDockingCallback );
  66. SetMode(W_CONSOLE);
  67. initialized = true;
  68. return TRUE; // return TRUE unless you set the focus to a control
  69. // EXCEPTION: OCX Property Pages should return FALSE
  70. }
  71. void CInspectorDialog::SetMode(int mode, bool updateTabs) {
  72. FocusWindow ( mode );
  73. }
  74. void CInspectorDialog::UpdateEntitySel(eclass_t *ent) {
  75. entityDlg.UpdateEntitySel(ent);
  76. }
  77. void CInspectorDialog::FillClassList() {
  78. entityDlg.AddClassNames();
  79. }
  80. void CInspectorDialog::UpdateSelectedEntity() {
  81. entityDlg.SetKeyValPairs();
  82. }
  83. bool CInspectorDialog::GetSelectAllCriteria(idStr &key, idStr &val) {
  84. CString k, v;
  85. entityDlg.editKey.GetWindowText(k);
  86. entityDlg.editVal.GetWindowText(v);
  87. key = k;
  88. val = v;
  89. return true;
  90. }
  91. void CInspectorDialog::OnSize(UINT nType, int cx, int cy)
  92. {
  93. CTabsDlg::OnSize(nType, cx, cy);
  94. DockedWindowInfo* info = NULL;
  95. POSITION pos;
  96. WORD wID;
  97. if (!initialized) {
  98. return;
  99. }
  100. CRect rect;
  101. GetClientRect(rect);
  102. CRect tabRect;
  103. m_Tabs.GetWindowRect(tabRect);
  104. // retain vert size but size 4 in from edges and 4 up from bottom
  105. tabRect.left = 4;
  106. tabRect.right = rect.Width() - 4;
  107. tabRect.top = rect.Height() - tabRect.Height() - 4;
  108. tabRect.bottom = rect.Height() - 4;
  109. // adjust rect for children size
  110. rect.bottom -= 5 + tabRect.Height();
  111. m_Tabs.SetWindowPos(NULL, tabRect.left, tabRect.top, tabRect.Width(), tabRect.Height(), 0);
  112. for( pos = m_Windows.GetStartPosition(); pos != NULL ; )
  113. {
  114. m_Windows.GetNextAssoc( pos, wID, (void*&)info );
  115. if ( (info->m_State == DockedWindowInfo::DOCKED) ) {
  116. info->m_Window->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), 0);
  117. }
  118. }
  119. }
  120. void CInspectorDialog::OnDestroy()
  121. {
  122. ::SaveWindowPlacement(GetSafeHwnd() , "radiant_InspectorsWindow" );
  123. SetCvarInt("radiant_InspectorDockedDialogs" , dockedTabs );
  124. CTabsDlg::OnDestroy();
  125. }
  126. void CInspectorDialog::OnClose()
  127. {
  128. CTabsDlg::OnClose();
  129. }
  130. BOOL CInspectorDialog::PreTranslateMessage(MSG* pMsg)
  131. {
  132. // TODO: Add your specialized code here and/or call the base class
  133. if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP) {
  134. g_pParentWnd->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
  135. }
  136. return CTabsDlg::PreTranslateMessage(pMsg);
  137. }
  138. void CInspectorDialog::SetDockedTabs ( bool docked , int ID )
  139. {
  140. if ( docked ) {
  141. dockedTabs |= ID;
  142. }
  143. else {
  144. dockedTabs &= ~ID;
  145. }
  146. }
  147. void CInspectorDialog::AssignModel ()
  148. {
  149. entityDlg.AssignModel();
  150. }