1
0
Fork 0
mirror of https://fem.mint.lgbt/m/Rhythmblock.git synced 2024-08-14 20:27:11 +00:00

added close button for mouse and monitor usage

This commit is contained in:
mint 2021-05-07 03:29:39 -04:00
parent e1791d8e9c
commit 0ea45bfc0b

View file

@ -45,22 +45,27 @@ function playDisc()
disk.playAudio(drive) disk.playAudio(drive)
renderStopButton() renderStopButton()
renderEjectButton() renderEjectButton()
renderCloseButton()
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() renderPlayButton()
renderEjectButton() renderEjectButton()
renderCloseButton()
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() renderPlayButton()
renderEjectButton() renderEjectButton()
renderCloseButton()
end end
end end
function ejectDisc() -- Ejects the disc! How cool is that? function ejectDisc() -- Ejects the disc! How cool is that?
term.clear()
renderPlayButton() renderPlayButton()
renderEjectButton() renderEjectButton()
renderCloseButton()
if playing == true then if playing == true then
stopDisc() stopDisc()
disk.eject() disk.eject()
@ -78,6 +83,7 @@ function stopDisc() -- Stops the music
term.clear() term.clear()
renderPlayButton() renderPlayButton()
renderEjectButton() renderEjectButton()
renderCloseButton()
end end
function renderPlayButton() -- Renders the Play button function renderPlayButton() -- Renders the Play button
@ -100,17 +106,25 @@ function renderEjectButton() -- Renders the Eject button
term.write(ejectText) term.write(ejectText)
end end
function statusRender(s) -- Resets the status position function statusRender(s) -- Renders the status bar
term.setCursorPos(1, 1) term.setCursorPos(1, 1)
term.setTextColor(textColor) term.setTextColor(textColor)
term.setBackgroundColor(backgroundColor) term.setBackgroundColor(backgroundColor)
term.write(s) term.write(s)
end end
function renderCloseButton() -- Renders the X button
term.setCurorPos(width, 1)
term.setTextColor(textColor)
term.setBackgroundColor(backgroundColor)
term.write("x")
end
term.clear() term.clear()
term.setBackgroundColor(backgroundColor) -- Setting the background color term.setBackgroundColor(backgroundColor) -- Setting the background color
renderPlayButton() -- Rendering the play button renderPlayButton() -- Rendering the play button
renderEjectButton() -- Rendering the eject button renderEjectButton() -- Rendering the eject button
renderCloseButton() -- Rendering the close button
status = defaultStatus -- Setting the value to the default status = defaultStatus -- Setting the value to the default
while true do while true do
@ -126,9 +140,12 @@ 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 elseif eventData[2] == 1 and eventData[3] == width and eventData[4] == 1 then
term.clear()
term.setCursorPos(1, 1)
return true
end
elseif event == "key_up" then elseif event == "key_up" then
local name = keys.getName(eventData[2]) or "unknown key" local name = keys.getName(eventData[2]) or "unknown key"
if name == "space" then if name == "space" then