MotorcycleDialog.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. // MotorcycleDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "phystest.h"
  22. #include "MotorcycleDialog.h"
  23. #include "motorcycle.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. const float MIN_K = 0.01f;
  30. const float MAX_K = 100.0f;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMotorcycleDialog dialog
  33. CMotorcycleDialog::CMotorcycleDialog(CWnd* pParent,MotorcycleClass * obj)
  34. : CDialog(CMotorcycleDialog::IDD, pParent),
  35. EditedObject(obj)
  36. {
  37. //{{AFX_DATA_INIT(CMotorcycleDialog)
  38. // NOTE: the ClassWizard will add member initialization here
  39. //}}AFX_DATA_INIT
  40. }
  41. void CMotorcycleDialog::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CMotorcycleDialog)
  45. DDX_Control(pDX, IDC_LEAN_K1_SPIN, m_LeanK1Spin);
  46. DDX_Control(pDX, IDC_LEAN_K0_SPIN, m_LeanK0Spin);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CMotorcycleDialog, CDialog)
  50. //{{AFX_MSG_MAP(CMotorcycleDialog)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMotorcycleDialog message handlers
  55. float CMotorcycleDialog::GetDlgItemFloat(int controlid)
  56. {
  57. CString string;
  58. GetDlgItemText(controlid,string);
  59. return atof(string);
  60. }
  61. void CMotorcycleDialog::SetDlgItemFloat(int controlid,float val)
  62. {
  63. CString string;
  64. string.Format("%.2f",val);
  65. SetDlgItemText(controlid,string);
  66. }
  67. BOOL CMotorcycleDialog::OnInitDialog()
  68. {
  69. CDialog::OnInitDialog();
  70. m_LeanK0Spin.SetRange(MIN_K * 100,MAX_K * 100);
  71. m_LeanK1Spin.SetRange(MIN_K * 100,MAX_K * 100);
  72. float k;
  73. k = EditedObject->LeanK0;
  74. m_LeanK0Spin.SetPos(k * 100);
  75. SetDlgItemFloat(IDC_LEAN_K0_EDIT,k);
  76. k = EditedObject->LeanK1;
  77. m_LeanK1Spin.SetPos(k * 100);
  78. SetDlgItemFloat(IDC_LEAN_K1_EDIT,k);
  79. return TRUE;
  80. }
  81. BOOL CMotorcycleDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  82. {
  83. // make the spin controls work...
  84. switch(wParam)
  85. {
  86. case IDC_LEAN_K0_SPIN:
  87. case IDC_LEAN_K1_SPIN:
  88. LPNMUPDOWN lpnmud = (LPNMUPDOWN) lParam;
  89. if (lpnmud->hdr.code == UDN_DELTAPOS) {
  90. HWND hwnd = (HWND)SendDlgItemMessage(LOWORD(wParam),UDM_GETBUDDY);
  91. float curval = GetDlgItemFloat(GetWindowLong(hwnd,GWL_ID));
  92. curval += (float)lpnmud->iDelta / 100.0f;
  93. SetDlgItemFloat(GetWindowLong(hwnd,GWL_ID), curval);
  94. }
  95. break;
  96. }
  97. return CDialog::OnNotify(wParam, lParam, pResult);
  98. }
  99. void CMotorcycleDialog::OnOK()
  100. {
  101. float k;
  102. k = GetDlgItemFloat(IDC_LEAN_K0_EDIT);
  103. EditedObject->LeanK0 = k;
  104. k = GetDlgItemFloat(IDC_LEAN_K1_EDIT);
  105. EditedObject->LeanK1 = k;
  106. CDialog::OnOK();
  107. }