Implement ScreenMiniMenu with ScreenOptions

This commit is contained in:
Chris Danford
2005-03-20 06:41:56 +00:00
parent 48e6cb1a69
commit bbadc010f4
16 changed files with 534 additions and 745 deletions
+41 -67
View File
@@ -3,105 +3,79 @@
#ifndef SCREEN_MINI_MENU_H
#define SCREEN_MINI_MENU_H
#include "Screen.h"
#include "ScreenOptions.h"
#include "BitmapText.h"
#include "Transition.h"
#include "Quad.h"
#include "RageSound.h"
#include "BGAnimation.h"
#define MAX_MENU_ROWS 40
struct MenuRow
{
int iRowCode;
const char *name;
bool enabled;
CString sName;
bool bEnabled;
bool bShowInHomeEditMode;
int defaultChoice;
const char *choices[32];
};
struct MenuRowInternal
{
int iRowCode;
CString name;
bool enabled;
bool bShowInHomeEditMode;
int defaultChoice;
int iDefaultChoice;
vector<CString> choices;
MenuRowInternal()
MenuRow() {}
MenuRow( int r, CString n, bool e, bool s, int d, 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 )
{
iRowCode = -1;
enabled = true;
bShowInHomeEditMode = true;
defaultChoice = 0;
iRowCode = r; sName = n; bEnabled = e; bShowInHomeEditMode = s; iDefaultChoice = d;
#define PUSH( c ) if(c) choices.push_back(c);
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
}
MenuRowInternal( const MenuRow &r );
void SetDefaultChoiceIfPresent( const CString &s );
void SetDefaultChoiceIfPresent( CString sChoice )
{
iDefaultChoice = 0;
FOREACH_CONST( CString, choices, s )
if( sChoice == *s )
iDefaultChoice = s - choices.begin();
}
};
struct Menu
{
CString title;
vector<MenuRowInternal> rows;
CString sClassName;
vector<MenuRow> rows;
Menu() {}
Menu( CString t, const MenuRow *rows );
Menu( CString c, MenuRow r0=MenuRow(), MenuRow r1=MenuRow(), MenuRow r2=MenuRow(), MenuRow r3=MenuRow(), MenuRow r4=MenuRow(), MenuRow r5=MenuRow(), MenuRow r6=MenuRow(), MenuRow r7=MenuRow(), MenuRow r8=MenuRow(), MenuRow r9=MenuRow(), MenuRow r10=MenuRow(), MenuRow r11=MenuRow(), MenuRow r12=MenuRow(), MenuRow r13=MenuRow(), MenuRow r14=MenuRow(), MenuRow r15=MenuRow(), MenuRow r16=MenuRow(), MenuRow r17=MenuRow(), MenuRow r18=MenuRow(), MenuRow r19=MenuRow(), MenuRow r20=MenuRow(), MenuRow r21=MenuRow(), MenuRow r22=MenuRow(), MenuRow r23=MenuRow(), MenuRow r24=MenuRow(), MenuRow r25=MenuRow(), MenuRow r26=MenuRow(), MenuRow r27=MenuRow(), MenuRow r28=MenuRow(), MenuRow r29=MenuRow() )
{
sClassName = c;
#define PUSH( r ) if(!r.sName.empty()) rows.push_back(r);
PUSH(r0);PUSH(r1);PUSH(r2);PUSH(r3);PUSH(r4);PUSH(r5);PUSH(r6);PUSH(r7);PUSH(r8);PUSH(r9);PUSH(r10);PUSH(r11);PUSH(r12);PUSH(r13);PUSH(r14);PUSH(r15);PUSH(r16);PUSH(r17);PUSH(r18);PUSH(r19);PUSH(r20);PUSH(r21);PUSH(r22);PUSH(r23);PUSH(r24);PUSH(r25);PUSH(r26);PUSH(r27);PUSH(r28);PUSH(r29);
#undef PUSH
}
};
class ScreenMiniMenu : public Screen
class ScreenMiniMenu : public ScreenOptions
{
public:
ScreenMiniMenu( CString sName );
ScreenMiniMenu( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel );
virtual void Update( float fDeltaTime );
virtual void DrawPrimitives();
virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI );
virtual void HandleScreenMessage( const ScreenMessage SM );
ScreenMiniMenu( CString sScreenClass );
void Init( const Menu* pDef, ScreenMessage SM_SendOnOK, ScreenMessage SM_SendOnCancel );
protected:
void MenuUp( PlayerNumber pn, const InputEventType type );
void MenuDown( PlayerNumber pn, const InputEventType type );
void MenuLeft( PlayerNumber pn, const InputEventType type );
void MenuRight( PlayerNumber pn, const InputEventType type );
void MenuBack( PlayerNumber pn );
void MenuStart( PlayerNumber pn, const InputEventType type );
virtual void ImportOptions( int row, PlayerNumber pn );
virtual void ExportOptions( int row, PlayerNumber pn );
virtual void GoToNextScreen();
virtual void GoToPrevScreen();
int GetGoUpSpot(); // return -1 if can't go up
int GetGoDownSpot(); // return -1 if can't go down
bool CanGoLeft();
bool CanGoRight();
// Screens that get pushed on top of other screens don't
// use the ScreenManager's shared background, so they must draw their own.
AutoActor m_Background;
ScreenMessage m_SMSendOnOK;
ScreenMessage m_SMSendOnCancel;
void BeforeLineChanged();
void AfterLineChanged();
void AfterAnswerChanged();
BGAnimation m_Background;
Menu m_Def;
BitmapText m_textTitle;
BitmapText m_textLabel[MAX_MENU_ROWS];
BitmapText m_textAnswer[MAX_MENU_ROWS];
int m_iCurLine;
int m_iCurAnswers[MAX_MENU_ROWS];
ScreenMessage m_SMSendOnOK, m_SMSendOnCancel;
RageSound m_sndChangeRow;
RageSound m_sndChangeValue;
Transition m_In;
Transition m_Out;
vector<MenuRow> m_vMenuRows;
public:
static int s_iLastRowCode;
static int s_iLastAnswers[MAX_MENU_ROWS];
static vector<int> s_viLastAnswers;
};