fork/m-overlay

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

blackops7799More config file work (exporting/importing/defaults) Properly cleanup orphaned panels and "removed" panels SetZPos will now reorder the parents child panels MakePopup will take the place of the highest Z positioned panel29daa42

GUI
3.1 KiB145 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 test = gui.createScenePanel("MiniMap")
35
36	--[[local test = gui.createScenePanel("PlayerPercent")
37	test:SetPort(2)
38	test:SetSize(200, 128)]]
39
40	--gui.saveSceneLayout()
41
42	gui.loadConfig(gui.getDefaultConfig())
43end
44
45function love.update(dt)
46	gui.tick(dt)
47	watcher.update("Dolphin.exe") -- Look for Dolphin.exe
48end
49
50function love.resize(w, h)
51	gui.resize(w, h)
52end
53
54function love.joystickpressed(joy, but)
55	gui.joyPressed(joy, but)
56end
57
58function love.joystickreleased(joy, but)
59	gui.joyReleased(joy, but)
60end
61
62function love.keypressed(key, scancode, isrepeat)
63	gui.keyPressed(key, scancode, isrepeat)
64end
65
66function love.keyreleased(key)
67	gui.keyReleased(key)
68end
69
70function love.textinput(text)
71	gui.textInput(text)
72end
73
74function love.mousemoved(x, y, dx, dy, istouch)
75	gui.mouseMoved(x, y, dx, dy, istouch)
76end
77
78function love.mousepressed(x, y, button, istouch, presses)
79	gui.mousePressed(x, y, button, istouch, presses)
80end
81
82function love.mousereleased(x, y, button, istouch, presses)
83	gui.mouseReleased(x, y, button, istouch, presses)
84end
85
86function love.wheelmoved(x, y)
87	gui.mouseWheeled(x, y)
88end
89
90function love.draw()	
91	gui.render()
92end
93
94function love.quit()
95	gui.shutdown()
96end
97
98local FPS_LIMIT = 60
99
100function love.run()
101	if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
102 
103	-- We don't want the first frame's dt to include time taken by love.load.
104	if love.timer then love.timer.step() end
105 
106	local dt = 0
107 
108	-- Main loop time.
109	return function()
110		local frame_start = love.timer.getTime()
111
112		-- Process events.
113		if love.event then
114			love.event.pump()
115			for name, a,b,c,d,e,f in love.event.poll() do
116				if name == "quit" then
117					if not love.quit or not love.quit() then
118						return a or 0
119					end
120				end
121				love.handlers[name](a,b,c,d,e,f)
122			end
123		end
124 
125		-- Update dt, as we'll be passing it to update
126		if love.timer then dt = love.timer.step() end
127 
128		-- Call update and draw
129		if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
130 
131		if love.graphics and love.graphics.isActive() then
132			love.graphics.origin()
133			love.graphics.clear(love.graphics.getBackgroundColor())
134 
135			if love.draw then love.draw() end
136 
137			love.graphics.present()
138		end
139 
140		if love.timer then
141			local frame_time = love.timer.getTime() - frame_start
142			love.timer.sleep(1 / FPS_LIMIT- frame_time)
143		end
144	end
145end