add ScreenOptionsProfiles (to soon replace ScreenProfileOptions)

This commit is contained in:
Chris Danford
2005-07-05 11:30:30 +00:00
parent 1cc24c34d7
commit 16fc6e6723
7 changed files with 240 additions and 6 deletions
+9 -3
View File
@@ -47,9 +47,15 @@ void OptionRow::PrepareItemText( CString &s ) const
if( CAPITALIZE_ALL_OPTION_NAMES ) if( CAPITALIZE_ALL_OPTION_NAMES )
s.MakeUpper(); s.MakeUpper();
} }
static CString OPTION_TITLE( CString s )
CString OptionRow::OptionTitle( CString s ) const
{ {
return THEME->GetMetric("OptionTitles",s); bool bTheme = false;
// HACK: Always theme the NEXT_ROW and EXIT items, even if metrics says not to theme.
if( THEME_TITLES && m_RowDef.m_bAllowThemeTitles ) bTheme = true;
return bTheme ? THEME->GetMetric("OptionTitles",s) : s;
} }
CString ITEMS_LONG_ROW_X_NAME( size_t p ) { return ssprintf("ItemsLongRowP%dX",int(p+1)); } CString ITEMS_LONG_ROW_X_NAME( size_t p ) { return ssprintf("ItemsLongRowP%dX",int(p+1)); }
@@ -174,7 +180,7 @@ void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pH
CString OptionRow::GetRowTitle() const CString OptionRow::GetRowTitle() const
{ {
CString sLineName = m_RowDef.name; CString sLineName = m_RowDef.name;
CString sTitle = THEME_TITLES ? OPTION_TITLE(sLineName) : sLineName; CString sTitle = OptionTitle(sLineName);
// HACK: tack the BPM onto the name of the speed line // HACK: tack the BPM onto the name of the speed line
if( sLineName.CompareNoCase("speed")==0 ) if( sLineName.CompareNoCase("speed")==0 )
+7
View File
@@ -42,6 +42,9 @@ struct OptionRowDefinition
set<PlayerNumber> m_vEnabledForPlayers; // only players in this set may change focus to this row set<PlayerNumber> m_vEnabledForPlayers; // only players in this set may change focus to this row
bool m_bExportOnChange; bool m_bExportOnChange;
bool m_bAllowThemeItems; // if false, ignores ScreenOptions::THEME_ITEMS bool m_bAllowThemeItems; // if false, ignores ScreenOptions::THEME_ITEMS
bool m_bAllowThemeTitles; // if false, ignores ScreenOptions::THEME_TITLES
bool m_bAllowExplanation; // if false, ignores ScreenOptions::SHOW_EXPLANATIONS
bool m_bShowChoicesListOnSelect;
bool IsEnabledForPlayer( PlayerNumber pn ) const bool IsEnabledForPlayer( PlayerNumber pn ) const
{ {
@@ -61,6 +64,9 @@ struct OptionRowDefinition
m_vEnabledForPlayers.insert( pn ); m_vEnabledForPlayers.insert( pn );
m_bExportOnChange = false; m_bExportOnChange = false;
m_bAllowThemeItems = true; m_bAllowThemeItems = true;
m_bAllowThemeTitles = true;
m_bAllowExplanation = true;
m_bShowChoicesListOnSelect = false;
} }
OptionRowDefinition( const char *n, bool b, 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 ) OptionRowDefinition( const char *n, bool b, 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 )
@@ -146,6 +152,7 @@ public:
bool GetFirstItemGoesDown() { return m_bFirstItemGoesDown; } bool GetFirstItemGoesDown() { return m_bFirstItemGoesDown; }
void PrepareItemText( CString &s ) const; void PrepareItemText( CString &s ) const;
CString OptionTitle( CString s ) const;
void SetExitText( CString sExitText ); void SetExitText( CString sExitText );
+3 -1
View File
@@ -319,7 +319,9 @@ CString ScreenOptions::GetExplanationText( int iRow ) const
CString sLineName = row.GetRowDef().name; CString sLineName = row.GetRowDef().name;
ASSERT( !sLineName.empty() ); ASSERT( !sLineName.empty() );
return SHOW_EXPLANATIONS ? OPTION_EXPLANATION(sLineName) : "";
bool bAllowExplanation = row.GetRowDef().m_bAllowExplanation;
return (bAllowExplanation && SHOW_EXPLANATIONS.GetValue()) ? OPTION_EXPLANATION(sLineName) : "";
} }
BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow ) BitmapText &ScreenOptions::GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow )
+1 -1
View File
@@ -19,7 +19,7 @@ protected:
vector<OptionRowHandler*> OptionRowHandlers; vector<OptionRowHandler*> OptionRowHandlers;
protected: protected:
void HandleScreenMessage( const ScreenMessage SM ); virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns ); virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns ); virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns );
+169
View File
@@ -0,0 +1,169 @@
#include "global.h"
#include "ScreenOptionsProfiles.h"
#include "ScreenMiniMenu.h"
#include "ProfileManager.h"
#include "ScreenTextEntry.h"
#include "RageUtil.h"
AutoScreenMessage( SM_BackFromCreateNewName )
AutoScreenMessage( SM_BackFromProfileContextMenu )
enum ContextMenuAnswer
{
A_EDIT,
A_RENAME,
A_DELETE,
A_CANCEL,
};
static MenuDef g_ProfileContextMenu(
"ScreenMiniMenuProfiles",
MenuRowDef( -1, "Edit", true, EDIT_MODE_PRACTICE, 0, "" ),
MenuRowDef( -1, "Rename", true, EDIT_MODE_PRACTICE, 0, "" ),
MenuRowDef( -1, "Delete", true, EDIT_MODE_PRACTICE, 0, "" ),
MenuRowDef( -1, "Cancel", true, EDIT_MODE_PRACTICE, 0, "" )
);
REGISTER_SCREEN_CLASS( ScreenOptionsProfiles );
ScreenOptionsProfiles::ScreenOptionsProfiles( CString sName ) :
ScreenOptions( sName )
{
}
void ScreenOptionsProfiles::Init()
{
ScreenOptions::Init();
vector<OptionRowDefinition> vDefs;
vector<OptionRowHandler*> vHands;
OptionRowDefinition def;
def.layoutType = LAYOUT_SHOW_ONE_IN_ROW;
def.m_bAllowThemeItems = false;
def.m_bAllowThemeTitles = false;
def.m_bAllowExplanation = false;
def.name = "Create New";
def.choices.clear();
vDefs.push_back( def );
vHands.push_back( NULL );
vector<CString> vsProfileNames;
PROFILEMAN->GetLocalProfileNames( vsProfileNames );
FOREACH_CONST( CString, vsProfileNames, s )
{
def.name = *s;
def.choices.clear();
vDefs.push_back( def );
vHands.push_back( NULL );
}
InitMenu( INPUTMODE_SHARE_CURSOR, vDefs, vHands );
}
ScreenOptionsProfiles::~ScreenOptionsProfiles()
{
}
void ScreenOptionsProfiles::ImportOptions( int row, const vector<PlayerNumber> &vpns )
{
}
void ScreenOptionsProfiles::ExportOptions( int row, const vector<PlayerNumber> &vpns )
{
}
void ScreenOptionsProfiles::GoToNextScreen()
{
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
}
void ScreenOptionsProfiles::GoToPrevScreen()
{
SCREENMAN->SetNewScreen( "ScreenOptionsMenu" );
}
void ScreenOptionsProfiles::HandleScreenMessage( const ScreenMessage SM )
{
if( SM == SM_BackFromCreateNewName )
{
if( !ScreenTextEntry::s_bCancelledLast && ScreenTextEntry::s_sLastAnswer != "" )
{
CString sNewName = ScreenTextEntry::s_sLastAnswer;
bool bResult = PROFILEMAN->CreateLocalProfile( sNewName );
if( bResult )
SCREENMAN->SetNewScreen( m_sName ); // reload
else
SCREENMAN->Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewName.c_str()) );
}
}
else if( SM == SM_BackFromProfileContextMenu )
{
switch( ScreenMiniMenu::s_iLastRowCode )
{
default:
ASSERT(0);
case A_EDIT:
case A_RENAME:
case A_DELETE:
case A_CANCEL:
SCREENMAN->PlayInvalidSound();
break;
}
}
}
void ScreenOptionsProfiles::ProcessMenuStart( PlayerNumber pn, const InputEventType type )
{
int iRow = GetCurrentRow();;
OptionRow &row = *m_pRows[iRow];
if( iRow == 0 ) // "create new"
{
//ScreenOptions::BeginFadingOut();
SCREENMAN->TextEntry( SM_BackFromCreateNewName, "Enter a name for a new profile.", "", 64 );
}
else if( row.GetRowType() == OptionRow::ROW_EXIT )
{
ScreenOptions::ProcessMenuStart( pn, type );
}
else
{
SCREENMAN->MiniMenu( &g_ProfileContextMenu, SM_BackFromProfileContextMenu );
}
}
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+50
View File
@@ -0,0 +1,50 @@
#ifndef ScreenOptionsProfiles_H
#define ScreenOptionsProfiles_H
#include "ScreenOptions.h"
class ScreenOptionsProfiles : public ScreenOptions
{
public:
ScreenOptionsProfiles( CString sName );
virtual void Init();
virtual ~ScreenOptionsProfiles();
protected:
private:
virtual void ImportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int row, const vector<PlayerNumber> &vpns );
virtual void GoToNextScreen();
virtual void GoToPrevScreen();
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void ProcessMenuStart( PlayerNumber pn, const InputEventType type );
};
#endif
/*
* (c) 2003-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+1 -1
View File
@@ -146,7 +146,7 @@ void ScreenProfileOptions::HandleScreenMessage( const ScreenMessage SM )
CString sNewName = ScreenTextEntry::s_sLastAnswer; CString sNewName = ScreenTextEntry::s_sLastAnswer;
bool bResult = PROFILEMAN->CreateLocalProfile( sNewName ); bool bResult = PROFILEMAN->CreateLocalProfile( sNewName );
if( bResult ) if( bResult )
SCREENMAN->SetNewScreen( "ScreenProfileOptions" ); // reload SCREENMAN->SetNewScreen( m_sName ); // reload
else else
ScreenPrompt::Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewName.c_str()) ); ScreenPrompt::Prompt( SM_None, ssprintf("Error creating profile '%s'.", sNewName.c_str()) );
} }