mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-04-21 12:25:33 +00:00
Initial commit
This commit is contained in:
parent
2211ed7650
commit
ebb3dc9cdd
10121 changed files with 801 additions and 4 deletions
105
docs/base/@vl2/scripts.vl2/scripts/redbook.cs
Normal file
105
docs/base/@vl2/scripts.vl2/scripts/redbook.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
//------------------------------------------------------------------------------
|
||||
function RedBookCallback(%type)
|
||||
{
|
||||
if(%type $= "PlayFinished")
|
||||
CDPlayer.playFinished();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function CDAudio::playFinished(%this)
|
||||
{
|
||||
if(%this.repeat == false)
|
||||
return;
|
||||
|
||||
%this.play();
|
||||
}
|
||||
|
||||
function CDAudio::play(%this)
|
||||
{
|
||||
%numTracks = %this.getTrackCount();
|
||||
if(%numTracks == 0)
|
||||
{
|
||||
error(redbookGetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
switch$(%this.playMode)
|
||||
{
|
||||
case "one_shot":
|
||||
%this.playTrack(%this.currentTrack);
|
||||
|
||||
case "continuous":
|
||||
%this.currentTrack++;
|
||||
if(%this.currentTrack >= %numTracks)
|
||||
%this.currentTrack = 0;
|
||||
%this.playTrack(%this.currentTrack);
|
||||
|
||||
case "random":
|
||||
%track = mFloor(getRandom() * (%numTracks + 1));
|
||||
if(%track >= %numTracks)
|
||||
%track = %numTracks - 1;
|
||||
%this.playTrack(%track);
|
||||
}
|
||||
}
|
||||
|
||||
function CDAudio::playTrack(%this, %track)
|
||||
{
|
||||
if(redbookPlay(%track) == false)
|
||||
{
|
||||
error(redbookGetLastError());
|
||||
%this.repeat = false;
|
||||
return;
|
||||
}
|
||||
%this.currentTrack = %track;
|
||||
}
|
||||
|
||||
function CDAudio::stop(%this)
|
||||
{
|
||||
redbookStop();
|
||||
}
|
||||
|
||||
function CDAudio::getTrackCount(%this)
|
||||
{
|
||||
return(redbookGetTrackCount());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
new ScriptObject(CDPlayer)
|
||||
{
|
||||
class = CDAudio;
|
||||
currentTrack = 0;
|
||||
playMode = "one_shot";
|
||||
repeat = true;
|
||||
};
|
||||
|
||||
if($pref::Audio::musicEnabled)
|
||||
{
|
||||
redbookOpen();
|
||||
redbookSetVolume($pref::Audio::musicVolume);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function clientCmdPlayCDTrack(%track)
|
||||
{
|
||||
if(%track $= "")
|
||||
{
|
||||
%numTracks = CDPlayer.getTrackCount();
|
||||
if(%numTracks == 0)
|
||||
{
|
||||
error(redbookGetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
%track = mFloor(getRandom() * (%numTracks + 1));
|
||||
if(%track >= %numTracks)
|
||||
%track = %numTracks - 1;
|
||||
}
|
||||
|
||||
CDPlayer.playTrack(%track);
|
||||
}
|
||||
|
||||
function clientCmdStopCD()
|
||||
{
|
||||
CDPlayer.stop();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue