search songs by a genre list

move MenuDir to SSMaster header
GoalType name cleanup
This commit is contained in:
Chris Danford
2006-07-11 06:51:46 +00:00
parent a3b803e9e4
commit 29d77f5c8c
9 changed files with 64 additions and 55 deletions
+2 -2
View File
@@ -71,8 +71,8 @@ RString CourseEntry::GetTextDescription() const
vsEntryDescription.push_back( "Random" ); vsEntryDescription.push_back( "Random" );
if( !songCriteria.m_sGroupName.empty() ) if( !songCriteria.m_sGroupName.empty() )
vsEntryDescription.push_back( songCriteria.m_sGroupName ); vsEntryDescription.push_back( songCriteria.m_sGroupName );
if( !songCriteria.m_sGenre.empty() ) if( songCriteria.m_bUseSongGenreAllowedList )
vsEntryDescription.push_back( songCriteria.m_sGenre ); vsEntryDescription.push_back( join(",",songCriteria.m_vsSongGenreAllowedList) );
if( stepsCriteria.m_difficulty != DIFFICULTY_INVALID && stepsCriteria.m_difficulty != DIFFICULTY_MEDIUM ) if( stepsCriteria.m_difficulty != DIFFICULTY_INVALID && stepsCriteria.m_difficulty != DIFFICULTY_MEDIUM )
vsEntryDescription.push_back( DifficultyToLocalizedString(stepsCriteria.m_difficulty) ); vsEntryDescription.push_back( DifficultyToLocalizedString(stepsCriteria.m_difficulty) );
if( stepsCriteria.m_iLowMeter != -1 ) if( stepsCriteria.m_iLowMeter != -1 )
+4 -4
View File
@@ -54,7 +54,7 @@ void GameCommand::Init()
m_vsScreensToPrepare.clear(); m_vsScreensToPrepare.clear();
m_iWeightPounds = -1; m_iWeightPounds = -1;
m_iGoalCalories = -1; m_iGoalCalories = -1;
m_GoalType = GOAL_INVALID; m_GoalType = GoalType_INVALID;
m_sProfileID = ""; m_sProfileID = "";
m_sUrl = ""; m_sUrl = "";
@@ -129,7 +129,7 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
return false; return false;
if( m_iGoalCalories != -1 && PROFILEMAN->GetProfile(pn)->m_iGoalCalories != m_iGoalCalories ) if( m_iGoalCalories != -1 && PROFILEMAN->GetProfile(pn)->m_iGoalCalories != m_iGoalCalories )
return false; return false;
if( m_GoalType != GOAL_INVALID && PROFILEMAN->GetProfile(pn)->m_GoalType != m_GoalType ) if( m_GoalType != GoalType_INVALID && PROFILEMAN->GetProfile(pn)->m_GoalType != m_GoalType )
return false; return false;
if( !m_sProfileID.empty() && ProfileManager::m_sDefaultLocalProfileID[pn].Get() != m_sProfileID ) if( !m_sProfileID.empty() && ProfileManager::m_sDefaultLocalProfileID[pn].Get() != m_sProfileID )
return false; return false;
@@ -707,7 +707,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_iGoalCalories != -1 ) if( m_iGoalCalories != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn ) FOREACH_CONST( PlayerNumber, vpns, pn )
PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories; PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories;
if( m_GoalType != GOAL_INVALID ) if( m_GoalType != GoalType_INVALID )
FOREACH_CONST( PlayerNumber, vpns, pn ) FOREACH_CONST( PlayerNumber, vpns, pn )
PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType; PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType;
if( !m_sProfileID.empty() ) if( !m_sProfileID.empty() )
@@ -767,7 +767,7 @@ bool GameCommand::IsZero() const
m_SortOrder != SORT_INVALID || m_SortOrder != SORT_INVALID ||
m_iWeightPounds != -1 || m_iWeightPounds != -1 ||
m_iGoalCalories != -1 || m_iGoalCalories != -1 ||
m_GoalType != GOAL_INVALID || m_GoalType != GoalType_INVALID ||
!m_sProfileID.empty() || !m_sProfileID.empty() ||
!m_sUrl.empty() ) !m_sUrl.empty() )
return false; return false;
+1 -11
View File
@@ -384,22 +384,12 @@ XToString( StyleType, NUM_STYLE_TYPES );
StringToX( StyleType ); StringToX( StyleType );
static const char *MenuDirNames[] = {
"Up",
"Down",
"Left",
"Right",
"Auto",
};
XToString( MenuDir, NUM_MENU_DIRS );
static const char *GoalTypeNames[] = { static const char *GoalTypeNames[] = {
"Calories", "Calories",
"Time", "Time",
"None", "None",
}; };
XToString( GoalType, NUM_GOAL_TYPES ); XToString( GoalType, NUM_GoalType );
StringToX( GoalType ); StringToX( GoalType );
static void LuaGoalType(lua_State* L) static void LuaGoalType(lua_State* L)
{ {
+6 -19
View File
@@ -387,28 +387,15 @@ const RString& StyleTypeToString( StyleType s );
StyleType StringToStyleType( const RString& s ); StyleType StringToStyleType( const RString& s );
enum MenuDir
{
MENU_DIR_UP,
MENU_DIR_DOWN,
MENU_DIR_LEFT,
MENU_DIR_RIGHT,
MENU_DIR_AUTO, // when players join and the selection becomes invalid
NUM_MENU_DIRS
};
#define FOREACH_MenuDir( md ) FOREACH_ENUM( MenuDir, NUM_MENU_DIRS, md )
const RString& MenuDirToString( MenuDir md );
enum GoalType enum GoalType
{ {
GOAL_CALORIES, GoalType_Calories,
GOAL_TIME, GoalType_Time,
GOAL_NONE, GoalType_None,
NUM_GOAL_TYPES, NUM_GoalType,
GOAL_INVALID, GoalType_INVALID,
}; };
#define FOREACH_GoalType( gt ) FOREACH_ENUM( GoalType, NUM_GOAL_TYPES, gt ) #define FOREACH_GoalType( gt ) FOREACH_ENUM( GoalType, NUM_GoalType, gt )
const RString& GoalTypeToString( GoalType gt ); const RString& GoalTypeToString( GoalType gt );
GoalType StringToGoalType( const RString& s ); GoalType StringToGoalType( const RString& s );
+3 -3
View File
@@ -1774,15 +1774,15 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn )
float fGoal = 0; float fGoal = 0;
switch( pProfile->m_GoalType ) switch( pProfile->m_GoalType )
{ {
case GOAL_CALORIES: case GoalType_Calories:
fActual = pssAccum.fCaloriesBurned + pssCurrent.fCaloriesBurned; fActual = pssAccum.fCaloriesBurned + pssCurrent.fCaloriesBurned;
fGoal = (float)pProfile->m_iGoalCalories; fGoal = (float)pProfile->m_iGoalCalories;
break; break;
case GOAL_TIME: case GoalType_Time:
fActual = ssAccum.fGameplaySeconds + ssCurrent.fGameplaySeconds; fActual = ssAccum.fGameplaySeconds + ssCurrent.fGameplaySeconds;
fGoal = (float)pProfile->m_iGoalSeconds; fGoal = (float)pProfile->m_iGoalSeconds;
break; break;
case GOAL_NONE: case GoalType_None:
return 0; // never complete return 0; // never complete
default: default:
ASSERT(0); ASSERT(0);
+20 -11
View File
@@ -14,6 +14,15 @@
#include "RageSoundManager.h" #include "RageSoundManager.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
static const char *MenuDirNames[] = {
"Up",
"Down",
"Left",
"Right",
"Auto",
};
XToString( MenuDir, NUM_MenuDir );
AutoScreenMessage( SM_PlayPostSwitchPage ) AutoScreenMessage( SM_PlayPostSwitchPage )
RString CURSOR_OFFSET_X_FROM_ICON_NAME( size_t p ) { return ssprintf("CursorP%dOffsetXFromIcon",int(p+1)); } RString CURSOR_OFFSET_X_FROM_ICON_NAME( size_t p ) { return ssprintf("CursorP%dOffsetXFromIcon",int(p+1)); }
@@ -42,7 +51,7 @@ void ScreenSelectMaster::Init()
PER_CHOICE_ICON_ELEMENT.Load( m_sName, "PerChoiceIconElement" ); PER_CHOICE_ICON_ELEMENT.Load( m_sName, "PerChoiceIconElement" );
PRE_SWITCH_PAGE_SECONDS.Load( m_sName, "PreSwitchPageSeconds" ); PRE_SWITCH_PAGE_SECONDS.Load( m_sName, "PreSwitchPageSeconds" );
POST_SWITCH_PAGE_SECONDS.Load( m_sName, "PostSwitchPageSeconds" ); POST_SWITCH_PAGE_SECONDS.Load( m_sName, "PostSwitchPageSeconds" );
OPTION_ORDER.Load( m_sName, OPTION_ORDER_NAME, NUM_MENU_DIRS ); OPTION_ORDER.Load( m_sName, OPTION_ORDER_NAME, NUM_MenuDir );
WRAP_CURSOR.Load( m_sName, "WrapCursor" ); WRAP_CURSOR.Load( m_sName, "WrapCursor" );
WRAP_SCROLLER.Load( m_sName, "WrapScroller" ); WRAP_SCROLLER.Load( m_sName, "WrapScroller" );
LOOP_SCROLLER.Load( m_sName, "LoopScroller" ); LOOP_SCROLLER.Load( m_sName, "LoopScroller" );
@@ -202,8 +211,8 @@ void ScreenSelectMaster::Init()
int add; int add;
switch( dir ) switch( dir )
{ {
case MENU_DIR_UP: case MenuDir_Up:
case MENU_DIR_LEFT: case MenuDir_Left:
add = -1; add = -1;
break; break;
default: default:
@@ -212,8 +221,8 @@ void ScreenSelectMaster::Init()
} }
m_mapCurrentChoiceToNextChoice[dir][c] = c + add; m_mapCurrentChoiceToNextChoice[dir][c] = c + add;
/* Always wrap around MENU_DIR_AUTO. */ /* Always wrap around MenuDir_Auto. */
if( dir == MENU_DIR_AUTO || (bool)WRAP_CURSOR ) if( dir == MenuDir_Auto || (bool)WRAP_CURSOR )
wrap( m_mapCurrentChoiceToNextChoice[dir][c], m_aGameCommands.size() ); wrap( m_mapCurrentChoiceToNextChoice[dir][c], m_aGameCommands.size() );
else else
m_mapCurrentChoiceToNextChoice[dir][c] = clamp( m_mapCurrentChoiceToNextChoice[dir][c], 0, (int)m_aGameCommands.size()-1 ); m_mapCurrentChoiceToNextChoice[dir][c] = clamp( m_mapCurrentChoiceToNextChoice[dir][c], 0, (int)m_aGameCommands.size()-1 );
@@ -349,7 +358,7 @@ void ScreenSelectMaster::UpdateSelectableChoices()
*/ */
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
if( !m_aGameCommands[m_iChoice[p]].IsPlayable() ) if( !m_aGameCommands[m_iChoice[p]].IsPlayable() )
Move( p, MENU_DIR_AUTO ); Move( p, MenuDir_Auto );
} }
bool ScreenSelectMaster::AnyOptionsArePlayable() const bool ScreenSelectMaster::AnyOptionsArePlayable() const
@@ -399,7 +408,7 @@ void ScreenSelectMaster::MenuLeft( const InputEventPlus &input )
if( m_TrackingRepeatingInput != input.MenuI ) if( m_TrackingRepeatingInput != input.MenuI )
return; return;
} }
if( Move(pn, MENU_DIR_LEFT) ) if( Move(pn, MenuDir_Left) )
{ {
m_TrackingRepeatingInput = input.MenuI; m_TrackingRepeatingInput = input.MenuI;
m_soundChange.Play(); m_soundChange.Play();
@@ -422,7 +431,7 @@ void ScreenSelectMaster::MenuRight( const InputEventPlus &input )
if( m_TrackingRepeatingInput != input.MenuI ) if( m_TrackingRepeatingInput != input.MenuI )
return; return;
} }
if( Move(pn, MENU_DIR_RIGHT) ) if( Move(pn, MenuDir_Right) )
{ {
m_TrackingRepeatingInput = input.MenuI; m_TrackingRepeatingInput = input.MenuI;
m_soundChange.Play(); m_soundChange.Play();
@@ -445,7 +454,7 @@ void ScreenSelectMaster::MenuUp( const InputEventPlus &input )
if( m_TrackingRepeatingInput != input.MenuI ) if( m_TrackingRepeatingInput != input.MenuI )
return; return;
} }
if( Move(pn, MENU_DIR_UP) ) if( Move(pn, MenuDir_Up) )
{ {
m_TrackingRepeatingInput = input.MenuI; m_TrackingRepeatingInput = input.MenuI;
m_soundChange.Play(); m_soundChange.Play();
@@ -468,7 +477,7 @@ void ScreenSelectMaster::MenuDown( const InputEventPlus &input )
if( m_TrackingRepeatingInput != input.MenuI ) if( m_TrackingRepeatingInput != input.MenuI )
return; return;
} }
if( Move(pn, MENU_DIR_DOWN) ) if( Move(pn, MenuDir_Down) )
{ {
m_TrackingRepeatingInput = input.MenuI; m_TrackingRepeatingInput = input.MenuI;
m_soundChange.Play(); m_soundChange.Play();
@@ -607,7 +616,7 @@ bool ScreenSelectMaster::ChangeSelection( PlayerNumber pn, MenuDir dir, int iNew
{ {
// HACK: We can't tell from the option orders whether or not we wrapped. // HACK: We can't tell from the option orders whether or not we wrapped.
// For now, assume that the order is increasing left to right. // For now, assume that the order is increasing left to right.
int iPressedDir = (dir == MENU_DIR_LEFT) ? -1 : +1; int iPressedDir = (dir == MenuDir_Left) ? -1 : +1;
int iActualDir = (iOldChoice < iNewChoice) ? +1 : -1; int iActualDir = (iOldChoice < iNewChoice) ? +1 : -1;
if( iPressedDir != iActualDir ) // wrapped if( iPressedDir != iActualDir ) // wrapped
+13 -1
View File
@@ -8,6 +8,18 @@
#include "ActorScroller.h" #include "ActorScroller.h"
#include "MenuInput.h" #include "MenuInput.h"
enum MenuDir
{
MenuDir_Up,
MenuDir_Down,
MenuDir_Left,
MenuDir_Right,
MenuDir_Auto, // when players join and the selection becomes invalid
NUM_MenuDir,
};
#define FOREACH_MenuDir( md ) FOREACH_ENUM( MenuDir, NUM_MenuDir, md )
const RString& MenuDirToString( MenuDir md );
class ScreenSelectMaster : public ScreenSelect class ScreenSelectMaster : public ScreenSelect
{ {
public: public:
@@ -57,7 +69,7 @@ protected:
ThemeMetric<int> SCROLLER_SUBDIVISIONS; ThemeMetric<int> SCROLLER_SUBDIVISIONS;
ThemeMetric<RString> DEFAULT_CHOICE; ThemeMetric<RString> DEFAULT_CHOICE;
map<int,int> m_mapCurrentChoiceToNextChoice[NUM_MENU_DIRS]; map<int,int> m_mapCurrentChoiceToNextChoice[NUM_MenuDir];
virtual int GetSelectionIndex( PlayerNumber pn ); virtual int GetSelectionIndex( PlayerNumber pn );
virtual void UpdateSelectableChoices(); virtual void UpdateSelectableChoices();
+10 -1
View File
@@ -19,8 +19,13 @@ bool SongCriteria::Matches( const Song *pSong ) const
{ {
if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName ) if( !m_sGroupName.empty() && m_sGroupName != pSong->m_sGroupName )
return false; return false;
if( !m_sGenre.empty() && m_sGenre != pSong->m_sGenre )
if( m_bUseSongGenreAllowedList )
{
if( find(m_vsSongGenreAllowedList.begin(),m_vsSongGenreAllowedList.end(),pSong->m_sGenre) == m_vsSongGenreAllowedList.end() )
return false; return false;
}
switch( m_Selectable ) switch( m_Selectable )
{ {
DEFAULT_FAIL(m_Selectable); DEFAULT_FAIL(m_Selectable);
@@ -35,13 +40,16 @@ bool SongCriteria::Matches( const Song *pSong ) const
case Selectable_DontCare: case Selectable_DontCare:
break; break;
} }
if( m_bUseSongAllowedList ) if( m_bUseSongAllowedList )
{ {
if( find(m_vpSongAllowedList.begin(),m_vpSongAllowedList.end(),pSong) == m_vpSongAllowedList.end() ) if( find(m_vpSongAllowedList.begin(),m_vpSongAllowedList.end(),pSong) == m_vpSongAllowedList.end() )
return false; return false;
} }
if( m_iStagesForSong != -1 && SONGMAN->GetNumStagesForSong(pSong) != m_iStagesForSong ) if( m_iStagesForSong != -1 && SONGMAN->GetNumStagesForSong(pSong) != m_iStagesForSong )
return false; return false;
switch( m_Tutorial ) switch( m_Tutorial )
{ {
DEFAULT_FAIL(m_Tutorial); DEFAULT_FAIL(m_Tutorial);
@@ -56,6 +64,7 @@ bool SongCriteria::Matches( const Song *pSong ) const
case Tutorial_DontCare: case Tutorial_DontCare:
break; break;
} }
switch( m_Locked ) switch( m_Locked )
{ {
DEFAULT_FAIL(m_Locked); DEFAULT_FAIL(m_Locked);
+3 -1
View File
@@ -15,7 +15,8 @@ class SongCriteria
{ {
public: public:
RString m_sGroupName; // "" means don't match RString m_sGroupName; // "" means don't match
RString m_sGenre; // "" means don't match bool m_bUseSongGenreAllowedList;
vector<RString> m_vsSongGenreAllowedList;
enum Selectable { Selectable_Yes, Selectable_No, Selectable_DontCare } m_Selectable; enum Selectable { Selectable_Yes, Selectable_No, Selectable_DontCare } m_Selectable;
bool m_bUseSongAllowedList; bool m_bUseSongAllowedList;
vector<Song*> m_vpSongAllowedList; vector<Song*> m_vpSongAllowedList;
@@ -25,6 +26,7 @@ public:
SongCriteria() SongCriteria()
{ {
m_bUseSongGenreAllowedList = false;
m_Selectable = Selectable_DontCare; m_Selectable = Selectable_DontCare;
m_bUseSongAllowedList = false; m_bUseSongAllowedList = false;
m_iStagesForSong = -1; m_iStagesForSong = -1;