Files
itgmania212121/stepmania/src/ScreenPrompt.cpp
T

171 lines
4.3 KiB
C++
Raw Normal View History

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"
#include "RageMusic.h"
#include "ScreenTitleMenu.h"
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.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-02 09:31:06 +00:00
ScreenPrompt::ScreenPrompt( ScreenMessage SM_SendWhenDone, CString sText, PromptType pt, bool bDefaultAnswer, void(*OnYes)(), void(*OnNo)() )
2002-07-27 19:29:51 +00:00
{
m_SMSendWhenDone = SM_SendWhenDone;
m_pOnYes = OnYes;
m_pOnNo = OnNo;
2002-05-20 08:59:37 +00:00
m_PromptType = pt;
2002-07-27 19:29:51 +00:00
m_bAnswer = bDefaultAnswer;
2002-05-20 08:59:37 +00:00
m_Fade.SetTransitionTime( 0.5f );
2002-08-01 03:15:27 +00:00
m_Fade.SetDiffuseColor( D3DXCOLOR(0,0,0,0.7f) );
2002-05-20 08:59:37 +00:00
m_Fade.SetOpened();
m_Fade.CloseWipingRight();
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_Fade );
2002-05-20 08:59:37 +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 );
this->AddSubActor( &m_textQuestion );
2002-05-20 08:59:37 +00:00
m_rectAnswerBox.SetDiffuseColor( D3DXCOLOR(0.5f,0.5f,1.0f,0.7f) );
2002-07-23 01:41:40 +00:00
this->AddSubActor( &m_rectAnswerBox );
2002-05-20 08:59:37 +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-07-23 01:41:40 +00:00
this->AddSubActor( &m_textAnswer[0] );
this->AddSubActor( &m_textAnswer[1] );
2002-05-20 08:59:37 +00:00
switch( m_PromptType )
{
case PROMPT_OK:
m_textAnswer[0].SetText( "OK" );
2002-07-27 19:29:51 +00:00
m_textAnswer[0].SetX( PROMPT_X );
2002-05-20 08:59:37 +00:00
break;
case PROMPT_YES_NO:
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
break;
}
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();
SOUND->PlayOnceStreamed( 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;
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-05-27 18:36:01 +00:00
void ScreenPrompt::MenuLeft( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
if( m_PromptType == PROMPT_OK )
return;
MenuRight( p );
}
2002-05-27 18:36:01 +00:00
void ScreenPrompt::MenuRight( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
if( m_PromptType == PROMPT_OK )
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
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
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","edit change line") );
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
void ScreenPrompt::MenuStart( const PlayerNumber p )
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 );
m_textQuestion.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
2002-05-20 08:59:37 +00:00
m_rectAnswerBox.BeginTweening( 0.2f );
m_rectAnswerBox.SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
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 );
m_textAnswer[0].SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
m_textAnswer[1].BeginTweening( 0.2f );
m_textAnswer[1].SetTweenDiffuseColor( D3DXCOLOR(1,1,1,0) );
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") );
2002-08-02 09:31:06 +00:00
if( m_bAnswer )
m_pOnYes();
else
m_pOnNo();
2002-05-20 08:59:37 +00:00
}
2002-05-27 18:36:01 +00:00
void ScreenPrompt::MenuBack( const PlayerNumber p )
2002-05-20 08:59:37 +00:00
{
}