1
0
Fork 0

Added status line and "not implemented" messages

This commit is contained in:
Casey 2023-10-20 04:58:34 +03:00
parent 3dbd27525a
commit b051d36bc0
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 58 additions and 35 deletions

View File

@ -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,13 +381,30 @@ 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)
if statusTicks <= 0 then
local speen = spinner[(math.floor(drive.getPosition() / 3000) % #spinner) + 1]
local action = ""
if drive.getState() == "PLAYING" then action = "Playing:"
@ -393,17 +415,8 @@ function()
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))
term.write(action)
-- Statusline text
term.setCursorPos(#action + 2, th)
@ -418,9 +431,12 @@ function()
term.write(txt:sub(off, off + w - 1))
end
end
end
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())