Files
itgmania212121/stepmania/src/ScreenPlayerOptions.cpp
T

262 lines
8.2 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-05-20 08:59:37 +00:00
/*
-----------------------------------------------------------------------------
Class: ScreenPlayerOptions
2002-05-20 08:59:37 +00:00
Desc: Select a song.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenPlayerOptions.h"
#include "RageUtil.h"
#include "ScreenManager.h"
#include "RageLog.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "ThemeManager.h"
#include "AnnouncerManager.h"
2003-02-17 12:19:42 +00:00
#include "NoteSkinManager.h"
2002-05-20 08:59:37 +00:00
2002-12-30 20:19:18 +00:00
#define SONGSEL_SCREEN THEME->GetMetric("ScreenGameplay","SongSelectScreen")
2002-05-20 08:59:37 +00:00
enum {
PO_SPEED = 0,
2003-01-25 11:05:12 +00:00
PO_ACCEL,
2002-05-20 08:59:37 +00:00
PO_EFFECT,
PO_APPEAR,
PO_TURN,
PO_TRANSFORM,
2002-05-20 08:59:37 +00:00
PO_SCROLL,
2003-02-17 12:19:42 +00:00
PO_NOTE_SKIN,
2002-05-27 08:23:27 +00:00
PO_HOLD_NOTES,
2002-07-03 21:27:26 +00:00
PO_DARK,
2002-05-20 08:59:37 +00:00
NUM_PLAYER_OPTIONS_LINES
};
OptionRowData g_PlayerOptionsLines[NUM_PLAYER_OPTIONS_LINES] = {
2003-02-12 15:56:01 +00:00
{ "Speed", 11, {"x0.25","x0.5","x0.75","x1","x1.5","x2","x3","x4","x5","x8", "x12"} },
2003-01-25 11:05:12 +00:00
{ "Acceler\n-ation",6, {"OFF","BOOST","LAND","WAVE","EXPAND","BOOMERANG"} },
{ "Effect", 7, {"OFF","DRUNK","DIZZY","SPACE","MINI","FLIP","TORNADO"} },
{ "Appear\n-ance", 5, {"VISIBLE","HIDDEN","SUDDEN","STEALTH","BLINK"} },
{ "Turn", 6, {"OFF","MIRROR","LEFT","RIGHT","SHUFFLE","SUPER SHUFFLE"} },
2003-02-20 00:57:52 +00:00
{ "Trans\n-form", 5, {"OFF","LITTLE","WIDE","BIG","QUICK"} },
{ "Scroll", 2, {"STANDARD","REVERSE"} },
2003-02-17 12:19:42 +00:00
{ "Note\nSkin", 0, {""} },
{ "Holds", 2, {"OFF","ON"} },
{ "Dark", 2, {"OFF","ON"} },
2002-05-20 08:59:37 +00:00
};
ScreenPlayerOptions::ScreenPlayerOptions() :
2003-03-09 00:55:49 +00:00
ScreenOptions("ScreenPlayerOptions",true)
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenPlayerOptions::ScreenPlayerOptions()" );
2002-05-20 08:59:37 +00:00
Init(
INPUTMODE_PLAYERS,
2002-05-20 08:59:37 +00:00
g_PlayerOptionsLines,
NUM_PLAYER_OPTIONS_LINES,
true );
2002-08-01 05:11:11 +00:00
2003-01-02 08:13:34 +00:00
SOUNDMAN->PlayOnceFromDir( ANNOUNCER->GetPathTo("player options intro") );
2003-03-11 08:52:45 +00:00
m_sprOptionsMessage.Load( THEME->GetPathTo("Graphics","ScreenPlayerOptions options") );
m_sprOptionsMessage.StopAnimating();
m_sprOptionsMessage.SetXY( CENTER_X, CENTER_Y );
m_sprOptionsMessage.SetZoom( 1 );
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
//this->AddChild( &m_sprOptionsMessage ); // we have to draw this manually over the top of transitions
m_bAcceptedChoices = false;
m_bGoToOptions = false;
2002-05-20 08:59:37 +00:00
}
void ScreenPlayerOptions::ImportOptions()
{
2003-02-17 12:19:42 +00:00
//
// fill in skin names
//
CStringArray arraySkinNames;
NOTESKIN->GetNoteSkinNames( arraySkinNames );
m_OptionRowData[PO_NOTE_SKIN].iNumOptions = arraySkinNames.size();
for( unsigned i=0; i<arraySkinNames.size(); i++ )
{
arraySkinNames[i].MakeUpper();
strcpy( m_OptionRowData[PO_NOTE_SKIN].szOptionsText[i], arraySkinNames[i] );
}
2002-05-20 08:59:37 +00:00
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-07-23 01:41:40 +00:00
PlayerOptions &po = GAMESTATE->m_PlayerOptions[p];
2002-05-20 08:59:37 +00:00
2003-01-25 11:05:12 +00:00
if( po.m_fScrollSpeed == 0.25f ) m_iSelectedOption[p][PO_SPEED] = 0;
else if( po.m_fScrollSpeed == 0.5f ) m_iSelectedOption[p][PO_SPEED] = 1;
else if( po.m_fScrollSpeed == 0.75f) m_iSelectedOption[p][PO_SPEED] = 2;
else if( po.m_fScrollSpeed == 1.0f ) m_iSelectedOption[p][PO_SPEED] = 3;
else if( po.m_fScrollSpeed == 1.5f ) m_iSelectedOption[p][PO_SPEED] = 4;
else if( po.m_fScrollSpeed == 2.0f ) m_iSelectedOption[p][PO_SPEED] = 5;
else if( po.m_fScrollSpeed == 3.0f ) m_iSelectedOption[p][PO_SPEED] = 6;
else if( po.m_fScrollSpeed == 4.0f ) m_iSelectedOption[p][PO_SPEED] = 7;
else if( po.m_fScrollSpeed == 5.0f ) m_iSelectedOption[p][PO_SPEED] = 8;
else if( po.m_fScrollSpeed == 8.0f ) m_iSelectedOption[p][PO_SPEED] = 9;
2003-02-12 15:56:01 +00:00
else if( po.m_fScrollSpeed == 12.0f) m_iSelectedOption[p][PO_SPEED] = 10;
else m_iSelectedOption[p][PO_SPEED] = 3;
2002-05-20 08:59:37 +00:00
m_iSelectedOption[p][PO_ACCEL] = po.GetFirstAccel()+1;
m_iSelectedOption[p][PO_EFFECT] = po.GetFirstEffect()+1;
m_iSelectedOption[p][PO_APPEAR] = po.GetFirstAppearance()+1;
m_iSelectedOption[p][PO_TURN] = po.m_Turn;
m_iSelectedOption[p][PO_TRANSFORM] = po.m_Transform;
m_iSelectedOption[p][PO_SCROLL] = po.m_fReverseScroll==1 ? 1 : 0 ;
2003-02-17 12:19:42 +00:00
// highlight currently selected skin
m_iSelectedOption[p][PO_NOTE_SKIN] = -1;
for( unsigned j=0; j<m_OptionRowData[PO_NOTE_SKIN].iNumOptions; j++ )
2003-02-17 12:19:42 +00:00
{
if( 0==stricmp(m_OptionRowData[PO_NOTE_SKIN].szOptionsText[j], NOTESKIN->GetCurNoteSkinName((PlayerNumber)p)) )
2003-02-17 12:19:42 +00:00
{
m_iSelectedOption[p][PO_NOTE_SKIN] = j;
2003-02-17 12:19:42 +00:00
break;
}
}
if( m_iSelectedOption[p][PO_NOTE_SKIN] == -1 )
m_iSelectedOption[p][PO_NOTE_SKIN] = 0;
2002-05-27 08:23:27 +00:00
m_iSelectedOption[p][PO_HOLD_NOTES] = po.m_bHoldNotes ? 1 : 0;
m_iSelectedOption[p][PO_DARK] = po.m_fDark==1 ? 1 : 0;
po.Init();
2002-05-20 08:59:37 +00:00
}
}
void ScreenPlayerOptions::ExportOptions()
{
for( int p=0; p<NUM_PLAYERS; p++ )
{
2002-07-23 01:41:40 +00:00
PlayerOptions &po = GAMESTATE->m_PlayerOptions[p];
po.Init();
2002-05-20 08:59:37 +00:00
switch( m_iSelectedOption[p][PO_SPEED] )
{
2003-01-25 11:05:12 +00:00
case 0: po.m_fScrollSpeed = 0.25f; break;
case 1: po.m_fScrollSpeed = 0.5f; break;
case 2: po.m_fScrollSpeed = 0.75f; break;
case 3: po.m_fScrollSpeed = 1.0f; break;
case 4: po.m_fScrollSpeed = 1.5f; break;
case 5: po.m_fScrollSpeed = 2.0f; break;
case 6: po.m_fScrollSpeed = 3.0f; break;
case 7: po.m_fScrollSpeed = 4.0f; break;
case 8: po.m_fScrollSpeed = 5.0f; break;
case 9: po.m_fScrollSpeed = 8.0f; break;
2003-02-12 15:56:01 +00:00
case 10: po.m_fScrollSpeed = 12.0f; break;
2002-05-20 08:59:37 +00:00
}
if( m_iSelectedOption[p][PO_ACCEL] != 0 )
po.SetOneAccel( (PlayerOptions::Accel)(m_iSelectedOption[p][PO_ACCEL]-1) );
if( m_iSelectedOption[p][PO_EFFECT] != 0 )
po.SetOneEffect( (PlayerOptions::Effect)(m_iSelectedOption[p][PO_EFFECT]-1) );
if( m_iSelectedOption[p][PO_APPEAR] != 0 )
po.SetOneAppearance( (PlayerOptions::Appearance)(m_iSelectedOption[p][PO_APPEAR]-1) );
2002-09-11 05:30:49 +00:00
po.m_Turn = (PlayerOptions::Turn)m_iSelectedOption[p][PO_TURN];
po.m_Transform = (PlayerOptions::Transform)m_iSelectedOption[p][PO_TRANSFORM];
po.m_fReverseScroll = (m_iSelectedOption[p][PO_SCROLL] == 1) ? 1.f : 0.f;
2003-02-17 12:19:42 +00:00
int iSelectedSkin = m_iSelectedOption[p][PO_NOTE_SKIN];
CString sNewSkin = m_OptionRowData[PO_NOTE_SKIN].szOptionsText[iSelectedSkin];
NOTESKIN->SwitchNoteSkin( (PlayerNumber)p, sNewSkin );
2002-05-27 08:23:27 +00:00
po.m_bHoldNotes = (m_iSelectedOption[p][PO_HOLD_NOTES] == 1);
po.m_fDark = (m_iSelectedOption[p][PO_DARK] == 1) ? 1.f : 0.f;
2002-05-20 08:59:37 +00:00
}
}
void ScreenPlayerOptions::GoToPrevState()
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen();
else if( GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP ||
GAMESTATE->m_PlayMode == PLAY_MODE_ONI ||
GAMESTATE->m_PlayMode == PLAY_MODE_ENDLESS)
SCREENMAN->SetNewScreen( "ScreenSelectCourse" );
else
2002-12-30 20:19:18 +00:00
SCREENMAN->SetNewScreen( SONGSEL_SCREEN );
2002-05-20 08:59:37 +00:00
}
void ScreenPlayerOptions::GoToNextState()
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen();
2003-03-11 08:52:45 +00:00
else if( m_bGoToOptions )
2003-02-12 15:56:01 +00:00
SCREENMAN->SetNewScreen( "ScreenSongOptions" );
else
SCREENMAN->SetNewScreen( "ScreenStage" );
2002-05-20 08:59:37 +00:00
}
2003-03-11 08:52:45 +00:00
void ScreenPlayerOptions::Update( float fDelta )
{
ScreenOptions::Update( fDelta );
m_sprOptionsMessage.Update( fDelta );
}
2002-05-20 08:59:37 +00:00
2003-03-11 08:52:45 +00:00
void ScreenPlayerOptions::DrawPrimitives()
{
ScreenOptions::DrawPrimitives();
m_sprOptionsMessage.Draw();
}
void ScreenPlayerOptions::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
if( type == IET_FIRST_PRESS &&
!m_Menu.m_In.IsTransitioning() &&
MenuI.IsValid() &&
MenuI.button == MENU_BUTTON_START &&
PREFSMAN->m_bShowSongOptions )
{
if( m_bAcceptedChoices && !m_bGoToOptions )
{
m_bGoToOptions = true;
m_sprOptionsMessage.SetState( 1 );
SOUNDMAN->PlayOnce( THEME->GetPathTo("Sounds","Common start") );
}
}
ScreenOptions::Input( DeviceI, type, GameI, MenuI, StyleI );
}
void ScreenPlayerOptions::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_BeginFadingOut: // when the user accepts the page of options
{
m_bAcceptedChoices = true;
float fShowSeconds = m_Menu.m_Out.GetLengthSeconds();
// show "hold START for options"
m_sprOptionsMessage.SetDiffuse( RageColor(1,1,1,0) );
m_sprOptionsMessage.BeginTweening( 0.15f ); // fade in
m_sprOptionsMessage.SetTweenZoomY( 1 );
m_sprOptionsMessage.SetTweenDiffuse( RageColor(1,1,1,1) );
m_sprOptionsMessage.BeginTweening( fShowSeconds-0.3f ); // sleep
m_sprOptionsMessage.BeginTweening( 0.15f ); // fade out
m_sprOptionsMessage.SetTweenDiffuse( RageColor(1,1,1,0) );
m_sprOptionsMessage.SetTweenZoomY( 0 );
}
break;
}
ScreenOptions::HandleScreenMessage( SM );
}