ScreenOptions.h
Go to the documentation of this file.00001
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,
00037
INPUTMODE_SHARE_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
00086
int GetCurrentRow(PlayerNumber pn = PLAYER_1)
const;
00087
bool AllAreOnExit() const;
00088
00089 protected:
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
00096 struct Row
00097 {
00098
Row();
00099
~Row();
00100 OptionRowData
m_RowDef;
00101
enum {
ROW_NORMAL,
ROW_EXIT } Type;
00102 vector<BitmapText *>
m_textItems;
00103 vector<OptionsCursor *>
m_Underline[
NUM_PLAYERS];
00104 Sprite m_sprBullet;
00105 BitmapText m_textTitle;
00106 OptionIcon m_OptionIcons[
NUM_PLAYERS];
00107
00108 float m_fY;
00109 bool m_bRowIsLong;
00110 bool m_bHidden;
00111
00112 int m_iChoiceInRowWithFocus[
NUM_PLAYERS];
00113
00114
00115 vector<bool>
m_vbSelected[
NUM_PLAYERS];
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);
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
00164 AutoActor m_sprDisqualify[
NUM_PLAYERS];
00165
00166
00167
00168
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
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
Generated on Thu Jan 27 20:57:32 2005 for StepMania by
1.3.7