Added better formatting.

This commit is contained in:
Andrew Lalis 2023-08-29 18:28:16 -04:00
parent 67d56fb8be
commit b4ba496a32
1 changed files with 8 additions and 8 deletions

16
atm.lua
View File

@ -159,19 +159,19 @@ local function showAccountsUI()
drawFrame() drawFrame()
g.drawXLine(term, 1, 19, 2, colors.gray) g.drawXLine(term, 1, 19, 2, colors.gray)
g.drawText(term, 2, 2, "Account", colors.white, colors.gray) g.drawText(term, 2, 2, "Account", colors.white, colors.gray)
g.drawXLine(term, 20, 40, 2, colors.lightGray) g.drawXLine(term, 10, 30, 2, colors.lightGray)
g.drawText(term, 21, 2, "Name", colors.white, colors.lightGray) g.drawText(term, 11, 2, "Name", colors.white, colors.lightGray)
g.drawXLine(term, 41, W, 2, colors.gray) g.drawXLine(term, 31, W, 2, colors.gray)
g.drawText(term, 42, 2, "Balance ($HMK)", colors.white, colors.gray) g.drawText(term, 32, 2, "Balance ($HMK)", colors.white, colors.gray)
for i, account in pairs(accounts) do for i, account in pairs(accounts) do
local bg = colors.blue local bg = colors.blue
if i % 2 == 0 then bg = colors.lightBlue end if i % 2 == 0 then bg = colors.lightBlue end
local fg = colors.white local fg = colors.white
local y = i + 2 local y = i + 2
g.drawXLine(term, 1, W, y, bg) g.drawXLine(term, 1, W, y, bg)
g.drawText(term, 1, y, account.id, fg, bg) g.drawText(term, 2, y, "..." .. string.sub(account.id, -5, -1), fg, bg)
g.drawText(term, 20, y, account.name, fg, bg) g.drawText(term, 11, y, account.name, fg, bg)
g.drawText(term, 41, y, tostring(account.balance), fg, bg) g.drawText(term, 32, y, tostring(account.balance), fg, bg)
end end
local event, button, x, y = os.pullEvent("mouse_click") local event, button, x, y = os.pullEvent("mouse_click")
if button == 1 and y > 2 and (y - 2) <= #accounts then if button == 1 and y > 2 and (y - 2) <= #accounts then
@ -184,7 +184,7 @@ while true do
local credentials = showLoginUI() local credentials = showLoginUI()
local loginSuccess = checkCredentialsUI(credentials) local loginSuccess = checkCredentialsUI(credentials)
if loginSuccess then if loginSuccess then
print("Login success!") showAccountsUI()
end end
return return
end end