Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

837 lines
23 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CHOREOVIEW_H
  8. #define CHOREOVIEW_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <mxtk/mx.h>
  13. #include <mxtk/mxWindow.h>
  14. #include "mxBitmapButton.h"
  15. #include "utlvector.h"
  16. #include "ChoreoWidget.h"
  17. #include "ichoreoeventcallback.h"
  18. #include "faceposertoolwindow.h"
  19. #include "ChoreoEvent.h"
  20. #include "mathlib/mathlib.h"
  21. #include "SoundEmitterSystem/isoundemittersystembase.h"
  22. #define IDC_CV_CC_LANGUAGESTART 5300
  23. #define IDC_STOPSCENE 5000
  24. #define IDC_PLAYSCENE 5001
  25. #define IDC_PAUSESCENE 5002
  26. #define IDC_CHOREOVSCROLL 5003
  27. #define IDC_CHOREOHSCROLL 5004
  28. #define IDC_ADDACTOR 5005
  29. #define IDC_DELETEACTOR 5006
  30. #define IDC_MOVEACTORUP 5007
  31. #define IDC_MOVEACTORDOWN 5008
  32. #define IDC_EDITACTOR 5009
  33. #define IDC_EDITEVENT 5010
  34. #define IDC_DELETEEVENT 5011
  35. #define IDC_ADDEVENT_EXPRESSION 5012
  36. #define IDC_ADDEVENT_GESTURE 5013
  37. #define IDC_ADDEVENT_LOOKAT 5014
  38. #define IDC_ADDEVENT_MOVETO 5015
  39. #define IDC_ADDEVENT_SPEAK 5016
  40. #define IDC_ADDEVENT_FACE 5017
  41. #define IDC_ADDEVENT_FIRETRIGGER 5018
  42. #define IDC_ADDEVENT_SEQUENCE 5019
  43. #define IDC_ADDEVENT_GENERIC 5020
  44. #define IDC_CV_CHANGESCALE 5021
  45. #define IDC_EDITGLOBALEVENT 5022
  46. #define IDC_DELETEGLOBALEVENT 5023
  47. #define IDC_ADDEVENT_PAUSE 5024
  48. #define IDC_ADDCHANNEL 5025
  49. #define IDC_EDITCHANNEL 5026
  50. #define IDC_DELETECHANNEL 5027
  51. #define IDC_MOVECHANNELUP 5028
  52. #define IDC_MOVECHANNELDOWN 5029
  53. #define IDC_CHANNELOPEN 5030
  54. #define IDC_CHANNELCLOSE 5031
  55. #define IDC_CBACTORACTIVE 5032
  56. #define IDC_DELETERELATIVETAG 5033
  57. #define IDC_ADDTIMINGTAG 5034
  58. #define IDC_SELECTALL 5035
  59. #define IDC_DESELECTALL 5036
  60. #define IDC_MOVETOBACK 5037
  61. #define IDC_UNDO 5038
  62. #define IDC_REDO 5039
  63. #define IDC_EXPRESSIONTOOL 5040
  64. #define IDC_ASSOCIATEBSP 5041
  65. #define IDC_ADDEVENT_FLEXANIMATION 5042
  66. #define IDC_COPYEVENTS 5043
  67. #define IDC_PASTEEVENTS 5044
  68. #define IDC_IMPORTEVENTS 5045
  69. #define IDC_EXPORTEVENTS 5046
  70. #define IDC_ADDEVENT_SUBSCENE 5047
  71. #define IDC_PLAYSCENE_BACKWARD 5048
  72. #define IDC_ASSOCIATEMODEL 5049
  73. #define IDC_CHOREO_PLAYBACKRATE 5050
  74. #define IDC_CV_CHECKSEQLENGTHS 5051
  75. #define IDC_CV_PROCESSSEQUENCES 5052
  76. #define IDC_GESTURETOOL 5053
  77. #define IDC_ADDEVENT_LOOP 5054
  78. #define IDC_CV_TOGGLERAMPONLY 5055
  79. #define IDC_ADDEVENT_INTERRUPT 5056
  80. #define IDC_ADDEVENT_STOPPOINT 5067
  81. #define SCENE_ACTION_UNKNOWN 0
  82. #define SCENE_ACTION_CANCEL 1
  83. #define SCENE_ACTION_RESUME 2
  84. #define SCENE_ANIMLAYER_SEQUENCE 0
  85. #define SCENE_ANIMLAYER_GESTURE 1
  86. #define IDC_ADDEVENT_NULLGESTURE 5068
  87. #define IDC_SELECTEVENTS_ALL_BEFORE 5069
  88. #define IDC_SELECTEVENTS_ALL_AFTER 5070
  89. #define IDC_SELECTEVENTS_ACTIVE_BEFORE 5071
  90. #define IDC_SELECTEVENTS_ACTIVE_AFTER 5072
  91. #define IDC_SELECTEVENTS_CHANNEL_BEFORE 5073
  92. #define IDC_SELECTEVENTS_CHANNEL_AFTER 5074
  93. #define IDC_INSERT_TIME 5075
  94. #define IDC_DELETE_TIME 5076
  95. #define IDC_EXPORT_VCD 5077
  96. #define IDC_IMPORT_VCD 5078
  97. #define IDC_ADDEVENT_PERMITRESPONSES 5079
  98. #define IDC_CV_CC_SHOW 5080
  99. #define IDC_CV_COMBINESPEAKEVENTS 5081
  100. #define IDC_CV_REMOVESPEAKEVENTFROMGROUP 5082
  101. #define IDC_CV_CHANGECLOSECAPTIONTOKEN 5083
  102. #define IDC_CV_TOGGLECLOSECAPTIONS 5084
  103. #define IDC_CV_ALIGN_LEFT 5085
  104. #define IDC_CV_ALIGN_RIGHT 5086
  105. #define IDC_CV_SAMESIZE_SMALLEST 5087
  106. #define IDC_CV_SAMESIZE_LARGEST 5088
  107. #define IDC_CV_ALLEVENTS_CHANNEL 5089
  108. #define IDC_CV_ALLEVENTS_ACTOR 5090
  109. #define IDC_CV_ENABLEEVENTS 5091
  110. #define IDC_CV_DISABLEEVENTS 5092
  111. #define IDC_ADDEVENT_CAMERA 5093
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CChoreoView window
  114. class CChoreoScene;
  115. class CChoreoEvent;
  116. class CChoreoActor;
  117. class CChoreoChannel;
  118. class CChoreoActorWidget;
  119. class CChoreoChannelWidget;
  120. class CChoreoEventWidget;
  121. class CChoreoGlobalEventWidget;
  122. class CChoreoWidgetDrawHelper;
  123. class PhonemeEditor;
  124. class CExpression;
  125. class CExpClass;
  126. class StudioModel;
  127. //-----------------------------------------------------------------------------
  128. // Purpose: The main view of the choreography data for a scene
  129. //-----------------------------------------------------------------------------
  130. class CChoreoView : public mxWindow, public IFacePoserToolWindow, public IChoreoEventCallback
  131. {
  132. // Construction
  133. public:
  134. CChoreoView( mxWindow *parent, int x, int y, int w, int h, int id );
  135. virtual ~CChoreoView();
  136. virtual void OnModelChanged();
  137. virtual void OnDelete();
  138. virtual bool CanClose();
  139. void InvalidateTrackLookup( void );
  140. // Implements IChoreoEventCallback
  141. virtual void StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  142. virtual void EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  143. virtual void ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  144. virtual bool CheckEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  145. void SetChoreoFile( char const *filename );
  146. char const *GetChoreoFile( void ) const;
  147. // Scene load/unload
  148. void LoadSceneFromFile( const char *filename );
  149. CChoreoScene *LoadScene( char const *filename );
  150. void UnloadScene( void );
  151. // UI
  152. void New( void );
  153. void Save( void );
  154. void SaveAs( void );
  155. void Load( void );
  156. void LoadNext( void );
  157. bool Close( void );
  158. // Drag/drop from expression thumbnail
  159. bool CreateExpressionEvent( int mx, int my, CExpClass *cl, CExpression *exp );
  160. bool CreateAnimationEvent( int mx, int my, char const *animationname );
  161. void SelectAll( void );
  162. void DeselectAll( void );
  163. struct SelectionParams_t
  164. {
  165. enum
  166. {
  167. SP_CHANNEL = 0,
  168. SP_ACTIVE,
  169. SP_ALL
  170. };
  171. float time;
  172. bool forward;
  173. int type;
  174. };
  175. void SelectEvents( SelectionParams_t& params );
  176. // Channel/actor right click menu
  177. void NewChannel( void );
  178. void DeleteChannel( CChoreoChannel *channel );
  179. void MoveChannelUp( CChoreoChannel *channel );
  180. void MoveChannelDown( CChoreoChannel *channel );
  181. void EditChannel( CChoreoChannel *channel );
  182. void AddEvent( int type, int subtype = 0, char const *defaultparameters = NULL );
  183. // Actor right click menu
  184. void NewActor( void );
  185. void DeleteActor( CChoreoActor *actor );
  186. void MoveActorUp( CChoreoActor *actor );
  187. void MoveActorDown( CChoreoActor *actor );
  188. void EditActor( CChoreoActor *actor );
  189. // Event menu
  190. void EditEvent( CChoreoEvent *event );
  191. void DeleteSelectedEvents( void );
  192. void EnableSelectedEvents( bool state );
  193. void DeleteEventRelativeTag( CChoreoEvent *event, int tagnum );
  194. void AddEventRelativeTag( void );
  195. CChoreoEventWidget *FindWidgetForEvent( CChoreoEvent *event );
  196. CChoreoChannelWidget *FindChannelForEvent( CChoreoEvent *event );
  197. void MoveEventToBack( CChoreoEvent *event );
  198. void OnExpressionTool( void );
  199. void OnGestureTool( void );
  200. // Global event ( pause ) menu
  201. void EditGlobalEvent( CChoreoEvent *event );
  202. void DeleteGlobalEvent( CChoreoEvent *event );
  203. void AddGlobalEvent( CChoreoEvent::EVENTTYPE type );
  204. void AssociateBSP( void );
  205. void AssociateModel( void );
  206. void AssociateModelToActor( CChoreoActor *actor, int modelindex );
  207. // UI Layout
  208. void CreateSceneWidgets( void );
  209. void DeleteSceneWidgets( void );
  210. void LayoutScene( void );
  211. void InvalidateLayout( void );
  212. void ForceScrollBarsToRecompute( bool resetthumb );
  213. // Layout data that children should obey
  214. int GetLabelWidth( void );
  215. int GetStartRow( void );
  216. int GetRowHeight( void );
  217. int GetFontSize( void );
  218. int GetEndRow( void );
  219. // Simulation
  220. void PlayScene( bool forward );
  221. void PauseScene( void );
  222. bool IsPlayingScene( void );
  223. void ResetTargetSettings( void );
  224. void UpdateCurrentSettings( void );
  225. virtual void Think( float dt );
  226. virtual bool IsScrubbing( void ) const;
  227. virtual bool IsProcessing( void );
  228. bool ShouldProcessSpeak( void );
  229. void SceneThink( float time );
  230. void PauseThink( void );
  231. void FinishSimulation( void );
  232. void StopScene();
  233. float GetStartTime( void );
  234. float GetEndTime( void );
  235. void SetStartTime( float time );
  236. void ProcessExpression( CChoreoScene *scene, CChoreoEvent *event );
  237. void ProcessFlexAnimation( CChoreoScene *scene, CChoreoEvent *event );
  238. void ProcessLookat( CChoreoScene *scene, CChoreoEvent *event );
  239. bool GetTarget( CChoreoScene *scene, CChoreoEvent *event, Vector &vecTarget, QAngle &vecAngle );
  240. void ProcessFace( CChoreoScene *scene, CChoreoEvent *event );
  241. void ProcessGesture( CChoreoScene *scene, CChoreoEvent *event );
  242. void ProcessSequence( CChoreoScene *scene, CChoreoEvent *event );
  243. void ProcessMoveto( CChoreoScene *scene, CChoreoEvent *event );
  244. int GetMovetoSequence( CChoreoScene *scene, CChoreoEvent *event, StudioModel *model );
  245. void ProcessSubscene( CChoreoScene *scene, CChoreoEvent *event );
  246. void ProcessPause( CChoreoScene *scene, CChoreoEvent *event );
  247. void ProcessSpeak( CChoreoScene *scene, CChoreoEvent *event );
  248. void ProcessLoop( CChoreoScene *scene, CChoreoEvent *event );
  249. void ProcessInterrupt( CChoreoScene *scene, CChoreoEvent *event );
  250. void ProcessPermitResponses( CChoreoScene *scene, CChoreoEvent *event );
  251. float GetPixelsPerSecond( void );
  252. // mxWindow overrides
  253. virtual void redraw();
  254. virtual bool PaintBackground( void );
  255. virtual int handleEvent( mxEvent *event );
  256. // Draw helpers
  257. void DrawSceneABTicks( CChoreoWidgetDrawHelper& drawHelper );
  258. void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
  259. void DrawBackground( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  260. void DrawRelativeTagLines( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  261. // Remap click position to/from time value
  262. float GetTimeValueForMouse( int mx, bool clip = false );
  263. int GetPixelForTimeValue( float time, bool *clipped = NULL );
  264. float GetTimeDeltaForMouseDelta( int mx, int origmx );
  265. // Readjust slider
  266. void MoveTimeSliderToPos( int x );
  267. // Dirty flag for file save prompting
  268. bool GetDirty( void );
  269. void SetDirty( bool dirty, bool clearundo = true );
  270. void ShowContextMenu( int mx, int my );
  271. // Caller must first translate mouse into screen coordinates
  272. bool IsMouseOverTimeline( int mx, int my );
  273. CChoreoActorWidget *GetActorUnderCursorPos( int mx, int my );
  274. CChoreoChannelWidget *GetChannelUnderCursorPos( int mx, int my );
  275. CChoreoEventWidget *GetEventUnderCursorPos( int mx, int my );
  276. CChoreoGlobalEventWidget *GetGlobalEventUnderCursorPos( int mx, int my );
  277. int GetTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
  278. CEventAbsoluteTag *GetAbsoluteTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
  279. void GetObjectsUnderMouse( int mx, int my,
  280. CChoreoActorWidget **actor,
  281. CChoreoChannelWidget **channel,
  282. CChoreoEventWidget **event,
  283. CChoreoGlobalEventWidget **globalevent,
  284. int* clickedTag,
  285. CEventAbsoluteTag **absolutetag,
  286. int *clickedCCButton );
  287. void OnDoubleClicked( void );
  288. void ApplyBounds( int& mx, int& my );
  289. void CalcBounds( int movetype );
  290. void MouseStartDrag( mxEvent *event, int mx, int my );
  291. void MouseContinueDrag( mxEvent *event, int mx, int my );
  292. void MouseFinishDrag( mxEvent *event, int mx, int my );
  293. void MouseMove( int mx, int my );
  294. //void StartDraggingGlobalEvent( int mx, int my );
  295. void StartDraggingEvent( int mx, int my );
  296. //void FinishDraggingGlobalEvent( int mx, int my );
  297. void FinishDraggingEvent( mxEvent *event, int mx, int my );
  298. // Draw focus rect while mouse dragging is going on
  299. void DrawFocusRect( void );
  300. int ComputeEventDragType( int mx, int my );
  301. void SetCurrentWaveFile( const char *filename, CChoreoEvent *event );
  302. void RecomputeWaves();
  303. typedef void (CChoreoView::*CVMEMBERFUNC)( CChoreoWidget *widget, CChoreoWidget *param1 );
  304. void TraverseWidgets( CVMEMBERFUNC pfn, CChoreoWidget *param1 );
  305. int CountSelectedEvents( void );
  306. int CountSelectedGlobalEvents( void );
  307. int GetSelectedEvents( CUtlVector< CChoreoEvent * >& events );
  308. int GetSelectedEventWidgets( CUtlVector< CChoreoEventWidget * >& events );
  309. int GetEarliestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
  310. int GetLatestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
  311. // Traversal functions
  312. void Deselect( CChoreoWidget *widget, CChoreoWidget *param1 );
  313. void Select( CChoreoWidget *widget, CChoreoWidget *param1 );
  314. void SelectInActor( CChoreoWidget *widget, CChoreoWidget *param1 );
  315. void SelectInChannel( CChoreoWidget *widget, CChoreoWidget *param1 );
  316. void SelectAllEvents( CChoreoWidget *widget, CChoreoWidget *param1 );
  317. void SelectAllEventsInActor( CChoreoActorWidget *actor );
  318. void SelectAllEventsInChannel( CChoreoChannelWidget *channel );
  319. // Adjust scroll bars
  320. void RepositionVSlider( void );
  321. void RepositionHSlider( void );
  322. void UpdateStatusArea( int mx, int my );
  323. void ClearStatusArea( void );
  324. void RedrawStatusArea( CChoreoWidgetDrawHelper& drawHelper, RECT& rcStatus );
  325. void GetUndoLevels( int& current, int& number );
  326. // Undo/Redo
  327. void Undo( void );
  328. void Redo( void );
  329. bool CanUndo();
  330. bool CanRedo();
  331. // Do push before changes
  332. void PushUndo( const char *description );
  333. // Do this push after changes, must match pushundo 1for1
  334. void PushRedo( const char *description );
  335. void WipeUndo( void );
  336. void WipeRedo( void );
  337. const char *GetUndoDescription( void );
  338. const char *GetRedoDescription( void );
  339. CChoreoScene *GetScene( void );
  340. void ReportSceneClearToTools( void );
  341. void CopyEvents( void );
  342. void PasteEvents( void );
  343. void ImportEvents( void );
  344. void ExportEvents( void );
  345. void ExportVCD();
  346. void ImportVCD();
  347. void ExportVCDFile( char const *filename );
  348. void ImportVCDFile( char const *filename );
  349. bool CanPaste( void );
  350. bool IsMouseOverScrubHandle( mxEvent *event );
  351. bool IsMouseOverScrubArea( mxEvent *event );
  352. void GetScrubHandleRect( RECT& rcHandle, bool clipped = false );
  353. void GetScrubAreaRect( RECT& rcArea );
  354. void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper );
  355. void DrawScrubHandle( void );
  356. void ScrubThink( float dt, bool scrubbing, IFacePoserToolWindow *invoker );
  357. void ClampTimeToSelectionInterval( float& timeval );
  358. void SetScrubTime( float t );
  359. void SetScrubTargetTime( float t );
  360. void OnCheckSequenceLengths( void );
  361. bool IsRampOnly( void ) const;
  362. void SetTimeZoom( const char *tool, int tz, bool preserveFocus );
  363. int GetTimeZoom( const char *tool );
  364. template< class T >
  365. void SetPreservedTimeZoom( T *other, int tz );
  366. template< class T >
  367. int HandleZoomKey( T *other, int keyCode );
  368. void OnInsertTime();
  369. void OnDeleteTime();
  370. bool GetShowCloseCaptionData( void ) const;
  371. bool ValidateCombinedSoundCheckSum( CChoreoEvent *e );
  372. void OnPlaceNextSpeakEvent();
  373. void SetScrubUnitSeconds( bool bUseSeconds);
  374. private:
  375. void CheckInsertTime( CChoreoEvent *e, float dt, float starttime, float endtime );
  376. void CheckDeleteTime( CChoreoEvent *d, float dt, float starttime, float endtime, bool& deleteEvent );
  377. bool FixupSequenceDurations( CChoreoScene *scene, bool checkonly );
  378. bool CheckSequenceLength( CChoreoEvent *e, bool checkonly );
  379. bool CheckGestureLength( CChoreoEvent *e, bool checkonly );
  380. bool DefaultGestureLength( CChoreoEvent *e, bool checkonly );
  381. bool AutoaddGestureKeys( CChoreoEvent *e, bool checkonly );
  382. void InvalidateTrackLookup_R( CChoreoScene *scene );
  383. void ShowButtons( bool show );
  384. // Compute full size of data in pixels, for setting up scroll bars
  385. int ComputeVPixelsNeeded( void );
  386. int ComputeHPixelsNeeded( void );
  387. void PositionControls();
  388. void OnChangeScale();
  389. float FindNextEventTime( CChoreoEvent::EVENTTYPE type, CChoreoChannel *channel, CChoreoEvent *e, bool forward );
  390. bool ShouldSelectEvent( SelectionParams_t &params, CChoreoEvent *event );
  391. bool IsMouseOverSceneEndTime( int mx );
  392. void StartDraggingSceneEndTime( int mx, int my );
  393. void FinishDraggingSceneEndTime( mxEvent *event, int mx, int my );
  394. void SetShowCloseCaptionData( bool show );
  395. void OnToggleCloseCaptionTags();
  396. void OnCombineSpeakEvents();
  397. void OnRemoveSpeakEventFromGroup();
  398. void OnChangeCloseCaptionToken( CChoreoEvent *e );
  399. bool AreSelectedEventsCombinable();
  400. bool AreSelectedEventsInSpeakGroup();
  401. void OnToggleCloseCaptionsForEvent();
  402. bool GenerateCombinedFile( char const *outfilename, const char *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
  403. bool ValidateCombinedFileCheckSum( char const *outfilename, char const *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
  404. void RememberSelectedEvents( CUtlVector< CChoreoEvent * >& list );
  405. void ReselectEvents( CUtlVector< CChoreoEvent * >& list );
  406. void OnAlign( bool left );
  407. void OnMakeSameSize( bool smallest );
  408. bool IsMouseOverEventEdge( CChoreoEventWidget *ew, bool bLeftEdge, int mx, int my );
  409. bool IsMouseOverEvent( CChoreoEventWidget *ew, int mx, int my );
  410. typedef struct
  411. {
  412. bool active;
  413. float time;
  414. } SCENEAB;
  415. void PlaceABPoint( int mx );
  416. void ClearABPoints( void );
  417. SCENEAB m_rgABPoints[ 2 ];
  418. int m_nCurrentABPoint;
  419. bool m_bForward;
  420. // The underlying scene we are editing
  421. CChoreoScene *m_pScene;
  422. enum
  423. {
  424. MAX_ACTORS = 32
  425. };
  426. typedef struct
  427. {
  428. bool expanded;
  429. } ACTORSTATE;
  430. ACTORSTATE m_ActorExpanded[ MAX_ACTORS ];
  431. // The scene's ui actors
  432. CUtlVector < CChoreoActorWidget * > m_SceneActors;
  433. // The scenes segment markers
  434. CUtlVector < CChoreoGlobalEventWidget * > m_SceneGlobalEvents;
  435. // How many pixels per second we are showing in the UI
  436. float m_flPixelsPerSecond;
  437. // Do we need to move controls?
  438. bool m_bLayoutIsValid;
  439. // Starting row of first actor
  440. int m_nStartRow;
  441. // How wide the actor/channel name area is
  442. int m_nLabelWidth;
  443. // Height between channel/actor names
  444. int m_nRowHeight;
  445. // Font size for drawing event labels
  446. int m_nFontSize;
  447. // Height/width of scroll bars
  448. int m_nScrollbarHeight;
  449. // Height off info area for flyover info / help
  450. int m_nInfoHeight;
  451. // Simulation info
  452. float m_flStartTime;
  453. float m_flEndTime;
  454. float m_flFrameTime;
  455. bool m_bSimulating;
  456. bool m_bPaused;
  457. float m_flLastSpeedScale;
  458. bool m_bResetSpeedScale;
  459. bool m_bAutomated;
  460. int m_nAutomatedAction;
  461. float m_flAutomationDelay;
  462. float m_flAutomationTime;
  463. // Some rectangles for the UI
  464. RECT m_rcTitles;
  465. RECT m_rcTimeLine;
  466. // Play/pause buttons for simulation
  467. mxBitmapButton *m_btnPlay;
  468. mxBitmapButton *m_btnPause;
  469. mxBitmapButton *m_btnStop;
  470. mxSlider *m_pPlaybackRate;
  471. float m_flPlaybackRate;
  472. // The scroll bars
  473. mxScrollbar *m_pVertScrollBar;
  474. mxScrollbar *m_pHorzScrollBar;
  475. int m_nLastHPixelsNeeded;
  476. int m_nLastVPixelsNeeded;
  477. // Current sb values
  478. int m_nTopOffset;
  479. float m_flLeftOffset;
  480. // Need save?
  481. bool m_bDirty;
  482. // Currently loaded scene file
  483. char m_szChoreoFile[ 256 ];
  484. CChoreoActorWidget *m_pClickedActor;
  485. CChoreoChannelWidget *m_pClickedChannel;
  486. CChoreoEventWidget *m_pClickedEvent;
  487. CChoreoGlobalEventWidget *m_pClickedGlobalEvent;
  488. // Relative to the clicked event
  489. int m_nClickedTag;
  490. CEventAbsoluteTag *m_pClickedAbsoluteTag;
  491. int m_nSelectedEvents;
  492. int m_nClickedX, m_nClickedY;
  493. int m_nClickedChannelCloseCaptionButton;
  494. // For mouse dragging
  495. // How close to right or left edge the mouse has to be before the wider/shorten
  496. // cursor shows up
  497. enum
  498. {
  499. DRAG_EVENT_EDGE_TOLERANCE = 5,
  500. };
  501. // When dragging, what time of action is being performed
  502. enum
  503. {
  504. DRAGTYPE_NONE = 0,
  505. DRAGTYPE_EVENT_MOVE,
  506. DRAGTYPE_EVENT_STARTTIME,
  507. DRAGTYPE_EVENT_STARTTIME_RESCALE,
  508. DRAGTYPE_EVENT_ENDTIME,
  509. DRAGTYPE_EVENT_ENDTIME_RESCALE,
  510. DRAGTYPE_EVENTTAG_MOVE,
  511. DRAGTYPE_EVENTABSTAG_MOVE,
  512. DRAGTYPE_SCRUBBER,
  513. DRAGTYPE_SCENE_ENDTIME,
  514. DRAGTYPE_RESCALELEFT,
  515. DRAGTYPE_RESCALERIGHT,
  516. };
  517. float m_flScrub;
  518. int m_bScrubSeconds;
  519. float m_flScrubTarget;
  520. bool m_bDragging;
  521. int m_xStart;
  522. int m_yStart;
  523. bool m_bUseBounds;
  524. int m_nMinX;
  525. int m_nMaxX;
  526. struct CFocusRect
  527. {
  528. RECT m_rcOrig;
  529. RECT m_rcFocus;
  530. };
  531. CUtlVector < CFocusRect > m_FocusRects;
  532. int m_nDragType;
  533. HCURSOR m_hPrevCursor;
  534. struct FLYOVER
  535. {
  536. CChoreoActorWidget *a;
  537. CChoreoChannelWidget *c;
  538. CChoreoEventWidget *e;
  539. CChoreoGlobalEventWidget *ge;
  540. int tag;
  541. CEventAbsoluteTag *at;
  542. int ccbutton;
  543. };
  544. FLYOVER m_Flyover;
  545. bool m_bCanDraw;
  546. struct CVUndo
  547. {
  548. CChoreoScene *undo;
  549. CChoreoScene *redo;
  550. char *udescription;
  551. char *rdescription;
  552. };
  553. CUtlVector< CVUndo * > m_UndoStack;
  554. int m_nUndoLevel;
  555. bool m_bRedoPending;
  556. bool m_bProcessSequences;
  557. float m_flLastMouseClickTime;
  558. bool m_bSuppressLayout;
  559. bool m_bRampOnly;
  560. float m_flScrubberTimeOffset;
  561. bool m_bShowCloseCaptionData;
  562. bool m_bForceProcess;
  563. // cached version of the local directory when a scene is loaded
  564. CUtlVector< CUtlString > m_nextFileList;
  565. };
  566. extern CChoreoView *g_pChoreoView;
  567. template< class T >
  568. void CChoreoView::SetPreservedTimeZoom( T *other, int tz )
  569. {
  570. POINT pt;
  571. ::GetCursorPos( &pt );
  572. ::ScreenToClient( (HWND)other->getHandle(), &pt );
  573. // Now figure out time under cursor at old zoom scale
  574. float t = other->GetTimeValueForMouse( pt.x, true );
  575. // Call CChoreoView's version
  576. SetTimeZoom( other->GetToolName(), tz, false );
  577. // Now figure out tie under pt.x
  578. float newT = other->GetTimeValueForMouse( pt.x, true );
  579. if ( newT != t )
  580. {
  581. // We need to scroll over a bit
  582. float pps = other->GetPixelsPerSecond();
  583. float movePixels = pps * ( newT - t );
  584. float newOffset = other->m_flLeftOffset - movePixels;
  585. if ( newOffset < 0.0f )
  586. {
  587. newOffset = 0;
  588. }
  589. float ed = other->GetEventEndTime();
  590. float flLastPixel = ed * pps;
  591. if ( newOffset + other->w2() > flLastPixel )
  592. {
  593. newOffset = flLastPixel - other->w2();
  594. }
  595. other->m_flLeftOffset = newOffset;
  596. other->m_pHorzScrollBar->setValue( (int)( other->m_flLeftOffset ) );
  597. }
  598. other->RepositionHSlider();
  599. }
  600. template< class T >
  601. int CChoreoView::HandleZoomKey( T *other, int keyCode )
  602. {
  603. int iret = 1;
  604. switch ( keyCode )
  605. {
  606. default:
  607. {
  608. iret = 0;
  609. }
  610. break;
  611. case VK_HOME:
  612. {
  613. other->MoveTimeSliderToPos( 0 );
  614. }
  615. break;
  616. case VK_END:
  617. {
  618. float maxtime = other->GetEventEndTime();
  619. int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
  620. other->MoveTimeSliderToPos( pixels );
  621. }
  622. break;
  623. case VK_PRIOR: // PgUp
  624. {
  625. int window = other->w2();
  626. other->m_flLeftOffset = max( other->m_flLeftOffset - (float)window, 0.0f );
  627. other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
  628. }
  629. break;
  630. case VK_NEXT: // PgDown
  631. {
  632. int window = other->w2();
  633. float maxtime = other->GetEventEndTime();
  634. int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
  635. other->m_flLeftOffset = min( other->m_flLeftOffset + (float)window, (float)pixels );
  636. other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
  637. }
  638. break;
  639. }
  640. return iret;
  641. }
  642. float SnapTime( float input, float granularity );
  643. class StudioModel;
  644. StudioModel *FindAssociatedModel( CChoreoScene *scene, CChoreoActor *a );
  645. #endif // CHOREOVIEW_H