Files
itgmania212121/stepmania/src/NoteData.h
T

133 lines
4.8 KiB
C++
Raw Normal View History

2002-04-16 17:31:00 +00:00
#pragma once
/*
-----------------------------------------------------------------------------
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
index - corresponds to subdivisions of beats
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
-----------------------------------------------------------------------------
*/
//#include "GameConstantsAndTypes.h"
2002-07-27 19:29:51 +00:00
#include "PlayerOptions.h"
#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];
2002-04-16 17:31:00 +00:00
public:
NoteData();
2002-05-19 01:59:48 +00:00
~NoteData();
NoteData(const NoteData &cpy);
void Init();
NoteData &operator=(const NoteData &cpy);
2002-04-16 17:31:00 +00:00
2002-05-19 01:59:48 +00:00
int m_iNumTracks;
2002-07-11 19:02:26 +00:00
HoldNote m_HoldNotes[MAX_HOLD_NOTES];
2002-05-19 01:59:48 +00:00
int m_iNumHoldNotes;
2002-04-16 17:31:00 +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. */
inline TapNote GetTapNote(unsigned track, unsigned row) const
2002-10-12 21:14:40 +00:00
{
if(row < 0 || row >= 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);
/* Pad m_TapNotes so it includes the row "rows". */
void PadTapNotes(int rows);
void SetTapNote(int track, int row, TapNote t);
2002-10-12 21:41:15 +00:00
2002-07-03 03:13:13 +00:00
void LoadFromSMNoteDataString( CString sSMNoteData );
CString GetSMNoteDataString();
2002-05-27 08:23:27 +00:00
void ClearRange( int iNoteIndexBegin, int iNoteIndexEnd );
2002-05-19 01:59:48 +00:00
void ClearAll() { ClearRange( 0, MAX_TAP_NOTE_ROWS ); };
2002-06-29 11:59:09 +00:00
void CopyRange( NoteData* pFrom, int iFromIndexBegin, int iFromIndexEnd, int iToIndexBegin = -1 );
2002-06-24 22:04:31 +00:00
void CopyAll( NoteData* pFrom ) { m_iNumTracks = pFrom->m_iNumTracks; m_iNumHoldNotes = 0; CopyRange( pFrom, 0, MAX_TAP_NOTE_ROWS ); };
2002-04-16 17:31:00 +00:00
2002-05-27 08:23:27 +00:00
inline bool IsRowEmpty( int index )
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;
}
// 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
bool IsThereANoteAtRow( int iRow ) const;
2002-07-11 19:02:26 +00:00
float GetFirstBeat(); // return the beat number of the first note
int GetFirstRow();
2002-05-19 01:59:48 +00:00
float GetLastBeat(); // return the beat number of the last note
int GetLastRow();
int GetNumTapNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS );
int GetNumDoubles( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS );
2002-11-02 22:53:04 +00:00
/* optimization: for the default of start to end, use the second (faster) */
int GetNumHoldNotes( const float fStartBeat, const float fEndBeat = MAX_BEATS );
int GetNumHoldNotes() const { return m_iNumHoldNotes; }
2002-06-14 22:25:22 +00:00
int GetPossibleDancePoints();
2002-05-19 01:59:48 +00:00
// radar values - return between 0.0 and 1.2
2002-07-02 00:27:58 +00:00
float GetRadarValue( RadarCategory rv, float fSongSeconds )
2002-06-14 22:25:22 +00:00
{
switch( rv )
{
case RADAR_STREAM: return GetStreamRadarValue( fSongSeconds ); break;
case RADAR_VOLTAGE: return GetVoltageRadarValue( fSongSeconds ); break;
case RADAR_AIR: return GetAirRadarValue( fSongSeconds ); break;
2002-06-23 11:43:53 +00:00
case RADAR_FREEZE: return GetFreezeRadarValue( fSongSeconds ); break;
2002-06-24 22:04:31 +00:00
case RADAR_CHAOS: return GetChaosRadarValue( fSongSeconds ); break;
2002-06-14 22:25:22 +00:00
default: ASSERT(0); return 0;
}
};
2002-05-19 01:59:48 +00:00
float GetStreamRadarValue( float fSongSeconds );
float GetVoltageRadarValue( float fSongSeconds );
float GetAirRadarValue( float fSongSeconds );
2002-06-23 11:43:53 +00:00
float GetFreezeRadarValue( float fSongSeconds );
2002-06-24 22:04:31 +00:00
float GetChaosRadarValue( float fSongSeconds );
2002-04-16 17:31:00 +00:00
// Transformations
void LoadTransformed( NoteData* pOriginal, int iNewNumTracks, const int iOriginalTrackToTakeFrom[] ); // -1 for iOriginalTracksToTakeFrom means no track
2002-10-05 20:03:14 +00:00
void LoadTransformedSlidingWindow( NoteData* pOriginal, int iNewNumTracks ); // used by autogen
2002-04-16 17:31:00 +00:00
void CropToLeftSide();
void CropToRightSide();
void RemoveHoldNotes();
void Turn( PlayerOptions::TurnType tt );
void MakeLittle();
2002-10-18 19:01:32 +00:00
void SnapToNearestNoteType( NoteType nt, float fBeginBeat, float fEndBeat ) { SnapToNearestNoteType( nt, (NoteType)-1, fBeginBeat, fEndBeat ); }
2002-04-16 17:31:00 +00:00
void SnapToNearestNoteType( NoteType nt1, NoteType nt2, float fBeginBeat, float fEndBeat );
NoteType GetSmallestNoteTypeForMeasure( int iMeasureIndex );
2002-04-16 17:31:00 +00:00
// Convert between HoldNote representation and '2' and '3' markers in TapNotes
void Convert2sAnd3sToHoldNotes();
void ConvertHoldNotesTo2sAnd3s();
2002-08-25 05:00:23 +00:00
void Convert4sToHoldNotes();
void ConvertHoldNotesTo4s();
2002-04-16 17:31:00 +00:00
};