Appearance options support.

This commit is contained in:
Glenn Maynard
2003-09-28 07:14:07 +00:00
parent dffed727a6
commit ab16cff6db
3 changed files with 177 additions and 18 deletions
+18 -5
View File
@@ -17,6 +17,7 @@
#include "PrefsManager.h"
#include "ScreenOptionsMasterPrefs.h"
#include "RageSounds.h"
#include "StepMania.h"
#define OPTION_MENU_FLAGS THEME->GetMetric (m_sName,"OptionMenuFlags")
#define ROW_LINE(i) THEME->GetMetric (m_sName,ssprintf("Line%i",(i+1)))
@@ -329,7 +330,7 @@ int ScreenOptionsMaster::ImportOption( const OptionRow &row, const OptionRowHand
}
case ROW_CONFIG:
return hand.opt->Get();
return hand.opt->Get( row.choices );
default:
ASSERT(0);
@@ -372,7 +373,7 @@ void ScreenOptionsMaster::ExportOption( const OptionRow &row, const OptionRowHan
break;
case ROW_CONFIG:
hand.opt->Put( sel );
hand.opt->Put( sel, row.choices );
break;
case ROW_CHARACTER:
@@ -421,6 +422,8 @@ void ScreenOptionsMaster::ExportOption( const OptionRow &row, const OptionRowHan
void ScreenOptionsMaster::ExportOptions()
{
const CString OldTheme = THEME->GetCurThemeName();
unsigned i;
for( i = 0; i < OptionRowHandlers.size(); ++i )
{
@@ -461,12 +464,22 @@ void ScreenOptionsMaster::ExportOptions()
m_NextScreen = NEXT_SCREEN;
/* If any ROW_CONFIG options were used, save preferences. */
bool ConfUsed = false;
bool ConfChanged = false;
for( i = 0; i < OptionRowHandlers.size(); ++i )
if( OptionRowHandlers[i].type == ROW_CONFIG )
ConfUsed = true;
ConfChanged = true;
if( ConfUsed )
/* Did the theme change? */
if( OldTheme != THEME->GetCurThemeName() )
{
// THEME->SwitchThemeAndLanguage( sNewTheme, THEME->GetCurLanguage() );
ApplyGraphicOptions(); // reset graphics to apply new window title and icon
SONGMAN->UpdateRankingCourses(); // update ranking courses
ConfChanged = true; // save it
}
if( ConfChanged )
{
LOG->Trace("ROW_CONFIG used; saving ...");
PREFSMAN->SaveGlobalPrefsToDisk();
+145 -9
View File
@@ -2,14 +2,21 @@
#include "ScreenOptionsMasterPrefs.h"
#include "PrefsManager.h"
#include "ThemeManager.h"
#include "AnnouncerManager.h"
#include "NoteSkinManager.h"
#include "PlayerOptions.h"
#include "SongOptions.h"
/* "sel" is the selection in the menu. */
static void MoveData( int &sel, int &opt, bool ToSel )
template<class T>
static void MoveData( int &sel, T &opt, bool ToSel )
{
if( ToSel ) sel = opt;
else opt = sel;
if( ToSel ) (int&) sel = opt;
else opt = (T) sel;
}
template<>
static void MoveData( int &sel, bool &opt, bool ToSel )
{
if( ToSel ) sel = opt;
@@ -17,18 +24,146 @@ static void MoveData( int &sel, bool &opt, bool ToSel )
}
#define MOVE( name, opt ) \
static void name( int &sel, bool ToSel ) \
static void name( int &sel, bool ToSel, const CStringArray &choices ) \
{ \
MoveData( sel, opt, ToSel ); \
}
MOVE( PreloadSounds, PREFSMAN->m_bSoundPreloadAll );
MOVE( ResamplingQuality, PREFSMAN->m_iSoundResampleQuality );
static void LanguageChoices( CStringArray &out )
{
THEME->GetLanguages( out );
}
static void Language( int &sel, bool ToSel, const CStringArray &choices )
{
if( ToSel )
{
sel = 0;
for( unsigned i=1; i<choices.size(); i++ )
if( !stricmp(choices[i], THEME->GetCurLanguage()) )
sel = i;
} else {
const CString sNewLanguage = choices[sel];
if( THEME->GetCurLanguage() != sNewLanguage )
THEME->SwitchThemeAndLanguage( THEME->GetCurThemeName(), sNewLanguage );
}
}
static void ThemeChoices( CStringArray &out )
{
THEME->GetThemeNames( out );
}
static void Theme( int &sel, bool ToSel, const CStringArray &choices )
{
if( ToSel )
{
sel = 0;
for( unsigned i=1; i<choices.size(); i++ )
if( !stricmp(choices[i], THEME->GetCurThemeName()) )
sel = i;
} else {
const CString sNewTheme = choices[sel];
if( THEME->GetCurThemeName() != sNewTheme )
THEME->SwitchThemeAndLanguage( sNewTheme, THEME->GetCurLanguage() );
}
}
static void AnnouncerChoices( CStringArray &out )
{
ANNOUNCER->GetAnnouncerNames( out );
out.insert( out.begin(), "OFF" );
}
static void Announcer( int &sel, bool ToSel, const CStringArray &choices )
{
if( ToSel )
{
sel = 0;
for( unsigned i=1; i<choices.size(); i++ )
if( !stricmp(choices[i], ANNOUNCER->GetCurAnnouncerName()) )
sel = i;
} else {
const CString sNewAnnouncer = sel? choices[sel]:"";
ANNOUNCER->SwitchAnnouncer( sNewAnnouncer );
}
}
static void DefaultNoteSkinChoices( CStringArray &out )
{
NOTESKIN->GetNoteSkinNames( out );
for( unsigned i = 0; i < out.size(); ++i )
out[i].MakeUpper();
}
static void DefaultNoteSkin( int &sel, bool ToSel, const CStringArray &choices )
{
if( ToSel )
{
PlayerOptions po;
po.FromString( PREFSMAN->m_sDefaultModifiers );
sel = 0;
for( unsigned i=0; i < choices.size(); i++ )
if( !stricmp(choices[i], po.m_sNoteSkin) )
sel = i;
} else {
CString sModifiers = PREFSMAN->m_sDefaultModifiers;
PlayerOptions po;
po.FromString( sModifiers );
SongOptions so;
so.FromString( sModifiers );
po.m_sNoteSkin = choices[sel];
CStringArray as;
if( po.GetString() != "" )
as.push_back( po.GetString() );
if( so.GetString() != "" )
as.push_back( so.GetString() );
PREFSMAN->m_sDefaultModifiers = join(", ",as);
}
}
MOVE( Instructions, PREFSMAN->m_bInstructions );
MOVE( Caution, PREFSMAN->m_bShowDontDie );
MOVE( OniScoreDisplay, PREFSMAN->m_bDancePointsForOni );
MOVE( SongGroup, PREFSMAN->m_bShowSelectGroup );
MOVE( WheelSections, PREFSMAN->m_MusicWheelUsesSections );
MOVE( TenFootInRed, PREFSMAN->m_bTenFooterInRed );
MOVE( CourseSort, PREFSMAN->m_iCourseSortOrder );
MOVE( RandomAtEnd, PREFSMAN->m_bMoveRandomToEnd );
MOVE( Translations, PREFSMAN->m_bShowNative );
MOVE( Lyrics, PREFSMAN->m_bShowLyrics );
MOVE( PreloadSounds, PREFSMAN->m_bSoundPreloadAll );
MOVE( ResamplingQuality,PREFSMAN->m_iSoundResampleQuality );
static const ConfOption g_ConfOptions[] =
{
ConfOption( "Preload\nSounds", PreloadSounds, "NO","YES" ),
ConfOption( "Resampling\nQuality", ResamplingQuality, "FAST","NORMAL","HIGH QUALITY" ),
/* Appearance options */
ConfOption( "Language", Language, LanguageChoices ),
ConfOption( "Theme", Theme, ThemeChoices ),
ConfOption( "Announcer", Announcer, AnnouncerChoices ),
ConfOption( "Default\nNoteSkin", DefaultNoteSkin, DefaultNoteSkinChoices ),
ConfOption( "Instructions", Instructions, "SKIP","SHOW"),
ConfOption( "Caution", Caution, "SKIP","SHOW"),
ConfOption( "Oni Score\nDisplay", OniScoreDisplay, "PERCENT","DANCE POINTS"),
ConfOption( "Song\nGroup", SongGroup, "ALL MUSIC","CHOOSE"),
ConfOption( "Wheel\nSections", WheelSections, "NEVER","ALWAYS", "ABC ONLY"),
ConfOption( "10+ foot\nIn Red", TenFootInRed, "NO", "YES"),
ConfOption( "Course\nSort", CourseSort, "# SONGS","AVG FEET","TOTAL FEET","RANKING"),
ConfOption( "Random\nAt End", RandomAtEnd, "NO","YES"),
ConfOption( "Translations", Translations, "ROMANIZATION","NATIVE LANGUAGE"),
ConfOption( "Lyrics", Lyrics, "HIDE","SHOW"),
/* Sound options */
ConfOption( "Preload\nSounds", PreloadSounds, "NO","YES" ),
ConfOption( "Resampling\nQuality", ResamplingQuality, "FAST","NORMAL","HIGH QUALITY" ),
ConfOption( "", NULL )
};
@@ -41,8 +176,9 @@ const ConfOption *FindConfOption( CString name )
CString match(opt->name);
match.Replace("\n", "");
match.Replace("-", "");
match.Replace(" ", "");
if( match != name )
if( match.CompareNoCase(name) )
continue;
return opt;
+14 -4
View File
@@ -7,16 +7,16 @@ struct ConfOption
/* Name of this option. It's helpful to delimit this with newlines, as it'll
* be the default display title. */
CString name;
void (*MoveData)( int &sel, bool ToSel );
void (*MoveData)( int &sel, bool ToSel, const CStringArray &choices );
/* If MakeOptionsListCB is set, it'll be called by MakeOptionsList; otherwise
* the contents of names is returned. */
void MakeOptionsList( CStringArray &out ) const;
inline int Get() const { int sel; MoveData( sel, true ); return sel; }
inline void Put( int sel ) const { MoveData( sel, false ); }
inline int Get( const CStringArray &choices ) const { int sel; MoveData( sel, true, choices ); return sel; }
inline void Put( int sel, const CStringArray &choices ) const { MoveData( sel, false, choices ); }
ConfOption( const char *n, void (*m)( int &sel, bool in ),
ConfOption( const char *n, void (*m)( int &sel, bool in, const CStringArray &choices ),
const char *c0=NULL, const char *c1=NULL, const char *c2=NULL, const char *c3=NULL, const char *c4=NULL, const char *c5=NULL, const char *c6=NULL, const char *c7=NULL, const char *c8=NULL, const char *c9=NULL, const char *c10=NULL, const char *c11=NULL, const char *c12=NULL, const char *c13=NULL, const char *c14=NULL, const char *c15=NULL, const char *c16=NULL, const char *c17=NULL, const char *c18=NULL, const char *c19=NULL )
{
name = n;
@@ -26,6 +26,16 @@ struct ConfOption
PUSH(c0);PUSH(c1);PUSH(c2);PUSH(c3);PUSH(c4);PUSH(c5);PUSH(c6);PUSH(c7);PUSH(c8);PUSH(c9);PUSH(c10);PUSH(c11);PUSH(c12);PUSH(c13);PUSH(c14);PUSH(c15);PUSH(c16);PUSH(c17);PUSH(c18);PUSH(c19);
#undef PUSH
}
ConfOption( const char *n, void (*m)( int &sel, bool in, const CStringArray &choices ),
void (*lst)( CStringArray &out ) )
{
name = n;
MoveData = m;
MakeOptionsListCB = lst;
}
private:
vector<CString> names;
void (*MakeOptionsListCB)( CStringArray &out );