2003-02-18 23:15:38 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: ScreenMiniMenu
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "ScreenMiniMenu.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2003-07-26 23:05:16 +00:00
|
|
|
#include "RageSounds.h"
|
2003-02-18 23:15:38 +00:00
|
|
|
#include "GameConstantsAndTypes.h"
|
|
|
|
|
#include "PrefsManager.h"
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const float LABEL_X = 200;
|
|
|
|
|
const float ANSWER_X = 440;
|
2003-09-07 00:37:29 +00:00
|
|
|
const float SPACING_Y = 26;
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2003-02-19 05:46:09 +00:00
|
|
|
const float ZOOM_SELECTED = 0.7f;
|
|
|
|
|
const float ZOOM_NOT_SELECTED = 0.5f;
|
|
|
|
|
|
|
|
|
|
const RageColor COLOR_ENABLED = RageColor(1,1,1,1);
|
|
|
|
|
const RageColor COLOR_DISABLED = RageColor(0.5f,0.5f,0.5f,1);
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
const ScreenMessage SM_GoToOK = (ScreenMessage)(SM_User+1);
|
|
|
|
|
const ScreenMessage SM_GoToCancel = (ScreenMessage)(SM_User+2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ScreenMiniMenu::s_iLastLine;
|
2003-03-15 19:25:37 +00:00
|
|
|
int ScreenMiniMenu::s_iLastAnswers[MAX_MENU_ROWS];
|
2003-02-18 23:15:38 +00:00
|
|
|
|
|
|
|
|
|
2003-04-12 06:16:12 +00:00
|
|
|
ScreenMiniMenu::ScreenMiniMenu( Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel ) :
|
|
|
|
|
Screen("ScreenMiniMenu")
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-02-20 21:22:18 +00:00
|
|
|
m_bIsTransparent = true; // draw screens below us
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
m_SMSendOnOK = SM_SendOnOK;
|
|
|
|
|
m_SMSendOnCancel = SM_SendOnCancel;
|
|
|
|
|
m_Def = *pDef;
|
2003-03-15 19:25:37 +00:00
|
|
|
ASSERT( m_Def.rows.size() <= MAX_MENU_ROWS );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
|
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Background.LoadFromAniDir( THEME->GetPathToB("ScreenMiniMenu background") );
|
|
|
|
|
this->AddChild( &m_Background );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2003-09-07 00:37:29 +00:00
|
|
|
float fHeightOfAll = min( SCREEN_HEIGHT-80, (m_Def.rows.size()-1)*SPACING_Y );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textTitle.LoadFromFont( THEME->GetPathToF("Common normal") );
|
2003-03-15 19:25:37 +00:00
|
|
|
m_textTitle.SetText( m_Def.title );
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textTitle.SetXY( CENTER_X, CENTER_Y - fHeightOfAll/2 - 30 );
|
|
|
|
|
m_textTitle.SetZoom( 0.8f );
|
|
|
|
|
this->AddChild( &m_textTitle );
|
|
|
|
|
|
|
|
|
|
bool bMarkedFirstEnabledLine = false;
|
2003-02-19 05:46:09 +00:00
|
|
|
m_iCurLine = 0;
|
|
|
|
|
|
|
|
|
|
float fLongestLabelPlusAnswer = 0;
|
|
|
|
|
|
2003-03-15 23:55:59 +00:00
|
|
|
for( unsigned i=0; i<m_Def.rows.size(); i++ )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-11-08 00:50:25 +00:00
|
|
|
MenuRowInternal& line = m_Def.rows[i];
|
2003-02-18 23:15:38 +00:00
|
|
|
m_iCurAnswers[i] = 0;
|
|
|
|
|
|
2003-03-15 19:25:37 +00:00
|
|
|
float fY = SCALE( i, 0.f, m_Def.rows.size()-1.f, CENTER_Y-fHeightOfAll/2, CENTER_Y+fHeightOfAll/2 );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textLabel[i].LoadFromFont( THEME->GetPathToF("Common normal") );
|
2003-03-15 19:25:37 +00:00
|
|
|
m_textLabel[i].SetText( line.name );
|
2003-02-19 05:46:09 +00:00
|
|
|
m_textLabel[i].SetY( fY );
|
|
|
|
|
m_textLabel[i].SetZoom( ZOOM_NOT_SELECTED );
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textLabel[i].SetHorizAlign( Actor::align_left );
|
2003-03-15 19:25:37 +00:00
|
|
|
m_textLabel[i].SetDiffuse( line.enabled ? COLOR_ENABLED : COLOR_DISABLED );
|
2003-02-18 23:15:38 +00:00
|
|
|
this->AddChild( &m_textLabel[i] );
|
|
|
|
|
|
2003-03-15 19:25:37 +00:00
|
|
|
CString sText = line.choices.empty() ? "" : line.choices[line.defaultChoice];
|
2003-04-12 17:39:27 +00:00
|
|
|
m_textAnswer[i].LoadFromFont( THEME->GetPathToF("Common normal") );
|
2003-03-15 19:25:37 +00:00
|
|
|
m_textAnswer[i].SetText( sText );
|
2003-02-19 05:46:09 +00:00
|
|
|
m_textAnswer[i].SetY( fY );
|
|
|
|
|
m_textAnswer[i].SetZoom( ZOOM_NOT_SELECTED );
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textAnswer[i].SetHorizAlign( Actor::align_right );
|
2003-03-15 19:25:37 +00:00
|
|
|
m_textAnswer[i].SetDiffuse( line.enabled ? COLOR_ENABLED : COLOR_DISABLED );
|
2003-02-18 23:15:38 +00:00
|
|
|
this->AddChild( &m_textAnswer[i] );
|
|
|
|
|
|
2003-02-19 05:46:09 +00:00
|
|
|
fLongestLabelPlusAnswer = max(
|
|
|
|
|
fLongestLabelPlusAnswer,
|
2003-11-24 02:41:52 +00:00
|
|
|
m_textLabel[i].GetUnzoomedWidth() * ZOOM_SELECTED +
|
|
|
|
|
m_textAnswer[i].GetUnzoomedWidth() * ZOOM_SELECTED );
|
2003-02-19 05:46:09 +00:00
|
|
|
|
2003-03-15 19:25:37 +00:00
|
|
|
if( !bMarkedFirstEnabledLine && line.enabled )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
|
|
|
|
m_iCurLine = i;
|
|
|
|
|
AfterLineChanged();
|
|
|
|
|
bMarkedFirstEnabledLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-15 19:25:37 +00:00
|
|
|
m_iCurAnswers[i] = line.defaultChoice;
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
2003-02-19 05:46:09 +00:00
|
|
|
// adjust text spacing based on widest line
|
|
|
|
|
float fLabelX = LABEL_X;
|
|
|
|
|
float fAnswerX = ANSWER_X;
|
|
|
|
|
float fDefaultWidth = ANSWER_X - LABEL_X;
|
|
|
|
|
if( fLongestLabelPlusAnswer+20 > fDefaultWidth )
|
|
|
|
|
{
|
|
|
|
|
float fIncreaseBy = fLongestLabelPlusAnswer - fDefaultWidth + 20;
|
|
|
|
|
fLabelX -= fIncreaseBy/2;
|
|
|
|
|
fAnswerX += fIncreaseBy/2;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-15 23:55:59 +00:00
|
|
|
for( unsigned k=0; k<m_Def.rows.size(); k++ )
|
2003-02-19 05:46:09 +00:00
|
|
|
{
|
2003-02-19 10:58:32 +00:00
|
|
|
m_textLabel[k].SetX( fLabelX );
|
|
|
|
|
m_textAnswer[k].SetX( fAnswerX );
|
2003-02-19 05:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_In.Load( THEME->GetPathToB("ScreenMiniMenu in") );
|
|
|
|
|
m_In.StartTransitioning();
|
|
|
|
|
this->AddChild( &m_In );
|
|
|
|
|
|
|
|
|
|
m_Out.Load( THEME->GetPathToB("ScreenMiniMenu out") );
|
|
|
|
|
this->AddChild( &m_Out );
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
Screen::Update( fDeltaTime );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::DrawPrimitives()
|
|
|
|
|
{
|
|
|
|
|
Screen::DrawPrimitives();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::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() )
|
2003-02-18 23:15:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Screen::Input( DeviceI, type, GameI, MenuI, StyleI );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::HandleScreenMessage( const ScreenMessage SM )
|
|
|
|
|
{
|
|
|
|
|
switch( SM )
|
|
|
|
|
{
|
|
|
|
|
case SM_GoToOK:
|
|
|
|
|
SCREENMAN->PopTopScreen( m_SMSendOnOK );
|
|
|
|
|
break;
|
|
|
|
|
case SM_GoToCancel:
|
|
|
|
|
SCREENMAN->PopTopScreen( m_SMSendOnCancel );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 06:31:39 +00:00
|
|
|
void ScreenMiniMenu::MenuUp( PlayerNumber pn, const InputEventType type )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-10-08 06:31:39 +00:00
|
|
|
if( type == IET_RELEASE )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
if( GetGoUpSpot() != -1 )
|
|
|
|
|
{
|
|
|
|
|
BeforeLineChanged();
|
|
|
|
|
m_iCurLine = GetGoUpSpot();
|
|
|
|
|
AfterLineChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 06:31:39 +00:00
|
|
|
void ScreenMiniMenu::MenuDown( PlayerNumber pn, const InputEventType type )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-10-08 06:31:39 +00:00
|
|
|
if( type == IET_RELEASE )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
if( GetGoDownSpot() != -1 )
|
|
|
|
|
{
|
|
|
|
|
BeforeLineChanged();
|
|
|
|
|
m_iCurLine = GetGoDownSpot();
|
|
|
|
|
AfterLineChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 06:31:39 +00:00
|
|
|
void ScreenMiniMenu::MenuLeft( PlayerNumber pn, const InputEventType type )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-10-08 06:31:39 +00:00
|
|
|
if( type == IET_RELEASE )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
if( CanGoLeft() )
|
|
|
|
|
{
|
|
|
|
|
m_iCurAnswers[m_iCurLine]--;
|
|
|
|
|
AfterAnswerChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 06:31:39 +00:00
|
|
|
void ScreenMiniMenu::MenuRight( PlayerNumber pn, const InputEventType type )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-10-08 06:31:39 +00:00
|
|
|
if( type == IET_RELEASE )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-02-18 23:15:38 +00:00
|
|
|
if( CanGoRight() )
|
|
|
|
|
{
|
|
|
|
|
m_iCurAnswers[m_iCurLine]++;
|
|
|
|
|
AfterAnswerChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 06:31:39 +00:00
|
|
|
void ScreenMiniMenu::MenuStart( PlayerNumber pn, const InputEventType type )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-10-08 06:31:39 +00:00
|
|
|
if( type == IET_RELEASE )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Out.StartTransitioning( SM_GoToOK );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("Common start") );
|
2003-02-18 23:15:38 +00:00
|
|
|
|
|
|
|
|
s_iLastLine = m_iCurLine;
|
|
|
|
|
COPY( s_iLastAnswers, m_iCurAnswers );
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-08 07:22:27 +00:00
|
|
|
void ScreenMiniMenu::MenuBack( PlayerNumber pn )
|
2003-02-18 23:15:38 +00:00
|
|
|
{
|
2003-04-12 18:34:05 +00:00
|
|
|
m_Out.StartTransitioning( SM_GoToCancel );
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::BeforeLineChanged()
|
|
|
|
|
{
|
|
|
|
|
m_textLabel[m_iCurLine].SetEffectNone();
|
|
|
|
|
m_textAnswer[m_iCurLine].SetEffectNone();
|
2003-02-19 05:46:09 +00:00
|
|
|
m_textLabel[m_iCurLine].SetZoom( ZOOM_NOT_SELECTED );
|
|
|
|
|
m_textAnswer[m_iCurLine].SetZoom( ZOOM_NOT_SELECTED );
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("ScreenMiniMenu row") );
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::AfterLineChanged()
|
|
|
|
|
{
|
|
|
|
|
m_textLabel[m_iCurLine].SetEffectGlowShift( 1.0f, RageColor(0,0.5f,0,1), RageColor(0,1,0,1) );
|
|
|
|
|
m_textAnswer[m_iCurLine].SetEffectGlowShift( 1.0f, RageColor(0,0.5f,0,1), RageColor(0,1,0,1) );
|
2003-02-19 05:46:09 +00:00
|
|
|
m_textLabel[m_iCurLine].SetZoom( ZOOM_SELECTED );
|
|
|
|
|
m_textAnswer[m_iCurLine].SetZoom( ZOOM_SELECTED );
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenMiniMenu::AfterAnswerChanged()
|
|
|
|
|
{
|
2003-07-26 23:05:16 +00:00
|
|
|
SOUND->PlayOnce( THEME->GetPathToS("ScreenMiniMenu row") );
|
2003-02-18 23:15:38 +00:00
|
|
|
int iAnswerInRow = m_iCurAnswers[m_iCurLine];
|
2003-03-15 19:25:37 +00:00
|
|
|
CString sAnswerText = m_Def.rows[m_iCurLine].choices[iAnswerInRow];
|
2003-02-18 23:15:38 +00:00
|
|
|
m_textAnswer[m_iCurLine].SetText( sAnswerText );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ScreenMiniMenu::GetGoUpSpot()
|
|
|
|
|
{
|
2003-02-22 00:48:38 +00:00
|
|
|
int i;
|
|
|
|
|
for( i=m_iCurLine-1; i>=0; i-- )
|
2003-03-15 19:25:37 +00:00
|
|
|
if( m_Def.rows[i].enabled )
|
2003-02-22 00:48:38 +00:00
|
|
|
return i;
|
|
|
|
|
// wrap
|
2003-03-15 19:25:37 +00:00
|
|
|
for( i=m_Def.rows.size()-1; i>=0; i-- )
|
|
|
|
|
if( m_Def.rows[i].enabled )
|
2003-02-18 23:15:38 +00:00
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ScreenMiniMenu::GetGoDownSpot()
|
|
|
|
|
{
|
2003-03-15 23:55:59 +00:00
|
|
|
unsigned i;
|
2003-03-15 19:25:37 +00:00
|
|
|
for( i=m_iCurLine+1; i<m_Def.rows.size(); i++ )
|
|
|
|
|
if( m_Def.rows[i].enabled )
|
2003-02-22 00:48:38 +00:00
|
|
|
return i;
|
|
|
|
|
// wrap
|
2003-03-15 19:25:37 +00:00
|
|
|
for( i=0; i<m_Def.rows.size(); i++ )
|
|
|
|
|
if( m_Def.rows[i].enabled )
|
2003-02-18 23:15:38 +00:00
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ScreenMiniMenu::CanGoLeft()
|
|
|
|
|
{
|
2003-03-16 00:05:23 +00:00
|
|
|
int iNumInCurRow = m_Def.rows[m_iCurLine].choices.size();
|
|
|
|
|
if( iNumInCurRow==0 )
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return m_iCurAnswers[m_iCurLine] != 0;
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ScreenMiniMenu::CanGoRight()
|
|
|
|
|
{
|
2003-03-15 19:25:37 +00:00
|
|
|
int iNumInCurRow = m_Def.rows[m_iCurLine].choices.size();
|
2003-03-16 00:05:23 +00:00
|
|
|
if( iNumInCurRow==0 )
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return m_iCurAnswers[m_iCurLine] != iNumInCurRow-1;
|
2003-02-18 23:15:38 +00:00
|
|
|
}
|
2003-11-08 00:50:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Menu::Menu( CString t, const MenuRow *rowp )
|
|
|
|
|
{
|
|
|
|
|
title = t;
|
|
|
|
|
for( int i = 0; rowp[i].name; ++i )
|
|
|
|
|
rows.push_back( rowp[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MenuRowInternal::MenuRowInternal( const MenuRow &r )
|
|
|
|
|
{
|
|
|
|
|
name = r.name;
|
|
|
|
|
enabled = r.enabled;
|
|
|
|
|
defaultChoice = r.defaultChoice;
|
|
|
|
|
#define PUSH( c ) if(c!=NULL) choices.push_back(c);
|
|
|
|
|
for( unsigned i = 0; i < ARRAYSIZE(r.choices); ++i )
|
|
|
|
|
PUSH( r.choices[i] );
|
|
|
|
|
#undef PUSH
|
|
|
|
|
}
|
|
|
|
|
|