2003-02-16 04:01:45 +00:00
#include "global.h"
2002-05-20 08:59:37 +00:00
/*
-----------------------------------------------------------------------------
2002-06-29 11:59:09 +00:00
Class: ScreenEdit
2002-05-20 08:59:37 +00:00
2002-06-29 11:59:09 +00:00
Desc: See header.
2002-05-20 08:59:37 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-06-29 11:59:09 +00:00
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenEdit.h"
#include "PrefsManager.h"
#include "SongManager.h"
#include "ScreenManager.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-05-20 08:59:37 +00:00
#include "GameManager.h"
#include "GameConstantsAndTypes.h"
#include "RageLog.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2002-10-18 19:01:32 +00:00
#include "InputMapper.h"
2002-11-11 04:53:31 +00:00
#include "RageLog.h"
#include <math.h>
#include "ThemeManager.h"
2002-11-29 20:37:12 +00:00
#include "SDL_keysym.h" // for SDLKeys
2003-02-18 23:15:38 +00:00
#include "ScreenMiniMenu.h"
2003-02-19 06:27:20 +00:00
#include "NoteSkinManager.h"
2003-02-22 01:58:56 +00:00
#include "Notes.h"
2002-09-26 06:05:32 +00:00
#include <utility>
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
2003-02-18 23:15:38 +00:00
const float RECORD_HOLD_SECONDS = 0.3f ;
2002-10-18 19:01:32 +00:00
2002-05-20 08:59:37 +00:00
//
// Defines specific to GameScreenTitleMenu
//
const float MAX_SECONDS_CAN_BE_OFF_BY = 0.20f ;
2002-08-17 06:44:04 +00:00
const float GRAY_ARROW_Y = ARROW_SIZE * 1.5 ;
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
const float DEBUG_X = SCREEN_LEFT + 10 ;
const float DEBUG_Y = CENTER_Y - 100 ;
2002-05-20 08:59:37 +00:00
2002-08-23 20:18:29 +00:00
const float SHORTCUTS_X = CENTER_X - 150 ;
const float SHORTCUTS_Y = CENTER_Y ;
2002-08-17 06:44:04 +00:00
2003-02-18 23:15:38 +00:00
const float HELP_X = SCREEN_LEFT ;
const float HELP_Y = CENTER_Y ;
const float HELP_TEXT_X = SCREEN_LEFT + 4 ;
const float HELP_TEXT_Y = 40 ;
const float INFO_X = SCREEN_RIGHT ;
const float INFO_Y = CENTER_Y ;
const float INFO_TEXT_X = SCREEN_RIGHT - 114 ;
const float INFO_TEXT_Y = 40 ;
2002-05-20 08:59:37 +00:00
const float MENU_WIDTH = 110 ;
2002-08-17 06:44:04 +00:00
const float EDIT_X = CENTER_X ;
const float EDIT_GRAY_Y = GRAY_ARROW_Y ;
2002-05-20 08:59:37 +00:00
2003-02-18 23:15:38 +00:00
const float PLAYER_X = CENTER_X ;
2002-07-02 00:27:58 +00:00
const float PLAYER_Y = SCREEN_TOP ;
2002-09-26 06:05:32 +00:00
const float ACTION_MENU_ITEM_X = CENTER_X - 200 ;
const float ACTION_MENU_ITEM_START_Y = SCREEN_TOP + 24 ;
const float ACTION_MENU_ITEM_SPACING_Y = 18 ;
const float NAMING_MENU_ITEM_X = CENTER_X - 200 ;
const float NAMING_MENU_ITEM_START_Y = SCREEN_TOP + 24 ;
const float NAMING_MENU_ITEM_SPACING_Y = 18 ;
2002-08-17 06:44:04 +00:00
2003-02-18 23:15:38 +00:00
CachedThemeMetric TICK_EARLY_SECONDS ( "ScreenGameplay" , "TickEarlySeconds" );
const ScreenMessage SM_BackFromMainMenu = ( ScreenMessage )( SM_User + 1 );
const ScreenMessage SM_BackFromAreaMenu = ( ScreenMessage )( SM_User + 2 );
const ScreenMessage SM_BackFromEditNotesStatistics = ( ScreenMessage )( SM_User + 3 );
const ScreenMessage SM_BackFromEditOptions = ( ScreenMessage )( SM_User + 4 );
const ScreenMessage SM_BackFromEditSongInfo = ( ScreenMessage )( SM_User + 5 );
2003-02-07 23:58:21 +00:00
2002-06-29 11:59:09 +00:00
const CString HELP_TEXT =
2003-02-18 23:15:38 +00:00
"Up/Down: \n change beat \n "
"Left/Right: \n change snap \n "
"Number keys: \n add/remove \n tap note \n "
"Create hold note: \n Hold a number \n while moving \n Up or Down \n "
2003-02-19 05:46:09 +00:00
"Space bar: \n Set area \n marker \n "
"Enter: \n Area Menu \n "
"Escape: \n Main Menu \n "
"F1: \n Show \n keyboard \n shortcuts \n " ;
2002-08-17 06:44:04 +00:00
2002-06-29 11:59:09 +00:00
2003-02-19 05:46:09 +00:00
MiniMenuDefinition g_KeyboardShortcuts =
{
"Keyboard Shortcuts" ,
9 ,
{
{ "PgUp/PgDn: jump measure" , false , 1 , 0 , { "" } },
{ "Home/End: jump to first/last beat" , false , 1 , 0 , { "" } },
{ "Ctrl + Up/Down: Change zoom" , false , 1 , 0 , { "" } },
{ "Shift + Up/Down: Drag area marker" , false , 1 , 0 , { "" } },
2003-02-22 01:58:56 +00:00
{ "P: Play selection" , false , 1 , 0 , { "" } },
{ "Ctrl + P: Play whole song" , false , 1 , 0 , { "" } },
2003-02-19 05:46:09 +00:00
{ "F7/F8: Decrease/increase BPM at cur beat" , false , 1 , 0 , { "" } },
{ "F9/F10: Decrease/increase stop at cur beat" , false , 1 , 0 , { "" } },
{ "F11/F12: Decrease/increase music offset" , false , 1 , 0 , { "" } },
2003-03-05 02:38:17 +00:00
/* XXX: This would be better as a single submenu, to let people tweak
* and play the sample several times (without having to re-enter the
* menu each time), so it doesn't use a whole bunch of hotkeys. */
2003-02-19 05:46:09 +00:00
{ "[ and ]: Decrease/increase sample music start" , false , 1 , 0 , { "" } },
{ "{ and }: Decrease/increase sample music length" , false , 1 , 0 , { "" } },
2003-03-05 02:38:17 +00:00
{ "M: Play sample music" , false , 1 , 0 , { "" } },
2003-02-19 05:46:09 +00:00
}
};
2003-02-18 23:15:38 +00:00
MiniMenuDefinition g_MainMenu =
{
"Main Menu" ,
ScreenEdit :: NUM_MAIN_MENU_CHOICES ,
{
{ "Edit Notes Statistics" , true , 1 , 0 , { "" } },
{ "Play Whole Song" , true , 1 , 0 , { "" } },
{ "Save" , true , 1 , 0 , { "" } },
{ "Player Options" , true , 1 , 0 , { "" } },
{ "Song Options" , true , 1 , 0 , { "" } },
{ "Edit Song Info" , true , 1 , 0 , { "" } },
{ "Add/Edit BPM Change" , true , 1 , 0 , { "" } },
{ "Add/Edit Stop" , true , 1 , 0 , { "" } },
{ "Add/Edit BG Change" , true , 1 , 0 , { "" } },
{ "Play preview music" , true , 1 , 0 , { "" } },
{ "Exit" , true , 1 , 0 , { "" } },
}
2002-08-17 06:44:04 +00:00
};
2002-06-29 11:59:09 +00:00
2003-02-18 23:15:38 +00:00
MiniMenuDefinition g_AreaMenu =
{
"Area Menu" ,
ScreenEdit :: NUM_AREA_MENU_CHOICES ,
{
2003-02-22 00:48:38 +00:00
{ "Cut" , true , 1 , 0 , { "" } },
{ "Copy" , true , 1 , 0 , { "" } },
{ "Paste at current beat" , true , 1 , 0 , { "" } },
{ "Paste at begin marker" , true , 1 , 0 , { "" } },
{ "Clear" , true , 1 , 0 , { "" } },
{ "Quantize" , true , NUM_NOTE_TYPES , 0 , { "4TH" , "8TH" , "12TH" , "16TH" , "24TH" , "32ND" } },
{ "Transform" , true , ScreenEdit :: NUM_TRANSFORM_TYPES , 0 , { "Little" , "Wide" , "Big" , "Quick" , "Left" , "Right" , "Mirror" , "Shuffle" , "Super Shuffle" , "Backwards" , "Swap Sides" } },
{ "Play selection" , true , 1 , 0 , { "" } },
{ "Record in selection" , true , 1 , 0 , { "" } },
2003-02-18 23:15:38 +00:00
{ "Insert blank beat and shift down" , true , 1 , 0 , { "" } },
{ "Delete blank beat and shift up" , true , 1 , 0 , { "" } },
}
2002-09-26 06:05:32 +00:00
};
2002-05-20 08:59:37 +00:00
2003-02-18 23:15:38 +00:00
MiniMenuDefinition g_EditNotesStatistics =
{
"Statistics" ,
ScreenEdit :: NUM_EDIT_NOTES_STATISTICS_CHOICES ,
{
{ "Difficulty" , true , 5 , 0 , { "BEGINNER" , "EASY" , "MEDIUM" , "HARD" , "CHALLENGE" } },
{ "Meter" , true , 11 , 0 , { "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" , "10" , "11" } },
{ "Description" , true , 1 , 0 , { "" } },
{ "Tap Notes" , false , 1 , 0 , { "" } },
{ "Hold Notes" , false , 1 , 0 , { "" } },
{ "Stream" , false , 1 , 0 , { "" } },
{ "Voltage" , false , 1 , 0 , { "" } },
{ "Air" , false , 1 , 0 , { "" } },
{ "Freeze" , false , 1 , 0 , { "" } },
{ "Chaos" , false , 1 , 0 , { "" } },
}
};
MiniMenuDefinition g_EditSongInfo =
{
"Edit Song Info" ,
ScreenEdit :: NUM_EDIT_SONG_INFO_CHOICES ,
{
{ "Main title" , true , 1 , 0 , { "" } },
{ "Sub title" , true , 1 , 0 , { "" } },
{ "Artist" , true , 1 , 0 , { "" } },
{ "Main title transliteration" , true , 1 , 0 , { "" } },
{ "Sub title transliteration" , true , 1 , 0 , { "" } },
{ "Artist transliteration" , true , 1 , 0 , { "" } },
}
};
2002-05-20 08:59:37 +00:00
ScreenEdit :: ScreenEdit ()
{
2002-07-31 19:40:40 +00:00
LOG -> Trace ( "ScreenEdit::ScreenEdit()" );
2002-05-20 08:59:37 +00:00
2003-02-18 23:15:38 +00:00
TICK_EARLY_SECONDS . Refresh ();
2002-08-17 06:44:04 +00:00
// set both players to joined so the credit message doesn't show
for ( int p = 0 ; p < NUM_PLAYERS ; p ++ )
2002-08-20 21:00:56 +00:00
GAMESTATE -> m_bSideIsJoined [ p ] = true ;
2002-08-17 06:44:04 +00:00
SCREENMAN -> RefreshCreditsMessages ();
2002-08-29 04:56:03 +00:00
m_iRowLastCrossed = - 1 ;
2002-08-17 06:44:04 +00:00
2002-07-23 01:41:40 +00:00
m_pSong = GAMESTATE -> m_pCurSong ;
2002-07-02 00:27:58 +00:00
2002-07-23 01:41:40 +00:00
m_pNotes = GAMESTATE -> m_pCurNotes [ PLAYER_1 ];
2002-08-24 08:28:44 +00:00
2002-05-20 08:59:37 +00:00
2002-07-03 03:13:13 +00:00
NoteData noteData ;
m_pNotes -> GetNoteData ( & noteData );
2002-07-28 20:28:37 +00:00
m_EditMode = MODE_EDITING ;
GAMESTATE -> m_bEditing = true ;
2002-05-20 08:59:37 +00:00
2002-08-01 20:30:40 +00:00
GAMESTATE -> m_fSongBeat = 0 ;
m_fTrailingBeat = GAMESTATE -> m_fSongBeat ;
2002-08-01 13:42:56 +00:00
2003-01-25 11:05:12 +00:00
GAMESTATE -> m_PlayerOptions [ PLAYER_1 ]. m_fScrollSpeed = 1 ;
2003-02-19 06:27:20 +00:00
GAMESTATE -> m_SongOptions . m_fMusicRate = 1 ;
NOTESKIN -> SwitchNoteSkin ( PLAYER_1 , "note" ); // change noteskin before loading all of the edit Actors
2002-05-20 08:59:37 +00:00
2003-03-09 00:55:49 +00:00
m_BGAnimation . LoadFromAniDir ( THEME -> GetPathTo ( "BGAnimations" , "ScreenEdit background" ) );
2002-05-20 08:59:37 +00:00
2002-08-21 22:48:33 +00:00
shiftAnchor = - 1 ;
2002-08-13 23:26:46 +00:00
m_SnapDisplay . SetXY ( EDIT_X , EDIT_GRAY_Y );
2002-08-17 06:44:04 +00:00
m_SnapDisplay . Load ( PLAYER_1 );
2002-08-13 23:26:46 +00:00
m_SnapDisplay . SetZoom ( 0.5f );
2002-05-20 08:59:37 +00:00
2002-07-02 00:27:58 +00:00
m_GrayArrowRowEdit . SetXY ( EDIT_X , EDIT_GRAY_Y );
2002-07-28 20:28:37 +00:00
m_GrayArrowRowEdit . Load ( PLAYER_1 );
2002-05-20 08:59:37 +00:00
m_GrayArrowRowEdit . SetZoom ( 0.5f );
2002-07-02 00:27:58 +00:00
m_NoteFieldEdit . SetXY ( EDIT_X , EDIT_GRAY_Y );
2002-05-20 08:59:37 +00:00
m_NoteFieldEdit . SetZoom ( 0.5f );
2003-02-19 07:59:00 +00:00
m_NoteFieldEdit . Load ( & noteData , PLAYER_1 , - 240 , 800 );
2002-05-20 08:59:37 +00:00
2002-10-31 05:52:12 +00:00
m_rectRecordBack . StretchTo ( RectI ( SCREEN_LEFT , SCREEN_TOP , SCREEN_RIGHT , SCREEN_BOTTOM ) );
2002-10-28 05:30:45 +00:00
m_rectRecordBack . SetDiffuse ( RageColor ( 0 , 0 , 0 , 0 ) );
2002-05-20 08:59:37 +00:00
2002-07-02 00:27:58 +00:00
m_GrayArrowRowRecord . SetXY ( EDIT_X , EDIT_GRAY_Y );
2002-07-28 20:28:37 +00:00
m_GrayArrowRowRecord . Load ( PLAYER_1 );
2002-05-20 08:59:37 +00:00
m_GrayArrowRowRecord . SetZoom ( 1.0f );
2002-07-02 00:27:58 +00:00
m_NoteFieldRecord . SetXY ( EDIT_X , EDIT_GRAY_Y );
2002-05-20 08:59:37 +00:00
m_NoteFieldRecord . SetZoom ( 1.0f );
2003-01-31 21:34:34 +00:00
m_NoteFieldRecord . Load ( & noteData , PLAYER_1 , - 150 , 350 );
2002-05-20 08:59:37 +00:00
2003-02-01 05:16:38 +00:00
m_Clipboard . SetNumTracks ( m_NoteFieldEdit . GetNumTracks () );
2002-07-02 00:27:58 +00:00
2003-02-19 06:27:20 +00:00
NOTESKIN -> SwitchNoteSkin ( PLAYER_1 , "default" ); // change noteskin back to default before loading player
2003-02-25 02:51:04 +00:00
m_Player . Load ( PLAYER_1 , & noteData , NULL , NULL , NULL );
2002-07-02 00:27:58 +00:00
m_Player . SetXY ( PLAYER_X , PLAYER_Y );
2002-05-20 08:59:37 +00:00
m_Fade . SetClosed ();
2003-03-09 00:55:49 +00:00
m_sprHelp . Load ( THEME -> GetPathTo ( "Graphics" , "ScreenEdit help" ) );
2003-02-18 23:15:38 +00:00
m_sprHelp . SetHorizAlign ( Actor :: align_left );
m_sprHelp . SetXY ( HELP_X , HELP_Y );
2002-05-20 08:59:37 +00:00
2002-08-13 23:26:46 +00:00
m_textHelp . LoadFromFont ( THEME -> GetPathTo ( "Fonts" , "normal" ) );
2003-02-18 23:15:38 +00:00
m_textHelp . SetXY ( HELP_TEXT_X , HELP_TEXT_Y );
2002-06-29 11:59:09 +00:00
m_textHelp . SetHorizAlign ( Actor :: align_left );
2003-02-18 23:15:38 +00:00
m_textHelp . SetVertAlign ( Actor :: align_top );
2002-06-29 11:59:09 +00:00
m_textHelp . SetZoom ( 0.5f );
m_textHelp . SetText ( HELP_TEXT );
2002-05-20 08:59:37 +00:00
2003-03-09 00:55:49 +00:00
m_sprInfo . Load ( THEME -> GetPathTo ( "Graphics" , "ScreenEdit Info" ) );
2003-02-18 23:15:38 +00:00
m_sprInfo . SetHorizAlign ( Actor :: align_right );
m_sprInfo . SetXY ( INFO_X , INFO_Y );
2002-08-17 06:44:04 +00:00
2003-02-18 23:15:38 +00:00
m_textInfo . LoadFromFont ( THEME -> GetPathTo ( "Fonts" , "normal" ) );
m_textInfo . SetXY ( INFO_TEXT_X , INFO_TEXT_Y );
m_textInfo . SetHorizAlign ( Actor :: align_left );
m_textInfo . SetVertAlign ( Actor :: align_top );
m_textInfo . SetZoom ( 0.5f );
//m_textInfo.SetText(); // set this below every frame
2002-06-29 11:59:09 +00:00
2003-03-09 00:55:49 +00:00
m_soundChangeLine . Load ( THEME -> GetPathTo ( "Sounds" , "ScreenEdit line" ) );
m_soundChangeSnap . Load ( THEME -> GetPathTo ( "Sounds" , "ScreenEdit snap" ) );
m_soundMarker . Load ( THEME -> GetPathTo ( "Sounds" , "ScreenEdit marker" ) );
2002-05-20 08:59:37 +00:00
2002-06-29 11:59:09 +00:00
2002-12-22 08:51:41 +00:00
m_soundMusic . Load ( m_pSong -> GetMusicPath ());
m_soundMusic . SetAccurateSync ( true );
2002-05-20 08:59:37 +00:00
2003-03-09 00:55:49 +00:00
m_soundAssistTick . Load ( THEME -> GetPathTo ( "Sounds" , "ScreenEdit assist tick" ) );
2002-08-29 04:56:03 +00:00
2002-05-20 08:59:37 +00:00
m_Fade . OpenWipingRight ();
}
ScreenEdit ::~ ScreenEdit ()
{
2002-07-31 19:40:40 +00:00
LOG -> Trace ( "ScreenEdit::~ScreenEdit()" );
2002-12-22 08:51:41 +00:00
m_soundMusic . StopPlaying ();
2002-05-20 08:59:37 +00:00
}
2002-10-18 01:09:59 +00:00
// play assist ticks
bool ScreenEdit :: PlayTicks () const
{
// Sound cards have a latency between when a sample is Play()ed and when the sound
// will start coming out the speaker. Compensate for this by boosting
// fPositionSeconds ahead
if ( GAMESTATE -> m_SongOptions . m_AssistType != SongOptions :: ASSIST_TICK )
return false ;
float fPositionSeconds = GAMESTATE -> m_fMusicSeconds ;
// HACK: Play the sound a little bit early to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing.
2003-02-18 23:15:38 +00:00
fPositionSeconds += ( SOUNDMAN -> GetPlayLatency () + ( float ) TICK_EARLY_SECONDS ) * m_soundMusic . GetPlaybackRate ();
2003-02-07 23:58:21 +00:00
float fSongBeat = GAMESTATE -> m_pCurSong -> GetBeatFromElapsedTime ( fPositionSeconds );
2002-10-18 01:09:59 +00:00
int iRowNow = BeatToNoteRowNotRounded ( fSongBeat );
iRowNow = max ( 0 , iRowNow );
static int iRowLastCrossed = 0 ;
bool bAnyoneHasANote = false ; // set this to true if any player has a note at one of the indicies we crossed
for ( int r = iRowLastCrossed + 1 ; r <= iRowNow ; r ++ ) // for each index we crossed since the last update
bAnyoneHasANote |= m_Player . IsThereANoteAtRow ( r );
iRowLastCrossed = iRowNow ;
return bAnyoneHasANote ;
}
2002-05-20 08:59:37 +00:00
2003-03-05 02:38:17 +00:00
void ScreenEdit :: PlayPreviewMusic ()
{
SOUNDMAN -> PlayMusic ( "" );
SOUNDMAN -> PlayMusic ( m_pSong -> GetMusicPath (), false ,
m_pSong -> m_fMusicSampleStartSeconds ,
m_pSong -> m_fMusicSampleLengthSeconds ,
1.5f );
}
2002-05-20 08:59:37 +00:00
void ScreenEdit :: Update ( float fDeltaTime )
{
2003-03-13 08:43:04 +00:00
if ( m_soundMusic . IsPlaying ())
2003-02-22 00:22:27 +00:00
GAMESTATE -> UpdateSongPosition ( m_soundMusic . GetPositionSeconds ());
2002-08-01 20:30:40 +00:00
2002-10-18 19:01:32 +00:00
if ( m_EditMode == MODE_RECORDING )
{
// add or extend holds
for ( int t = 0 ; t < GAMESTATE -> GetCurrentStyleDef () -> m_iColsPerPlayer ; t ++ ) // for each track
{
StyleInput StyleI ( PLAYER_1 , t );
float fSecsHeld = INPUTMAPPER -> GetSecsHeld ( StyleI );
2003-02-18 23:15:38 +00:00
if ( fSecsHeld > RECORD_HOLD_SECONDS )
2002-10-18 19:01:32 +00:00
{
// add or extend hold
const float fHoldStartSeconds = m_soundMusic . GetPositionSeconds () - fSecsHeld ;
float fStartBeat = m_pSong -> GetBeatFromElapsedTime ( fHoldStartSeconds );
float fEndBeat = GAMESTATE -> m_fSongBeat ;
// Round hold start and end to the nearest snap interval
fStartBeat = froundf ( fStartBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ()) );
fEndBeat = froundf ( fEndBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ()) );
// create a new hold note
HoldNote newHN = { t , fStartBeat , fEndBeat };
m_NoteFieldRecord . AddHoldNote ( newHN );
}
}
}
2002-07-28 20:28:37 +00:00
if ( m_EditMode == MODE_RECORDING || m_EditMode == MODE_PLAYING )
2002-05-20 08:59:37 +00:00
{
2003-03-13 08:43:04 +00:00
// check for end of playback/record
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
if ( GAMESTATE -> m_fSongBeat > m_NoteFieldEdit . m_fEndMarker + 4 ) // give a one measure lead out
2002-05-20 08:59:37 +00:00
{
2002-07-28 20:28:37 +00:00
if ( m_EditMode == MODE_RECORDING )
2002-05-20 08:59:37 +00:00
{
2002-08-18 23:20:18 +00:00
TransitionFromRecordToEdit ();
2002-05-20 08:59:37 +00:00
}
2002-07-28 20:28:37 +00:00
else if ( m_EditMode == MODE_PLAYING )
2002-05-20 08:59:37 +00:00
{
2002-10-18 00:45:09 +00:00
TransitionToEdit ();
2002-05-20 08:59:37 +00:00
}
2002-10-18 00:30:00 +00:00
GAMESTATE -> m_fSongBeat = m_NoteFieldEdit . m_fEndMarker ;
2002-05-20 08:59:37 +00:00
}
}
2002-10-08 00:39:31 +00:00
m_BGAnimation . Update ( fDeltaTime );
2002-08-13 23:26:46 +00:00
m_SnapDisplay . Update ( fDeltaTime );
2002-07-28 20:28:37 +00:00
m_GrayArrowRowEdit . Update ( fDeltaTime );
m_NoteFieldEdit . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
m_Fade . Update ( fDeltaTime );
2003-02-18 23:15:38 +00:00
m_sprHelp . Update ( fDeltaTime );
2002-06-29 11:59:09 +00:00
m_textHelp . Update ( fDeltaTime );
2003-02-18 23:15:38 +00:00
m_sprInfo . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
m_textInfo . Update ( fDeltaTime );
2002-08-17 06:44:04 +00:00
m_rectRecordBack . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
2002-07-28 20:28:37 +00:00
if ( m_EditMode == MODE_RECORDING )
2002-05-20 08:59:37 +00:00
{
2002-07-28 20:28:37 +00:00
m_GrayArrowRowRecord . Update ( fDeltaTime );
m_NoteFieldRecord . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
}
2002-07-28 20:28:37 +00:00
if ( m_EditMode == MODE_PLAYING )
2002-05-20 08:59:37 +00:00
{
2002-07-28 20:28:37 +00:00
m_Player . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
}
2002-07-31 19:40:40 +00:00
//LOG->Trace( "ScreenEdit::Update(%f)", fDeltaTime );
2002-05-20 08:59:37 +00:00
Screen :: Update ( fDeltaTime );
2002-06-29 11:59:09 +00:00
// Update trailing beat
2002-08-01 20:30:40 +00:00
float fDelta = GAMESTATE -> m_fSongBeat - m_fTrailingBeat ;
2002-06-29 11:59:09 +00:00
if ( fabsf ( fDelta ) < 0.01 )
2002-05-20 08:59:37 +00:00
{
2002-08-01 20:30:40 +00:00
m_fTrailingBeat = GAMESTATE -> m_fSongBeat ; // snap
2002-05-20 08:59:37 +00:00
}
2002-06-29 11:59:09 +00:00
else
{
float fSign = fDelta / fabsf ( fDelta );
2003-02-26 23:26:57 +00:00
float fMoveDelta = fSign * fDeltaTime * 40 / GAMESTATE -> m_CurrentPlayerOptions [ PLAYER_1 ]. m_fScrollSpeed ;
2002-06-29 11:59:09 +00:00
if ( fabsf ( fMoveDelta ) > fabsf ( fDelta ) )
fMoveDelta = fDelta ;
2002-08-01 20:30:40 +00:00
m_fTrailingBeat += fMoveDelta ;
2002-06-29 11:59:09 +00:00
if ( fabsf ( fDelta ) > 10 )
2002-08-01 20:30:40 +00:00
m_fTrailingBeat += fDelta * fDeltaTime * 5 ;
2002-06-29 11:59:09 +00:00
}
2002-07-28 20:28:37 +00:00
m_NoteFieldEdit . Update ( fDeltaTime );
2002-05-20 08:59:37 +00:00
2002-10-18 01:09:59 +00:00
if ( m_EditMode == MODE_PLAYING && PlayTicks ())
m_soundAssistTick . Play ();
2002-08-29 04:56:03 +00:00
2002-05-20 08:59:37 +00:00
CString sNoteType ;
2002-10-18 19:01:32 +00:00
switch ( m_SnapDisplay . GetNoteType () )
2002-05-20 08:59:37 +00:00
{
2002-10-18 19:01:32 +00:00
case NOTE_TYPE_4TH : sNoteType = "4th notes" ; break ;
case NOTE_TYPE_8TH : sNoteType = "8th notes" ; break ;
case NOTE_TYPE_12TH : sNoteType = "12th notes" ; break ;
case NOTE_TYPE_16TH : sNoteType = "16th notes" ; break ;
case NOTE_TYPE_24TH : sNoteType = "24th notes" ; break ;
case NOTE_TYPE_32ND : sNoteType = "32nd notes" ; break ;
2002-08-23 20:18:29 +00:00
default : ASSERT ( 0 );
2002-05-20 08:59:37 +00:00
}
2002-08-29 04:56:03 +00:00
2003-03-13 08:43:04 +00:00
static float fUpdateCounter = 0.5 ;
fUpdateCounter -= fDeltaTime ;
if ( fUpdateCounter < 0 )
2002-06-29 11:59:09 +00:00
{
2003-03-13 08:43:04 +00:00
fUpdateCounter = 0.5 ;
int iNumTapNotes = m_NoteFieldEdit . GetNumTapNotes ();
int iNumHoldNotes = m_NoteFieldEdit . GetNumHoldNotes ();
CString sText ;
sText += ssprintf ( "Current Beat: \n %.2f \n " , GAMESTATE -> m_fSongBeat );
sText += ssprintf ( "Snap to: \n %s \n " , sNoteType . GetString () );
sText += ssprintf ( "Selection begin: \n %s \n " , m_NoteFieldEdit . m_fBeginMarker ==- 1 ? "not set" : ssprintf ( "%.2f" , m_NoteFieldEdit . m_fBeginMarker ). GetString () );
sText += ssprintf ( "Selection end: \n %s \n " , m_NoteFieldEdit . m_fEndMarker ==- 1 ? "not set" : ssprintf ( "%.2f" , m_NoteFieldEdit . m_fEndMarker ). GetString () );
sText += ssprintf ( "Difficulty: \n %s \n " , DifficultyToString ( m_pNotes -> GetDifficulty () ). GetString () );
sText += ssprintf ( "Description: \n %s \n " , GAMESTATE -> m_pCurNotes [ PLAYER_1 ] ? GAMESTATE -> m_pCurNotes [ PLAYER_1 ] -> GetDescription (). GetString () : "no description" );
sText += ssprintf ( "Main title: \n %s \n " , m_pSong -> m_sMainTitle . GetString () );
sText += ssprintf ( "Tap Notes: \n %d \n " , iNumTapNotes );
sText += ssprintf ( "Hold Notes: \n %d \n " , iNumHoldNotes );
sText += ssprintf ( "Beat 0 Offset: \n %.2f secs \n " , m_pSong -> m_fBeat0OffsetInSeconds );
sText += ssprintf ( "Preview Start: \n %.2f secs \n " , m_pSong -> m_fMusicSampleStartSeconds );
sText += ssprintf ( "Preview Length: \n %.2f secs \n " , m_pSong -> m_fMusicSampleLengthSeconds );
m_textInfo . SetText ( sText );
2002-06-29 11:59:09 +00:00
}
2002-05-20 08:59:37 +00:00
}
void ScreenEdit :: DrawPrimitives ()
{
2003-02-19 07:59:00 +00:00
// m_rectRecordBack.Draw();
2002-08-01 20:30:40 +00:00
2003-02-19 07:59:00 +00:00
switch ( m_EditMode )
2002-05-20 08:59:37 +00:00
{
2003-02-19 07:59:00 +00:00
case MODE_EDITING :
{
m_BGAnimation . Draw ();
m_SnapDisplay . Draw ();
m_GrayArrowRowEdit . Draw ();
// HACK: Make NoteFieldEdit draw using the trailing beat
float fSongBeat = GAMESTATE -> m_fSongBeat ; // save song beat
GAMESTATE -> m_fSongBeat = m_fTrailingBeat ; // put trailing beat in effect
m_NoteFieldEdit . Draw ();
GAMESTATE -> m_fSongBeat = fSongBeat ; // restore real song beat
m_sprHelp . Draw ();
m_textHelp . Draw ();
m_sprInfo . Draw ();
m_textInfo . Draw ();
m_Fade . Draw ();
}
break ;
case MODE_RECORDING :
m_BGAnimation . Draw ();
2002-05-20 08:59:37 +00:00
m_GrayArrowRowRecord . Draw ();
m_NoteFieldRecord . Draw ();
2003-02-19 07:59:00 +00:00
break ;
case MODE_PLAYING :
m_BGAnimation . Draw ();
2002-05-20 08:59:37 +00:00
m_Player . Draw ();
2003-02-19 07:59:00 +00:00
break ;
default :
ASSERT ( 0 );
2002-05-20 08:59:37 +00:00
}
Screen :: DrawPrimitives ();
}
void ScreenEdit :: Input ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI )
{
2003-02-25 00:33:42 +00:00
// LOG->Trace( "ScreenEdit::Input()" );
2002-05-20 08:59:37 +00:00
2002-07-28 20:28:37 +00:00
switch ( m_EditMode )
2002-05-20 08:59:37 +00:00
{
2002-07-28 20:28:37 +00:00
case MODE_EDITING : InputEdit ( DeviceI , type , GameI , MenuI , StyleI ); break ;
case MODE_RECORDING : InputRecord ( DeviceI , type , GameI , MenuI , StyleI ); break ;
case MODE_PLAYING : InputPlay ( DeviceI , type , GameI , MenuI , StyleI ); break ;
2002-08-17 06:44:04 +00:00
default : ASSERT ( 0 );
2002-05-20 08:59:37 +00:00
}
}
void ScreenEdit :: InputEdit ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI )
{
2002-08-17 06:44:04 +00:00
if ( DeviceI . device != DEVICE_KEYBOARD )
return ;
2002-05-20 08:59:37 +00:00
2002-08-21 22:48:33 +00:00
if ( type == IET_RELEASE )
{
switch ( DeviceI . button ) {
2002-11-29 20:37:12 +00:00
case SDLK_LSHIFT :
case SDLK_RSHIFT :
2002-08-21 22:48:33 +00:00
shiftAnchor = - 1 ;
break ;
}
return ;
}
2002-08-17 06:44:04 +00:00
switch ( DeviceI . button )
2002-05-20 08:59:37 +00:00
{
2002-11-29 20:37:12 +00:00
case SDLK_1 :
case SDLK_2 :
case SDLK_3 :
case SDLK_4 :
case SDLK_5 :
case SDLK_6 :
case SDLK_7 :
case SDLK_8 :
case SDLK_9 :
case SDLK_0 :
2002-05-20 08:59:37 +00:00
{
2002-08-17 06:44:04 +00:00
if ( type != IET_FIRST_PRESS )
break ; // We only care about first presses
2002-05-20 08:59:37 +00:00
2002-11-29 20:37:12 +00:00
int iCol = DeviceI . button - SDLK_1 ;
2002-08-17 06:44:04 +00:00
const float fSongBeat = GAMESTATE -> m_fSongBeat ;
const int iSongIndex = BeatToNoteRow ( fSongBeat );
2002-05-20 08:59:37 +00:00
2003-02-01 05:16:38 +00:00
if ( iCol >= m_NoteFieldEdit . GetNumTracks () ) // this button is not in the range of columns for this StyleDef
2002-06-29 11:59:09 +00:00
break ;
2002-05-20 08:59:37 +00:00
2002-10-13 17:38:11 +00:00
/* XXX: easier to do with 4s */
2002-08-17 06:44:04 +00:00
// check for to see if the user intended to remove a HoldNote
bool bRemovedAHoldNote = false ;
2002-11-02 22:46:15 +00:00
for ( int i = 0 ; i < m_NoteFieldEdit . GetNumHoldNotes (); i ++ ) // for each HoldNote
2002-08-17 06:44:04 +00:00
{
2002-11-02 22:46:15 +00:00
const HoldNote & hn = m_NoteFieldEdit . GetHoldNote ( i );
2003-02-16 20:27:53 +00:00
if ( iCol == hn . iTrack && // the notes correspond
fSongBeat >= hn . fStartBeat && fSongBeat <= hn . fEndBeat ) // the cursor lies within this HoldNote
2002-06-29 11:59:09 +00:00
{
2002-08-17 06:44:04 +00:00
m_NoteFieldEdit . RemoveHoldNote ( i );
bRemovedAHoldNote = true ;
break ; // stop iterating over all HoldNotes
2002-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
}
2002-06-29 11:59:09 +00:00
2002-08-17 06:44:04 +00:00
if ( ! bRemovedAHoldNote )
2002-05-20 08:59:37 +00:00
{
2002-08-17 06:44:04 +00:00
// We didn't remove a HoldNote, so the user wants to add or delete a TapNote
2002-11-03 01:49:13 +00:00
if ( m_NoteFieldEdit . GetTapNote ( iCol , iSongIndex ) == TAP_EMPTY )
m_NoteFieldEdit . SetTapNote ( iCol , iSongIndex , TAP_TAP );
2002-06-29 11:59:09 +00:00
else
2002-11-03 01:49:13 +00:00
m_NoteFieldEdit . SetTapNote ( iCol , iSongIndex , TAP_EMPTY );
2002-05-20 08:59:37 +00:00
}
2002-07-02 00:27:58 +00:00
}
2002-08-17 06:44:04 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_UP :
case SDLK_DOWN :
case SDLK_PAGEUP :
case SDLK_PAGEDOWN :
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
if ( INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_LCTRL )) ||
INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_RCTRL )) )
{
2003-02-26 23:26:57 +00:00
float & fScrollSpeed = GAMESTATE -> m_PlayerOptions [ PLAYER_1 ]. m_fScrollSpeed ;
2003-02-18 23:15:38 +00:00
if ( DeviceI . button == SDLK_UP )
{
2003-02-26 23:26:57 +00:00
if ( fScrollSpeed == 4 )
2003-02-18 23:15:38 +00:00
{
2003-02-26 23:26:57 +00:00
fScrollSpeed = 2 ;
2003-02-18 23:15:38 +00:00
m_soundMarker . Play ();
}
2003-02-26 23:26:57 +00:00
else if ( fScrollSpeed == 2 )
2003-02-18 23:15:38 +00:00
{
2003-02-26 23:26:57 +00:00
fScrollSpeed = 1 ;
2003-02-18 23:15:38 +00:00
m_soundMarker . Play ();
}
break ;
}
else if ( DeviceI . button == SDLK_DOWN )
{
2003-02-26 23:26:57 +00:00
if ( fScrollSpeed == 2 )
2003-02-18 23:15:38 +00:00
{
2003-02-26 23:26:57 +00:00
fScrollSpeed = 4 ;
2003-02-18 23:15:38 +00:00
m_soundMarker . Play ();
}
2003-02-26 23:26:57 +00:00
else if ( fScrollSpeed == 1 )
2003-02-20 21:50:01 +00:00
{
2003-02-26 23:26:57 +00:00
fScrollSpeed = 2 ;
2003-02-20 21:50:01 +00:00
m_soundMarker . Play ();
}
2003-02-18 23:15:38 +00:00
break ;
}
}
2002-09-07 10:33:44 +00:00
float fBeatsToMove = 0.f ;
2002-08-17 06:44:04 +00:00
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_UP :
case SDLK_DOWN :
2002-10-18 19:01:32 +00:00
fBeatsToMove = NoteTypeToBeat ( m_SnapDisplay . GetNoteType () );
2002-11-29 20:37:12 +00:00
if ( DeviceI . button == SDLK_UP )
2002-08-17 06:44:04 +00:00
fBeatsToMove *= - 1 ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_PAGEUP :
case SDLK_PAGEDOWN :
2002-08-17 06:44:04 +00:00
fBeatsToMove = BEATS_PER_MEASURE ;
2002-11-29 20:37:12 +00:00
if ( DeviceI . button == SDLK_PAGEUP )
2002-08-17 06:44:04 +00:00
fBeatsToMove *= - 1 ;
}
const float fStartBeat = GAMESTATE -> m_fSongBeat ;
const float fEndBeat = GAMESTATE -> m_fSongBeat + fBeatsToMove ;
// check to see if they're holding a button
2003-02-01 05:16:38 +00:00
for ( int col = 0 ; col < m_NoteFieldEdit . GetNumTracks () && col <= 10 ; col ++ )
2002-08-17 06:44:04 +00:00
{
2002-11-29 20:37:12 +00:00
const DeviceInput di ( DEVICE_KEYBOARD , SDLK_1 + col );
2002-08-17 06:44:04 +00:00
2002-09-08 06:11:59 +00:00
if ( ! INPUTFILTER -> IsBeingPressed ( di ) )
2002-08-21 22:48:33 +00:00
continue ;
// create a new hold note
HoldNote newHN ;
2003-02-16 20:27:53 +00:00
newHN . iTrack = col ;
newHN . fStartBeat = min ( fStartBeat , fEndBeat );
newHN . fEndBeat = max ( fStartBeat , fEndBeat );
2002-09-09 05:22:02 +00:00
2003-02-16 20:27:53 +00:00
newHN . fStartBeat = max ( newHN . fStartBeat , 0 );
newHN . fEndBeat = max ( newHN . fEndBeat , 0 );
2002-09-09 05:22:02 +00:00
2002-08-21 22:48:33 +00:00
m_NoteFieldEdit . AddHoldNote ( newHN );
}
2002-11-29 20:37:12 +00:00
if ( INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_LSHIFT )) ||
INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_RSHIFT )))
2002-08-21 22:48:33 +00:00
{
/* Shift is being held.
*
* If this is the first time we've moved since shift was depressed,
* the old position (before this move) becomes the start pos: */
if ( shiftAnchor == - 1 )
shiftAnchor = fStartBeat ;
if ( fEndBeat == shiftAnchor )
2002-08-17 06:44:04 +00:00
{
2002-08-21 22:48:33 +00:00
/* We're back at the anchor, so we have nothing selected. */
m_NoteFieldEdit . m_fBeginMarker = m_NoteFieldEdit . m_fEndMarker = - 1 ;
}
else
{
m_NoteFieldEdit . m_fBeginMarker = shiftAnchor ;
m_NoteFieldEdit . m_fEndMarker = fEndBeat ;
if ( m_NoteFieldEdit . m_fBeginMarker > m_NoteFieldEdit . m_fEndMarker )
swap ( m_NoteFieldEdit . m_fBeginMarker , m_NoteFieldEdit . m_fEndMarker );
2002-08-17 06:44:04 +00:00
}
}
GAMESTATE -> m_fSongBeat += fBeatsToMove ;
2003-03-06 22:50:44 +00:00
GAMESTATE -> m_fSongBeat = max ( GAMESTATE -> m_fSongBeat , 0 );
2002-10-18 19:01:32 +00:00
GAMESTATE -> m_fSongBeat = froundf ( GAMESTATE -> m_fSongBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ()) );
2002-08-17 06:44:04 +00:00
m_soundChangeLine . Play ();
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_HOME :
2002-08-17 06:44:04 +00:00
GAMESTATE -> m_fSongBeat = 0 ;
m_soundChangeLine . Play ();
break ;
2002-11-29 20:37:12 +00:00
case SDLK_END :
2002-08-17 06:44:04 +00:00
GAMESTATE -> m_fSongBeat = m_NoteFieldEdit . GetLastBeat ();
m_soundChangeLine . Play ();
break ;
2003-02-19 05:46:09 +00:00
case SDLK_LEFT :
2002-08-17 06:44:04 +00:00
m_SnapDisplay . PrevSnapMode ();
OnSnapModeChange ();
break ;
2003-02-19 05:46:09 +00:00
case SDLK_RIGHT :
2002-08-17 06:44:04 +00:00
m_SnapDisplay . NextSnapMode ();
OnSnapModeChange ();
break ;
2002-11-29 20:37:12 +00:00
case SDLK_SPACE :
2003-02-18 23:15:38 +00:00
if ( m_NoteFieldEdit . m_fBeginMarker ==- 1 && m_NoteFieldEdit . m_fEndMarker ==- 1 )
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
// lay begin marker
m_NoteFieldEdit . m_fBeginMarker = GAMESTATE -> m_fSongBeat ;
2002-08-17 06:44:04 +00:00
}
2003-02-18 23:15:38 +00:00
else if ( m_NoteFieldEdit . m_fEndMarker ==- 1 ) // only begin marker is laid
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
if ( GAMESTATE -> m_fSongBeat == m_NoteFieldEdit . m_fBeginMarker )
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
m_NoteFieldEdit . m_fBeginMarker = - 1 ;
2002-08-17 06:44:04 +00:00
}
else
{
2003-02-18 23:15:38 +00:00
m_NoteFieldEdit . m_fEndMarker = max ( m_NoteFieldEdit . m_fBeginMarker , GAMESTATE -> m_fSongBeat );
m_NoteFieldEdit . m_fBeginMarker = min ( m_NoteFieldEdit . m_fBeginMarker , GAMESTATE -> m_fSongBeat );
2002-08-17 06:44:04 +00:00
}
}
2003-02-18 23:15:38 +00:00
else // both markers are laid
{
2003-02-22 00:22:27 +00:00
m_NoteFieldEdit . m_fBeginMarker = GAMESTATE -> m_fSongBeat ;
m_NoteFieldEdit . m_fEndMarker = - 1 ;
2003-02-18 23:15:38 +00:00
}
m_soundMarker . Play ();
break ;
case SDLK_RETURN :
case SDLK_KP_ENTER :
{
// update enabled/disabled in g_AreaMenu
bool bAreaSelected = m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 ;
g_AreaMenu . lines [ cut ]. bEnabled = bAreaSelected ;
g_AreaMenu . lines [ copy ]. bEnabled = bAreaSelected ;
2003-02-22 00:48:38 +00:00
g_AreaMenu . lines [ paste_at_current_beat ]. bEnabled = this -> m_Clipboard . GetLastBeat () != 0 ;
g_AreaMenu . lines [ paste_at_begin_marker ]. bEnabled = this -> m_Clipboard . GetLastBeat () != 0 && m_NoteFieldEdit . m_fBeginMarker !=- 1 ;
2003-02-18 23:15:38 +00:00
g_AreaMenu . lines [ clear ]. bEnabled = bAreaSelected ;
g_AreaMenu . lines [ quantize ]. bEnabled = bAreaSelected ;
g_AreaMenu . lines [ transform ]. bEnabled = bAreaSelected ;
2003-02-19 05:46:09 +00:00
g_AreaMenu . lines [ play ]. bEnabled = bAreaSelected ;
2003-02-18 23:15:38 +00:00
g_AreaMenu . lines [ record ]. bEnabled = bAreaSelected ;
SCREENMAN -> MiniMenu ( & g_AreaMenu , SM_BackFromAreaMenu );
}
2002-08-17 06:44:04 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_ESCAPE :
2003-02-18 23:15:38 +00:00
SCREENMAN -> MiniMenu ( & g_MainMenu , SM_BackFromMainMenu );
2002-08-17 06:44:04 +00:00
break ;
2003-02-19 05:46:09 +00:00
case SDLK_F1 :
SCREENMAN -> MiniMenu ( & g_KeyboardShortcuts , SM_None );
2002-08-29 04:56:03 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_F7 :
case SDLK_F8 :
2002-08-17 06:44:04 +00:00
{
float fBPM = m_pSong -> GetBPMAtBeat ( GAMESTATE -> m_fSongBeat );
float fDeltaBPM ;
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_F7 : fDeltaBPM = - 0.020f ; break ;
case SDLK_F8 : fDeltaBPM = + 0.020f ; break ;
2002-09-07 10:31:35 +00:00
default : ASSERT ( 0 ); return ;
2002-08-17 06:44:04 +00:00
}
switch ( type )
{
case IET_SLOW_REPEAT : fDeltaBPM *= 10 ; break ;
case IET_FAST_REPEAT : fDeltaBPM *= 40 ; break ;
}
float fNewBPM = fBPM + fDeltaBPM ;
2002-10-31 02:20:11 +00:00
unsigned i ;
for ( i = 0 ; i < m_pSong -> m_BPMSegments . size (); i ++ )
2002-08-17 06:44:04 +00:00
if ( m_pSong -> m_BPMSegments [ i ]. m_fStartBeat == GAMESTATE -> m_fSongBeat )
break ;
2002-10-31 02:20:11 +00:00
if ( i == m_pSong -> m_BPMSegments . size () ) // there is no BPMSegment at the current beat
2002-08-17 06:44:04 +00:00
{
// create a new BPMSegment
m_pSong -> AddBPMSegment ( BPMSegment ( GAMESTATE -> m_fSongBeat , fNewBPM ) );
}
else // BPMSegment being modified is m_BPMSegments[i]
{
if ( i > 0 && fabsf ( m_pSong -> m_BPMSegments [ i - 1 ]. m_fBPM - fNewBPM ) < 0.025f )
2002-10-31 04:11:08 +00:00
m_pSong -> m_BPMSegments . erase ( m_pSong -> m_BPMSegments . begin () + i ,
m_pSong -> m_BPMSegments . begin () + i + 1 );
2002-08-17 06:44:04 +00:00
else
m_pSong -> m_BPMSegments [ i ]. m_fBPM = fNewBPM ;
}
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_F9 :
case SDLK_F10 :
2002-08-17 06:44:04 +00:00
{
2002-08-23 20:18:29 +00:00
float fStopDelta ;
2002-08-17 06:44:04 +00:00
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_F9 : fStopDelta = - 0.02f ; break ;
case SDLK_F10 : fStopDelta = + 0.02f ; break ;
2002-09-07 10:31:35 +00:00
default : ASSERT ( 0 ); return ;
2002-08-17 06:44:04 +00:00
}
switch ( type )
{
2002-08-23 20:18:29 +00:00
case IET_SLOW_REPEAT : fStopDelta *= 10 ; break ;
case IET_FAST_REPEAT : fStopDelta *= 40 ; break ;
2002-08-17 06:44:04 +00:00
}
2002-10-31 02:20:11 +00:00
unsigned i ;
for ( i = 0 ; i < m_pSong -> m_StopSegments . size (); i ++ )
2002-08-17 06:44:04 +00:00
{
if ( m_pSong -> m_StopSegments [ i ]. m_fStartBeat == GAMESTATE -> m_fSongBeat )
break ;
}
2002-10-31 02:20:11 +00:00
if ( i == m_pSong -> m_StopSegments . size () ) // there is no BPMSegment at the current beat
2002-08-17 06:44:04 +00:00
{
// create a new StopSegment
2002-08-23 20:18:29 +00:00
if ( fStopDelta > 0 )
m_pSong -> AddStopSegment ( StopSegment ( GAMESTATE -> m_fSongBeat , fStopDelta ) );
2002-08-17 06:44:04 +00:00
}
else // StopSegment being modified is m_StopSegments[i]
{
2002-08-23 20:18:29 +00:00
m_pSong -> m_StopSegments [ i ]. m_fStopSeconds += fStopDelta ;
2002-08-17 06:44:04 +00:00
if ( m_pSong -> m_StopSegments [ i ]. m_fStopSeconds <= 0 )
2002-10-31 04:11:08 +00:00
m_pSong -> m_StopSegments . erase ( m_pSong -> m_StopSegments . begin () + i ,
m_pSong -> m_StopSegments . begin () + i + 1 );
2002-08-17 06:44:04 +00:00
}
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_F11 :
case SDLK_F12 :
2002-08-17 06:44:04 +00:00
{
float fOffsetDelta ;
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_F11 : fOffsetDelta = - 0.02f ; break ;
case SDLK_F12 : fOffsetDelta = + 0.02f ; break ;
2002-09-07 10:31:35 +00:00
default : ASSERT ( 0 ); return ;
2002-08-17 06:44:04 +00:00
}
switch ( type )
{
case IET_SLOW_REPEAT : fOffsetDelta *= 10 ; break ;
case IET_FAST_REPEAT : fOffsetDelta *= 40 ; break ;
}
m_pSong -> m_fBeat0OffsetInSeconds += fOffsetDelta ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_LEFTBRACKET :
case SDLK_RIGHTBRACKET :
2002-08-17 06:44:04 +00:00
{
float fDelta ;
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_LEFTBRACKET : fDelta = - 0.02f ; break ;
case SDLK_RIGHTBRACKET : fDelta = + 0.02f ; break ;
2002-09-07 10:31:35 +00:00
default : ASSERT ( 0 ); return ;
2002-08-17 06:44:04 +00:00
}
switch ( type )
{
case IET_SLOW_REPEAT : fDelta *= 10 ; break ;
case IET_FAST_REPEAT : fDelta *= 40 ; break ;
}
2002-11-29 20:37:12 +00:00
if ( INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_LSHIFT )) ||
INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_RSHIFT )))
2002-08-21 22:48:33 +00:00
{
m_pSong -> m_fMusicSampleLengthSeconds += fDelta ;
m_pSong -> m_fMusicSampleLengthSeconds = max ( m_pSong -> m_fMusicSampleLengthSeconds , 0 );
} else {
m_pSong -> m_fMusicSampleStartSeconds += fDelta ;
m_pSong -> m_fMusicSampleStartSeconds = max ( m_pSong -> m_fMusicSampleStartSeconds , 0 );
}
2002-08-17 06:44:04 +00:00
}
break ;
2003-03-05 02:38:17 +00:00
case SDLK_m :
PlayPreviewMusic ();
break ;
2003-02-22 01:58:56 +00:00
case SDLK_p :
{
if ( INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_LCTRL )) ||
INPUTFILTER -> IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_RCTRL )) )
HandleMainMenuChoice ( play_whole_song , NULL );
else
if ( m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 )
HandleAreaMenuChoice ( play , NULL );
}
break ;
2002-05-20 08:59:37 +00:00
}
}
void ScreenEdit :: InputRecord ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI )
{
2002-11-29 20:37:12 +00:00
if ( DeviceI . device == DEVICE_KEYBOARD && DeviceI . button == SDLK_ESCAPE )
2002-05-20 08:59:37 +00:00
{
2002-10-18 19:01:32 +00:00
TransitionFromRecordToEdit ();
return ;
}
if ( StyleI . player != PLAYER_1 )
return ; // ignore
const int iCol = StyleI . col ;
switch ( type )
{
case IET_FIRST_PRESS :
2002-05-20 08:59:37 +00:00
{
2002-10-18 19:01:32 +00:00
// Add a tap
float fBeat = GAMESTATE -> m_fSongBeat ;
fBeat = froundf ( fBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ()) );
const int iRow = BeatToNoteRow ( fBeat );
if ( iRow < 0 )
2002-10-18 02:02:53 +00:00
break ;
2002-05-20 08:59:37 +00:00
2002-10-25 04:59:26 +00:00
m_NoteFieldRecord . SetTapNote ( iCol , iRow , TAP_TAP );
2002-10-18 19:01:32 +00:00
m_GrayArrowRowRecord . Step ( iCol );
}
break ;
case IET_SLOW_REPEAT :
case IET_FAST_REPEAT :
case IET_RELEASE :
// don't add or extend holds here
break ;
2002-05-20 08:59:37 +00:00
}
}
void ScreenEdit :: InputPlay ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI )
{
if ( type != IET_FIRST_PRESS )
return ;
if ( DeviceI . device == DEVICE_KEYBOARD )
{
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_ESCAPE :
2002-10-18 00:45:09 +00:00
TransitionToEdit ();
2002-05-20 08:59:37 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_F11 :
case SDLK_F12 :
2002-09-11 04:49:07 +00:00
{
float fOffsetDelta ;
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_F11 : fOffsetDelta = - 0.020f ; break ;
case SDLK_F12 : fOffsetDelta = + 0.020f ; break ;
2002-09-11 04:49:07 +00:00
default : ASSERT ( 0 ); return ;
}
switch ( type )
{
case IET_SLOW_REPEAT : fOffsetDelta *= 10 ; break ;
case IET_FAST_REPEAT : fOffsetDelta *= 40 ; break ;
}
m_pSong -> m_fBeat0OffsetInSeconds += fOffsetDelta ;
}
break ;
2002-05-20 08:59:37 +00:00
}
}
switch ( StyleI . player )
{
case PLAYER_1 :
2002-07-28 20:28:37 +00:00
m_Player . Step ( StyleI . col );
2002-05-20 08:59:37 +00:00
return ;
}
}
2002-10-18 00:45:09 +00:00
/* Switch to editing. */
void ScreenEdit :: TransitionToEdit ()
2002-05-20 08:59:37 +00:00
{
2002-07-28 20:28:37 +00:00
m_EditMode = MODE_EDITING ;
2002-12-22 08:51:41 +00:00
m_soundMusic . StopPlaying ();
2002-10-18 00:45:09 +00:00
m_rectRecordBack . StopTweening ();
m_rectRecordBack . BeginTweening ( 0.5f );
2002-10-28 05:30:45 +00:00
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0 ) );
2002-10-18 00:53:22 +00:00
/* Make sure we're snapped. */
2002-10-18 19:01:32 +00:00
GAMESTATE -> m_fSongBeat = froundf ( GAMESTATE -> m_fSongBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ()) );
2002-10-18 00:58:21 +00:00
/* Playing and recording have lead-ins, which may start before beat 0;
* make sure we don't stay there if we escaped out early. */
GAMESTATE -> m_fSongBeat = max ( GAMESTATE -> m_fSongBeat , 0 );
2002-10-18 00:45:09 +00:00
}
void ScreenEdit :: TransitionFromRecordToEdit ()
{
TransitionToEdit ();
2002-05-20 08:59:37 +00:00
int iNoteIndexBegin = BeatToNoteRow ( m_NoteFieldEdit . m_fBeginMarker );
int iNoteIndexEnd = BeatToNoteRow ( m_NoteFieldEdit . m_fEndMarker );
// delete old TapNotes in the range
m_NoteFieldEdit . ClearRange ( iNoteIndexBegin , iNoteIndexEnd );
2002-10-18 00:59:34 +00:00
m_NoteFieldEdit . CopyRange ( & m_NoteFieldRecord , iNoteIndexBegin , iNoteIndexEnd , iNoteIndexBegin );
2002-05-20 08:59:37 +00:00
}
void ScreenEdit :: HandleScreenMessage ( const ScreenMessage SM )
{
switch ( SM )
{
2002-08-27 23:31:41 +00:00
case SM_GoToPrevScreen :
2002-08-27 03:59:22 +00:00
SCREENMAN -> SetNewScreen ( "ScreenEditMenu" );
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 ( "ScreenEditMenu" );
2002-05-20 08:59:37 +00:00
break ;
2003-02-18 23:15:38 +00:00
case SM_BackFromMainMenu :
HandleMainMenuChoice ( ( MainMenuChoice ) ScreenMiniMenu :: s_iLastLine , ScreenMiniMenu :: s_iLastAnswers );
break ;
case SM_BackFromAreaMenu :
HandleAreaMenuChoice ( ( AreaMenuChoice ) ScreenMiniMenu :: s_iLastLine , ScreenMiniMenu :: s_iLastAnswers );
break ;
case SM_BackFromEditNotesStatistics :
HandleEditNotesStatisticsChoice ( ( EditNotesStatisticsChoice ) ScreenMiniMenu :: s_iLastLine , ScreenMiniMenu :: s_iLastAnswers );
break ;
case SM_BackFromEditSongInfo :
HandleEditSongInfoChoice ( ( EditSongInfoChoice ) ScreenMiniMenu :: s_iLastLine , ScreenMiniMenu :: s_iLastAnswers );
break ;
2003-02-19 05:46:09 +00:00
case SM_RegainingFocus :
// coming back from PlayerOptions or SongOptions
m_soundMusic . SetPlaybackRate ( GAMESTATE -> m_SongOptions . m_fMusicRate );
break ;
2002-05-20 08:59:37 +00:00
}
}
void ScreenEdit :: OnSnapModeChange ()
{
2002-06-29 11:59:09 +00:00
m_soundChangeSnap . Play ();
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
NoteType nt = m_SnapDisplay . GetNoteType ();
2002-08-01 20:30:40 +00:00
int iStepIndex = BeatToNoteRow ( GAMESTATE -> m_fSongBeat );
2002-05-20 08:59:37 +00:00
int iElementsPerNoteType = BeatToNoteRow ( NoteTypeToBeat ( nt ) );
int iStepIndexHangover = iStepIndex % iElementsPerNoteType ;
2002-08-01 20:30:40 +00:00
GAMESTATE -> m_fSongBeat -= NoteRowToBeat ( iStepIndexHangover );
2002-05-20 08:59:37 +00:00
}
2002-08-17 06:44:04 +00:00
2003-02-19 05:46:09 +00:00
// Helper function for below
// Begin helper functions for InputEdit
void AddBGChange ( CString sBGName )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
unsigned i ;
for ( i = 0 ; i < pSong -> m_BackgroundChanges . size (); i ++ )
{
if ( pSong -> m_BackgroundChanges [ i ]. m_fStartBeat == GAMESTATE -> m_fSongBeat )
break ;
}
if ( i != pSong -> m_BackgroundChanges . size () ) // there is already a BGChange here
pSong -> m_BackgroundChanges . erase ( pSong -> m_BackgroundChanges . begin () + i ,
pSong -> m_BackgroundChanges . begin () + i + 1 );
// create a new BGChange
if ( sBGName != "" )
pSong -> AddBackgroundChange ( BackgroundChange ( GAMESTATE -> m_fSongBeat , sBGName ) );
}
void ChangeDescription ( CString sNew )
{
Notes * pNotes = GAMESTATE -> m_pCurNotes [ PLAYER_1 ];
pNotes -> SetDescription ( sNew );
}
void ChangeMainTitle ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sMainTitle = sNew ;
}
void ChangeSubTitle ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sSubTitle = sNew ;
}
void ChangeArtist ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sArtist = sNew ;
}
void ChangeMainTitleTranslit ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sMainTitleTranslit = sNew ;
}
void ChangeSubTitleTranslit ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sSubTitleTranslit = sNew ;
}
void ChangeArtistTranslit ( CString sNew )
{
Song * pSong = GAMESTATE -> m_pCurSong ;
pSong -> m_sArtistTranslit = sNew ;
}
// End helper functions
2003-02-18 23:15:38 +00:00
void ScreenEdit :: HandleMainMenuChoice ( MainMenuChoice c , int * iAnswers )
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
switch ( c )
{
case edit_notes_statistics :
{
Notes * pNotes = GAMESTATE -> m_pCurNotes [ PLAYER_1 ];
float fMusicSeconds = m_soundMusic . GetLengthSeconds ();
g_EditNotesStatistics . lines [ difficulty ]. iDefaultOption = pNotes -> GetDifficulty ();
2003-02-19 05:46:09 +00:00
g_EditNotesStatistics . lines [ meter ]. iDefaultOption = pNotes -> GetMeter () - 1 ;
2003-02-18 23:15:38 +00:00
strcpy ( g_EditNotesStatistics . lines [ description ]. szOptionsText [ 0 ], pNotes -> GetDescription () );
strcpy ( g_EditNotesStatistics . lines [ tap_notes ]. szOptionsText [ 0 ], ssprintf ( "%d" , m_NoteFieldEdit . GetNumTapNotes ()) );
strcpy ( g_EditNotesStatistics . lines [ hold_notes ]. szOptionsText [ 0 ], ssprintf ( "%d" , m_NoteFieldEdit . GetNumHoldNotes ()) );
strcpy ( g_EditNotesStatistics . lines [ stream ]. szOptionsText [ 0 ], ssprintf ( "%f" , NoteDataUtil :: GetStreamRadarValue ( m_NoteFieldEdit , fMusicSeconds )) );
strcpy ( g_EditNotesStatistics . lines [ voltage ]. szOptionsText [ 0 ], ssprintf ( "%f" , NoteDataUtil :: GetVoltageRadarValue ( m_NoteFieldEdit , fMusicSeconds )) );
strcpy ( g_EditNotesStatistics . lines [ air ]. szOptionsText [ 0 ], ssprintf ( "%f" , NoteDataUtil :: GetAirRadarValue ( m_NoteFieldEdit , fMusicSeconds )) );
strcpy ( g_EditNotesStatistics . lines [ freeze ]. szOptionsText [ 0 ], ssprintf ( "%f" , NoteDataUtil :: GetFreezeRadarValue ( m_NoteFieldEdit , fMusicSeconds )) );
strcpy ( g_EditNotesStatistics . lines [ chaos ]. szOptionsText [ 0 ], ssprintf ( "%f" , NoteDataUtil :: GetChaosRadarValue ( m_NoteFieldEdit , fMusicSeconds )) );
SCREENMAN -> MiniMenu ( & g_EditNotesStatistics , SM_BackFromEditNotesStatistics );
}
break ;
case play_whole_song :
2003-02-19 05:46:09 +00:00
{
m_NoteFieldEdit . m_fBeginMarker = 0 ;
m_NoteFieldEdit . m_fEndMarker = m_NoteFieldEdit . GetLastBeat ();
HandleAreaMenuChoice ( play , NULL );
}
2003-02-18 23:15:38 +00:00
break ;
case save :
{
// copy edit into current Notes
Notes * pNotes = GAMESTATE -> m_pCurNotes [ PLAYER_1 ];
ASSERT ( pNotes );
pNotes -> SetNoteData ( & m_NoteFieldEdit );
GAMESTATE -> m_pCurSong -> Save ();
SCREENMAN -> SystemMessage ( "Saved as SM and DWI." );
SOUNDMAN -> PlayOnce ( THEME -> GetPathTo ( "Sounds" , "edit save" ) );
}
break ;
case player_options :
2003-02-19 05:46:09 +00:00
SCREENMAN -> AddNewScreenToTop ( "ScreenPlayerOptions" );
2003-02-18 23:15:38 +00:00
break ;
case song_options :
2003-02-19 05:46:09 +00:00
SCREENMAN -> AddNewScreenToTop ( "ScreenSongOptions" );
2003-02-18 23:15:38 +00:00
break ;
case edit_song_info :
2003-02-19 05:46:09 +00:00
{
Song * pSong = GAMESTATE -> m_pCurSong ;
strcpy ( g_EditSongInfo . lines [ main_title ]. szOptionsText [ 0 ], pSong -> m_sMainTitle );
strcpy ( g_EditSongInfo . lines [ sub_title ]. szOptionsText [ 0 ], pSong -> m_sSubTitle );
strcpy ( g_EditSongInfo . lines [ artist ]. szOptionsText [ 0 ], pSong -> m_sArtist );
strcpy ( g_EditSongInfo . lines [ main_title_transliteration ]. szOptionsText [ 0 ], pSong -> m_sMainTitleTranslit );
strcpy ( g_EditSongInfo . lines [ sub_title_transliteration ]. szOptionsText [ 0 ], pSong -> m_sSubTitleTranslit );
strcpy ( g_EditSongInfo . lines [ artist_transliteration ]. szOptionsText [ 0 ], pSong -> m_sArtistTranslit );
SCREENMAN -> MiniMenu ( & g_EditSongInfo , SM_BackFromEditSongInfo );
}
2003-02-18 23:15:38 +00:00
break ;
case edit_bpm :
break ;
case edit_stop :
break ;
case edit_bg_change :
2003-02-19 05:46:09 +00:00
{
CString sOldBackground ;
unsigned i ;
for ( i = 0 ; i < m_pSong -> m_BackgroundChanges . size (); i ++ )
{
if ( m_pSong -> m_BackgroundChanges [ i ]. m_fStartBeat == GAMESTATE -> m_fSongBeat )
break ;
}
if ( i != m_pSong -> m_BackgroundChanges . size () ) // there is already a BGChange here
sOldBackground = m_pSong -> m_BackgroundChanges [ i ]. m_sBGName ;
SCREENMAN -> TextEntry ( SM_None , "Type a background name. \n Press Enter to keep, \n Escape to cancel. \n Enter an empty string to remove \n the Background Change." , sOldBackground , AddBGChange , NULL );
}
2003-02-18 23:15:38 +00:00
break ;
case play_preview_music :
2003-03-05 02:38:17 +00:00
PlayPreviewMusic ();
2003-02-18 23:15:38 +00:00
break ;
case exit :
SCREENMAN -> SetNewScreen ( "ScreenEditMenu" );
break ;
default :
ASSERT ( 0 );
};
2002-08-17 06:44:04 +00:00
}
2003-02-18 23:15:38 +00:00
void ScreenEdit :: HandleAreaMenuChoice ( AreaMenuChoice c , int * iAnswers )
2002-08-17 06:44:04 +00:00
{
2003-02-18 23:15:38 +00:00
switch ( c )
{
case cut :
{
2003-02-22 00:48:38 +00:00
HandleAreaMenuChoice ( copy , NULL );
HandleAreaMenuChoice ( clear , NULL );
2003-02-18 23:15:38 +00:00
}
break ;
case copy :
{
ASSERT ( m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 );
int iFirstRow = BeatToNoteRow ( m_NoteFieldEdit . m_fBeginMarker );
int iLastRow = BeatToNoteRow ( m_NoteFieldEdit . m_fEndMarker );
m_Clipboard . ClearAll ();
m_Clipboard . CopyRange ( & m_NoteFieldEdit , iFirstRow , iLastRow );
}
break ;
2003-02-22 00:48:38 +00:00
case paste_at_current_beat :
2003-02-18 23:15:38 +00:00
{
int iSrcFirstRow = 0 ;
int iSrcLastRow = BeatToNoteRow ( m_Clipboard . GetLastBeat () );
int iDestFirstRow = BeatToNoteRow ( GAMESTATE -> m_fSongBeat );
m_NoteFieldEdit . CopyRange ( & m_Clipboard , iSrcFirstRow , iSrcLastRow , iDestFirstRow );
}
break ;
2003-02-22 00:48:38 +00:00
case paste_at_begin_marker :
{
ASSERT ( m_NoteFieldEdit . m_fBeginMarker !=- 1 );
int iSrcFirstRow = 0 ;
int iSrcLastRow = BeatToNoteRow ( m_Clipboard . GetLastBeat () );
int iDestFirstRow = BeatToNoteRow ( m_NoteFieldEdit . m_fBeginMarker );
m_NoteFieldEdit . CopyRange ( & m_Clipboard , iSrcFirstRow , iSrcLastRow , iDestFirstRow );
}
break ;
2003-02-18 23:15:38 +00:00
case clear :
{
ASSERT ( m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 );
int iFirstRow = BeatToNoteRow ( m_NoteFieldEdit . m_fBeginMarker );
int iLastRow = BeatToNoteRow ( m_NoteFieldEdit . m_fEndMarker );
m_NoteFieldEdit . ClearRange ( iFirstRow , iLastRow );
}
break ;
case quantize :
{
NoteType nt = ( NoteType ) iAnswers [ c ];
NoteDataUtil :: SnapToNearestNoteType ( m_NoteFieldEdit , nt , nt , m_NoteFieldEdit . m_fBeginMarker , m_NoteFieldEdit . m_fEndMarker );
}
break ;
case transform :
{
2003-02-22 00:48:38 +00:00
HandleAreaMenuChoice ( cut , NULL );
2003-02-18 23:15:38 +00:00
TransformType tt = ( TransformType ) iAnswers [ c ];
switch ( tt )
{
case little : NoteDataUtil :: Little ( m_Clipboard ); break ;
2003-02-19 22:58:14 +00:00
case wide : NoteDataUtil :: Wide ( m_Clipboard ); break ;
2003-02-20 00:57:52 +00:00
case big : NoteDataUtil :: Big ( m_Clipboard ); break ;
case quick : NoteDataUtil :: Quick ( m_Clipboard ); break ;
2003-02-18 23:15:38 +00:00
case left : NoteDataUtil :: Turn ( m_Clipboard , NoteDataUtil :: left ); break ;
case right : NoteDataUtil :: Turn ( m_Clipboard , NoteDataUtil :: right ); break ;
2003-02-22 00:22:27 +00:00
case mirror : NoteDataUtil :: Turn ( m_Clipboard , NoteDataUtil :: mirror ); break ;
2003-02-18 23:15:38 +00:00
case shuffle : NoteDataUtil :: Turn ( m_Clipboard , NoteDataUtil :: shuffle ); break ;
case super_shuffle : NoteDataUtil :: Turn ( m_Clipboard , NoteDataUtil :: super_shuffle ); break ;
case backwards : NoteDataUtil :: Backwards ( m_Clipboard ); break ;
case swap_sides : NoteDataUtil :: SwapSides ( m_Clipboard ); break ;
default : ASSERT ( 0 );
}
2003-02-22 00:48:38 +00:00
HandleAreaMenuChoice ( paste_at_begin_marker , NULL );
2003-02-18 23:15:38 +00:00
}
break ;
case play :
{
ASSERT ( m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 );
m_EditMode = MODE_PLAYING ;
2003-02-25 02:51:04 +00:00
m_Player . Load ( PLAYER_1 , ( NoteData * ) & m_NoteFieldEdit , NULL , NULL , NULL );
2003-02-18 23:15:38 +00:00
m_rectRecordBack . StopTweening ();
m_rectRecordBack . BeginTweening ( 0.5f );
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) );
GAMESTATE -> m_fSongBeat = m_NoteFieldEdit . m_fBeginMarker - 4 ; // give a 1 measure lead-in
float fStartSeconds = m_pSong -> GetElapsedTimeFromBeat ( GAMESTATE -> m_fSongBeat ) ;
2003-02-25 00:33:42 +00:00
LOG -> Trace ( "Starting playback at %f" , fStartSeconds );
2003-02-18 23:15:38 +00:00
m_soundMusic . SetPlaybackRate ( GAMESTATE -> m_SongOptions . m_fMusicRate );
2003-02-25 00:33:42 +00:00
m_soundMusic . SetPositionSeconds ( fStartSeconds );
2003-02-18 23:15:38 +00:00
}
break ;
case record :
{
ASSERT ( m_NoteFieldEdit . m_fBeginMarker !=- 1 && m_NoteFieldEdit . m_fEndMarker !=- 1 );
m_EditMode = MODE_RECORDING ;
// initialize m_NoteFieldRecord
m_NoteFieldRecord . ClearAll ();
m_NoteFieldRecord . SetNumTracks ( m_NoteFieldEdit . GetNumTracks () );
m_NoteFieldRecord . m_fBeginMarker = m_NoteFieldEdit . m_fBeginMarker ;
m_NoteFieldRecord . m_fEndMarker = m_NoteFieldEdit . m_fEndMarker ;
m_rectRecordBack . StopTweening ();
m_rectRecordBack . BeginTweening ( 0.5f );
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) );
GAMESTATE -> m_fSongBeat = m_NoteFieldEdit . m_fBeginMarker - 4 ; // give a 1 measure lead-in
2003-02-25 00:33:42 +00:00
float fStartSeconds = m_pSong -> GetElapsedTimeFromBeat ( GAMESTATE -> m_fSongBeat );
LOG -> Trace ( "Starting playback at %f" , fStartSeconds );
2003-02-18 23:15:38 +00:00
m_soundMusic . SetPlaybackRate ( GAMESTATE -> m_SongOptions . m_fMusicRate );
2003-02-25 00:33:42 +00:00
m_soundMusic . SetPositionSeconds ( fStartSeconds );
2003-02-18 23:15:38 +00:00
m_soundMusic . StartPlaying ();
}
break ;
case insert_and_shift :
{
NoteData temp ;
temp . SetNumTracks ( m_NoteFieldEdit . GetNumTracks () );
int iTakeFromRow = 0 ;
int iPasteAtRow ;
iTakeFromRow = BeatToNoteRow ( GAMESTATE -> m_fSongBeat );
iPasteAtRow = BeatToNoteRow ( GAMESTATE -> m_fSongBeat + 1 );
temp . CopyRange ( & m_NoteFieldEdit , iTakeFromRow , m_NoteFieldEdit . GetLastRow () );
m_NoteFieldEdit . ClearRange ( min ( iTakeFromRow , iPasteAtRow ), m_NoteFieldEdit . GetLastRow () );
m_NoteFieldEdit . CopyRange ( & temp , 0 , temp . GetLastRow (), iPasteAtRow );
}
break ;
case delete_and_shift :
{
NoteData temp ;
temp . SetNumTracks ( m_NoteFieldEdit . GetNumTracks () );
int iTakeFromRow = 0 ;
int iPasteAtRow ;
iTakeFromRow = BeatToNoteRow ( GAMESTATE -> m_fSongBeat + 1 );
iPasteAtRow = BeatToNoteRow ( GAMESTATE -> m_fSongBeat );
temp . CopyRange ( & m_NoteFieldEdit , iTakeFromRow , m_NoteFieldEdit . GetLastRow () );
m_NoteFieldEdit . ClearRange ( min ( iTakeFromRow , iPasteAtRow ), m_NoteFieldEdit . GetLastRow () );
m_NoteFieldEdit . CopyRange ( & temp , 0 , temp . GetLastRow (), iPasteAtRow );
}
break ;
default :
ASSERT ( 0 );
};
2002-08-17 06:44:04 +00:00
}
2003-02-18 23:15:38 +00:00
void ScreenEdit :: HandleEditNotesStatisticsChoice ( EditNotesStatisticsChoice c , int * iAnswers )
{
2003-02-19 05:46:09 +00:00
Notes * pNotes = GAMESTATE -> m_pCurNotes [ PLAYER_1 ];
Difficulty dc = ( Difficulty ) iAnswers [ difficulty ];
pNotes -> SetDifficulty ( dc );
int iMeter = iAnswers [ meter ] + 1 ;
pNotes -> SetMeter ( iMeter );
2003-02-18 23:15:38 +00:00
switch ( c )
{
case description :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit notes description. \n Press Enter to confirm, \n Escape to cancel." , m_pNotes -> GetDescription (), ChangeDescription , NULL );
2003-02-18 23:15:38 +00:00
break ;
2003-02-19 05:46:09 +00:00
}
2003-02-18 23:15:38 +00:00
}
void ScreenEdit :: HandleEditSongInfoChoice ( EditSongInfoChoice c , int * iAnswers )
{
2003-02-19 05:46:09 +00:00
Song * pSong = GAMESTATE -> m_pCurSong ;
2003-02-18 23:15:38 +00:00
switch ( c )
{
case main_title :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit main title. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sMainTitle , ChangeMainTitle , NULL );
2003-02-18 23:15:38 +00:00
break ;
case sub_title :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit sub title. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sSubTitle , ChangeSubTitle , NULL );
2003-02-18 23:15:38 +00:00
break ;
case artist :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit artist. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sArtist , ChangeArtist , NULL );
2003-02-18 23:15:38 +00:00
break ;
case main_title_transliteration :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit main title transliteration. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sMainTitleTranslit , ChangeMainTitleTranslit , NULL );
2003-02-18 23:15:38 +00:00
break ;
case sub_title_transliteration :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit sub title transliteration. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sSubTitleTranslit , ChangeSubTitleTranslit , NULL );
2003-02-18 23:15:38 +00:00
break ;
case artist_transliteration :
2003-02-19 05:46:09 +00:00
SCREENMAN -> TextEntry ( SM_None , "Edit artist transliteration. \n Press Enter to confirm, \n Escape to cancel." , pSong -> m_sArtistTranslit , ChangeArtistTranslit , NULL );
2003-02-18 23:15:38 +00:00
break ;
default :
ASSERT ( 0 );
};
}