wavelength 1.0.0
Loading...
Searching...
No Matches
tutorialgamelogic.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "game/btnevent.h"
6#include "game/catchtrack.h"
7#include "game/gamelogic.h"
8#include "game/player.h"
10#include "game/playscriptcmd.h"
11#include "game/rotateevent.h"
12#include "game/song.h"
13#include "game/streamqueue.h"
14#include "game/track.h"
15#include "met/metagame.h"
16#include "msg/message.h"
17#include "os/command.h"
18#include "os/ptr.h"
19#include "os/serialtasks.h"
20#include "os/task.h"
21#include "os/taskdonenotifier.h"
22#include "script/dataarray.h"
23
37public:
45
57 TutorialGameLogic(Song *pSong, DataArray *pSongConfig);
58
67
76 bool DispatchPriv(Message *pMsg) override;
77
85 int GetTick() override;
86
94 float GetTime() override;
95
104 void Poll() override;
105
113 float GetProgress() override;
114
116
124 void HandleInput(const RotateEvent &event) override;
125
133 void HandleInput(const PlayNoteEvent &event) override;
134
142 void HandleInput(const BtnEvent<4> &event) override;
143
151 void HandleInput(const BtnEvent<5> &event) override;
152
162 void SetPaused(bool bPaused, int nPad, int nReason) override;
163
170 void OnStart() override;
171
179 void OnFinish([[maybe_unused]] bool bWon) override {
180 }
181
189 void OnBar(int nBar) override;
190
197 void OnSection() override {
198 }
199
210 void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak) override;
211
219 void OnPhraseEnded(Track *pTrack) override;
220
228 void OnPhraseMissed([[maybe_unused]] Track *pTrack) override {
229 }
230
241 void NotifyWhenDone(Task *pTask, const char *pszName) override;
242
253
261 void PlayScriptTrack(const char *pszName);
262
271 void QueueStream(const char *pszName, bool bSkipIfBusy);
272
282 void LoopTrack(int nStartBar, int nNumBars, int nBarsAhead);
283
291 void SetInputDisabled(bool bDisabled);
292
300 void SetRotateMode(int nMode);
301
309 void SetPowerupsDisabled(bool bDisabled);
310
320 void ActivateBars(int nBar, int nBars, int nTrack);
321
333 void ScheduleDeactivateTrack(int nBarsAhead, int nBar, int nBars);
334
342
350
360 void PlacePowerup(int nPowerup, int nTrack, int nBar);
361
369 void MoveTrack(int nTrack);
370
378 void SetAutopilot(bool bAutopilot);
379
387 void SetNoSeeker(bool bNoSeeker);
388
396 void SetManualEnableNext(bool bManual);
397
406 void SetSongPosParams(int nPlayedBars, int nTotalBars);
407
417 void ShowStreakArrow(int nTrack, int nBarsAhead, int nUnused);
418
427 void ScheduleSetJuice(int nBarsAhead, float fJuice);
428
436 void ScheduleStageComplete(int nBarsAhead);
437
445
446private:
447 SerialTasks mScript;
448 StreamQueue mStreams;
449 std::vector<Ptr<PlayScriptCmd> > mScriptCmds;
450 int mBar;
451 int mRotateMode;
452 int mInputDisabled;
453 float mProgressLength;
454 float mProgressOffset;
455 int mPowerupsDisabled;
456 int mManualEnableNext;
457 std::vector<Ptr<Command> > mDeactivators;
458 int mSavedNoCapture;
459 int mSavedNoDeactivate;
460 int mReserved548; // +0x548, not read or written by the class.
461 int mSavedStreaksEnabled;
462 int mSavedGuideTicks;
463 int mSavedStrandBars;
476 Task *CreateTask(DataArray *pStep);
477
486 static void OnDialog(Metagame::DialogAction action, void *pUserData);
487
496 static void OnMidiCommand(DataArray *pCommand, void *pUserData);
497
506 static void OnSchedDeactivateTrackCommand(DataArray *pCommand, void *pUserData);
507
516 static void OnStreamCommand(DataArray *pCommand, void *pUserData);
517
526 static void OnLoopTrackCommand(DataArray *pCommand, void *pUserData);
527
536 static void OnDisableRotCommand(DataArray *pCommand, void *pUserData);
537
546 static void OnDisableInputCommand(DataArray *pCommand, void *pUserData);
547
556 static void OnTutorialPrintCommand(DataArray *pCommand, void *pUserData);
557
566 static void OnDisablePowerupsCommand(DataArray *pCommand, void *pUserData);
567
576 static void OnActivateBarsCommand(DataArray *pCommand, void *pUserData);
577
586 static void OnSetSongPosParamsCommand(DataArray *pCommand, void *pUserData);
587
596 static void OnCaptureTrackCommand(DataArray *pCommand, void *pUserData);
597
606 static void OnCaptureAllTracksCommand(DataArray *pCommand, void *pUserData);
607
616 static void OnSetPowerupCommand(DataArray *pCommand, void *pUserData);
617
626 static void OnMoveTrackCommand(DataArray *pCommand, void *pUserData);
627
636 static void OnSetNoCaptureCommand(DataArray *pCommand, void *pUserData);
637
646 static void OnSetNoDeactivateCommand(DataArray *pCommand, void *pUserData);
647
656 static void OnSetNoSeekerCommand(DataArray *pCommand, void *pUserData);
657
666 static void OnSetNoStreaksCommand(DataArray *pCommand, void *pUserData);
667
676 static void OnSetStrandBarsCommand(DataArray *pCommand, void *pUserData);
677
686 static void OnShowStreakArrowCommand(DataArray *pCommand, void *pUserData);
687
696 static void OnSchedSetJuiceCommand(DataArray *pCommand, void *pUserData);
697
706 static void OnSetAutopilotCommand(DataArray *pCommand, void *pUserData);
707
716 static void OnSetManualEnableNextCommand(DataArray *pCommand, void *pUserData);
717
726 static void OnEnableNextCommand(DataArray *pCommand, void *pUserData);
727
736 static void OnSchedStageCompleteCommand(DataArray *pCommand, void *pUserData);
737
738#ifdef VIDEO_STANDARD_PAL
749 static void OnShowDemoMsgCommand(DataArray *pCommand, void *pUserData);
750#endif
751};
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
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.
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
Input event that rotates a player's view of the tracks by one track.
Definition rotateevent.h:11
Task that runs a list of tasks one after another.
Definition serialtasks.h:14
One song: its configuration from the song text file and the tracks its MIDI file builds.
Definition song.h:38
Queue of narration streams that plays one stream at a time.
Definition streamqueue.h:16
Object a task can ask to report when a named piece of work is done.
Definition taskdonenotifier.h:10
Unit of work an owner starts, polls until it reports that it is done, and stops.
Definition task.h:9
One instrument track of the song that a player can play.
Definition track.h:18
void SetNoSeeker(bool bNoSeeker)
Hide or show the seeker of the first player's track.
float GetProgress() override
Report how far the tutorial has played, from the span set_songpos_params sets.
void SetAutopilot(bool bAutopilot)
Turn on or off the automatic play of the first player's track.
void CaptureAllTracks()
Capture the phrase of the current bar on every catch track for the first player.
void EnableNext()
Enable the next catch tracks from the bar after the current one.
~TutorialGameLogic() override
Cancel the scheduled deactivations, restore the song speed, the game settings, and the controller bin...
void MoveTrack(int nTrack)
Move the first player to a catch track.
void OnSection() override
Ignore the start of a section.
Definition tutorialgamelogic.h:197
void NotifyWhenDone(Task *pTask, const char *pszName) override
Arrange for a task to learn when the commands of a track named "SCRIPT" ran out.
void CaptureTrack()
Capture the phrase of the recorded bar on the first player's track.
void SetPowerupsDisabled(bool bDisabled)
Disable or enable the power-ups.
void ShowStreakArrow(int nTrack, int nBarsAhead, int nUnused)
Point at the next phrase of a catch track from a number of bars after the clock's bar.
void SetRotateMode(int nMode)
Set the rotations that pass.
void ScheduleStageComplete(int nBarsAhead)
Schedule the stage completion display at the start of a later bar.
RotateMode
Values of mRotateMode, the disable_rot argument.
Definition tutorialgamelogic.h:39
@ kRotateModeNone
Definition tutorialgamelogic.h:42
@ kRotateModeNextOnly
Definition tutorialgamelogic.h:40
@ kRotateModeAll
Definition tutorialgamelogic.h:43
@ kRotateModePreviousOnly
Definition tutorialgamelogic.h:41
bool DispatchPriv(Message *pMsg) override
Report the type of a message and pass it to WorldLogic::DispatchPriv().
void HandleInput(const BtnEvent< 5 > &event) override
Deploy a power-up, unless the input or the power-ups are disabled.
void Poll() override
Advance the song, the steps, and the narration.
void SetInputDisabled(bool bDisabled)
Disable or enable the input.
bool IsPhraseAbsent()
Report whether no phrase of the first player's track plays at or after the current bar.
void HandleInput(const PlayNoteEvent &event) override
Pass a note, unless the input is disabled.
void ScheduleSetJuice(int nBarsAhead, float fJuice)
Schedule the first player's energy meter to change at the start of a later bar.
TutorialGameLogic(Song *pSong, DataArray *pSongConfig)
Construct the logic of the tutorial song with a random seed.
float GetTime() override
Report the song position on the song clock.
void HandleInput(const BtnEvent< 4 > &event) override
Ignore the event.
void OnBar(int nBar) override
Record the bar, unless it precedes bar 0.
void PlacePowerup(int nPowerup, int nTrack, int nBar)
Place a power-up in a bar of a catch track.
void SetManualEnableNext(bool bManual)
Leave the enabling of the next catch tracks to the script, or return it to the captures.
void OnPhraseCaptured(CatchTrack *pTrack, Player *pPlayer, int nBar, bool bStreak) override
Enable the next catch tracks, unless set_manual_enable_next asked for the script to do it.
int GetTick() override
Report the song position in ticks.
void PlayScriptTrack(const char *pszName)
Start the commands of a track named "SCRIPT" from the current tick.
void SetPaused(bool bPaused, int nPad, int nReason) override
Pause or resume the song and the narration, and show the pause menu while paused.
void OnPhraseMissed(Track *pTrack) override
Ignore a missed phrase.
Definition tutorialgamelogic.h:228
void QueueStream(const char *pszName, bool bSkipIfBusy)
Queue a narration stream.
void OnStart() override
Enable the first catch tracks and start the steps.
void SetSongPosParams(int nPlayedBars, int nTotalBars)
Set the span GetProgress() measures.
void ScheduleDeactivateTrack(int nBarsAhead, int nBar, int nBars)
Schedule the deactivation of a run of bars of the first player's track.
void LoopTrack(int nStartBar, int nNumBars, int nBarsAhead)
Loop a range of bars of the song from a number of bars after the recorded bar.
void OnPhraseEnded(Track *pTrack) override
Ignore the end of a phrase.
void HandleInput(const RotateEvent &event) override
Pass a rotation that mRotateMode allows, unless the input is disabled.
void OnFinish(bool bWon) override
Ignore the end of the song.
Definition tutorialgamelogic.h:179
void ActivateBars(int nBar, int nBars, int nTrack)
Give a run of bars of a catch track to the first player.