-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lua
84 lines (64 loc) · 1.71 KB
/
main.lua
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
io.stdout:setvbuf("no")
require "love_run"
vector = require "lib.vec2xy"
input = require "input"
VERSION = "2.2"
BASE_WINDOW_TITLE = ("Multiviewer %s - "):format(VERSION)
local Camera = require "lib.Camera"
local Editor = require "Editor"
local backgroundColor = { 0.2, 0.2, 0.2 }
local editor
camera = nil
function love.load(arg)
love.window.setTitle(BASE_WINDOW_TITLE .. "No project")
love.graphics.setDefaultFilter("nearest", "nearest")
love.graphics.setBackgroundColor(backgroundColor)
local font = love.graphics.newFont("font/source/OpenSans-Semibold.ttf", 15)
love.graphics.setFont(font)
for i,binding in ipairs(require("input_bindings")) do
input.bind(unpack(binding))
end
love.window.maximize()
camera = Camera(0, 0, 0, nil, "expand view")
editor = Editor()
editor:init()
editor:update(0.01)
if arg[1] then
editor:openProjectFile(arg[1])
end
end
function input.callback(name, change)
editor:input(name, change)
end
local droppedFiles
function love.update(dt)
if droppedFiles then
editor:filesDropped(droppedFiles)
droppedFiles = nil
end
editor:update(dt)
end
function love.draw()
camera:applyTransform()
editor:draw()
camera:resetTransform()
end
function love.filedropped(file)
droppedFiles = droppedFiles or {}
table.insert(droppedFiles, file)
end
function love.directorydropped(absDirPath)
editor:directoryDropped(absDirPath)
end
function love.resize(w, h)
camera:setViewport(0, 0, w, h)
shouldUpdate = true
end
function love.focus(focus)
if focus then shouldUpdate = true end
end
function love.mousemoved(x, y, dx, dy, istouch)
if love.window.hasFocus() then
shouldUpdate = true
end
end