Team Fortress 2 Source Code as on 22/4/2020
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.

832 lines
23 KiB

  1. //========= Copyright 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. /////////////////////////////////////////////////////////////////////////////
  112. // CChoreoView window
  113. class CChoreoScene;
  114. class CChoreoEvent;
  115. class CChoreoActor;
  116. class CChoreoChannel;
  117. class CChoreoActorWidget;
  118. class CChoreoChannelWidget;
  119. class CChoreoEventWidget;
  120. class CChoreoGlobalEventWidget;
  121. class CChoreoWidgetDrawHelper;
  122. class PhonemeEditor;
  123. class CExpression;
  124. class CExpClass;
  125. class StudioModel;
  126. //-----------------------------------------------------------------------------
  127. // Purpose: The main view of the choreography data for a scene
  128. //-----------------------------------------------------------------------------
  129. class CChoreoView : public mxWindow, public IFacePoserToolWindow, public IChoreoEventCallback
  130. {
  131. // Construction
  132. public:
  133. CChoreoView( mxWindow *parent, int x, int y, int w, int h, int id );
  134. virtual ~CChoreoView();
  135. virtual void OnModelChanged();
  136. virtual void OnDelete();
  137. virtual bool CanClose();
  138. void InvalidateTrackLookup( void );
  139. // Implements IChoreoEventCallback
  140. virtual void StartEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  141. virtual void EndEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  142. virtual void ProcessEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  143. virtual bool CheckEvent( float currenttime, CChoreoScene *scene, CChoreoEvent *event );
  144. void SetChoreoFile( char const *filename );
  145. char const *GetChoreoFile( void ) const;
  146. // Scene load/unload
  147. void LoadSceneFromFile( const char *filename );
  148. CChoreoScene *LoadScene( char const *filename );
  149. void UnloadScene( void );
  150. // UI
  151. void New( void );
  152. void Save( void );
  153. void SaveAs( void );
  154. void Load( void );
  155. void LoadNext( void );
  156. bool Close( void );
  157. // Drag/drop from expression thumbnail
  158. bool CreateExpressionEvent( int mx, int my, CExpClass *cl, CExpression *exp );
  159. bool CreateAnimationEvent( int mx, int my, char const *animationname );
  160. void SelectAll( void );
  161. void DeselectAll( void );
  162. struct SelectionParams_t
  163. {
  164. enum
  165. {
  166. SP_CHANNEL = 0,
  167. SP_ACTIVE,
  168. SP_ALL
  169. };
  170. float time;
  171. bool forward;
  172. int type;
  173. };
  174. void SelectEvents( SelectionParams_t& params );
  175. // Channel/actor right click menu
  176. void NewChannel( void );
  177. void DeleteChannel( CChoreoChannel *channel );
  178. void MoveChannelUp( CChoreoChannel *channel );
  179. void MoveChannelDown( CChoreoChannel *channel );
  180. void EditChannel( CChoreoChannel *channel );
  181. void AddEvent( int type, int subtype = 0, char const *defaultparameters = NULL );
  182. // Actor right click menu
  183. void NewActor( void );
  184. void DeleteActor( CChoreoActor *actor );
  185. void MoveActorUp( CChoreoActor *actor );
  186. void MoveActorDown( CChoreoActor *actor );
  187. void EditActor( CChoreoActor *actor );
  188. // Event menu
  189. void EditEvent( CChoreoEvent *event );
  190. void DeleteSelectedEvents( void );
  191. void EnableSelectedEvents( bool state );
  192. void DeleteEventRelativeTag( CChoreoEvent *event, int tagnum );
  193. void AddEventRelativeTag( void );
  194. CChoreoEventWidget *FindWidgetForEvent( CChoreoEvent *event );
  195. CChoreoChannelWidget *FindChannelForEvent( CChoreoEvent *event );
  196. void MoveEventToBack( CChoreoEvent *event );
  197. void OnExpressionTool( void );
  198. void OnGestureTool( void );
  199. // Global event ( pause ) menu
  200. void EditGlobalEvent( CChoreoEvent *event );
  201. void DeleteGlobalEvent( CChoreoEvent *event );
  202. void AddGlobalEvent( CChoreoEvent::EVENTTYPE type );
  203. void AssociateBSP( void );
  204. void AssociateModel( void );
  205. void AssociateModelToActor( CChoreoActor *actor, int modelindex );
  206. // UI Layout
  207. void CreateSceneWidgets( void );
  208. void DeleteSceneWidgets( void );
  209. void LayoutScene( void );
  210. void InvalidateLayout( void );
  211. void ForceScrollBarsToRecompute( bool resetthumb );
  212. // Layout data that children should obey
  213. int GetLabelWidth( void );
  214. int GetStartRow( void );
  215. int GetRowHeight( void );
  216. int GetFontSize( void );
  217. int GetEndRow( void );
  218. // Simulation
  219. void PlayScene( bool forward );
  220. void PauseScene( void );
  221. bool IsPlayingScene( void );
  222. void ResetTargetSettings( void );
  223. void UpdateCurrentSettings( void );
  224. virtual void Think( float dt );
  225. virtual bool IsScrubbing( void ) const;
  226. virtual bool IsProcessing( void );
  227. bool ShouldProcessSpeak( void );
  228. void SceneThink( float time );
  229. void PauseThink( void );
  230. void FinishSimulation( void );
  231. void StopScene();
  232. float GetStartTime( void );
  233. float GetEndTime( void );
  234. void SetStartTime( float time );
  235. void ProcessExpression( CChoreoScene *scene, CChoreoEvent *event );
  236. void ProcessFlexAnimation( CChoreoScene *scene, CChoreoEvent *event );
  237. void ProcessLookat( CChoreoScene *scene, CChoreoEvent *event );
  238. bool GetTarget( CChoreoScene *scene, CChoreoEvent *event, Vector &vecTarget, QAngle &vecAngle );
  239. void ProcessFace( CChoreoScene *scene, CChoreoEvent *event );
  240. void ProcessGesture( CChoreoScene *scene, CChoreoEvent *event );
  241. void ProcessSequence( CChoreoScene *scene, CChoreoEvent *event );
  242. void ProcessMoveto( CChoreoScene *scene, CChoreoEvent *event );
  243. int GetMovetoSequence( CChoreoScene *scene, CChoreoEvent *event, StudioModel *model );
  244. void ProcessSubscene( CChoreoScene *scene, CChoreoEvent *event );
  245. void ProcessPause( CChoreoScene *scene, CChoreoEvent *event );
  246. void ProcessSpeak( CChoreoScene *scene, CChoreoEvent *event );
  247. void ProcessLoop( CChoreoScene *scene, CChoreoEvent *event );
  248. void ProcessInterrupt( CChoreoScene *scene, CChoreoEvent *event );
  249. void ProcessPermitResponses( CChoreoScene *scene, CChoreoEvent *event );
  250. float GetPixelsPerSecond( void );
  251. // mxWindow overrides
  252. virtual void redraw();
  253. virtual bool PaintBackground( void );
  254. virtual int handleEvent( mxEvent *event );
  255. // Draw helpers
  256. void DrawSceneABTicks( CChoreoWidgetDrawHelper& drawHelper );
  257. void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
  258. void DrawBackground( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  259. void DrawRelativeTagLines( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  260. // Remap click position to/from time value
  261. float GetTimeValueForMouse( int mx, bool clip = false );
  262. int GetPixelForTimeValue( float time, bool *clipped = NULL );
  263. float GetTimeDeltaForMouseDelta( int mx, int origmx );
  264. // Readjust slider
  265. void MoveTimeSliderToPos( int x );
  266. // Dirty flag for file save prompting
  267. bool GetDirty( void );
  268. void SetDirty( bool dirty, bool clearundo = true );
  269. void ShowContextMenu( int mx, int my );
  270. // Caller must first translate mouse into screen coordinates
  271. bool IsMouseOverTimeline( int mx, int my );
  272. CChoreoActorWidget *GetActorUnderCursorPos( int mx, int my );
  273. CChoreoChannelWidget *GetChannelUnderCursorPos( int mx, int my );
  274. CChoreoEventWidget *GetEventUnderCursorPos( int mx, int my );
  275. CChoreoGlobalEventWidget *GetGlobalEventUnderCursorPos( int mx, int my );
  276. int GetTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
  277. CEventAbsoluteTag *GetAbsoluteTagUnderCursorPos( CChoreoEventWidget *event, int mx, int my );
  278. void GetObjectsUnderMouse( int mx, int my,
  279. CChoreoActorWidget **actor,
  280. CChoreoChannelWidget **channel,
  281. CChoreoEventWidget **event,
  282. CChoreoGlobalEventWidget **globalevent,
  283. int* clickedTag,
  284. CEventAbsoluteTag **absolutetag,
  285. int *clickedCCButton );
  286. void OnDoubleClicked( void );
  287. void ApplyBounds( int& mx, int& my );
  288. void CalcBounds( int movetype );
  289. void MouseStartDrag( mxEvent *event, int mx, int my );
  290. void MouseContinueDrag( mxEvent *event, int mx, int my );
  291. void MouseFinishDrag( mxEvent *event, int mx, int my );
  292. void MouseMove( int mx, int my );
  293. //void StartDraggingGlobalEvent( int mx, int my );
  294. void StartDraggingEvent( int mx, int my );
  295. //void FinishDraggingGlobalEvent( int mx, int my );
  296. void FinishDraggingEvent( mxEvent *event, int mx, int my );
  297. // Draw focus rect while mouse dragging is going on
  298. void DrawFocusRect( void );
  299. int ComputeEventDragType( int mx, int my );
  300. void SetCurrentWaveFile( const char *filename, CChoreoEvent *event );
  301. void RecomputeWaves();
  302. typedef void (CChoreoView::*CVMEMBERFUNC)( CChoreoWidget *widget, CChoreoWidget *param1 );
  303. void TraverseWidgets( CVMEMBERFUNC pfn, CChoreoWidget *param1 );
  304. int CountSelectedEvents( void );
  305. int CountSelectedGlobalEvents( void );
  306. int GetSelectedEvents( CUtlVector< CChoreoEvent * >& events );
  307. int GetSelectedEventWidgets( CUtlVector< CChoreoEventWidget * >& events );
  308. int GetEarliestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
  309. int GetLatestEventIndex( CUtlVector< CChoreoEventWidget * >& events );
  310. // Traversal functions
  311. void Deselect( CChoreoWidget *widget, CChoreoWidget *param1 );
  312. void Select( CChoreoWidget *widget, CChoreoWidget *param1 );
  313. void SelectInActor( CChoreoWidget *widget, CChoreoWidget *param1 );
  314. void SelectInChannel( CChoreoWidget *widget, CChoreoWidget *param1 );
  315. void SelectAllEvents( CChoreoWidget *widget, CChoreoWidget *param1 );
  316. void SelectAllEventsInActor( CChoreoActorWidget *actor );
  317. void SelectAllEventsInChannel( CChoreoChannelWidget *channel );
  318. // Adjust scroll bars
  319. void RepositionVSlider( void );
  320. void RepositionHSlider( void );
  321. void UpdateStatusArea( int mx, int my );
  322. void ClearStatusArea( void );
  323. void RedrawStatusArea( CChoreoWidgetDrawHelper& drawHelper, RECT& rcStatus );
  324. void GetUndoLevels( int& current, int& number );
  325. // Undo/Redo
  326. void Undo( void );
  327. void Redo( void );
  328. bool CanUndo();
  329. bool CanRedo();
  330. // Do push before changes
  331. void PushUndo( const char *description );
  332. // Do this push after changes, must match pushundo 1for1
  333. void PushRedo( const char *description );
  334. void WipeUndo( void );
  335. void WipeRedo( void );
  336. const char *GetUndoDescription( void );
  337. const char *GetRedoDescription( void );
  338. CChoreoScene *GetScene( void );
  339. void ReportSceneClearToTools( void );
  340. void CopyEvents( void );
  341. void PasteEvents( void );
  342. void ImportEvents( void );
  343. void ExportEvents( void );
  344. void ExportVCD();
  345. void ImportVCD();
  346. void ExportVCDFile( char const *filename );
  347. void ImportVCDFile( char const *filename );
  348. bool CanPaste( void );
  349. bool IsMouseOverScrubHandle( mxEvent *event );
  350. bool IsMouseOverScrubArea( mxEvent *event );
  351. void GetScrubHandleRect( RECT& rcHandle, bool clipped = false );
  352. void GetScrubAreaRect( RECT& rcArea );
  353. void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper );
  354. void DrawScrubHandle( void );
  355. void ScrubThink( float dt, bool scrubbing, IFacePoserToolWindow *invoker );
  356. void ClampTimeToSelectionInterval( float& timeval );
  357. void SetScrubTime( float t );
  358. void SetScrubTargetTime( float t );
  359. void OnCheckSequenceLengths( void );
  360. bool IsRampOnly( void ) const;
  361. void SetTimeZoom( const char *tool, int tz, bool preserveFocus );
  362. int GetTimeZoom( const char *tool );
  363. template< class T >
  364. void SetPreservedTimeZoom( T *other, int tz );
  365. template< class T >
  366. int HandleZoomKey( T *other, int keyCode );
  367. void OnInsertTime();
  368. void OnDeleteTime();
  369. bool GetShowCloseCaptionData( void ) const;
  370. bool ValidateCombinedSoundCheckSum( CChoreoEvent *e );
  371. void OnPlaceNextSpeakEvent();
  372. private:
  373. void CheckInsertTime( CChoreoEvent *e, float dt, float starttime, float endtime );
  374. void CheckDeleteTime( CChoreoEvent *d, float dt, float starttime, float endtime, bool& deleteEvent );
  375. bool FixupSequenceDurations( CChoreoScene *scene, bool checkonly );
  376. bool CheckSequenceLength( CChoreoEvent *e, bool checkonly );
  377. bool CheckGestureLength( CChoreoEvent *e, bool checkonly );
  378. bool DefaultGestureLength( CChoreoEvent *e, bool checkonly );
  379. bool AutoaddGestureKeys( CChoreoEvent *e, bool checkonly );
  380. void InvalidateTrackLookup_R( CChoreoScene *scene );
  381. void ShowButtons( bool show );
  382. // Compute full size of data in pixels, for setting up scroll bars
  383. int ComputeVPixelsNeeded( void );
  384. int ComputeHPixelsNeeded( void );
  385. void PositionControls();
  386. void OnChangeScale();
  387. float FindNextEventTime( CChoreoEvent::EVENTTYPE type, CChoreoChannel *channel, CChoreoEvent *e, bool forward );
  388. bool ShouldSelectEvent( SelectionParams_t &params, CChoreoEvent *event );
  389. bool IsMouseOverSceneEndTime( int mx );
  390. void StartDraggingSceneEndTime( int mx, int my );
  391. void FinishDraggingSceneEndTime( mxEvent *event, int mx, int my );
  392. void SetShowCloseCaptionData( bool show );
  393. void OnToggleCloseCaptionTags();
  394. void OnCombineSpeakEvents();
  395. void OnRemoveSpeakEventFromGroup();
  396. void OnChangeCloseCaptionToken( CChoreoEvent *e );
  397. bool AreSelectedEventsCombinable();
  398. bool AreSelectedEventsInSpeakGroup();
  399. void OnToggleCloseCaptionsForEvent();
  400. bool GenerateCombinedFile( char const *outfilename, const char *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
  401. bool ValidateCombinedFileCheckSum( char const *outfilename, char const *cctoken, gender_t gender, CUtlRBTree< CChoreoEvent * >& sorted );
  402. void RememberSelectedEvents( CUtlVector< CChoreoEvent * >& list );
  403. void ReselectEvents( CUtlVector< CChoreoEvent * >& list );
  404. void OnAlign( bool left );
  405. void OnMakeSameSize( bool smallest );
  406. bool IsMouseOverEventEdge( CChoreoEventWidget *ew, bool bLeftEdge, int mx, int my );
  407. bool IsMouseOverEvent( CChoreoEventWidget *ew, int mx, int my );
  408. typedef struct
  409. {
  410. bool active;
  411. float time;
  412. } SCENEAB;
  413. void PlaceABPoint( int mx );
  414. void ClearABPoints( void );
  415. SCENEAB m_rgABPoints[ 2 ];
  416. int m_nCurrentABPoint;
  417. bool m_bForward;
  418. // The underlying scene we are editing
  419. CChoreoScene *m_pScene;
  420. enum
  421. {
  422. MAX_ACTORS = 32
  423. };
  424. typedef struct
  425. {
  426. bool expanded;
  427. } ACTORSTATE;
  428. ACTORSTATE m_ActorExpanded[ MAX_ACTORS ];
  429. // The scene's ui actors
  430. CUtlVector < CChoreoActorWidget * > m_SceneActors;
  431. // The scenes segment markers
  432. CUtlVector < CChoreoGlobalEventWidget * > m_SceneGlobalEvents;
  433. // How many pixels per second we are showing in the UI
  434. float m_flPixelsPerSecond;
  435. // Do we need to move controls?
  436. bool m_bLayoutIsValid;
  437. // Starting row of first actor
  438. int m_nStartRow;
  439. // How wide the actor/channel name area is
  440. int m_nLabelWidth;
  441. // Height between channel/actor names
  442. int m_nRowHeight;
  443. // Font size for drawing event labels
  444. int m_nFontSize;
  445. // Height/width of scroll bars
  446. int m_nScrollbarHeight;
  447. // Height off info area for flyover info / help
  448. int m_nInfoHeight;
  449. // Simulation info
  450. float m_flStartTime;
  451. float m_flEndTime;
  452. float m_flFrameTime;
  453. bool m_bSimulating;
  454. bool m_bPaused;
  455. float m_flLastSpeedScale;
  456. bool m_bResetSpeedScale;
  457. bool m_bAutomated;
  458. int m_nAutomatedAction;
  459. float m_flAutomationDelay;
  460. float m_flAutomationTime;
  461. // Some rectangles for the UI
  462. RECT m_rcTitles;
  463. RECT m_rcTimeLine;
  464. // Play/pause buttons for simulation
  465. mxBitmapButton *m_btnPlay;
  466. mxBitmapButton *m_btnPause;
  467. mxBitmapButton *m_btnStop;
  468. mxSlider *m_pPlaybackRate;
  469. float m_flPlaybackRate;
  470. // The scroll bars
  471. mxScrollbar *m_pVertScrollBar;
  472. mxScrollbar *m_pHorzScrollBar;
  473. int m_nLastHPixelsNeeded;
  474. int m_nLastVPixelsNeeded;
  475. // Current sb values
  476. int m_nTopOffset;
  477. float m_flLeftOffset;
  478. // Need save?
  479. bool m_bDirty;
  480. // Currently loaded scene file
  481. char m_szChoreoFile[ 256 ];
  482. CChoreoActorWidget *m_pClickedActor;
  483. CChoreoChannelWidget *m_pClickedChannel;
  484. CChoreoEventWidget *m_pClickedEvent;
  485. CChoreoGlobalEventWidget *m_pClickedGlobalEvent;
  486. // Relative to the clicked event
  487. int m_nClickedTag;
  488. CEventAbsoluteTag *m_pClickedAbsoluteTag;
  489. int m_nSelectedEvents;
  490. int m_nClickedX, m_nClickedY;
  491. int m_nClickedChannelCloseCaptionButton;
  492. // For mouse dragging
  493. // How close to right or left edge the mouse has to be before the wider/shorten
  494. // cursor shows up
  495. enum
  496. {
  497. DRAG_EVENT_EDGE_TOLERANCE = 5,
  498. };
  499. // When dragging, what time of action is being performed
  500. enum
  501. {
  502. DRAGTYPE_NONE = 0,
  503. DRAGTYPE_EVENT_MOVE,
  504. DRAGTYPE_EVENT_STARTTIME,
  505. DRAGTYPE_EVENT_STARTTIME_RESCALE,
  506. DRAGTYPE_EVENT_ENDTIME,
  507. DRAGTYPE_EVENT_ENDTIME_RESCALE,
  508. DRAGTYPE_EVENTTAG_MOVE,
  509. DRAGTYPE_EVENTABSTAG_MOVE,
  510. DRAGTYPE_SCRUBBER,
  511. DRAGTYPE_SCENE_ENDTIME,
  512. DRAGTYPE_RESCALELEFT,
  513. DRAGTYPE_RESCALERIGHT,
  514. };
  515. float m_flScrub;
  516. float m_flScrubTarget;
  517. bool m_bDragging;
  518. int m_xStart;
  519. int m_yStart;
  520. bool m_bUseBounds;
  521. int m_nMinX;
  522. int m_nMaxX;
  523. struct CFocusRect
  524. {
  525. RECT m_rcOrig;
  526. RECT m_rcFocus;
  527. };
  528. CUtlVector < CFocusRect > m_FocusRects;
  529. int m_nDragType;
  530. HCURSOR m_hPrevCursor;
  531. struct FLYOVER
  532. {
  533. CChoreoActorWidget *a;
  534. CChoreoChannelWidget *c;
  535. CChoreoEventWidget *e;
  536. CChoreoGlobalEventWidget *ge;
  537. int tag;
  538. CEventAbsoluteTag *at;
  539. int ccbutton;
  540. };
  541. FLYOVER m_Flyover;
  542. bool m_bCanDraw;
  543. struct CVUndo
  544. {
  545. CChoreoScene *undo;
  546. CChoreoScene *redo;
  547. char *udescription;
  548. char *rdescription;
  549. };
  550. CUtlVector< CVUndo * > m_UndoStack;
  551. int m_nUndoLevel;
  552. bool m_bRedoPending;
  553. bool m_bProcessSequences;
  554. float m_flLastMouseClickTime;
  555. bool m_bSuppressLayout;
  556. bool m_bRampOnly;
  557. float m_flScrubberTimeOffset;
  558. bool m_bShowCloseCaptionData;
  559. bool m_bForceProcess;
  560. // cached version of the local directory when a scene is loaded
  561. CUtlVector< CUtlString > m_nextFileList;
  562. };
  563. extern CChoreoView *g_pChoreoView;
  564. template< class T >
  565. void CChoreoView::SetPreservedTimeZoom( T *other, int tz )
  566. {
  567. POINT pt;
  568. ::GetCursorPos( &pt );
  569. ::ScreenToClient( (HWND)other->getHandle(), &pt );
  570. // Now figure out time under cursor at old zoom scale
  571. float t = other->GetTimeValueForMouse( pt.x, true );
  572. // Call CChoreoView's version
  573. SetTimeZoom( other->GetToolName(), tz, false );
  574. // Now figure out tie under pt.x
  575. float newT = other->GetTimeValueForMouse( pt.x, true );
  576. if ( newT != t )
  577. {
  578. // We need to scroll over a bit
  579. float pps = other->GetPixelsPerSecond();
  580. float movePixels = pps * ( newT - t );
  581. float newOffset = other->m_flLeftOffset - movePixels;
  582. if ( newOffset < 0.0f )
  583. {
  584. newOffset = 0;
  585. }
  586. float ed = other->GetEventEndTime();
  587. float flLastPixel = ed * pps;
  588. if ( newOffset + other->w2() > flLastPixel )
  589. {
  590. newOffset = flLastPixel - other->w2();
  591. }
  592. other->m_flLeftOffset = newOffset;
  593. other->m_pHorzScrollBar->setValue( (int)( other->m_flLeftOffset ) );
  594. }
  595. other->RepositionHSlider();
  596. }
  597. template< class T >
  598. int CChoreoView::HandleZoomKey( T *other, int keyCode )
  599. {
  600. int iret = 1;
  601. switch ( keyCode )
  602. {
  603. default:
  604. {
  605. iret = 0;
  606. }
  607. break;
  608. case VK_HOME:
  609. {
  610. other->MoveTimeSliderToPos( 0 );
  611. }
  612. break;
  613. case VK_END:
  614. {
  615. float maxtime = other->GetEventEndTime();
  616. int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
  617. other->MoveTimeSliderToPos( pixels );
  618. }
  619. break;
  620. case VK_PRIOR: // PgUp
  621. {
  622. int window = other->w2();
  623. other->m_flLeftOffset = max( other->m_flLeftOffset - (float)window, 0.0f );
  624. other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
  625. }
  626. break;
  627. case VK_NEXT: // PgDown
  628. {
  629. int window = other->w2();
  630. float maxtime = other->GetEventEndTime();
  631. int pixels = max( 0, (int)( maxtime * other->GetPixelsPerSecond() ) - other->w2() );
  632. other->m_flLeftOffset = min( other->m_flLeftOffset + (float)window, (float)pixels );
  633. other->MoveTimeSliderToPos( (int)other->m_flLeftOffset );
  634. }
  635. break;
  636. }
  637. return iret;
  638. }
  639. float SnapTime( float input, float granularity );
  640. class StudioModel;
  641. StudioModel *FindAssociatedModel( CChoreoScene *scene, CChoreoActor *a );
  642. #endif // CHOREOVIEW_H