Files
itgmania212121/stepmania/src/NoteData.h
T

128 lines
4.2 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
-----------------------------------------------------------------------------
*/
2002-05-01 19:14:55 +00:00
#include "GameConstantsAndTypes.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
struct HoldNote
{
2002-05-27 08:23:27 +00:00
int m_iTrack;
int m_iStartIndex;
int m_iEndIndex;
2002-04-16 17:31:00 +00:00
};
2002-05-19 01:59:48 +00:00
inline int BeatToNoteRow( float fBeatNum ) { return int( fBeatNum * ELEMENTS_PER_BEAT + 0.5f); }; // round
2002-06-23 02:50:33 +00:00
inline int BeatToNoteRowNotRounded( float fBeatNum ) { return (int)( fBeatNum * ELEMENTS_PER_BEAT ); };
inline float NoteRowToBeat( float fNoteIndex ) { return fNoteIndex / (float)ELEMENTS_PER_BEAT; };
2002-05-19 01:59:48 +00:00
inline float NoteRowToBeat( int iNoteIndex ) { return NoteRowToBeat( (float)iNoteIndex ); };
2002-04-16 17:31:00 +00:00
class NoteData
{
public:
NoteData();
2002-06-23 02:50:33 +00:00
void Init();
2002-05-19 01:59:48 +00:00
~NoteData();
2002-04-16 17:31:00 +00:00
2002-05-19 01:59:48 +00:00
// used for loading
void SetFromMeasureStrings( CStringArray &arrayMeasureStrings ); // for loading from a .notes file
void SetFromDWIInfo(); // for loading from a .dwi file
void SetFromBMSInfo(); // for loading from a .bms file
void ReadFromCacheFile( FILE* file );
static void SkipOverDataInCacheFile( FILE* file );
// used for saving
void GetMeasureStrings( CStringArray &arrayMeasureStrings ); // for saving to a .notes file
void WriteToCacheFile( FILE* file );
int m_iNumTracks;
TapNote m_TapNotes[MAX_NOTE_TRACKS][MAX_TAP_NOTE_ROWS];
HoldNote m_HoldNotes[MAX_HOLD_NOTE_ELEMENTS];
int m_iNumHoldNotes;
2002-04-16 17:31:00 +00:00
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-05-27 08:23:27 +00:00
void CopyRange( NoteData* pFrom, int iNoteIndexBegin, int iNoteIndexEnd );
2002-06-23 02:50:33 +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++ )
if( m_TapNotes[t][index] != '0' )
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 );
// statistics
2002-06-23 02:50:33 +00:00
bool IsThereANoteAtRow( int iRow );
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 );
int GetNumHoldNotes( const float fStartBeat = 0, const float fEndBeat = MAX_BEATS );
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-06-14 22:25:22 +00:00
float GetRadarValue( RadarCatrgory rv, float fSongSeconds )
{
switch( rv )
{
case RADAR_STREAM: return GetStreamRadarValue( fSongSeconds ); break;
case RADAR_VOLTAGE: return GetVoltageRadarValue( fSongSeconds ); break;
case RADAR_AIR: return GetAirRadarValue( fSongSeconds ); break;
case RADAR_FREEZE: return GetFreezeRadarValue( fSongSeconds ); break;
2002-06-23 02:50:33 +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 );
float GetFreezeRadarValue( float fSongSeconds );
2002-06-23 02:50:33 +00:00
float GetChaosRadarValue( float fSongSeconds );
2002-04-16 17:31:00 +00:00
// Transformations
2002-05-27 08:23:27 +00:00
void LoadTransformed( NoteData* pOriginal, int iNewNumTracks, int iNewToOriginalTrack[] );
2002-04-16 17:31:00 +00:00
void CropToLeftSide();
void CropToRightSide();
void RemoveHoldNotes();
void Turn( PlayerOptions::TurnType tt );
void MakeLittle();
void SnapToNearestNoteType( NoteType nt1, NoteType nt2, float fBeginBeat, float fEndBeat );
// Convert between HoldNote representation and '2' and '3' markers in TapNotes
void Convert2sAnd3sToHoldNotes();
void ConvertHoldNotesTo2sAnd3s();
};