Skip to content

Commit b5c7bc4

Browse files
committed
Show internal GAMEID in the title of the window when loading a game.
Changed port changing to show a temporary number on the bottom left corner rather than changing the title of the application. Backported notification library from GUI branch to show if loading clones.lua from %APPDATA%/m-overlay is successful or not.
1 parent fafd235 commit b5c7bc4

File tree

6 files changed

+165
-3
lines changed

6 files changed

+165
-3
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Latest downloads can be found in ![releases](https://github.com/bkacjios/m-overl
88

99
### Usage
1010

11+
**You can change which controller port is displayed by using the scrollwheel.**
12+
13+
Extra game clones can be defined in "%APPDATA%/m-overlay/clones.lua"
14+
If you are running from source via *run64*, it will load from "%APPDATA%/LOVE/m-overlay/clones.lua" instead..
15+
To see an example of the clones.lua file format, please ![click here.](https://github.com/bkacjios/m-overlay/blob/master/source/modules/games/clones.lua)
16+
1117
This program hooks into Dolphin and reads from memory to show a players inputs. This could be an alternative to Nintendo-Spy for those who don't have the technical prowess of setting up an Arduino.
1218

1319
Currently this program will work on Melee (NTSC v1.02, PAL), 20XX, UnclePunch Training Mode, Brawl, Project M/P+, Need for Speed Underground 1/2, and The Legend of Zelda: The Wind Waker.
@@ -17,8 +23,6 @@ More games can be supported upon request!
1723
To use with OBS, add a "Game Capture" source and use "capture specific window" select "[M'Overlay.exe]"
1824
and be sure to check "Allow Transparency"
1925

20-
You can change display ports by using the scrollwheel.
21-
2226
### Why?
2327

2428
This is the start of a bigger project to make a fully customizable stream overlay. I plan on making a overlay system to show different elements of the game, like percents, stocks, game time, an off camera minimap (like Smash Ultimate), APM meters, controller inputs, and much more. The plan is to have a plugin system for people to script their own overlay elements.

source/fonts/melee-bold.otf

3.45 MB
Binary file not shown.

source/main.lua

+22-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ require("util.love2d")
55

66
local watcher = require("memory")
77
local perspective = require("perspective")
8+
local notification = require("notification")
89

910
local graphics = love.graphics
1011
local newImage = graphics.newImage
1112

13+
local portChangeFont = graphics.newFont("fonts/melee-bold.otf", 42)
14+
1215
function love.load()
1316
love.window.setTitle("M'Overlay - Waiting for Dolphin...")
1417
graphics.setBackgroundColor(0, 0, 0, 0) -- Transparent background for OBS
@@ -31,6 +34,7 @@ local BUTTONS = {
3134

3235
function love.update(dt)
3336
watcher.update("Dolphin.exe") -- Look for Dolphin.exe
37+
notification.update(8, 0)
3438
end
3539

3640
local DC_CON = newImage("textures/buttons/disconnected.png")
@@ -147,6 +151,7 @@ local BUTTON_TEXTURES = {
147151

148152
local MAX_PORTS = 4
149153
local PORT = 0
154+
local CONTROLLER_PORT_DISPLAY = 0
150155

151156
function love.wheelmoved(x, y)
152157
if not watcher.isReady() then return end
@@ -157,7 +162,8 @@ function love.wheelmoved(x, y)
157162
PORT = PORT + 1
158163
end
159164
PORT = PORT % MAX_PORTS
160-
love.window.setTitle(string.format("M'Overlay - Port %d", PORT + 1))
165+
166+
CONTROLLER_PORT_DISPLAY = love.timer.getTime() + 1.5
161167
end
162168

163169
local vertices = {
@@ -212,6 +218,21 @@ local function transformVertices(vertices, x, y, angle, ox, oy)
212218
end
213219

214220
function love.draw()
221+
love.drawControllerOverlay()
222+
223+
-- Draw a temporary number to show that the user changed controller port
224+
if CONTROLLER_PORT_DISPLAY >= love.timer.getTime() then
225+
graphics.setFont(portChangeFont)
226+
graphics.setColor(0, 0, 0, 255)
227+
graphics.textOutline(PORT + 1, 3, 16, 256 - 42 - 16)
228+
graphics.setColor(255, 255, 255, 255)
229+
graphics.print(PORT + 1, 16, 256 - 42 - 16)
230+
end
231+
232+
notification.draw()
233+
end
234+
235+
function love.drawControllerOverlay()
215236
if not watcher.initialized or not watcher.game then return end
216237

217238
local controller = watcher.controller[PORT + 1]

source/modules/memory/init.lua

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local bit = require("bit")
22
local log = require("log")
33
local memory = require("memory." .. jit.os:lower())
44
local clones = require("games.clones")
5+
local notification = require("notification")
56
local filesystem = love.filesystem
67

78
local configdir = filesystem.getSaveDirectory()
@@ -19,6 +20,7 @@ if filesystem.getInfo(clones_file, "file") then
1920
if not status then
2021
-- Failed loading chunk, chunk is an error string
2122
log.error(chunk)
23+
notification.error(chunk)
2224
elseif chunk then
2325
-- Create a sandboxed lua environment
2426
local env = {}
@@ -31,13 +33,15 @@ if filesystem.getInfo(clones_file, "file") then
3133
if not status then
3234
-- Failed calling the chunk, custom_clones is an error string
3335
log.error(custom_clones)
36+
notification.error(custom_clones)
3437
else
3538
local num_clones = 0
3639
for clone_id, info in pairs(custom_clones) do
3740
num_clones = num_clones + 1
3841
clones[clone_id] = info
3942
end
4043
log.info("Loaded %d clones from %s", num_clones, clones_file)
44+
notification.coloredMessage(("Loaded %d clones from %s"):format(num_clones, clones_file))
4145
end
4246
end
4347
end
@@ -272,6 +276,7 @@ function watcher.checkmemoryvalues()
272276

273277
if gid ~= "\0\0\0\0\0\0" then
274278
log.debug("GAMEID: %q (Version %d)", gid, version)
279+
love.window.setTitle(("M'Overlay - Dolphin hooked (%s-%d)"):format(gid, version))
275280

276281
-- See if this GameID is a clone of another
277282
local clone = clones[gid]
@@ -292,6 +297,7 @@ function watcher.checkmemoryvalues()
292297
log.error(game)
293298
end
294299
else
300+
love.window.setTitle("M'Overlay - Dolphin hooked")
295301
log.info("Game closed..")
296302
end
297303
end

source/modules/notification.lua

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
local graphics = love.graphics
2+
local newImage = graphics.newImage
3+
local newFont = graphics.newFont
4+
local timer = love.timer
5+
6+
local log = require("log")
7+
8+
local notification = {
9+
messages = {},
10+
font = newFont("fonts/melee-bold.otf", 12),
11+
padding = 8,
12+
}
13+
14+
local dummy = function(height, fade) end
15+
16+
function notification.add(height, length, fade, draw)
17+
height = height or 16
18+
length = length or 3
19+
fade = fade or 0.75
20+
21+
local now = timer.getTime()
22+
23+
table.insert(notification.messages, {
24+
time = now,
25+
length = length,
26+
fade = fade,
27+
finish = now + length + fade,
28+
29+
height = height,
30+
31+
draw = draw or dummy,
32+
33+
lerp = {},
34+
})
35+
end
36+
37+
function notification.update(x, y)
38+
local now = timer.getTime()
39+
40+
local prevh = 0
41+
42+
for k, message in pairs(notification.messages) do
43+
if (message.finish >= now) then
44+
x = x * 0.5 + (message.lerp.x or x) * 0.5
45+
y = y * 0.5 + (message.lerp.y or y) * 0.5
46+
y = y + prevh/2 + notification.padding/2
47+
48+
message.lerp.x = x
49+
message.lerp.y = y
50+
51+
prevh = message.height
52+
end
53+
end
54+
55+
for k, message in pairs(notification.messages) do
56+
if (message.finish >= now) then
57+
return
58+
end
59+
end
60+
61+
notification.messages = {}
62+
end
63+
64+
function notification.draw()
65+
local now = timer.getTime()
66+
for k, message in pairs(notification.messages) do
67+
68+
local fade = 1
69+
70+
if now >= message.time + message.length then
71+
fade = 1-((now - message.time - message.length)/message.fade)
72+
end
73+
74+
local x, y = message.lerp.x, message.lerp.y
75+
76+
if x and y then
77+
graphics.push("transform")
78+
graphics.translate(x, y)
79+
graphics.setFont(notification.font)
80+
graphics.setColor(255, 255, 255, 255 * fade)
81+
local succ, ret = xpcall(message.draw, debug.traceback, message.height, fade)
82+
if not succ then
83+
log.error("notification error: %s", ret)
84+
end
85+
graphics.pop()
86+
end
87+
end
88+
end
89+
90+
function notification.error(text)
91+
notification.add(14, 10, 0.75, function(height, fade)
92+
graphics.setColor(0, 0, 0, 255 * fade)
93+
graphics.textOutline(text, 1, 1, 1)
94+
graphics.setColor(205, 16, 26, 255 * fade)
95+
graphics.print(text, 0, 0)
96+
end)
97+
end
98+
99+
function notification.coloredMessage(...)
100+
local args = {...}
101+
notification.add(14, 5, 0.75, function(height, fade)
102+
graphics.setColor(0, 0, 0, 255 * fade)
103+
graphics.textOutline(args, 1, 1, 1)
104+
graphics.setColor(255, 255, 255, 255 * fade)
105+
graphics.print(args, 0, 0)
106+
end)
107+
end
108+
109+
return notification

source/modules/util/love2d.lua

+22
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,26 @@ function love.graphics.easyDraw(obj, x, y, rotation, width, height, originX, ori
2828
local scaledW = width / objW
2929
local scaledH = height / objH
3030
love.graphics.draw(obj, x, y, rotation, scaledW, scaledH, objW * originX, objH * originY, ...)
31+
end
32+
33+
function love.graphics.textOutlinef(text, width, x, y, ...)
34+
local steps = width * 2 / 3
35+
if steps < 1 then steps = 1 end
36+
37+
for _x = -width, width, steps do
38+
for _y = -width, width, steps do
39+
love.graphics.printf(text, x + _x, y + _y, ...)
40+
end
41+
end
42+
end
43+
44+
function love.graphics.textOutline(text, width, x, y, ...)
45+
local steps = width * 2 / 3
46+
if steps < 1 then steps = 1 end
47+
48+
for _x = -width, width, steps do
49+
for _y = -width, width, steps do
50+
love.graphics.print(text, x + _x, y + _y, ...)
51+
end
52+
end
3153
end

0 commit comments

Comments
 (0)