PresetSettingsTab.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. // PresetSettingsTab.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "presetsettingstab.h"
  23. #include "definition.h"
  24. #include "preset.h"
  25. #include "specsheet.h"
  26. #include "utils.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. //
  34. // PresetSettingsTabClass
  35. //
  36. /////////////////////////////////////////////////////////////////////////////
  37. PresetSettingsTabClass::PresetSettingsTabClass (PresetClass *preset)
  38. : m_Preset (preset),
  39. m_ParamSheet (NULL),
  40. m_IsReadOnly (false),
  41. DockableFormClass (PresetSettingsTabClass::IDD)
  42. {
  43. //{{AFX_DATA_INIT(PresetSettingsTabClass)
  44. // NOTE: the ClassWizard will add member initialization here
  45. //}}AFX_DATA_INIT
  46. return ;
  47. }
  48. /////////////////////////////////////////////////////////////////////////////
  49. //
  50. // ~PresetSettingsTabClass
  51. //
  52. /////////////////////////////////////////////////////////////////////////////
  53. PresetSettingsTabClass::~PresetSettingsTabClass (void)
  54. {
  55. SAFE_DELETE (m_ParamSheet);
  56. return ;
  57. }
  58. /////////////////////////////////////////////////////////////////////////////
  59. //
  60. // PresetSettingsTabClass
  61. //
  62. /////////////////////////////////////////////////////////////////////////////
  63. void
  64. PresetSettingsTabClass::DoDataExchange (CDataExchange *pDX)
  65. {
  66. DockableFormClass::DoDataExchange(pDX);
  67. //{{AFX_DATA_MAP(PresetSettingsTabClass)
  68. // NOTE: the ClassWizard will add DDX and DDV calls here
  69. //}}AFX_DATA_MAP
  70. return ;
  71. }
  72. BEGIN_MESSAGE_MAP(PresetSettingsTabClass, DockableFormClass)
  73. //{{AFX_MSG_MAP(PresetSettingsTabClass)
  74. ON_WM_SIZE()
  75. //}}AFX_MSG_MAP
  76. END_MESSAGE_MAP()
  77. /////////////////////////////////////////////////////////////////////////////
  78. // PresetSettingsTabClass diagnostics
  79. #ifdef _DEBUG
  80. void PresetSettingsTabClass::AssertValid() const
  81. {
  82. DockableFormClass::AssertValid();
  83. }
  84. void PresetSettingsTabClass::Dump(CDumpContext& dc) const
  85. {
  86. DockableFormClass::Dump(dc);
  87. }
  88. #endif //_DEBUG
  89. /////////////////////////////////////////////////////////////////////////////
  90. //
  91. // HandleInitDialog
  92. //
  93. /////////////////////////////////////////////////////////////////////////////
  94. void
  95. PresetSettingsTabClass::HandleInitDialog (void)
  96. {
  97. ASSERT (m_Preset != NULL);
  98. DefinitionClass *definition = m_Preset->Get_Definition ();
  99. if (definition != NULL) {
  100. //
  101. // Create a scrollable dialog that contains all the
  102. // definition's parameters.
  103. //
  104. CRect rect;
  105. GetClientRect (&rect);
  106. m_ParamSheet = new SpecSheetClass (definition);
  107. m_ParamSheet->Set_Is_Temp (m_Preset->Get_IsTemporary ());
  108. m_ParamSheet->Set_Read_Only (m_IsReadOnly);
  109. m_ParamSheet->Create ("static", "", WS_CHILD | WS_VISIBLE, rect, this, 101);
  110. }
  111. return ;
  112. }
  113. /////////////////////////////////////////////////////////////////////////////
  114. //
  115. // Apply_Changes
  116. //
  117. /////////////////////////////////////////////////////////////////////////////
  118. bool
  119. PresetSettingsTabClass::Apply_Changes (void)
  120. {
  121. // Assume success
  122. bool retval = true;
  123. DefinitionClass *definition = m_Preset->Get_Definition ();
  124. if (definition != NULL) {
  125. }
  126. m_ParamSheet->Apply ();
  127. // Return true to allow the dialog to close
  128. return retval;
  129. }
  130. /////////////////////////////////////////////////////////////////////////////
  131. //
  132. // OnSize
  133. //
  134. /////////////////////////////////////////////////////////////////////////////
  135. void
  136. PresetSettingsTabClass::OnSize (UINT nType, int cx, int cy)
  137. {
  138. if ((m_ParamSheet != NULL) && (cx > 0) && (cy > 0)) {
  139. m_ParamSheet->SetWindowPos (NULL, 10, 5, cx-20, cy-10, SWP_NOZORDER);
  140. }
  141. DockableFormClass::OnSize (nType, cx, cy);
  142. return ;
  143. }