CheckinStyleDialog.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. // CheckinStyleDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "CheckinStyleDialog.h"
  23. #include "RegKeys.H"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. //
  31. // Constants
  32. //
  33. const TCHAR * const REG_NOT_CACHED = TEXT ("NotCached");
  34. const TCHAR * const REG_NOW = TEXT ("Now");
  35. const TCHAR * const REG_LATER = TEXT ("Later");
  36. /////////////////////////////////////////////////////////////////////////////
  37. //
  38. // CheckinStyleDialogClass
  39. //
  40. CheckinStyleDialogClass::CheckinStyleDialogClass(CWnd* pParent /*=NULL*/)
  41. : CDialog(CheckinStyleDialogClass::IDD, pParent)
  42. {
  43. //{{AFX_DATA_INIT(CheckinStyleDialogClass)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. }
  47. void CheckinStyleDialogClass::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CDialog::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CheckinStyleDialogClass)
  51. // NOTE: the ClassWizard will add DDX and DDV calls here
  52. //}}AFX_DATA_MAP
  53. }
  54. BEGIN_MESSAGE_MAP(CheckinStyleDialogClass, CDialog)
  55. //{{AFX_MSG_MAP(CheckinStyleDialogClass)
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CheckinStyleDialogClass message handlers
  60. /////////////////////////////////////////////////////////////////////////////
  61. //
  62. // OnOK
  63. //
  64. void
  65. CheckinStyleDialogClass::OnOK (void)
  66. {
  67. UINT ret_code = IDC_UPDATE_NOW;
  68. CString cache_value = REG_NOW;
  69. if (SendDlgItemMessage (IDC_UPDATE_LATER, BM_GETCHECK) == 1) {
  70. ret_code = IDC_UPDATE_LATER;
  71. cache_value = REG_LATER;
  72. }
  73. // Cache the value in the registry if necessary
  74. if (SendDlgItemMessage (IDC_DONT_ASK_ME_AGAIN, BM_GETCHECK) == 1) {
  75. theApp.WriteProfileString (CONFIG_KEY, CHECKIN_STYLE_VALUE, cache_value);
  76. }
  77. // Close the dialog with the appropriate control ID
  78. EndDialog (ret_code);
  79. return ;
  80. }
  81. /////////////////////////////////////////////////////////////////////////////
  82. //
  83. // OnCommand
  84. //
  85. BOOL
  86. CheckinStyleDialogClass::OnCommand
  87. (
  88. WPARAM wParam,
  89. LPARAM lParam
  90. )
  91. {
  92. // Don't allow the user to cancel out of this dialog
  93. if (LOWORD (wParam) == IDCANCEL) {
  94. return FALSE;
  95. }
  96. // Allow the base class to process this message
  97. return CDialog::OnCommand (wParam, lParam);
  98. }
  99. /////////////////////////////////////////////////////////////////////////////
  100. //
  101. // DoModal
  102. //
  103. int
  104. CheckinStyleDialogClass::DoModal (void)
  105. {
  106. UINT ret_code = IDC_UPDATE_NOW;
  107. // Get the cached 'checkin' style if possible
  108. CString checkin_style = theApp.GetProfileString (CONFIG_KEY, CHECKIN_STYLE_VALUE, REG_NOT_CACHED);
  109. if (checkin_style.CompareNoCase (REG_NOT_CACHED) == 0) {
  110. // Allow the base class to show the dialog
  111. ret_code = CDialog::DoModal ();
  112. } else {
  113. if (checkin_style.CompareNoCase (REG_LATER) == 0) {
  114. ret_code = IDC_UPDATE_LATER;
  115. }
  116. }
  117. // Return the dialog control's ID
  118. return ret_code;
  119. }
  120. /////////////////////////////////////////////////////////////////////////////
  121. //
  122. // OnInitDialog
  123. //
  124. BOOL
  125. CheckinStyleDialogClass::OnInitDialog (void)
  126. {
  127. // Allow the base class to process this message
  128. CDialog::OnInitDialog ();
  129. // Check 'update now' by default
  130. SendDlgItemMessage (IDC_UPDATE_NOW, BM_SETCHECK, (WPARAM)TRUE);
  131. return TRUE;
  132. }