wavelength 1.0.0
Loading...
Searching...
No Matches
sologamelogic.h
Go to the documentation of this file.
1#pragma once
2
3#include "game/catchtrack.h"
4#include "game/gamelogic.h"
5#include "game/juicemeter.h"
6#include "game/player.h"
7#include "game/song.h"
8#include "game/track.h"
9#include "met/metagame.h"
10#include "msg/message.h"
11#include "os/command.h"
12#include "os/ptr.h"
13#include "os/string.h"
14#include "script/dataarray.h"
15
25class SoloGameLogic : public GameLogic {
26public:
36
42 class CheckpointTextCmd : public Command {
43 public:
49 explicit CheckpointTextCmd(SoloGameLogic *pLogic) : mLogic(pLogic) {
50 }
51
58 ~CheckpointTextCmd() override {
59 }
60
67 void Execute() override;
68
69 private:
70 SoloGameLogic *mLogic;
71 };
72
85 SoloGameLogic(Song *pSong, DataArray *pConfig, int nSeed);
86
93 ~SoloGameLogic() override;
94
103 bool DispatchPriv(Message *pMsg) override;
104
112 int GetTick() override;
113
121 float GetTime() override;
122
124
132 void HandleInput(const PlayNoteEvent &event) override;
133
141 void HandleInput(const BtnEvent<3> &event) override;
142
150 void HandleInput(const StickEvent<2> &event) override;
151
159 void HandleInput(const StickEvent<6> &event) override;
160
170 void SetPaused(bool bPaused, int nPad, int nReason) override;
171
180 bool DeployFreestyle(Player *pPlayer) override;
181
188 void OnStart() override;
189
197 void OnFinish(bool bWon) override;
198
209 void OnBar(int nBar) override;
210
217 void OnSection() override;
218
229 void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak) override;
230
238 void OnPhraseEnded(Track *pTrack) override;
239
247 void OnPhraseMissed(Track *pTrack) override;
248
256
264
272
279 void WinNow();
280
288
296
304 void ResumeWithCue(bool bIntro);
305
313 void Restart(bool bRestartIntro);
314
323 static void OnPauseDialog(Metagame::DialogAction action, void *pUserData);
324
333 static void OnWinDialog(Metagame::DialogAction action, void *pUserData);
334
343 static void OnResultDialog(Metagame::DialogAction action, void *pUserData);
344
353 static void OnJuice(DataArray *pCommand, void *pUserData);
354
363 static void OnWinCheat(DataArray *pCommand, void *pUserData);
364
373 static void OnWinSequence(DataArray *pCommand, void *pUserData);
374
375private:
376 JuiceMeter mJuice;
377 Player *mPlayer;
378 int mTickOffset;
379 float mTimeOffset;
380 int mBankSlot;
381 String mSoloBankFile;
382 String mWinBankFile;
383 Ptr<Command> mFreezeCmd;
384 Ptr<Command> mRestartCmd;
385 Ptr<Command> mIntroCmd;
386 Ptr<Command> mSaveOrRetryCmd;
387 Ptr<CheckpointTextCmd> mCheckpointTextCmd;
388 Ptr<Command> mSwapMovieCmd;
389 float mIntroDuration;
390 int mPlayBars;
391 int mCapturedTracks;
392 int mFailingTrack;
393 float mPendingJuice;
394 float mCaptureJuice;
395 int mDialogOpen;
396 int mForceWinSequence;
397 int mWinSequenceStep;
398 int mFullMixBars;
399 int mBestStreak;
400 int mPossibleCaptureBars;
401};
Input event of a button press that names only the player.
Definition btnevent.h:15
Track whose phrases a player captures by playing them.
Definition catchtrack.h:33
Unit of work a Scheduler runs at a set time.
Definition command.h:13
Reference-counted array of script data nodes.
Definition dataarray.h:20
GameLogic(Song *pSong, DataArray *pConfig, int nSeed)
Construct the logic of a song.
void HandleInput(const RotateEvent &event) override
Move a playing player to the next or previous catch track.
Energy of a solo player, which falls while the player misses phrases and ends the song at 0.
Definition juicemeter.h:9
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
DialogAction
Choices a dialog reports to its callback.
Definition metagame.h:101
Input event that plays a note on one of the three gem buttons.
Definition playnoteevent.h:10
One participant in a song: the track the participant plays, the score, and the streak.
Definition player.h:19
Owner of one reference to an Attachment.
Definition ptr.h:16
void Execute() override
Show the localised "STAGE_COMPLETED" message with the number of the section.
~CheckpointTextCmd() override
Release the command.
Definition sologamelogic.h:58
CheckpointTextCmd(SoloGameLogic *pLogic)
Construct the command for a logic.
Definition sologamelogic.h:49
static void OnJuice(DataArray *pCommand, void *pUserData)
Run the "juice" script command, which adds its argument to the juice meter.
static void OnResultDialog(Metagame::DialogAction action, void *pUserData)
Act on the choice of the dialog of a lost song or of a practice song.
void DrainPendingJuice()
Take one unit from the pending juice for a bar of a phrase the player does not play.
int GetTick() override
Report the game tick, the song tick shifted by the restarts of the victory lap.
float GetTime() override
Report the game time, the song time shifted by the restarts of the victory lap.
static void OnPauseDialog(Metagame::DialogAction action, void *pUserData)
Act on the choice of the pause dialog.
WinSequenceStep
Steps of the campaign win sequence, the values of mWinSequenceStep.
Definition sologamelogic.h:28
@ kWinStepPrompt
Definition sologamelogic.h:33
@ kWinStepNextDifficulty
Definition sologamelogic.h:30
@ kWinStepNextCampaign
Definition sologamelogic.h:31
@ kWinStepDone
Definition sologamelogic.h:34
@ kWinStepFinalCampaign
Definition sologamelogic.h:32
@ kWinStepCampaign
Definition sologamelogic.h:29
void Restart(bool bRestartIntro)
Restart the song from the start of the next loop of the victory lap.
bool DispatchPriv(Message *pMsg) override
Handle a message sent to the logic.
void ResumeWithCue(bool bIntro)
Start the victory lap on the freestyle track.
void SaveOrRetry()
Show the result dialog once the display and the win sound bank are ready, or retry later.
void WinNow()
Win the song at once with a fixed score.
void OnStart() override
Fill the juice meter, show the controller display, and enable the first tracks.
void AdvanceWinSequence()
Show the next message of the campaign win sequence and schedule the one after.
void OnPhraseMissed(Track *pTrack) override
Lose the song when the phrase missed was the last chance, and commit the pending juice.
static void OnWinSequence(DataArray *pCommand, void *pUserData)
Run the "win_sequence" script command, which runs the win sequence after the next win.
void HandleInput(const PlayNoteEvent &event) override
Pass a played note on unless a dialog is open and the button is down.
void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak) override
Add the juice of a capture and count the bars the capture makes possible to capture.
void OnPhraseEnded(Track *pTrack) override
Uncount the captured track.
static void OnWinCheat(DataArray *pCommand, void *pUserData)
Run the "win_cheat" script command, which wins the song.
void FreezeAfterLoss()
Stop the song clock and the sound at the end of the slowdown of a lost song.
static void OnWinDialog(Metagame::DialogAction action, void *pUserData)
Act on the choice of the dialog of a won song.
~SoloGameLogic() override
Unregister the script commands and restore the song speed.
void HandleInput(const StickEvent< 6 > &event) override
Pass a stick event on unless a dialog is open.
bool DeployFreestyle(Player *pPlayer) override
Deploy the freestyle power-up and count the bars it makes possible to capture.
void SetPaused(bool bPaused, int nPad, int nReason) override
Pause the playing song and show the pause dialog, or resume it.
void CommitPendingJuice()
Add the pending juice to the meter unless a player is freestyling.
void OnFinish(bool bWon) override
Record the result of the song and start the victory lap or the loss.
SoloGameLogic(Song *pSong, DataArray *pConfig, int nSeed)
Construct the logic of a solo song.
void HandleInput(const StickEvent< 2 > &event) override
Pass a stick event on unless a dialog is open.
void OnSection() override
Win the song after the last section, or award the energy bonus of the section.
void HandleInput(const BtnEvent< 3 > &event) override
Act on a press of the start button, ending the victory lap or the win sequence.
void OnBar(int nBar) override
Drain the juice for the bar and end the song when the juice ran out.
One song: its configuration from the song text file and the tracks its MIDI file builds.
Definition song.h:38
Input event of an analog stick position.
Definition stickevent.h:15
Growable text buffer that is also a PrnStream.
Definition string.h:19
One instrument track of the song that a player can play.
Definition track.h:18