2002-05-20 08:59:37 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
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
|
|
|
|
|
|
|
|
|
2002-08-27 03:59:22 +00:00
|
|
|
ScreenPrompt::ScreenPrompt( ScreenMessage SM_SendWhenDone, CString sText, bool bYesNoPrompt, bool bDefaultAnswer, void(*OnYes)(), void(*OnNo)() )
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
m_Fade.SetTransitionTime( 0.5f );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_Fade.SetDiffuse( RageColor(0,0,0,0.7f) );
|
2002-05-20 08:59:37 +00:00
|
|
|
m_Fade.SetOpened();
|
|
|
|
|
m_Fade.CloseWipingRight();
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Fade );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_textQuestion.LoadFromFont( THEME->GetPathTo("Fonts","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
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_textAnswer[0].LoadFromFont( THEME->GetPathTo("Fonts","header1") );
|
|
|
|
|
m_textAnswer[1].LoadFromFont( THEME->GetPathTo("Fonts","header1") );
|
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
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textAnswer[m_bAnswer].SetEffectGlowing();
|
2002-08-13 23:26:46 +00:00
|
|
|
|
2003-01-02 08:13:34 +00:00
|
|
|
SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","menu prompt") );
|
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 )
|
|
|
|
|
{
|
|
|
|
|
if( m_Fade.IsOpening() )
|
|
|
|
|
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;
|
|
|
|
|
m_textAnswer[m_bAnswer].SetEffectGlowing();
|
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 );
|
2002-07-27 19:29:51 +00:00
|
|
|
m_rectAnswerBox.SetTweenXY( m_textAnswer[m_bAnswer].GetX(), m_textAnswer[m_bAnswer].GetY() );
|
|
|
|
|
m_rectAnswerBox.SetTweenZoomX( m_textAnswer[m_bAnswer].GetWidestLineWidthInSourcePixels()+10.0f );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-02 08:13:34 +00:00
|
|
|
SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","edit change line") );
|
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
|
|
|
{
|
|
|
|
|
m_Fade.OpenWipingRight( SM_DoneOpeningWipingRight );
|
|
|
|
|
|
2002-07-27 19:29:51 +00:00
|
|
|
m_textQuestion.BeginTweening( 0.2f );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_textQuestion.SetTweenDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
|
|
|
|
m_rectAnswerBox.BeginTweening( 0.2f );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_rectAnswerBox.SetTweenDiffuse( 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 );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_textAnswer[0].SetTweenDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
m_textAnswer[1].BeginTweening( 0.2f );
|
2002-10-28 05:30:45 +00:00
|
|
|
m_textAnswer[1].SetTweenDiffuse( RageColor(1,1,1,0) );
|
2002-05-20 08:59:37 +00:00
|
|
|
|
2003-01-02 08:13:34 +00:00
|
|
|
SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","menu start") );
|
2002-08-02 09:31:06 +00:00
|
|
|
|
|
|
|
|
if( m_bAnswer )
|
2002-09-16 00:56:30 +00:00
|
|
|
if( m_pOnYes )
|
|
|
|
|
m_pOnYes();
|
2002-08-02 09:31:06 +00:00
|
|
|
else
|
2002-09-16 00:56:30 +00:00
|
|
|
if( m_pOnNo )
|
|
|
|
|
m_pOnNo();
|
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
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|