Files
itgmania212121/stepmania/src/ScreenMiniMenu.h
T

144 lines
6.0 KiB
C++
Raw Normal View History

/* ScreenMiniMenu - Displays a simple menu over the top of another screen. */
2003-02-18 23:15:38 +00:00
2004-06-08 05:22:33 +00:00
#ifndef SCREEN_MINI_MENU_H
#define SCREEN_MINI_MENU_H
2003-02-18 23:15:38 +00:00
2005-03-20 06:41:56 +00:00
#include "ScreenOptions.h"
2005-10-30 21:39:49 +00:00
#include "GameConstantsAndTypes.h"
2003-02-18 23:15:38 +00:00
typedef bool (*MenuRowUpdateEnabled)();
2005-07-05 11:23:31 +00:00
struct MenuRowDef
{
2006-01-16 04:26:54 +00:00
int iRowCode;
2006-01-22 01:00:06 +00:00
RString sName;
bool bEnabled;
2006-01-16 04:26:54 +00:00
MenuRowUpdateEnabled pfnEnabled; // if ! NULL, used to fill bEnabled
EditMode emShowIn;
2006-01-16 04:26:54 +00:00
int iDefaultChoice;
2006-01-22 01:00:06 +00:00
vector<RString> choices;
2006-02-13 22:45:17 +00:00
bool bThemeTitle;
2005-12-01 09:43:21 +00:00
bool bThemeItems;
2005-07-05 11:23:31 +00:00
MenuRowDef() {}
2006-02-13 22:45:17 +00:00
MenuRowDef( int r, RString n, MenuRowUpdateEnabled pe, EditMode s, bool bTT, bool bTI, 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 = r;
sName = n;
bEnabled = true;
pfnEnabled = pe;
emShowIn = s;
2006-02-13 22:45:17 +00:00
bThemeTitle = bTT;
bThemeItems = bTI;
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
}
2006-02-13 22:45:17 +00:00
MenuRowDef( int r, RString n, bool e, EditMode s, bool bTT, bool bTI, 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 = r;
sName = n;
bEnabled = e;
pfnEnabled = NULL;
emShowIn = s;
2006-02-13 22:45:17 +00:00
bThemeTitle = bTT;
bThemeItems = bTI;
iDefaultChoice = d;
2005-03-20 06:41:56 +00:00
#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
}
2006-01-22 01:00:06 +00:00
void SetOneUnthemedChoice( const RString &sChoice )
2005-12-29 04:19:22 +00:00
{
choices.resize(1);
choices[0] = "|" + sChoice;
}
2006-01-22 01:00:06 +00:00
bool SetDefaultChoiceIfPresent( RString sChoice )
2005-03-20 06:41:56 +00:00
{
iDefaultChoice = 0;
2006-01-22 01:00:06 +00:00
FOREACH_CONST( RString, choices, s )
{
2005-03-20 06:41:56 +00:00
if( sChoice == *s )
{
2005-03-20 06:41:56 +00:00
iDefaultChoice = s - choices.begin();
return true;
}
}
return false;
2005-03-20 06:41:56 +00:00
}
};
2005-07-05 11:23:31 +00:00
struct MenuDef
2003-02-18 23:15:38 +00:00
{
2006-01-22 01:00:06 +00:00
RString sClassName;
2005-07-05 11:23:31 +00:00
vector<MenuRowDef> rows;
2006-01-22 01:00:06 +00:00
MenuDef( RString c, MenuRowDef r0=MenuRowDef(), MenuRowDef r1=MenuRowDef(), MenuRowDef r2=MenuRowDef(), MenuRowDef r3=MenuRowDef(), MenuRowDef r4=MenuRowDef(), MenuRowDef r5=MenuRowDef(), MenuRowDef r6=MenuRowDef(), MenuRowDef r7=MenuRowDef(), MenuRowDef r8=MenuRowDef(), MenuRowDef r9=MenuRowDef(), MenuRowDef r10=MenuRowDef(), MenuRowDef r11=MenuRowDef(), MenuRowDef r12=MenuRowDef(), MenuRowDef r13=MenuRowDef(), MenuRowDef r14=MenuRowDef(), MenuRowDef r15=MenuRowDef(), MenuRowDef r16=MenuRowDef(), MenuRowDef r17=MenuRowDef(), MenuRowDef r18=MenuRowDef(), MenuRowDef r19=MenuRowDef(), MenuRowDef r20=MenuRowDef(), MenuRowDef r21=MenuRowDef(), MenuRowDef r22=MenuRowDef(), MenuRowDef r23=MenuRowDef(), MenuRowDef r24=MenuRowDef(), MenuRowDef r25=MenuRowDef(), MenuRowDef r26=MenuRowDef(), MenuRowDef r27=MenuRowDef(), MenuRowDef r28=MenuRowDef(), MenuRowDef r29=MenuRowDef() )
2005-03-20 06:41:56 +00:00
{
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
}
2003-02-18 23:15:38 +00:00
};
2005-03-20 06:41:56 +00:00
class ScreenMiniMenu : public ScreenOptions
2003-02-18 23:15:38 +00:00
{
public:
2006-01-28 02:10:24 +00:00
static void MiniMenu( const MenuDef* pDef, ScreenMessage smSendOnOK, ScreenMessage smSendOnCancel = SM_None, float fX = 0, float fY = 0 );
2005-07-03 04:50:21 +00:00
void Init();
2006-01-17 23:43:20 +00:00
void BeginScreen();
void HandleScreenMessage( const ScreenMessage SM );
2005-07-03 04:50:21 +00:00
2005-03-20 06:41:56 +00:00
protected:
2005-07-29 22:52:36 +00:00
virtual void AfterChangeValueOrRow( PlayerNumber pn );
2005-07-13 19:01:42 +00:00
virtual void ImportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual void ExportOptions( int iRow, const vector<PlayerNumber> &vpns );
virtual bool FocusedItemEndsScreen( PlayerNumber pn ) const;
void LoadMenu( const MenuDef* pDef );
2005-03-20 06:41:56 +00:00
ScreenMessage m_SMSendOnOK;
ScreenMessage m_SMSendOnCancel;
2006-01-16 04:26:54 +00:00
vector<MenuRowDef> m_vMenuRows;
2003-02-18 23:15:38 +00:00
public:
2006-01-16 04:26:54 +00:00
static bool s_bCancelled;
static int s_iLastRowCode;
2005-03-20 06:41:56 +00:00
static vector<int> s_viLastAnswers;
2003-02-18 23:15:38 +00:00
};
2004-06-08 05:22:33 +00:00
#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.
*/