2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "ScreenEditMenu.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "RageUtil.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "GameManager.h"
|
|
|
|
|
#include "RageLog.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "GameState.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2003-08-03 00:13:55 +00:00
|
|
|
#include "Steps.h"
|
2003-11-07 20:24:44 +00:00
|
|
|
#include "song.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2005-01-29 23:45:27 +00:00
|
|
|
#define PREV_SCREEN THEME->GetMetric(m_sName,"PrevScreen")
|
2004-05-22 00:12:57 +00:00
|
|
|
#define EXPLANATION_TEXT THEME->GetMetric(m_sName,"ExplanationText")
|
|
|
|
|
#define HELP_TEXT THEME->GetMetric(m_sName,"HelpText")
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
const ScreenMessage SM_RefreshSelector = (ScreenMessage)(SM_User+1);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-11-26 17:28:47 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenEditMenu );
|
2004-05-01 23:19:33 +00:00
|
|
|
ScreenEditMenu::ScreenEditMenu( CString sName ) : ScreenWithMenuElements( sName )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEditMenu::ScreenEditMenu()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-05-22 00:12:57 +00:00
|
|
|
/* Enable all players. */
|
|
|
|
|
FOREACH_PlayerNumber( pn )
|
|
|
|
|
GAMESTATE->m_bSideIsJoined[pn] = true;
|
2005-02-23 18:56:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenEditMenu::Init()
|
|
|
|
|
{
|
|
|
|
|
ScreenWithMenuElements::Init();
|
2002-08-29 04:56:03 +00:00
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
m_Selector.SetXY( 0, 0 );
|
|
|
|
|
// m_Selector.AllowNewNotes();
|
|
|
|
|
this->AddChild( &m_Selector );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-27 16:53:25 +00:00
|
|
|
|
2004-05-22 00:12:57 +00:00
|
|
|
m_textExplanation.SetName( "Explanation" );
|
2005-03-05 09:11:56 +00:00
|
|
|
m_textExplanation.LoadFromFont( THEME->GetPathF(m_sName,"explanation") );
|
2004-05-22 00:12:57 +00:00
|
|
|
SET_XY_AND_ON_COMMAND( m_textExplanation );
|
2002-06-29 11:59:09 +00:00
|
|
|
m_textExplanation.SetText( EXPLANATION_TEXT );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textExplanation );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-05-03 00:08:56 +00:00
|
|
|
this->SortByDrawOrder();
|
|
|
|
|
|
2005-03-05 09:11:56 +00:00
|
|
|
SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
case SM_RefreshSelector:
|
2003-02-22 01:58:56 +00:00
|
|
|
m_Selector.RefreshNotes();
|
2003-01-30 07:18:33 +00:00
|
|
|
break;
|
2002-08-27 23:31:41 +00:00
|
|
|
case SM_GoToPrevScreen:
|
2005-01-29 23:45:27 +00:00
|
|
|
SCREENMAN->SetNewScreen( PREV_SCREEN );
|
2002-05-20 08:59:37 +00:00
|
|
|
break;
|
2002-08-27 23:31:41 +00:00
|
|
|
case SM_GoToNextScreen:
|
2002-08-27 03:59:22 +00:00
|
|
|
SCREENMAN->SetNewScreen( "ScreenEdit" );
|
2002-05-20 08:59:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuUp( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
m_Selector.Up();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuDown( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
m_Selector.Down();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuLeft( PlayerNumber pn, const InputEventType type )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
m_Selector.Left();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuRight( PlayerNumber pn, const InputEventType type )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
m_Selector.Right();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-16 17:53:58 +00:00
|
|
|
// helpers for MenuStart() below
|
2003-08-23 18:33:49 +00:00
|
|
|
void DeleteCurNotes( void* pThrowAway )
|
2003-08-16 17:53:58 +00:00
|
|
|
{
|
|
|
|
|
Song* pSong = GAMESTATE->m_pCurSong;
|
2004-05-24 06:12:17 +00:00
|
|
|
Steps* pStepsToDelete = GAMESTATE->m_pCurSteps[PLAYER_1];
|
2004-05-24 03:41:39 +00:00
|
|
|
pSong->RemoveSteps( pStepsToDelete );
|
2003-08-16 17:53:58 +00:00
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2004-05-01 23:19:33 +00:00
|
|
|
if( IsTransitioning() )
|
2002-10-18 02:42:52 +00:00
|
|
|
return;
|
|
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
Song* pSong = m_Selector.GetSelectedSong();
|
2004-07-12 02:19:24 +00:00
|
|
|
StepsType st = m_Selector.GetSelectedStepsType();
|
2003-01-30 07:18:33 +00:00
|
|
|
Difficulty dc = m_Selector.GetSelectedDifficulty();
|
2004-05-24 03:41:39 +00:00
|
|
|
Steps* pSteps = m_Selector.GetSelectedNotes();
|
2004-07-12 02:19:24 +00:00
|
|
|
// StepsType soureNT = m_Selector.GetSelectedSourceStepsType();
|
2003-01-30 07:18:33 +00:00
|
|
|
// Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty();
|
2003-08-03 00:13:55 +00:00
|
|
|
Steps* pSourceNotes = m_Selector.GetSelectedSourceNotes();
|
2003-02-11 02:20:38 +00:00
|
|
|
EditMenu::Action action = m_Selector.GetSelectedAction();
|
2003-01-30 07:18:33 +00:00
|
|
|
|
2005-02-24 12:27:30 +00:00
|
|
|
GAMESTATE->m_pCurSong.Set( pSong );
|
2004-07-12 02:19:24 +00:00
|
|
|
GAMESTATE->m_pCurStyle = GAMEMAN->GetEditorStyleForStepsType( st );
|
2005-02-25 18:17:26 +00:00
|
|
|
GAMESTATE->m_pCurSteps[PLAYER_1].Set( pSteps );
|
2003-01-30 07:18:33 +00:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// handle error cases
|
|
|
|
|
//
|
2002-09-16 00:56:30 +00:00
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
if( !pSong->HasMusic() )
|
2002-09-16 00:56:30 +00:00
|
|
|
{
|
2003-02-11 21:41:43 +00:00
|
|
|
SCREENMAN->Prompt( SM_None, "This song is missing a music file\nand cannot be edited" );
|
2002-09-16 00:56:30 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
switch( action )
|
|
|
|
|
{
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_EDIT:
|
2003-01-30 07:18:33 +00:00
|
|
|
// Prepare prepare for ScreenEdit
|
2004-05-24 03:41:39 +00:00
|
|
|
ASSERT( pSteps );
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->StopMusic();
|
2004-05-01 23:19:33 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
|
|
|
|
StartTransitioning( SM_GoToNextScreen );
|
2003-01-30 07:18:33 +00:00
|
|
|
break;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_DELETE:
|
2004-05-24 03:41:39 +00:00
|
|
|
ASSERT( pSteps );
|
2003-08-16 17:53:58 +00:00
|
|
|
SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\n\nContinue with delete?", true, false, DeleteCurNotes );
|
2003-02-22 01:58:56 +00:00
|
|
|
m_Selector.RefreshNotes();
|
2003-01-30 07:18:33 +00:00
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_COPY:
|
2004-05-24 03:41:39 +00:00
|
|
|
ASSERT( !pSteps );
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( pSourceNotes );
|
|
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
2003-08-03 00:13:55 +00:00
|
|
|
// Song allocates all of the other Steps.
|
|
|
|
|
Steps* pNewNotes = new Steps;
|
2004-05-24 03:32:56 +00:00
|
|
|
pNewNotes->CopyFrom( pSourceNotes, st );
|
2003-01-30 07:18:33 +00:00
|
|
|
pNewNotes->SetDifficulty( dc );
|
2004-05-24 03:41:39 +00:00
|
|
|
pSong->AddSteps( pNewNotes );
|
2003-01-30 07:18:33 +00:00
|
|
|
|
2003-08-03 00:13:55 +00:00
|
|
|
SCREENMAN->SystemMessage( "Steps created from copy." );
|
2005-03-05 09:11:56 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
|
2003-02-22 01:58:56 +00:00
|
|
|
m_Selector.RefreshNotes();
|
2003-01-30 07:18:33 +00:00
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_AUTOGEN:
|
2004-05-24 03:41:39 +00:00
|
|
|
ASSERT( !pSteps );
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( pSourceNotes );
|
|
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
2003-08-03 00:13:55 +00:00
|
|
|
// Song allocates all of the other Steps.
|
|
|
|
|
Steps* pNewNotes = new Steps;
|
2004-05-24 03:32:56 +00:00
|
|
|
pNewNotes->AutogenFrom( pSourceNotes, st );
|
2003-02-22 01:58:56 +00:00
|
|
|
pNewNotes->DeAutogen();
|
|
|
|
|
pNewNotes->SetDifficulty( dc ); // override difficulty with the user's choice
|
2004-05-24 03:41:39 +00:00
|
|
|
pSong->AddSteps( pNewNotes );
|
2003-01-30 07:18:33 +00:00
|
|
|
|
2003-08-03 00:13:55 +00:00
|
|
|
SCREENMAN->SystemMessage( "Steps created from AutoGen." );
|
2005-03-05 09:11:56 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
|
2003-02-22 01:58:56 +00:00
|
|
|
m_Selector.RefreshNotes();
|
2003-01-30 07:18:33 +00:00
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_BLANK:
|
2004-05-24 03:41:39 +00:00
|
|
|
ASSERT( !pSteps );
|
2003-01-30 07:18:33 +00:00
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
2003-08-03 00:13:55 +00:00
|
|
|
// Song allocates all of the other Steps.
|
|
|
|
|
Steps* pNewNotes = new Steps;
|
2004-05-24 03:32:56 +00:00
|
|
|
pNewNotes->CreateBlank( st );
|
2003-01-30 07:18:33 +00:00
|
|
|
pNewNotes->SetDifficulty( dc );
|
|
|
|
|
pNewNotes->SetMeter( 1 );
|
2004-05-24 03:41:39 +00:00
|
|
|
pSong->AddSteps( pNewNotes );
|
2003-01-30 07:18:33 +00:00
|
|
|
|
2003-08-03 00:13:55 +00:00
|
|
|
SCREENMAN->SystemMessage( "Blank Steps created." );
|
2005-03-05 09:11:56 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathS(m_sName,"create") );
|
2003-02-22 01:58:56 +00:00
|
|
|
m_Selector.RefreshNotes();
|
2003-01-30 07:18:33 +00:00
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuBack( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2004-05-01 23:19:33 +00:00
|
|
|
Back( SM_GoToPrevScreen );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-07-26 22:53:22 +00:00
|
|
|
SOUND->StopMusic();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2004-01-01 01:21:59 +00:00
|
|
|
|
2004-05-22 00:12:57 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2002-2004 Chris Danford
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|