Files
itgmania212121/stepmania/src/ScreenOptions.h
T

192 lines
6.4 KiB
C++
Raw Normal View History

#ifndef SCREENOPTIONS_H
#define SCREENOPTIONS_H
2002-05-20 08:59:37 +00:00
/*
-----------------------------------------------------------------------------
File: ScreenOptions.h
Desc: A grid of options, and the selected option is drawn with a highlight rectangle.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "Screen.h"
#include "Sprite.h"
#include "BitmapText.h"
#include "RandomSample.h"
#include "Quad.h"
#include "MenuElements.h"
#include "OptionsCursor.h"
2002-09-03 06:33:08 +00:00
#include "OptionIcon.h"
2003-12-18 00:17:04 +00:00
#include "DualScrollBar.h"
2002-05-20 08:59:37 +00:00
struct OptionRowData
{
CString name;
bool bOneChoiceForAllPlayers;
2004-01-10 04:35:30 +00:00
bool bMultiSelect;
vector<CString> choices;
2002-05-20 08:59:37 +00:00
OptionRowData(): name(""), bOneChoiceForAllPlayers(false), bMultiSelect(false) { }
2003-09-27 08:00:10 +00:00
OptionRowData( const char *n, int 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 )
{
name = n;
bOneChoiceForAllPlayers = !!b;
bMultiSelect = false;
2003-09-19 01:45:45 +00:00
#define PUSH( c ) if(c) choices.push_back(c);
2003-08-16 18:40:05 +00:00
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);
2003-03-17 21:13:14 +00:00
#undef PUSH
}
2002-05-20 08:59:37 +00:00
};
enum InputMode
{
INPUTMODE_INDIVIDUAL, // each player controls their own cursor
INPUTMODE_TOGETHER // both players control the same cursor
};
2002-05-20 08:59:37 +00:00
class ScreenOptions : public Screen
{
public:
2003-09-27 04:58:30 +00:00
ScreenOptions( CString sClassName );
void Init( InputMode im, OptionRowData OptionRowData[], int iNumOptionLines );
2002-05-20 08:59:37 +00:00
virtual ~ScreenOptions();
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 );
protected:
virtual void ImportOptions() = 0;
virtual void ExportOptions() = 0;
void InitOptionsText();
2004-01-10 06:57:05 +00:00
void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut );
2003-11-08 02:46:12 +00:00
CString GetExplanationText( int row ) const;
CString GetExplanationTitle( int row ) const;
2004-01-10 06:57:05 +00:00
BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow );
2002-05-20 08:59:37 +00:00
void PositionUnderlines();
2002-09-03 06:33:08 +00:00
void PositionIcons();
virtual void RefreshIcons();
void PositionCursors();
2003-06-16 03:29:59 +00:00
void PositionItems();
void TweenCursor( PlayerNumber player_no );
void UpdateText( PlayerNumber player_no, int row );
void UpdateEnabledDisabled();
2003-11-06 09:54:40 +00:00
virtual void OnChange( PlayerNumber pn );
2002-05-20 08:59:37 +00:00
2003-02-12 00:41:56 +00:00
virtual void MenuBack( PlayerNumber pn );
virtual void MenuStart( PlayerNumber pn, const InputEventType type );
2003-02-12 00:41:56 +00:00
void StartGoToNextState();
2002-05-20 08:59:37 +00:00
virtual void GoToNextState() = 0;
virtual void GoToPrevState() = 0;
void MenuLeft( PlayerNumber pn, const InputEventType type ) { ChangeValueInRow(pn,-1,type != IET_FIRST_PRESS); }
void MenuRight( PlayerNumber pn, const InputEventType type ) { ChangeValueInRow(pn,+1,type != IET_FIRST_PRESS); }
void ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat );
void MenuUp( PlayerNumber pn, const InputEventType type ) { MoveRow( pn, -1, type != IET_FIRST_PRESS ); }
void MenuDown( PlayerNumber pn, const InputEventType type ) { MoveRow( pn, +1, type != IET_FIRST_PRESS ); }
void MoveRow( PlayerNumber pn, int dir, bool Repeat );
2002-05-20 08:59:37 +00:00
/* Returns -1 if on a row with no OptionRowData (eg. EXIT). */
2004-01-09 04:14:13 +00:00
int GetCurrentRow(PlayerNumber pn = PLAYER_1) const;
2003-05-30 21:36:56 +00:00
MenuElements m_Menu;
2003-11-01 19:36:52 +00:00
protected: // derived classes need access to these
2004-01-09 04:14:13 +00:00
void LoadOptionIcon( PlayerNumber pn, int iRow, CString sText );
2004-01-14 04:59:07 +00:00
enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY, NAV_FIRST_CHOICE_GOES_DOWN };
void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; }
2004-01-08 23:32:14 +00:00
2004-01-10 04:35:30 +00:00
protected:
/* Map menu lines to m_OptionRow entries. */
2004-01-09 04:14:13 +00:00
struct Row
{
Row();
~Row();
OptionRowData m_RowDef;
2004-01-09 10:47:33 +00:00
enum { ROW_NORMAL, ROW_EXIT } Type;
vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined
vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined
2004-01-09 04:14:13 +00:00
Sprite m_sprBullet;
BitmapText m_textTitle;
OptionIcon m_OptionIcons[NUM_PLAYERS];
float m_fY;
bool m_bRowIsLong; // goes off edge of screen
bool m_bHidden; // currently off screen
2004-01-10 08:57:08 +00:00
int m_iChoiceWithFocus[NUM_PLAYERS]; // this choice has input focus
// Only one will true at a time if m_RowDef.bMultiSelect
vector<bool> m_vbSelected[NUM_PLAYERS]; // size = m_RowDef.choices.size().
2004-01-13 07:06:46 +00:00
int GetOneSelection( PlayerNumber pn ) const
{
2004-01-11 05:47:23 +00:00
for( unsigned i=0; i<(unsigned)m_vbSelected[pn].size(); i++ )
if( m_vbSelected[pn][i] )
return i;
2004-01-10 08:57:08 +00:00
ASSERT(0); // shouldn't call this if not expecting one to be selected
return -1;
}
2004-01-13 07:06:46 +00:00
int GetOneSharedSelection() const
{
return GetOneSelection( (PlayerNumber)0 );
}
void SetOneSelection( PlayerNumber pn, int iChoice )
{
2004-01-11 05:47:23 +00:00
for( unsigned i=0; i<(unsigned)m_vbSelected[pn].size(); i++ )
m_vbSelected[pn][i] = false;
m_vbSelected[pn][iChoice] = true;
}
void SetOneSharedSelection( int iChoice )
{
SetOneSelection( (PlayerNumber)0, iChoice );
}
2004-01-09 04:14:13 +00:00
};
vector<Row*> m_Rows;
Navigation m_OptionsNavigation;
2004-01-09 04:43:27 +00:00
2004-01-09 04:14:13 +00:00
int m_iCurrentRow[NUM_PLAYERS];
InputMode m_InputMode;
2002-05-20 08:59:37 +00:00
ActorFrame m_framePage;
2003-12-19 22:10:06 +00:00
AutoActor m_sprPage;
AutoActor m_sprFrame;
2002-05-20 08:59:37 +00:00
OptionsCursor m_Highlight[NUM_PLAYERS];
2003-12-19 22:10:06 +00:00
Sprite m_sprLineHighlight[NUM_PLAYERS];
2003-12-18 22:51:43 +00:00
BitmapText m_textPlayerName[NUM_PLAYERS];
BitmapText m_textExplanation[NUM_PLAYERS];
2003-12-18 00:17:04 +00:00
DualScrollBar m_ScrollBar;
2004-01-10 03:36:14 +00:00
AutoActor m_sprMore;
bool m_bMoreShown, m_bWasOnExit[NUM_PLAYERS];
// show if the current selections will disqualify a high score
AutoActor m_sprDisqualify[NUM_PLAYERS];
// TRICKY: People hold Start to get to PlayerOptions, then
// the repeat events cause them to zip to the bottom. So, ignore
// Start repeat events until we've seen one first pressed event.
bool m_bGotAtLeastOneStartPressed[NUM_PLAYERS];
2004-01-10 03:36:14 +00:00
2003-01-02 08:13:34 +00:00
RageSound m_SoundChangeCol;
RageSound m_SoundNextRow;
RageSound m_SoundPrevRow;
RageSound m_SoundStart;
2004-01-10 21:34:18 +00:00
RageSound m_SoundToggleOn;
RageSound m_SoundToggleOff;
2002-05-20 08:59:37 +00:00
};
#endif