2003-02-16 04:01:45 +00:00
|
|
|
#include "global.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2002-07-27 19:29:51 +00:00
|
|
|
Class: ScreenPrompt
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +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-07-27 19:29:51 +00:00
|
|
|
Chris Danford
|
2002-05-20 08:59:37 +00:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "ScreenPrompt.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2003-01-02 07:54:28 +00:00
|
|
|
#include "RageSoundManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-11-11 04:53:31 +00:00
|
|
|
#include "ThemeManager.h"
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
const float QUESTION_X = CENTER_X;
|
|
|
|
|
const float QUESTION_Y = CENTER_Y - 60;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
const float PROMPT_X = CENTER_X;
|
|
|
|
|
const float PROMPT_Y = CENTER_Y + 120;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
ScreenPrompt::ScreenPrompt( ScreenMessage SM_SendWhenDone, CString sText, bool bYesNoPrompt, bool bDefaultAnswer, void(*OnYes)(), void(*OnNo)() ) :
|
|
|
|
|
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-07-27 19:29:51 +00:00
|
|
|
m_SMSendWhenDone = SM_SendWhenDone;
|
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;
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenPrompt background") );
|
|
|
|
|
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() );
|
|
|
|
|
m_rectAnswerBox.SetZoomX( m_textAnswer[m_bAnswer].GetWidestLineWidthInSourcePixels()+10.0f );
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
switch( DeviceI.button )
|
|
|
|
|
{
|
|
|
|
|
case SDLK_LEFT:
|
|
|
|
|
this->MenuLeft( StyleI.player );
|
|
|
|
|
return;
|
|
|
|
|
case SDLK_RIGHT:
|
2003-02-01 01:11:00 +00:00
|
|
|
this->MenuRight( StyleI.player );
|
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:
|
2002-07-27 19:29:51 +00:00
|
|
|
SCREENMAN->PopTopScreen( m_SMSendWhenDone );
|
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() );
|
|
|
|
|
m_rectAnswerBox.SetZoomX( m_textAnswer[m_bAnswer].GetWidestLineWidthInSourcePixels()+10.0f );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
SOUNDMAN->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
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
SOUNDMAN->PlayOnce( THEME->GetPathToS("Common start") );
|
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 )
|
|
|
|
|
m_pOnYes();
|
2003-06-24 20:03:28 +00:00
|
|
|
} else {
|
2002-09-16 00:56:30 +00:00
|
|
|
if( m_pOnNo )
|
|
|
|
|
m_pOnNo();
|
2003-06-24 20:03:28 +00:00
|
|
|
}
|
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
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|