Fix aligning in orders, rename function
This commit is contained in:
parent
3289e07a89
commit
20e844488a
12
orders.lua
12
orders.lua
|
@ -49,13 +49,14 @@ local function drawEntry(win, obj)
|
||||||
win.write(obj.pos.x .. "," .. obj.pos.y .. "," .. obj.pos.z)
|
win.write(obj.pos.x .. "," .. obj.pos.y .. "," .. obj.pos.z)
|
||||||
win.write(" ")
|
win.write(" ")
|
||||||
end
|
end
|
||||||
|
local padding
|
||||||
if obj.res_status then
|
if obj.res_status then
|
||||||
winhlp.alignRight(win, #obj.res_status + 4)
|
padding = winhlp.alignRightPadding(win, #obj.res_status + 4)
|
||||||
win.write(" " .. obj.res_status)
|
win.write(" " .. obj.res_status)
|
||||||
else
|
else
|
||||||
winhlp.alignRight(win, 3)
|
padding = winhlp.alignRightPadding(win, 3)
|
||||||
end
|
end
|
||||||
win.write(" ")
|
win.write(string.format("%" .. padding+1 .. "s", " "))
|
||||||
if obj.claimed then
|
if obj.claimed then
|
||||||
win.setTextColor(colors.green)
|
win.setTextColor(colors.green)
|
||||||
win.write("C")
|
win.write("C")
|
||||||
|
@ -66,8 +67,9 @@ local function drawEntry(win, obj)
|
||||||
win.setTextColor(colors.gray)
|
win.setTextColor(colors.gray)
|
||||||
win.setCursorPos(1, 2)
|
win.setCursorPos(1, 2)
|
||||||
if obj.target then
|
if obj.target then
|
||||||
winhlp.alignRight(win, #obj.target + 1)
|
padding = winhlp.alignRightPadding(win, #obj.target + 1)
|
||||||
win.write(" " .. obj.target)
|
win.write(string.format("%" .. padding+1 .. "s", " "))
|
||||||
|
win.write(obj.target)
|
||||||
end
|
end
|
||||||
win.setTextColor(colors.white)
|
win.setTextColor(colors.white)
|
||||||
win.setCursorPos(1, 2)
|
win.setCursorPos(1, 2)
|
||||||
|
|
|
@ -64,7 +64,7 @@ local function drawLine(termlike, obj)
|
||||||
termlike.write(" ")
|
termlike.write(" ")
|
||||||
if obj.answer == nil then
|
if obj.answer == nil then
|
||||||
termlike.setTextColor(colors.orange)
|
termlike.setTextColor(colors.orange)
|
||||||
local padding = winhlp.alignRight(termlike, 5)
|
local padding = winhlp.alignRightPadding(termlike, 5)
|
||||||
termlike.write(string.format("%" .. padding+5 .. "s", " N/A "))
|
termlike.write(string.format("%" .. padding+5 .. "s", " N/A "))
|
||||||
else
|
else
|
||||||
if permset.has(allowed_items, obj.answer.name) then
|
if permset.has(allowed_items, obj.answer.name) then
|
||||||
|
@ -74,7 +74,7 @@ local function drawLine(termlike, obj)
|
||||||
end
|
end
|
||||||
termlike.write(obj.answer.name)
|
termlike.write(obj.answer.name)
|
||||||
termlike.setTextColor(colors.white)
|
termlike.setTextColor(colors.white)
|
||||||
local padding = winhlp.alignRight(termlike, 5)
|
local padding = winhlp.alignRightPadding(termlike, 5)
|
||||||
termlike.write(string.format("%" .. padding+2 .. "s", " ["))
|
termlike.write(string.format("%" .. padding+2 .. "s", " ["))
|
||||||
if permset.has(allowed_items, obj.answer.name) then
|
if permset.has(allowed_items, obj.answer.name) then
|
||||||
termlike.setTextColor(colors.green)
|
termlike.setTextColor(colors.green)
|
||||||
|
|
|
@ -15,7 +15,7 @@ local function setHeight(win, height)
|
||||||
win.reposition(winX, winY, sizeX, height)
|
win.reposition(winX, winY, sizeX, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function alignRight(termlike, length)
|
local function alignRightPadding(termlike, length)
|
||||||
local tw, th = termlike.getSize()
|
local tw, th = termlike.getSize()
|
||||||
local x, y = termlike.getCursorPos()
|
local x, y = termlike.getCursorPos()
|
||||||
termlike.setCursorPos(math.min(x, tw-length+1), y)
|
termlike.setCursorPos(math.min(x, tw-length+1), y)
|
||||||
|
@ -27,5 +27,5 @@ return {
|
||||||
translate=translate,
|
translate=translate,
|
||||||
contains=contains,
|
contains=contains,
|
||||||
setHeight=setHeight,
|
setHeight=setHeight,
|
||||||
alignRight=alignRight,
|
alignRightPadding=alignRightPadding,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue