wavelength 1.0.0
Loading...
Searching...
No Matches
gfxarena.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <memory>
5#include <vector>
6
7#include "math/key.h"
8#include "os/asyncstream.h"
9#include "os/string.h"
10#include "rnd/rndanimatable.h"
11#include "rnd/rndenviron.h"
12#include "rnd/rndloader.h"
13#include "rnd/rndmat.h"
14#include "rnd/rndmatanim.h"
15#include "rnd/rndmovie.h"
16#include "rnd/rndtex.h"
17#include "rnd/rndtransanim.h"
18#include "rnd/rndview.h"
19#include "script/dataarray.h"
20
28class GfxArena {
29public:
31 struct MovieMat {
34 char mStage;
35 };
36
43
45 static constexpr int kNumMovies = 4;
46
48 static constexpr int kBeatMovie = 3;
49
51 typedef GfxArena *(*Creator)(const char *pszName);
52
62 explicit GfxArena(const char *pszName);
63
73 static GfxArena *Create(const char *pszName);
74
81 virtual ~GfxArena();
82
89 virtual void LoadConfig();
90
98 virtual void SetSongTicks(float fSongTicks);
99
108 virtual void Poll(float fTick, float fTime);
109
117
126 void PollLoad(bool bHudLoaded);
127
136
144
153 void SetEnergy(int nZone, float fEnergy);
154
162 void ShowResult(bool bWon);
163
171 void HandleBeat(signed char nEvent);
172
180
188 static float sLowEnergy;
189
191 const String &GetName() const {
192 return mName;
193 }
194
197 return mConfig;
198 }
199
201 void SetLoader(RndLoader *pLoader) {
202 mLoader = pLoader;
203 }
204
206 RndView *GetView() const {
207 return mView;
208 }
209
212 return mCamPath;
213 }
214
216 float GetSongTicks() const {
217 return mSongTicks;
218 }
219
221 float GetCamPathLength() const {
222 return mCamPathLength;
223 }
224
226 int GetUnlockIndex() const {
227 return mUnlockIndex;
228 }
229
232 return mEnviron;
233 }
234
236 float GetFreestyle() const {
237 return mFreestyle;
238 }
239
241 int GetTriggersLoaded() const {
242 return mTriggersLoaded;
243 }
244
247 return mTriggerStream.get();
248 }
249
250protected:
253
254private:
255 String mName;
256 int mLoaded;
257 int mTriggersLoaded;
258 std::unique_ptr<AsyncStream> mTriggerStream;
259 RndLoader *mLoader;
260 RndView *mView;
262 std::unique_ptr<RndView> mOwnedView;
264 RndTransAnim *mCamPath;
265 RndTex *mFrequencyTex;
266 float mFrameOffset;
267 float mLength;
268 float mSongTicks;
269 float mCamPathLength;
270 RndEnviron *mEnviron;
271 int mUnlockIndex;
272 std::vector<Key<float>> mFreestyleKeys;
273 float mFreestyle;
274 char mPanelFlags;
275 int mResultShown;
276 int mWon;
277 std::list<RndMatAnim *> mMatAnims;
278 std::list<MovieMat> mMovieMats;
279 std::vector<RndMovie *> mMovies;
280 float mBeatTick;
281 RndMovie *mSnow;
282
291 static void CollectMovieMats(RndTex *pTex, std::list<MovieMat> *pMats);
292
303 static void CollectMatAnims(RndTex *pTex, std::list<RndMatAnim *> *pAnims);
304
312 static void DetachAnim(RndAnimatable *pAnim);
313
322 void FitCamPath(RndTransAnim *pPath);
323
332 void SetPanelFlags(char nFlags, bool bOn);
333
342 static void ShowTexture(const MovieMat *pMat, RndTex *pTex);
343};
BinStream over a file read into a buffer in the background.
Definition asyncstream.h:16
Reference-counted array of script data nodes.
Definition dataarray.h:20
virtual ~GfxArena()
Destroy the arena.
RndEnviron * GetEnviron() const
Definition gfxarena.h:231
void SetLoader(RndLoader *pLoader)
Definition gfxarena.h:201
void ShowResult(bool bWon)
Show the result of the song on the panels.
static constexpr int kNumMovies
The number of movies of an arena, movie1.mov to movie4.mov.
Definition gfxarena.h:45
int GetTriggersLoaded() const
Definition gfxarena.h:241
AsyncStream * GetTriggerStream() const
Definition gfxarena.h:246
int GetUnlockIndex() const
Definition gfxarena.h:226
virtual void LoadConfig()
Read the configuration of the arena again, with its triggers from their file.
static float sLowEnergy
The energy at or below which the panels show snow, the second number of juice_blink_range.
Definition gfxarena.h:188
GfxArena(const char *pszName)
Construct the arena of a name from the arena_paths entry of the gfx configuration.
float GetSongTicks() const
Definition gfxarena.h:216
void HandleBeat(signed char nEvent)
Run the effect of a beat event of the song.
static GfxArena * Create(const char *pszName)
Create the arena of a name, through the first registered creator that accepts the name or as a plain ...
RndTransAnim * GetCamPath() const
Definition gfxarena.h:211
GfxArena *(* Creator)(const char *pszName)
A function that builds an arena of a name, or reports null when the name is not its own.
Definition gfxarena.h:51
void SetEnergy(int nZone, float fEnergy)
Show the energy of the play field on the panels, unless a won result is shown.
static Creator sCreators[]
The creators of derived arenas, up to a null entry.
Definition gfxarena.h:179
float mFrameScale
Definition gfxarena.h:252
PanelFlag
The bits of mPanelFlags, in order of precedence from the last.
Definition gfxarena.h:38
@ kPanelBeat
Definition gfxarena.h:40
@ kPanelFrequency
Definition gfxarena.h:41
@ kPanelLowEnergy
Definition gfxarena.h:39
const String & GetName() const
Definition gfxarena.h:191
void PollLoad(bool bHudLoaded)
Gather the objects of the arena once its file is read, and load the streamed triggers once they are r...
virtual void Poll(float fTick, float fTime)
Move the camera along its path, run the triggers, and animate the panels.
virtual void SetSongTicks(float fSongTicks)
Fit the camera path to the length of the song.
DataArray * GetConfig() const
Definition gfxarena.h:196
void ResetPanels()
Return the panels to their resting look.
void SetCamPath(RndTransAnim *pPath)
Set the camera path unless the arena found one.
RndView * GetView() const
Definition gfxarena.h:206
DataArray * mConfig
Definition gfxarena.h:251
void LoadTriggers()
Start to stream the triggers of the arena, or mark them loaded when the arena has none.
float GetCamPathLength() const
Definition gfxarena.h:221
static constexpr int kBeatMovie
The movie a beat plays.
Definition gfxarena.h:48
float GetFreestyle() const
Definition gfxarena.h:236
Mix-in for an object driven by a frame.
Definition rndanimatable.h:16
Lighting and fog environment, made current for the drawables after it when it is drawn.
Definition rndenviron.h:18
Loader of one .rnd file, which reads the file over several frames.
Definition rndloader.h:21
Surface description: blending, lighting colours, culling, and a list of texture stages.
Definition rndmat.h:20
Animation that plays a movie file into a texture.
Definition rndmovie.h:19
Texture, a bitmap loaded from a file or rendered to.
Definition rndtex.h:17
Animation of a transformable's local transform by rotation, translation, and scale keys.
Definition rndtransanim.h:20
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
Growable text buffer that is also a PrnStream.
Definition string.h:19
A material stage that shows the texture of a movie, 0xc bytes.
Definition gfxarena.h:31
RndTex * mTex
Definition gfxarena.h:33
char mStage
Definition gfxarena.h:34
RndMat * mMat
Definition gfxarena.h:32