Emergency 20 Dokumentation  4.2.0
CutscenePlayer.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <qsf/job/JobProxy.h>
17 #include <qsf/math/Color3.h>
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace em5
24 {
25  class SequencePlayer;
26 }
27 namespace qsf
28 {
29  class Entity;
30 }
31 
32 
33 //[-------------------------------------------------------]
34 //[ Namespace ]
35 //[-------------------------------------------------------]
36 namespace em5
37 {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Classes ]
42  //[-------------------------------------------------------]
47  class EM5_API_EXPORT CutscenePlayer : public boost::noncopyable
48  {
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public definitions ]
53  //[-------------------------------------------------------]
54  public:
55  enum class SkipSetting
56  {
57  DISABLED,
58  STOP,
59  FASTFORWARD
60  };
61 
62 
63  //[-------------------------------------------------------]
64  //[ Public methods ]
65  //[-------------------------------------------------------]
66  public:
72 
77  virtual ~CutscenePlayer();
78 
89  bool isPlaying() const;
90 
105  bool startCutscene(const std::string& sequenceLocalAssetName, bool movePlayerCamera, bool allowVideo = true, SkipSetting skipSetting = SkipSetting::STOP);
106 
111  void stopCutscene(bool emitMessage);
112 
117  void skipCutscene();
118 
126  bool reactToEscape();
127 
135  void showUserInterface(bool show);
136 
147  bool isScreenFading() const;
148 
165  void startScreenFade(float targetVisibility, const qsf::Time& fadeLength, const qsf::Color3& backgroundColor = qsf::Color3::BLACK, const qsf::Time& endPause = qsf::Time::ZERO);
166  void setScreenFade(float targetVisibility, const qsf::Color3& backgroundColor = qsf::Color3::BLACK);
167 
175  bool flyCameraTo(qsf::Entity& targetCameraEntity, float maximumAcceleration = 100.0f, float maximumSpeed = 25.0f);
176 
185  void startCameraFlight(qsf::Entity& targetCameraEntity, float maximumAcceleration = 100.0f, float maximumSpeed = 25.0f);
186 
187 
188  //[-------------------------------------------------------]
189  //[ Private methods ]
190  //[-------------------------------------------------------]
191  private:
192  void checkJobUpdateRegistration();
193  void setInputBlockedForCutscene(bool blocked);
194 
195  void movePlayheadToEnd(SequencePlayer& sequencePlayer);
196  void feedTextureStreamer(const std::string& sequenceLocalAssetName);
197 
198  // Job update
199  void updateRealtime(const qsf::JobArguments& jobArguments);
200 
201  // Message reactions
202  void onSequenceEnded(const qsf::MessageParameters& messageParameters);
203  void onSetCamera(const qsf::MessageParameters& messageParameters);
204  void onEndVideo(const qsf::MessageParameters& messageParameters);
205  void onCameraFlightStopped(const qsf::MessageParameters& parameters);
206 
207  void onScreenFadingDone();
208  void showGui();
209 
210  void setTimeOfDayToSequence(bool isInSequenceUpdate);
211 
212 
213  //[-------------------------------------------------------]
214  //[ Private data ]
215  //[-------------------------------------------------------]
216  private:
217  enum class Mode
218  {
219  NONE = 0,
220  PLAYING_VIDEO,
221  PLAYING_SEQUENCE,
222  ONE_FRAME_DUMMY,
223  SCREEN_FADE, // Includes "end pause" time after actual screen fade
224  CAMERA_FLIGHT
225  };
226  Mode mCurrentMode;
227  // TODO(fw): mCurrentMode was introduced after most variables below, so some of them are redundant now (e.g. mIsPlayingVideo, mDummyCutsceneRunning)
228 
229  bool mIsPlayingVideo;
230  bool mIsChronologicCacheClearingEnabled;
231  bool mPreviousSpawnCivilActive;
232  bool mSilentMode;
233 
234  // Sequence playback
235  SequencePlayer* mSequencePlayer;
236  bool mMovePlayerCamera;
237  bool mDummyCutsceneRunning;
238  SkipSetting mSkipSetting;
239 
240  // Screen fade out effect
241  float mScreenVisibilityTarget;
242  float mScreenVisibilityChangeRate;
243  qsf::Time mEndPause;
244 
245  // Proxies
246  qsf::JobProxy mRealtimeUpdateJobProxy;
247  qsf::MessageProxy mEndSequenceMessageProxy;
248  qsf::MessageProxy mSetCameraMessageProxy;
249  qsf::MessageProxy mEndVideoMessageProxy;
250  qsf::MessageProxy mCameraFlightStoppedMessageProxy;
251 
252 
253  //[-------------------------------------------------------]
254  //[ CAMP reflection system ]
255  //[-------------------------------------------------------]
256  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
257 
258 
259  };
260 
261 
262 //[-------------------------------------------------------]
263 //[ Namespace ]
264 //[-------------------------------------------------------]
265 } // em5
266 
267 
268 //[-------------------------------------------------------]
269 //[ CAMP reflection system ]
270 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
SkipSetting
Definition: CutscenePlayer.h:55
#define EM5_API_EXPORT
Definition: Export.h:28
Message listener proxy class.
Definition: MessageProxy.h:47
static const Time ZERO
A zero value for time.
Definition: Time.h:40
EMERGENCY 5 cutscene player.
Definition: CutscenePlayer.h:47
Color class with red, green and blue component.
Definition: Color3.h:30
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Definition: PickupPersonByParamedicAction.h:21
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
EMERGENCY 5 sequence player class.
Definition: SequencePlayer.h:45
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static const Color3 BLACK
Black (sRGB="0 0 0", Hex="#000000")
Definition: Color3.h:40
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32