Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ScreenOptions.h

Go to the documentation of this file.
00001 /* ScreenOptions - A grid of options; the selected option is drawn with a highlight rectangle. */ 00002 00003 #ifndef SCREENOPTIONS_H 00004 #define SCREENOPTIONS_H 00005 00006 #include "ScreenWithMenuElements.h" 00007 #include "Sprite.h" 00008 #include "BitmapText.h" 00009 #include "RandomSample.h" 00010 #include "Quad.h" 00011 #include "OptionsCursor.h" 00012 #include "OptionIcon.h" 00013 #include "DualScrollBar.h" 00014 00015 00016 struct OptionRowData 00017 { 00018 CString name; 00019 bool bOneChoiceForAllPlayers; 00020 enum Type { SELECT_ONE, SELECT_MULTIPLE, SELECT_NONE } type; 00021 vector<CString> choices; 00022 00023 OptionRowData(): name(""), bOneChoiceForAllPlayers(false), type(SELECT_ONE) { } 00024 00025 OptionRowData( const char *n, bool 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 ) : 00026 name(n), bOneChoiceForAllPlayers(b), type(SELECT_ONE) 00027 { 00028 #define PUSH( c ) if(c) choices.push_back(c); 00029 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); 00030 #undef PUSH 00031 } 00032 }; 00033 00034 enum InputMode 00035 { 00036 INPUTMODE_INDIVIDUAL, // each player controls their own cursor 00037 INPUTMODE_SHARE_CURSOR // both players control the same cursor 00038 }; 00039 00040 00041 class ScreenOptions : public ScreenWithMenuElements 00042 { 00043 public: 00044 ScreenOptions( CString sClassName ); 00045 void InitMenu( InputMode im, OptionRowData OptionRowData[], int iNumOptionLines ); 00046 virtual ~ScreenOptions(); 00047 virtual void Update( float fDeltaTime ); 00048 virtual void DrawPrimitives(); 00049 virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); 00050 virtual void HandleScreenMessage( const ScreenMessage SM ); 00051 00052 protected: 00053 virtual void ImportOptions() = 0; 00054 virtual void ExportOptions() = 0; 00055 void InitOptionsText(); 00056 void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ); 00057 CString GetExplanationText( int row ) const; 00058 CString GetExplanationTitle( int row ) const; 00059 BitmapText &GetTextItemForRow( PlayerNumber pn, int iRow, int iChoiceOnRow ); 00060 void PositionUnderlines(); 00061 void PositionIcons(); 00062 virtual void RefreshIcons(); 00063 void PositionCursors(); 00064 void PositionItems(); 00065 void TweenCursor( PlayerNumber pn ); 00066 void UpdateText( int row ); 00067 void UpdateEnabledDisabled(); 00068 virtual void OnChange( PlayerNumber pn ); 00069 00070 virtual void MenuBack( PlayerNumber pn ); 00071 virtual void MenuStart( PlayerNumber pn, const InputEventType type ); 00072 00073 void StartGoToNextScreen(); 00074 00075 virtual void GoToNextScreen() = 0; 00076 virtual void GoToPrevScreen() = 0; 00077 00078 void MenuLeft( PlayerNumber pn, const InputEventType type ) { ChangeValueInRow(pn,-1,type != IET_FIRST_PRESS); } 00079 void MenuRight( PlayerNumber pn, const InputEventType type ) { ChangeValueInRow(pn,+1,type != IET_FIRST_PRESS); } 00080 void ChangeValueInRow( PlayerNumber pn, int iDelta, bool Repeat ); 00081 void MenuUp( PlayerNumber pn, const InputEventType type ) { MoveRow( pn, -1, type != IET_FIRST_PRESS ); } 00082 void MenuDown( PlayerNumber pn, const InputEventType type ) { MoveRow( pn, +1, type != IET_FIRST_PRESS ); } 00083 void MoveRow( PlayerNumber pn, int dir, bool Repeat ); 00084 00085 /* Returns -1 if on a row with no OptionRowData (eg. EXIT). */ 00086 int GetCurrentRow(PlayerNumber pn = PLAYER_1) const; 00087 bool AllAreOnExit() const; 00088 00089 protected: // derived classes need access to these 00090 void LoadOptionIcon( PlayerNumber pn, int iRow, CString sText ); 00091 enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY, NAV_TOGGLE_THREE_KEY, NAV_TOGGLE_FIVE_KEY }; 00092 void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; } 00093 00094 protected: 00095 /* Map menu lines to m_OptionRow entries. */ 00096 struct Row 00097 { 00098 Row(); 00099 ~Row(); 00100 OptionRowData m_RowDef; 00101 enum { ROW_NORMAL, ROW_EXIT } Type; 00102 vector<BitmapText *> m_textItems; // size depends on m_bRowIsLong and which players are joined 00103 vector<OptionsCursor *> m_Underline[NUM_PLAYERS]; // size depends on m_bRowIsLong and which players are joined 00104 Sprite m_sprBullet; 00105 BitmapText m_textTitle; 00106 OptionIcon m_OptionIcons[NUM_PLAYERS]; 00107 00108 float m_fY; 00109 bool m_bRowIsLong; // goes off edge of screen 00110 bool m_bHidden; // currently off screen 00111 00112 int m_iChoiceInRowWithFocus[NUM_PLAYERS]; // this choice has input focus 00113 00114 // Only one will true at a time if m_RowDef.bMultiSelect 00115 vector<bool> m_vbSelected[NUM_PLAYERS]; // size = m_RowDef.choices.size(). 00116 int GetOneSelection( PlayerNumber pn ) const 00117 { 00118 for( unsigned i=0; i<(unsigned)m_vbSelected[pn].size(); i++ ) 00119 if( m_vbSelected[pn][i] ) 00120 return i; 00121 ASSERT(0); // shouldn't call this if not expecting one to be selected 00122 return -1; 00123 } 00124 int GetOneSharedSelection() const 00125 { 00126 return GetOneSelection( (PlayerNumber)0 ); 00127 } 00128 void SetOneSelection( PlayerNumber pn, int iChoice ) 00129 { 00130 for( unsigned i=0; i<(unsigned)m_vbSelected[pn].size(); i++ ) 00131 m_vbSelected[pn][i] = false; 00132 m_vbSelected[pn][iChoice] = true; 00133 } 00134 void SetOneSharedSelection( int iChoice ) 00135 { 00136 FOREACH_HumanPlayer( pn ) 00137 SetOneSelection( pn, iChoice ); 00138 } 00139 }; 00140 vector<Row*> m_Rows; 00141 00142 Navigation m_OptionsNavigation; 00143 00144 int m_iCurrentRow[NUM_PLAYERS]; 00145 int m_iFocusX[NUM_PLAYERS]; 00146 void StoreFocus( PlayerNumber pn ); 00147 00148 InputMode m_InputMode; 00149 00150 ActorFrame m_framePage; 00151 AutoActor m_sprPage; 00152 00153 OptionsCursor m_Highlight[NUM_PLAYERS]; 00154 Sprite m_sprLineHighlight[NUM_PLAYERS]; 00155 00156 BitmapText m_textPlayerName[NUM_PLAYERS]; 00157 BitmapText m_textExplanation[NUM_PLAYERS]; 00158 DualScrollBar m_ScrollBar; 00159 00160 AutoActor m_sprMore; 00161 bool m_bMoreShown, m_bWasOnExit[NUM_PLAYERS]; 00162 00163 // show if the current selections will disqualify a high score 00164 AutoActor m_sprDisqualify[NUM_PLAYERS]; 00165 00166 // TRICKY: People hold Start to get to PlayerOptions, then 00167 // the repeat events cause them to zip to the bottom. So, ignore 00168 // Start repeat events until we've seen one first pressed event. 00169 bool m_bGotAtLeastOneStartPressed[NUM_PLAYERS]; 00170 00171 RageSound m_SoundChangeCol; 00172 RageSound m_SoundNextRow; 00173 RageSound m_SoundPrevRow; 00174 RageSound m_SoundToggleOn; 00175 RageSound m_SoundToggleOff; 00176 }; 00177 00178 #endif 00179 00180 /* 00181 * (c) 2001-2004 Chris Danford, Glenn Maynard 00182 * All rights reserved. 00183 * 00184 * Permission is hereby granted, free of charge, to any person obtaining a 00185 * copy of this software and associated documentation files (the 00186 * "Software"), to deal in the Software without restriction, including 00187 * without limitation the rights to use, copy, modify, merge, publish, 00188 * distribute, and/or sell copies of the Software, and to permit persons to 00189 * whom the Software is furnished to do so, provided that the above 00190 * copyright notice(s) and this permission notice appear in all copies of 00191 * the Software and that both the above copyright notice(s) and this 00192 * permission notice appear in supporting documentation. 00193 * 00194 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00195 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00196 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00197 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00198 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00199 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00200 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00201 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00202 * PERFORMANCE OF THIS SOFTWARE. 00203 */

Generated on Thu Jan 27 20:57:32 2005 for StepMania by doxygen 1.3.7