wavelength 1.0.0
Loading...
Searching...
No Matches
remixlogic.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "game/btnevent.h"
9#include "game/fxmgr.h"
11#include "game/netarbiter.h"
12#include "game/pitchtrack.h"
13#include "game/player.h"
14#include "game/playmap.h"
15#include "game/playnoteevent.h"
16#include "game/remixhud.h"
17#include "game/remixtrack.h"
18#include "game/rotateevent.h"
20#include "game/song.h"
21#include "game/stickevent.h"
22#include "game/voxtrack.h"
23#include "game/worldbeat.h"
24#include "game/worldlogic.h"
25#include "met/metagame.h"
26#include "msg/arbiterpacket.h"
27#include "msg/editgempacket.h"
28#include "msg/erasebarpacket.h"
30#include "msg/fxpacket.h"
31#include "msg/gameendedmsg.h"
32#include "msg/keyboardkeymsg.h"
33#include "msg/message.h"
36#include "msg/previewpacket.h"
39#include "os/binstream.h"
40#include "os/command.h"
41#include "os/ptr.h"
42
43class RemixTutorial;
44
55class RemixLogic : public WorldLogic {
56public:
65
77 explicit RemixLogic(Song *pSong);
78
87 ~RemixLogic() override;
88
98 bool DispatchPriv(Message *pMsg) override;
99
108 void Start() override;
109
116 void Stop() override;
117
125 bool IsFinished() const override;
126
134 int HasQuit() const override;
135
143 int IsRestartRequested() const override {
144 return 0;
145 }
146
155 bool IsFreestyling(int nPlayer) override;
156
164 int GetTick() override;
165
173 float GetTime() override;
174
182 void Poll() override;
183
194 float GetProgress() override;
195
205 void HandleInput(const RotateEvent &event) override;
206
216 void HandleInput(const PlayNoteEvent &event) override;
217
225 void HandleInput(const BtnEvent<3> &event) override;
226
234 void HandleInput([[maybe_unused]] const BtnEvent<4> &event) override {
235 }
236
244 void HandleInput([[maybe_unused]] const BtnEvent<5> &event) override {
245 }
246
256 void HandleInput(const ChangeSectionEvent &event) override;
257
268 void HandleInput(const BtnEvent<9> &event) override;
269
277 void HandleInput(const BtnEvent<10> &event) override;
278
286 void HandleInput(const BtnEvent<8> &event) override;
287
295 void HandleInput(const StickEvent<2> &event) override;
296
304 void HandleInput(const StickEvent<6> &event) override;
305
317 void SetPaused(bool bPaused, int nPad, int nReason) override;
318
326 bool IsPlaying() const override {
327 return mState == kStatePlaying;
328 }
329
338 void SetLooping(int nPlayer, bool bLooping);
339
346 void ClearGems();
347
355 void EnableMenu(bool bEnable);
356
363 void OpenTempo();
364
372
380
388
389private:
398 int GetPlayerFromNetOrder(int nNetOrder) const;
399
411 static void OnPauseDialog(Metagame::DialogAction action, void *pUserData);
412
424 void BuildTracks(int *pFreestyleType, int *pFreestyleInstrument);
425
437 bool IsInputLocked(int nPressed, bool bNote);
438
445 void EndRemix();
446
455 PitchTrack *FindPitchTrack(int nTrack) const;
456
465 VoxTrack *FindVoxTrack(int nTrack) const;
466
474 void SetHudsActive(int nActive);
475
483 void UpdateHud(int nPlayer);
484
493 void UpdateHuds();
494
503 void QueueSectionChange(int nIndex);
504
513 void ChangeSection(int nIndex, int nBar);
514
521 void StartTransition();
522
531 void OnTransition();
532
542 void ApplySectionTracks();
543
551 void RebuildPatterns();
552
561 void OnSectionEnd();
562
571 void ApplySectionEffects();
572
580 void AddSectionCheckpoints(int nFirstBar);
581
590 void StartPreview(int nBar, bool bTransition);
591
600 void PlayIntro();
601
610 void EndIntro();
611
620 void StopPreview(int nBar);
621
632 void SetLoop(int nStartBar, int nEndBar, int nPlayBar, int nLoopBar);
633
641 float GetTempo();
642
650 void AdjustTempo(float fDelta);
651
660 void MuteVocals(int nTrack, bool bMute);
661
669 void SetMuteRemote(int nMuteRemote);
670
679 void SetFilter(int nTrack, bool bOn);
680
689 void SetStutter(int nTrack, bool bOn);
690
699 void SetChorus(int nTrack, bool bOn);
700
707 void LoadRemix();
708
715 void SaveRemix();
716
724 void Save(BinStream &stream);
725
733 void Load(BinStream &stream);
734
743 bool IsTickInCurrentSection(int nTick);
744
753 int OnSectionChange(SectionChangePacket *pPacket);
754
763 int OnFX(FXPacket *pPacket);
764
773 int OnMuteVocals(MuteVocalsPacket *pPacket);
774
783 int OnPreview(PreviewPacket *pPacket);
784
793 int OnEditGem(EditGemPacket *pPacket);
794
803 int OnEraseBar(EraseBarPacket *pPacket);
804
813 int OnEraseSection(EraseSectionPacket *pPacket);
814
823 int OnRemixerUpdate(RemixerUpdatePacket *pPacket);
824
833 int OnArbiter(ArbiterPacket *pPacket);
834
843 int OnPlayerAborted(PlayerAbortedMsg *pMsg);
844
853 int OnGameEnded(GameEndedMsg *pMsg);
854
864 static void OnHudEvent(int nPlayer, int nEvent, void *pData);
865
874 void HandleHudEvent(int nPlayer, int nEvent);
875
886 int OnKeyboardKey(KeyboardKeyMsg *pMsg);
887
888 Song *mSong;
889 int mTicksPerBar;
890 int mNumBars;
891 int mState;
892 int mSavedState;
893 int mPaused;
894 PlayMap *mPlayMap;
895 SectionBoundaries *mSections;
896 std::vector<std::unique_ptr<RemixTrack>> mRemixTracks;
897 std::vector<PitchTrack *> mPitchTracks;
898 std::vector<VoxTrack *> mVoxTracks;
899 std::unique_ptr<FreestyleTrack> mFreestyleTrack;
900 std::vector<std::unique_ptr<Player>> mPlayers;
901 std::unique_ptr<GameTrackSelector> mTrackSelector;
902 WorldBeat mWorldBeat;
903 std::vector<int> mPlayableSections;
904 int mSectionIndex;
905 int mLoopBar;
906 int mMuteRemote;
907 int mPreviewing;
908 int mQuit;
909 int mModified;
910 int mReadOnly;
911 float mBaseTempo;
912 std::vector<int> mNetOrderPlayers;
913 std::unique_ptr<NetArbiter> mNetArbiter;
914 unsigned int mArbiterVersion;
915 std::vector<unsigned int> mUpdateVersions;
916 std::vector<int> mPlayerTracks;
917 std::vector<int> mTrackVolumes;
918 std::vector<std::unique_ptr<RemixHUD>> mHuds;
919 FXMgr mFx;
920 Ptr<Command> mTransitionCmd;
921 Ptr<Command> mSectionStartCmd;
922 Ptr<Command> mUpdateHudsCmd;
923 Ptr<Command> mSectionEndCmd;
924 Ptr<Command> mApplyEffectsCmd;
925 Ptr<Command> mPlayIntroCmd;
926 Ptr<Command> mEndIntroCmd;
927 std::unique_ptr<RemixTutorial> mTutorial;
928 int mSavedMuteRemote;
929 int mEndTick;
930 int mRemixLoaded;
931};
Packet in which the arbitrating console assigns every player a track.
Definition arbiterpacket.h:22
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Input event of a button press that names only the player.
Definition btnevent.h:15
Input event that changes the section a player is on.
Definition changesectionevent.h:10
Packet that reports a gem placed or removed in the remix editor.
Definition editgempacket.h:20
Packet that reports a bar of a track erased in the remix editor.
Definition erasebarpacket.h:20
Packet that reports a section of a track erased in the remix editor.
Definition erasesectionpacket.h:20
The effect sets a song applies to the synthesiser channels at given bars.
Definition fxmgr.h:15
Packet that reports a remix effect switched on or off for a track of a section.
Definition fxpacket.h:20
Message that reports the end of an online session, with the final scores.
Definition gameendedmsg.h:23
Message the keyboard poll sends when a key of a USB keyboard is pressed.
Definition keyboardkeymsg.h:23
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
Packet that reports the vocals of a track of a remix section muted or restored.
Definition mutevocalspacket.h:20
Track of a remixed song whose gems players place, each gem playing the riff of its gem button.
Definition pitchtrack.h:28
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
Message that reports a player leaving an online session.
Definition playerabortedmsg.h:20
Packet that reports the remix editor's preview of a section started or stopped.
Definition previewpacket.h:20
Owner of one reference to an Attachment.
Definition ptr.h:16
void HandleInput(const RotateEvent &event) override
Rotate a player to the next or the previous track while the song plays.
void HandleInput(const BtnEvent< 10 > &event) override
Pass a button event of command 10 to its player while the song plays.
bool IsFreestyling(int nPlayer) override
Report whether a player plays the freestyle track.
void HandleInput(const StickEvent< 6 > &event) override
Pass a stick event of command 6 to its player while the song plays.
void HandleInput(const BtnEvent< 4 > &event) override
Ignore a button event of command 4.
Definition remixlogic.h:234
void HandleInput(const BtnEvent< 3 > &event) override
Pause the song while it plays.
void Poll() override
End the tutorial once its script is done, and stop the song once the outro and the fade are done.
void EnableMenu(bool bEnable)
Focus or release the remix menu of the first controller.
void HandleInput(const BtnEvent< 5 > &event) override
Ignore a button event of command 5.
Definition remixlogic.h:244
void OpenTempo()
Open the tempo control.
void Start() override
Start the tracks, the players, the background music, and the intro of the song.
bool IsPlaying() const override
Report whether the song is playing.
Definition remixlogic.h:326
int HasQuit() const override
Report whether a player quit the remix from a menu.
void SetPaused(bool bPaused, int nPad, int nReason) override
Pause or resume the song.
int IsRestartRequested() const override
Report that no restart was requested.
Definition remixlogic.h:143
void LowerTempo()
Lower the tempo by one beat per minute.
void HandleInput(const BtnEvent< 9 > &event) override
Start or stop a preview.
void ClearGems()
Erase the gems of the section at the song position from every pitch track.
RemixLogic(Song *pSong)
Construct the rules for a song.
void HandleInput(const StickEvent< 2 > &event) override
Pass a stick event of command 2 to its player while the song plays.
void SetLooping(int nPlayer, bool bLooping)
Turn looping of a player's track on or off.
void HandleInput(const ChangeSectionEvent &event) override
Move to the next or the previous playable section.
void HandleInput(const BtnEvent< 8 > &event) override
Pass a button event of command 8 to its player while the song plays outside a preview.
void HandleInput(const PlayNoteEvent &event) override
Pass a gem button to its player while the song plays.
float GetProgress() override
Report how much of the song has been played.
void Stop() override
Stop the song and the tracks.
int GetTick() override
Report the song position in ticks.
void RaiseTempo()
Raise the tempo by one beat per minute.
bool DispatchPriv(Message *pMsg) override
Pass a packet of the session to its handler.
~RemixLogic() override
Save the remix outside the tutorial and release the rules.
bool IsFinished() const override
Report whether the remix ended.
float GetTime() override
Report the song position on the song clock.
State
Values of mState.
Definition remixlogic.h:58
@ kStatePaused
Definition remixlogic.h:60
@ kStateEnding
Definition remixlogic.h:62
@ kStateTutorialEnd
Definition remixlogic.h:61
@ kStateFinished
Definition remixlogic.h:63
@ kStatePlaying
Definition remixlogic.h:59
void CloseTempo()
Close the tempo control.
Scripted lesson that runs on top of a remix session.
Definition remixtutorial.h:19
Packet that reports the track and repeat state of a local player in a remix to the other consoles.
Definition remixerupdatepacket.h:22
Input event that rotates a player's view of the tracks by one track.
Definition rotateevent.h:11
Ascending list of the measures at which the sections of a song end.
Definition sectionboundaries.h:12
Packet that tells the other consoles of a remix session about a section change.
Definition sectionchangepacket.h:22
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
Vocal track of a remixed song, whose players switch its sections on and off.
Definition voxtrack.h:21
Player of the events of the track named "WORLD", which runs each event at its tick.
Definition worldbeat.h:16
WorldLogic()
Construct the logic and give the input of every controller to the world.