From 6d7da107f339c796c26c43405c8c9ea3f08c25e3 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Thu, 29 Aug 2002 04:56:03 +0000 Subject: [PATCH] Added assist tick and text field editing to editor. Cleaned up more theme metrics stuff. --- stepmania/NEWS | 2 + stepmania/Themes/default/metrics.ini | 8 +- stepmania/src/Background.cpp | 2 +- stepmania/src/GhostArrow.cpp | 11 +- stepmania/src/GhostArrowBright.cpp | 9 +- stepmania/src/ScreenEdit.cpp | 223 +++++++++++++++++-------- stepmania/src/ScreenEdit.h | 7 +- stepmania/src/ScreenEditMenu.cpp | 6 +- stepmania/src/ScreenGraphicOptions.cpp | 23 +-- stepmania/src/ScreenTextEntry.cpp | 2 - 10 files changed, 186 insertions(+), 107 deletions(-) diff --git a/stepmania/NEWS b/stepmania/NEWS index 5c93a2e679..077d3c5835 100644 --- a/stepmania/NEWS +++ b/stepmania/NEWS @@ -1,4 +1,6 @@ ------------------------CVS after 3.00 beta 6---------------- +NEW FEATURE: Added assist tick toggle to editor. +NEW FEATURE: Added editing of text fields to editor. CHANGE: Improved the appearance of hidden/sudden. CHANGE: After changing sort to "BEST", focus will be changed to the the most-played song. diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 2e7c04620c..bad0392a3c 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -39,13 +39,13 @@ NextScreen=ScreenSelectStyle [ScreenEz2SelectPlayer] CursorP1X=120 -CursorP1Y=360 +CursorP1Y=280 CursorP2X=520 -CursorP2Y=360 +CursorP2Y=280 ControllerP1X=120 -ControllerP1Y=380 +ControllerP1Y=280 ControllerP2X=520 -ControllerP2Y=380 +ControllerP2Y=280 HelpText=Press $ on the pad you wish to play on TimerSeconds=40 NextScreen=ScreenSelectGroup diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index f881ae98f2..56c3204647 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -73,7 +73,7 @@ Background::Background() m_sprDangerBackground.StretchTo( RECT_BACKGROUND ); m_quadBGBrightness.StretchTo( RECT_BACKGROUND ); - m_quadBGBrightness.SetDiffuseColor( D3DXCOLOR(0,0,0,1-0.5f) ); + m_quadBGBrightness.SetDiffuseColor( D3DXCOLOR(0,0,0,1-PREFSMAN->m_fBGBrightness) ); m_quadBorder[0].StretchTo( CRect(SCREEN_LEFT,SCREEN_TOP,LEFT_EDGE,SCREEN_BOTTOM) ); m_quadBorder[0].SetDiffuseColor( D3DXCOLOR(0,0,0,1) ); diff --git a/stepmania/src/GhostArrow.cpp b/stepmania/src/GhostArrow.cpp index c776340de5..fb85e14f29 100644 --- a/stepmania/src/GhostArrow.cpp +++ b/stepmania/src/GhostArrow.cpp @@ -51,19 +51,22 @@ GhostArrow::GhostArrow() SetDiffuseColor( D3DXCOLOR(1,1,1,0) ); - - // set the length of each frame so the animation plays in exactly 1 pop up time - for( int i=0; im_bSideIsJoined[p] = true; - } SCREENMAN->RefreshCreditsMessages(); + m_iRowLastCrossed = -1; m_pSong = GAMESTATE->m_pCurSong; @@ -245,7 +257,7 @@ ScreenEdit::ScreenEdit() m_textHelp.SetText( HELP_TEXT ); m_rectShortcutsBack.StretchTo( CRect(SCREEN_LEFT, SCREEN_TOP, SCREEN_RIGHT, SCREEN_BOTTOM) ); - m_rectShortcutsBack.SetDiffuseColor( D3DXCOLOR(0,0,0,0.5f) ); + m_rectShortcutsBack.SetDiffuseColor( D3DXCOLOR(0,0,0,0.8f) ); m_textShortcuts.LoadFromFont( THEME->GetPathTo("Fonts","normal") ); m_textShortcuts.SetXY( SHORTCUTS_X, SHORTCUTS_Y ); @@ -264,6 +276,8 @@ ScreenEdit::ScreenEdit() m_soundMusic.Load( m_pSong->GetMusicPath(), true ); // enable accurate sync + m_soundAssistTick.Load( THEME->GetPathTo("Sounds","gameplay assist tick") ); + for( int i=0; iGetPathTo("Fonts","normal") ); @@ -370,14 +384,6 @@ void ScreenEdit::Update( float fDeltaTime ) m_fTrailingBeat += fDelta * fDeltaTime*5; } - -// float fSongBeat, fBPS; -/// float fPositionSeconds = m_soundMusic.GetPositionSeconds(); - -// fPositionSeconds += 0.08f; // HACK: The assist ticks are playing too late, so make them play a tiny bit earlier -// m_pSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS ); -// LOG->Trace( "fPositionSeconds = %f, fSongBeat = %f, fBPS = %f", fPositionSeconds, fSongBeat, fBPS ); - if( m_EditMode == MODE_MENU ) { for( int i=0; im_fSongBeat ); + + + // + // play assist ticks + // + // 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( m_EditMode == MODE_PLAYING && GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_TICK ) + { + fPositionSeconds += (SOUND->GetPlayLatency()+0.018f) * m_soundMusic.GetPlaybackRate(); // HACK: Add 0.015 seconds to account for the fact that the middle of the tick sounds occurs 0.015 seconds into playing. + GAMESTATE->m_pCurSong->GetBeatAndBPSFromElapsedTime( fPositionSeconds, fSongBeat, fBPS, bFreeze ); + + 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 ); + + if( bAnyoneHasANote ) + m_soundAssistTick.Play(); + + iRowLastCrossed = iRowNow; + } + + + CString sNoteType; switch( m_SnapDisplay.GetSnapMode() ) { @@ -399,11 +435,12 @@ void ScreenEdit::Update( float fDeltaTime ) default: ASSERT(0); } + + // Only update stats every 100 frames because it's slow static int iNumTapNotes = 0, iNumHoldNotes = 0; static int iCounter = 0; - iCounter++; - if( iCounter % 30 == 0 ) + if( iCounter % 100 == 0 ) { iNumTapNotes = m_NoteFieldEdit.GetNumTapNotes(); iNumHoldNotes = m_NoteFieldEdit.GetNumHoldNotes(); @@ -416,7 +453,10 @@ void ScreenEdit::Update( float fDeltaTime ) "Play/Record rate: %.1f\n" "Difficulty = %s\n" "Description = %s\n" + "Main title = %s\n" + "Sub title = %s\n" "Num notes tap: %d, hold: %d\n" + "Assist tick is %s\n" "MusicOffsetSeconds: %.2f\n" "Preview start: %.2f, length = %.2f\n", sNoteType, @@ -425,7 +465,10 @@ void ScreenEdit::Update( float fDeltaTime ) GAMESTATE->m_SongOptions.m_fMusicRate, DifficultyClassToString( m_pNotes->m_DifficultyClass ), GAMESTATE->m_pCurNotes[PLAYER_1] ? GAMESTATE->m_pCurNotes[PLAYER_1]->m_sDescription : "no description", + m_pSong->m_sMainTitle, + m_pSong->m_sSubTitle, iNumTapNotes, iNumHoldNotes, + GAMESTATE->m_SongOptions.m_AssistType==SongOptions::ASSIST_TICK ? "ON" : "OFF", m_pSong->m_fBeat0OffsetInSeconds, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds ) ); @@ -505,6 +548,46 @@ void ScreenEdit::Input( const DeviceInput& DeviceI, const InputEventType type, c } } +// Begin helper functions for InputEdit + +void AddBGChange( CString sBGName ) +{ + Song* pSong = GAMESTATE->m_pCurSong; + + for( int i=0; im_BackgroundChanges.GetSize(); i++ ) + { + if( pSong->m_BackgroundChanges[i].m_fStartBeat == GAMESTATE->m_fSongBeat ) + break; + } + + if( i != pSong->m_BackgroundChanges.GetSize() ) // there is already a BGChange here + pSong->m_BackgroundChanges.RemoveAt( i ); + + // 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->m_sDescription = 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; +} + +// End helper functions for InputEdit + void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { if( DeviceI.device != DEVICE_KEYBOARD ) @@ -577,8 +660,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ // copy edit into current Notes Song* pSong = GAMESTATE->m_pCurSong; Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; + + // strip out the autogen marker if any. The autogen marker would have caused these Notes not to be saved to disk. + pNotes->m_sDescription.Replace( " (autogen)", "" ); - ASSERT( pNotes ); + ASSERT( pNotes ); /* if( pNotes == NULL ) { @@ -753,7 +839,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ MenuItemGainFocus( m_iMenuSelection ); m_rectRecordBack.BeginTweening( 0.5f ); - m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.5f) ); + m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.8f) ); } break; case DIK_P: @@ -769,7 +855,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_Player.Load( PLAYER_1, (NoteData*)&m_NoteFieldEdit, NULL, NULL ); m_rectRecordBack.BeginTweening( 0.5f ); - m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.5f) ); + m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.8f) ); GAMESTATE->m_fSongBeat = m_NoteFieldEdit.m_fBeginMarker - 4; // give a 1 measure lead-in float fElapsedSeconds = max( 0, m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) ); @@ -795,7 +881,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_EditMode = MODE_RECORDING; m_rectRecordBack.BeginTweening( 0.5f ); - m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.5f) ); + m_rectRecordBack.SetTweenDiffuseColor( D3DXCOLOR(0,0,0,0.8f) ); GAMESTATE->m_fSongBeat = m_NoteFieldEdit.m_fBeginMarker - 4; // give a 1 measure lead-in float fElapsedSeconds = max( 0, m_pSong->GetElapsedTimeFromBeat(GAMESTATE->m_fSongBeat) ); @@ -882,6 +968,18 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } break; + case DIK_E: + SCREENMAN->TextEntry( SM_None, "Edit notes description.\nPress Enter to confirm,\nEscape to cancel.", m_pNotes->m_sDescription, ChangeDescription, NULL ); + break; + + case DIK_A: + SCREENMAN->TextEntry( SM_None, "Edit song main title.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sMainTitle, ChangeMainTitle, NULL ); + break; + + case DIK_U: + SCREENMAN->TextEntry( SM_None, "Edit song sub title.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sSubTitle, ChangeSubTitle, NULL ); + break; + case DIK_B: { CString sOldBackground; @@ -897,6 +995,13 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } break; + case DIK_I: + 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; + case DIK_F7: case DIK_F8: { @@ -1022,24 +1127,6 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } -void ScreenEdit::AddBGChange( CString sBGName ) -{ - Song* pSong = GAMESTATE->m_pCurSong; - - for( int i=0; im_BackgroundChanges.GetSize(); i++ ) - { - if( pSong->m_BackgroundChanges[i].m_fStartBeat == GAMESTATE->m_fSongBeat ) - break; - } - - if( i != pSong->m_BackgroundChanges.GetSize() ) // there is already a BGChange here - pSong->m_BackgroundChanges.RemoveAt( i ); - - // create a new BGChange - if( sBGName != "" ) - pSong->AddBackgroundChange( BackgroundChange(GAMESTATE->m_fSongBeat, sBGName) ); -} - void ScreenEdit::InputRecord( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { if(type == IET_RELEASE) return; // don't care diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 0f4f24738c..9507f60066 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -22,7 +22,7 @@ #include "SnapDisplay.h" -const int NUM_MENU_ITEMS = 21; +const int NUM_MENU_ITEMS = 25; class ScreenEdit : public Screen @@ -46,7 +46,6 @@ protected: void MenuItemGainFocus( int iItemIndex ); void MenuItemLoseFocus( int iItemIndex ); - static void AddBGChange( CString sBGName ); enum EditMode { MODE_EDITING, MODE_MENU, MODE_RECORDING, MODE_PLAYING }; EditMode m_EditMode; @@ -97,6 +96,10 @@ protected: int m_iMenuSelection; BitmapText m_textMenu[NUM_MENU_ITEMS]; + + int m_iRowLastCrossed; + RageSoundSample m_soundAssistTick; + }; diff --git a/stepmania/src/ScreenEditMenu.cpp b/stepmania/src/ScreenEditMenu.cpp index 8361afa534..39c3a4b737 100644 --- a/stepmania/src/ScreenEditMenu.cpp +++ b/stepmania/src/ScreenEditMenu.cpp @@ -39,6 +39,8 @@ ScreenEditMenu::ScreenEditMenu() { LOG->Trace( "ScreenEditMenu::ScreenEditMenu()" ); + GAMESTATE->m_CurStyle = STYLE_NONE; + Selector.SetXY( 0, 0 ); // Selector.AllowNewNotes(); this->AddSubActor( &Selector ); @@ -149,9 +151,9 @@ void ScreenEditMenu::MenuStart( PlayerNumber p ) m_soundSelect.PlayRandom(); - m_Menu.TweenOffScreenToBlack( SM_None, false ); + m_Menu.TweenOffScreenToBlack( SM_GoToNextScreen, false ); - m_Fade.CloseWipingRight( SM_GoToNextScreen ); + m_Fade.CloseWipingRight( SM_None ); } void ScreenEditMenu::MenuBack( PlayerNumber p ) diff --git a/stepmania/src/ScreenGraphicOptions.cpp b/stepmania/src/ScreenGraphicOptions.cpp index 391f5db2b1..60ab258235 100644 --- a/stepmania/src/ScreenGraphicOptions.cpp +++ b/stepmania/src/ScreenGraphicOptions.cpp @@ -42,7 +42,7 @@ OptionLineData g_GraphicOptionsLines[NUM_GRAPHIC_OPTIONS_LINES] = { { "Refresh Rate", 11, {"MAX","DEFAULT","60","70","72","75","80","85","90","100","120"} }, { "Show Stats", 2, {"OFF","ON"} }, { "BG Mode", 4, {"OFF","ANIMATIONS","VISUALIZATIONS","RANDOM MOVIES"} }, - { "BG Brightness", 5, {"20%","40%","60%","80%","100%"} }, + { "BG Brightness", 11, {"0%","10%","20%","30%","40%","50%","60%","70%","80%","90%","100%"} }, { "Movie Decode", 4, {"1ms","2ms","3ms","4ms"} }, { "BG For Banner", 2, {"NO", "YES (slow)"} }, }; @@ -166,14 +166,7 @@ void ScreenGraphicOptions::ImportOptions() m_iSelectedOption[0][GO_SHOWSTATS] = PREFSMAN->m_bShowStats ? 1:0; m_iSelectedOption[0][GO_BGMODE] = PREFSMAN->m_BackgroundMode; - - if( PREFSMAN->m_fBGBrightness == 0.2f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 0; - else if( PREFSMAN->m_fBGBrightness == 0.4f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 1; - else if( PREFSMAN->m_fBGBrightness == 0.6f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 2; - else if( PREFSMAN->m_fBGBrightness == 0.8f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 3; - else if( PREFSMAN->m_fBGBrightness == 1.0f ) m_iSelectedOption[0][GO_BGBRIGHTNESS] = 4; - else m_iSelectedOption[0][GO_BGBRIGHTNESS] = 2; - + m_iSelectedOption[0][GO_BGBRIGHTNESS] = roundf( PREFSMAN->m_fBGBrightness*10 ); m_iSelectedOption[0][GO_MOVIEDECODEMS] = PREFSMAN->m_iMovieDecodeMS-1; m_iSelectedOption[0][GO_BGIFNOBANNER] = PREFSMAN->m_bUseBGIfNoBanner ? 1:0; } @@ -215,17 +208,7 @@ void ScreenGraphicOptions::ExportOptions() PREFSMAN->m_bShowStats = m_iSelectedOption[0][GO_SHOWSTATS] == 1; PREFSMAN->m_BackgroundMode = PrefsManager::BackgroundMode( m_iSelectedOption[0][GO_BGMODE] ); - - switch( m_iSelectedOption[0][GO_BGBRIGHTNESS] ) - { - case 0: PREFSMAN->m_fBGBrightness = 0.2f; break; - case 1: PREFSMAN->m_fBGBrightness = 0.4f; break; - case 2: PREFSMAN->m_fBGBrightness = 0.6f; break; - case 3: PREFSMAN->m_fBGBrightness = 0.8f; break; - case 4: PREFSMAN->m_fBGBrightness = 1.0f; break; - default: ASSERT(0); - } - + PREFSMAN->m_fBGBrightness = m_iSelectedOption[0][GO_BGBRIGHTNESS] / 10.0f; PREFSMAN->m_iMovieDecodeMS = m_iSelectedOption[0][GO_MOVIEDECODEMS]+1; PREFSMAN->m_bUseBGIfNoBanner = m_iSelectedOption[0][GO_BGIFNOBANNER] == 1; } diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index c28c4f61c0..47da0f6220 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -100,8 +100,6 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty m_textAnswer.SetText( m_sAnswer ); break; } - - Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); } void ScreenTextEntry::HandleScreenMessage( const ScreenMessage SM )