2002-08-23 20:18:29 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenTextEntry
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ScreenTextEntry.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
|
|
|
|
#include "RageMusic.h"
|
|
|
|
|
#include "ScreenTitleMenu.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
|
|
|
|
|
const float QUESTION_X = CENTER_X;
|
|
|
|
|
const float QUESTION_Y = CENTER_Y - 60;
|
|
|
|
|
|
|
|
|
|
const float ANSWER_X = CENTER_X;
|
|
|
|
|
const float ANSWER_Y = CENTER_Y + 120;
|
|
|
|
|
const float ANSWER_WIDTH = 440;
|
|
|
|
|
const float ANSWER_HEIGHT = 30;
|
|
|
|
|
|
|
|
|
|
ScreenTextEntry::ScreenTextEntry( ScreenMessage SM_SendWhenDone, CString sQuestion, CString sInitialAnswer, void(*OnOK)(CString sAnswer), void(*OnCancel)() )
|
|
|
|
|
{
|
|
|
|
|
m_SMSendWhenDone = SM_SendWhenDone;
|
|
|
|
|
m_pOnOK = OnOK;
|
|
|
|
|
m_pOnCancel = OnCancel;
|
|
|
|
|
m_sAnswer = sInitialAnswer;
|
2002-09-16 22:33:44 +00:00
|
|
|
m_bCancelled = false;
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_Fade.SetTransitionTime( 0.5f );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_Fade.SetDiffuse( D3DXCOLOR(0,0,0,0.7f) );
|
2002-08-23 20:18:29 +00:00
|
|
|
m_Fade.SetOpened();
|
|
|
|
|
m_Fade.CloseWipingRight();
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_Fade );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_textQuestion.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
|
|
|
|
|
m_textQuestion.SetText( sQuestion );
|
|
|
|
|
m_textQuestion.SetXY( QUESTION_X, QUESTION_Y );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textQuestion );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
2002-09-02 21:59:58 +00:00
|
|
|
m_rectAnswerBox.SetDiffuse( D3DXCOLOR(0.5f,0.5f,1.0f,0.7f) );
|
|
|
|
|
this->AddChild( &m_rectAnswerBox );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_rectAnswerBox.SetXY( ANSWER_X, ANSWER_Y );
|
|
|
|
|
m_rectAnswerBox.SetZoomX( ANSWER_WIDTH );
|
|
|
|
|
m_rectAnswerBox.SetZoomY( ANSWER_HEIGHT );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_rectAnswerBox );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_textAnswer.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
|
|
|
|
|
m_textAnswer.LoadFromFont( THEME->GetPathTo("Fonts","header1") );
|
|
|
|
|
m_textAnswer.SetXY( ANSWER_X, ANSWER_Y );
|
|
|
|
|
m_textAnswer.SetText( m_sAnswer );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textAnswer );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu prompt") );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
Screen::Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
|
|
|
|
|
{
|
|
|
|
|
if( m_Fade.IsOpening() )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if( type != IET_FIRST_PRESS )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch( DeviceI.button )
|
|
|
|
|
{
|
|
|
|
|
case DIK_ESCAPE:
|
|
|
|
|
m_bCancelled = true;
|
|
|
|
|
MenuStart(PLAYER_1);
|
|
|
|
|
break;
|
|
|
|
|
case DIK_RETURN:
|
|
|
|
|
MenuStart(PLAYER_1);
|
|
|
|
|
break;
|
|
|
|
|
case DIK_BACK:
|
|
|
|
|
m_sAnswer = m_sAnswer.Left( max(0,m_sAnswer.GetLength()-1) );
|
|
|
|
|
m_textAnswer.SetText( m_sAnswer );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
char c;
|
|
|
|
|
c = DeviceI.ToChar();
|
2002-09-16 22:25:23 +00:00
|
|
|
if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) ||
|
|
|
|
|
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT)))
|
|
|
|
|
{
|
|
|
|
|
c = toupper(c);
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-23 20:18:29 +00:00
|
|
|
if( c != '\0' )
|
|
|
|
|
m_sAnswer += c;
|
|
|
|
|
m_textAnswer.SetText( m_sAnswer );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenTextEntry::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_DoneClosingWipingLeft:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneClosingWipingRight:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneOpeningWipingLeft:
|
|
|
|
|
break;
|
|
|
|
|
case SM_DoneOpeningWipingRight:
|
|
|
|
|
SCREENMAN->PopTopScreen( m_SMSendWhenDone );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuLeft( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuRight( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuStart( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
|
|
|
|
m_Fade.OpenWipingRight( SM_DoneOpeningWipingRight );
|
|
|
|
|
|
|
|
|
|
m_textQuestion.BeginTweening( 0.2f );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_textQuestion.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_rectAnswerBox.BeginTweening( 0.2f );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_rectAnswerBox.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
m_textAnswer.SetEffectNone();
|
|
|
|
|
|
|
|
|
|
m_textAnswer.BeginTweening( 0.2f );
|
2002-09-02 21:59:58 +00:00
|
|
|
m_textAnswer.SetTweenDiffuse( D3DXCOLOR(1,1,1,0) );
|
2002-08-23 20:18:29 +00:00
|
|
|
|
|
|
|
|
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") );
|
|
|
|
|
|
2002-09-16 22:33:44 +00:00
|
|
|
if( m_bCancelled ) {
|
|
|
|
|
if( m_pOnCancel ) m_pOnCancel();
|
|
|
|
|
} else {
|
|
|
|
|
if( m_pOnOK ) m_pOnOK( m_sAnswer );
|
|
|
|
|
}
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-04 03:49:08 +00:00
|
|
|
void ScreenTextEntry::MenuBack( PlayerNumber pn )
|
2002-08-23 20:18:29 +00:00
|
|
|
{
|
|
|
|
|
m_bCancelled = true;
|
2002-09-04 03:49:08 +00:00
|
|
|
MenuStart(pn);
|
2002-08-23 20:18:29 +00:00
|
|
|
}
|