Files
itgmania212121/stepmania/src/ScreenOptions.h
T

186 lines
7.1 KiB
C++
Raw Normal View History

2004-06-08 05:22:33 +00:00
/* ScreenOptions - A grid of options; the selected option is drawn with a highlight rectangle. */
#ifndef SCREENOPTIONS_H
#define SCREENOPTIONS_H
2002-05-20 08:59:37 +00:00
#include "ScreenWithMenuElements.h"
2003-12-18 00:17:04 +00:00
#include "DualScrollBar.h"
2005-02-02 08:31:15 +00:00
#include "ThemeMetric.h"
2005-02-11 07:50:26 +00:00
#include "OptionRow.h"
2005-07-30 04:49:50 +00:00
#include "OptionsCursor.h"
#include "LuaExpressionTransform.h"
#include "InputEventPlus.h"
2005-10-30 21:39:49 +00:00
#include "RageSound.h"
2002-05-20 08:59:37 +00:00
class OptionRowHandler;
2002-05-20 08:59:37 +00:00
AutoScreenMessage( SM_ExportOptions )
enum InputMode
{
INPUTMODE_INDIVIDUAL, // each player controls their own cursor
2006-01-16 02:34:09 +00:00
INPUTMODE_SHARE_CURSOR, // both players control the same cursor
NUM_InputMode,
InputMode_Invalid
};
2006-01-22 01:00:06 +00:00
InputMode StringToInputMode( const RString& str );
2002-05-20 08:59:37 +00:00
#define FOREACH_OptionsPlayer( pn ) \
for( PlayerNumber pn=GetNextHumanPlayer((PlayerNumber)-1); pn!=PLAYER_INVALID && (m_InputMode==INPUTMODE_INDIVIDUAL || pn==0); pn=GetNextHumanPlayer(pn) )
2002-05-20 08:59:37 +00:00
class ScreenOptions : public ScreenWithMenuElements
2002-05-20 08:59:37 +00:00
{
public:
2006-01-15 19:49:02 +00:00
ScreenOptions();
virtual void Init();
virtual void BeginScreen();
2006-01-17 21:31:50 +00:00
void InitMenu( const vector<OptionRowHandler*> &vHands );
2002-05-20 08:59:37 +00:00
virtual ~ScreenOptions();
virtual void Update( float fDeltaTime );
virtual void Input( const InputEventPlus &input );
2002-05-20 08:59:37 +00:00
virtual void HandleScreenMessage( const ScreenMessage SM );
virtual void TweenOnScreen();
virtual void TweenOffScreen();
2006-02-03 02:32:26 +00:00
//
// Lua
//
virtual void PushSelf( lua_State *L );
friend class LunaScreenOptions;
protected:
2005-07-13 19:01:42 +00:00
virtual void ImportOptions( int iRow, const vector<PlayerNumber> &vpns ) = 0;
virtual void ExportOptions( int iRow, const vector<PlayerNumber> &vpns ) = 0;
2006-02-03 07:53:33 +00:00
void RestartOptions();
2006-01-16 20:30:19 +00:00
void GetWidthXY( PlayerNumber pn, int iRow, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const;
2006-01-22 01:00:06 +00:00
RString GetExplanationText( int iRow ) const;
2002-09-03 06:33:08 +00:00
void PositionIcons();
2006-01-16 04:39:02 +00:00
void RefreshIcons( int iRow, PlayerNumber pn );
2005-03-13 02:25:33 +00:00
void RefreshAllIcons();
void PositionCursors();
void PositionRows();
void TweenCursor( PlayerNumber pn );
void UpdateEnabledDisabled();
void UpdateEnabledDisabled( int iRow );
2006-01-16 04:36:17 +00:00
void StoreFocus( PlayerNumber pn );
2002-05-20 08:59:37 +00:00
void BeginFadingOut();
2006-01-22 01:00:06 +00:00
RString GetNextScreenForSelection( PlayerNumber pn ) const;
2002-05-20 08:59:37 +00:00
2005-07-30 19:34:23 +00:00
void ChangeValueInRowRelative( int iRow, PlayerNumber pn, int iDelta, bool bRepeat );
void ChangeValueInRowAbsolute( int iRow, PlayerNumber pn, int iChoiceIndex, bool bRepeat );
virtual void AfterChangeValueInRow( int iRow, PlayerNumber pn ); // override this to detect when the value in a row has changed
2006-02-03 04:40:49 +00:00
bool MoveRowRelative( PlayerNumber pn, int iDir, bool bRepeat );
2006-02-03 08:03:25 +00:00
bool MoveRowAbsolute( PlayerNumber pn, int iRow );
2005-07-29 22:52:36 +00:00
virtual void AfterChangeRow( PlayerNumber pn ); // override this to detect when the row has changed
virtual void AfterChangeValueOrRow( PlayerNumber pn );
2002-05-20 08:59:37 +00:00
2006-01-16 04:43:21 +00:00
virtual void MenuBack( PlayerNumber pn );
virtual void MenuStart( const InputEventPlus &input );
virtual void ProcessMenuStart( const InputEventPlus &input );
virtual void MenuLeft( const InputEventPlus &input ) { ChangeValueInRowRelative(m_iCurrentRow[input.MenuI.player],input.MenuI.player,-1, input.type != IET_FIRST_PRESS); }
virtual void MenuRight( const InputEventPlus &input ) { ChangeValueInRowRelative(m_iCurrentRow[input.MenuI.player], input.MenuI.player,+1, input.type != IET_FIRST_PRESS); }
virtual void MenuUp( const InputEventPlus &input );
virtual void MenuDown( const InputEventPlus &input );
virtual void MenuSelect( const InputEventPlus &input );
virtual void MenuUpDown( const InputEventPlus &input, int iDir ); // iDir == -1 or iDir == +1
2005-02-11 07:50:26 +00:00
/* Returns -1 if on a row with no OptionRowDefinition (eg. EXIT). */
2004-01-09 04:14:13 +00:00
int GetCurrentRow(PlayerNumber pn = PLAYER_1) const;
2005-02-26 21:35:27 +00:00
bool AllAreOnLastRow() const;
2003-05-30 21:36:56 +00:00
2003-11-01 19:36:52 +00:00
protected: // derived classes need access to these
enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_FIVE_KEY, NAV_TOGGLE_THREE_KEY, NAV_TOGGLE_FIVE_KEY };
void SetNavigation( Navigation nav ) { m_OptionsNavigation = nav; }
void SetInputMode( InputMode im ) { m_InputMode = im; }
2004-01-08 23:32:14 +00:00
/* Map menu lines to m_OptionRow entries. */
2005-06-23 08:05:09 +00:00
vector<OptionRow*> m_pRows;
2006-02-03 02:33:47 +00:00
int m_iCurrentRow[NUM_PLAYERS];
2006-01-16 04:46:36 +00:00
OptionRowType m_OptionRowType;
2004-01-09 04:14:13 +00:00
Navigation m_OptionsNavigation;
2006-01-16 04:38:16 +00:00
InputMode m_InputMode;
2004-01-09 04:43:27 +00:00
2006-01-16 04:36:17 +00:00
int m_iFocusX[NUM_PLAYERS];
2006-01-16 04:38:16 +00:00
bool m_bWasOnExit[NUM_PLAYERS];
float m_fLockInputSecs;
2006-01-16 04:38:16 +00:00
// 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];
2002-05-20 08:59:37 +00:00
2006-02-03 02:37:29 +00:00
// actors
ActorFrame m_framePage;
2003-12-19 22:10:06 +00:00
AutoActor m_sprPage;
2002-05-20 08:59:37 +00:00
2005-07-30 04:49:50 +00:00
OptionsCursorPlus m_Cursor[NUM_PLAYERS];
2005-10-29 23:47:03 +00:00
AutoActor m_sprLineHighlight[NUM_PLAYERS];
BitmapText m_textExplanation[NUM_PLAYERS];
2006-01-16 04:36:17 +00:00
DualScrollBar m_ScrollBar;
2004-01-10 03:36:14 +00:00
AutoActor m_sprMore;
2003-01-02 08:13:34 +00:00
RageSound m_SoundChangeCol;
RageSound m_SoundNextRow;
RageSound m_SoundPrevRow;
2004-01-10 21:34:18 +00:00
RageSound m_SoundToggleOn;
RageSound m_SoundToggleOff;
2005-02-02 08:31:15 +00:00
// metrics
2006-01-16 04:36:17 +00:00
ThemeMetric<int> NUM_ROWS_SHOWN;
ThemeMetric<apActorCommands> ROW_INIT_COMMAND;
ThemeMetric<apActorCommands> ROW_ON_COMMAND;
ThemeMetric<apActorCommands> ROW_OFF_COMMAND;
LuaExpressionTransform m_exprRowPositionTransformFunction; // params: self,positionIndex,itemIndex,numItems
2006-01-16 04:36:17 +00:00
ThemeMetric1D<float> EXPLANATION_X;
ThemeMetric1D<float> EXPLANATION_Y;
ThemeMetric1D<apActorCommands> EXPLANATION_ON_COMMAND;
2006-01-16 04:36:17 +00:00
ThemeMetric<float> EXPLANATION_TOGETHER_X;
ThemeMetric<float> EXPLANATION_TOGETHER_Y;
ThemeMetric<apActorCommands> EXPLANATION_TOGETHER_ON_COMMAND;
2006-01-16 04:36:17 +00:00
ThemeMetric<bool> SHOW_SCROLL_BAR;
ThemeMetric<float> SCROLL_BAR_HEIGHT;
ThemeMetric<float> SCROLL_BAR_TIME;
ThemeMetric<float> LINE_HIGHLIGHT_X;
ThemeMetric<bool> SHOW_EXIT_ROW;
ThemeMetric<bool> SEPARATE_EXIT_ROW;
ThemeMetric<float> SEPARATE_EXIT_ROW_Y;
ThemeMetric<bool> SHOW_EXPLANATIONS;
ThemeMetric<bool> ALLOW_REPEATING_CHANGE_VALUE_INPUT;
ThemeMetric<float> CURSOR_TWEEN_SECONDS;
ThemeMetric<bool> WRAP_VALUE_IN_ROW;
2002-05-20 08:59:37 +00:00
};
#endif
2004-06-08 05:22:33 +00:00
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* 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.
*/