Files
itgmania212121/stepmania/src/Steps.h
T

124 lines
5.0 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;
2003-08-03 00:57:20 +00:00
void DeAutogen(); /* If this Steps is autogenerated, make it a real Steps. */
2002-12-14 21:43:00 +00:00
2004-02-08 01:05:53 +00:00
// Use a special value of difficulty
bool IsAnEdit() const { return m_Difficulty == DIFFICULTY_EDIT; }
2005-12-01 03:20:25 +00:00
bool IsAPlayerEdit() const { return m_Difficulty == DIFFICULTY_EDIT && GetLoadedFromProfileSlot() < ProfileSlot_Machine; }
bool WasLoadedFromProfile() const { return m_LoadedFromProfile != ProfileSlot_INVALID; }
2004-04-23 00:26:51 +00:00
ProfileSlot GetLoadedFromProfileSlot() const { return m_LoadedFromProfile; }
unsigned GetHash() const { return Real()->m_uHash; }
2006-01-22 01:00:06 +00:00
RString GetDescription() const { return Real()->m_sDescription; }
2003-01-02 22:10:51 +00:00
Difficulty GetDifficulty() const { return Real()->m_Difficulty; }
int GetMeter() const { return Real()->m_iMeter; }
const RadarValues& GetRadarValues() const { return Real()->m_CachedRadarValues; }
2003-01-02 22:10:51 +00:00
2006-01-22 01:00:06 +00:00
void SetFilename( RString fn ) { m_sFilename = fn; }
RString GetFilename() const { return m_sFilename; }
void SetSavedToDisk( bool b ) { m_bSavedToDisk = b; }
2005-12-03 20:34:49 +00:00
bool GetSavedToDisk() const { return m_bSavedToDisk; }
2006-01-22 01:00:06 +00:00
void SetDifficultyAndDescription( Difficulty dc, RString sDescription );
void SetDifficulty( Difficulty dc ) { SetDifficultyAndDescription( dc, this->GetDescription() ); }
2006-01-22 01:00:06 +00:00
void SetDescription( RString sDescription ) { SetDifficultyAndDescription( this->GetDifficulty(), sDescription ); }
static bool MakeValidEditDescription( RString &sPreferredDescription ); // return true if was modified
2005-03-07 05:23:18 +00:00
2004-04-16 23:47:24 +00:00
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
2003-01-02 22:10:51 +00:00
void SetMeter(int meter);
void SetCachedRadarValues( const RadarValues& v );
2003-01-02 22:10:51 +00:00
bool IsAutogen() const; // Was created by autogen?
2003-12-18 21:24:30 +00:00
float PredictMeter() const;
2003-12-18 20:35:46 +00:00
2003-11-17 03:38:24 +00:00
StepsType m_StepsType;
2002-05-27 08:23:27 +00:00
2004-10-23 17:43:49 +00:00
void GetNoteData( NoteData& noteDataOut ) const;
void SetNoteData( const NoteData& noteDataNew );
2006-01-22 01:00:06 +00:00
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 );
2002-09-06 23:36:04 +00:00
protected:
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. */
2003-08-03 00:57:20 +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. */
mutable HiddenPtr<NoteData> m_pNoteData;
mutable bool m_bNoteDataIsFilled;
2006-01-22 01:00:06 +00:00
mutable RString m_sNoteDataCompressed;
2003-01-02 22:10:51 +00:00
2003-08-03 00:57:20 +00:00
const Steps *Real() const;
2003-01-02 22:10:51 +00:00
2006-01-22 01:00:06 +00:00
RString m_sFilename;
2005-12-03 20:34:49 +00:00
bool m_bSavedToDisk; // true if this was loaded from disk or has been saved to disk.
2003-01-02 22:10:51 +00:00
/* These values are pulled from the autogen source first, if there is one. */
2005-12-01 03:20:25 +00:00
ProfileSlot m_LoadedFromProfile; // ProfileSlot_INVALID if wasn't loaded from a profile
unsigned m_uHash; // only used if m_Difficulty == DIFFICULTY_EDIT
2006-01-22 01:00:06 +00:00
RString m_sDescription; // Step author, edit name, or something meaningful
2003-01-02 22:10:51 +00:00
Difficulty m_Difficulty; // difficulty classification
2004-02-07 05:57:19 +00:00
int m_iMeter; // difficulty rating from MIN_METER to MAX_METER
RadarValues m_CachedRadarValues;
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.
*/