MainDialogBar.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program 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. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // MainDialogBar.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "maindialogbar.h"
  23. #include "presetslibform.h"
  24. #include "utils.h"
  25. #include "instancespage.h"
  26. #include "overlappage.h"
  27. #include "conversationpage.h"
  28. #include "mainfrm.h"
  29. #include "heightfieldpage.h"
  30. #ifdef _DEBUG
  31. #define new DEBUG_NEW
  32. #undef THIS_FILE
  33. static char THIS_FILE[] = __FILE__;
  34. #endif
  35. /////////////////////////////////////////////////////////////////////////////
  36. //
  37. // MainDialogBarClass dialog
  38. //
  39. /////////////////////////////////////////////////////////////////////////////
  40. MainDialogBarClass::MainDialogBarClass (void)
  41. : m_iCurrentTab (0)
  42. {
  43. //{{AFX_DATA_INIT(MainDialogBarClass)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. ::memset (m_pTabs, 0, sizeof (m_pTabs));
  47. return ;
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. //
  51. // ~MainDialogBarClass
  52. //
  53. /////////////////////////////////////////////////////////////////////////////
  54. MainDialogBarClass::~MainDialogBarClass (void)
  55. {
  56. for (int index = 0; index < TAB_COUNT; index ++) {
  57. SAFE_DELETE (m_pTabs[index]);
  58. }
  59. return ;
  60. }
  61. void
  62. MainDialogBarClass::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CDialogBar::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(MainDialogBarClass)
  66. DDX_Control(pDX, IDC_LIBRARY_TAB, m_TabCtrl);
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(MainDialogBarClass, CDialogBar)
  70. //{{AFX_MSG_MAP(MainDialogBarClass)
  71. ON_WM_SIZE()
  72. ON_NOTIFY(TCN_SELCHANGE, IDC_LIBRARY_TAB, OnSelchangeLibraryTab)
  73. //}}AFX_MSG_MAP
  74. END_MESSAGE_MAP()
  75. /////////////////////////////////////////////////////////////////////////////
  76. //
  77. // MainDialogBarClass message handlers
  78. //
  79. /////////////////////////////////////////////////////////////////////////////
  80. BOOL
  81. MainDialogBarClass::OnInitDialog (void)
  82. {
  83. return TRUE;
  84. }
  85. /////////////////////////////////////////////////////////////////////////////
  86. //
  87. // OnSize
  88. //
  89. /////////////////////////////////////////////////////////////////////////////
  90. void
  91. MainDialogBarClass::OnSize
  92. (
  93. UINT nType,
  94. int cx,
  95. int cy
  96. )
  97. {
  98. CDialogBar::OnSize (nType, cx, cy);
  99. if (::IsWindow (m_TabCtrl) && (cx > 0) && (cy > 0)) {
  100. //CRect client_rect;
  101. //GetClientRect (&client_rect);
  102. // Resize the tab control to fill the entire contents of the client area
  103. m_TabCtrl.SetWindowPos (NULL, 0, 3, cx, cy - 6, SWP_NOZORDER);
  104. // Get the display rectangle of the tab control
  105. CRect rect;
  106. m_TabCtrl.GetWindowRect (&rect);
  107. m_TabCtrl.AdjustRect (FALSE, &rect);
  108. // Convert the display rectangle from screen to client coords
  109. ScreenToClient (&rect);
  110. //
  111. // Loop through all the tabs in the library
  112. //
  113. for (int tab = 0; tab < TAB_COUNT; tab ++) {
  114. if (m_pTabs[tab] != NULL) {
  115. //
  116. // Resize this tab
  117. //
  118. m_pTabs[tab]->SetWindowPos (NULL, rect.left, rect.top,
  119. rect.Width (), rect.Height (), SWP_NOZORDER);
  120. }
  121. }
  122. }
  123. return ;
  124. }
  125. /////////////////////////////////////////////////////////////////////////////
  126. //
  127. // OnSelchangeLibraryTab
  128. //
  129. /////////////////////////////////////////////////////////////////////////////
  130. void
  131. MainDialogBarClass::OnSelchangeLibraryTab
  132. (
  133. NMHDR* pNMHDR,
  134. LRESULT* pResult
  135. )
  136. {
  137. // Which tab is selected?
  138. int newtab = m_TabCtrl.GetCurSel ();
  139. // Is this a new tab?
  140. if (m_iCurrentTab != newtab) {
  141. // Is the old tab valid?
  142. if (m_pTabs[m_iCurrentTab] != NULL) {
  143. // Hide the contents of the old tab
  144. m_pTabs[m_iCurrentTab]->ShowWindow (SW_HIDE);
  145. }
  146. // Is the new tab valid?
  147. if (m_pTabs[newtab] != NULL) {
  148. // Show the contents of the new tab
  149. m_pTabs[newtab]->ShowWindow (SW_SHOW);
  150. }
  151. // Remember what our new current tab is
  152. m_iCurrentTab = newtab;
  153. }
  154. (*pResult) = 0;
  155. return ;
  156. }
  157. /////////////////////////////////////////////////////////////////////////////
  158. //
  159. // Initialize
  160. //
  161. /////////////////////////////////////////////////////////////////////////////
  162. void
  163. MainDialogBarClass::Initialize (void)
  164. {
  165. UpdateData (FALSE);
  166. TC_ITEM tab_info = { 0 };
  167. tab_info.mask = TCIF_TEXT;
  168. tab_info.pszText = "Presets";
  169. m_TabCtrl.InsertItem (TAB_GLOBAL, &tab_info);
  170. tab_info.mask = TCIF_TEXT;
  171. tab_info.pszText = "Instances";
  172. m_TabCtrl.InsertItem (TAB_INSTANCES, &tab_info);
  173. tab_info.mask = TCIF_TEXT;
  174. tab_info.pszText = "Conversations";
  175. m_TabCtrl.InsertItem (TAB_CONVERSATION, &tab_info);
  176. tab_info.mask = TCIF_TEXT;
  177. tab_info.pszText = "Overlap";
  178. m_TabCtrl.InsertItem (TAB_OVERLAP, &tab_info);
  179. //
  180. // Create the form's to add to the different tabs
  181. //
  182. m_pTabs[TAB_GLOBAL] = new PresetsFormClass (this);
  183. m_pTabs[TAB_INSTANCES] = new InstancesPageClass (this);
  184. m_pTabs[TAB_CONVERSATION] = new ConversationPageClass (this);
  185. m_pTabs[TAB_OVERLAP] = new OverlapPageClass (this);
  186. //#ifndef PUBLIC_EDITOR_VER (gth) go ahead and give the heightfield away!
  187. //
  188. // Install the heightfield tab
  189. //
  190. tab_info.mask = TCIF_TEXT;
  191. tab_info.pszText = "Heightfield";
  192. m_TabCtrl.InsertItem (TAB_HEIGHTFIELD, &tab_info);
  193. m_pTabs[TAB_HEIGHTFIELD] = new HeightfieldPageClass (this);
  194. //#endif //PUBLIC_EDITOR_VER
  195. //
  196. // Loop through and create the tabs
  197. //
  198. for (int index = 0; index < TAB_COUNT; index ++) {
  199. if (m_pTabs[index] != NULL) {
  200. m_pTabs[index]->ShowWindow ((index == 0) ? SW_SHOW : SW_HIDE);
  201. }
  202. }
  203. return ;
  204. }
  205. BOOL MainDialogBarClass::PreTranslateMessage(MSG* pMsg)
  206. {
  207. // TODO: Add your specialized code here and/or call the base class
  208. /*CMainFrame *main_wnd = (CMainFrame *)::AfxGetMainWnd ();
  209. if (main_wnd != NULL) {
  210. HACCEL accel_table = main_wnd->GetDefaultAccelerator ();
  211. if (::TranslateAccelerator (main_wnd->m_hWnd, accel_table, pMsg)) {
  212. return 1;
  213. }
  214. }*/
  215. return CDialogBar::PreTranslateMessage(pMsg);
  216. }