new rendering system
This commit is contained in:
parent
8e30772391
commit
39e65ab514
|
@ -36,22 +36,31 @@ end
|
||||||
defaultStatus = "Rhythmblock 1.0"
|
defaultStatus = "Rhythmblock 1.0"
|
||||||
invalidFormatStatus = "Not a music disc"
|
invalidFormatStatus = "Not a music disc"
|
||||||
noDiscStatus = "No disc"
|
noDiscStatus = "No disc"
|
||||||
|
noAudioStatus = "No audio is playing"
|
||||||
ejectText = "Eject"
|
ejectText = "Eject"
|
||||||
|
|
||||||
function playDisc()
|
function playDisc()
|
||||||
|
term.clear()
|
||||||
if disk.isPresent(drive) and disk.hasAudio(drive) then -- Determines if there's a disc or not and if it's a music disc
|
if disk.isPresent(drive) and disk.hasAudio(drive) then -- Determines if there's a disc or not and if it's a music disc
|
||||||
disk.playAudio(drive)
|
disk.playAudio(drive)
|
||||||
renderStopButton()
|
renderStopButton()
|
||||||
|
renderEjectButton()
|
||||||
playing = true
|
playing = true
|
||||||
status = disk.getAudioTitle(drive)
|
status = disk.getAudioTitle(drive)
|
||||||
elseif disk.isPresent(drive) then -- If there's a floppy disk for example, Rhythmbox won't play it.
|
elseif disk.isPresent(drive) then -- If there's a floppy disk for example, Rhythmbox won't play it.
|
||||||
status = invalidFormatStatus
|
status = invalidFormatStatus
|
||||||
|
renderPlayButton()
|
||||||
|
renderEjectButton()
|
||||||
else -- If none of these checks are passed then it just means there's no disc in the drive.
|
else -- If none of these checks are passed then it just means there's no disc in the drive.
|
||||||
status = noDiscStatus
|
status = noDiscStatus
|
||||||
|
renderPlayButton()
|
||||||
|
renderEjectButton()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ejectDisc() -- Ejects the disc! How cool is that?
|
function ejectDisc() -- Ejects the disc! How cool is that?
|
||||||
|
renderPlayButton()
|
||||||
|
renderEjectButton()
|
||||||
if playing == true then
|
if playing == true then
|
||||||
stopDisc()
|
stopDisc()
|
||||||
disk.eject()
|
disk.eject()
|
||||||
|
@ -63,10 +72,11 @@ function ejectDisc() -- Ejects the disc! How cool is that?
|
||||||
end
|
end
|
||||||
|
|
||||||
function stopDisc() -- Stops the music
|
function stopDisc() -- Stops the music
|
||||||
disk.stopAudio()
|
|
||||||
renderPlayButton()
|
|
||||||
playing = false
|
playing = false
|
||||||
status = defaultStatus
|
status = defaultStatus
|
||||||
|
term.clear()
|
||||||
|
renderPlayButton()
|
||||||
|
renderEjectButton()
|
||||||
end
|
end
|
||||||
|
|
||||||
function renderPlayButton() -- Renders the Play button
|
function renderPlayButton() -- Renders the Play button
|
||||||
|
@ -115,6 +125,7 @@ while true do
|
||||||
playDisc()
|
playDisc()
|
||||||
end
|
end
|
||||||
elseif eventData[2] == 1 and eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
|
elseif eventData[2] == 1 and eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
|
||||||
|
term.clear()
|
||||||
ejectDisc()
|
ejectDisc()
|
||||||
end
|
end
|
||||||
elseif event == "monitor_touch" then
|
elseif event == "monitor_touch" then
|
||||||
|
@ -125,6 +136,7 @@ while true do
|
||||||
playDisc()
|
playDisc()
|
||||||
end
|
end
|
||||||
elseif eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
|
elseif eventData[3] >= centerWidth - 2 and eventData[4] >= centerHeight + 4 and eventData[3] <= centerWidth + 2 and eventData[4] <= centerHeight + 4 then
|
||||||
|
term.clear()
|
||||||
ejectDisc()
|
ejectDisc()
|
||||||
end
|
end
|
||||||
elseif event == "key_up" then
|
elseif event == "key_up" then
|
||||||
|
@ -135,6 +147,8 @@ while true do
|
||||||
else
|
else
|
||||||
playDisc()
|
playDisc()
|
||||||
end
|
end
|
||||||
|
if name == "e" then
|
||||||
|
ejectDisc()
|
||||||
elseif name == "q" then
|
elseif name == "q" then
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1, 1)
|
term.setCursorPos(1, 1)
|
||||||
|
|
Loading…
Reference in a new issue