AnimationSpeed.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. // AnimationSpeed.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "W3DView.h"
  22. #include "AnimationSpeed.h"
  23. #include "MainFrm.H"
  24. #include "GraphicView.H"
  25. #include "Utils.H"
  26. #include "W3DViewDoc.H"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. //extern bool CompressQ;
  33. //extern int QnBytes;
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CAnimationSpeed dialog
  36. //////////////////////////////////////////////////////////////
  37. //
  38. // CAnimationSpeed
  39. //
  40. CAnimationSpeed::CAnimationSpeed (CWnd* pParent)
  41. : m_iInitialPercent (0),
  42. CDialog(CAnimationSpeed::IDD, pParent)
  43. {
  44. //{{AFX_DATA_INIT(CAnimationSpeed)
  45. // NOTE: the ClassWizard will add member initialization here
  46. //}}AFX_DATA_INIT
  47. return ;
  48. }
  49. //////////////////////////////////////////////////////////////
  50. //
  51. // DoDataExchange
  52. //
  53. void
  54. CAnimationSpeed::DoDataExchange (CDataExchange* pDX)
  55. {
  56. CDialog::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CAnimationSpeed)
  58. DDX_Control(pDX, IDC_SPEED_SLIDER, m_speedSlider);
  59. //}}AFX_DATA_MAP
  60. return ;
  61. }
  62. BEGIN_MESSAGE_MAP(CAnimationSpeed, CDialog)
  63. //{{AFX_MSG_MAP(CAnimationSpeed)
  64. ON_WM_HSCROLL()
  65. ON_WM_DESTROY()
  66. ON_BN_CLICKED(IDC_BLEND, OnBlend)
  67. ON_BN_CLICKED(IDC_COMPRESSQ, OnCompressq)
  68. ON_BN_CLICKED(IDC_16BIT, On16bit)
  69. ON_BN_CLICKED(IDC_8BIT, On8bit)
  70. //}}AFX_MSG_MAP
  71. END_MESSAGE_MAP()
  72. //////////////////////////////////////////////////////////////
  73. //
  74. // OnInitDialog
  75. //
  76. BOOL
  77. CAnimationSpeed::OnInitDialog (void)
  78. {
  79. // Allow the base class to process this message
  80. CDialog::OnInitDialog ();
  81. // Center the dialog around the data tree view instead
  82. // of the direct center of the screen
  83. ::CenterDialogAroundTreeView (m_hWnd);
  84. // Get a pointer to the doc so we can get at the current scene
  85. // pointer.
  86. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  87. if (pCDoc)
  88. {
  89. SendDlgItemMessage (IDC_BLEND, BM_SETCHECK, (WPARAM)pCDoc->GetAnimationBlend ());
  90. CheckDlgButton(IDC_COMPRESSQ, pCDoc->GetChannelQCompression());
  91. CheckRadioButton(IDC_16BIT, IDC_8BIT, IDC_16BIT+2);//-pCDoc->GetChannelQnBytes());
  92. if(pCDoc->GetChannelQCompression()){
  93. GetDlgItem(IDC_16BIT)->EnableWindow(TRUE);
  94. GetDlgItem(IDC_8BIT)->EnableWindow(TRUE);
  95. }else{
  96. GetDlgItem(IDC_16BIT)->EnableWindow(FALSE);
  97. GetDlgItem(IDC_8BIT)->EnableWindow(FALSE);
  98. }
  99. }
  100. // Get a pointer to the main window
  101. CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd ();
  102. if (pCMainWnd)
  103. {
  104. // Get a pointer to the graphic view pane
  105. CGraphicView *pCGraphicView = (CGraphicView *)pCMainWnd->GetPane (0, 1);
  106. if (pCGraphicView)
  107. {
  108. // Determine the current display speed
  109. float animationSpeed = pCGraphicView->GetAnimationSpeed ();
  110. // Convert the current display speed to a percentage
  111. m_iInitialPercent = int(animationSpeed*100.00F);
  112. }
  113. }
  114. // Set the range of the slider control
  115. m_speedSlider.SetRange (1, 200);
  116. // Set the initial pos of the slider control
  117. m_speedSlider.SetPos (m_iInitialPercent);
  118. return TRUE;
  119. }
  120. //////////////////////////////////////////////////////////////
  121. //
  122. // OnInitDialog
  123. //
  124. void
  125. CAnimationSpeed::OnHScroll
  126. (
  127. UINT nSBCode,
  128. UINT nPos,
  129. CScrollBar* pScrollBar
  130. )
  131. {
  132. // Get the current position of the slider control
  133. m_iInitialPercent = m_speedSlider.GetPos ();
  134. // Get a pointer to the main window
  135. CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd ();
  136. if (pCMainWnd)
  137. {
  138. // Get a pointer to the graphic view pane
  139. CGraphicView *pCGraphicView = (CGraphicView *)pCMainWnd->GetPane (0, 1);
  140. if (pCGraphicView)
  141. {
  142. pCGraphicView->SetAnimationSpeed (((float)m_iInitialPercent) / (100.00F));
  143. }
  144. }
  145. // Allow the base class to process this message
  146. CDialog::OnHScroll (nSBCode, nPos, pScrollBar);
  147. return ;
  148. }
  149. //////////////////////////////////////////////////////////////
  150. //
  151. // OnDestroy
  152. //
  153. void
  154. CAnimationSpeed::OnDestroy (void)
  155. {
  156. m_iInitialPercent = m_speedSlider.GetPos ();
  157. CDialog::OnDestroy();
  158. return ;
  159. }
  160. //////////////////////////////////////////////////////////////
  161. //
  162. // OnBlend
  163. //
  164. void
  165. CAnimationSpeed::OnBlend (void)
  166. {
  167. // Get a pointer to the doc so we can get at the current scene
  168. // pointer.
  169. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  170. if (pCDoc)
  171. {
  172. // Turn on/off the blending option
  173. pCDoc->SetAnimationBlend (SendDlgItemMessage (IDC_BLEND, BM_GETCHECK));
  174. }
  175. return ;
  176. }
  177. void CAnimationSpeed::
  178. OnCompressq(){
  179. /* CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  180. if(pCDoc){
  181. bool b_was_compressed = pCDoc->GetChannelQCompression();
  182. bool b_compress = IsDlgButtonChecked(IDC_COMPRESSQ) == BST_CHECKED;
  183. pCDoc->SetChannelQCompression(b_compress);
  184. //Enable/Disable
  185. if(b_compress){
  186. GetDlgItem(IDC_16BIT)->EnableWindow(TRUE);
  187. GetDlgItem(IDC_8BIT)->EnableWindow(TRUE);
  188. }else{
  189. GetDlgItem(IDC_16BIT)->EnableWindow(FALSE);
  190. GetDlgItem(IDC_8BIT)->EnableWindow(FALSE);
  191. }
  192. //Update
  193. if(b_compress != b_was_compressed){
  194. int n_bytes = pCDoc->GetChannelQnBytes();
  195. CompressQ = b_compress;
  196. QnBytes = n_bytes;
  197. }
  198. }
  199. */
  200. }
  201. void CAnimationSpeed::
  202. On16bit(){
  203. /*
  204. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  205. pCDoc->SetChannelQnBytes(2);
  206. QnBytes = 2;
  207. */
  208. }
  209. void CAnimationSpeed::
  210. On8bit(){
  211. /*
  212. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  213. pCDoc->SetChannelQnBytes(1);
  214. QnBytes = 1;
  215. */
  216. }