resonance 1.0.1
Loading...
Searching...
No Matches
metremixmanager.h
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <vector>
5
9#include "met/metscreen.h"
10#include "os/asynccallback.h"
11#include "os/hxstr.h"
12
13class MetRenderer;
15
65class MetRemixManager : public MetScreen, public MemcardUser, public AsyncCallback {
66public:
78 MetRemixManager(MetRenderer *pRenderer, int nPriority);
79
85
97 static MetRemixManager *New(MetRenderer *pRenderer, int nPriority);
98
107
118
128 void SetRecord(const MetRemixRecord &record);
129
142
155
165
175
185
195 inline void NextTrack();
196
207
221 void StartPlayList(const std::vector<HxStr> &returnScreens, int nShuffle);
222
236 void SavePlayList(const std::vector<HxStr> &returnScreens);
237
253 void BeginRemixLoad(const std::vector<HxStr> &returnScreens,
254 const std::vector<HxStr> &restoreScreens,
255 const MetRemixRecord &record,
256 int nFactory);
257
272 void ListRemixes(const std::vector<HxStr> &returnScreens,
273 std::vector<MemcardConnectState> slots,
274 int bLoadPlayList);
275
285
297 virtual void EnterAndShow();
298
305 virtual void OnExitFinished();
306
322 virtual void OnMsgScreenDismissed(const HxStr &name, int nChoice);
323
337 virtual void OnCardFormatted(int nPortSlot, int nStatus);
338
353#ifdef VIDEO_STANDARD_PAL
354 virtual void OnJukeboxPlayListSaved(int nPortSlot, int nStatus, int nKilobytes);
355#else
356 virtual void OnJukeboxPlayListSaved(int nPortSlot, int nStatus);
357#endif
358
371 virtual void OnRemixesListed(int nPortSlot, int nStatus);
372
391 virtual void OnRemixLoaded(int nPortSlot, int nStatus);
392
405 virtual void OnJukeboxPlayListLoaded(int nPortSlot, int nStatus);
406
423 virtual void Done(int nHandle, int nFile, void *pBuffer, int nLength, int nStatus);
424
431 static constexpr int kFactorySlot = -1;
432
433private:
441 static MetRemixManager *ResolveSharedInstance();
449 static void CacheSharedInstance();
456 void LoadIndex();
463 void LoadRemixFile(const HxStr &fileName);
464 // NTSC-U/C: 0x00361418, PAL: 0x0038e8f8
465 // A factory remix is read from its file and any other through the memory card.
466 // LoadCurrentTrack() expands it inline.
467 inline void LoadRemix(const MetRemixRecord &record, int nFactory);
468 // NTSC-U/C: 0x00361480, PAL: 0x0038e960
469 void LoadCurrentTrack();
470 // NTSC-U/C: 0x0035abf8, PAL: 0x00387e58
471 // Starts a jukebox game on the current track's remix in a random arena, burns the recorded
472 // appearances, steps the playlist, and brings up MetLoadGameScreen. Both remix-load
473 // completions call it. The title is inferred.
474 void StartLoadedRemix();
475 // Saves the playlist again with a copy of mReturnScreens as the return screens.
476 // OnMsgScreenDismissed() expands it at each retry.
477 inline void RetrySavePlayList();
486 void SetCurrentTrack(int nTrack);
487 // NTSC-U/C: 0x003610d0, PAL: 0x0038e590
488 // Pushes every screen listed in mRestoreScreens and activates the first.
489 void PushRestoreScreens();
490 // NTSC-U/C: 0x00361170, PAL: 0x0038e630
491 // Pushes every screen listed in mReturnScreens and activates the first.
492 void PushReturnScreens();
493
494 // NTSC-U/C: 0x006c1110, PAL: 0x00704108
495 static MetRemixManager *sInstance;
496
497public:
504 std::map<int, std::vector<MetRemixRecord>> mRemixes;
505
512 std::map<int, int> mListStatus;
513
514private:
515 // The screens a dismissed manager dialogue brings back. +0xac
516 std::vector<HxStr> mReturnScreens;
517 // The screens restored after a jukebox track or a failed remix load. +0xb8
518 std::vector<HxStr> mRestoreScreens;
519
520public:
529
530private:
531 int mListingsDone; // +0xd4, listings received since ListRemixes()
532 int mListingsExpected; // +0xd8, sources ListRemixes() requested
533 int mPlayListReady; // +0xdc, starts at one, clear while a playlist load is queued
534 int mIndexRequest; // +0xe0
535 int mRemixRequest; // +0xe4, matched by Done()
536 // The mRemixes key Done() files the index under. Starts at -1.
537 int mIndexSlot; // +0xe8
538 int mCurrentPlaylistTrack; // +0xec
539 int mShuffle; // +0xf0, RandomTrack() steps when set
540 int mAfterLoadAction; // +0xf4, start the remix or exit the dialogue after a load
541 std::vector<bool> mPlayedTracks; // +0xf8, one per playlist entry
542 MetRemixRecord mRecord; // +0x114
543};
Receiver notified once a queued asynchronous read has finished.
Definition asynccallback.h:18
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Ordered list of the remixes queued in the jukebox.
Definition jukeboxplaylist.h:46
Receiver notified once a memory-card task has finished.
Definition memcarduser.h:24
virtual void OnJukeboxPlayListSaved(int nPortSlot, int nStatus)
Act on the playlist save the card reported.
virtual void EnterAndShow()
Hide the dialogue view instead of showing it.
virtual void OnCardFormatted(int nPortSlot, int nStatus)
Act on the format the card reported.
virtual void OnExitFinished()
Slot 36, overridden empty.
MetRemixRecord * LookupRemix(const HxStr &name)
Look a remix up by name for the playlist editor.
static constexpr int kFactorySlot
The key of the factory remixes in mRemixes.
Definition metremixmanager.h:431
virtual void Done(int nHandle, int nFile, void *pBuffer, int nLength, int nStatus)
Act on the asynchronous read the file layer finished.
virtual void OnJukeboxPlayListLoaded(int nPortSlot, int nStatus)
Act on the playlist load the card reported.
MetRemixRecord * FindRecord(const HxStr &name)
Look a remix up by name in the catalogue.
MetRemixManager(MetRenderer *pRenderer, int nPriority)
Construct the manager.
static MetRemixManager * New(MetRenderer *pRenderer, int nPriority)
Build the manager on the heap.
virtual ~MetRemixManager()
std::map< int, int > mListStatus
The listing status of each card, keyed by port and slot.
Definition metremixmanager.h:512
std::map< int, std::vector< MetRemixRecord > > mRemixes
The remix lists, keyed by card slot, with -1 for the factory remixes.
Definition metremixmanager.h:504
void SavePlayList(const std::vector< HxStr > &returnScreens)
Save the playlist to the first memory-card slot.
void PlayCurrentTrack()
Start loading the current playlist track.
void ListRemixes(const std::vector< HxStr > &returnScreens, std::vector< MemcardConnectState > slots, int bLoadPlayList)
Rebuild the catalogue from the factory set and the given memory-card slots.
void PrunePlayList()
Drop the playlist entries the catalogue no longer knows.
virtual void OnMsgScreenDismissed(const HxStr &name, int nChoice)
Act on the choice the user made in one of the manager's dialogues.
void LeaveJukeboxMode()
Clear the jukebox flag in the game parameters and rewind the playlist.
void PreviousTrack()
Step to the previous playlist track, or to a random one in shuffle mode.
void NextTrack()
Step to the next playlist track, or to a random one in shuffle mode.
MetRemixRecord * GetRecord()
Report the current remix record.
void StartPlayList(const std::vector< HxStr > &returnScreens, int nShuffle)
Start playing the playlist.
JukeboxPlayList mPlayList
The jukebox playlist.
Definition metremixmanager.h:528
void SetRecord(const MetRemixRecord &record)
Replace the current remix record.
void RandomTrack()
Pick a random track that has not played since the last reset.
virtual void OnRemixesListed(int nPortSlot, int nStatus)
Record the remixes one card slot reported.
void BeginRemixLoad(const std::vector< HxStr > &returnScreens, const std::vector< HxStr > &restoreScreens, const MetRemixRecord &record, int nFactory)
Raise the load warning and start loading one remix.
static MetRemixManager * shared()
Return the one instance, resolving it through the screen registry on first use.
virtual void OnRemixLoaded(int nPortSlot, int nStatus)
Act on the remix load the card reported.
Front-end renderer that owns the screen stack and drives every MetScreen.
Definition metrenderer.h:68
MetScreen(MetRenderer *pRenderer, int nPriority, const HxStr &name, const HxStr &directory, const HxStr &file)
Construct a screen and start its container load.
What one card slot reports about itself, and the memory-card location the front end stores.
Definition memcardconnectstate.h:21
One remix in the catalogue, with the appearances of the players who recorded it.
Definition metremixrecord.h:36