2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "ScreenPrompt.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2004-07-08 00:10:34 +00:00
|
|
|
#include "GameSoundManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2004-12-04 11:09:32 +00:00
|
|
|
#include "GameState.h"
|
|
|
|
|
#include "Style.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2004-09-21 06:07:12 +00:00
|
|
|
#include "ScreenDimensions.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-11-05 06:35:10 +00:00
|
|
|
#define QUESTION_X (SCREEN_CENTER_X)
|
|
|
|
|
#define QUESTION_Y (SCREEN_CENTER_Y - 60)
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-11-05 06:35:10 +00:00
|
|
|
#define PROMPT_X (SCREEN_CENTER_X)
|
|
|
|
|
#define PROMPT_Y (SCREEN_CENTER_Y + 120)
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-11-01 19:36:52 +00:00
|
|
|
bool ScreenPrompt::s_bLastAnswer = false;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-11-26 17:28:47 +00:00
|
|
|
//REGISTER_SCREEN_CLASS( ScreenPrompt );
|
2004-01-30 05:07:26 +00:00
|
|
|
ScreenPrompt::ScreenPrompt( CString sText, bool bYesNoPrompt, bool bDefaultAnswer, void(*OnYes)(void*), void(*OnNo)(void*), void* pCallbackData ) :
|
2003-04-12 06:16:12 +00:00
|
|
|
Screen("ScreenPrompt")
|
2002-07-27 19:29:51 +00:00
|
|
|
{
|
2003-02-20 21:22:18 +00:00
|
|
|
m_bIsTransparent = true; // draw screens below us
|
|
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
m_bYesNoPrompt = bYesNoPrompt;
|
|
|
|
|
m_bAnswer = bDefaultAnswer;
|
2002-07-27 19:29:51 +00:00
|
|
|
m_pOnYes = OnYes;
|
|
|
|
|
m_pOnNo = OnNo;
|
2003-08-23 18:33:49 +00:00
|
|
|
m_pCallbackData = pCallbackData;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenPrompt background") );
|
2005-01-15 19:21:09 +00:00
|
|
|
m_Background.PlayCommand("On");
|
2003-04-12 18:34:05 +00:00
|
|
|
this->AddChild( &m_Background );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textQuestion.LoadFromFont( THEME->GetPathToF("Common normal") );
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textQuestion.SetText( sText );
|
|
|
|
|
m_textQuestion.SetXY( QUESTION_X, QUESTION_Y );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textQuestion );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-10-28 05:30:45 +00:00
|
|
|
m_rectAnswerBox.SetDiffuse( RageColor(0.5f,0.5f,1.0f,0.7f) );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_rectAnswerBox );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textAnswer[0].LoadFromFont( THEME->GetPathToF("_shared1") );
|
|
|
|
|
m_textAnswer[1].LoadFromFont( THEME->GetPathToF("_shared1") );
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textAnswer[0].SetY( PROMPT_Y );
|
|
|
|
|
m_textAnswer[1].SetY( PROMPT_Y );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textAnswer[0] );
|
|
|
|
|
this->AddChild( &m_textAnswer[1] );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
if( m_bYesNoPrompt )
|
|
|
|
|
{
|
2002-05-20 08:59:37 +00:00
|
|
|
m_textAnswer[0].SetText( "NO" );
|
|
|
|
|
m_textAnswer[1].SetText( "YES" );
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textAnswer[0].SetX( PROMPT_X+50 );
|
|
|
|
|
m_textAnswer[1].SetX( PROMPT_X-50 );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
2002-08-27 16:53:25 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_textAnswer[0].SetText( "OK" );
|
|
|
|
|
m_textAnswer[0].SetX( PROMPT_X );
|
|
|
|
|
}
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_rectAnswerBox.SetXY( m_textAnswer[m_bAnswer].GetX(), m_textAnswer[m_bAnswer].GetY() );
|
2003-11-24 02:41:52 +00:00
|
|
|
m_rectAnswerBox.SetZoomX( m_textAnswer[m_bAnswer].GetUnzoomedWidth()+10.0f );
|
2002-07-27 19:29:51 +00:00
|
|
|
m_rectAnswerBox.SetZoomY( 30 );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textAnswer[m_bAnswer].SetEffectGlowShift();
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_In.Load( THEME->GetPathToB("ScreenPrompt in") );
|
|
|
|
|
m_In.StartTransitioning();
|
|
|
|
|
this->AddChild( &m_In );
|
|
|
|
|
|
|
|
|
|
m_Out.Load( THEME->GetPathToB("ScreenPrompt out") );
|
|
|
|
|
this->AddChild( &m_Out );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenPrompt::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
Screen::Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenPrompt::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenPrompt::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
2003-04-12 18:34:05 +00:00
|
|
|
if( m_In.IsTransitioning() || m_Out.IsTransitioning() )
|
2002-05-20 08:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
2003-01-11 08:55:21 +00:00
|
|
|
if( DeviceI.device==DEVICE_KEYBOARD && type==IET_FIRST_PRESS )
|
2003-01-10 02:22:07 +00:00
|
|
|
{
|
2004-12-04 11:09:32 +00:00
|
|
|
PlayerNumber pn = GAMESTATE->GetCurrentStyle()->ControllerToPlayerNumber( GameI.controller );
|
2003-01-10 02:22:07 +00:00
|
|
|
switch( DeviceI.button )
|
|
|
|
|
{
|
2004-09-09 17:48:25 +00:00
|
|
|
case KEY_LEFT:
|
2004-12-04 11:09:32 +00:00
|
|
|
this->MenuLeft( pn );
|
2003-01-10 02:22:07 +00:00
|
|
|
return;
|
2004-09-09 17:48:25 +00:00
|
|
|
case KEY_RIGHT:
|
2004-12-04 11:09:32 +00:00
|
|
|
this->MenuRight( pn );
|
2003-01-10 02:22:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-20 08:59:37 +00:00
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenPrompt::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_DoneClosingWipingLeft:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneClosingWipingRight:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneOpeningWipingLeft:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneOpeningWipingRight:
|
2004-01-30 05:07:26 +00:00
|
|
|
SCREENMAN->PopTopScreen();
|
2002-05-20 08:59:37 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenPrompt::MenuLeft( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-27 03:59:22 +00:00
|
|
|
if( !m_bYesNoPrompt )
|
2002-05-20 08:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
MenuRight( pn );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenPrompt::MenuRight( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2002-08-27 03:59:22 +00:00
|
|
|
if( !m_bYesNoPrompt )
|
2002-05-20 08:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textAnswer[m_bAnswer].SetEffectNone();
|
|
|
|
|
m_bAnswer = !m_bAnswer;
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textAnswer[m_bAnswer].SetEffectGlowShift();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-11 08:55:21 +00:00
|
|
|
m_rectAnswerBox.StopTweening();
|
2002-05-20 08:59:37 +00:00
|
|
|
m_rectAnswerBox.BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_rectAnswerBox.SetXY( m_textAnswer[m_bAnswer].GetX(), m_textAnswer[m_bAnswer].GetY() );
|
2003-11-24 02:41:52 +00:00
|
|
|
m_rectAnswerBox.SetZoomX( m_textAnswer[m_bAnswer].GetUnzoomedWidth()+10.0f );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("ScreenPrompt change") );
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenPrompt::MenuStart( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Out.StartTransitioning( SM_DoneOpeningWipingRight );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textQuestion.BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textQuestion.SetDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
m_rectAnswerBox.BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_rectAnswerBox.SetDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textAnswer[m_bAnswer].SetEffectNone();
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
m_textAnswer[0].BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textAnswer[0].SetDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
m_textAnswer[1].BeginTweening( 0.2f );
|
2003-04-12 06:16:12 +00:00
|
|
|
m_textAnswer[1].SetDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2004-05-01 23:28:53 +00:00
|
|
|
SCREENMAN->PlayStartSound();
|
2002-08-02 09:31:06 +00:00
|
|
|
|
|
|
|
|
if( m_bAnswer )
|
2003-06-24 20:03:28 +00:00
|
|
|
{
|
2002-09-16 00:56:30 +00:00
|
|
|
if( m_pOnYes )
|
2003-08-23 18:33:49 +00:00
|
|
|
m_pOnYes(m_pCallbackData);
|
2003-11-01 19:36:52 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-09-16 00:56:30 +00:00
|
|
|
if( m_pOnNo )
|
2003-08-23 18:33:49 +00:00
|
|
|
m_pOnNo(m_pCallbackData);
|
2003-06-24 20:03:28 +00:00
|
|
|
}
|
2003-11-01 19:36:52 +00:00
|
|
|
|
|
|
|
|
s_bLastAnswer = m_bAnswer;
|
2002-05-20 08:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenPrompt::MenuBack( PlayerNumber pn )
|
2002-05-20 08:59:37 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2004-06-08 05:22:33 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 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.
|
|
|
|
|
*/
|