Etterna 0.74.4
Loading...
Searching...
No Matches
WheelBase.h
1#ifndef WHEELBASE_H
2#define WHEELBASE_H
3
4#include "Etterna/Actor/Base/ActorFrame.h"
5#include "Etterna/Actor/Base/AutoActor.h"
6#include "Etterna/Models/Lua/LuaExpressionTransform.h"
7#include "RageUtil/Sound/RageSound.h"
8#include "RageUtil/Misc/RageTimer.h"
9#include "ScrollBar.h"
10#include "Etterna/Models/Misc/ThemeMetric.h"
11#include "WheelItemBase.h"
12
13#define NUM_WHEEL_ITEMS (static_cast<int>(ceil(NUM_WHEEL_ITEMS_TO_DRAW + 2)))
14
15enum WheelState
16{
17 STATE_SELECTING,
18 STATE_FLYING_OFF_BEFORE_NEXT_SORT,
19 STATE_FLYING_ON_AFTER_NEXT_SORT,
20 STATE_ROULETTE_SPINNING,
21 STATE_ROULETTE_SLOWING_DOWN,
22 STATE_RANDOM_SPINNING,
23 STATE_LOCKED,
24 NUM_WheelState,
25 WheelState_Invalid,
26};
27auto
28WheelStateToString(WheelState ws) -> const std::string&;
29auto
30StringToWheelState(const std::string& sDC) -> WheelState;
31LuaDeclareType(WheelState);
32
34class WheelBase : public ActorFrame
35{
36 public:
37 ~WheelBase() override;
38 virtual void Load(const std::string& sType);
39 void BeginScreen();
40
41 void HandleMessage(const Message& msg) override;
42
43 void Update(float fDeltaTime) override;
44
45 virtual void Move(int n);
46 void ChangeMusicUnlessLocked(int n); /* +1 or -1 */
47 virtual void ChangeMusic(int dist); /* +1 or -1 */
48 virtual void SetOpenSection(const std::string& group) {}
49
50 // Return true if we're moving fast automatically.
51 auto IsMoving() const -> int;
52 auto IsSettled() const -> bool;
53
54 void GetItemPosition(float fPosOffsetsFromMiddle,
55 float& fX_out,
56 float& fY_out,
57 float& fZ_out,
58 float& fRotationX_out);
59 void SetItemPosition(Actor& item, int item_index, float offset_from_middle);
60
61 virtual auto Select()
62 -> bool; // return true if this selection can end the screen
63
64 auto GetCurrentGroup() -> std::string;
65
66 auto GetWheelState() -> WheelState { return m_WheelState; }
67 void Lock() { m_WheelState = STATE_LOCKED; }
68 auto WheelIsLocked() -> bool
69 {
70 return (m_WheelState == STATE_LOCKED ? true : false);
71 }
72 void RebuildWheelItems(int dist = INT_MAX); // INT_MAX = refresh all
73 // Update the list of songs to match whatever songs are indexed by the song
74 // manager (SONGMAN)
75 virtual void ReloadSongList(bool searching, const std::string& findme) {}
76
77 virtual auto GetNumItems() const -> unsigned int
78 {
79 return m_CurWheelItemData.size();
80 }
81 auto IsEmpty() -> bool { return m_bEmpty; }
82 auto GetItem(unsigned int index) -> WheelItemBaseData*;
83 auto LastSelected() -> WheelItemBaseData*;
84 auto GetWheelItem(int i) -> WheelItemBase*
85 {
86 if (i < 0 || i >= static_cast<int>(m_WheelBaseItems.size())) {
87 return nullptr;
88 }
89 return m_WheelBaseItems[i];
90 }
91 auto GetExpandedSectionName() -> std::string
92 {
93 return m_sExpandedSectionName;
94 }
95 auto GetCurrentIndex() -> int { return m_iSelection; }
96
97 auto GetSelectedType() -> WheelItemDataType
98 {
99 return m_CurWheelItemData[m_iSelection]->m_Type;
100 }
101
102 // Lua
103 void PushSelf(lua_State* L) override;
104
105 protected:
106 void TweenOnScreenForSort();
107 void TweenOffScreenForSort();
108
109 virtual auto MakeItem() -> WheelItemBase* = 0;
110 virtual void UpdateSwitch();
111 virtual auto MoveSpecific(int n) -> bool;
112 void SetPositions();
113 void MaintainItemCount();
114
115 auto FirstVisibleIndex() -> int;
116
117 ScrollBar m_ScrollBar;
118 AutoActor m_sprHighlight;
119
120 std::vector<WheelItemBaseData*> m_CurWheelItemData;
121 std::vector<WheelItemBase*> m_WheelBaseItems;
122 WheelItemBaseData* m_LastSelection{};
123
124 bool m_bEmpty{};
125 int m_iSelection{}; // index into m_CurWheelItemBaseData
126 std::string m_sExpandedSectionName;
127
128 int m_iSwitchesLeftInSpinDown{};
129 float m_fLockedWheelVelocity{};
130 // 0 = none; -1 or 1 = up/down
131 int m_Moving{};
132 RageTimer m_MovingSoundTimer;
133 float m_TimeBeforeMovingBegins{};
134 float m_SpinSpeed{};
135
136 WheelState m_WheelState;
137 float m_fTimeLeftInState{};
138 float m_fPositionOffsetFromSelection{};
139
140 RageSound m_soundChangeMusic;
141 RageSound m_soundExpand;
142 RageSound m_soundCollapse;
143 RageSound m_soundLocked;
144
145 // bool WheelItemIsVisible(int n);
146 void UpdateScrollbar();
147
148 ThemeMetric<float> SWITCH_SECONDS;
149 ThemeMetric<float> LOCKED_INITIAL_VELOCITY;
150 ThemeMetric<int> SCROLL_BAR_HEIGHT;
151 LuaExpressionTransform m_exprItemTransformFunction;
152 ThemeMetric<float> NUM_WHEEL_ITEMS_TO_DRAW;
153 ThemeMetric<RageColor> WHEEL_ITEM_LOCKED_COLOR;
154};
155
156#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
Handle transforming a list of items.
Definition LuaExpressionTransform.h:16
Definition RageSound.h:130
Definition RageTimer.h:9
Definition ScrollBar.h:10
The theme specific data.
Definition ThemeMetric.h:52
A wheel with data elements.
Definition WheelBase.h:35
An item on the wheel.
Definition WheelItemBase.h:42
Definition MessageManager.h:96
Definition WheelItemBase.h:30