Skip to content

Commit 4c78888

Browse files
authored
Merge pull request YimMenu-Lua#70 from tupoy-ya/fix-extra-scan
fix: Don't search for the screen size twice.
2 parents 496f08f + 93a8846 commit 4c78888

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

includes/services/ToastNotifier.lua

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,6 @@ local function logError(caller, message)
5353
log.warning(("[ERROR] (%s): %s"):format(caller, message))
5454
end
5555

56-
local function GetScreenResolution()
57-
if PatternScanner:IsDone() then
58-
return Game.GetScreenResolution()
59-
end
60-
61-
local pScreenResolution = memory.scan_pattern("66 0F 6E 0D ? ? ? ? 0F B7 3D")
62-
if pScreenResolution:is_null() then
63-
return { x = 0, y = 0 }
64-
end
65-
66-
return {
67-
x = pScreenResolution:sub(0x4):rip():get_word(),
68-
y = pScreenResolution:add(0x4):rip():get_word()
69-
}
70-
end
71-
72-
local SCREEN_RESOLUTION = GetScreenResolution()
73-
7456
--#region Toast
7557

7658
--------------------------------------
@@ -88,8 +70,7 @@ local SCREEN_RESOLUTION = GetScreenResolution()
8870
local Toast = {}
8971
Toast.__index = Toast
9072
Toast.ui_width = 320
91-
Toast.ui_pos_x = SCREEN_RESOLUTION.x - Toast.ui_width - 20
92-
Toast.ui_pos_y = -200.0
73+
9374

9475
---@param caller string The notification title.
9576
---@param message string The notification body.
@@ -105,7 +86,9 @@ function Toast.new(caller, message, level, duration, log)
10586
duration = duration or 3.0,
10687
start_time = Time.now(),
10788
should_draw = false,
108-
should_log = log
89+
should_log = log,
90+
ui_pos_x = GPointers.ScreenResolution.x - Toast.ui_width - 20,
91+
ui_pos_y = -200.0
10992
},
11093
Toast
11194
)

0 commit comments

Comments
 (0)