SudokuLua/ui/draw.lua
2020-05-22 05:29:43 +04:30

82 lines
2.7 KiB
Lua

require "ui.globals"
require "ui.colors"
function drawGrid()
love.graphics.setLineWidth(1)
setColor(colors.boardThinLines)
for i = 1, 6 do
love.graphics.line(grid.vline[i].x1, grid.vline[i].y1, grid.vline[i].x2, grid.vline[i].y2)
love.graphics.line(grid.hline[i].x1, grid.hline[i].y1, grid.hline[i].x2, grid.hline[i].y2)
end
love.graphics.setLineWidth(2)
setColor(colors.boardThikLines)
for i = 1, 4 do
love.graphics.line(grid.vbline[i].x1, grid.vbline[i].y1, grid.vbline[i].x2, grid.vbline[i].y2)
love.graphics.line(grid.hbline[i].x1, grid.hbline[i].y1, grid.hbline[i].x2, grid.hbline[i].y2)
end
end
function drawSmallNumbers()
love.graphics.setFont(fonts.smallNum)
for x = 1, 9 do
for y = 1, 9 do
for i = 1, 9 do
if uiBoard[2][y][x] == 0 then
local x1 = smallNumbers[x][y][i].x
local y1 = smallNumbers[x][y][i].y
if smallNumbersVal[x][y][i] then
setColor(colors.smallNumbersEnabled)
else
setColor(colors.smallNumbersDisabled)
end
love.graphics.print(tostring(i), x1, y1)
end
end
end
end
end
function drawBigNumbers()
for x = 1, 9 do
for y = 1, 9 do
if uiBoard[1][x][y] ~= 0 then
local c = tostring(uiBoard[1][x][y])
love.graphics.setFont(fonts.bigNumbersOriginal)
setColor(colors.bigNumbersOriginal)
love.graphics.print(c, grid[y][x].x1+25, grid[y][x].y1+10)
elseif uiBoard[2][x][y] ~= 0 then
local c = tostring(uiBoard[2][x][y])
love.graphics.setFont(fonts.bigNumbersPlayer)
setColor(colors.bigNumbersPlayer)
love.graphics.print(c, grid[y][x].x1+33, grid[y][x].y1+15)
end
end
end
end
function drawCursor()
local x = grid[cursor.x][cursor.y].x1
local y = grid[cursor.x][cursor.y].y1
if uiBoard[1][cursor.y][cursor.x] == 0 then
if cursor.editMode then
setColor(colors.cursorActiveSmall)
else
setColor(colors.cursorActiveBig)
end
else
setColor(colors.cursorDisabled)
end
love.graphics.setLineWidth(3)
love.graphics.rectangle("line", x+3, y+3, cell.width-6, cell.height-6, 10, 10)
end
function drawMessages()
setColor(colors.backGround)
love.graphics.rectangle("fill", 25, 150, grid.x1- 25 - 2, grid.y2 - grid.y1)
setColor(colors.messagesText)
love.graphics.setFont(fonts.info)
for i, msg in ipairs(messages) do
love.graphics.print(msg, 25, 150 + 24 * (i-1))
end
end