Skip to content

Commit 1d52916

Browse files
TimMenu: fixed some bad code removed unnecesary liabilities
1 parent d9d9187 commit 1d52916

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

TimMenu/Common.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---@diagnostic disable: duplicate-set-field
21
local Utils = require("TimMenu.Utils")
32
local Globals = require("TimMenu.Globals")
43

@@ -236,12 +235,12 @@ local function OnUnload()
236235
input.SetMouseInputEnabled(false)
237236
Utils.PruneOrphanedWindows(TimMenuGlobal.windows, TimMenuGlobal.order)
238237
print("Unloading TimMenu")
238+
-- Unregister callbacks to prevent conflicts on reload
239+
callbacks.Unregister("Draw", "zTimMenu_GlobalDraw")
239240
package.loaded["TimMenu"] = nil
240241
end
241242

242243
callbacks.Unregister("Unload", "TimMenu_Unload")
243244
callbacks.Register("Unload", "TimMenu_Unload", OnUnload)
244245

245-
-- Monkey patch draw functions to ensure all draw positions are integers-- This prevents floating point coordinates which can cause rendering issuesdo local origFilled = draw.FilledRect ---@diagnostic disable-next-line: duplicate-set-field draw.FilledRect = function(x1, y1, x2, y2) origFilled(math.floor(x1), math.floor(y1), math.floor(x2), math.floor(y2)) end local origOutlined = draw.OutlinedRect ---@diagnostic disable-next-line: duplicate-set-field draw.OutlinedRect = function(x1, y1, x2, y2) origOutlined(math.floor(x1), math.floor(y1), math.floor(x2), math.floor(y2)) end local origLine = draw.Line if origLine then ---@diagnostic disable-next-line: duplicate-set-field draw.Line = function(x1, y1, x2, y2) origLine(math.floor(x1), math.floor(y1), math.floor(x2), math.floor(y2)) end end local origText = draw.Text ---@diagnostic disable-next-line: duplicate-set-field draw.Text = function(x, y, text) origText(math.floor(x), math.floor(y), text) end local origTextured = draw.TexturedRect if origTextured then ---@diagnostic disable-next-line: duplicate-set-field draw.TexturedRect = function(id, x1, y1, x2, y2) origTextured(id, math.floor(x1), math.floor(y1), math.floor(x2), math.floor(y2)) end endend
246-
247246
return Common

TimMenu/Main.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ end
4444

4545
local function withFontReset(func, ...)
4646
local prevFont = applyNextWidgetFont()
47-
local results = {func(...)}
47+
local results = { func(...) }
4848
restoreWidgetFont(prevFont)
4949
return table.unpack(results)
5050
end
@@ -357,13 +357,8 @@ local function _TimMenu_GlobalDraw()
357357
end
358358
end
359359

360-
callbacks.Unregister("Draw", "TimMenu_GlobalDraw")
361-
callbacks.Unregister("Draw", "zTimMenu_GlobalDraw")
362360
callbacks.Register("Draw", "zTimMenu_GlobalDraw", _TimMenu_GlobalDraw)
363361

364-
-- Textbox is deprecated, use TextInput instead
365-
TimMenu.Textbox = TimMenu.TextInput
366-
367362
function TimMenu.Keybind(label, currentKey)
368363
local win = TimMenu.GetCurrentWindow()
369364
if not win then

TimMenu/Utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Utils.PruneOrphanedWindows(windows, order)
1515
end
1616
end
1717

18-
function Utils.IsMouseOverWindow(win, mouseX, mouseY, titleHeight)
18+
function Utils.IsMouseOverWindow(win, mouseX, mouseY)
1919
local titleHeight = require("TimMenu.Globals").Defaults.TITLE_BAR_HEIGHT
2020
return mouseX >= win.X and mouseX <= win.X + win.W and mouseY >= win.Y and mouseY <= win.Y + titleHeight + win.H
2121
end

0 commit comments

Comments
 (0)