Added status line and "not implemented" messages
This commit is contained in:
parent
3dbd27525a
commit
b051d36bc0
|
@ -166,6 +166,10 @@ end):gmatch("[^\n]+") do
|
|||
table.insert(help, line)
|
||||
end
|
||||
|
||||
local statusText, statusTicks = nil, 0
|
||||
local function setStatus(txt, ticks)
|
||||
statusText, statusTicks = txt, ticks or 10
|
||||
end
|
||||
|
||||
local mplayer = {
|
||||
colors = {
|
||||
|
@ -306,6 +310,7 @@ local mplayer = {
|
|||
render = function(self)
|
||||
term.clear()
|
||||
term.write(string.format("opt = %d, scroll = %d", self.screens[3].cursor, self.screens[3].scroll))
|
||||
term.write(" // TODO")
|
||||
end,
|
||||
handleKey = function(self, key, repeating)
|
||||
if key == keys.down or key == keys.j then
|
||||
|
@ -376,51 +381,62 @@ function()
|
|||
title = song.title
|
||||
end
|
||||
|
||||
-- Statusline
|
||||
term.setCursorPos(1, th)
|
||||
-- Progressbar
|
||||
local lw = math.floor(tw * time / duration)
|
||||
term.setCursorPos(1, th - 1)
|
||||
term.setTextColor(mplayer.colors.current)
|
||||
term.clearLine()
|
||||
term.write(string.rep("=", lw))
|
||||
term.write("\x10")
|
||||
term.setTextColor(mplayer.colors.cursor)
|
||||
term.write(string.rep("\xad", tw - lw - 1))
|
||||
|
||||
local timeString = string.format("[%s:%s]", time2str(time), time2str(duration))
|
||||
|
||||
term.setCursorPos(1, th)
|
||||
term.clearLine()
|
||||
if statusTicks > 0 then
|
||||
term.setTextColor(colors.red)
|
||||
term.write(statusText)
|
||||
statusTicks = statusTicks - 1
|
||||
end
|
||||
|
||||
if drive.getState() ~= "STOPPED" then
|
||||
term.setTextColor(mplayer.colors.status)
|
||||
local speen = spinner[(math.floor(drive.getPosition() / 3000) % #spinner) + 1]
|
||||
local action = ""
|
||||
if drive.getState() == "PLAYING" then action = "Playing:"
|
||||
elseif drive.getState() == "REWINDING" then action = "Rewinding"
|
||||
elseif drive.getState() == "FORWARDING" then action = "Forwarding"
|
||||
else
|
||||
printError("Unknown drive state: "..tostring(drive.getState()))
|
||||
return
|
||||
end
|
||||
action = speen .. " " .. action
|
||||
term.write(action)
|
||||
|
||||
-- Progressbar
|
||||
local lw = math.floor(tw * time / duration)
|
||||
term.setCursorPos(1, th - 1)
|
||||
term.setTextColor(mplayer.colors.current)
|
||||
term.clearLine()
|
||||
term.write(string.rep("=", lw))
|
||||
term.write("\x10")
|
||||
term.setTextColor(mplayer.colors.cursor)
|
||||
term.write(string.rep("\xad", tw - lw - 1))
|
||||
if statusTicks <= 0 then
|
||||
local speen = spinner[(math.floor(drive.getPosition() / 3000) % #spinner) + 1]
|
||||
local action = ""
|
||||
if drive.getState() == "PLAYING" then action = "Playing:"
|
||||
elseif drive.getState() == "REWINDING" then action = "Rewinding"
|
||||
elseif drive.getState() == "FORWARDING" then action = "Forwarding"
|
||||
else
|
||||
printError("Unknown drive state: "..tostring(drive.getState()))
|
||||
return
|
||||
end
|
||||
action = speen .. " " .. action
|
||||
|
||||
-- Statusline text
|
||||
term.setCursorPos(#action + 2, th)
|
||||
local w = tw - #timeString - #action - 2 -- "Playing: ", spinner plus spacing
|
||||
term.write(action)
|
||||
|
||||
term.setTextColor(mplayer.colors.current)
|
||||
if #title <= w then
|
||||
term.write(title)
|
||||
else
|
||||
local off = (mplayer.statusLineScroll % (#title + 5)) + 1
|
||||
local txt = title .. " ::: " .. title
|
||||
term.write(txt:sub(off, off + w - 1))
|
||||
-- Statusline text
|
||||
term.setCursorPos(#action + 2, th)
|
||||
local w = tw - #timeString - #action - 2 -- "Playing: ", spinner plus spacing
|
||||
|
||||
term.setTextColor(mplayer.colors.current)
|
||||
if #title <= w then
|
||||
term.write(title)
|
||||
else
|
||||
local off = (mplayer.statusLineScroll % (#title + 5)) + 1
|
||||
local txt = title .. " ::: " .. title
|
||||
term.write(txt:sub(off, off + w - 1))
|
||||
end
|
||||
end
|
||||
end
|
||||
term.setTextColor(mplayer.colors.status)
|
||||
term.setCursorPos(tw - #timeString + 1, th)
|
||||
term.write(timeString)
|
||||
if statusTicks <= 0 then
|
||||
term.setTextColor(mplayer.colors.status)
|
||||
term.setCursorPos(tw - #timeString + 1, th)
|
||||
term.write(timeString)
|
||||
end
|
||||
os.sleep(0.1)
|
||||
end
|
||||
end,
|
||||
|
@ -435,6 +451,9 @@ function()
|
|||
mplayer.heldKeys[evd[1]] = nil
|
||||
end
|
||||
|
||||
local shiftHeld = mplayer.heldKeys[keys.leftShift] ~= nil or mplayer.heldKeys[keys.rightShift] ~= nil
|
||||
local ctrlHeld = mplayer.heldKeys[keys.leftCtrl] ~= nil or mplayer.heldKeys[keys.rightCtrl] ~= nil
|
||||
|
||||
if ev == "key_up" and evd[1] == keys.q then
|
||||
break
|
||||
elseif ev == "key" and (evd[1] == keys.one or evd[1] == keys.f1) then
|
||||
|
@ -447,6 +466,10 @@ function()
|
|||
drive.seek(3000)
|
||||
elseif ev == "key" and evd[1] == keys.b then
|
||||
drive.seek(-3000)
|
||||
elseif ev == "key" and (evd[1] == keys.comma or evd[1] == keys.period) and shiftHeld then
|
||||
setStatus("Not implemented yet!", 20)
|
||||
elseif ev == "key" and evd[1] == keys.left or evd[1] == keys.right or evd[1] == keys.minus or (evd[1] == keys.equals and shiftHeld) then
|
||||
setStatus("Not implemented yet!", 20)
|
||||
elseif ev == "key" and evd[1] == keys.s then
|
||||
drive.stop()
|
||||
drive.seek(-drive.getSize())
|
||||
|
|
Loading…
Reference in New Issue