WWConfigDlg.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. // WWConfigDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "wwconfig.h"
  22. #include "wwconfigdlg.h"
  23. #include "videoconfigdialog.h"
  24. #include "audioconfigdialog.h"
  25. #include "performanceconfigdialog.h"
  26. #include "locale_api.h"
  27. #include "wwconfig_ids.h"
  28. extern int GlobalExitValue;
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. ///////////////////////////////////////////////////////////////////
  35. //
  36. // CWWConfigDlg
  37. //
  38. ///////////////////////////////////////////////////////////////////
  39. CWWConfigDlg::CWWConfigDlg (CWnd *pParent)
  40. : CurrentTab (0),
  41. CDialog(CWWConfigDlg::IDD, pParent)
  42. {
  43. //{{AFX_DATA_INIT(CWWConfigDlg)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  47. return ;
  48. }
  49. ///////////////////////////////////////////////////////////////////
  50. //
  51. // DoDataExchange
  52. //
  53. ///////////////////////////////////////////////////////////////////
  54. void
  55. CWWConfigDlg::DoDataExchange (CDataExchange *pDX)
  56. {
  57. CDialog::DoDataExchange(pDX);
  58. //{{AFX_DATA_MAP(CWWConfigDlg)
  59. DDX_Control(pDX, IDC_TAB_CTRL, m_TabCtrl);
  60. //}}AFX_DATA_MAP
  61. return ;
  62. }
  63. BEGIN_MESSAGE_MAP(CWWConfigDlg, CDialog)
  64. //{{AFX_MSG_MAP(CWWConfigDlg)
  65. ON_WM_PAINT()
  66. ON_WM_QUERYDRAGICON()
  67. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_CTRL, OnSelchangeTabCtrl)
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. ///////////////////////////////////////////////////////////////////
  71. //
  72. // OnInitDialog
  73. //
  74. // Modified: 12/06/2001 by MML - Retrieving strings from Locomoto file.
  75. ///////////////////////////////////////////////////////////////////
  76. BOOL
  77. CWWConfigDlg::OnInitDialog (void)
  78. {
  79. char string[ _MAX_PATH ];
  80. CDialog::OnInitDialog();
  81. // Set the icon for this dialog. The framework does this automatically
  82. // when the application's main window is not a dialog
  83. SetIcon (m_hIcon, TRUE);
  84. SetIcon (m_hIcon, FALSE);
  85. //
  86. // Set Title of Dialog.
  87. //
  88. Locale_GetString( IDS_WWCONFIG_TITLE, string );
  89. SetWindowText((LPCTSTR) string );
  90. //
  91. // Set text on buttons.
  92. //
  93. Locale_GetString( IDS_OK, string );
  94. SetDlgItemText( IDOK, string );
  95. Locale_GetString( IDS_CANCEL, string );
  96. SetDlgItemText( IDCANCEL, string );
  97. //
  98. // Add a tab to the dialog for video configuration
  99. //
  100. TC_ITEM tab_info = { 0 };
  101. Locale_GetString( IDS_VIDEO_TAB, string );
  102. tab_info.mask = TCIF_TEXT;
  103. // tab_info.pszText = "Video";
  104. tab_info.pszText = string;
  105. m_TabCtrl.InsertItem (0xFF, &tab_info);
  106. //
  107. // Add a tab to the dialog for audio configuration
  108. //
  109. Locale_GetString( IDS_SOUND_TAB, string );
  110. tab_info.mask = TCIF_TEXT;
  111. // tab_info.pszText = "Sound";
  112. tab_info.pszText = string;
  113. m_TabCtrl.InsertItem (0xFF, &tab_info);
  114. //
  115. // Add a tab to the dialog for performance configuration
  116. //
  117. Locale_GetString( IDS_PERFORMANCE_TAB, string );
  118. tab_info.mask = TCIF_TEXT;
  119. // tab_info.pszText = "Performance";
  120. tab_info.pszText = string;
  121. m_TabCtrl.InsertItem (0xFF, &tab_info);
  122. //
  123. // Get the display rectangle of the tab control
  124. //
  125. CRect tab_rect;
  126. m_TabCtrl.GetWindowRect (&tab_rect);
  127. m_TabCtrl.AdjustRect (FALSE, &tab_rect);
  128. ScreenToClient (&tab_rect);
  129. VideoConfigDialogClass *video_page = new VideoConfigDialogClass (this);
  130. AudioConfigDialogClass *audio_page = new AudioConfigDialogClass (this);
  131. PerformanceConfigDialogClass *performance_page = new PerformanceConfigDialogClass (this);
  132. video_page->SetWindowPos ( NULL, tab_rect.left, tab_rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  133. audio_page->SetWindowPos ( NULL, tab_rect.left, tab_rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  134. performance_page->SetWindowPos ( NULL, tab_rect.left, tab_rect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
  135. ConfigPages.Add ( video_page );
  136. ConfigPages.Add ( audio_page );
  137. ConfigPages.Add ( performance_page );
  138. //
  139. // Display the first category page
  140. //
  141. ConfigPages[0]->ShowWindow( SW_SHOW );
  142. return TRUE;
  143. }
  144. ///////////////////////////////////////////////////////////////////
  145. //
  146. // OnPaint
  147. //
  148. ///////////////////////////////////////////////////////////////////
  149. void
  150. CWWConfigDlg::OnPaint (void)
  151. {
  152. if (IsIconic())
  153. {
  154. CPaintDC dc(this);
  155. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  156. // Center icon in client rectangle
  157. int cxIcon = GetSystemMetrics(SM_CXICON);
  158. int cyIcon = GetSystemMetrics(SM_CYICON);
  159. CRect rect;
  160. GetClientRect(&rect);
  161. int x = (rect.Width() - cxIcon + 1) / 2;
  162. int y = (rect.Height() - cyIcon + 1) / 2;
  163. // Draw the icon
  164. dc.DrawIcon(x, y, m_hIcon);
  165. }
  166. else
  167. {
  168. CDialog::OnPaint();
  169. }
  170. return ;
  171. }
  172. ///////////////////////////////////////////////////////////////////
  173. //
  174. // OnQueryDragIcon
  175. //
  176. ///////////////////////////////////////////////////////////////////
  177. HCURSOR
  178. CWWConfigDlg::OnQueryDragIcon (void)
  179. {
  180. return (HCURSOR) m_hIcon;
  181. }
  182. ///////////////////////////////////////////////////////////////////
  183. //
  184. // OnOK
  185. //
  186. ///////////////////////////////////////////////////////////////////
  187. void
  188. CWWConfigDlg::OnOK (void)
  189. {
  190. GlobalExitValue=0;
  191. //
  192. // Loop over each page and ask them to save themselves
  193. //
  194. for (int index = 0; index < ConfigPages.Count (); index ++) {
  195. ConfigPages[index]->SendMessage (WM_USER + 101);
  196. }
  197. CDialog::OnOK ();
  198. return ;
  199. }
  200. ///////////////////////////////////////////////////////////////////
  201. //
  202. // OnSelchangeTabCtrl
  203. //
  204. ///////////////////////////////////////////////////////////////////
  205. void
  206. CWWConfigDlg::OnSelchangeTabCtrl
  207. (
  208. NMHDR * pNMHDR,
  209. LRESULT * pResult
  210. )
  211. {
  212. (*pResult) = 0;
  213. //
  214. // Check to see if the user has selected a new tab
  215. //
  216. int newtab = m_TabCtrl.GetCurSel ();
  217. if (CurrentTab != newtab) {
  218. //
  219. // Hide the old tab
  220. //
  221. if (CurrentTab < ConfigPages.Count () && ConfigPages[CurrentTab] != NULL) {
  222. ConfigPages[CurrentTab]->ShowWindow (SW_HIDE);
  223. }
  224. //
  225. // Show the new tab
  226. //
  227. if (ConfigPages[newtab] != NULL) {
  228. ConfigPages[newtab]->ShowWindow (SW_SHOW);
  229. }
  230. //
  231. // Remember what our new current tab is
  232. //
  233. CurrentTab = newtab;
  234. }
  235. return ;
  236. }
  237. void CWWConfigDlg::OnCancel()
  238. {
  239. // TODO: Add extra cleanup here
  240. GlobalExitValue=1;
  241. CDialog::OnCancel();
  242. }