Etterna 0.74.4
Loading...
Searching...
No Matches
OptionRow.h
1/* OptionRow - One line in ScreenOptions. */
2
3#ifndef OptionRow_H
4#define OptionRow_H
5
6#include "Etterna/Actor/Base/ActorFrame.h"
7#include "Etterna/Actor/Base/AutoActor.h"
8#include "Etterna/Actor/Base/BitmapText.h"
9#include "ModIcon.h"
10#include "OptionsCursor.h"
11#include "Etterna/Models/Misc/ThemeMetric.h"
12
14class GameCommand;
16
17std::string
18ITEMS_LONG_ROW_X_NAME(size_t p);
19std::string
20MOD_ICON_X_NAME(size_t p);
21
23{
24 public:
25 void Load(const std::string& sMetricsGroup, Actor* pParent);
26
27 private:
28 std::string m_sMetricsGroup;
29
30 BitmapText m_textItem;
31 OptionsCursor m_Underline;
32 AutoActor m_sprFrame;
33 BitmapText m_textTitle;
34 ModIcon m_ModIcon;
35
36 ThemeMetric<float> ITEMS_START_X;
37 ThemeMetric<float> ITEMS_END_X;
38 ThemeMetric<float> ITEMS_GAP_X;
39 ThemeMetric<float> ITEMS_MIN_BASE_ZOOM;
40 ThemeMetric1D<float> ITEMS_LONG_ROW_X;
41 ThemeMetric<float> ITEMS_LONG_ROW_SHARED_X;
42 ThemeMetric1D<float> MOD_ICON_X;
43 ThemeMetric<RageColor> COLOR_SELECTED;
44 ThemeMetric<RageColor> COLOR_NOT_SELECTED;
45 ThemeMetric<RageColor> COLOR_DISABLED;
46 ThemeMetric<float> TWEEN_SECONDS;
47 ThemeMetric<bool> SHOW_BPM_IN_SPEED_TITLE;
48 ThemeMetric<bool> SHOW_MOD_ICONS;
49 ThemeMetric<bool> SHOW_UNDERLINES;
50 ThemeMetric<std::string> MOD_ICON_METRICS_GROUP;
51
52 friend class OptionRow;
53};
54
55class OptionRow : public ActorFrame
56{
57 public:
58 OptionRow(const OptionRowType* pType);
59 ~OptionRow() override;
60
61 void Clear();
62 void LoadNormal(OptionRowHandler* pHand, bool bFirstItemGoesDown);
63 void LoadExit();
64
65 void SetModIcon(PlayerNumber pn, const std::string& sText, GameCommand& gc);
66
67 void ImportOptions(const PlayerNumber& vpns);
68 int ExportOptions(const PlayerNumber& vpns, bool bRowHasFocus);
69
70 enum RowType
71 {
72 RowType_Normal,
73 RowType_Exit
74 };
75
76 void InitText(RowType type);
77 void AfterImportOptions(PlayerNumber pn);
78
79 std::string GetRowTitle() const;
80
81 void ChoicesChanged(RowType type, bool reset_focus = true);
82 void PositionUnderlines(PlayerNumber pn);
83 void PositionIcons(PlayerNumber pn);
84 void UpdateText(PlayerNumber pn);
85 bool GetRowHasFocus(PlayerNumber pn) const { return m_bRowHasFocus; }
86 void SetRowHasFocus(PlayerNumber pn, bool bRowHasFocus);
87 void UpdateEnabledDisabled();
88
89 int GetOneSelection(PlayerNumber pn, bool bAllowFail = false) const;
90 int GetOneSharedSelection(bool bAllowFail = false) const;
91 void SetOneSelection(PlayerNumber pn, int iChoice);
92 void SetOneSharedSelection(int iChoice);
93 void SetOneSharedSelectionIfPresent(const std::string& sChoice);
94
95 int GetChoiceInRowWithFocus() const;
96 int GetChoiceInRowWithFocusShared() const;
97 void SetChoiceInRowWithFocus(PlayerNumber pn, int iChoice);
98 void ResetFocusFromSelection(PlayerNumber pn);
99
100 bool GetSelected(int iChoice) const;
101 // SetSelected returns true if the choices changed because of setting.
102 bool SetSelected(PlayerNumber pn, int iChoice, bool b);
103
104 bool NotifyHandlerOfSelection(PlayerNumber pn, int choice);
105
106 const OptionRowDefinition& GetRowDef() const;
107 OptionRowDefinition& GetRowDef();
108 RowType GetRowType() const { return m_RowType; }
109 const OptionRowHandler* GetHandler() const { return m_pHand; }
110
111 const BitmapText& GetTextItemForRow(PlayerNumber pn,
112 int iChoiceOnRow) const;
113 void GetWidthXY(PlayerNumber pn,
114 int iChoiceOnRow,
115 int& iWidthOut,
116 int& iXOut,
117 int& iYOut) const;
118
119 // ScreenOptions calls positions m_FrameDestination, then m_Frame tween to
120 // that same TweenState.
121 unsigned GetTextItemsSize() const { return m_textItems.size(); }
122 bool GetFirstItemGoesDown() const { return m_bFirstItemGoesDown; }
123 bool GoToFirstOnStart();
124
125 std::string GetThemedItemText(int iChoice) const;
126
127 void SetExitText(const std::string& sExitText);
128
129 void Reload();
130
131 // Messages
132 void HandleMessage(const Message& msg) override;
133
134 // Lua
135 void PushSelf(lua_State* L) override;
136
137 protected:
138 const OptionRowType* m_pParentType;
139 RowType m_RowType;
140 OptionRowHandler* m_pHand;
141
142 ActorFrame m_Frame;
143
144 std::vector<BitmapText*>
145 m_textItems; // size depends on m_bRowIsLong and which players are joined
146 std::vector<OptionsCursor*> m_Underline; // size depends on
147 // m_bRowIsLong and which
148 // players are joined
149
150 Actor* m_sprFrame;
151 BitmapText* m_textTitle;
152 ModIcon* m_ModIcons;
153
154 bool m_bFirstItemGoesDown;
155 bool m_bRowHasFocus;
156
157 int m_iChoiceInRowWithFocus; // this choice has input focus
158 // Only one will true at a time if m_pHand->m_Def.bMultiSelect
159 std::vector<bool> m_vbSelected; // size = m_pHand->m_Def.choices.size()
160 Actor::TweenState m_tsDestination; // this should approach m_tsDestination.
161
162 public:
163 void SetDestination(Actor::TweenState& ts, bool bTween);
164};
165
166#endif
A container for other Actors.
Definition ActorFrame.h:8
Base class for all objects that appear on the screen.
Definition Actor.h:77
A smart pointer for Actor.
Definition AutoActor.h:13
An actor that holds a Font and draws text to the screen.
Definition BitmapText.h:11
Definition GameCommand.h:20
Shows PlayerOptions and SongOptions in icon form.
Definition ModIcon.h:10
Shows PlayerOptions and SongOptions in icon form.
Definition OptionRowHandler.h:185
Definition OptionRow.h:23
Definition OptionRow.h:56
A cursor for ScreenOptions.
Definition OptionsCursor.h:9
Definition ThemeMetric.h:192
The theme specific data.
Definition ThemeMetric.h:52
The present state for the Tween.
Definition Actor.h:140
Definition MessageManager.h:96
Define the purpose of the OptionRow.
Definition OptionRowHandler.h:57