2002-05-20 08:59:37 +00:00
# include "stdafx.h"
/*
-----------------------------------------------------------------------------
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
2002-05-20 08:59:37 +00:00
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
const float RECORD_HOLD_THRESHOLD = 0.3f ;
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 ;
const float DEBUG_X = SCREEN_LEFT + 10 ;
const float DEBUG_Y = CENTER_Y - 100 ;
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
const float HELP_X = SCREEN_LEFT + 10 ;
const float HELP_Y = SCREEN_BOTTOM - 10 ;
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-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
const float INFO_X = SCREEN_RIGHT - 10 ;
const float INFO_Y = SCREEN_BOTTOM - 10 ;
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
2002-07-02 00:27:58 +00:00
const float PLAYER_X = EDIT_X ;
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-07 23:58:21 +00:00
# define TICK_EARLY_SECONDS THEME->GetMetricF("ScreenGameplay","TickEarlySeconds")
static float g_fTickEarlySecondsCache = 0 ; // reading directly out of theme metrics is slow
2002-06-29 11:59:09 +00:00
const CString HELP_TEXT =
2002-08-29 04:56:03 +00:00
" Esc: show command menu \n "
// "Hold F1 to show more commands\n"
" Hold keys for faster change: \n "
" F7/F8: Decrease/increase BPM at cur beat \n "
" F9/F10: Dec/inc freeze secs at cur beat \n "
" F11/F12: Decrease/increase music offset \n "
2002-09-12 04:40:51 +00:00
" [ and ]: Dec/inc sample music start \n "
" { and }: Dec/inc sample music length \n "
2002-06-29 11:59:09 +00:00
" Up/Down: change beat \n "
" Left/Right: change snap \n "
" PgUp/PgDn: jump 1 measure \n "
" Home/End: jump to first/last beat \n "
" Number keys: add or remove tap note \n "
" To create a hold note, hold a number key \n "
2002-08-17 06:44:04 +00:00
" while changing the beat pressing Up/Down \n " ;
2002-08-29 04:56:03 +00:00
const CString SHORTCUT_TEXT = " " ;
/* "S: save changes\n"
2002-08-23 20:18:29 +00:00
"W: save as SM and DWI (lossy)\n"
2002-06-29 11:59:09 +00:00
"Enter/Space: set begin/end selection markers\n"
2002-10-20 19:54:15 +00:00
"G/H/J/K/L: Quantize selection to nearest\n"
2002-06-29 11:59:09 +00:00
" 4th / 8th / 12th / 16th / 12th or 16th\n"
"P: Play selected area\n"
"R: Record in selected area\n"
2002-08-01 13:42:56 +00:00
"T: Toggle Play/Record rate\n"
2002-06-29 11:59:09 +00:00
"X: Cut selected area\n"
"C: Copy selected area\n"
"V: Paste at current beat\n"
"D: Toggle difficulty\n"
2002-08-29 04:56:03 +00:00
"E: Edit description\n"
"A: Edit main title\n"
"U: Edit sub title\n"
"B: Add/Edit background change\n"
2002-06-29 11:59:09 +00:00
"Ins: Insert blank beat\n"
"Del: Delete current beat and shift\n"
2002-07-02 00:27:58 +00:00
"M: Play sample music\n";
2002-08-29 04:56:03 +00:00
*/
2002-06-29 11:59:09 +00:00
2002-09-26 06:05:32 +00:00
const CString ACTION_MENU_ITEM_TEXT [ NUM_ACTION_MENU_ITEMS ] = {
2002-08-29 04:56:03 +00:00
" Enter: Set begin marker (Enter) " ,
" Space: Set end marker (Space) " ,
" P: Play selection " ,
" R: Record in selection " ,
" T: Toggle Play/Record rate " ,
" X: Cut selection " ,
" C: Copy selection " ,
" V: Paste clipboard at current beat " ,
" D: Toggle difficulty " ,
" E: Edit description " ,
2002-09-26 06:05:32 +00:00
" N: Edit Title/Subtitle/Artist & Transliterations " ,
2002-08-29 04:56:03 +00:00
" I: Toggle assist tick " ,
" B: Add/Edit background change at current beat " ,
" Ins: Insert blank beat and shift down " ,
" Del: Delete blank beat and shift up " ,
2002-10-20 19:54:15 +00:00
" G: Quantize selection to 4th notes " ,
" H: Quantize selection to 8th notes " ,
" J: Quantize selection to 12th notes " ,
" K: Quantize selection to 16th notes " ,
" L: Quantize selection to 12th or 16th notes " ,
2002-08-29 04:56:03 +00:00
" M: Play sample music " ,
2002-09-11 04:49:07 +00:00
" S: Save changes as SM and DWI " ,
2002-08-29 04:56:03 +00:00
" Q: Quit "
2002-08-17 06:44:04 +00:00
} ;
2002-09-26 06:05:32 +00:00
const int ACTION_MENU_ITEM_KEY [ NUM_ACTION_MENU_ITEMS ] = {
2002-11-29 20:37:12 +00:00
SDLK_RETURN ,
SDLK_SPACE ,
SDLK_p ,
SDLK_r ,
SDLK_t ,
SDLK_x ,
SDLK_c ,
SDLK_v ,
SDLK_d ,
SDLK_e ,
SDLK_n ,
SDLK_i ,
SDLK_b ,
SDLK_INSERT ,
SDLK_DELETE ,
SDLK_g ,
SDLK_h ,
SDLK_j ,
SDLK_k ,
SDLK_l ,
SDLK_m ,
SDLK_s ,
SDLK_q ,
2002-08-17 06:44:04 +00:00
} ;
2002-06-29 11:59:09 +00:00
2002-09-26 06:05:32 +00:00
const CString NAMING_MENU_ITEM_TEXT [ NUM_NAMING_MENU_ITEMS ] = {
" M: Edit main title " ,
" S: Edit sub title " ,
" A: Edit artist " ,
" Shift-M: Edit main title transliteration " ,
" Shift-S: Edit sub title transliteration " ,
" Shift-A: Edit artist transliteration "
} ;
// Pairs of keystroke + ifCapital
const std : : pair < int , bool > NAMING_MENU_ITEM_KEY [ NUM_NAMING_MENU_ITEMS ] = {
2002-11-29 20:37:12 +00:00
std : : make_pair ( SDLK_m , false ) ,
std : : make_pair ( SDLK_s , false ) ,
std : : make_pair ( SDLK_a , false ) ,
std : : make_pair ( SDLK_m , true ) ,
std : : make_pair ( SDLK_s , true ) ,
std : : make_pair ( SDLK_a , true ) ,
2002-09-26 06:05:32 +00:00
} ;
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
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 ] ;
2003-01-02 22:10:51 +00:00
2003-02-07 23:58:21 +00:00
g_fTickEarlySecondsCache = TICK_EARLY_SECONDS ;
2003-02-05 03:53:57 +00:00
/* Make EditMenu responsible for creating new Notes */
//if( m_pNotes == NULL )
//{
// m_pNotes = new Notes;
// m_pNotes->SetDifficulty(DIFFICULTY_MEDIUM);
// m_pNotes->m_NotesType = GAMESTATE->GetCurrentStyleDef()->m_NotesType;
// m_pNotes->SetDescription("Untitled");
// // In ScreenEditMenu, the screen preceding this one,
// // GAMEMAN->m_CurStyle is set to the target game style
// // of the current edit. Naturally, this is where we'll
// // want to extract the NotesType for a (NEW) sequence.
// m_pSong->m_apNotes.push_back( m_pNotes );
// GAMESTATE->m_pCurNotes[PLAYER_1] = m_pNotes;
//}
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
2002-08-01 20:30:40 +00:00
GAMESTATE - > m_SongOptions . m_fMusicRate = 1 ;
2002-05-20 08:59:37 +00:00
2003-01-25 11:05:12 +00:00
GAMESTATE - > m_PlayerOptions [ PLAYER_1 ] . m_fScrollSpeed = 1 ;
2002-07-28 20:28:37 +00:00
GAMESTATE - > m_PlayerOptions [ PLAYER_1 ] . m_ColorType = PlayerOptions : : COLOR_NOTE ;
2002-05-20 08:59:37 +00:00
2002-10-08 00:39:31 +00:00
m_BGAnimation . LoadFromAniDir ( THEME - > GetPathTo ( " BGAnimations " , " edit " ) ) ;
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-01-25 11:05:12 +00:00
m_NoteFieldEdit . Load ( & noteData , PLAYER_1 , - 200 , 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-07-02 00:27:58 +00:00
2003-02-01 05:16:38 +00:00
m_Clipboard . SetNumTracks ( m_NoteFieldEdit . GetNumTracks ( ) ) ;
2002-05-20 08:59:37 +00:00
2002-07-28 20:28:37 +00:00
m_Player . Load ( PLAYER_1 , & noteData , 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 ( ) ;
2002-08-13 23:26:46 +00:00
m_textInfo . LoadFromFont ( THEME - > GetPathTo ( " Fonts " , " normal " ) ) ;
2002-05-20 08:59:37 +00:00
m_textInfo . SetXY ( INFO_X , INFO_Y ) ;
2002-06-29 11:59:09 +00:00
m_textInfo . SetHorizAlign ( Actor : : align_right ) ;
2002-08-18 23:20:18 +00:00
m_textInfo . SetVertAlign ( Actor : : align_bottom ) ;
2002-05-20 08:59:37 +00:00
m_textInfo . SetZoom ( 0.5f ) ;
2002-06-29 11:59:09 +00:00
m_textInfo . SetShadowLength ( 2 ) ;
2002-05-20 08:59:37 +00:00
//m_textInfo.SetText(); // set this below every frame
2002-08-13 23:26:46 +00:00
m_textHelp . LoadFromFont ( THEME - > GetPathTo ( " Fonts " , " normal " ) ) ;
2002-06-29 11:59:09 +00:00
m_textHelp . SetXY ( HELP_X , HELP_Y ) ;
m_textHelp . SetHorizAlign ( Actor : : align_left ) ;
2002-08-18 17:48:50 +00:00
m_textHelp . SetVertAlign ( Actor : : align_bottom ) ;
2002-06-29 11:59:09 +00:00
m_textHelp . SetZoom ( 0.5f ) ;
m_textHelp . SetShadowLength ( 2 ) ;
m_textHelp . SetText ( HELP_TEXT ) ;
2002-05-20 08:59:37 +00:00
2002-10-31 05:52:12 +00:00
m_rectShortcutsBack . StretchTo ( RectI ( SCREEN_LEFT , SCREEN_TOP , SCREEN_RIGHT , SCREEN_BOTTOM ) ) ;
2002-10-28 05:30:45 +00:00
m_rectShortcutsBack . SetDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) ) ;
2002-08-23 20:18:29 +00:00
2002-08-17 06:44:04 +00:00
m_textShortcuts . LoadFromFont ( THEME - > GetPathTo ( " Fonts " , " normal " ) ) ;
m_textShortcuts . SetXY ( SHORTCUTS_X , SHORTCUTS_Y ) ;
m_textShortcuts . SetHorizAlign ( Actor : : align_left ) ;
2002-08-23 20:18:29 +00:00
m_textShortcuts . SetVertAlign ( Actor : : align_middle ) ;
2002-08-17 06:44:04 +00:00
m_textShortcuts . SetZoom ( 0.5f ) ;
m_textShortcuts . SetShadowLength ( 2 ) ;
m_textShortcuts . SetText ( SHORTCUT_TEXT ) ;
2002-06-29 11:59:09 +00:00
2003-01-02 08:13:34 +00:00
m_soundChangeLine . Load ( THEME - > GetPathTo ( " Sounds " , " edit change line " ) ) ;
2002-08-13 23:26:46 +00:00
m_soundChangeSnap . Load ( THEME - > GetPathTo ( " Sounds " , " edit change snap " ) ) ;
m_soundMarker . Load ( THEME - > GetPathTo ( " Sounds " , " edit marker " ) ) ;
m_soundInvalid . Load ( THEME - > GetPathTo ( " Sounds " , " menu invalid " ) ) ;
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
2002-08-29 04:56:03 +00:00
m_soundAssistTick . Load ( THEME - > GetPathTo ( " Sounds " , " gameplay assist tick " ) ) ;
2002-09-26 06:05:32 +00:00
for ( int i = 0 ; i < NUM_ACTION_MENU_ITEMS ; i + + )
{
m_textActionMenu [ i ] . LoadFromFont ( THEME - > GetPathTo ( " Fonts " , " normal " ) ) ;
m_textActionMenu [ i ] . SetXY ( ACTION_MENU_ITEM_X , ACTION_MENU_ITEM_START_Y + ACTION_MENU_ITEM_SPACING_Y * i ) ;
m_textActionMenu [ i ] . SetHorizAlign ( Actor : : align_left ) ;
m_textActionMenu [ i ] . SetZoom ( 0.5f ) ;
m_textActionMenu [ i ] . SetShadowLength ( 2 ) ;
m_textActionMenu [ i ] . SetText ( ACTION_MENU_ITEM_TEXT [ i ] ) ;
}
for ( int j = 0 ; j < NUM_NAMING_MENU_ITEMS ; j + + )
2002-08-17 06:44:04 +00:00
{
2002-09-26 06:05:32 +00:00
m_textNamingMenu [ j ] . LoadFromFont ( THEME - > GetPathTo ( " Fonts " , " normal " ) ) ;
m_textNamingMenu [ j ] . SetXY ( NAMING_MENU_ITEM_X , NAMING_MENU_ITEM_START_Y + NAMING_MENU_ITEM_SPACING_Y * j ) ;
m_textNamingMenu [ j ] . SetHorizAlign ( Actor : : align_left ) ;
m_textNamingMenu [ j ] . SetZoom ( 0.5f ) ;
m_textNamingMenu [ j ] . SetShadowLength ( 2 ) ;
m_textNamingMenu [ j ] . SetText ( NAMING_MENU_ITEM_TEXT [ j ] ) ;
2002-08-17 06:44:04 +00:00
}
m_iMenuSelection = 0 ;
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-07 23:58:21 +00:00
fPositionSeconds + = ( SOUNDMAN - > GetPlayLatency ( ) + g_fTickEarlySecondsCache ) * m_soundMusic . GetPlaybackRate ( ) ;
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
void ScreenEdit : : Update ( float fDeltaTime )
{
float fPositionSeconds = m_soundMusic . GetPositionSeconds ( ) ;
2002-06-30 23:19:33 +00:00
float fSongBeat , fBPS ;
bool bFreeze ;
m_pSong - > GetBeatAndBPSFromElapsedTime ( fPositionSeconds , fSongBeat , fBPS , bFreeze ) ;
2002-05-20 08:59:37 +00:00
2002-08-01 20:30:40 +00:00
// update the global music statistics for other classes to access
GAMESTATE - > m_fMusicSeconds = fPositionSeconds ;
// GAMESTATE->m_fSongBeat = fSongBeat;
GAMESTATE - > m_fCurBPS = fBPS ;
GAMESTATE - > m_bFreeze = bFreeze ;
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 ) ;
if ( fSecsHeld > RECORD_HOLD_THRESHOLD )
{
// 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
{
2002-08-01 20:30:40 +00:00
GAMESTATE - > m_fSongBeat = fSongBeat ;
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 ) ;
2002-06-29 11:59:09 +00:00
m_textHelp . Update ( fDeltaTime ) ;
2002-05-20 08:59:37 +00:00
m_textInfo . Update ( fDeltaTime ) ;
2002-08-23 20:18:29 +00:00
m_rectShortcutsBack . Update ( fDeltaTime ) ;
2002-08-17 06:44:04 +00:00
m_textShortcuts . Update ( fDeltaTime ) ;
2002-05-20 08:59:37 +00:00
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-05-20 08:59:37 +00:00
2002-06-29 11:59:09 +00:00
if ( fabsf ( fDelta ) < 0.01 )
{
2002-08-01 20:30:40 +00:00
m_fTrailingBeat = GAMESTATE - > m_fSongBeat ; // snap
2002-06-29 11:59:09 +00:00
}
else
{
float fSign = fDelta / fabsf ( fDelta ) ;
float fMoveDelta = fSign * fDeltaTime * 40 ;
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-05-20 08:59:37 +00:00
}
2002-09-26 06:05:32 +00:00
if ( m_EditMode = = MODE_ACTION_MENU )
2002-08-17 06:44:04 +00:00
{
2002-09-26 06:05:32 +00:00
for ( int i = 0 ; i < NUM_ACTION_MENU_ITEMS ; i + + )
m_textActionMenu [ i ] . Update ( fDeltaTime ) ;
}
if ( m_EditMode = = MODE_NAMING_MENU )
{
for ( int i = 0 ; i < NUM_NAMING_MENU_ITEMS ; i + + )
m_textNamingMenu [ i ] . Update ( fDeltaTime ) ;
2002-08-17 06:44:04 +00:00
}
2002-05-20 08:59:37 +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
// Only update stats every 100 frames because it's slow
2002-06-29 11:59:09 +00:00
static int iNumTapNotes = 0 , iNumHoldNotes = 0 ;
static int iCounter = 0 ;
iCounter + + ;
2002-08-29 04:56:03 +00:00
if ( iCounter % 100 = = 0 )
2002-06-29 11:59:09 +00:00
{
iNumTapNotes = m_NoteFieldEdit . GetNumTapNotes ( ) ;
iNumHoldNotes = m_NoteFieldEdit . GetNumHoldNotes ( ) ;
}
m_textInfo . SetText ( ssprintf (
" Snap = %s \n "
" Beat = %.2f \n "
" Selection = begin: %.2f, end: %.2f \n "
2002-08-01 13:42:56 +00:00
" Play/Record rate: %.1f \n "
2002-06-29 11:59:09 +00:00
" Difficulty = %s \n "
" Description = %s \n "
2002-08-29 04:56:03 +00:00
" Main title = %s \n "
" Sub title = %s \n "
2002-06-29 11:59:09 +00:00
" Num notes tap: %d, hold: %d \n "
2002-08-29 04:56:03 +00:00
" Assist tick is %s \n "
2002-07-02 00:27:58 +00:00
" MusicOffsetSeconds: %.2f \n "
2002-06-29 11:59:09 +00:00
" Preview start: %.2f, length = %.2f \n " ,
2002-10-29 07:58:44 +00:00
sNoteType . GetString ( ) ,
2002-08-01 20:30:40 +00:00
GAMESTATE - > m_fSongBeat ,
2002-06-29 11:59:09 +00:00
m_NoteFieldEdit . m_fBeginMarker , m_NoteFieldEdit . m_fEndMarker ,
2002-08-01 20:30:40 +00:00
GAMESTATE - > m_SongOptions . m_fMusicRate ,
2003-01-02 22:10:51 +00:00
DifficultyToString ( m_pNotes - > GetDifficulty ( ) ) . GetString ( ) ,
GAMESTATE - > m_pCurNotes [ PLAYER_1 ] ? GAMESTATE - > m_pCurNotes [ PLAYER_1 ] - > GetDescription ( ) . GetString ( ) : " no description " ,
2002-10-29 07:58:44 +00:00
m_pSong - > m_sMainTitle . GetString ( ) ,
m_pSong - > m_sSubTitle . GetString ( ) ,
2002-06-29 11:59:09 +00:00
iNumTapNotes , iNumHoldNotes ,
2002-08-29 04:56:03 +00:00
GAMESTATE - > m_SongOptions . m_AssistType = = SongOptions : : ASSIST_TICK ? " ON " : " OFF " ,
2002-07-03 21:27:26 +00:00
m_pSong - > m_fBeat0OffsetInSeconds ,
2002-06-29 11:59:09 +00:00
m_pSong - > m_fMusicSampleStartSeconds , m_pSong - > m_fMusicSampleLengthSeconds
) ) ;
2002-05-20 08:59:37 +00:00
}
void ScreenEdit : : DrawPrimitives ( )
{
2002-10-08 00:39:31 +00:00
m_BGAnimation . Draw ( ) ;
2002-08-13 23:26:46 +00:00
m_SnapDisplay . Draw ( ) ;
2002-05-20 08:59:37 +00:00
m_GrayArrowRowEdit . Draw ( ) ;
2002-08-01 20:30:40 +00:00
// 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
2002-05-20 08:59:37 +00:00
m_NoteFieldEdit . Draw ( ) ;
2002-08-01 20:30:40 +00:00
GAMESTATE - > m_fSongBeat = fSongBeat ; // restore real song beat
2002-08-17 06:44:04 +00:00
m_textHelp . Draw ( ) ;
2002-05-20 08:59:37 +00:00
m_textInfo . Draw ( ) ;
2002-06-29 11:59:09 +00:00
m_Fade . Draw ( ) ;
2002-11-29 20:37:12 +00:00
/* if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,SDLK_F1) ) )
2002-08-23 20:18:29 +00:00
{
m_rectShortcutsBack.Draw();
m_textShortcuts.Draw();
2002-10-18 01:46:25 +00:00
} */
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
m_rectRecordBack . Draw ( ) ;
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
{
m_GrayArrowRowRecord . Draw ( ) ;
m_NoteFieldRecord . Draw ( ) ;
}
2002-07-28 20:28:37 +00:00
if ( m_EditMode = = MODE_PLAYING )
2002-05-20 08:59:37 +00:00
{
m_Player . Draw ( ) ;
}
2002-08-13 23:26:46 +00:00
if ( m_EditMode = = MODE_RECORDING )
{
/*
for( int t=0; t<GAMESTATE->GetCurrentStyleDef()->m_iColsPerPlayer; t++ )
{
if( m_bLayingAHold[t] )
{
bool bHoldingButton = false;
for( int p=0; p<NUM_PLAYERS; p++ )
bHoldingButton |= INPUTMAPPER->IsButtonDown( StyleInput(PlayerInput(p), t) );
if( bHoldingButton
}
}
*/
}
2002-09-26 06:05:32 +00:00
if ( m_EditMode = = MODE_ACTION_MENU )
{
for ( int i = 0 ; i < NUM_ACTION_MENU_ITEMS ; i + + )
m_textActionMenu [ i ] . Draw ( ) ;
}
if ( m_EditMode = = MODE_NAMING_MENU )
2002-08-17 06:44:04 +00:00
{
2002-09-26 06:05:32 +00:00
for ( int i = 0 ; i < NUM_NAMING_MENU_ITEMS ; i + + )
m_textNamingMenu [ i ] . Draw ( ) ;
2002-08-17 06:44:04 +00:00
}
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 )
{
2002-08-21 22:48:33 +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 ;
2002-09-26 06:05:32 +00:00
case MODE_ACTION_MENU : InputActionMenu ( DeviceI , type , GameI , MenuI , StyleI ) ; break ;
case MODE_NAMING_MENU : InputNamingMenu ( DeviceI , type , GameI , MenuI , StyleI ) ; break ;
2002-07-28 20:28:37 +00:00
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
}
}
2002-08-29 04:56:03 +00:00
// Begin helper functions for InputEdit
void AddBGChange ( CString sBGName )
{
Song * pSong = GAMESTATE - > m_pCurSong ;
2002-10-31 02:20:11 +00:00
unsigned i ;
for ( i = 0 ; i < pSong - > m_BackgroundChanges . size ( ) ; i + + )
2002-08-29 04:56:03 +00:00
{
if ( pSong - > m_BackgroundChanges [ i ] . m_fStartBeat = = GAMESTATE - > m_fSongBeat )
break ;
}
2002-10-31 02:20:11 +00:00
if ( i ! = pSong - > m_BackgroundChanges . size ( ) ) // there is already a BGChange here
2002-10-31 04:11:08 +00:00
pSong - > m_BackgroundChanges . erase ( pSong - > m_BackgroundChanges . begin ( ) + i ,
pSong - > m_BackgroundChanges . begin ( ) + i + 1 ) ;
2002-08-29 04:56:03 +00:00
// create a new BGChange
if ( sBGName ! = " " )
pSong - > AddBackgroundChange ( BackgroundChange ( GAMESTATE - > m_fSongBeat , sBGName ) ) ;
}
void ChangeDescription ( CString sNew )
{
Notes * pNotes = GAMESTATE - > m_pCurNotes [ PLAYER_1 ] ;
2003-01-02 22:10:51 +00:00
pNotes - > SetDescription ( sNew ) ;
2002-08-29 04:56:03 +00:00
}
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 ;
}
2002-09-26 06:05:32 +00:00
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 )
2002-09-16 22:16:14 +00:00
{
Song * pSong = GAMESTATE - > m_pCurSong ;
2002-09-26 06:05:32 +00:00
pSong - > m_sArtistTranslit = sNew ;
2002-09-16 22:16:14 +00:00
}
2002-08-29 04:56:03 +00:00
// End helper functions for InputEdit
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-08-17 06:44:04 +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 ) ;
2002-08-17 06:44:04 +00:00
if ( iCol = = hn . m_iTrack & & // the notes correspond
fSongBeat > = hn . m_fStartBeat & & fSongBeat < = hn . m_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-05-20 08:59:37 +00:00
}
2002-06-29 11:59:09 +00:00
2002-08-17 06:44:04 +00:00
if ( ! bRemovedAHoldNote )
{
// 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-08-17 06:44:04 +00:00
else
2002-11-03 01:49:13 +00:00
m_NoteFieldEdit . SetTapNote ( iCol , iSongIndex , TAP_EMPTY ) ;
2002-08-17 06:44:04 +00:00
}
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_q :
2002-08-27 03:59:22 +00:00
SCREENMAN - > SetNewScreen ( " ScreenEditMenu " ) ;
2002-08-17 06:44:04 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_s :
2002-08-17 06:44:04 +00:00
{
// copy edit into current Notes
Notes * pNotes = GAMESTATE - > m_pCurNotes [ PLAYER_1 ] ;
2002-10-18 04:13:19 +00:00
ASSERT ( pNotes ) ;
2002-05-20 08:59:37 +00:00
2002-10-18 04:13:19 +00:00
pNotes - > SetNoteData ( & m_NoteFieldEdit ) ;
2002-09-11 04:49:07 +00:00
GAMESTATE - > m_pCurSong - > Save ( ) ;
2002-11-13 05:17:15 +00:00
SCREENMAN - > SystemMessage ( " Saved as SM and DWI. " ) ;
2003-01-02 08:13:34 +00:00
SOUNDMAN - > PlayOnce ( THEME - > GetPathTo ( " Sounds " , " edit save " ) ) ;
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
{
2002-09-07 10:33:44 +00:00
float fBeatsToMove = 0.f ;
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_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 ;
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
// 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-05-20 08:59:37 +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 ;
newHN . m_iTrack = col ;
newHN . m_fStartBeat = min ( fStartBeat , fEndBeat ) ;
newHN . m_fEndBeat = max ( fStartBeat , fEndBeat ) ;
2002-09-09 05:22:02 +00:00
newHN . m_fStartBeat = max ( newHN . m_fStartBeat , 0 ) ;
newHN . m_fEndBeat = max ( newHN . m_fEndBeat , 0 ) ;
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 )
{
/* We're back at the anchor, so we have nothing selected. */
m_NoteFieldEdit . m_fBeginMarker = m_NoteFieldEdit . m_fEndMarker = - 1 ;
}
else
2002-05-20 08:59:37 +00:00
{
2002-08-21 22:48:33 +00:00
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-05-20 08:59:37 +00:00
}
}
2002-08-17 06:44:04 +00:00
GAMESTATE - > m_fSongBeat + = fBeatsToMove ;
GAMESTATE - > m_fSongBeat = clamp ( GAMESTATE - > m_fSongBeat , 0 , MAX_BEATS - 1 ) ;
2002-10-18 19:01:32 +00:00
GAMESTATE - > m_fSongBeat = froundf ( GAMESTATE - > m_fSongBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ( ) ) ) ;
2002-06-29 11:59:09 +00:00
m_soundChangeLine . Play ( ) ;
2002-08-17 06:44:04 +00:00
}
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 ;
2002-11-29 20:37:12 +00:00
case SDLK_RIGHT :
2002-08-17 06:44:04 +00:00
m_SnapDisplay . PrevSnapMode ( ) ;
OnSnapModeChange ( ) ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_LEFT :
2002-08-17 06:44:04 +00:00
m_SnapDisplay . NextSnapMode ( ) ;
OnSnapModeChange ( ) ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_RETURN :
2003-02-06 07:32:57 +00:00
case SDLK_KP_ENTER :
2002-08-17 06:44:04 +00:00
if ( m_NoteFieldEdit . m_fEndMarker ! = - 1 & & GAMESTATE - > m_fSongBeat > m_NoteFieldEdit . m_fEndMarker )
{
// invalid! The begin maker must be placed before the end marker
m_soundInvalid . Play ( ) ;
}
else
{
m_NoteFieldEdit . m_fBeginMarker = GAMESTATE - > m_fSongBeat ;
m_soundMarker . Play ( ) ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_SPACE :
2002-08-17 06:44:04 +00:00
if ( m_NoteFieldEdit . m_fBeginMarker ! = - 1 & & GAMESTATE - > m_fSongBeat < m_NoteFieldEdit . m_fBeginMarker )
{
// invalid! The end maker must be placed after the begin marker
m_soundInvalid . Play ( ) ;
}
else
{
m_NoteFieldEdit . m_fEndMarker = GAMESTATE - > m_fSongBeat ;
m_soundMarker . Play ( ) ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_g :
case SDLK_h :
case SDLK_j :
case SDLK_k :
case SDLK_l :
2002-08-17 06:44:04 +00:00
{
if ( m_NoteFieldEdit . m_fBeginMarker = = - 1 | | m_NoteFieldEdit . m_fEndMarker = = - 1 )
2002-05-20 08:59:37 +00:00
{
2002-06-29 11:59:09 +00:00
m_soundInvalid . Play ( ) ;
2002-05-20 08:59:37 +00:00
}
else
{
2002-08-17 06:44:04 +00:00
NoteType noteType1 ;
NoteType noteType2 ;
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_g : noteType1 = NOTE_TYPE_4TH ; noteType2 = NOTE_TYPE_4TH ; break ;
case SDLK_h : noteType1 = NOTE_TYPE_8TH ; noteType2 = NOTE_TYPE_8TH ; break ;
case SDLK_j : noteType1 = NOTE_TYPE_12TH ; noteType2 = NOTE_TYPE_12TH ; break ;
case SDLK_k : noteType1 = NOTE_TYPE_16TH ; noteType2 = NOTE_TYPE_16TH ; break ;
case SDLK_l : noteType1 = NOTE_TYPE_12TH ; noteType2 = NOTE_TYPE_16TH ; break ;
2002-09-07 10:33:44 +00:00
default : ASSERT ( false ) ; return ;
2002-08-17 06:44:04 +00:00
}
2002-12-13 23:34:37 +00:00
NoteDataUtil : : SnapToNearestNoteType ( m_NoteFieldEdit , noteType1 , noteType2 , m_NoteFieldEdit . m_fBeginMarker , m_NoteFieldEdit . m_fEndMarker ) ;
2002-05-20 08:59:37 +00:00
}
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_ESCAPE :
2002-08-17 06:44:04 +00:00
{
2002-09-26 06:05:32 +00:00
m_EditMode = MODE_ACTION_MENU ;
2002-08-17 06:44:04 +00:00
m_iMenuSelection = 0 ;
2002-09-26 06:05:32 +00:00
MenuItemGainFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
2002-10-12 01:49:41 +00:00
m_rectRecordBack . StopTweening ( ) ;
2002-09-26 06:05:32 +00:00
m_rectRecordBack . BeginTweening ( 0.5f ) ;
2002-10-28 05:30:45 +00:00
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) ) ;
2002-09-26 06:05:32 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_n :
2002-09-26 06:05:32 +00:00
{
m_EditMode = MODE_NAMING_MENU ;
m_iMenuSelection = 0 ;
MenuItemGainFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
2002-08-17 06:44:04 +00:00
2002-10-12 01:49:41 +00:00
m_rectRecordBack . StopTweening ( ) ;
2002-08-17 06:44:04 +00:00
m_rectRecordBack . BeginTweening ( 0.5f ) ;
2002-10-28 05:30:45 +00:00
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) ) ;
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_r :
case SDLK_p :
2002-08-17 06:44:04 +00:00
{
2002-09-10 03:20:31 +00:00
if ( m_NoteFieldEdit . m_fBeginMarker = = - 1 )
2002-10-05 14:47:03 +00:00
m_NoteFieldEdit . m_fBeginMarker = GAMESTATE - > m_fSongBeat ;
2002-09-10 03:20:31 +00:00
if ( m_NoteFieldEdit . m_fEndMarker = = - 1 )
m_NoteFieldEdit . m_fEndMarker = m_pSong - > m_fLastBeat ;
2002-08-17 06:44:04 +00:00
2002-11-29 20:37:12 +00:00
if ( DeviceI . button = = SDLK_r ) {
2002-10-18 02:08:44 +00:00
m_EditMode = MODE_RECORDING ;
2002-09-10 03:20:31 +00:00
2002-10-18 02:08:44 +00:00
// initialize m_NoteFieldRecord
m_NoteFieldRecord . ClearAll ( ) ;
2003-02-01 05:16:38 +00:00
m_NoteFieldRecord . SetNumTracks ( m_NoteFieldEdit . GetNumTracks ( ) ) ;
2002-10-18 02:08:44 +00:00
m_NoteFieldRecord . m_fBeginMarker = m_NoteFieldEdit . m_fBeginMarker ;
m_NoteFieldRecord . m_fEndMarker = m_NoteFieldEdit . m_fEndMarker ;
2002-05-20 08:59:37 +00:00
2002-10-18 02:08:44 +00:00
} else {
m_EditMode = MODE_PLAYING ;
2002-06-29 11:59:09 +00:00
2002-10-18 02:08:44 +00:00
m_Player . Load ( PLAYER_1 , ( NoteData * ) & m_NoteFieldEdit , NULL , NULL ) ;
}
2002-06-29 11:59:09 +00:00
2002-10-12 01:49:41 +00:00
m_rectRecordBack . StopTweening ( ) ;
2002-08-17 06:44:04 +00:00
m_rectRecordBack . BeginTweening ( 0.5f ) ;
2002-10-28 05:30:45 +00:00
m_rectRecordBack . SetTweenDiffuse ( RageColor ( 0 , 0 , 0 , 0.8f ) ) ;
2002-06-29 11:59:09 +00:00
2002-08-17 06:44:04 +00:00
GAMESTATE - > m_fSongBeat = m_NoteFieldEdit . m_fBeginMarker - 4 ; // give a 1 measure lead-in
2002-10-18 02:03:44 +00:00
float fStartSeconds = m_pSong - > GetElapsedTimeFromBeat ( GAMESTATE - > m_fSongBeat ) ;
m_soundMusic . SetPositionSeconds ( fStartSeconds ) ;
2002-08-17 06:44:04 +00:00
m_soundMusic . SetPlaybackRate ( GAMESTATE - > m_SongOptions . m_fMusicRate ) ;
2002-12-22 08:51:41 +00:00
m_soundMusic . StartPlaying ( ) ;
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_t :
2002-08-17 06:44:04 +00:00
if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.0f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 0.9f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 0.9f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 0.8f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 0.8f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 0.7f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 0.7f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.5f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.5f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.4f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.4f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.3f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.3f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.2f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.2f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.1f ;
else if ( GAMESTATE - > m_SongOptions . m_fMusicRate = = 1.1f ) GAMESTATE - > m_SongOptions . m_fMusicRate = 1.0f ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_INSERT :
case SDLK_DELETE :
2002-08-17 06:44:04 +00:00
{
NoteData temp ;
2003-02-01 05:16:38 +00:00
temp . SetNumTracks ( m_NoteFieldEdit . GetNumTracks ( ) ) ;
2002-09-07 10:33:44 +00:00
int iTakeFromRow = 0 ;
2002-08-17 06:44:04 +00:00
int iPasteAtRow ;
switch ( DeviceI . button )
2002-06-29 11:59:09 +00:00
{
2002-11-29 20:37:12 +00:00
case SDLK_INSERT :
2002-08-17 06:44:04 +00:00
iTakeFromRow = BeatToNoteRow ( GAMESTATE - > m_fSongBeat ) ;
iPasteAtRow = BeatToNoteRow ( GAMESTATE - > m_fSongBeat + 1 ) ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_DELETE :
2002-08-17 06:44:04 +00:00
iTakeFromRow = BeatToNoteRow ( GAMESTATE - > m_fSongBeat + 1 ) ;
iPasteAtRow = BeatToNoteRow ( GAMESTATE - > m_fSongBeat ) ;
break ;
}
2002-12-18 08:30:01 +00:00
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 ) ;
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_x :
2002-08-17 06:44:04 +00:00
if ( m_NoteFieldEdit . m_fBeginMarker = = - 1 | | m_NoteFieldEdit . m_fEndMarker = = - 1 )
{
m_soundInvalid . Play ( ) ;
2003-01-21 03:10:50 +00:00
} else {
2002-08-17 06:44:04 +00:00
int iFirstRow = BeatToNoteRow ( m_NoteFieldEdit . m_fBeginMarker ) ;
int iLastRow = BeatToNoteRow ( m_NoteFieldEdit . m_fEndMarker ) ;
2002-06-29 11:59:09 +00:00
2003-01-21 03:10:50 +00:00
m_Clipboard . ClearAll ( ) ;
2002-08-17 06:44:04 +00:00
m_Clipboard . CopyRange ( & m_NoteFieldEdit , iFirstRow , iLastRow ) ;
2003-01-21 03:10:50 +00:00
if ( DeviceI . button = = SDLK_x )
m_NoteFieldEdit . ClearRange ( iFirstRow , iLastRow ) ;
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_v :
2002-08-17 06:44:04 +00:00
{
int iSrcFirstRow = 0 ;
int iSrcLastRow = BeatToNoteRow ( m_Clipboard . GetLastBeat ( ) ) ;
int iDestFirstRow = BeatToNoteRow ( GAMESTATE - > m_fSongBeat ) ;
2002-05-20 08:59:37 +00:00
2002-08-17 06:44:04 +00:00
m_NoteFieldEdit . CopyRange ( & m_Clipboard , iSrcFirstRow , iSrcLastRow , iDestFirstRow ) ;
}
break ;
2002-06-29 11:59:09 +00:00
2002-11-29 20:37:12 +00:00
case SDLK_d :
2002-08-17 06:44:04 +00:00
{
2003-01-02 22:10:51 +00:00
Difficulty dc = Difficulty ( ( m_pNotes - > GetDifficulty ( ) + 1 ) % NUM_DIFFICULTIES ) ;
m_pNotes - > SetDifficulty ( dc ) ;
2002-08-17 06:44:04 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_e :
2003-01-02 22:10:51 +00:00
SCREENMAN - > TextEntry ( SM_None , " Edit notes description. \n Press Enter to confirm, \n Escape to cancel. " , m_pNotes - > GetDescription ( ) , ChangeDescription , NULL ) ;
2002-08-29 04:56:03 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_b :
2002-08-23 20:18:29 +00:00
{
CString sOldBackground ;
2002-10-31 02:20:11 +00:00
unsigned i ;
for ( i = 0 ; i < m_pSong - > m_BackgroundChanges . size ( ) ; i + + )
2002-08-23 20:18:29 +00:00
{
if ( m_pSong - > m_BackgroundChanges [ i ] . m_fStartBeat = = GAMESTATE - > m_fSongBeat )
break ;
}
2002-10-31 02:20:11 +00:00
if ( i ! = m_pSong - > m_BackgroundChanges . size ( ) ) // there is already a BGChange here
2002-08-23 20:18:29 +00:00
sOldBackground = m_pSong - > m_BackgroundChanges [ i ] . m_sBGName ;
2002-08-27 03:59:22 +00:00
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 ) ;
2002-08-23 20:18:29 +00:00
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_i :
2002-08-29 04:56:03 +00:00
if ( GAMESTATE - > m_SongOptions . m_AssistType = = SongOptions : : ASSIST_TICK )
GAMESTATE - > m_SongOptions . m_AssistType = SongOptions : : ASSIST_NONE ;
else
GAMESTATE - > m_SongOptions . m_AssistType = SongOptions : : ASSIST_TICK ;
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-05-20 08:59:37 +00:00
{
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-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
switch ( type )
2002-05-20 08:59:37 +00:00
{
2002-08-17 06:44:04 +00:00
case IET_SLOW_REPEAT : fDeltaBPM * = 10 ; break ;
case IET_FAST_REPEAT : fDeltaBPM * = 40 ; break ;
2002-05-20 08:59:37 +00:00
}
2002-08-17 06:44:04 +00:00
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-05-20 08:59:37 +00:00
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 ) ) ;
2002-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
else // BPMSegment being modified is m_BPMSegments[i]
2002-06-29 11:59:09 +00:00
{
2002-08-17 06:44:04 +00:00
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 ;
2002-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
}
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-06-29 11:59:09 +00:00
{
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-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
switch ( type )
2002-06-29 11:59:09 +00:00
{
2002-08-23 20:18:29 +00:00
case IET_SLOW_REPEAT : fStopDelta * = 10 ; break ;
case IET_FAST_REPEAT : fStopDelta * = 40 ; break ;
2002-05-20 08:59:37 +00:00
}
2002-06-29 11:59:09 +00:00
2002-10-31 02:20:11 +00:00
unsigned i ;
for ( i = 0 ; i < m_pSong - > m_StopSegments . size ( ) ; i + + )
2002-05-20 08:59:37 +00:00
{
2002-08-17 06:44:04 +00:00
if ( m_pSong - > m_StopSegments [ i ] . m_fStartBeat = = GAMESTATE - > m_fSongBeat )
break ;
2002-05-20 08:59:37 +00:00
}
2002-10-31 02:20:11 +00:00
if ( i = = m_pSong - > m_StopSegments . size ( ) ) // there is no BPMSegment at the current beat
2002-06-29 11:59:09 +00:00
{
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-06-29 11:59:09 +00:00
}
2002-08-17 06:44:04 +00:00
else // StopSegment being modified is m_StopSegments[i]
2002-06-29 11:59:09 +00:00
{
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-06-29 11:59:09 +00:00
}
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-07-02 00:27:58 +00:00
{
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-07-02 00:27:58 +00:00
}
2002-08-17 06:44:04 +00:00
switch ( type )
2002-07-02 00:27:58 +00:00
{
2002-08-17 06:44:04 +00:00
case IET_SLOW_REPEAT : fOffsetDelta * = 10 ; break ;
case IET_FAST_REPEAT : fOffsetDelta * = 40 ; break ;
}
2002-06-29 11:59:09 +00:00
2002-08-17 06:44:04 +00:00
m_pSong - > m_fBeat0OffsetInSeconds + = fOffsetDelta ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_m :
2003-01-27 01:31:28 +00:00
SOUNDMAN - > PlayMusic ( " " ) ;
2003-01-02 07:39:25 +00:00
SOUNDMAN - > PlayMusic ( m_pSong - > GetMusicPath ( ) , false ,
m_pSong - > m_fMusicSampleStartSeconds ,
m_pSong - > m_fMusicSampleLengthSeconds ) ;
2002-08-17 06:44:04 +00:00
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-07-02 00:27:58 +00:00
}
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-07-02 00:27:58 +00:00
}
2002-08-17 06:44:04 +00:00
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 ;
}
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
if ( StyleI . player ! = PLAYER_1 )
return ; // ignore
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
const int iCol = StyleI . col ;
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
switch ( type )
{
case IET_FIRST_PRESS :
{
// Add a tap
2002-05-20 08:59:37 +00:00
2002-10-18 19:01:32 +00:00
float fBeat = GAMESTATE - > m_fSongBeat ;
fBeat = froundf ( fBeat , NoteTypeToBeat ( m_SnapDisplay . GetNoteType ( ) ) ) ;
const int iRow = BeatToNoteRow ( fBeat ) ;
if ( iRow < 0 )
break ;
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
}
}
2002-09-26 06:05:32 +00:00
void ScreenEdit : : InputActionMenu ( 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-08-21 22:48:33 +00:00
if ( type = = IET_RELEASE ) return ; // don't care
2002-08-17 06:44:04 +00:00
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_UP :
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
m_iMenuSelection = ( m_iMenuSelection - 1 + NUM_ACTION_MENU_ITEMS ) % NUM_ACTION_MENU_ITEMS ;
2002-08-17 06:44:04 +00:00
printf ( " %d \n " , m_iMenuSelection ) ;
2002-09-26 06:05:32 +00:00
MenuItemGainFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
2002-08-17 06:44:04 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_DOWN :
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
m_iMenuSelection = ( m_iMenuSelection + 1 ) % NUM_ACTION_MENU_ITEMS ;
2002-08-17 06:44:04 +00:00
printf ( " %d \n " , m_iMenuSelection ) ;
2002-09-26 06:05:32 +00:00
MenuItemGainFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
2002-08-17 06:44:04 +00:00
break ;
2002-11-29 20:37:12 +00:00
case SDLK_RETURN :
case SDLK_ESCAPE :
2002-10-18 00:45:09 +00:00
TransitionToEdit ( ) ;
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
2002-11-29 20:37:12 +00:00
if ( DeviceI . button = = SDLK_RETURN )
2002-08-17 06:44:04 +00:00
{
2003-01-02 08:13:34 +00:00
SOUNDMAN - > PlayOnce ( THEME - > GetPathTo ( " Sounds " , " menu start " ) ) ;
2002-09-26 06:05:32 +00:00
int iMenuKey = ACTION_MENU_ITEM_KEY [ m_iMenuSelection ] ;
2002-08-17 06:44:04 +00:00
InputEdit ( DeviceInput ( DEVICE_KEYBOARD , iMenuKey ) , IET_FIRST_PRESS , GameInput ( ) , MenuInput ( ) , StyleInput ( ) ) ;
}
break ;
2002-09-26 06:05:32 +00:00
default :
// On recognized keys, behave as on the top level
for ( int i = 0 ; i < NUM_ACTION_MENU_ITEMS ; i + + ) {
if ( DeviceI . button = = ACTION_MENU_ITEM_KEY [ i ] ) {
2002-10-18 00:45:09 +00:00
TransitionToEdit ( ) ;
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textActionMenu [ m_iMenuSelection ] ) ;
2003-01-02 08:13:34 +00:00
SOUNDMAN - > PlayOnce ( THEME - > GetPathTo ( " Sounds " , " menu start " ) ) ;
2002-09-26 06:05:32 +00:00
InputEdit ( DeviceI , IET_FIRST_PRESS , GameInput ( ) , MenuInput ( ) , StyleInput ( ) ) ;
}
}
break ;
}
}
void ScreenEdit : : InputNamingMenu ( const DeviceInput & DeviceI , const InputEventType type , const GameInput & GameI , const MenuInput & MenuI , const StyleInput & StyleI , bool forceShiftPressed )
{
if ( DeviceI . device ! = DEVICE_KEYBOARD )
return ;
if ( type = = IET_RELEASE ) return ; // don't care
bool translit = forceShiftPressed | |
2002-11-29 20:37:12 +00:00
INPUTFILTER - > IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_LSHIFT ) ) | |
INPUTFILTER - > IsBeingPressed ( DeviceInput ( DEVICE_KEYBOARD , SDLK_RSHIFT ) ) ;
2002-09-26 06:05:32 +00:00
switch ( DeviceI . button ) {
2002-11-29 20:37:12 +00:00
case SDLK_m :
case SDLK_s :
case SDLK_a :
case SDLK_ESCAPE :
case SDLK_RETURN :
2002-10-18 00:45:09 +00:00
TransitionToEdit ( ) ;
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
break ;
}
switch ( DeviceI . button )
{
2002-11-29 20:37:12 +00:00
case SDLK_m :
2002-09-26 06:05:32 +00:00
if ( translit ) {
SCREENMAN - > TextEntry ( SM_None , " Edit song main title transliteration. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sMainTitleTranslit , ChangeMainTitleTranslit , NULL ) ;
} else {
SCREENMAN - > TextEntry ( SM_None , " Edit song main title. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sMainTitle , ChangeMainTitle , NULL ) ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_s :
2002-09-26 06:05:32 +00:00
if ( translit ) {
SCREENMAN - > TextEntry ( SM_None , " Edit song sub title transliteration. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sSubTitleTranslit , ChangeSubTitleTranslit , NULL ) ;
} else {
SCREENMAN - > TextEntry ( SM_None , " Edit song sub title. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sSubTitle , ChangeSubTitle , NULL ) ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_a :
2002-09-26 06:05:32 +00:00
if ( translit ) {
SCREENMAN - > TextEntry ( SM_None , " Edit song artist transliteration. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sArtistTranslit , ChangeArtistTranslit , NULL ) ;
} else {
SCREENMAN - > TextEntry ( SM_None , " Edit song artist. \n Press Enter to confirm, \n Escape to cancel. " , m_pSong - > m_sArtist , ChangeArtist , NULL ) ;
}
break ;
2002-11-29 20:37:12 +00:00
case SDLK_UP :
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
m_iMenuSelection = ( m_iMenuSelection - 1 + NUM_NAMING_MENU_ITEMS ) % NUM_NAMING_MENU_ITEMS ;
printf ( " %d \n " , m_iMenuSelection ) ;
MenuItemGainFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_DOWN :
2002-09-26 06:05:32 +00:00
MenuItemLoseFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
m_iMenuSelection = ( m_iMenuSelection + 1 ) % NUM_NAMING_MENU_ITEMS ;
printf ( " %d \n " , m_iMenuSelection ) ;
MenuItemGainFocus ( & m_textNamingMenu [ m_iMenuSelection ] ) ;
break ;
2002-11-29 20:37:12 +00:00
case SDLK_RETURN :
2003-01-02 08:13:34 +00:00
SOUNDMAN - > PlayOnce ( THEME - > GetPathTo ( " Sounds " , " menu start " ) ) ;
2002-09-26 06:05:32 +00:00
const std : : pair < int , bool > & pairMenuKey = NAMING_MENU_ITEM_KEY [ m_iMenuSelection ] ;
InputNamingMenu ( DeviceInput ( DEVICE_KEYBOARD , pairMenuKey . first ) , IET_FIRST_PRESS , GameInput ( ) , MenuInput ( ) , StyleInput ( ) , pairMenuKey . second ) ;
break ;
2002-08-17 06:44:04 +00:00
}
}
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 ;
}
}
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
2002-09-26 06:05:32 +00:00
void ScreenEdit : : MenuItemGainFocus ( BitmapText * menuitem )
2002-08-17 06:44:04 +00:00
{
2002-10-28 05:30:45 +00:00
menuitem - > SetEffectCamelion ( 2.5 , RageColor ( 1 , 1 , 1 , 1 ) , RageColor ( 0 , 1 , 0 , 1 ) ) ;
2002-09-26 06:05:32 +00:00
menuitem - > SetZoom ( 0.7f ) ;
2003-01-30 07:18:33 +00:00
SOUNDMAN - > PlayOnce ( THEME - > GetPathTo ( " Sounds " , " edit menu row " ) ) ;
2002-08-17 06:44:04 +00:00
}
2002-09-26 06:05:32 +00:00
void ScreenEdit : : MenuItemLoseFocus ( BitmapText * menuitem )
2002-08-17 06:44:04 +00:00
{
2002-09-26 06:05:32 +00:00
menuitem - > SetEffectNone ( ) ;
menuitem - > SetZoom ( 0.5f ) ;
2002-08-17 06:44:04 +00:00
}