aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Big Bento/scripts/cbuttons.m
blob: 0b662f4c16f392f11dabf5aefae986a347dce84d (plain) (blame)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/*---------------------------------------------------
-----------------------------------------------------
Filename:	cbuttons.m
Version:	1.0

Type:		maki
Date:		03. Nov. 2006 - 17:02 
Author:		Martin Poehlmann aka Deimos
E-Mail:		martin@skinconsortium.com
Internet:	www.skinconsortium.com
		www.martin.deimos.de.vu
-----------------------------------------------------
---------------------------------------------------*/

#include <lib/std.mi>
#include <lib/pldir.mi>

#define GLOW_OBJECT Prev
#include <lib/com/glow.m>
#define GLOW_OBJECT Next
#include <lib/com/glow.m>
#define GLOW_OBJECT Play
#include <lib/com/glow.m>
#define GLOW_OBJECT Pause
#include <lib/com/glow.m>
#define GLOW_OBJECT Stop
#include <lib/com/glow.m>
#define GLOW_OBJECT Eject
#include <lib/com/glow.m>
#define GLOW_OBJECT Repeat
#include <lib/com/glow.m>
#define GLOW_OBJECT Shuffle
#include <lib/com/glow.m>
#define GLOW_OBJECT Bolt
#include <lib/com/glow.m>

Class Button InfoButton;
Class ToggleButton InfoToggleButton;

Global InfoButton b_play, b_pause, b_eject, b_prev, b_next, b_stop, b_bolt;
Global InfoToggleButton b_repeat, b_shuffle;
Global GuiObject SongTicker;
Global Group buttongroup;
Global GuiObject shuffleActive, repeatActive, boltGlow;
Global Int shuffleActive_Y, repeatActive_Y, minW, boltX, grabbX;
Global Layer mainframe_grabber;
Global Timer beatvis;

System.onScriptLoaded ()
{
	buttongroup = getScriptGroup().findObject("player.cbuttons");

	b_play = buttongroup.getObject("Play");
	b_pause = buttongroup.getObject("Pause");
	b_eject = buttongroup.getObject("Eject");
	b_prev = buttongroup.getObject("Prev");
	b_next = buttongroup.getObject("Next");
	b_stop = buttongroup.getObject("Stop");
	b_repeat = buttongroup.getObject("repeat");
	b_shuffle = buttongroup.getObject("shuffle");
	b_bolt = buttongroup.getParentLayout().getObject("bolt");
	boltGlow = buttongroup.getParentLayout().getObject("bolt.glow");
	shuffleActive = getScriptGroup().findObject("shuffle.active");
	shuffleActive_Y = shuffleActive.getGuiY();
	repeatActive = getScriptGroup().findObject("repeat.active");
	repeatActive_Y = repeatActive.getGuiY();
	mainframe_grabber = buttongroup.getParentLayout().getObject("player.mainframe.grabber");

	beatvis = new Timer;
	beatvis.setDelay(33);

	minW = stringToInteger(getParam());
	boltX = b_bolt.getGuiX();
	grabbX = mainframe_grabber.getGuiX();

	b_bolt.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
	boltGlow.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
	mainframe_grabber.setXmlParam("x", integerToString(grabbX + buttongroup.GetWidth() - minW));

	_Play_GlowInit (b_play, buttongroup.findObject("Play.glow"), 0.3);
	_Pause_GlowInit (b_pause, buttongroup.findObject("Pause.glow"), 0.3);
	_Stop_GlowInit (b_stop, buttongroup.findObject("Stop.glow"), 0.3);
	_Prev_GlowInit (b_prev, buttongroup.findObject("Prev.glow"), 0.3);
	_Next_GlowInit (b_next, buttongroup.findObject("Next.glow"), 0.3);
	_Eject_GlowInit (b_eject, buttongroup.findObject("Eject.glow"), 0.3);
	_Repeat_GlowInit (b_repeat, buttongroup.findObject("repeat.glow"), 0.3);
	_Shuffle_GlowInit (b_shuffle, buttongroup.findObject("shuffle.glow"), 0.3);
	_Bolt_GlowInit (b_bolt, buttongroup.getParentLayout().getObject("bolt.glow"), 0.7);

	SongTicker = buttongroup.getParentLayout().findObject("songticker");
}

system.onScriptUnloading ()
{
	beatvis.stop();
	delete beatvis;
}

InfoButton.onLeftButtonDown (int x, int y)
{
	if (InfoButton == b_play)
	{
		if (getStatus() == -1)
		{
			SongTicker.sendAction("showinfo", "Resume Playback", 0, 0, 0, 0);
		}
		else if (getStatus() == 0)
		{
			SongTicker.sendAction("showinfo", "Start Playback", 0, 0, 0, 0);
		}
		else if (getStatus() == 1)
		{
			SongTicker.sendAction("showinfo", "Restart Playback", 0, 0, 0, 0);
		}
	}
	else if (InfoButton == b_pause)
	{
		if (getStatus() == -1)
		{
			SongTicker.sendAction("showinfo", "Resume Playback", 0, 0, 0, 0);
		}
		else if (getStatus() == 1)
		{
			SongTicker.sendAction("showinfo", "Pause Playback", 0, 0, 0, 0);
		}
	}
	else if (InfoButton == b_pause)
	{
		if (getStatus() == 1)
		{
			SongTicker.sendAction("showinfo", "Pause Playback", 0, 0, 0, 0);
		}
	}
	else
	{
		string info = InfoButton.getXmlParam("tooltip");
		SongTicker.sendAction("showinfo", info, 0, 0, 0, 0);		
	}
}

InfoToggleButton.onLeftButtonDown (int x, int y)
{
	if (InfoToggleButton == b_shuffle)
	{
		if (getCurCfgVal() == 1)
		{
			SongTicker.sendAction("showinfo", "Shuffle: On", 0, 0, 0, 0);
		}
		else
		{
			SongTicker.sendAction("showinfo", "Shuffle: Off", 0, 0, 0, 0);
		}
	}
	else if (InfoToggleButton == b_repeat)
	{
		if (getCurCfgVal() == 1)
		{
			SongTicker.sendAction("showinfo", "Repeat: Playlist", 0, 0, 0, 0);
		}
		else if (getCurCfgVal() == -1)
		{
			SongTicker.sendAction("showinfo", "Repeat: Track", 0, 0, 0, 0);
		}
		else if (getCurCfgVal() == 0)
		{
			SongTicker.sendAction("showinfo", "Repeat: Off", 0, 0, 0, 0);
		}
	}
}

InfoToggleButton.onLeftButtonUp (int x, int y)
{
	if (InfoToggleButton == b_shuffle)
	{
		if (getCurCfgVal() == 1)
		{
			SongTicker.sendAction("showinfo", "Shuffle: On", 0, 0, 0, 0);
		}
		else
		{
			SongTicker.sendAction("showinfo", "Shuffle: Off", 0, 0, 0, 0);
		}
	}
	else if (InfoToggleButton == b_repeat)
	{
		if (getCurCfgVal() == 1)
		{
			SongTicker.sendAction("showinfo", "Repeat: Playlist", 0, 0, 0, 0);
		}
		else if (getCurCfgVal() == -1)
		{
			SongTicker.sendAction("showinfo", "Repeat: Track", 0, 0, 0, 0);
		}
		else if (getCurCfgVal() == 0)
		{
			SongTicker.sendAction("showinfo", "Repeat: Off", 0, 0, 0, 0);
		}
	}
}

Global Boolean shuffleDown, repeatDown;
b_shuffle.onLeftButtonDown (int x, int y)
{
	shuffleDown = 1;
	shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y+1));
}

b_shuffle.onLeftButtonUp (int x, int y)
{
	shuffleDown = 0;
	shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y));
}

b_shuffle.onleaveArea ()
{
	shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y));
}

b_shuffle.onEnterArea ()
{
	if (shuffleDown) shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y+1));
}

b_repeat.onLeftButtonDown (int x, int y)
{
	repeatDown = 1;
	repeatActive.setXmlParam("y", integerToString(repeatActive_Y+1));
}

b_repeat.onLeftButtonUp (int x, int y)
{
	repeatDown = 0;
	repeatActive.setXmlParam("y", integerToString(repeatActive_Y));
}

b_repeat.onleaveArea ()
{
	repeatActive.setXmlParam("y", integerToString(repeatActive_Y));
}

b_repeat.onEnterArea ()
{
	if (repeatDown) repeatActive.setXmlParam("y", integerToString(repeatActive_Y+1));
}

buttongroup.onResize (int x, int y, int w, int h)
{
	b_bolt.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
	boltGlow.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
	mainframe_grabber.setXmlParam("x", integerToString(grabbX + buttongroup.GetWidth() - minW));
}

b_bolt.onLeftButtonUp (int x, int y)
{
	if (isKeyDown(VK_ALT) && isKeyDown(VK_SHIFT) && isKeyDown(VK_CONTROL))
	{
		if (beatvis.isRunning())
		{
			beatvis.stop();
		}
		else
		{
			beatvis.start();
		}
		complete;
	}
}

beatvis.onTimer ()
{
	int value = (getRightVuMeter() + getLeftVuMeter()) / 2;
	boltGlow.setAlpha(value);
}
/*
System.onKeyDown (String key)
{
	if (key == "space")
	{
		PlEdit.showCurrentlyPlayingTrack();

		complete;
	}
}*/

System.onAccelerator (String action, String section, String key)
{
	if (strupper(action) == "SHOW_CURRENT_TRACK")
	{
		PlEdit.showCurrentlyPlayingTrack();

		complete;
	}
}