MainFrm.cpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. // MainFrm.cpp : implementation of the CMainFrame class
  19. //
  20. #include "stdafx.h"
  21. #include "SplineTest.h"
  22. #include "MainFrm.h"
  23. #include "SplineTestDoc.h"
  24. #include "SplineTestView.h"
  25. #include "curve.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMainFrame
  33. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  34. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  35. //{{AFX_MSG_MAP(CMainFrame)
  36. ON_WM_CREATE()
  37. ON_COMMAND(ID_CURVE_CARDINAL, OnCurveCardinal)
  38. ON_UPDATE_COMMAND_UI(ID_CURVE_CARDINAL, OnUpdateCurveCardinal)
  39. ON_COMMAND(ID_CURVE_CATMULL_ROM, OnCurveCatmullRom)
  40. ON_UPDATE_COMMAND_UI(ID_CURVE_CATMULL_ROM, OnUpdateCurveCatmullRom)
  41. ON_COMMAND(ID_CURVE_LINEAR, OnCurveLinear)
  42. ON_UPDATE_COMMAND_UI(ID_CURVE_LINEAR, OnUpdateCurveLinear)
  43. ON_COMMAND(ID_CURVE_TCB, OnCurveTcb)
  44. ON_UPDATE_COMMAND_UI(ID_CURVE_TCB, OnUpdateCurveTcb)
  45. ON_COMMAND(ID_CURVE_RESET, OnCurveReset)
  46. ON_COMMAND(ID_CURVE_DRAW_TANGENTS, OnCurveDrawTangents)
  47. ON_UPDATE_COMMAND_UI(ID_CURVE_DRAW_TANGENTS, OnUpdateCurveDrawTangents)
  48. ON_COMMAND(ID_CURVE_LOOP, OnCurveLoop)
  49. ON_UPDATE_COMMAND_UI(ID_CURVE_LOOP, OnUpdateCurveLoop)
  50. ON_COMMAND(IDM_VEHICLE_CURVE, OnVehicleCurve)
  51. ON_UPDATE_COMMAND_UI(IDM_VEHICLE_CURVE, OnUpdateVehicleCurve)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. static UINT indicators[] =
  55. {
  56. ID_SEPARATOR, // status line indicator
  57. ID_INDICATOR_CAPS,
  58. ID_INDICATOR_NUM,
  59. ID_INDICATOR_SCRL,
  60. };
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CMainFrame construction/destruction
  63. CMainFrame::CMainFrame()
  64. {
  65. // TODO: add member initialization code here
  66. }
  67. CMainFrame::~CMainFrame()
  68. {
  69. }
  70. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  71. {
  72. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  73. return -1;
  74. #if 0
  75. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  76. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  77. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  78. {
  79. TRACE0("Failed to create toolbar\n");
  80. return -1; // fail to create
  81. }
  82. #endif
  83. if (!m_wndStatusBar.Create(this) ||
  84. !m_wndStatusBar.SetIndicators(indicators,
  85. sizeof(indicators)/sizeof(UINT)))
  86. {
  87. TRACE0("Failed to create status bar\n");
  88. return -1; // fail to create
  89. }
  90. // TODO: Delete these three lines if you don't want the toolbar to
  91. // be dockable
  92. #if 0
  93. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  94. EnableDocking(CBRS_ALIGN_ANY);
  95. DockControlBar(&m_wndToolBar);
  96. #endif
  97. return 0;
  98. }
  99. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  100. {
  101. if( !CFrameWnd::PreCreateWindow(cs) )
  102. return FALSE;
  103. // TODO: Modify the Window class or styles here by modifying
  104. // the CREATESTRUCT cs
  105. return TRUE;
  106. }
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CMainFrame diagnostics
  109. #ifdef _DEBUG
  110. void CMainFrame::AssertValid() const
  111. {
  112. CFrameWnd::AssertValid();
  113. }
  114. void CMainFrame::Dump(CDumpContext& dc) const
  115. {
  116. CFrameWnd::Dump(dc);
  117. }
  118. #endif //_DEBUG
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CMainFrame message handlers
  121. void CMainFrame::OnCurveCardinal()
  122. {
  123. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  124. if (doc) {
  125. doc->Set_Curve_Type(CSplineTestDoc::CARDINAL);
  126. }
  127. }
  128. void CMainFrame::OnUpdateCurveCardinal(CCmdUI* pCmdUI)
  129. {
  130. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  131. if (doc != NULL) {
  132. pCmdUI->SetCheck(doc->Get_Curve_Type() == CSplineTestDoc::CARDINAL);
  133. }
  134. }
  135. void CMainFrame::OnCurveCatmullRom()
  136. {
  137. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  138. if (doc) {
  139. doc->Set_Curve_Type(CSplineTestDoc::CATMULL_ROM);
  140. }
  141. }
  142. void CMainFrame::OnUpdateCurveCatmullRom(CCmdUI* pCmdUI)
  143. {
  144. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  145. if (doc != NULL) {
  146. pCmdUI->SetCheck(doc->Get_Curve_Type() == CSplineTestDoc::CATMULL_ROM);
  147. }
  148. }
  149. void CMainFrame::OnCurveLinear()
  150. {
  151. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  152. if (doc) {
  153. doc->Set_Curve_Type(CSplineTestDoc::LINEAR);
  154. }
  155. }
  156. void CMainFrame::OnUpdateCurveLinear(CCmdUI* pCmdUI)
  157. {
  158. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  159. if (doc != NULL) {
  160. pCmdUI->SetCheck(doc->Get_Curve_Type() == CSplineTestDoc::LINEAR);
  161. }
  162. }
  163. void CMainFrame::OnCurveTcb()
  164. {
  165. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  166. if (doc) {
  167. doc->Set_Curve_Type(CSplineTestDoc::TCB);
  168. }
  169. }
  170. void CMainFrame::OnUpdateCurveTcb(CCmdUI* pCmdUI)
  171. {
  172. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  173. if (doc != NULL) {
  174. pCmdUI->SetCheck(doc->Get_Curve_Type() == CSplineTestDoc::TCB);
  175. }
  176. }
  177. void CMainFrame::OnCurveReset()
  178. {
  179. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  180. if (doc != NULL) {
  181. doc->Reset_Curve();
  182. }
  183. }
  184. void CMainFrame::OnCurveDrawTangents()
  185. {
  186. CSplineTestView * view = (CSplineTestView *)GetActiveView();
  187. if (view) {
  188. view->Enable_Draw_Tangents(!view->Is_Draw_Tangents_Enabled());
  189. }
  190. }
  191. void CMainFrame::OnUpdateCurveDrawTangents(CCmdUI* pCmdUI)
  192. {
  193. CSplineTestView * view = (CSplineTestView *)GetActiveView();
  194. if (view) {
  195. pCmdUI->SetCheck(view->Is_Draw_Tangents_Enabled());
  196. }
  197. }
  198. void CMainFrame::OnCurveLoop()
  199. {
  200. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  201. if (doc != NULL) {
  202. Curve3DClass * curve = doc->Get_Curve();
  203. if (curve) {
  204. curve->Set_Looping(!curve->Is_Looping());
  205. }
  206. doc->UpdateAllViews(NULL);
  207. }
  208. }
  209. void CMainFrame::OnUpdateCurveLoop(CCmdUI* pCmdUI)
  210. {
  211. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  212. if (doc != NULL) {
  213. Curve3DClass * curve = doc->Get_Curve();
  214. if (curve) {
  215. pCmdUI->SetCheck(curve->Is_Looping());
  216. }
  217. }
  218. }
  219. void CMainFrame::OnVehicleCurve()
  220. {
  221. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  222. if (doc) {
  223. doc->Set_Curve_Type(CSplineTestDoc::VEHICLE );
  224. }
  225. }
  226. void CMainFrame::OnUpdateVehicleCurve(CCmdUI* pCmdUI)
  227. {
  228. CSplineTestDoc * doc = (CSplineTestDoc *)GetActiveDocument();
  229. if (doc != NULL) {
  230. pCmdUI->SetCheck(doc->Get_Curve_Type() == CSplineTestDoc::VEHICLE);
  231. }
  232. }