fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

blackops7799Merge APM counter into controller display Lots of small fixes and stuff650c9b1

gui
3.2 KiB147 linesraw
1love.filesystem.setRequirePath("?.lua;?/init.lua;modules/?.lua;modules/?/init.lua")
2
3require("errorhandler")
4
5require("extensions.love")
6require("util.color")
7
8local watcher = require("memory.watcher")
9local gui = require("gui")
10local icons = require("smash.icons")
11
12local graphics = love.graphics
13
14function love.load()
15	graphics.setBackgroundColor(0, 0, 0, 0) -- Transparent background for OBS
16	love.window.setTitle("M'Overlay - Waiting for Dolphin.exe")
17
18	gui.init()
19	watcher.init()
20	icons.init()
21
22	local display = gui.createScenePanel("ControllerDisplay")
23	display:SetPort(1)
24
25	--[[local test = gui.createScenePanel("Label")
26	test:SetFont("fonts/A-OTF-FolkPro-Heavy.otf")
27	test:SetBGColor(color_white)
28	test:SetText("THIS IS A TEST OVERLAY ELEMENT")
29	test:SizeToText()]]
30
31	--local test = gui.createScenePanel("PlayerPercent")
32	--test:SetPort(1)
33
34	local map = gui.createScenePanel("MiniMap")
35
36	local test = gui.createScenePanel("KillFeed")
37
38	--[[local test = gui.createScenePanel("PlayerPercent")
39	test:SetPort(2)
40	test:SetSize(200, 128)]]
41
42	--gui.saveSceneLayout()
43
44	--gui.loadConfig(gui.getDefaultConfig())
45end
46
47function love.update(dt)
48	gui.tick(dt)
49	watcher.update("Dolphin.exe") -- Look for Dolphin.exe
50end
51
52function love.resize(w, h)
53	gui.resize(w, h)
54end
55
56function love.joystickpressed(joy, but)
57	gui.joyPressed(joy, but)
58end
59
60function love.joystickreleased(joy, but)
61	gui.joyReleased(joy, but)
62end
63
64function love.keypressed(key, scancode, isrepeat)
65	gui.keyPressed(key, scancode, isrepeat)
66end
67
68function love.keyreleased(key)
69	gui.keyReleased(key)
70end
71
72function love.textinput(text)
73	gui.textInput(text)
74end
75
76function love.mousemoved(x, y, dx, dy, istouch)
77	gui.mouseMoved(x, y, dx, dy, istouch)
78end
79
80function love.mousepressed(x, y, button, istouch, presses)
81	gui.mousePressed(x, y, button, istouch, presses)
82end
83
84function love.mousereleased(x, y, button, istouch, presses)
85	gui.mouseReleased(x, y, button, istouch, presses)
86end
87
88function love.wheelmoved(x, y)
89	gui.mouseWheeled(x, y)
90end
91
92function love.draw()	
93	gui.render()
94end
95
96function love.quit()
97	gui.shutdown()
98end
99
100local FPS_LIMIT = 60
101
102function love.run()
103	if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
104 
105	-- We don't want the first frame's dt to include time taken by love.load.
106	if love.timer then love.timer.step() end
107 
108	local dt = 0
109 
110	-- Main loop time.
111	return function()
112		local frame_start = love.timer.getTime()
113
114		-- Process events.
115		if love.event then
116			love.event.pump()
117			for name, a,b,c,d,e,f in love.event.poll() do
118				if name == "quit" then
119					if not love.quit or not love.quit() then
120						return a or 0
121					end
122				end
123				love.handlers[name](a,b,c,d,e,f)
124			end
125		end
126 
127		-- Update dt, as we'll be passing it to update
128		if love.timer then dt = love.timer.step() end
129 
130		-- Call update and draw
131		if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
132 
133		if love.graphics and love.graphics.isActive() then
134			love.graphics.origin()
135			love.graphics.clear(love.graphics.getBackgroundColor())
136 
137			if love.draw then love.draw() end
138 
139			love.graphics.present()
140		end
141 
142		if love.timer then
143			local frame_time = love.timer.getTime() - frame_start
144			love.timer.sleep(1 / FPS_LIMIT- frame_time)
145		end
146	end
147end