Files
itgmania212121/stepmania/src/Steps.h
T

123 lines
5.2 KiB
C++
Raw Normal View History

2004-05-31 21:35:31 +00:00
/* Steps - Holds note information for a Song. A Song may have one or more Notes. */
2003-08-03 00:57:20 +00:00
#ifndef STEPS_H
#define STEPS_H
2002-05-20 08:59:37 +00:00
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
2002-05-20 08:59:37 +00:00
#include "Grade.h"
2004-07-11 07:21:33 +00:00
#include "RadarValues.h"
2005-01-22 19:36:39 +00:00
#include "Difficulty.h"
#include "RageUtil_AutoPtr.h"
2004-02-10 09:42:01 +00:00
class Profile;
class NoteData;
2005-02-22 23:06:51 +00:00
struct lua_State;
2002-05-20 08:59:37 +00:00
2005-07-29 02:23:02 +00:00
const int MAX_EDIT_STEPS_DESCRIPTION_LENGTH = 12;
2005-03-07 05:23:18 +00:00
2003-08-03 00:57:20 +00:00
class Steps
2002-05-20 08:59:37 +00:00
{
public:
2003-08-03 00:57:20 +00:00
Steps();
~Steps();
2002-05-20 08:59:37 +00:00
// initializers
2003-12-29 22:50:54 +00:00
void AutogenFrom( const Steps *parent, StepsType ntTo );
void CopyFrom( Steps* pSource, StepsType ntTo, float fMusicLengthSeconds );
2003-08-07 06:16:17 +00:00
void CreateBlank( StepsType ntTo );
2002-12-14 21:43:00 +00:00
void Compress() const;
void Decompress() const;
2006-08-22 14:06:24 +00:00
bool IsAutogen() const { return parent != NULL; } // Was created by autogen?
2002-12-14 21:43:00 +00:00
2004-02-08 01:05:53 +00:00
// Use a special value of difficulty
2006-08-22 14:06:24 +00:00
bool IsAnEdit() const { return m_Difficulty == DIFFICULTY_EDIT; }
bool IsAPlayerEdit() const { return IsAnEdit() && GetLoadedFromProfileSlot() < ProfileSlot_Machine; }
2006-10-07 03:32:16 +00:00
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_Invalid; }
2006-08-22 14:06:24 +00:00
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
RString GetDescription() const { return Real()->m_sDescription; }
Difficulty GetDifficulty() const { return Real()->m_Difficulty; }
int GetMeter() const { return Real()->m_iMeter; }
const RadarValues& GetRadarValues( PlayerNumber pn ) const { return Real()->m_CachedRadarValues[pn]; }
2003-01-02 22:10:51 +00:00
2006-08-22 14:06:24 +00:00
void SetFilename( RString fn ) { m_sFilename = fn; }
RString GetFilename() const { return m_sFilename; }
void SetSavedToDisk( bool b ) { DeAutogen(); m_bSavedToDisk = b; }
bool GetSavedToDisk() const { return Real()->m_bSavedToDisk; }
2006-08-22 14:06:24 +00:00
void SetDifficulty( Difficulty dc ) { SetDifficultyAndDescription( dc, GetDescription() ); }
void SetDescription( RString sDescription ) { SetDifficultyAndDescription( this->GetDifficulty(), sDescription ); }
2006-01-22 01:00:06 +00:00
void SetDifficultyAndDescription( Difficulty dc, RString sDescription );
static bool MakeValidEditDescription( RString &sPreferredDescription ); // return true if was modified
2005-03-07 05:23:18 +00:00
2006-08-22 14:06:24 +00:00
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
2006-08-22 13:52:34 +00:00
void SetMeter( int meter );
void SetCachedRadarValues( const RadarValues v[NUM_PLAYERS] );
2003-12-18 21:24:30 +00:00
float PredictMeter() const;
2003-12-18 20:35:46 +00:00
unsigned GetHash() const;
2006-08-22 13:52:34 +00:00
void GetNoteData( NoteData& noteDataOut ) const;
void SetNoteData( const NoteData& noteDataNew );
void SetSMNoteData( const RString &notes_comp );
void GetSMNoteData( RString &notes_comp_out ) const;
2003-01-30 07:18:33 +00:00
2002-07-03 03:13:13 +00:00
void TidyUpData();
void CalculateRadarValues( float fMusicLengthSeconds );
2005-02-22 23:06:51 +00:00
// Lua
void PushSelf( lua_State *L );
2006-08-22 13:52:34 +00:00
StepsType m_StepsType;
private:
2006-08-22 14:06:24 +00:00
inline const Steps *Real() const { return parent ? parent : this; }
2006-11-12 04:38:44 +00:00
void DeAutogen( bool bCopyNoteData = true ); /* If this Steps is autogenerated, make it a real Steps. */
2006-08-22 13:52:34 +00:00
2003-08-03 00:57:20 +00:00
/* If this Steps is autogenerated, this will point to the autogen
* source. If this is true, m_sNoteDataCompressed will always be empty. */
2006-08-22 13:52:34 +00:00
const Steps *parent;
2002-09-06 23:36:04 +00:00
2003-01-02 22:10:51 +00:00
/* We can have one or both of these; if we have both, they're always identical.
* Call Compress() to force us to only have m_sNoteDataCompressed; otherwise, creation of
2003-01-02 22:10:51 +00:00
* these is transparent. */
2006-08-22 13:52:34 +00:00
mutable HiddenPtr<NoteData> m_pNoteData;
mutable bool m_bNoteDataIsFilled;
mutable RString m_sNoteDataCompressed;
2003-01-02 22:10:51 +00:00
2006-08-22 13:52:34 +00:00
RString m_sFilename;
bool m_bSavedToDisk; // true if this was loaded from disk or has been saved to disk.
2006-10-07 03:32:16 +00:00
ProfileSlot m_LoadedFromProfile; // ProfileSlot_Invalid if wasn't loaded from a profile
2003-01-02 22:10:51 +00:00
/* These values are pulled from the autogen source first, if there is one. */
2006-08-23 20:45:30 +00:00
mutable unsigned m_iHash; // only used if m_Difficulty == DIFFICULTY_EDIT
2006-08-22 13:52:34 +00:00
RString m_sDescription; // Step author, edit name, or something meaningful
Difficulty m_Difficulty; // difficulty classification
int m_iMeter; // difficulty rating from MIN_METER to MAX_METER
RadarValues m_CachedRadarValues[NUM_PLAYERS];
2002-05-20 08:59:37 +00:00
};
#endif
2004-05-31 21:35:31 +00:00
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/