Plan for Harold "LabRat" Brown
by Harold "LabRat" Brown · 04/12/2002 (3:31 am) · 7 comments
I haven't forgotten about the vehicle code.. I just couldn't get in the mood to work on packinging it up nice and neat.
Instead I've been playing some DAoC (Dark Age of Camelot) since they added a new dungeon. Along with getting a headache over the CD Audio functions of Torque (there is a small issue I have with them)
So after playing with the CD functions for a bit I present to you this CD Player console gui.
make a file named CDPlayer.gui in your common/ui/ folder and set it to be loaded on startup. The contents of the file should be:
To open the CD Player tool press Ctrl-F1, currently you can't change CD drives so your audio CD must be in the first CD Drive your system sees.
Instead I've been playing some DAoC (Dark Age of Camelot) since they added a new dungeon. Along with getting a headache over the CD Audio functions of Torque (there is a small issue I have with them)
So after playing with the CD functions for a bit I present to you this CD Player console gui.
make a file named CDPlayer.gui in your common/ui/ folder and set it to be loaded on startup. The contents of the file should be:
//--- OBJECT WRITE BEGIN ---
new GuiWindowCtrl(CDPlayerGui) {
profile = "GuiWindowProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "196 162";
extent = "245 128";
minExtent = "8 8";
visible = "1";
helpTag = "0";
text = "CD Player";
maxLength = "255";
resizeWidth = "0";
resizeHeight = "0";
canMove = "1";
canClose = "1";
canMinimize = "0";
canMaximize = "0";
minSize = "50 50";
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "43 57";
extent = "25 25";
minExtent = "8 8";
visible = "1";
command = "CDPlayer.Play();";
helpTag = "0";
text = "Play";
groupNum = "-1";
buttonType = "PushButton";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "74 57";
extent = "25 25";
minExtent = "8 8";
visible = "1";
command = "CDPlayer.Stop();";
helpTag = "0";
text = "Stop";
groupNum = "-1";
buttonType = "PushButton";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "105 57";
extent = "25 25";
minExtent = "8 8";
visible = "1";
command = "if (CDPlayer.dcurrentTrack == CDPlayer.getTrackCount()) { CDPlayer.currentTrack=-1; } CDPlayer.playTrack(CDPlayer.currentTrack++);";
helpTag = "0";
text = ">>";
groupNum = "-1";
buttonType = "PushButton";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "12 57";
extent = "25 25";
minExtent = "8 8";
visible = "1";
command = "if (CDPlayer.currentTrack == 0) { CDPlayer.currentTrack=CDPlayer.getTrackCount(); } CDPlayer.playTrack(CDPlayer.currentTrack--);";
helpTag = "0";
text = "<<";
groupNum = "-1";
buttonType = "PushButton";
};
new GuiPopUpMenuCtrl() {
profile = "GuiPopUpMenuProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "136 29";
extent = "36 19";
minExtent = "8 8";
visible = "1";
helpTag = "0";
text = "Drive";
maxLength = "255";
maxPopupHeight = "200";
};
new GuiPopUpMenuCtrl(playMode) {
profile = "GuiPopUpMenuProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "144 58";
extent = "85 21";
minExtent = "8 8";
visible = "1";
variable = "CDPlayer.playMode";
helpTag = "0";
maxLength = "255";
maxPopupHeight = "200";
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "11 30";
extent = "30 18";
minExtent = "8 8";
visible = "1";
helpTag = "0";
text = "Track:";
maxLength = "255";
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "45 30";
extent = "8 18";
minExtent = "8 8";
visible = "1";
variable = "CDPlayer.dcurrentTrack";
helpTag = "0";
maxLength = "255";
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "57 30";
extent = "8 18";
minExtent = "8 8";
visible = "1";
helpTag = "0";
text = "/";
maxLength = "255";
};
new GuiTextCtrl() {
profile = "GuiTextProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "69 30";
extent = "12 18";
minExtent = "8 8";
visible = "1";
variable = "CDPlayer.totalTracks";
helpTag = "0";
maxLength = "255";
};
new GuiRadioCtrl() {
profile = "GuiRadioProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "183 28";
extent = "58 20";
minExtent = "8 8";
visible = "1";
variable = "CDPlayer.repeat";
helpTag = "0";
text = "Repeat";
groupNum = "-1";
buttonType = "RadioButton";
};
new GuiSliderCtrl(cdvolume) {
profile = "GuiSliderProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "14 89";
extent = "220 31";
minExtent = "8 8";
visible = "1";
variable = "value";
command = "CDPlayer.setVolume();";
helpTag = "0";
range = "0.000000 1.000000";
ticks = "1000";
value = "0.471429";
};
};
//--- OBJECT WRITE END ---
playmode.add(Track,1);
playmode.add(Continuous,2);
playmode.add(Random,3);
function playmode::onSelect(%this, %id)
{
CDPlayer.playMode=playmode.gettextbyid(%id);
}
function RedBookCallback(%type)
{
if(%type $= "PlayFinished")
CDPlayer.playFinished();
}
new ScriptObject(CDPlayer)
{
class = CDAudio;
currentTrack = 0;
dcurrentTrack = 0;
totalTracks = 0;
playMode = "Track";
repeat = true;
volume=0.5;
};
redbookOpen();
redbookSetVolume(CDPlayer.volume);
//----
function CDAudio::setVolume(%this)
{
CDPlayer.volume = cdvolume.value;
redbookSetVolume(CDPlayer.volume);
}
function CDAudio::playFinished(%this)
{
if(%this.repeat == false)
return;
%this.play();
}
function CDAudio::play(%this)
{
%numTracks = %this.getTrackCount();
CDPlayer.totalTracks=%numTracks;
if(%numTracks == 0)
{
error(redbookGetLastError());
return;
}
switch$(%this.playMode)
{
case "Track":
%this.playTrack(%this.currentTrack);
case "Continuous":
%this.currentTrack++;
%this.dcurrentTrack++;
if(%this.currentTrack >= %numTracks) {
%this.currentTrack = 0;
%this.dcurrentTrack = 1;
}
%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;
%this.dcurrentTrack = %track+1;
}
function CDAudio::stop(%this)
{
redbookStop();
}
function CDAudio::getTrackCount(%this)
{
return(redbookGetTrackCount());
}
function CDAudio::togglecontrol(%this,%make){
if(!%this.show){
CDPlayerGui.mouseOn = Canvas.isCursorOn();
if(!CDPlayerGui.mouseOn)
CursorOn();
%this.controlhud();
%this.show = 1;
}
else {
%this.controlcanvas.remove(CDPlayerGUI);
%this.show = 0;
if(!CDPlayerGui.mouseOn)
CursorOff();
canvas.repaint();
}
}
function CDAudio::controlhud(%this)
{
%this.controlcanvas = Canvas.getContent();
Canvas.getContent().add(CDPlayerGUI);
canvas.repaint();
}
GlobalActionMap.bindcmd(keyboard, "ctrl F1", "CDPlayer.togglecontrol();","");To open the CD Player tool press Ctrl-F1, currently you can't change CD drives so your audio CD must be in the first CD Drive your system sees.
About the author
#2
04/12/2002 (1:54 pm)
I don't see where you're connecting up to the CDDB database... you planning on adding that ? :0
#3
If anything it would need to be from www.freedb.org as the origional CDDB database (www.gracenot.com/) requires licensing to use now.
That and I was working with the redbook functions already in the engine. ;)
04/12/2002 (2:14 pm)
Hmm... that would be interesting to add...If anything it would need to be from www.freedb.org as the origional CDDB database (www.gracenot.com/) requires licensing to use now.
That and I was working with the redbook functions already in the engine. ;)
#4
04/12/2002 (8:44 pm)
neat
#5
Randy...
04/12/2002 (9:41 pm)
OMG thats so sweet. Thank You for the contribution. I was just dreaming about this feature for torque.Randy...
#6
Is this an OPENal function? I have been trying to dig thru all the OPENal doc's but it's slow digestion. I would expect something like alxplaycd type of command. Also, I was wondering if OPENal could handle MP3 files? Just curious.
Randy...
04/12/2002 (9:50 pm)
I am sorry to add another post on this but...Is this an OPENal function? I have been trying to dig thru all the OPENal doc's but it's slow digestion. I would expect something like alxplaycd type of command. Also, I was wondering if OPENal could handle MP3 files? Just curious.
Randy...
#7
04/12/2002 (11:48 pm)
This is using the MCI functions (not sure what the linux / mac support is like for this) 
Associate Stefan Beffy Moises
Why don't you make that a resource - nobody will find it here... there are so much plans around...
Thanks!