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