give new edits unique names
This commit is contained in:
@@ -149,27 +149,6 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
|||||||
m_Selector.RefreshAll();
|
m_Selector.RefreshAll();
|
||||||
return;
|
return;
|
||||||
case EditMenu::ACTION_COPY:
|
case EditMenu::ACTION_COPY:
|
||||||
ASSERT( !pSteps );
|
|
||||||
ASSERT( pSourceSteps );
|
|
||||||
{
|
|
||||||
// Yuck. Doing the memory allocation doesn't seem right since
|
|
||||||
// Song allocates all of the other Steps.
|
|
||||||
Steps* pNewSteps = new Steps;
|
|
||||||
pNewSteps->CopyFrom( pSourceSteps, st );
|
|
||||||
pNewSteps->SetDifficulty( dc );
|
|
||||||
pNewSteps->SetDescription( GetCopyDescription(pSourceSteps) );
|
|
||||||
pSong->AddSteps( pNewSteps );
|
|
||||||
|
|
||||||
SCREENMAN->SystemMessage( "Steps created from copy." );
|
|
||||||
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
|
|
||||||
pSong->Save();
|
|
||||||
|
|
||||||
GAMESTATE->m_pCurSong.Set( pSong );
|
|
||||||
GAMESTATE->m_pCurSteps[0].Set( pNewSteps );
|
|
||||||
|
|
||||||
m_Selector.RefreshAll();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
case EditMenu::ACTION_AUTOGEN:
|
case EditMenu::ACTION_AUTOGEN:
|
||||||
ASSERT( !pSteps );
|
ASSERT( !pSteps );
|
||||||
ASSERT( pSourceSteps );
|
ASSERT( pSourceSteps );
|
||||||
@@ -177,10 +156,22 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
|||||||
// Yuck. Doing the memory allocation doesn't seem right since
|
// Yuck. Doing the memory allocation doesn't seem right since
|
||||||
// Song allocates all of the other Steps.
|
// Song allocates all of the other Steps.
|
||||||
Steps* pNewSteps = new Steps;
|
Steps* pNewSteps = new Steps;
|
||||||
|
switch( action )
|
||||||
|
{
|
||||||
|
case EditMenu::ACTION_COPY:
|
||||||
|
pNewSteps->CopyFrom( pSourceSteps, st );
|
||||||
|
break;
|
||||||
|
case EditMenu::ACTION_AUTOGEN:
|
||||||
pNewSteps->AutogenFrom( pSourceSteps, st );
|
pNewSteps->AutogenFrom( pSourceSteps, st );
|
||||||
pNewSteps->DeAutogen();
|
pNewSteps->DeAutogen();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
pNewSteps->SetDifficulty( dc ); // override difficulty with the user's choice
|
pNewSteps->SetDifficulty( dc ); // override difficulty with the user's choice
|
||||||
pNewSteps->SetDescription( GetCopyDescription(pSourceSteps) );
|
CString sPreferredEditName = GetCopyDescription(pSourceSteps);
|
||||||
|
pSong->MakeUniqueEditDescription( st, sPreferredEditName );
|
||||||
|
pNewSteps->SetDescription( sPreferredEditName );
|
||||||
pSong->AddSteps( pNewSteps );
|
pSong->AddSteps( pNewSteps );
|
||||||
|
|
||||||
SCREENMAN->SystemMessage( "Steps created from AutoGen." );
|
SCREENMAN->SystemMessage( "Steps created from AutoGen." );
|
||||||
|
|||||||
+44
-3
@@ -855,7 +855,7 @@ void Song::GetSteps(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Steps* Song::GetSteps(
|
Steps* Song::GetOneSteps(
|
||||||
StepsType st,
|
StepsType st,
|
||||||
Difficulty dc,
|
Difficulty dc,
|
||||||
int iMeterLow,
|
int iMeterLow,
|
||||||
@@ -952,12 +952,12 @@ bool Song::SongCompleteForStyle( const Style *st ) const
|
|||||||
|
|
||||||
bool Song::HasStepsType( StepsType st ) const
|
bool Song::HasStepsType( StepsType st ) const
|
||||||
{
|
{
|
||||||
return GetSteps( st ) != NULL;
|
return GetOneSteps( st ) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Song::HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const
|
bool Song::HasStepsTypeAndDifficulty( StepsType st, Difficulty dc ) const
|
||||||
{
|
{
|
||||||
return GetSteps( st, dc ) != NULL;
|
return GetOneSteps( st, dc ) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Song::Save()
|
void Song::Save()
|
||||||
@@ -1404,6 +1404,47 @@ bool Song::HasSignificantBpmChangesOrStops() const
|
|||||||
return m_Timing.HasBpmChangesOrStops();
|
return m_Timing.HasBpmChangesOrStops();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsEditDescriptionUnique( vector<Steps*> vSteps, StepsType st, CString sPreferredDescription )
|
||||||
|
{
|
||||||
|
FOREACH( Steps*, vSteps, s )
|
||||||
|
{
|
||||||
|
if( (*s)->GetDifficulty() != DIFFICULTY_EDIT )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( (*s)->m_StepsType != st )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( (*s)->GetDescription() == sPreferredDescription )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Song::MakeUniqueEditDescription( StepsType st, CString &sPreferredDescriptionInOut )
|
||||||
|
{
|
||||||
|
if( IsEditDescriptionUnique( m_vpSteps, st, sPreferredDescriptionInOut ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int i=0;
|
||||||
|
CString sTemp;
|
||||||
|
|
||||||
|
for( int i=0; i<1000; i++ )
|
||||||
|
{
|
||||||
|
// make name "My Edit" -> "My Edit"
|
||||||
|
CString sNum = ssprintf("%d", i+1);
|
||||||
|
sTemp = sPreferredDescriptionInOut.Left( MAX_DESCRIPTION_LENGTH - sNum.size() ) + sNum;
|
||||||
|
|
||||||
|
if( IsEditDescriptionUnique(m_vpSteps, st, sTemp) )
|
||||||
|
{
|
||||||
|
sPreferredDescriptionInOut = sTemp;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit limit guards should keep us from ever having more than 1000 edits per song.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// lua start
|
// lua start
|
||||||
#include "LuaBinding.h"
|
#include "LuaBinding.h"
|
||||||
|
|||||||
+11
-4
@@ -31,8 +31,6 @@
|
|||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "NotesLoaderSM.h"
|
#include "NotesLoaderSM.h"
|
||||||
|
|
||||||
const int MAX_DESCRIPTION_LENGTH = 12;
|
|
||||||
|
|
||||||
Steps::Steps()
|
Steps::Steps()
|
||||||
{
|
{
|
||||||
m_StepsType = STEPS_TYPE_INVALID;
|
m_StepsType = STEPS_TYPE_INVALID;
|
||||||
@@ -303,8 +301,17 @@ void Steps::SetDescription(CString desc)
|
|||||||
{
|
{
|
||||||
DeAutogen();
|
DeAutogen();
|
||||||
m_sDescription = desc;
|
m_sDescription = desc;
|
||||||
if( int(m_sDescription.size()) > MAX_DESCRIPTION_LENGTH )
|
MakeValidDescription( m_sDescription );
|
||||||
m_sDescription = m_sDescription.Left( MAX_DESCRIPTION_LENGTH );
|
}
|
||||||
|
|
||||||
|
bool Steps::MakeValidDescription( CString &sPreferredDescription )
|
||||||
|
{
|
||||||
|
if( int(sPreferredDescription.size()) > MAX_DESCRIPTION_LENGTH )
|
||||||
|
{
|
||||||
|
sPreferredDescription = sPreferredDescription.Left( MAX_DESCRIPTION_LENGTH );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Steps::SetDifficulty(Difficulty d)
|
void Steps::SetDifficulty(Difficulty d)
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ class NoteData;
|
|||||||
class Profile;
|
class Profile;
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
|
const int MAX_DESCRIPTION_LENGTH = 12;
|
||||||
|
|
||||||
class Steps
|
class Steps
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -40,6 +42,8 @@ public:
|
|||||||
|
|
||||||
void SetFile( CString fn );
|
void SetFile( CString fn );
|
||||||
void SetDescription(CString desc);
|
void SetDescription(CString desc);
|
||||||
|
static bool MakeValidDescription( CString &sPreferredDescription ); // return true if was modified
|
||||||
|
|
||||||
void SetDifficulty(Difficulty d);
|
void SetDifficulty(Difficulty d);
|
||||||
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
|
void SetLoadedFromProfile( ProfileSlot slot ) { m_LoadedFromProfile = slot; }
|
||||||
void SetMeter(int meter);
|
void SetMeter(int meter);
|
||||||
|
|||||||
@@ -176,11 +176,11 @@ Steps *StepsID::ToSteps( const Song *p, bool bAllowNull, bool bUseCache ) const
|
|||||||
Steps *ret = NULL;
|
Steps *ret = NULL;
|
||||||
if( dc == DIFFICULTY_EDIT )
|
if( dc == DIFFICULTY_EDIT )
|
||||||
{
|
{
|
||||||
ret = p->GetSteps( st, dc, -1, -1, sDescription, uHash, true );
|
ret = p->GetOneSteps( st, dc, -1, -1, sDescription, uHash, true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = p->GetSteps( st, dc, -1, -1, "", 0, true );
|
ret = p->GetOneSteps( st, dc, -1, -1, "", 0, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !bAllowNull && ret == NULL )
|
if( !bAllowNull && ret == NULL )
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public:
|
|||||||
unsigned uHash = 0,
|
unsigned uHash = 0,
|
||||||
int iMaxToGet = -1
|
int iMaxToGet = -1
|
||||||
) const;
|
) const;
|
||||||
Steps* GetSteps(
|
Steps* GetOneSteps(
|
||||||
StepsType st = STEPS_TYPE_INVALID,
|
StepsType st = STEPS_TYPE_INVALID,
|
||||||
Difficulty dc = DIFFICULTY_INVALID,
|
Difficulty dc = DIFFICULTY_INVALID,
|
||||||
int iMeterLow = -1,
|
int iMeterLow = -1,
|
||||||
@@ -219,6 +219,8 @@ public:
|
|||||||
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
|
int GetNumStepsLoadedFromProfile( ProfileSlot slot ) const;
|
||||||
bool IsEditAlreadyLoaded( Steps* pSteps ) const;
|
bool IsEditAlreadyLoaded( Steps* pSteps ) const;
|
||||||
|
|
||||||
|
void MakeUniqueEditDescription( StepsType st, CString &sPreferredDescriptionInOut );
|
||||||
|
|
||||||
// An array of keysound file names (e.g. "beep.wav").
|
// An array of keysound file names (e.g. "beep.wav").
|
||||||
// The index in this array corresponds to the index in TapNote. If you
|
// The index in this array corresponds to the index in TapNote. If you
|
||||||
// change the index in here, you must change all NoteData too.
|
// change the index in here, you must change all NoteData too.
|
||||||
|
|||||||
Reference in New Issue
Block a user