WelcomeDialog.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. // WelcomeDialog.cpp : implementation file
  19. //
  20. #include "StdAfx.H"
  21. #include "LevelEdit.H"
  22. #include "WelcomeDialog.H"
  23. #include "Utils.H"
  24. #include "FileMgr.H"
  25. #include "RegKeys.H"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // WelcomeDialogClass dialog
  33. /////////////////////////////////////////////////////////////////
  34. //
  35. // WelcomeDialogClass
  36. //
  37. WelcomeDialogClass::WelcomeDialogClass (CWnd* pParent /*=NULL*/)
  38. : m_bChangesTemp (false),
  39. m_hBMP (NULL),
  40. CDialog(WelcomeDialogClass::IDD, pParent)
  41. {
  42. //{{AFX_DATA_INIT(WelcomeDialogClass)
  43. // NOTE: the ClassWizard will add member initialization here
  44. //}}AFX_DATA_INIT
  45. return ;
  46. }
  47. /////////////////////////////////////////////////////////////////
  48. //
  49. // DoDataExchange
  50. //
  51. void
  52. WelcomeDialogClass::DoDataExchange (CDataExchange* pDX)
  53. {
  54. // Allow the base class to process this message
  55. CDialog::DoDataExchange(pDX);
  56. //{{AFX_DATA_MAP(WelcomeDialogClass)
  57. // NOTE: the ClassWizard will add DDX and DDV calls here
  58. //}}AFX_DATA_MAP
  59. return ;
  60. }
  61. BEGIN_MESSAGE_MAP(WelcomeDialogClass, CDialog)
  62. //{{AFX_MSG_MAP(WelcomeDialogClass)
  63. ON_WM_PAINT()
  64. ON_WM_DESTROY()
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////
  68. //
  69. // DoModal
  70. //
  71. int
  72. WelcomeDialogClass::DoModal (void)
  73. {
  74. int iret = IDOK;
  75. // Should this dialog be displayed?
  76. if (theApp.GetProfileInt (CONFIG_KEY, SHOW_WELCOME_VALUE, 1)) {
  77. iret = CDialog::DoModal ();
  78. }
  79. // Return the dialog exit code
  80. return iret;
  81. }
  82. /////////////////////////////////////////////////////////////////
  83. //
  84. // OnInitDialog
  85. //
  86. BOOL
  87. WelcomeDialogClass::OnInitDialog (void)
  88. {
  89. // Allow the base class to process this message
  90. CDialog::OnInitDialog ();
  91. // Check the 'yes' button by default
  92. SendDlgItemMessage (IDC_YES_RADIO, BM_SETCHECK, (WPARAM)TRUE);
  93. // Put the base path in its dialog control
  94. SetDlgItemText (IDC_ASSET_TREE_LOCATION, ::Get_File_Mgr()->Get_Base_Path ());
  95. m_hBMP = ::LoadBitmap (::AfxGetResourceHandle (), MAKEINTRESOURCE (IDB_WELCOME_BMP));
  96. if (m_hBMP != NULL) {
  97. // Determine the BMPs dimensions
  98. BITMAP bitmap = { 0 };
  99. ::GetObject (m_hBMP, sizeof (BITMAP), &bitmap);
  100. m_iWidth = bitmap.bmWidth;
  101. m_iHeight = bitmap.bmHeight;
  102. }
  103. return TRUE;
  104. }
  105. /////////////////////////////////////////////////////////////////
  106. //
  107. // OnOK
  108. //
  109. void
  110. WelcomeDialogClass::OnOK (void)
  111. {
  112. // Determine what option the user checked
  113. m_bChangesTemp = (bool)(SendDlgItemMessage (IDC_NO_RADIO, BM_GETCHECK) == 1);
  114. // Write an integer to the registry so we'll know whether to show this again or not.
  115. int ishow_again = (SendDlgItemMessage (IDC_DONT_ASK_AGAIN, BM_GETCHECK) == 0);
  116. theApp.WriteProfileInt (CONFIG_KEY, SHOW_WELCOME_VALUE, ishow_again);
  117. // Allow the base class to process this message
  118. CDialog::OnOK ();
  119. return ;
  120. }
  121. /////////////////////////////////////////////////////////////////
  122. //
  123. // OnOK
  124. //
  125. void
  126. WelcomeDialogClass::OnPaint (void)
  127. {
  128. CPaintDC dc (this);
  129. if (m_hBMP != NULL) {
  130. // Paint into the BMP window's contents
  131. HWND hwnd = ::GetDlgItem (m_hWnd, IDC_BMP);
  132. // Get the bounding rectangle so we know how much to paint
  133. RECT rect;
  134. ::GetClientRect (hwnd, &rect);
  135. // Determine the width, height, and width per each shade
  136. int width = rect.right-rect.left;
  137. int height = rect.bottom-rect.top;
  138. // Get the DCs we need to do the blitting
  139. HDC hdc = ::GetDC (hwnd);
  140. HDC hmem_dc = ::CreateCompatibleDC (NULL);
  141. HBITMAP hold_BMP = (HBITMAP)::SelectObject (hmem_dc, m_hBMP);
  142. // Paint the BMP, centered, onto screen
  143. ::BitBlt (hdc,
  144. (width >> 1) - (m_iWidth >> 1),
  145. (height >> 1) - (m_iHeight >> 1),
  146. m_iWidth,
  147. m_iHeight,
  148. hmem_dc,
  149. 0,
  150. 0,
  151. SRCCOPY);
  152. // Release the DCs
  153. ::SelectObject (hmem_dc, hold_BMP);
  154. ::ReleaseDC (hwnd, hdc);
  155. ::DeleteDC (hmem_dc);
  156. // Validate the contents of the window so the control won't paint itself
  157. ::ValidateRect (hwnd, NULL);
  158. }
  159. return ;
  160. }
  161. /////////////////////////////////////////////////////////////////
  162. //
  163. // OnDestroy
  164. //
  165. void
  166. WelcomeDialogClass::OnDestroy (void)
  167. {
  168. // Free the BMP if we need to
  169. if (m_hBMP != NULL) {
  170. ::DeleteObject (m_hBMP);
  171. m_hBMP = NULL;
  172. }
  173. // Allow the base class to process this message
  174. CDialog::OnDestroy ();
  175. return ;
  176. }