resonance 1.0.1
Loading...
Searching...
No Matches
phrasemgr.h
Go to the documentation of this file.
1#pragma once
2
3#include "app/msgsink.h"
4#include "app/msgsource.h"
5#include "mid/tick.h"
7#include "msg/message.h"
8#include "msg/phrasepacket.h"
9#include "sch/cmdid.h"
10
11class Phrase;
12class PhraseDatabase;
13class PhrasePlayer;
14class Player;
15class PowerbarMgr;
16class PlayMap;
17class TrackData;
18
19namespace Sch {
20class TickClock;
21} // namespace Sch
22
51class PhraseMgr : public MsgSink, public MsgSource {
52 // ScoreTrackGraph::GetPhraseDatabase() at 0x001cf978 reads mDatabase directly, the Catcher
53 // constructor at 0x001aba30 copies mBarTicks, PhrasePlayer maps a bar through mMap (at
54 // `0x001c1a28`), and PhraseEraser divides by mBarTicks at 0x001b9a8c. The three Pitcher
55 // subclasses copy mBarTicks in their constructors (0x001b1ea4, 0x001cfb00, 0x001d8330). The
56 // CatchingSTG constructor at 0x0019fb80 writes mExportLead.
57 friend class Catcher;
58 friend class CatchingSTG;
59 friend class NotePitcher;
60 friend class PhraseEraser;
61 friend class PhrasePlayer;
62 friend class ScoreTrackGraph;
63 friend class Scratcher;
64 friend class Voxer;
65
66public:
84 int nBarTicks,
85 PlayMap *pMap,
86 int nConfig,
87 const TrackData *pTrackData);
88
95 virtual ~PhraseMgr();
96
109
116 int GetPowerbar(int nBar);
117
127 void PostPhraseMsg(int nPhrase);
128
141 void PostGemMsg(Message *pMsg);
142
152 void PostGemMsgSecond(int nBar);
153
166 void PostGemMsgThird(int nBar, int bGhost);
167
180 void PostDurGemMsg(int nBar);
181
196 void RefreshBar(int nBar, int bClear);
197
208 void PostBarStatusMsg(int nBar);
209
219 void OnCommand(int nBar);
220
231 void OnExportCommand(int nBar);
232
239 Phrase *GetPhraseAt(int nBar);
240
247 long long *GetStepValue(int nBar);
248
255 unsigned char GetPhraseByte(int nBar);
256
266 void SetPhraseByte(int nBar, char cValue);
267
275 void ResetOwners(Player *pPlayer);
276
286
293 int TickToBar(int nTick);
294
301 int BarToTick(int nBar);
302
317 int PhrasesMatch(int nFirstBar, int nSecondBar);
318
329 void ReplayBar(int nBar, int nOffset);
330
344 void InstallPhrase(Phrase *pPhrase, int nBar, int bRefresh);
345
360 void ClearPhrase(int nBar, int bAll);
361
375
386
409 void AddGem(int nGem, int nTrans, int nBar, int nTick, Player *pOwner, int bPost);
410
418
432
444
458
468 Player *GetOwner(int nBar) const;
469
485 void SetPhraseOwner(Player *pPlayer, int nBar);
486
496
508
509protected:
522 virtual void DispatchPriv(Message *pMsg);
523
524private:
525 // Post again, with its gems cleared, the first window bar that mMap maps to a step.
526 // OnCaughtPhrasePacket() and OnPhrasePacket() expand it.
527 void RefreshWindowBarOfStep(int nStep);
528
529 const TrackData *mTrackData; // +0x20
530 // Created by the constructor over mMap, deleted by the destructor, and the object
531 // PostPhraseMsg() and three DispatchPriv() paths look a phrase up in.
532 PhraseDatabase *mDatabase; // +0x24
533 PlayMap *mMap; // +0x28
534 // Created by CreatePowerbarMgr() and deleted by the destructor.
535 PowerbarMgr *mPowerbarMgr; // +0x2c
536 // Copied from the track description's `+0x04`. The track this manager serves. A PhrasePacket's
537 // `+0x14` is matched against it, and PostPhraseMsg() copies it into the message's `+0x08`.
538 int mTrack; // +0x30
539 int mBarTicks; // +0x34
540 int mConfig; // +0x38
541 int mWindowStart; // +0x3c, the first bar RefreshBar() posts
542 int mWindowEnd; // +0x40, the bar RefreshBar() stops before
543 int mRefreshing; // +0x44, set while RefreshAllBars() and OnExportCommand() post bars
544 Sch::Tick mExportLead; // +0x48, from the start of a bar to its ExportCmd
545 Sch::TickClock *mClock; // +0x4c
546 Sch::CmdID mCommand; // +0x50, the handle of the file-local Cmd
547 Sch::CmdID mExportCommand; // +0x54, the handle of the file-local ExportCmd
548 int mTrackKind; // +0x58, a TrackMode copied from TrackData::mKind
549 int mPlayMode; // +0x5c, the play mode Globals reported at construction
550};
Event the game passes between a MsgSource and a MsgSink.
Definition invalidatetrackmsg.h:22
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:41
Receiver of engine messages.
Definition msgsink.h:37
Sender of engine messages, which stores the list of sinks that receive them.
Definition msgsource.h:26
Store of one phrase per step of a play map, and one jam effect mask per step.
Definition phrasedatabase.h:29
friend class CatchingSTG
Definition phrasemgr.h:58
void PostGemMsg(Message *pMsg)
Add the gem a GemPacket for this track carries to the phrase at its step and every step chained to it...
long long * GetStepValue(int nBar)
void PostBarStatusMsg(int nBar)
Post a BarStatusMsg for one bar with every field set.
void ReplayBar(int nBar, int nOffset)
Have mPhrasePlayer play a bar again from an offset, at the song position it has reached.
void AddGem(int nGem, int nTrans, int nBar, int nTick, Player *pOwner, int bPost)
Add a gem to the phrase at a bar, creating the phrase for an owner when the bar has none.
void PostGemMsgSecond(int nBar)
Post each gem of the phrase at a bar as a GemMsg, in the phrase owner's name.
void ClearPhrase(int nBar, int bAll)
Clear the phrase at a bar and at every bar slot 7 of mMap chains it to, and post the affected window ...
void WithdrawCommands()
Withdraw both scheduled commands.
PhrasePlayer * mPhrasePlayer
Player of this track's phrases.
Definition phrasemgr.h:495
void OnExportCommand(int nBar)
Move the window to start before a bar, post the bar entering it, and schedule the file-local ExportCm...
void InstallPhrase(Phrase *pPhrase, int nBar, int bRefresh)
Install a phrase at a bar, report the owner change, and optionally post the bar again.
void PostPhraseMsg(int nPhrase)
Post a PhraseMsg for one phrase.
void OnPhrasePacket(PhrasePacket *pPacket)
Install the phrase a PhrasePacket for this track carries at its step, or clear the step when the pack...
MsgSink * mNetSink
Sink the phrase changes go to as packets, installed by the stage classes' slot 8.
Definition phrasemgr.h:507
void RefreshBar(int nBar, int bClear)
Post one bar again when it lies in the window from mWindowStart up to mWindowEnd.
void RefreshAllBars()
Widen the window to the first mConfig + 1 bars and post each of them again.
int GetPowerbar(int nBar)
Phrase * GetPhraseAt(int nBar)
void SetPhraseOwner(Player *pPlayer, int nBar)
Give the phrase at a bar a new owner.
void OnRefreshNet(Message *pMsg)
Send mNetSink a CaughtPhrasePacket for the step of each bar a RefreshNetMsg for this track names.
int BarToTick(int nBar)
virtual void DispatchPriv(Message *pMsg)
Act on a message.
PhraseMgr(Sch::TickClock *pClock, int nBarTicks, PlayMap *pMap, int nConfig, const TrackData *pTrackData)
Construct the manager of one track and its phrase database.
virtual ~PhraseMgr()
Withdraw both commands through WithdrawCommands(), then delete both owned objects.
Player * GetOwner(int nBar) const
Report the player who owns the phrase at a bar.
void OnCaughtPhrasePacket(Message *pMsg)
Give the phrase of a CaughtPhrasePacket for this track to the player the packet identifies,...
void OnCommand(int nBar)
Play one bar through mPhrasePlayer and schedule the file-local Cmd for the next bar.
friend class PhraseEraser
Definition phrasemgr.h:60
void OnInvalidateTrack(InvalidateTrackMsg *pMsg)
Clear and post again every window bar whose mapped bar lies in the range an InvalidateTrackMsg for th...
void CreatePowerbarMgr()
Replace the powerbar source with the one the play mode and the track kind call for.
void StartCommands()
Schedule the file-local Cmd for bar 0 at position 0 and the file-local ExportCmd for bar 1,...
void PostDurGemMsg(int nBar)
Post the gems of the phrase at a bar as DurGemMsg objects, with a GemMsg at the head of each run.
unsigned char GetPhraseByte(int nBar)
void SetPhraseByte(int nBar, char cValue)
Set the byte at +0x28 of the phrase at a bar and at every bar slot 7 of mMap chains it to for this tr...
int PhrasesMatch(int nFirstBar, int nSecondBar)
Report whether the phrases at two bars carry the same gems.
void PostGemMsgThird(int nBar, int bGhost)
Post each gem the track description lists for a bar as a GemMsg, when the bar is enabled.
friend class NotePitcher
Definition phrasemgr.h:59
void ResetOwners(Player *pPlayer)
Return every phrase to one owner and clear and post every bar of the window again.
friend class PhrasePlayer
Definition phrasemgr.h:61
int TickToBar(int nTick)
friend class Scratcher
Definition phrasemgr.h:63
friend class ScoreTrackGraph
Definition phrasemgr.h:62
friend class Voxer
Definition phrasemgr.h:64
friend class Catcher
Definition phrasemgr.h:57
Network packet the game sends between game systems.
Definition phrasepacket.h:28
Player of the phrases one track is divided into.
Definition phraseplayer.h:30
One phrase of a track, with its gems, its player, and the messages and values scheduled across it.
Definition phrase.h:38
Traversal order over one playable sequence.
Definition playmap.h:47
One participant in a session, local or remote.
Definition player.h:39
Source of the powerbar a bar of one track awards when its phrase is caught.
Definition powerbarmgr.h:18
Handle that identifies one batch of commands the scheduler has queued.
Definition cmdid.h:35
Pausable view of scheduler time, together with the tempo that maps it to a song position.
Definition tickclock.h:40
Song position in MIDI ticks, printed as measure, beat, and tick.
Definition tick.h:70
Converted events of one track of a level.
Definition trackdata.h:52
Scheduling of timed commands.
Definition activefilter.h:9