forked from stepmania/stepmania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWheelNotifyIcon.cpp
117 lines (99 loc) · 4.01 KB
/
WheelNotifyIcon.cpp
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
#include "global.h"
#include "WheelNotifyIcon.h"
#include "RageUtil.h"
#include "GameConstantsAndTypes.h"
#include "MusicWheel.h"
#include "WheelNotifyIcon.h"
#include "RageTimer.h"
#include "ThemeManager.h"
/* todo: replace this entire thing with a set of AutoActors and a Scroller.
* In reality, everything except the Beginner/Training icon can be replicated
* in Lua (in stock StepMania 4), so I'm not sure if we even need this... -aj
*/
static ThemeMetric<bool> SHOW_TRAINING ("WheelNotifyIcon","ShowTraining");
static ThemeMetric<bool> BLINK_BEST_ICON ("WheelNotifyIcon","BlinkPlayersBest");
static ThemeMetric<int> NUM_ICONS_TO_SHOW ("WheelNotifyIcon","NumIconsToShow");
WheelNotifyIcon::WheelNotifyIcon()
{
// Load( THEME->GetPathG("MusicWheelItem","WheelNotifyIcon") );
Load( THEME->GetPathG("WheelNotifyIcon","icons 4x2") );
StopAnimating();
}
void WheelNotifyIcon::SetFlags( Flags flags )
{
m_vIconsToShow.clear();
// push onto vector in highest to lowest priority
switch( flags.iPlayersBestNumber )
{
case 1: m_vIconsToShow.push_back( best1 ); break;
case 2: m_vIconsToShow.push_back( best2 ); break;
case 3: m_vIconsToShow.push_back( best3 ); break;
}
if( flags.bEdits )
m_vIconsToShow.push_back( edits );
switch( flags.iStagesForSong )
{
case 1: break;
case 2: m_vIconsToShow.push_back( long_ver ); break;
case 3: m_vIconsToShow.push_back( marathon ); break;
default: FAIL_M( fmt::sprintf("flags.iStagesForSong = %d", flags.iStagesForSong) );
}
if( flags.bHasBeginnerOr1Meter && (bool)SHOW_TRAINING )
m_vIconsToShow.push_back( training );
// If BLINK_BEST_ICON, make player's best icon blink if it's the only icon.
if( m_vIconsToShow.size() == 1 && BLINK_BEST_ICON )
{
if( m_vIconsToShow[0] >= best1 && m_vIconsToShow[0] <= best3 )
m_vIconsToShow.push_back( empty );
}
m_vIconsToShow.resize( std::min(static_cast<unsigned int>(m_vIconsToShow.size()), static_cast<unsigned int>(NUM_ICONS_TO_SHOW)) );
// Broadcast Set message so items can react. (futures) -aj
//Message msg("Set");
//this->HandleMessage( msg );
/* Make sure the right icon is selected, since we might be drawn before
* we get another update. */
Update(0);
}
bool WheelNotifyIcon::EarlyAbortDraw() const
{
if( m_vIconsToShow.empty() )
return true;
return Sprite::EarlyAbortDraw();
}
void WheelNotifyIcon::Update( float fDeltaTime )
{
if( m_vIconsToShow.size() > 0 )
{
/* We should probably end up parsing the vector and then dynamically
* insert flag icons based on "priority". Easy to do, hopefully
- Midiman */
const float fSecondFraction = fmodf( RageTimer::GetTimeSinceStartFast(), 1 );
const int index = (int)(fSecondFraction*m_vIconsToShow.size());
Sprite::SetState( m_vIconsToShow[index] );
}
Sprite::Update( fDeltaTime );
}
/*
* (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.
*/