-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.lua
More file actions
95 lines (77 loc) · 2.31 KB
/
setup.lua
File metadata and controls
95 lines (77 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
-- ------ config
window = {
width = 640,
height = 480,
open_x = 200,
open_y = 200
}
love.keyboard.setKeyRepeat(true)
love.window.setMode(window.width, window.height,
{borderless=true, highdpi=true})
ww, wh = love.graphics.getDimensions()
wx, wy = love.window.getPosition()
fg = {color = {0, 0, 0}}
bg = {
enabled = true,
color = {1, 1, 1},
border = {
enabled = true,
color = {0,0,0},
width = 2}}
--[[
console.FONT_SIZE = 22
typeface = love.graphics.newFont("/resources/Blex Mono.ttf", fontsize)
Fira = love.graphics.newFont("/resources/Fira Code.ttf", console.FONT_SIZE)
Iosevka = love.graphics.newFont("/resources/Iosevka.ttf", console.FONT_SIZE)
Blex = love.graphics.newFont("/resources/Blex Mono.ttf", console.FONT_SIZE)
console.FONT = Fira
]]--
-- Set up pixel perfection
love.graphics.setDefaultFilter("nearest", "nearest", 1)
love.graphics.setLineStyle("rough")
love.graphics.setLineWidth(1)
-- ------ window dragging
handle = {
height = 20,
width = 20,
x = ww - 20,
y = 0,
r = 0.5,
g = 0.5,
b = 0.5,
a = 0.4,
hover = false
}
local cursor = love.mouse.getSystemCursor('sizeall')
local function inside_handle(x, y)
return x > handle.x and x < handle.x + handle.width
and y > handle.y and y < handle.y + handle.height
end
function love.mousemoved(x, y, dx, dy)
if draggable.dragging() or inside_handle(x, y) then
handle.hover = true
love.mouse.setCursor(cursor)
else
handle.hover = false
love.mouse.setCursor()
end
draggable.move(dx, dy)
end
function love.mousepressed(x, y, button)
if inside_handle(x, y) then
draggable.start()
end
end
function love.mousereleased(x, y, button)
draggable.stop()
end
draw_border = function(...)
love.graphics.setColor(unpack(bg.border.color))
love.graphics.rectangle("fill", 0, 0, ww, wh)
love.graphics.setColor(unpack(bg.color))
love.graphics.rectangle("fill", bg.border.width, bg.border.width, ww - bg.border.width*2, wh - bg.border.width*2, bg.border.radius, bg.border.segments)
end
draw_handle = function(...)
love.graphics.setColor(handle.r, handle.g, handle.b, handle.a)
love.graphics.polygon("fill", handle.x, handle.y, handle.x + handle.width, handle.y, handle.x+handle.width, handle.y + handle.height)
end