2002-05-20 08:59:37 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-08-13 23:26:46 +00:00
|
|
|
Class: ScreenEditMenu
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
Desc: The main title screen and menu.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-08-13 23:26:46 +00:00
|
|
|
Chris Danford
|
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"
|
2003-01-02 07:54:28 +00:00
|
|
|
#include "RageSoundManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Defines specific to ScreenEditMenu
|
|
|
|
|
//
|
2002-09-03 22:31:06 +00:00
|
|
|
#define EXPLANATION_X THEME->GetMetricF("ScreenEditMenu","ExplanationX")
|
|
|
|
|
#define EXPLANATION_Y THEME->GetMetricF("ScreenEditMenu","ExplanationY")
|
|
|
|
|
#define EXPLANATION_TEXT THEME->GetMetric("ScreenEditMenu","ExplanationText")
|
|
|
|
|
#define HELP_TEXT THEME->GetMetric("ScreenEditMenu","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
|
|
|
|
|
|
|
|
ScreenEditMenu::ScreenEditMenu()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEditMenu::ScreenEditMenu()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
GAMESTATE->m_CurStyle = STYLE_INVALID;
|
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
|
|
|
m_Menu.Load(
|
2002-09-24 02:55:32 +00:00
|
|
|
THEME->GetPathTo("BGAnimations","edit menu"),
|
2002-08-27 23:31:41 +00:00
|
|
|
THEME->GetPathTo("Graphics","edit menu top edge"),
|
2002-09-03 22:31:06 +00:00
|
|
|
HELP_TEXT, false, false, 99
|
2002-08-27 16:53:25 +00:00
|
|
|
);
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Menu );
|
2002-08-27 16:53:25 +00:00
|
|
|
|
|
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_textExplanation.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
|
2002-05-20 08:59:37 +00:00
|
|
|
m_textExplanation.SetXY( EXPLANATION_X, EXPLANATION_Y );
|
2002-06-29 11:59:09 +00:00
|
|
|
m_textExplanation.SetText( EXPLANATION_TEXT );
|
2002-05-20 08:59:37 +00:00
|
|
|
m_textExplanation.SetZoom( 0.7f );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textExplanation );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
m_Fade.SetOpened();
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Fade);
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-02 07:39:58 +00:00
|
|
|
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","edit menu music") );
|
2002-08-27 03:59:22 +00:00
|
|
|
|
2002-08-22 05:57:15 +00:00
|
|
|
m_soundSelect.Load( THEME->GetPathTo("Sounds","menu start") );
|
2003-01-30 07:18:33 +00:00
|
|
|
m_soundCreate.Load( THEME->GetPathTo("Sounds","edit menu create") );
|
2002-08-27 16:53:25 +00:00
|
|
|
|
|
|
|
|
m_Menu.TweenOnScreenFromBlack( SM_None );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ScreenEditMenu::~ScreenEditMenu()
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEditMenu::~ScreenEditMenu()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-08-27 16:53:25 +00:00
|
|
|
void ScreenEditMenu::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
m_Menu.DrawBottomLayer();
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
m_Menu.DrawTopLayer();
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
void ScreenEditMenu::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2002-07-31 19:40:40 +00:00
|
|
|
LOG->Trace( "ScreenEditMenu::Input()" );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenEditMenu::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
2003-01-30 07:18:33 +00:00
|
|
|
case SM_RefreshSelector:
|
|
|
|
|
m_Selector.Refresh();
|
|
|
|
|
break;
|
2002-08-27 23:31:41 +00:00
|
|
|
case SM_GoToPrevScreen:
|
2002-08-27 03:59:22 +00:00
|
|
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// helpers for MenuStart() below
|
|
|
|
|
void DeleteCurNotes()
|
|
|
|
|
{
|
|
|
|
|
Song* pSong = GAMESTATE->m_pCurSong;
|
|
|
|
|
Notes* pNotesToDelete = GAMESTATE->m_pCurNotes[PLAYER_1];
|
|
|
|
|
pSong->RemoveNotes( pNotesToDelete );
|
|
|
|
|
pSong->Save();
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-10-18 02:42:52 +00:00
|
|
|
if( m_Fade.IsClosing() || m_Fade.IsClosed() )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-01-30 07:18:33 +00:00
|
|
|
Song* pSong = m_Selector.GetSelectedSong();
|
|
|
|
|
NotesType nt = m_Selector.GetSelectedNotesType();
|
|
|
|
|
Difficulty dc = m_Selector.GetSelectedDifficulty();
|
|
|
|
|
Notes* pNotes = m_Selector.GetSelectedNotes();
|
|
|
|
|
// NotesType soureNT = m_Selector.GetSelectedSourceNotesType();
|
|
|
|
|
// Difficulty sourceDiff = m_Selector.GetSelectedSourceDifficulty();
|
|
|
|
|
Notes* 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
|
|
|
|
|
|
|
|
GAMESTATE->m_pCurSong = pSong;
|
|
|
|
|
GAMESTATE->m_CurStyle = GAMEMAN->GetEditorStyleForNotesType( nt );
|
|
|
|
|
GAMESTATE->m_pCurNotes[PLAYER_1] = pNotes;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
ASSERT( pNotes );
|
|
|
|
|
SOUNDMAN->StopMusic();
|
|
|
|
|
m_soundSelect.PlayRandom();
|
|
|
|
|
m_Menu.TweenOffScreenToBlack( SM_GoToNextScreen, false );
|
|
|
|
|
m_Fade.CloseWipingRight( SM_None );
|
|
|
|
|
break;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_DELETE:
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( pNotes );
|
|
|
|
|
SCREENMAN->Prompt( SM_RefreshSelector, "These notes will be lost permanently.\nContinue with delete?", true, false, DeleteCurNotes );
|
|
|
|
|
m_Selector.Refresh();
|
|
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_COPY:
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( !pNotes );
|
|
|
|
|
ASSERT( pSourceNotes );
|
|
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
|
|
|
|
// Song allocates all of the other Notes.
|
|
|
|
|
Notes* pNewNotes = new Notes;
|
|
|
|
|
pNewNotes->CopyFrom( pSourceNotes, nt );
|
|
|
|
|
pNewNotes->SetDifficulty( dc );
|
|
|
|
|
pSong->AddNotes( pNewNotes );
|
|
|
|
|
|
|
|
|
|
SCREENMAN->SystemMessage( "Notes created from copy." );
|
|
|
|
|
m_soundCreate.PlayRandom();
|
|
|
|
|
m_Selector.Refresh();
|
|
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_AUTOGEN:
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( !pNotes );
|
|
|
|
|
ASSERT( pSourceNotes );
|
|
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
|
|
|
|
// Song allocates all of the other Notes.
|
|
|
|
|
Notes* pNewNotes = new Notes;
|
2003-02-10 05:49:22 +00:00
|
|
|
pNewNotes->AutogenFrom( pSourceNotes, nt );
|
|
|
|
|
pNewNotes->BakeAutoGen();
|
2003-01-30 07:18:33 +00:00
|
|
|
pNewNotes->SetDifficulty( dc );
|
|
|
|
|
pSong->AddNotes( pNewNotes );
|
|
|
|
|
|
2003-02-10 05:49:22 +00:00
|
|
|
SCREENMAN->SystemMessage( "Notes created from AutoGen." );
|
2003-01-30 07:18:33 +00:00
|
|
|
m_soundCreate.PlayRandom();
|
|
|
|
|
m_Selector.Refresh();
|
|
|
|
|
pSong->Save();
|
|
|
|
|
}
|
|
|
|
|
return;
|
2003-02-11 02:20:38 +00:00
|
|
|
case EditMenu::ACTION_BLANK:
|
2003-01-30 07:18:33 +00:00
|
|
|
ASSERT( !pNotes );
|
|
|
|
|
{
|
|
|
|
|
// Yuck. Doing the memory allocation doesn't seem right since
|
|
|
|
|
// Song allocates all of the other Notes.
|
|
|
|
|
Notes* pNewNotes = new Notes;
|
|
|
|
|
pNewNotes->CreateBlank( nt );
|
|
|
|
|
pNewNotes->SetDifficulty( dc );
|
|
|
|
|
pNewNotes->SetMeter( 1 );
|
|
|
|
|
pSong->AddNotes( pNewNotes );
|
|
|
|
|
|
|
|
|
|
SCREENMAN->SystemMessage( "Blank Notes created." );
|
|
|
|
|
m_soundCreate.PlayRandom();
|
|
|
|
|
m_Selector.Refresh();
|
|
|
|
|
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
|
|
|
{
|
2002-08-27 16:53:25 +00:00
|
|
|
m_Menu.TweenOffScreenToBlack( SM_None, true );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-21 02:16:40 +00:00
|
|
|
SOUNDMAN->StopMusic();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-27 23:31:41 +00:00
|
|
|
m_Fade.CloseWipingLeft( SM_GoToPrevScreen );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|