WaypathInfoPage.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. // WaypathInfoPage.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "waypathinfopage.h"
  23. #include "waypathnode.h"
  24. #include "waypointnode.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. //
  32. // WaypathInfoPageClass
  33. //
  34. /////////////////////////////////////////////////////////////////////////////
  35. WaypathInfoPageClass::WaypathInfoPageClass (void)
  36. : m_Waypoint (NULL),
  37. DockableFormClass (WaypathInfoPageClass::IDD)
  38. {
  39. //{{AFX_DATA_INIT(WaypathInfoPageClass)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. return ;
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. //
  46. // WaypathInfoPageClass
  47. //
  48. /////////////////////////////////////////////////////////////////////////////
  49. WaypathInfoPageClass::WaypathInfoPageClass (WaypointNodeClass *waypoint)
  50. : m_Waypoint (waypoint),
  51. DockableFormClass (WaypathInfoPageClass::IDD)
  52. {
  53. return ;
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. //
  57. // ~WaypathInfoPageClass
  58. //
  59. /////////////////////////////////////////////////////////////////////////////
  60. WaypathInfoPageClass::~WaypathInfoPageClass (void)
  61. {
  62. return ;
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. //
  66. // DoDataExchange
  67. //
  68. /////////////////////////////////////////////////////////////////////////////
  69. void
  70. WaypathInfoPageClass::DoDataExchange (CDataExchange* pDX)
  71. {
  72. DockableFormClass::DoDataExchange(pDX);
  73. //{{AFX_DATA_MAP(WaypathInfoPageClass)
  74. DDX_Control(pDX, IDC_SPEED_SLIDER, m_SpeedSlider);
  75. //}}AFX_DATA_MAP
  76. return ;
  77. }
  78. BEGIN_MESSAGE_MAP(WaypathInfoPageClass, DockableFormClass)
  79. //{{AFX_MSG_MAP(WaypathInfoPageClass)
  80. ON_WM_DESTROY()
  81. //}}AFX_MSG_MAP
  82. END_MESSAGE_MAP()
  83. /////////////////////////////////////////////////////////////////////////////
  84. //
  85. // HandleInitDialog
  86. //
  87. /////////////////////////////////////////////////////////////////////////////
  88. void
  89. WaypathInfoPageClass::HandleInitDialog (void)
  90. {
  91. ASSERT (m_Waypoint != NULL);
  92. WaypathNodeClass *path = m_Waypoint->Peek_Waypath ();
  93. //
  94. // Set the initial state of the 'path' controls
  95. //
  96. CheckDlgButton (IDC_TWOWAY_CHECK, path->Get_Flag (WaypathClass::FLAG_TWO_WAY));
  97. CheckDlgButton (IDC_LOOPING_CHECK, path->Get_Flag (WaypathClass::FLAG_LOOPING));
  98. CheckDlgButton (IDC_HUMAN_CHECK, path->Get_Flag (WaypathClass::FLAG_HUMAN));
  99. CheckDlgButton (IDC_GROUND_VEHICLE_CHECK, path->Get_Flag (WaypathClass::FLAG_GROUND_VEHICLE));
  100. CheckDlgButton (IDC_AIR_VEHICLE_CHECK, path->Get_Flag (WaypathClass::FLAG_FLYING_VEHICLE));
  101. CheckDlgButton (IDC_INNATE_PATHFIND_CHECK, path->Get_Flag (WaypathClass::FLAG_INNATE_PATHFIND));
  102. //
  103. // Set the initial state of the 'point' controls
  104. //
  105. m_SpeedSlider.SetRange (1, 100);
  106. m_SpeedSlider.SetPos (int(m_Waypoint->Get_Speed () * 100));
  107. CheckDlgButton (IDC_JUMP_CHECK, m_Waypoint->Get_Flag (WaypointNodeClass::FLAG_REQUIRES_JUMP));
  108. //
  109. // Update the enabled state of the checkboxes
  110. //
  111. Update_Enable_State ();
  112. return ;
  113. }
  114. /////////////////////////////////////////////////////////////////////////////
  115. //
  116. // Apply_Changes
  117. //
  118. /////////////////////////////////////////////////////////////////////////////
  119. bool
  120. WaypathInfoPageClass::Apply_Changes (void)
  121. {
  122. WaypathNodeClass *path = m_Waypoint->Peek_Waypath ();
  123. //
  124. // Pass the flags back to the path object
  125. //
  126. path->Set_Flag (WaypathClass::FLAG_TWO_WAY, IsDlgButtonChecked (IDC_TWOWAY_CHECK) == 1);
  127. path->Set_Flag (WaypathClass::FLAG_LOOPING, IsDlgButtonChecked (IDC_LOOPING_CHECK) == 1);
  128. path->Set_Flag (WaypathClass::FLAG_HUMAN, IsDlgButtonChecked (IDC_HUMAN_CHECK) == 1);
  129. path->Set_Flag (WaypathClass::FLAG_GROUND_VEHICLE, IsDlgButtonChecked (IDC_GROUND_VEHICLE_CHECK) == 1);
  130. path->Set_Flag (WaypathClass::FLAG_FLYING_VEHICLE, IsDlgButtonChecked (IDC_AIR_VEHICLE_CHECK) == 1);
  131. path->Set_Flag (WaypathClass::FLAG_INNATE_PATHFIND, IsDlgButtonChecked (IDC_INNATE_PATHFIND_CHECK) == 1);
  132. //
  133. // Pass the waypoint settings onto the waypoint object
  134. //
  135. int speed = m_SpeedSlider.GetPos ();
  136. m_Waypoint->Set_Speed (((float)speed) / 100.0F);
  137. m_Waypoint->Set_Flag (WaypointNodeClass::FLAG_REQUIRES_JUMP, IsDlgButtonChecked (IDC_JUMP_CHECK) == 1);
  138. // Return true to allow the dialog to close
  139. return true;
  140. }
  141. /////////////////////////////////////////////////////////////////////////////
  142. //
  143. // OnCommand
  144. //
  145. /////////////////////////////////////////////////////////////////////////////
  146. BOOL
  147. WaypathInfoPageClass::OnCommand
  148. (
  149. WPARAM wParam,
  150. LPARAM lParam
  151. )
  152. {
  153. if (LOWORD (wParam) == IDC_INNATE_PATHFIND_CHECK && HIWORD (wParam) == BN_CLICKED) {
  154. Update_Enable_State ();
  155. }
  156. return DockableFormClass::OnCommand (wParam, lParam);
  157. }
  158. /////////////////////////////////////////////////////////////////////////////
  159. //
  160. // Update_Enable_State
  161. //
  162. /////////////////////////////////////////////////////////////////////////////
  163. void
  164. WaypathInfoPageClass::Update_Enable_State (void)
  165. {
  166. bool enabled = (IsDlgButtonChecked (IDC_INNATE_PATHFIND_CHECK) == 1);
  167. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_HUMAN_CHECK), enabled);
  168. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_GROUND_VEHICLE_CHECK), enabled);
  169. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_AIR_VEHICLE_CHECK), enabled);
  170. return ;
  171. }