home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 January
/
01_03.iso
/
service
/
winamp3
/
files
/
skins
/
Chronabie.wal
/
scripts
/
mainfunc.m
< prev
next >
Wrap
Text File
|
2002-06-24
|
7KB
|
235 lines
/*--------------------------------------------------------------------
System functions.
This scripts handles various system functions, like toggling of some
configuration options (crossfading for example), and temporary output
in the song ticker (volume, seek, clicks on the player buttons).
--------------------------------------------------------------------*/
#include "../../../lib/std.mi"
#include "../../../lib/config.mi"
#include "../../../lib/pldir.mi"
Function setTempText(String txt);
Function emptyTempText();
Global Text Songticker;
Global Slider Volbar, Seeker, SeekGhost;
Global Timer Songtickertimer;
Global Int Seeking;
Class GuiObject HintObject;
Class ToggleButton HintToggleButton;
Global HintObject Play, Stop, Previous, Next, Pause, Open, Ml, Pl, Minimize, Shade, Close;
Global HintToggleButton ToggleXFade, ToggleShuffle, ToggleRepeat;
Class ConfigAttribute ToggleConfigAttribute;
Global ToggleConfigAttribute attr_repeat, attr_shuffle, attr_crossfade;
System.onScriptUnloading() {
delete Songtickertimer;
}
System.onScriptLoaded() {
// Timers won't start until .start(); is called
Songtickertimer = new Timer;
Songtickertimer.setDelay(1000);
Layout mainnormal = getContainer("main").getLayout("Normal");
// Get buttons
ToggleXFade = mainnormal.getObject("Crossfade");
ToggleShuffle = mainnormal.getObject("Shuffle");
ToggleRepeat = mainnormal.getObject("Repeat");
// Get songticker, Volbar & Seeker
Songticker = mainnormal.getObject("Songticker");
Volbar = mainnormal.getObject("Volume");
Seeker = mainnormal.getObject("Seeker");
SeekGhost = mainnormal.getObject("SeekerGhost");
// Get Various buttons
Play = mainnormal.getObject("Play");
Pause = mainnormal.getObject("Pause");
Stop = mainnormal.getObject("Stop");
Next = mainnormal.getObject("Next");
Previous = mainnormal.getObject("Previous");
Open = mainnormal.getObject("Eject");
Minimize = mainnormal.getObject("Minimize");
Shade = mainnormal.getObject("winshade");
Close = mainnormal.getObject("close");
Ml = mainnormal.getObject("Ml");
Pl = mainnormal.getObject("Pl");
// Set buttons status
ConfigItem item;
item = Config.getItem("Playlist editor");
if (item != NULL) {
attr_repeat = item.getAttribute("repeat");
attr_shuffle = item.getAttribute("shuffle");
}
item = Config.getItem("Audio options");
if (item != NULL) {
attr_crossfade = item.getAttribute("Enable crossfading");
}
if (ToggleXFade != NULL && attr_crossfade != NULL) ToggleXFade.setActivated(StringToInteger(attr_crossfade.getData()));
if (ToggleShuffle != NULL && attr_shuffle != NULL) ToggleShuffle.setActivated(StringToInteger(attr_shuffle.getData()));
if (ToggleRepeat != NULL && attr_repeat != NULL) ToggleRepeat.setActivated(StringToInteger(attr_repeat.getData()));
if (SeekGhost != NULL)
SeekGhost.setAlpha(1);
}
Songticker.onLeftButtonDblClk(int x, int y) {
PlDir.showCurrentlyPlayingEntry();
}
Songtickertimer.onTimer() {
Songticker.setText("");
stop();
}
Volbar.onSetPosition(int p) {
Float f;
f = p;
f = f / 255 * 100;
setTempText("Vol: " + System.integerToString(f) + "%");
}
Volbar.onSetFinalPosition(int p) {
Songticker.setText("");
}
Seeker.onSetPosition(int p) {
if (!SeekGhost && seeking) {
Float f;
f = p;
f = f / 255 * 100;
Float len = getPlayItemLength();
if (len != 0) {
int np = len * f / 100;
setTempText(integerToTime(np) + " / " + integerToTime(len) + " (" + integerToString(f) + "%)");
}
}
}
Seeker.onLeftButtonDown(int x, int y) {
seeking = 1;
}
Seeker.onLeftButtonUp(int x, int y) {
seeking = 0;
setTempText("");
}
SeekGhost.onSetPosition(int p) {
if (getalpha() == 1) return;
Float f;
f = p;
f = f / 255 * 100;
Float len = getPlayItemLength();
if (len != 0) {
int np = len * f / 100;
setTempText(integerToTime(np) + " / " + integerToTime(len) + " (" + integerToString(f) + "%)");
}
}
SeekGhost.onLeftButtonDown(int x, int y) {
SeekGhost.setAlpha(128);
}
SeekGhost.onLeftButtonUp(int x, int y) {
SeekGhost.setAlpha(1);
}
Seeker.onSetFinalPosition(int p) {
Songticker.setText("");
}
SeekGhost.onsetfinalposition(int p) {
Songticker.setText("");
SeekGhost.setAlpha(1);
}
HintToggleButton.onLeftButtonDown(int x, int y) {
if (HintToggleButton == ToggleXFade) setTempText("Crossfade");
else if (HintToggleButton == ToggleRepeat) setTempText("Repeat");
else if (HintToggleButton == ToggleShuffle) setTempText("Shuffle");
}
HintToggleButton.onLeftButtonUp(int x, int y) {
emptyTempText();
}
HintToggleButton.onToggle(int onoff) {
String cmd, txt;
Wac dest;
ConfigAttribute item;
item = NULL;
if (HintToggleButton == ToggleXFade) {
item = attr_crossfade;
txt = "Crossfade";
} else if (HintToggleButton == ToggleRepeat) {
item = attr_repeat;
txt = "Repeat";
} else if (HintToggleButton == ToggleShuffle) {
item = attr_shuffle;
txt = "Shuffle";
}
if (item != NULL) {
item.setData(IntegerToString(onoff));
String s;
if (onoff) s = "on"; else s = "off";
setTempText(txt + s);
}
}
HintObject.onLeftButtonDown(int x, int y) {
if (HintObject == Play) setTempText("Play");
else if (HintObject == Stop) setTempText("Stop");
else if (HintObject == Pause) setTempText("Pause");
else if (HintObject == Next) setTempText("Next");
else if (HintObject == Previous) setTempText("Previous");
else if (HintObject == Open) setTempText("Open");
else if (HintObject == ML) setTempText("Media Library");
else if (HintObject == Pl) setTempText("Playlist Editor");
else if (HintObject == Minimize) setTempText("Minimize");
else if (HintObject == Shade) setTempText("Shade Mode");
else if (HintObject == close) setTempText("Exit, Why ??");
}
HintObject.onLeftButtonUp(int x, int y) {
emptyTempText();
}
setTempText(String txt) {
Songtickertimer.stop();
Songticker.setText(txt);
Songtickertimer.start();
}
emptyTempText() {
Songticker.setText("");
Songtickertimer.stop();
}
Songticker.onNotify(String s1, String s2, int i1, int i2) {
setTempText(s1);
}
ToggleConfigAttribute.onDataChanged() {
ToggleButton t = NULL;
if (ToggleConfigAttribute == attr_crossfade) t = ToggleXFade;
else if (ToggleConfigAttribute == attr_shuffle) t = ToggleShuffle;
else if (ToggleConfigAttribute == attr_repeat) t = ToggleRepeat;
if (t != NULL)
t.setActivated(StringToInteger(getData()));
}