Files
itgmania212121/stepmania/src/ScreenSongOptions.cpp
T

134 lines
4.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: ScreenSongOptions
2002-05-20 08:59:37 +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.
Chris Danford
2002-05-20 08:59:37 +00:00
-----------------------------------------------------------------------------
*/
#include "ScreenSongOptions.h"
#include "RageUtil.h"
#include "ScreenManager.h"
#include "GameConstantsAndTypes.h"
#include "RageLog.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "ThemeManager.h"
#include "PrefsManager.h"
2002-05-20 08:59:37 +00:00
#define PREV_SCREEN( play_mode ) THEME->GetMetric ("ScreenSongOptions","PrevScreen"+Capitalize(PlayModeToString(play_mode)))
#define NEXT_SCREEN( play_mode ) THEME->GetMetric ("ScreenSongOptions","NextScreen"+Capitalize(PlayModeToString(play_mode)))
2002-05-20 08:59:37 +00:00
enum {
2002-07-27 19:29:51 +00:00
SO_LIFE = 0,
SO_DRAIN,
SO_BAT_LIVES,
SO_FAIL,
2002-05-20 08:59:37 +00:00
SO_ASSIST,
SO_RATE,
SO_AUTOSYNC,
2003-09-06 19:21:34 +00:00
SO_SAVE,
2002-08-01 05:11:11 +00:00
NUM_SONG_OPTIONS_LINES
2002-05-20 08:59:37 +00:00
};
OptionRow g_SongOptionsLines[NUM_SONG_OPTIONS_LINES] = {
OptionRow( "Life\nType", true, "BAR","BATTERY" ),
OptionRow( "Bar\nDrain", true, "NORMAL","NO RECOVER","SUDDEN DEATH" ),
OptionRow( "Bat\nLives", true, "1","2","3","4","5","6","7","8","9","10" ),
OptionRow( "Fail", true, "ARCADE","END OF SONG","OFF" ),
OptionRow( "Assist\nTick", true, "OFF", "ON" ),
OptionRow( "Rate", true, "0.3x","0.4x","0.5x","0.6x","0.7x","0.8x","0.9x","1.0x","1.1x","1.2x","1.3x","1.4x","1.5x","1.6x","1.7x","1.8x","1.9x","2.0x" ),
OptionRow( "Auto\nAdjust", true, "OFF", "ON" ),
2003-09-06 19:21:34 +00:00
OptionRow( "Save\nScores", true, "OFF", "ON" ),
2002-08-01 05:11:11 +00:00
};
2002-05-20 08:59:37 +00:00
2003-04-21 22:36:45 +00:00
/* Get the next screen we'll go to when finished. */
CString ScreenSongOptions::GetNextScreen()
{
return NEXT_SCREEN(GAMESTATE->m_PlayMode);
}
2002-05-20 08:59:37 +00:00
2003-09-27 22:30:51 +00:00
ScreenSongOptions::ScreenSongOptions( CString sClassName ) :
ScreenOptions( sClassName )
2002-05-20 08:59:37 +00:00
{
LOG->Trace( "ScreenSongOptions::ScreenSongOptions()" );
2002-05-20 08:59:37 +00:00
Init( INPUTMODE_TOGETHER,
2002-05-20 08:59:37 +00:00
g_SongOptionsLines,
NUM_SONG_OPTIONS_LINES,
false );
2003-04-21 22:36:45 +00:00
/* If we're coming in from "press start for more options", we need a different
* fade in. XXX: this is a hack */
if(PREFSMAN->m_ShowSongOptions == PrefsManager::ASK)
{
m_Menu.m_In.Load( THEME->GetPathToB("ScreenSongOptions option in") );
m_Menu.m_In.StartTransitioning();
}
2002-05-20 08:59:37 +00:00
}
void ScreenSongOptions::ImportOptions()
{
2002-07-23 01:41:40 +00:00
SongOptions &so = GAMESTATE->m_SongOptions;
2002-05-20 08:59:37 +00:00
2002-07-27 19:29:51 +00:00
m_iSelectedOption[0][SO_LIFE] = so.m_LifeType;
m_iSelectedOption[0][SO_BAT_LIVES] = so.m_iBatteryLives-1;
2003-08-10 00:39:28 +00:00
if ( m_iSelectedOption[0][SO_BAT_LIVES] < 0 )
m_iSelectedOption[0][SO_BAT_LIVES] = 3; // default in case value is invalid
m_iSelectedOption[0][SO_FAIL] = so.m_FailType;
m_iSelectedOption[0][SO_ASSIST] = so.m_bAssistTick;
m_iSelectedOption[0][SO_AUTOSYNC] = so.m_bAutoSync;
2003-09-06 19:21:34 +00:00
m_iSelectedOption[0][SO_SAVE] = so.m_bSaveScore;
2002-05-20 08:59:37 +00:00
m_iSelectedOption[0][SO_RATE] = 7; // in case we don't match below
2003-08-10 03:23:17 +00:00
for( unsigned i=0; i<g_SongOptionsLines[SO_RATE].choices.size(); i++ )
2003-08-11 06:09:57 +00:00
{
2003-08-11 20:29:55 +00:00
float fThisRate = (float) atof(g_SongOptionsLines[SO_RATE].choices[i]);
2003-09-11 02:36:15 +00:00
if( fabsf(fThisRate - so.m_fMusicRate) < 0.001 )
m_iSelectedOption[0][SO_RATE] = i;
2003-08-11 06:09:57 +00:00
}
2002-05-20 08:59:37 +00:00
}
void ScreenSongOptions::ExportOptions()
{
2002-07-23 01:41:40 +00:00
SongOptions &so = GAMESTATE->m_SongOptions;
2002-05-20 08:59:37 +00:00
2002-07-27 19:29:51 +00:00
so.m_LifeType = (SongOptions::LifeType)m_iSelectedOption[0][SO_LIFE];
so.m_DrainType = (SongOptions::DrainType)m_iSelectedOption[0][SO_DRAIN];
so.m_iBatteryLives = m_iSelectedOption[0][SO_BAT_LIVES]+1;
2003-06-23 07:27:51 +00:00
if( so.m_FailType != (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL] )
{
/* The user is changing the fail mode explicitly; stop messing with it. */
GAMESTATE->m_bChangedFailType = true;
2003-06-23 07:27:51 +00:00
so.m_FailType = (SongOptions::FailType)m_iSelectedOption[0][SO_FAIL];
}
so.m_bAssistTick = !!m_iSelectedOption[0][SO_ASSIST];
so.m_bAutoSync = !!m_iSelectedOption[0][SO_AUTOSYNC];
2003-09-06 19:21:34 +00:00
so.m_bSaveScore = !!m_iSelectedOption[0][SO_SAVE];
2002-05-20 08:59:37 +00:00
int iSel = m_iSelectedOption[0][SO_RATE];
2003-08-11 20:29:55 +00:00
so.m_fMusicRate = (float) atof( g_SongOptionsLines[SO_RATE].choices[iSel] );
2002-05-20 08:59:37 +00:00
}
void ScreenSongOptions::GoToPrevState()
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen( SM_None );
else
SCREENMAN->SetNewScreen( PREV_SCREEN(GAMESTATE->m_PlayMode) );
2002-05-20 08:59:37 +00:00
}
void ScreenSongOptions::GoToNextState()
{
2003-02-19 05:46:09 +00:00
if( GAMESTATE->m_bEditing )
SCREENMAN->PopTopScreen();
else
SCREENMAN->SetNewScreen( NEXT_SCREEN(GAMESTATE->m_PlayMode) );
2002-05-20 08:59:37 +00:00
}