2005-05-19 23:29:39 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "ScreenSyncOverlay.h"
|
|
|
|
|
#include "ScreenDimensions.h"
|
2005-07-20 09:48:19 +00:00
|
|
|
#include "ScreenManager.h"
|
2005-05-19 23:29:39 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "song.h"
|
|
|
|
|
#include "PrefsManager.h"
|
2005-09-05 02:26:50 +00:00
|
|
|
#include "InputEventPlus.h"
|
2005-12-22 03:10:04 +00:00
|
|
|
#include "LocalizedString.h"
|
2006-02-06 01:23:25 +00:00
|
|
|
#include "AdjustSync.h"
|
2005-05-19 23:29:39 +00:00
|
|
|
|
|
|
|
|
static bool IsGameplay()
|
|
|
|
|
{
|
|
|
|
|
return SCREENMAN && SCREENMAN->GetTopScreen() && SCREENMAN->GetTopScreen()->GetScreenType() == gameplay;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-15 20:46:15 +00:00
|
|
|
REGISTER_SCREEN_CLASS( ScreenSyncOverlay );
|
2005-05-19 23:29:39 +00:00
|
|
|
|
2006-03-18 23:18:34 +00:00
|
|
|
static LocalizedString REVERT_SYNC_CHANGES ( "ScreenSyncOverlay", "Revert sync changes" );
|
|
|
|
|
static LocalizedString CURRENT_BPM ( "ScreenSyncOverlay", "Current BPM - smaller/larger" );
|
|
|
|
|
static LocalizedString SONG_OFFSET ( "ScreenSyncOverlay", "Song offset - notes earlier/later" );
|
|
|
|
|
static LocalizedString MACHINE_OFFSET ( "ScreenSyncOverlay", "Machine offset - notes earlier/later" );
|
|
|
|
|
static LocalizedString HOLD_ALT ( "ScreenSyncOverlay", "(hold Alt for smaller increment)" );
|
|
|
|
|
|
2005-05-19 23:29:39 +00:00
|
|
|
void ScreenSyncOverlay::Init()
|
|
|
|
|
{
|
|
|
|
|
Screen::Init();
|
|
|
|
|
|
|
|
|
|
m_quad.SetDiffuse( RageColor(0,0,0,0) );
|
2006-09-26 19:48:46 +00:00
|
|
|
m_quad.SetHorizAlign( align_left );
|
2005-05-19 23:29:39 +00:00
|
|
|
m_quad.SetXY( SCREEN_CENTER_X+10, SCREEN_TOP+100 );
|
|
|
|
|
this->AddChild( &m_quad );
|
|
|
|
|
|
2005-09-03 02:08:27 +00:00
|
|
|
m_textHelp.LoadFromFont( THEME->GetPathF("Common", "normal") );
|
2006-09-26 19:48:46 +00:00
|
|
|
m_textHelp.SetHorizAlign( align_left );
|
2005-05-19 23:29:39 +00:00
|
|
|
m_textHelp.SetXY( SCREEN_CENTER_X+20, SCREEN_TOP+100 );
|
|
|
|
|
m_textHelp.SetDiffuseAlpha( 0 );
|
|
|
|
|
m_textHelp.SetZoom( 0.6f );
|
|
|
|
|
m_textHelp.SetShadowLength( 2 );
|
|
|
|
|
m_textHelp.SetText(
|
2006-03-18 23:18:34 +00:00
|
|
|
REVERT_SYNC_CHANGES.GetValue()+":\n"
|
|
|
|
|
" F4\n" +
|
|
|
|
|
CURRENT_BPM.GetValue()+":\n"
|
|
|
|
|
" F9/F10\n" +
|
|
|
|
|
CURRENT_BPM.GetValue()+":\n"
|
|
|
|
|
" F11/F12\n" +
|
|
|
|
|
MACHINE_OFFSET.GetValue()+":\n"
|
|
|
|
|
" Shift + F11/F12\n" +
|
|
|
|
|
HOLD_ALT.GetValue() );
|
2005-05-19 23:29:39 +00:00
|
|
|
this->AddChild( &m_textHelp );
|
|
|
|
|
|
|
|
|
|
m_quad.ZoomToWidth( m_textHelp.GetZoomedWidth()+20 );
|
|
|
|
|
m_quad.ZoomToHeight( m_textHelp.GetZoomedHeight()+20 );
|
|
|
|
|
|
2005-09-03 02:08:27 +00:00
|
|
|
m_textStatus.LoadFromFont( THEME->GetPathF("Common", "normal") );
|
2006-09-26 19:48:46 +00:00
|
|
|
m_textStatus.SetHorizAlign( align_center );
|
2005-05-19 23:29:39 +00:00
|
|
|
m_textStatus.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y+150 );
|
|
|
|
|
m_textStatus.SetZoom( 0.8f );
|
|
|
|
|
m_textStatus.SetShadowLength( 2 );
|
|
|
|
|
this->AddChild( &m_textStatus );
|
|
|
|
|
|
|
|
|
|
Update( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSyncOverlay::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
this->SetVisible( IsGameplay() );
|
|
|
|
|
if( !IsGameplay() )
|
|
|
|
|
{
|
2006-04-04 21:48:17 +00:00
|
|
|
HideHelp();
|
2005-05-19 23:29:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Screen::Update(fDeltaTime);
|
|
|
|
|
|
|
|
|
|
// TODO: Only update when changed.
|
|
|
|
|
UpdateText();
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-08 09:05:44 +00:00
|
|
|
static Preference<bool> g_bShowAutoPlayStatus( "ShowAutoPlayStatus", true );
|
|
|
|
|
|
2006-01-26 05:53:29 +00:00
|
|
|
static LocalizedString AUTO_PLAY ( "ScreenSyncOverlay", "AutoPlay" );
|
2006-01-08 18:40:20 +00:00
|
|
|
static LocalizedString AUTO_PLAY_CPU ( "ScreenSyncOverlay", "AutoPlayCPU" );
|
|
|
|
|
static LocalizedString AUTO_SYNC_SONG ( "ScreenSyncOverlay", "AutoSync Song" );
|
|
|
|
|
static LocalizedString AUTO_SYNC_MACHINE ( "ScreenSyncOverlay", "AutoSync Machine" );
|
2005-05-19 23:29:39 +00:00
|
|
|
void ScreenSyncOverlay::UpdateText()
|
|
|
|
|
{
|
2006-01-22 01:00:06 +00:00
|
|
|
vector<RString> vs;
|
2005-05-19 23:29:39 +00:00
|
|
|
|
2006-07-08 09:05:44 +00:00
|
|
|
if( g_bShowAutoPlayStatus )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-07-08 08:32:54 +00:00
|
|
|
switch( PREFSMAN->m_AutoPlay )
|
|
|
|
|
{
|
|
|
|
|
case PC_HUMAN: break;
|
|
|
|
|
case PC_AUTOPLAY: vs.push_back(AUTO_PLAY); break;
|
|
|
|
|
case PC_CPU: vs.push_back(AUTO_PLAY_CPU); break;
|
|
|
|
|
default: ASSERT(0);
|
|
|
|
|
}
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-05 02:38:05 +00:00
|
|
|
switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 05:53:29 +00:00
|
|
|
case SongOptions::AUTOSYNC_OFF: break;
|
2006-01-08 18:40:20 +00:00
|
|
|
case SongOptions::AUTOSYNC_SONG: vs.push_back(AUTO_SYNC_SONG); break;
|
|
|
|
|
case SongOptions::AUTOSYNC_MACHINE: vs.push_back(AUTO_SYNC_MACHINE); break;
|
2005-05-19 23:29:39 +00:00
|
|
|
default: ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-26 05:55:19 +00:00
|
|
|
if( GAMESTATE->m_pCurSong != NULL && !GAMESTATE->IsCourseMode() ) // sync controls available
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-03-18 23:53:13 +00:00
|
|
|
AdjustSync::GetSyncChangeTextGlobal( vs );
|
|
|
|
|
AdjustSync::GetSyncChangeTextSong( vs );
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-08 18:40:20 +00:00
|
|
|
m_textStatus.SetText( join("\n",vs) );
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-20 08:35:47 +00:00
|
|
|
static LocalizedString CANT_SYNC_WHILE_PLAYING_A_COURSE ("ScreenSyncOverlay","Can't sync while playing a course.");
|
2006-01-26 05:53:29 +00:00
|
|
|
static LocalizedString SYNC_CHANGES_REVERTED ("ScreenSyncOverlay","Sync changes reverted.");
|
2005-09-05 02:26:50 +00:00
|
|
|
bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
|
|
|
|
if( !IsGameplay() )
|
|
|
|
|
return false;
|
|
|
|
|
|
2005-09-05 02:26:50 +00:00
|
|
|
if( input.DeviceI.device != DEVICE_KEYBOARD )
|
2005-05-19 23:29:39 +00:00
|
|
|
return false;
|
|
|
|
|
|
2006-01-26 06:12:25 +00:00
|
|
|
enum Action
|
|
|
|
|
{
|
|
|
|
|
RevertSyncChanges,
|
|
|
|
|
ChangeSongBPM,
|
|
|
|
|
ChangeGlobalOffset,
|
|
|
|
|
ChangeSongOffset,
|
|
|
|
|
Action_Invalid
|
|
|
|
|
};
|
|
|
|
|
Action a = Action_Invalid;
|
|
|
|
|
|
|
|
|
|
bool bIncrease = true;
|
2005-09-05 02:26:50 +00:00
|
|
|
switch( input.DeviceI.button )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 06:12:25 +00:00
|
|
|
case KEY_F4: a = RevertSyncChanges; break;
|
|
|
|
|
case KEY_F9: bIncrease = false; /* fall through */
|
|
|
|
|
case KEY_F10: a = ChangeSongBPM; break;
|
|
|
|
|
case KEY_F11: bIncrease = false; /* fall through */
|
2005-05-19 23:29:39 +00:00
|
|
|
case KEY_F12:
|
2006-01-26 06:12:25 +00:00
|
|
|
if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)) ||
|
2006-01-26 06:21:57 +00:00
|
|
|
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) )
|
2006-01-26 06:12:25 +00:00
|
|
|
a = ChangeGlobalOffset;
|
|
|
|
|
else
|
|
|
|
|
a = ChangeSongOffset;
|
2005-05-19 23:29:39 +00:00
|
|
|
break;
|
2006-01-26 06:21:57 +00:00
|
|
|
|
2005-05-19 23:29:39 +00:00
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-26 06:12:25 +00:00
|
|
|
if( GAMESTATE->IsCourseMode() && a != ChangeGlobalOffset )
|
|
|
|
|
{
|
|
|
|
|
SCREENMAN->SystemMessage( CANT_SYNC_WHILE_PLAYING_A_COURSE );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch( a )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 06:12:25 +00:00
|
|
|
case RevertSyncChanges:
|
2006-08-12 08:42:47 +00:00
|
|
|
switch( input.type )
|
|
|
|
|
{
|
|
|
|
|
case IET_FIRST_PRESS: break;
|
|
|
|
|
default: return false;
|
|
|
|
|
}
|
2005-12-20 08:35:47 +00:00
|
|
|
SCREENMAN->SystemMessage( SYNC_CHANGES_REVERTED );
|
2006-02-06 01:23:25 +00:00
|
|
|
AdjustSync::RevertSyncChanges();
|
2005-05-19 23:29:39 +00:00
|
|
|
break;
|
2006-01-26 06:12:25 +00:00
|
|
|
case ChangeSongBPM:
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 06:12:25 +00:00
|
|
|
float fDelta = bIncrease? +0.02f:-0.02f;
|
2005-05-19 23:29:39 +00:00
|
|
|
if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RALT)) ||
|
|
|
|
|
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LALT)) )
|
2005-09-05 02:26:50 +00:00
|
|
|
{
|
2005-05-19 23:29:39 +00:00
|
|
|
fDelta /= 20;
|
2005-09-05 02:26:50 +00:00
|
|
|
}
|
|
|
|
|
switch( input.type )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 05:53:29 +00:00
|
|
|
case IET_RELEASE: fDelta *= 0; break;
|
2006-09-13 02:59:05 +00:00
|
|
|
case IET_REPEAT:
|
2006-09-13 02:44:03 +00:00
|
|
|
if( INPUTFILTER->GetSecsHeld(input.DeviceI) < 1.0f )
|
|
|
|
|
fDelta *= 0;
|
|
|
|
|
else
|
|
|
|
|
fDelta *= 10;
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
if( GAMESTATE->m_pCurSong != NULL )
|
|
|
|
|
{
|
|
|
|
|
BPMSegment& seg = GAMESTATE->m_pCurSong->GetBPMSegmentAtBeat( GAMESTATE->m_fSongBeat );
|
|
|
|
|
seg.m_fBPS += fDelta;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2006-01-26 06:12:25 +00:00
|
|
|
case ChangeGlobalOffset:
|
|
|
|
|
case ChangeSongOffset:
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 06:12:25 +00:00
|
|
|
float fDelta = bIncrease? +0.02f:-0.02f;
|
2005-05-19 23:29:39 +00:00
|
|
|
if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RALT)) ||
|
|
|
|
|
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LALT)) )
|
2005-09-05 02:26:50 +00:00
|
|
|
{
|
2005-05-19 23:29:39 +00:00
|
|
|
fDelta /= 20; /* 1ms */
|
2005-09-05 02:26:50 +00:00
|
|
|
}
|
|
|
|
|
switch( input.type )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-03-18 23:18:34 +00:00
|
|
|
case IET_RELEASE: fDelta *= 0; break;
|
2006-09-13 02:59:05 +00:00
|
|
|
case IET_REPEAT:
|
2006-09-13 02:55:19 +00:00
|
|
|
if( INPUTFILTER->GetSecsHeld(input.DeviceI) < 1.0f )
|
|
|
|
|
fDelta *= 0;
|
|
|
|
|
else
|
|
|
|
|
fDelta *= 10;
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-26 06:12:25 +00:00
|
|
|
switch( a )
|
2005-05-19 23:29:39 +00:00
|
|
|
{
|
2006-01-26 06:12:25 +00:00
|
|
|
case ChangeGlobalOffset:
|
2005-05-19 23:29:39 +00:00
|
|
|
PREFSMAN->m_fGlobalOffsetSeconds.Set( PREFSMAN->m_fGlobalOffsetSeconds + fDelta );
|
2006-01-26 06:12:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ChangeSongOffset:
|
2005-05-19 23:29:39 +00:00
|
|
|
if( GAMESTATE->m_pCurSong != NULL )
|
|
|
|
|
GAMESTATE->m_pCurSong->m_Timing.m_fBeat0OffsetInSeconds += fDelta;
|
2006-01-26 06:12:25 +00:00
|
|
|
break;
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ShowHelp();
|
|
|
|
|
UpdateText();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenSyncOverlay::ShowHelp()
|
|
|
|
|
{
|
|
|
|
|
m_quad.StopTweening();
|
2006-01-23 04:42:12 +00:00
|
|
|
m_quad.BeginTweening( 0.3f, TWEEN_LINEAR );
|
2005-05-19 23:29:39 +00:00
|
|
|
m_quad.SetDiffuseAlpha( 0.5f );
|
|
|
|
|
|
|
|
|
|
m_textHelp.StopTweening();
|
2006-01-23 04:42:12 +00:00
|
|
|
m_textHelp.BeginTweening( 0.3f, TWEEN_LINEAR );
|
2005-05-19 23:29:39 +00:00
|
|
|
m_textHelp.SetDiffuseAlpha( 1 );
|
|
|
|
|
|
2005-06-02 08:31:31 +00:00
|
|
|
m_quad.Sleep( 4 );
|
2006-01-23 04:42:12 +00:00
|
|
|
m_quad.BeginTweening( 0.3f, TWEEN_LINEAR );
|
2005-06-02 08:31:31 +00:00
|
|
|
m_quad.SetDiffuseAlpha( 0 );
|
2005-05-19 23:29:39 +00:00
|
|
|
|
2005-06-02 08:31:31 +00:00
|
|
|
m_textHelp.Sleep( 4 );
|
2006-01-23 04:42:12 +00:00
|
|
|
m_textHelp.BeginTweening( 0.3f, TWEEN_LINEAR );
|
2005-06-02 08:31:31 +00:00
|
|
|
m_textHelp.SetDiffuseAlpha( 0 );
|
2005-05-19 23:29:39 +00:00
|
|
|
}
|
|
|
|
|
|
2006-04-04 21:48:17 +00:00
|
|
|
void ScreenSyncOverlay::HideHelp()
|
|
|
|
|
{
|
|
|
|
|
m_quad.FinishTweening();
|
|
|
|
|
m_textHelp.FinishTweening();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-19 23:29:39 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 2001-2005 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|