SoundSettingsPage.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/SoundSettingsPage.cpp $Modtime:: $*
  25. * *
  26. * $Revision:: 5 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #include "stdafx.h"
  32. #include "leveledit.h"
  33. #include "soundsettingspage.h"
  34. #include "utils.h"
  35. #include "filemgr.h"
  36. #include "audiblesound.h"
  37. #ifdef _DEBUG
  38. #define new DEBUG_NEW
  39. #undef THIS_FILE
  40. static char THIS_FILE[] = __FILE__;
  41. #endif
  42. /////////////////////////////////////////////////////////////////////////////
  43. //
  44. // SoundSettingsPageClass
  45. //
  46. SoundSettingsPageClass::SoundSettingsPageClass (void) :
  47. Definition (NULL),
  48. DockableFormClass (SoundSettingsPageClass::IDD)
  49. {
  50. return ;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. //
  54. // ~SoundSettingsPageClass
  55. //
  56. /////////////////////////////////////////////////////////////////////////////
  57. SoundSettingsPageClass::~SoundSettingsPageClass (void)
  58. {
  59. return;
  60. }
  61. /////////////////////////////////////////////////////////////////////////////
  62. //
  63. // DoDataExchange
  64. //
  65. /////////////////////////////////////////////////////////////////////////////
  66. void
  67. SoundSettingsPageClass::DoDataExchange (CDataExchange* pDX)
  68. {
  69. DockableFormClass::DoDataExchange(pDX);
  70. //{{AFX_DATA_MAP(SoundSettingsPageClass)
  71. DDX_Control(pDX, IDC_VOLUME_SLIDER, m_VolumeSlider);
  72. //}}AFX_DATA_MAP
  73. return ;
  74. }
  75. BEGIN_MESSAGE_MAP(SoundSettingsPageClass, DockableFormClass)
  76. //{{AFX_MSG_MAP(SoundSettingsPageClass)
  77. ON_WM_HSCROLL()
  78. ON_EN_CHANGE(IDC_VOLUME_EDIT, OnChangeVolumeEdit)
  79. //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // SoundSettingsPageClass diagnostics
  83. #ifdef _DEBUG
  84. void SoundSettingsPageClass::AssertValid() const
  85. {
  86. DockableFormClass::AssertValid();
  87. }
  88. void SoundSettingsPageClass::Dump(CDumpContext& dc) const
  89. {
  90. DockableFormClass::Dump(dc);
  91. }
  92. #endif //_DEBUG
  93. /////////////////////////////////////////////////////////////////////////////
  94. //
  95. // HandleInitDialog
  96. //
  97. /////////////////////////////////////////////////////////////////////////////
  98. void
  99. SoundSettingsPageClass::HandleInitDialog (void)
  100. {
  101. ASSERT (Definition != NULL);
  102. //
  103. // Set up the volume controls
  104. //
  105. m_VolumeSlider.SetRange (0, 100);
  106. m_VolumeSlider.SetPos (int(Definition->Get_Volume () * 100.0F));
  107. ::SetDlgItemFloat (m_hWnd, IDC_VOLUME_EDIT, (Definition->Get_Volume () * 100.0F));
  108. //
  109. // Put the attenuation factors into the edit fields
  110. //
  111. ::SetDlgItemFloat (m_hWnd, IDC_DROP_OFF_EDIT, Definition->Get_DropOff_Radius ());
  112. ::SetDlgItemFloat (m_hWnd, IDC_MAX_VOL_EDIT, Definition->Get_Max_Vol_Radius ());
  113. //
  114. // Put the start offset into the edit field
  115. //
  116. ::SetDlgItemFloat (m_hWnd, IDC_START_OFFSET_EDIT, Definition->Get_Start_Offset ());
  117. //
  118. // Put the pitch factor into the edit field
  119. //
  120. ::SetDlgItemFloat (m_hWnd, IDC_PITCH_FACTOR_EDIT, Definition->Get_Pitch_Factor ());
  121. return ;
  122. }
  123. /////////////////////////////////////////////////////////////////////////////
  124. //
  125. // Apply_Changes
  126. //
  127. /////////////////////////////////////////////////////////////////////////////
  128. bool
  129. SoundSettingsPageClass::Apply_Changes (void)
  130. {
  131. //
  132. // Read the volume settings
  133. //
  134. float volume = ::GetDlgItemFloat (m_hWnd, IDC_VOLUME_EDIT);
  135. Definition->Set_Volume (volume / 100.0F);
  136. //
  137. // Read the attenuation factors
  138. //
  139. float dropoff = ::GetDlgItemFloat (m_hWnd, IDC_DROP_OFF_EDIT);
  140. float maxvol = ::GetDlgItemFloat (m_hWnd, IDC_MAX_VOL_EDIT);
  141. Definition->Set_DropOff_Radius (dropoff);
  142. Definition->Set_Max_Vol_Radius (maxvol);
  143. //
  144. // Read the start offset
  145. //
  146. float offset = ::GetDlgItemFloat (m_hWnd, IDC_START_OFFSET_EDIT);
  147. Definition->Set_Start_Offset (offset);
  148. //
  149. // Read the pitch factor
  150. //
  151. float factor = ::GetDlgItemFloat (m_hWnd, IDC_PITCH_FACTOR_EDIT);
  152. Definition->Set_Pitch_Factor (factor);
  153. return true;
  154. }
  155. /////////////////////////////////////////////////////////////////////////////
  156. //
  157. // Discard_Changes
  158. //
  159. /////////////////////////////////////////////////////////////////////////////
  160. void
  161. SoundSettingsPageClass::Discard_Changes (void)
  162. {
  163. return ;
  164. }
  165. /////////////////////////////////////////////////////////////////////////////
  166. //
  167. // OnHScroll
  168. //
  169. /////////////////////////////////////////////////////////////////////////////
  170. void
  171. SoundSettingsPageClass::OnHScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
  172. {
  173. //
  174. // Update the edit control
  175. //
  176. ::SetDlgItemFloat (m_hWnd, IDC_VOLUME_EDIT, m_VolumeSlider.GetPos ());
  177. DockableFormClass::OnHScroll (nSBCode, nPos, pScrollBar);
  178. return ;
  179. }
  180. /////////////////////////////////////////////////////////////////////////////
  181. //
  182. // OnChangeVolumeEdit
  183. //
  184. /////////////////////////////////////////////////////////////////////////////
  185. void
  186. SoundSettingsPageClass::OnChangeVolumeEdit (void)
  187. {
  188. //
  189. // Update the edit control
  190. //
  191. float volume = ::GetDlgItemFloat (m_hWnd, IDC_VOLUME_EDIT);
  192. volume = WWMath::Clamp (volume, 0, 100.0F);
  193. m_VolumeSlider.SetPos (volume);
  194. return ;
  195. }