2002-11-16 08:07:38 +00:00
|
|
|
#ifndef NOTEDATA_H
|
|
|
|
|
#define NOTEDATA_H
|
2002-04-16 17:31:00 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
File: NoteData.h
|
|
|
|
|
|
|
|
|
|
Desc: Holds data about the notes that the player is supposed to hit. NoteData
|
|
|
|
|
is organized by:
|
|
|
|
|
track - corresponds to different columns of notes on the screen
|
2003-08-07 07:18:43 +00:00
|
|
|
row/index - corresponds to subdivisions of beats
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-04-16 17:31:00 +00:00
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-08-07 06:36:34 +00:00
|
|
|
//#include "GameConstantsAndTypes.h"
|
2002-08-13 23:26:46 +00:00
|
|
|
#include "NoteTypes.h"
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
// '1' = tap note
|
|
|
|
|
// '2' = hold note begin
|
2002-06-14 22:25:22 +00:00
|
|
|
// '3' = hold note end ('1' can also end a HoldNote) ('3' without a matching '2' is ignored
|
2002-04-16 17:31:00 +00:00
|
|
|
// ... for future expansion
|
|
|
|
|
|
|
|
|
|
class NoteData
|
|
|
|
|
{
|
2002-11-02 22:25:46 +00:00
|
|
|
/* Keep this aligned, so that they all have the same size. */
|
|
|
|
|
vector<TapNote> m_TapNotes[MAX_NOTE_TRACKS];
|
2003-02-01 05:16:38 +00:00
|
|
|
int m_iNumTracks;
|
|
|
|
|
|
2002-11-02 23:14:52 +00:00
|
|
|
vector<HoldNote> m_HoldNotes;
|
|
|
|
|
|
2002-12-13 23:34:37 +00:00
|
|
|
/* Pad m_TapNotes so it includes the row "rows". */
|
|
|
|
|
void PadTapNotes(int rows);
|
|
|
|
|
|
|
|
|
|
public:
|
2002-12-13 01:23:26 +00:00
|
|
|
/* Set up to hold the data in From; same number of tracks, same
|
|
|
|
|
* divisor. Doesn't allocate or copy anything. */
|
|
|
|
|
void Config( const NoteData &From );
|
|
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
NoteData();
|
2002-05-19 01:59:48 +00:00
|
|
|
~NoteData();
|
2002-10-11 23:23:49 +00:00
|
|
|
void Init();
|
2003-05-19 08:18:21 +00:00
|
|
|
|
2003-03-26 17:53:31 +00:00
|
|
|
int GetNumTracks() const;
|
2003-02-01 05:16:38 +00:00
|
|
|
void SetNumTracks( int iNewNumTracks );
|
|
|
|
|
|
2002-10-25 23:32:50 +00:00
|
|
|
/* Return the note at the given track and row. Row may be out of
|
|
|
|
|
* range; pretend the song goes on with TAP_EMPTYs indefinitely. */
|
2003-06-30 05:20:57 +00:00
|
|
|
inline TapNote GetTapNote(unsigned track, int row) const
|
2002-10-12 21:14:40 +00:00
|
|
|
{
|
2003-06-30 05:20:57 +00:00
|
|
|
if(row < 0 || row >= (int) m_TapNotes[track].size()) return TapNote(TAP_EMPTY);
|
2002-10-12 21:14:40 +00:00
|
|
|
return m_TapNotes[track][row];
|
|
|
|
|
}
|
2002-11-02 21:04:00 +00:00
|
|
|
void MoveTapNoteTrack(int dest, int src);
|
2002-10-25 23:32:50 +00:00
|
|
|
void SetTapNote(int track, int row, TapNote t);
|
2002-10-12 21:41:15 +00:00
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd );
|
2002-12-14 20:30:49 +00:00
|
|
|
void ClearAll();
|
2003-10-04 04:05:29 +00:00
|
|
|
void CopyRange( const NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = -1 );
|
2003-10-04 02:30:06 +00:00
|
|
|
void CopyAll( const NoteData* pFrom );
|
2002-12-13 01:23:26 +00:00
|
|
|
|
2002-12-13 22:09:26 +00:00
|
|
|
inline bool IsRowEmpty( int index ) const
|
2002-04-16 17:31:00 +00:00
|
|
|
{
|
|
|
|
|
for( int t=0; t<m_iNumTracks; t++ )
|
2002-10-25 04:59:12 +00:00
|
|
|
if( GetTapNote(t, index) != TAP_EMPTY )
|
2002-04-16 17:31:00 +00:00
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-02-18 23:15:38 +00:00
|
|
|
inline int GetNumTapNonEmptyTracks( int index ) const
|
2003-02-16 20:27:53 +00:00
|
|
|
{
|
|
|
|
|
int iNum = 0;
|
|
|
|
|
for( int t=0; t<m_iNumTracks; t++ )
|
|
|
|
|
if( GetTapNote(t, index) != TAP_EMPTY )
|
|
|
|
|
iNum++;
|
|
|
|
|
return iNum;
|
|
|
|
|
}
|
2003-02-18 23:15:38 +00:00
|
|
|
inline int GetFirstNonEmptyTrack( int index ) const
|
|
|
|
|
{
|
|
|
|
|
for( int t=0; t<m_iNumTracks; t++ )
|
|
|
|
|
if( GetTapNote(t, index) != TAP_EMPTY )
|
|
|
|
|
return t;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2003-02-20 01:35:49 +00:00
|
|
|
inline int GetNumTracksWithTap( int index ) const
|
|
|
|
|
{
|
|
|
|
|
int iNum = 0;
|
|
|
|
|
for( int t=0; t<m_iNumTracks; t++ )
|
|
|
|
|
if( GetTapNote(t, index) == TAP_TAP )
|
|
|
|
|
iNum++;
|
|
|
|
|
return iNum;
|
|
|
|
|
}
|
|
|
|
|
inline int GetFirstTrackWithTap( int index ) const
|
|
|
|
|
{
|
|
|
|
|
for( int t=0; t<m_iNumTracks; t++ )
|
|
|
|
|
if( GetTapNote(t, index) == TAP_TAP )
|
|
|
|
|
return t;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
// used in edit/record
|
|
|
|
|
void AddHoldNote( HoldNote newNote ); // add note hold note merging overlapping HoldNotes and destroying TapNotes underneath
|
|
|
|
|
void RemoveHoldNote( int index );
|
2002-11-02 22:25:46 +00:00
|
|
|
HoldNote &GetHoldNote( int index ) { return m_HoldNotes[index]; }
|
|
|
|
|
const HoldNote &GetHoldNote( int index ) const { return m_HoldNotes[index]; }
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
// statistics
|
2003-03-16 18:57:34 +00:00
|
|
|
bool IsThereATapAtRow( int iRow ) const;
|
2002-10-05 14:47:03 +00:00
|
|
|
|
2003-02-25 19:49:16 +00:00
|
|
|
/* Return the highest beat/row that might contain notes. (Use GetLastBeat if you need
|
|
|
|
|
* accuracy.) */
|
|
|
|
|
float GetMaxBeat() const { return NoteRowToBeat(GetMaxRow()); }
|
|
|
|
|
int GetMaxRow() const { return int(m_TapNotes[0].size()); }
|
|
|
|
|
|
2002-12-14 20:27:52 +00:00
|
|
|
float GetFirstBeat() const; // return the beat number of the first note
|
|
|
|
|
int GetFirstRow() const;
|
2002-12-13 22:40:42 +00:00
|
|
|
float GetLastBeat() const; // return the beat number of the last note
|
|
|
|
|
int GetLastRow() const;
|
2003-02-25 19:49:16 +00:00
|
|
|
int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = -1 ) const;
|
2003-03-16 18:57:34 +00:00
|
|
|
int GetNumRowsWithTaps( const float fStartBeat = 0, const float fEndBeat = -1 ) const;
|
2003-02-25 19:49:16 +00:00
|
|
|
int GetNumDoubles( const float fStartBeat = 0, const float fEndBeat = -1 ) const;
|
2002-11-02 22:53:04 +00:00
|
|
|
/* optimization: for the default of start to end, use the second (faster) */
|
2003-02-25 19:49:16 +00:00
|
|
|
int GetNumHoldNotes( const float fStartBeat, const float fEndBeat = -1 ) const;
|
2002-11-02 23:10:38 +00:00
|
|
|
int GetNumHoldNotes() const { return m_HoldNotes.size(); }
|
2002-11-02 22:53:04 +00:00
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
// Transformations
|
2003-10-04 04:14:30 +00:00
|
|
|
void LoadTransformed( const NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
|
|
|
|
|
void LoadTransformedSlidingWindow( const NoteData* pOriginal, int iNewNumTracks ); // used by autogen
|
2002-10-05 14:47:03 +00:00
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
// Convert between HoldNote representation and '2' and '3' markers in TapNotes
|
|
|
|
|
void Convert2sAnd3sToHoldNotes();
|
|
|
|
|
void ConvertHoldNotesTo2sAnd3s();
|
2003-10-04 03:12:45 +00:00
|
|
|
void To2sAnd3s( const NoteData &out );
|
|
|
|
|
void From2sAnd3s( const NoteData &out );
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2002-08-25 05:00:23 +00:00
|
|
|
void Convert4sToHoldNotes();
|
|
|
|
|
void ConvertHoldNotesTo4s();
|
2003-10-04 04:05:29 +00:00
|
|
|
void To4s( const NoteData &out );
|
|
|
|
|
void From4s( const NoteData &out );
|
2003-08-07 07:18:43 +00:00
|
|
|
|
2003-09-21 23:16:44 +00:00
|
|
|
void EliminateAllButOneTap( int row );
|
2003-10-29 23:17:00 +00:00
|
|
|
|
|
|
|
|
// MD 10/29/03 - Join two tracks together.
|
|
|
|
|
void CombineTracks( int iTrackTo, int iTrackFrom );
|
2002-04-16 17:31:00 +00:00
|
|
|
};
|
2002-11-16 08:07:38 +00:00
|
|
|
|
2002-12-13 22:09:26 +00:00
|
|
|
|
2002-11-16 08:07:38 +00:00
|
|
|
#endif
|