Files
itgmania212121/stepmania/src/OptionRow.h
T

183 lines
6.0 KiB
C++
Raw Normal View History

2005-02-11 07:50:26 +00:00
/* OptionRow - One line in ScreenOptions. */
#ifndef OptionRow_H
#define OptionRow_H
#include "ActorFrame.h"
#include "BitmapText.h"
#include "OptionsCursor.h"
#include "OptionIcon.h"
#include "ThemeMetric.h"
2005-07-16 07:01:48 +00:00
#include "AutoActor.h"
2005-02-11 07:50:26 +00:00
class OptionRowHandler;
2005-07-16 07:01:48 +00:00
class GameCommand;
struct OptionRowDefinition;
2005-02-11 07:50:26 +00:00
class OptionRowType
{
public:
2006-10-14 04:55:36 +00:00
void Load( const RString &sType, Actor *pParent );
2005-07-16 03:23:53 +00:00
private:
2006-01-22 01:00:06 +00:00
RString m_sType;
2005-07-16 07:01:48 +00:00
2006-01-16 04:02:19 +00:00
BitmapText m_textItemParent;
OptionsCursor m_UnderlineParent;
2006-09-20 22:09:44 +00:00
AutoActor m_sprBullet;
2006-01-16 04:02:19 +00:00
BitmapText m_textTitle;
OptionIcon m_OptionIcon;
2005-07-16 03:23:53 +00:00
// metrics
2006-01-16 04:02:19 +00:00
ThemeMetric<float> BULLET_X;
2005-08-30 07:58:53 +00:00
ThemeMetric<apActorCommands> BULLET_ON_COMMAND;
2006-01-16 04:02:19 +00:00
ThemeMetric<float> TITLE_X;
2005-12-06 04:21:00 +00:00
ThemeMetric<apActorCommands> TITLE_ON_COMMAND;
ThemeMetric<apActorCommands> TITLE_GAIN_FOCUS_COMMAND;
ThemeMetric<apActorCommands> TITLE_LOSE_FOCUS_COMMAND;
2006-01-16 04:02:19 +00:00
ThemeMetric<float> ITEMS_START_X;
ThemeMetric<float> ITEMS_END_X;
ThemeMetric<float> ITEMS_GAP_X;
2006-03-06 04:29:33 +00:00
ThemeMetric<float> ITEMS_MIN_BASE_ZOOM;
2006-01-16 04:02:19 +00:00
ThemeMetric1D<float> ITEMS_LONG_ROW_X;
ThemeMetric<float> ITEMS_LONG_ROW_SHARED_X;
2005-07-16 03:23:53 +00:00
ThemeMetric<apActorCommands> ITEMS_ON_COMMAND;
ThemeMetric<apActorCommands> ITEM_GAIN_FOCUS_COMMAND;
ThemeMetric<apActorCommands> ITEM_LOSE_FOCUS_COMMAND;
2006-01-16 04:02:19 +00:00
ThemeMetric1D<float> ICONS_X;
2005-07-16 03:23:53 +00:00
ThemeMetric<apActorCommands> ICONS_ON_COMMAND;
2006-01-16 04:02:19 +00:00
ThemeMetric<RageColor> COLOR_SELECTED;
ThemeMetric<RageColor> COLOR_NOT_SELECTED;
ThemeMetric<RageColor> COLOR_DISABLED;
ThemeMetric<bool> CAPITALIZE_ALL_OPTION_NAMES;
ThemeMetric<float> TWEEN_SECONDS;
ThemeMetric<bool> SHOW_BPM_IN_SPEED_TITLE;
ThemeMetric<bool> SHOW_OPTION_ICONS;
ThemeMetric<bool> SHOW_UNDERLINES;
2005-07-16 03:23:53 +00:00
friend class OptionRow;
};
2005-02-11 07:50:26 +00:00
class OptionRow : public ActorFrame
{
public:
OptionRow( const OptionRowType *pType );
2005-02-11 07:50:26 +00:00
~OptionRow();
void Update( float fDeltaTime );
2005-02-14 01:29:25 +00:00
void Clear();
2006-01-17 21:40:39 +00:00
void LoadNormal( OptionRowHandler *pHand, bool bFirstItemGoesDown );
void LoadExit();
2005-07-16 07:01:48 +00:00
2006-01-22 01:00:06 +00:00
void SetOptionIcon( PlayerNumber pn, const RString &sText, GameCommand &gc );
2005-04-03 06:21:02 +00:00
void ImportOptions( const vector<PlayerNumber> &vpns );
int ExportOptions( const vector<PlayerNumber> &vpns, bool bRowHasFocus[NUM_PLAYERS] );
2005-02-25 05:45:16 +00:00
void InitText();
void AfterImportOptions( PlayerNumber pn );
2006-01-18 04:56:39 +00:00
void ChoicesChanged();
2005-03-13 02:15:38 +00:00
void PositionUnderlines( PlayerNumber pn );
2006-02-03 09:31:51 +00:00
void PositionIcons( PlayerNumber pn );
2006-01-19 01:01:13 +00:00
void UpdateText( PlayerNumber pn );
2006-01-15 23:33:29 +00:00
void SetRowHasFocus( PlayerNumber pn, bool bRowHasFocus );
void UpdateEnabledDisabled();
int GetOneSelection( PlayerNumber pn, bool bAllowFail=false ) const;
2005-03-20 06:41:56 +00:00
int GetOneSharedSelection( bool bAllowFail=false ) const;
void SetOneSelection( PlayerNumber pn, int iChoice );
void SetOneSharedSelection( int iChoice );
2006-01-22 01:00:06 +00:00
void SetOneSharedSelectionIfPresent( const RString &sChoice );
2005-06-28 08:11:30 +00:00
int GetChoiceInRowWithFocus( PlayerNumber pn ) const;
int GetChoiceInRowWithFocusShared() const;
void SetChoiceInRowWithFocus( PlayerNumber pn, int iChoice );
2006-01-19 00:29:22 +00:00
void ResetFocusFromSelection( PlayerNumber pn );
2005-06-28 08:11:30 +00:00
2006-01-17 22:16:58 +00:00
bool GetSelected( PlayerNumber pn, int iChoice ) const;
void SetSelected( PlayerNumber pn, int iChoice, bool b );
enum RowType
{
2005-12-06 12:41:33 +00:00
RowType_Normal,
RowType_Exit
};
2006-01-17 22:16:58 +00:00
const OptionRowDefinition &GetRowDef() const;
OptionRowDefinition &GetRowDef();
RowType GetRowType() const { return m_RowType; }
2006-01-16 19:58:22 +00:00
const OptionRowHandler *GetHandler() const { return m_pHand; }
2006-01-15 07:12:05 +00:00
const BitmapText &GetTextItemForRow( PlayerNumber pn, int iChoiceOnRow ) const;
void GetWidthXY( PlayerNumber pn, int iChoiceOnRow, int &iWidthOut, int &iXOut, int &iYOut ) const;
// ScreenOptions calls positions m_FrameDestination, then m_Frame tween to that same TweenState.
2006-01-15 07:10:05 +00:00
unsigned GetTextItemsSize() const { return m_textItems.size(); }
bool GetFirstItemGoesDown() const { return m_bFirstItemGoesDown; }
2006-09-01 04:44:30 +00:00
RString GetThemedItemText( int iChoice ) const;
2005-03-21 00:19:34 +00:00
2006-01-22 01:00:06 +00:00
void SetExitText( RString sExitText );
void Reload();
//
// Messages
//
2006-11-13 23:11:25 +00:00
virtual void HandleMessage( const Message &msg );
protected:
2006-01-22 01:00:06 +00:00
RString GetRowTitle() const;
2005-07-15 23:31:58 +00:00
2005-07-16 03:23:53 +00:00
const OptionRowType *m_pParentType;
2006-01-16 04:02:19 +00:00
RowType m_RowType;
OptionRowHandler* m_pHand;
2006-01-16 04:02:19 +00:00
ActorFrame m_Frame;
2006-01-16 04:02:19 +00:00
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
2005-07-16 07:01:48 +00:00
2006-01-16 04:02:19 +00:00
Actor *m_sprBullet;
BitmapText *m_textTitle;
OptionIcon *m_OptionIcons[NUM_PLAYERS];
2006-01-16 04:02:19 +00:00
bool m_bFirstItemGoesDown;
bool m_bRowHasFocus[NUM_PLAYERS];
2005-02-11 07:50:26 +00:00
2006-01-16 04:02:19 +00:00
int m_iChoiceInRowWithFocus[NUM_PLAYERS]; // this choice has input focus
2006-01-17 22:16:58 +00:00
// Only one will true at a time if m_pHand->m_Def.bMultiSelect
vector<bool> m_vbSelected[NUM_PLAYERS]; // size = m_pHand->m_Def.choices.size()
Actor::TweenState m_tsDestination; // this should approach m_tsDestination.
2005-02-26 11:19:19 +00:00
public:
void SetDestination( Actor::TweenState &ts, bool bTween );
2005-02-11 07:50:26 +00:00
};
#endif
/*
* (c) 2001-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.
*/