MotorVehicleDialog.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. // MotorVehicleDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "phystest.h"
  22. #include "MotorVehicleDialog.h"
  23. #include "motorvehicle.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_TORQUE = 1.0f;
  30. const float MAX_TORQUE = 10000.0f;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMotorVehicleDialog dialog
  33. CMotorVehicleDialog::CMotorVehicleDialog(CWnd* pParent,MotorVehicleClass * obj)
  34. : CDialog(CMotorVehicleDialog::IDD, pParent),
  35. EditedObject(obj)
  36. {
  37. //{{AFX_DATA_INIT(CMotorVehicleDialog)
  38. // NOTE: the ClassWizard will add member initialization here
  39. //}}AFX_DATA_INIT
  40. }
  41. void CMotorVehicleDialog::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CMotorVehicleDialog)
  45. DDX_Control(pDX, IDC_MVEHICLE_TORQUE_SPIN, m_TorqueSpin);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CMotorVehicleDialog, CDialog)
  49. //{{AFX_MSG_MAP(CMotorVehicleDialog)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CMotorVehicleDialog message handlers
  54. float CMotorVehicleDialog::GetDlgItemFloat(int controlid)
  55. {
  56. CString string;
  57. GetDlgItemText(controlid,string);
  58. return atof(string);
  59. }
  60. void CMotorVehicleDialog::SetDlgItemFloat(int controlid,float val)
  61. {
  62. CString string;
  63. string.Format("%.2f",val);
  64. SetDlgItemText(controlid,string);
  65. }
  66. BOOL CMotorVehicleDialog::OnInitDialog()
  67. {
  68. CDialog::OnInitDialog();
  69. m_TorqueSpin.SetRange(MIN_TORQUE * 100,MAX_TORQUE * 100);
  70. float mt = EditedObject->Get_Max_Engine_Torque();
  71. m_TorqueSpin.SetPos(mt * 100);
  72. SetDlgItemFloat(IDC_MVEHICLE_TORQUE_EDIT,mt);
  73. return TRUE;
  74. }
  75. BOOL CMotorVehicleDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  76. {
  77. // make the spin controls work...
  78. switch(wParam)
  79. {
  80. case IDC_MVEHICLE_TORQUE_SPIN:
  81. LPNMUPDOWN lpnmud = (LPNMUPDOWN) lParam;
  82. if (lpnmud->hdr.code == UDN_DELTAPOS) {
  83. HWND hwnd = (HWND)SendDlgItemMessage(LOWORD(wParam),UDM_GETBUDDY);
  84. float curval = GetDlgItemFloat(GetWindowLong(hwnd,GWL_ID));
  85. curval += (float)lpnmud->iDelta / 100.0f;
  86. SetDlgItemFloat(GetWindowLong(hwnd,GWL_ID), curval);
  87. }
  88. break;
  89. }
  90. return CDialog::OnNotify(wParam, lParam, pResult);
  91. }
  92. void CMotorVehicleDialog::OnOK()
  93. {
  94. float mt = GetDlgItemFloat(IDC_MVEHICLE_TORQUE_EDIT);
  95. EditedObject->Set_Max_Engine_Torque(mt);
  96. CDialog::OnOK();
  97. }