generalize branching screens with ScreenBranch

Add ScreenRemoveMemoryCard
This commit is contained in:
Chris Danford
2003-12-24 20:29:26 +00:00
parent 90fcf5b7b3
commit e36b7e0120
11 changed files with 339 additions and 71 deletions
+11
View File
@@ -3624,6 +3624,17 @@ TimerSeconds=24
MaxRankingNameLength=4
StyleIcon=1
MemoryCardIcons=1
NextScreen=ScreenRemoveMemoryCard
[ScreenRemoveMemoryCard]
NextScreen=ScreenBranchEnding@ScreenBranch
[ScreenBranchEnding]
Choices=Credits,MusicScroll
ConditionCredits=topgrade,>=,AA
ConditionMusicScroll=
NextScreenCredits=ScreenCredits
NextScreenMusicScroll=ScreenMusicScroll
[EditMenu]
Arrows1X=190
+2 -2
View File
@@ -29,7 +29,7 @@ $(srcdir)/libresample/libresample.a:
Screens = \
Screen.cpp Screen.h ScreenAttract.cpp ScreenAttract.h ScreenBookkeeping.h ScreenBookkeeping.cpp \
ScreenCaution.cpp ScreenCaution.h ScreencenterImage.h ScreenCenterImage.cpp ScreenCredits.cpp ScreenCredits.h ScreenDemonstration.cpp ScreenDemonstration.h \
ScreenBranch.cpp ScreenBranch.h ScreenCaution.cpp ScreenCaution.h ScreencenterImage.h ScreenCenterImage.cpp ScreenCredits.cpp ScreenCredits.h ScreenDemonstration.cpp ScreenDemonstration.h \
ScreenDimensions.h ScreenEdit.cpp ScreenEdit.h ScreenEditCoursesMenu.cpp ScreenEditCoursesMenu.h \
ScreenEditMenu.cpp ScreenEditMenu.h ScreenEndlessBreak.cpp ScreenEndlessBreak.h ScreenEvaluation.cpp ScreenEvaluation.h \
ScreenExit.cpp ScreenExit.h ScreenEz2SelectMusic.cpp ScreenEz2SelectMusic.h ScreenEz2SelectPlayer.cpp ScreenEz2SelectPlayer.h \
@@ -42,7 +42,7 @@ ScreenMusicScroll.cpp ScreenMusicScroll.h ScreenNameEntry.cpp ScreenNameEntry.h
ScreenOptionsMaster.cpp ScreenOptionsMaster.h ScreenOptionsMasterPrefs.cpp ScreenOptionsMasterPrefs.h \
ScreenPlayerOptions.cpp ScreenPlayerOptions.h ScreenPrompt.cpp ScreenPrompt.h \
ScreenProfileOptions.cpp ScreenProfileOptions.h ScreenRanking.cpp ScreenRanking.h ScreenRaveOptions.cpp ScreenRaveOptions.h \
ScreenReloadSongs.cpp ScreenReloadSongs.h ScreenSandbox.cpp ScreenSandbox.h ScreenSelect.cpp ScreenSelect.h \
ScreenReloadSongs.cpp ScreenReloadSongs.h ScreenRemoveMemoryCard.cpp ScreenRemoveMemoryCard.h ScreenSandbox.cpp ScreenSandbox.h ScreenSelect.cpp ScreenSelect.h \
ScreenSelectCharacter.cpp ScreenSelectCharacter.h ScreenSelectCourse.cpp ScreenSelectCourse.h \
ScreenSelectDifficulty.cpp ScreenSelectDifficulty.h ScreenSelectDifficultyEX.cpp ScreenSelectDifficultyEX.h \
ScreenSelectGroup.cpp ScreenSelectGroup.h ScreenSelectMaster.cpp ScreenSelectMaster.h \
+4
View File
@@ -287,6 +287,8 @@ void Screen::ClearMessageQueue( const ScreenMessage SM )
#include "ScreenCenterImage.h"
#include "ScreenTestInput.h"
#include "ScreenBookkeeping.h"
#include "ScreenRemoveMemoryCard.h"
#include "ScreenBranch.h"
Screen* Screen::Create( CString sClassName )
{
@@ -390,6 +392,8 @@ Screen* Screen::Create( CString sClassName )
IF_RETURN( ScreenCenterImage );
IF_RETURN( ScreenTestInput );
IF_RETURN( ScreenBookkeeping );
IF_RETURN( ScreenRemoveMemoryCard );
IF_RETURN( ScreenBranch );
RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() );
}
+1 -1
View File
@@ -2,7 +2,7 @@
-----------------------------------------------------------------------------
Class: ScreenBookkeeping
Desc: Where the player maps device input to instrument buttons.
Desc: Show coin drop stats.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
+92
View File
@@ -0,0 +1,92 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ScreenBranch
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenBranch.h"
#include "RageLog.h"
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
#include "ScreenManager.h"
#include "ThemeManager.h"
#include "Grade.h"
#include "GameState.h"
#include "StageStats.h"
#define CHOICES THEME->GetMetric (m_sName,"Choices")
#define CONDITION(choice) THEME->GetMetric (m_sName,"Condition"+choice)
#define NEXT_SCREEN(choice) THEME->GetMetric (m_sName,"NextScreen"+choice)
bool EvaluateCondition( CString sCondition )
{
// For now, empty expresions evaluate to true. Is there a better way to handle this?
if( sCondition.empty() )
return true;
// TODO: Make this a general expression evaluator
CStringArray as;
split( sCondition, ",", as, false );
if( as.size()==3 && as[0].CompareNoCase("topgrade")==0 )
{
Grade top_grade = GRADE_E;
vector<Song*> vSongs;
StageStats stats;
GAMESTATE->GetFinalEvalStatsAndSongs( stats, vSongs );
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) )
top_grade = max( top_grade, stats.GetGrade((PlayerNumber)p) );
CString &sOp = as[1];
Grade grade = StringToGrade(as[2]);
if( sOp == ">=" )
return top_grade >= grade;
}
RageException::Throw( "Condition '%s' is invalid", sCondition.c_str() );
}
ScreenBranch::ScreenBranch( CString sClassName ) : Screen( sClassName )
{
LOG->Trace( "ScreenBranch::ScreenBranch()" );
CStringArray as;
split( CHOICES, ",", as, true );
for( unsigned i=0; i<as.size(); i++ )
{
CString sChoice = Capitalize( as[i] );
CString sCondition = CONDITION(sChoice);
if( EvaluateCondition(sCondition) )
{
m_sChoice = sChoice;
HandleScreenMessage( SM_GoToNextScreen );
return;
}
}
RageException::Throw( "On screen '%s' no conditions are true", sClassName.c_str() );
}
void ScreenBranch::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_GoToNextScreen:
{
CString sNextScreen = NEXT_SCREEN(m_sChoice);
LOG->Trace( "Branching to '%s'", sNextScreen.c_str() );
SCREENMAN->SetNewScreen( sNextScreen );
}
break;
}
}
+26
View File
@@ -0,0 +1,26 @@
/*
-----------------------------------------------------------------------------
Class: ScreenBranch
Desc: Load one of several screens.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
#include "MenuElements.h"
class ScreenBranch : public Screen
{
public:
ScreenBranch( CString sName );
virtual void HandleScreenMessage( const ScreenMessage SM );
private:
CString m_sChoice;
};
+9 -18
View File
@@ -48,6 +48,7 @@
#define FAKE_BEATS_PER_SEC THEME->GetMetricF("ScreenNameEntry","FakeBeatsPerSec")
#define TIMER_SECONDS THEME->GetMetricI("ScreenNameEntry","TimerSeconds")
#define MAX_RANKING_NAME_LENGTH THEME->GetMetricI(m_sName,"MaxRankingNameLength")
#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen")
// cache for frequently used metrics
@@ -395,25 +396,15 @@ void ScreenNameEntry::HandleScreenMessage( const ScreenMessage SM )
{
GAMESTATE->RestoreSelectedOptions();
/* Hack: go back to the select course screen in event mode. */
if( PREFSMAN->m_bEventMode && GAMESTATE->IsCourseMode() )
{
SCREENMAN->SetNewScreen( "ScreenSelectCourse" );
break;
}
// There shouldn't be NameEntry in event mode. -Chris
// /* Hack: go back to the select course screen in event mode. */
// if( PREFSMAN->m_bEventMode && GAMESTATE->IsCourseMode() )
// {
// SCREENMAN->SetNewScreen( "ScreenSelectCourse" );
// break;
// }
Grade max_grade = GRADE_E;
vector<Song*> vSongs;
StageStats stats;
GAMESTATE->GetFinalEvalStatsAndSongs( stats, vSongs );
for( int p=0; p<NUM_PLAYERS; p++ )
if( GAMESTATE->IsHumanPlayer(p) )
max_grade = max( max_grade, stats.GetGrade((PlayerNumber)p) );
if( max_grade >= GRADE_AA )
SCREENMAN->SetNewScreen( "ScreenCredits" );
else
SCREENMAN->SetNewScreen( "ScreenMusicScroll" );
SCREENMAN->SetNewScreen( NEXT_SCREEN );
}
break;
}
+101
View File
@@ -0,0 +1,101 @@
#include "global.h"
/*
-----------------------------------------------------------------------------
Class: ScreenRemoveMemoryCard
Desc: Where the player maps device input to pad input.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "ScreenRemoveMemoryCard.h"
#include "MemoryCardManager.h"
#include "RageLog.h"
#include "RageSounds.h"
#include "ThemeManager.h"
#include "GameConstantsAndTypes.h"
#include "PlayerNumber.h"
#include "ScreenManager.h"
#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen")
ScreenRemoveMemoryCard::ScreenRemoveMemoryCard( CString sClassName ) : Screen( sClassName )
{
if( !AnyCardsInserted() )
{
HandleScreenMessage( SM_GoToNextScreen ); // Don't show this screen
return;
}
LOG->Trace( "ScreenRemoveMemoryCard::ScreenRemoveMemoryCard()" );
m_Menu.Load( "ScreenRemoveMemoryCard" );
this->AddChild( &m_Menu );
SOUND->PlayMusic( THEME->GetPathToS("ScreenRemoveMemoryCard music") );
}
ScreenRemoveMemoryCard::~ScreenRemoveMemoryCard()
{
LOG->Trace( "ScreenRemoveMemoryCard::~ScreenRemoveMemoryCard()" );
}
void ScreenRemoveMemoryCard::DrawPrimitives()
{
m_Menu.DrawBottomLayer();
Screen::DrawPrimitives();
m_Menu.DrawTopLayer();
}
void ScreenRemoveMemoryCard::Update( float fDelta )
{
Screen::Update( fDelta );
if( !AnyCardsInserted() ) // all cards are pulled out
{
if( !m_Menu.IsTransitioning() )
m_Menu.StartTransitioning( SM_GoToPrevScreen );
}
}
void ScreenRemoveMemoryCard::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI )
{
if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT )
return; // ignore
Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default handler
}
void ScreenRemoveMemoryCard::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_GoToNextScreen:
SCREENMAN->SetNewScreen( NEXT_SCREEN );
break;
}
}
void ScreenRemoveMemoryCard::MenuStart( PlayerNumber pn )
{
MenuBack( pn );
}
void ScreenRemoveMemoryCard::MenuBack( PlayerNumber pn )
{
if(!m_Menu.IsTransitioning())
{
m_Menu.StartTransitioning( SM_GoToPrevScreen );
}
}
bool ScreenRemoveMemoryCard::AnyCardsInserted()
{
for( int p=0; p<NUM_PLAYERS; p++ )
if( MEMCARDMAN->GetCardState((PlayerNumber)p) != MEMORY_CARD_STATE_NO_CARD )
return true;
return false;
}
+35
View File
@@ -0,0 +1,35 @@
/*
-----------------------------------------------------------------------------
Class: ScreenRemoveMemoryCard
Desc: Remind the player to remove their memory card.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
#include "MenuElements.h"
class ScreenRemoveMemoryCard : public Screen
{
public:
ScreenRemoveMemoryCard( CString sName );
virtual ~ScreenRemoveMemoryCard();
virtual void DrawPrimitives();
virtual void Update( float fDelta );
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void MenuStart( PlayerNumber pn );
virtual void MenuBack( PlayerNumber pn );
private:
bool AnyCardsInserted();
MenuElements m_Menu;
};
+46 -50
View File
@@ -58,14 +58,14 @@ BSC32=bscmake.exe
LINK32=link.exe
# ADD BASE LINK32 $(intdir)\verstub.obj kernel32.lib shell32.lib user32.lib gdi32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /pdb:"../debug6/StepMania-debug.pdb" /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../StepMania-debug.exe"
# SUBTRACT BASE LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../../itg/Program/StepMania-debug.exe"
# ADD LINK32 $(intdir)\verstub.obj kernel32.lib gdi32.lib shell32.lib user32.lib advapi32.lib winmm.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libcmtd.lib" /out:"../Program/StepMania-debug.exe"
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
# Begin Special Build Tool
IntDir=.\../Debug6
TargetDir=\stepmania\itg\Program
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -102,8 +102,8 @@ IntDir=.\Debug
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp \
/Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -143,7 +143,7 @@ IntDir=.\../Release6
TargetDir=\stepmania\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -184,8 +184,8 @@ IntDir=.\StepMania___Xbox_Release
TargetDir=\stepmania\stepmania
TargetName=default
SOURCE="$(InputPath)"
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c \
verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi
# End Special Build Tool
@@ -1871,25 +1871,6 @@ SOURCE=.\MsdFile.cpp
SOURCE=.\MsdFile.h
# End Source File
# Begin Source File
SOURCE=.\XmlFile.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\XmlFile.h
# End Source File
# End Group
# Begin Group "StepMania"
@@ -2885,25 +2866,6 @@ SOURCE=.\BitmapText.h
# End Source File
# Begin Source File
SOURCE=.\mathlib.c
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\mathlib.h
# End Source File
# Begin Source File
SOURCE=.\Model.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
@@ -4448,6 +4410,25 @@ SOURCE=.\ScreenBookkeeping.h
# End Source File
# Begin Source File
SOURCE=.\ScreenBranch.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\ScreenBranch.h
# End Source File
# Begin Source File
SOURCE=.\ScreenCaution.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
@@ -4831,10 +4812,6 @@ SOURCE=.\ScreenMapControllers.h
# End Source File
# Begin Source File
SOURCE=.\ScreenMemoryCard.h
# End Source File
# Begin Source File
SOURCE=.\ScreenMessage.h
# End Source File
# Begin Source File
@@ -5086,6 +5063,25 @@ SOURCE=.\ScreenReloadSongs.h
# End Source File
# Begin Source File
SOURCE=.\ScreenRemoveMemoryCard.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
!ELSEIF "$(CFG)" == "StepMania - Xbox Debug"
!ELSEIF "$(CFG)" == "StepMania - Win32 Release"
!ELSEIF "$(CFG)" == "StepMania - Xbox Release"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\ScreenRemoveMemoryCard.h
# End Source File
# Begin Source File
SOURCE=.\ScreenSandbox.cpp
!IF "$(CFG)" == "StepMania - Win32 Debug"
+12
View File
@@ -181,6 +181,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ScreenBookkeeping.h">
</File>
<File
RelativePath="ScreenBranch.cpp">
</File>
<File
RelativePath="ScreenBranch.h">
</File>
<File
RelativePath="ScreenCaution.cpp">
</File>
@@ -382,6 +388,12 @@ cl /Zl /nologo /c verstub.cpp /Fo&quot;$(IntDir)&quot;\
<File
RelativePath="ScreenReloadSongs.h">
</File>
<File
RelativePath="ScreenRemoveMemoryCard.cpp">
</File>
<File
RelativePath="ScreenRemoveMemoryCard.h">
</File>
<File
RelativePath="ScreenSandbox.cpp">
</File>