wavelength 1.0.0
Loading...
Searching...
No Matches
axetrack.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/axetrackdata.h"
8#include "game/playmap.h"
10#include "gs/axecontour.h"
11#include "gs/axeharmony.h"
12#include "gs/axer.h"
13#include "os/command.h"
14#include "os/mem.h"
15#include "os/ptr.h"
16
25class AxeTrack : public FreestyleTrack {
26public:
28 static constexpr int kNumAxers = AxeTrackData::kSetSize;
29
35 static void operator delete(void *pBlock) {
36 PoolMemFree(pBlock);
37 }
38
54 SectionBoundaries *pSections,
55 PlayMap *pPlayMap,
56 const float *pfMsPerTick,
57 int nIndex,
58 int nIntroBars,
59 int nNumBars,
60 int nTicksPerBar);
61
68 ~AxeTrack() override;
69
76 void Start() override;
77
84 void Stop() override;
85
93 void SetPlayer(Player *pPlayer) override;
94
96
105 void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override;
106
115 void HandleInput(Player *pPlayer, const StickEvent<2> &event) override;
116
125 void HandleInput([[maybe_unused]] Player *pPlayer,
126 [[maybe_unused]] const BtnEvent<10> &event) override {
127 }
128
136 bool IsActive() override {
137 return mActiveButton != kNoButton;
138 }
139
147 void Refresh() override;
148
149private:
150 int mTicksPerBar;
151 int mNumBars;
152 AxeTrackData *mData;
153 std::vector<std::unique_ptr<Axer>> mAxers;
154 int mActiveButton;
155 float mX;
156 float mY;
157 const AxeHarmony *mHarmony;
158 AxeContour *mContours[kNumAxers];
159 Ptr<Command> mHarmonyCommand;
160 Ptr<Command> mContourCommand;
161
162 static constexpr int kNoButton = -1;
163
173 void StartNote(int nButton, float fX, float fY);
174
181 void EndNote();
182
189 void UpdateHarmony();
190
197 void UpdateContours();
198};
The notes AxeTrack plays on a guitar track, looped over the length of the track.
Definition axecontour.h:19
The notes of one harmony of a guitar track, from one song position onward.
Definition axeharmony.h:13
The notes and chords of a guitar track, one set of each for each span of the song.
Definition axetrackdata.h:17
static constexpr int kSetSize
The number of gem buttons, each with the notes of one AxeContour.
Definition axetrackdata.h:20
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Start the note of a pressed gem button, or end it when the button is released.
void Refresh() override
Withdraw the scheduled commands and give the players the chord and the notes of the song position aga...
static constexpr int kNumAxers
The number of gem buttons, each with an Axer.
Definition axetrack.h:28
AxeTrack(AxeTrackData *pData, SectionBoundaries *pSections, PlayMap *pPlayMap, const float *pfMsPerTick, int nIndex, int nIntroBars, int nNumBars, int nTicksPerBar)
Construct a guitar track.
void HandleInput(Player *pPlayer, const StickEvent< 2 > &event) override
Move the held note with the stick.
void SetPlayer(Player *pPlayer) override
End the held note and give the track to the player it plays for.
void Start() override
Give the players the chord and the notes of the song position, and keep them updated.
bool IsActive() override
Report whether a gem button is held.
Definition axetrack.h:136
~AxeTrack() override
Stop the track and release its players.
void Stop() override
Withdraw the scheduled commands and stop every player.
void HandleInput(Player *pPlayer, const BtnEvent< 10 > &event) override
Ignore the input.
Definition axetrack.h:125
Input event of a button press that names only the player.
Definition btnevent.h:15
FreestyleTrack(const SectionBoundaries *pSections, PlayMap *pPlayMap, const float *pfMsPerTick, int nIndex, int nNumBars, int nTicksPerBar)
Construct a track.
void HandleInput(Player *pPlayer, const PlayNoteEvent &event) override
Send a note the track's player played, and start or stop the scoring of the time it sounds.
Map from the bars a song plays to the bars of the song as written, with the loops that repeat stretch...
Definition playmap.h:11
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
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Input event of an analog stick position.
Definition stickevent.h:15
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.