fork/m-overlay

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

BkacjiosBugfixes + Dark Mode skina8034e9

v2.1.6
21.3 KiB817 linesraw
1love.filesystem.setRequirePath("?.lua;?/init.lua;modules/?.lua;modules/?/init.lua")
2
3math.randomseed(love.timer.getTime())
4
5local VERSION
6
7if love.filesystem.getInfo("version.txt") then
8	-- Read version file and strip any trailing whitespace
9	VERSION = love.filesystem.read("version.txt"):match("^(%S+)")
10end
11
12function love.getMOverlayVersion()
13	return VERSION or "0.0.0"
14end
15
16require("console")
17require("errorhandler")
18require("extensions.love")
19
20local log = require("log")
21local melee = require("melee")
22local zce = require("zce")
23local memory = require("memory")
24local notification = require("notification")
25
26local overlay = require("overlay")
27local music = require("music")
28
29local color = require("util.color")
30local gui = require("gui")
31
32local ease = require("ease")
33
34local web = require("web")
35local downloader = require("downloader")
36
37local graphics = love.graphics
38local newImage = graphics.newImage
39
40local PORT_FONT = graphics.newFont("fonts/melee-bold.otf", 42)
41local WAITING_FONT = graphics.newFont("fonts/melee-bold.otf", 24)
42local DEBUG_FONT = graphics.newFont("fonts/melee-bold.otf", 12)
43
44local GRADIENT = newImage("textures/gui/gradient.png")
45local DOLPHIN = newImage("textures/dolphin.png")
46local GAME = newImage("textures/game.png")
47local MELEE = newImage("textures/meleedisk.png")
48local MELEELABEL = newImage("textures/meleedisklabel.png")
49local SHADOW = newImage("textures/shadow.png")
50local KEY = newImage("textures/key.png")
51
52local ESCAPE_MENU_HINT = love.timer.getTime() + 5
53local ESCAPE_MENU_HINT_FADE = ESCAPE_MENU_HINT + 1
54
55MAX_PORTS = 4
56
57local PORT_DISPLAY_OVERRIDE = nil
58
59local PORT_TEXTURES = {
60	[1] = newImage("textures/player1_color.png"),
61	[2] = newImage("textures/player2_color.png"),
62	[3] = newImage("textures/player3_color.png"),
63	[4] = newImage("textures/player4_color.png")
64}
65
66local CODE_ENTERED = false
67
68local CODE_POSITION = {
69	[1] = 1,
70	[2] = 1,
71	[3] = 1,
72	[4] = 1
73}
74
75local CODE = { -- Konami code
76	0x0008, 0x0008,
77	0x0004, 0x0004,
78	0x0001, 0x0002,
79	0x0001, 0x0002,
80	0x0200, 0x0100, 0x1000
81}
82
83--[[local CODE2 = { -- Konami code using joysticks
84	0x10000, 0x10000,
85	0x20000, 0x20000,
86	0x40000, 0x80000,
87	0x40000, 0x80000,
88	0x0200, 0x0100, 0x1000
89}]]
90
91local portless_title = ""
92function love.updateTitle(str)
93	local title = str
94	portless_title = str
95	if PANEL_SETTINGS:IsPortTitleEnabled() then
96		title = string.format("%s (Port %d)", str, overlay.getPort())
97	end
98	love.window.setTitle(title)
99	--love.window.setMode(1280, 720, nil)
100end
101
102function love.getTitleNoPort()
103	return portless_title
104end
105
106memory.hook("romstring.akaneia", "Load Game Specific Textures", function(romname, romvalue)
107	melee.loadRomSpecificTextures()
108end)
109
110function love.load(args, unfilteredArg)
111	love.keyboard.setKeyRepeat(true)
112
113	melee.loadTextures()
114	gui.init()
115	music.init()
116	overlay.init()
117
118	if memory.hasPermissions() then
119		love.updateTitle("M'Overlay - Waiting for Dolphin...")
120	else
121		love.updateTitle("M'Overlay - Invalid permissions...")
122		--notification.error()
123	end
124
125	-- Loop through all the commandline arguments
126	for n, arg in pairs(args) do
127		 -- Check for '--port=N' first..
128		local portn = tonumber(string.match(arg, "%-%-port=(%d+)"))
129
130		if arg == "--port" then -- Alternative '--port N'
131			portn = tonumber(args[n+1]) -- Convert the next argument in the commandline to a number
132		elseif arg == "--sublime" then
133			-- Running through sublime text
134			_SUBLIME_TEXT = true
135			log.color = false
136		end
137
138		if portn then -- A port number was specified..
139			overlay.setPort(portn)
140			break -- Done
141		end
142	end
143
144	log.debug("M'Overlay (%s)", love.getMOverlayVersion())
145	log.debug(string.format("Love2D %d.%d.%d - %s", love.getVersion()))
146	log.debug("%s (%s - %s)", _VERSION, jit.version, jit.arch)
147	log.debug("System: %s", jit.os)
148
149	local renderer, version, vendor, device = love.graphics.getRendererInfo()
150
151	log.debug("Renderer: %s (%s)", renderer, version)
152	log.debug("Graphics: %s (%s)", vendor, device)
153end
154
155memory.hook("menu.player_one_port", "Controller port that is acting as player 1", function(port)
156	if melee.isSinglePlayerGame() or (memory.scene.major == SCENE_VS_ONLINE and PANEL_SETTINGS:IsSlippiNetplay()) then
157		overlay.setPort(port+1)
158		log.debug("[AUTOPORT] Player \"one\" port changed %d", overlay.getPort())
159	end
160end)
161
162memory.hook("scene.major", "Slippi Auto Port Switcher", function(major)
163	if melee.isSinglePlayerGame() or (major == SCENE_VS_ONLINE and PANEL_SETTINGS:IsSlippiNetplay()) then
164		-- Switch back to whatever controller is controlling port 1, when not in a match
165		overlay.setPort(memory.menu.player_one_port+1)
166		log.debug("[AUTOPORT] Forcing port %d in menus", overlay.getPort())
167	end
168end)
169
170memory.hook("scene.minor", "Slippi Auto Port Switcher", function(minor)
171	-- SCENE_VS_ONLINE = Slippi online
172	if memory.scene.major == SCENE_VS_ONLINE and PANEL_SETTINGS:IsSlippiNetplay() then
173		if minor == SCENE_VS_ONLINE_CSS or menu == SCENE_VS_ONLINE_SSS then
174			-- Switch back to whatever controller is controlling port 1, when not in a match
175			overlay.setPort(memory.menu.player_one_port+1)
176			log.debug("[AUTOPORT] Forcing port %d in menus", overlay.getPort())
177			if minor == SCENE_VS_ONLINE_CSS then
178				-- Display the port info only when swiching back to CSS
179				overlay.showPort(1.5) -- Show the port display number for 1.5 seconds
180			end
181		elseif minor == SCENE_VS_ONLINE_VERSUS then
182			PORT_DISPLAY_OVERRIDE = (memory.slippi.local_player.index % MAX_PORTS) + 1
183			overlay.showPort(3) -- Show the port display number for 3 seconds
184			log.debug("[AUTOPORT] Switching display icon to use port %d", overlay.getPort())
185		elseif minor == SCENE_VS_ONLINE_INGAME then
186			-- Switch to the local player index whenever else
187			PORT_DISPLAY_OVERRIDE = nil
188			overlay.setPort(memory.slippi.local_player.index+1)
189			log.debug("[AUTOPORT] Switching to slippi local player index %d", overlay.getPort())
190		end
191	end
192end)
193
194memory.hook("player.*.character", "Show port on character select", function(port, character)
195	if memory.scene.minor == SCENE_VS_CSS and port == overlay.getPort() then
196		overlay.showPort(1.5) -- Show the port display number for 1.5 seconds
197	end
198end)
199
200do
201	local snd = love.audio.newSource("sounds/blip.ogg", "static")
202
203	memory.hook("controller.*.buttons.pressed", "Konami code check", function(port, pressed)
204		if pressed == 0x0 or port ~= overlay.getPort() then return end
205		local pos = CODE_POSITION[port]
206		if CODE[pos] == pressed then
207			CODE_POSITION[port] = pos + 1
208			if pos >= #CODE then
209				CODE_ENTERED = not CODE_ENTERED
210				snd:setVolume(0.25)
211				snd:setPitch(CODE_ENTERED and 1 or 0.75)
212				snd:play()
213				log.warn("[KONAMI] %s developer stats..", CODE_ENTERED and "Showing" or "Hiding")
214			end
215		else
216			CODE_POSITION[port] = 1
217		end
218	end)
219end
220
221function love.update(dt)
222	web.update()
223	downloader.update()
224	music.update()
225	memory.update() -- Look for Dolphin.exe
226	notification.update(8, 0)
227	gui.update(dt)
228end
229
230function love.resize(w, h)
231	gui.resize(w, h)
232end
233
234function love.joystickpressed(joy, but)
235	gui.joyPressed(joy, but)
236end
237
238function love.joystickreleased(joy, but)
239	gui.joyReleased(joy, but)
240end
241
242function love.keypressed(key, scancode, isrepeat)
243	if key == "escape" and not isrepeat then
244		PANEL_SETTINGS:Toggle()
245		ESCAPE_MENU_HINT = nil
246		ESCAPE_MENU_HINT_FADE = nil
247	end
248
249	gui.keyPressed(key, scancode, isrepeat)
250
251	local num = tonumber(string.match(key, "kp(%d)") or key)
252
253	if not PANEL_SETTINGS:IsVisible() and num and num >= 1 and num <= 4 then
254		overlay.setPort(num)
255		PORT_DISPLAY_OVERRIDE = nil
256		overlay.showPort(1.5) -- Show the port display number for 1.5 seconds
257	end
258end
259
260function love.keyreleased(key)
261	gui.keyReleased(key)
262end
263
264function love.textinput(text)
265	gui.textInput(text)
266end
267
268function love.mousemoved(x, y, dx, dy, istouch)
269	gui.mouseMoved(x, y, dx, dy, istouch)
270end
271
272function love.mousepressed(x, y, button, istouch, presses)
273	gui.mousePressed(x, y, button, istouch, presses)
274end
275
276function love.mousereleased(x, y, button, istouch, presses)
277	gui.mouseReleased(x, y, button, istouch, presses)
278end
279
280function love.wheelmoved(x, y)
281	if PANEL_SETTINGS:IsVisible() then
282		gui.mouseWheeled(x, y)
283		return
284	end
285
286	local port = overlay.getPort()
287	
288	if y > 0 then
289		port = port - 1
290	elseif y < 0 then
291		port = port + 1
292	end
293	overlay.setPort(port)
294	overlay.showPort(1.5)
295	PORT_DISPLAY_OVERRIDE = nil
296end
297
298local DEBUG_SORT_KEYS
299
300function love.drawDeveloperInfo()
301	local stats = love.graphics.getStats()
302	stats.memory = collectgarbage("count")
303	stats.fps = love.timer.getFPS()
304
305	if not DEBUG_SORT_KEYS then
306		DEBUG_SORT_KEYS = table.keys(stats)
307		table.sort(DEBUG_SORT_KEYS)
308	end
309
310	graphics.setFont(DEBUG_FONT)
311	local i = 0
312	for i, stat in ipairs(DEBUG_SORT_KEYS) do
313		local val = stats[stat]
314
315		local str
316
317		if stat == "memory" or stat == "texturememory" then
318			str = string.format("%s: %s", stat, string.toSize(val))
319		else
320			str = string.format("%s: %d", stat, val)
321		end
322
323		graphics.setColor(0, 0, 0, 255)
324		graphics.textOutline(str, 2, 8, 8 + 14 * i)
325		graphics.setColor(0, 255, 0, 255)
326		graphics.print(str, 8, 8 + 14 * i)
327
328		i = i + 1
329	end
330end
331
332local DC_CON = newImage("textures/buttons/disconnected.png")
333
334function love.drawControllerOverlay()
335	local controller
336	local port = overlay.getPort()
337
338	-- Check if ZCE (dynamic controller address swapping)
339	if zce.isZce() then
340		if zce.isOot() then
341			controller = memory.controller.oot[port]
342		elseif zce.isMajora() then
343			controller = memory.controller.mm[port]
344		elseif zce.isZ1() then
345			controller = memory.controller.z1[port]
346		elseif zce.isZ2() then
347			controller = memory.controller.z2[port]
348		else
349			controller = memory.controller.menu[port]
350		end
351	else
352		controller = memory.controller[port]
353	end
354
355	if PANEL_SETTINGS:IsSlippiReplay() and melee.isInGame() then
356		local player = memory.player[port]
357
358		if not player then return end
359
360		local entity
361
362		if player.transformed == 256 then
363			-- If the player has the "transformed" flag set, assume they are now controlling the "partner" entity
364			entity = player.partner
365		else
366			entity = player.entity
367		end
368		
369		controller = entity.controller
370	end
371
372	if controller then
373		if controller.plugged and controller.plugged ~= (memory.game.pluggedValue or 0x00) then
374			local sin = 128 + math.sin(love.timer.getTime()*2) * 128
375			graphics.setColor(255, 0, 0, sin)
376			graphics.easyDraw(DC_CON, 512-42-16, 256-42-42, 0, 42, 42)
377		end
378
379		overlay.draw(controller)
380
381		if PANEL_SETTINGS:GetDebuggingInputFlags() > 0 then
382			local x, y = memory.game.translateJoyStick(controller.joystick.x, controller.joystick.y)
383			local cx, cy = memory.game.translateCStick(controller.cstick.x, controller.cstick.y)
384			local a = 0
385			local l, r = 0, 0
386
387			local xoff = 0
388			
389			graphics.setFont(DEBUG_FONT)
390
391			if PANEL_SETTINGS:IsDebuggingTriggers() then
392				if PANEL_SETTINGS:IsSlippiReplay() and melee.isInGame() then
393					a = controller.analog and controller.analog.float or 0
394
395					local stra = ("A: % f"):format(a)
396
397					xoff = xoff + DEBUG_FONT:getWidth(stra) + 8
398
399					graphics.setColor(0, 0, 0, 255)
400					graphics.textOutline(stra, 2, 512 - xoff, 256 - 4 - 12)
401
402					graphics.setColor(255, 255, 255, 255)
403					graphics.print(stra, 512 - xoff, 256 - 4 - 12)
404				else
405					l, r = memory.game.translateTriggers(controller.analog.l, controller.analog.r)
406
407					local strl = ("L: % f"):format(l)
408					local strr = ("R: % f"):format(r)
409
410					xoff = xoff + DEBUG_FONT:getWidth(strl) + 8
411
412					graphics.setColor(0, 0, 0, 255)
413					graphics.textOutline(strl, 2, 512 - xoff, 256 - 4 - 24)
414					graphics.textOutline(strr, 2, 512 - xoff, 256 - 4 - 12)
415
416					graphics.setColor(255, 255, 255, 255)
417					graphics.print(strl, 512 - xoff, 256 - 4 - 24)
418					graphics.print(strr, 512 - xoff, 256 - 4 - 12)
419				end
420			end
421
422			if PANEL_SETTINGS:IsDebuggingCStick() then
423				local strcx = ("CX: % .4f"):format(cx)
424				local strcy = ("CY: % .4f"):format(cy)
425
426				xoff = xoff + DEBUG_FONT:getWidth(strcx) + 8
427
428				graphics.setColor(0, 0, 0, 255)
429				graphics.textOutline(strcx, 2, 512 - xoff, 256 - 4 - 24)
430				graphics.textOutline(strcy, 2, 512 - xoff, 256 - 4 - 12)
431
432				graphics.setColor(255, 255, 255, 255)
433				graphics.print(strcx, 512 - xoff, 256 - 4 - 24)
434				graphics.print(strcy, 512 - xoff, 256 - 4 - 12)
435			end
436
437			if PANEL_SETTINGS:IsDebuggingJoystick() then
438				local strx = ("X: % .4f"):format(x)
439				local stry = ("Y: % .4f"):format(y)
440
441				xoff = xoff + DEBUG_FONT:getWidth(strx) + 8
442
443				graphics.setColor(0, 0, 0, 255)
444				graphics.textOutline(strx, 2, 512 - xoff, 256 - 4 - 24)
445				graphics.textOutline(stry, 2, 512 - xoff, 256 - 4 - 12)
446
447				graphics.setColor(255, 255, 255, 255)
448				graphics.print(strx, 512 - xoff, 256 - 4 - 24)
449				graphics.print(stry, 512 - xoff, 256 - 4 - 12)
450			end
451
452			if PANEL_SETTINGS:IsDebuggingButtons() then
453				local btts = ("B:  %X"):format(controller.buttons.pressed)
454
455				local yoff = 36
456
457				if xoff <= 0 then
458					yoff = 12
459					xoff = xoff + DEBUG_FONT:getWidth(btts) + 8
460				end
461
462				graphics.setColor(0, 0, 0, 255)
463				graphics.textOutline(btts, 2, 512 - xoff, 256 - 4 - yoff)
464
465				graphics.setColor(255, 255, 255, 255)
466				graphics.print(btts, 512 - xoff, 256 - 4 - yoff)
467			end
468		end
469	end
470end
471
472do
473	local icon_time_start
474	local icon_time_show
475	local icon_time_next
476
477	local icon_rotate = 0
478
479	local canvas = love.graphics.newCanvas()
480
481	function love.drawTrobber(game)
482		local t = love.timer.getTime()
483		local dt = love.timer.getDelta()
484
485		local lx = 0
486		local ly = math.sin(t*3) * 4
487		local rx = icon_rotate
488
489		local rotate_speed = 0
490		
491		if not game then
492			if not icon_time_start or icon_time_next < t then
493				icon_time_start = t
494				icon_time_show = t + 1
495				icon_time_next = t + 2
496			end
497
498			local anim = 0
499			if icon_time_show > t then
500				anim = ease.sigmoid(math.min(1, (t - icon_time_start)/1))
501				lx = ease.lerp(0, -160, anim)
502				ly = ease.lerp(0, 64, anim)
503				rx = ease.lerp(0, -90, anim)
504			else
505				anim = ease.outback(math.min(1, (t - icon_time_show)/1))
506				lx = ease.lerp(160, 0, anim)
507				ly = ease.lerp(64, 0, anim)
508				rx = ease.lerp(90, 0, anim)
509			end
510		else
511			rotate_speed = math.sinlerp(0, 360*4*dt/2, t/2)
512			icon_rotate = (icon_rotate + rotate_speed) % 360
513		end
514
515		graphics.setColor(255, 255, 255, 255)
516
517		graphics.setCanvas(canvas)
518
519		graphics.clear(0,0,0,0)
520		if not game then
521			graphics.setBlendMode("replace", "premultiplied")
522		end
523
524		graphics.setScissor(256-80-20, 0, 160+40, 256)
525
526		local slippi = PANEL_SETTINGS:IsSlippiNetplay() or PANEL_SETTINGS:IsSlippiReplay()
527		local icon = game and (slippi and MELEE or GAME) or DOLPHIN
528
529		graphics.setColor(255, 255, 255, 255)
530		graphics.easyDraw(icon, 256+lx, 64+40+ly, math.rad(rx), 80, 80, 0.5, 0.5)
531		
532		if game then
533			local p = rotate_speed/13
534
535			for i=0, 16 do
536				local j = rotate_speed - i
537				graphics.setColor(255, 255, 255, rotate_speed*4)
538				graphics.easyDraw(slippi and MELEELABEL or icon, 256+lx, 64+40+ly, math.rad(rx-(i*p*4)), 80, 80, 0.5, 0.5)
539			end
540		end
541
542		graphics.setScissor()
543
544		if not game then
545			graphics.setBlendMode("multiply", "premultiplied")
546
547			graphics.easyDraw(GRADIENT, 256-80-20, 0, 0, 80, 256)
548			graphics.easyDraw(GRADIENT, 256+80+20, 0, math.rad(180), 80, 256, 0, 1)
549		end
550
551		graphics.setCanvas()
552
553		graphics.setBlendMode("alpha", "alphamultiply")
554
555		if game then
556			local sw = math.sinlerp(0.5, 1, t*3)
557			graphics.setColor(125, 125, 125, 150)
558			graphics.easyDraw(SHADOW, 256, 154, 0, 64*sw, 6*sw, 0.5, 0.5)
559		end
560
561		graphics.setColor(255, 255, 255, 255)
562		graphics.draw(canvas)
563	end
564end
565
566do
567	local ellipses = {".", "..", "..."}
568
569	function love.drawNotificationText(msg)
570		local t = love.timer.getTime()
571
572		local w = WAITING_FONT:getWidth(msg)
573		local h = WAITING_FONT:getHeight()
574		local x = 256 - (w/2)
575		local y = 128+32
576
577		local i = math.floor(t % #ellipses) + 1
578
579		msg = msg .. ellipses[i]
580
581		graphics.setFont(WAITING_FONT)
582		graphics.setColor(0, 0, 0, 255)
583		graphics.textOutline(msg, 3, x, y)
584		graphics.setColor(255, 255, 255, 255)
585		graphics.print(msg, x, y)
586	end
587end
588
589function love.isWindows()
590	return jit.os:lower() == "windows"
591end
592
593function love.supportsGameCapture()
594	return love.isWindows()
595end
596
597function love.supportsAttachableConsole()
598	return love.isWindows()
599end
600
601--[=[local canvas = love.graphics.newCanvas()
602
603local stenciledCanvas =  {
604	canvas,
605	stencil = true,
606}
607
608local blur = graphics.newShader[[
609extern number radius;
610extern vec2 imageSize;
611
612vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pc)
613{
614	color = vec4(0);
615	vec2 st;
616
617	for (float x = -radius; x <= radius; x++) {
618		for (float y = -radius; y <= radius; y++) {
619			// to texture coordinates
620			st.xy = vec2(x,y) / imageSize;
621			color += Texel(tex, tc + st);
622		}
623	}
624	return color / ((2.0 * radius + 1.0) * (2.0 * radius + 1.0));
625}
626]]
627
628blur:send("radius", 6)
629blur:send("imageSize", {canvas:getPixelDimensions()})]=]
630
631function love.draw()
632	if not love.supportsGameCapture() or not PANEL_SETTINGS:UseTransparency() then
633		graphics.setBackgroundColor(PANEL_SETTINGS:GetBackgroundColor())
634	else
635		-- Default to completely transparent, makes the overlay completely invisible when not in a game!
636		local alpha = 0
637
638		if (memory.initialized and memory.game) or PANEL_SETTINGS:IsVisible() then
639			-- Only apply transparency when we are watching a games memory.
640			alpha = 255 - ((PANEL_SETTINGS:GetTransparency() / 100) * 255)
641		end
642
643		-- Transparent background for OBS
644		graphics.setBackgroundColor(0, 0, 0, alpha)
645
646		-- Show a preview for transparency
647		if PANEL_SETTINGS:IsVisible() then
648			graphics.setBackgroundColor(255, 255, 255, alpha)
649
650			for x=0, 512/32 do
651				for y=0, 256/32 do
652					graphics.setColor(230, 230, 230, 255)
653					graphics.rectangle("fill", 32 * (x + (y%2)), 32 * (y + (x%2)), 32, 32)
654				end
655			end
656
657			graphics.setColor(0, 0, 0, alpha)
658			graphics.rectangle("fill", 0, 0, 512, 256)
659
660			--[[graphics.setColor(0, 0, 0, 100)
661			graphics.rectangle("fill", 512 - 20, 0, 20, 256)
662
663			local rad = math.rad(90)
664
665			graphics.setFont(DEBUG_FONT)
666			graphics.setColor(0, 0, 0, 255)
667			graphics.print(VERSION, 512 - 5, 5, rad)
668			graphics.setColor(255, 255, 255, 255)
669			graphics.print(VERSION, 512 - 4, 4, rad)]]
670		end
671	end
672
673	--[[if PANEL_SETTINGS:IsVisible() then
674		graphics.setCanvas(stenciledCanvas)
675		graphics.clear(0, 0, 0, 0)
676	end]]
677
678	if memory.initialized and memory.ingame and memory.game and memory.controller then
679		love.drawControllerOverlay()
680	else
681		if memory.hooked then
682			love.drawTrobber(true)
683			local slippi = PANEL_SETTINGS:IsSlippiNetplay() or PANEL_SETTINGS:IsSlippiReplay()
684			love.drawNotificationText(slippi and "Waiting for melee" or "Waiting for game")
685		else
686			love.drawTrobber()
687			love.drawNotificationText("Waiting for dolphin")
688		end
689	end
690
691	-- Draw a temporary number to show that the user changed controller port
692	if ((PANEL_SETTINGS:AlwaysShowPort() and memory.isInGame()) or overlay.isPortShowing()) then
693		local port = overlay.getPort()
694		if memory.isMelee() then
695			local port = PORT_DISPLAY_OVERRIDE or port
696			local portColor
697			if melee.isTeams() then
698				portColor = melee.getPlayerTeamColor(port)
699			else
700				portColor = melee.getPlayerColor(port)
701			end
702			portColor.a = 200
703			graphics.setColor(portColor)
704			melee.drawSeries(port, 8, 256 - 72 - 4, 0, 72, 72)
705			graphics.setColor(255, 255, 255, 255)
706			melee.drawStock(port, 40, 256 - 42, 0, 24, 24)
707			graphics.easyDraw(PORT_TEXTURES[port], 12, 256 - 42 - 24, 0, 33, 14)
708		else
709			graphics.setFont(PORT_FONT)
710			graphics.setColor(0, 0, 0, 255)
711			graphics.textOutline(port, 3, 16, 256 - 42 - 16)
712			graphics.setColor(255, 255, 255, 255)
713			graphics.print(port, 16, 256 - 42 - 16)
714		end
715	end
716
717	--[[if PANEL_SETTINGS:IsVisible() then
718		graphics.setCanvas()
719
720		graphics.setShader(blur)
721			graphics.easyDraw(canvas, 0, 0, 0, 512, 256)
722		graphics.setShader()
723	end]]
724	
725	music.draw()
726
727	local time = love.timer.getTime()
728
729	if ESCAPE_MENU_HINT_FADE and ESCAPE_MENU_HINT_FADE >= time then
730		local msg = "Press 'ESC' to access the settings!"
731
732		local w = DEBUG_FONT:getWidth(msg) + 40
733		local h = 32
734
735		local x = 512/2 - w/2
736		local y = 256-h-16
737
738		y = y + math.sin(time*5) * 4
739
740		local alpha = 255
741
742		if ESCAPE_MENU_HINT < time then
743			local fadeLen = ESCAPE_MENU_HINT_FADE - ESCAPE_MENU_HINT
744			local timeRem = ESCAPE_MENU_HINT_FADE - time
745			alpha = timeRem/fadeLen*255
746		end
747
748		graphics.setColor(255, 255, 255, alpha)
749		graphics.roundRect(x, y, w, h, 4)
750		graphics.easyDraw(KEY, x, y, 0, 32, 32)
751
752		graphics.setFont(DEBUG_FONT)
753		graphics.setColor(0, 0, 0, alpha)
754		graphics.print(msg, x + 36, y+(h/2)-6)
755	end
756	notification.draw()
757	gui.render()
758	if CODE_ENTERED then
759		love.drawDeveloperInfo()
760	end
761end
762
763local FPS_LIMIT = 59.94
764
765function love.run()
766	if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
767 
768	-- We don't want the first frame's dt to include time taken by love.load.
769	if love.timer then love.timer.step() end
770 
771	local dt = 0
772 
773	-- Main loop time.
774	return function()
775		local frame_start = love.timer.getTime()
776
777		-- Process events.
778		if love.event then
779			love.event.pump()
780			for name, a,b,c,d,e,f in love.event.poll() do
781				if name == "quit" then
782					if not love.quit or not love.quit() then
783						return a or 0
784					end
785				end
786				love.handlers[name](a,b,c,d,e,f)
787			end
788		end
789 
790		-- Update dt, as we'll be passing it to update
791		if love.timer then dt = love.timer.step() end
792 
793		-- Call update and draw
794		if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled
795 
796		if love.graphics and love.graphics.isActive() then
797			love.graphics.origin()
798			love.graphics.clear(love.graphics.getBackgroundColor())
799 
800			if love.draw then love.draw() end
801 
802			love.graphics.present()
803		end
804 
805		if love.timer then
806			local frame_time = love.timer.getTime() - frame_start
807			love.timer.sleep(1 / FPS_LIMIT - frame_time)
808		end
809	end
810end
811
812function love.quit()
813	PANEL_SETTINGS:OnClosed()
814	gui.shutdown()
815	web.close()
816	downloader.close()
817end