Skip to content

Commit

Permalink
v0.10.1.1-alpha - EEex_Menu_AddWindowSizeChangedListener()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubb13 committed Mar 8, 2024
1 parent 3d34de9 commit a9d4498
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
2 changes: 1 addition & 1 deletion EEex/EEex.tp2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BACKUP ~EEex/backup~
AUTHOR ~Bubb~
VERSION ~v0.10.1-alpha~
VERSION ~v0.10.1.1-alpha~
README ~EEex/readme-EEex.html~

BEGIN ~EEex~ LABEL ~B3-EEex-Main~
Expand Down
34 changes: 7 additions & 27 deletions EEex/copy/B3Scale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ function B3Scale_PokeEngine()
EEex_EngineGlobal_CBaldurChitin:OnResizeWindow(w, h)
end

function B3Scale_Hook_DoSizeChange()
--[[
+-----------------------------------------------------------------------------+
| Tweak the UI scale whenever the window is resized (called directly by EEex) |
+-----------------------------------------------------------------------------+
--]]

function B3Scale_DoSizeChange()

if B3Scale_Percentage == -1 then
return
Expand All @@ -43,29 +49,3 @@ function B3Scale_Hook_DoSizeChange()
CVidMode.SCREENWIDTH = math.floor(scaledH * ratio)
CVidMode.SCREENHEIGHT = math.floor(scaledH)
end

(function()

EEex_DisableCodeProtection()

--[[
+---------------------------------------------------+
| Tweak the UI scale whenever the window is resized |
+---------------------------------------------------+
| [Lua] B3Scale_Hook_DoSizeChange() |
+---------------------------------------------------+
--]]

EEex_HookAfterCallWithLabels(EEex_Label("Hook-CChitin::OnResizeWindow()-B3Scale"), {
{"hook_integrity_watchdog_ignore_registers", {EEex_HookIntegrityWatchdogRegister.RAX}}},
EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(32)
]], EEex_GenLuaCall("B3Scale_Hook_DoSizeChange"), [[
call_error:
#DESTROY_SHADOW_SPACE
]]})
)

EEex_EnableCodeProtection()

end)()
32 changes: 26 additions & 6 deletions EEex/copy/EEex_Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ function EEex_Menu_SetForceScrollbarRender(itemName, value)
EEex_Menu_ScrollbarForced[itemName] = value
end

EEex_Menu_BeforeUIItemRenderListeners = {}

function EEex_Menu_AddBeforeUIItemRenderListener(itemName, func)
EEex_Menu_BeforeUIItemRenderListeners[itemName] = func
end

---------------
-- Listeners --
---------------
Expand Down Expand Up @@ -261,6 +255,18 @@ function EEex_Menu_AddBeforeListRendersItemListener(listName, listener)
table.insert(listListeners, listener)
end

EEex_Menu_BeforeUIItemRenderListeners = {}

function EEex_Menu_AddBeforeUIItemRenderListener(itemName, listener)
EEex_Menu_BeforeUIItemRenderListeners[itemName] = listener
end

EEex_Menu_WindowSizeChangedListeners = {}

function EEex_Menu_AddWindowSizeChangedListener(listener)
table.insert(EEex_Menu_WindowSizeChangedListeners, listener)
end

-----------
-- Hooks --
-----------
Expand Down Expand Up @@ -327,3 +333,17 @@ function EEex_Menu_Hook_OnBeforeUIItemRender(item)
listener(item)
end
end

function EEex_Menu_Hook_OnWindowSizeChanged()

if EEex_Modules["B3Scale"] then
B3Scale_DoSizeChange()
end

local width = CVidMode.SCREENWIDTH
local height = CVidMode.SCREENHEIGHT

for _, listener in ipairs(EEex_Menu_WindowSizeChangedListeners) do
listener(width, height)
end
end
18 changes: 18 additions & 0 deletions EEex/copy/EEex_Menu_Patch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,24 @@
})
)

--[[
+---------------------------------------------------------+
| Call a hook whenever the engine changes the window size |
+---------------------------------------------------------+
| [Lua] EEex_Menu_Hook_OnWindowSizeChanged() |
+---------------------------------------------------------+
--]]

EEex_HookAfterCallWithLabels(EEex_Label("Hook-CChitin::OnResizeWindow()-B3Scale"), {
{"hook_integrity_watchdog_ignore_registers", {EEex_HookIntegrityWatchdogRegister.RAX}}},
EEex_FlattenTable({[[
#MAKE_SHADOW_SPACE(32)
]], EEex_GenLuaCall("EEex_Menu_Hook_OnWindowSizeChanged"), [[
call_error:
#DESTROY_SHADOW_SPACE
]]})
)


EEex_EnableCodeProtection()

Expand Down
2 changes: 1 addition & 1 deletion package_mod.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ call "%~dp0..\ModPackaging\utilities\ie_games.bat"

REM /* MODIFY: set the values of the 3 variables below to reflect the current mod version */
set "mod_name=EEex"
set "mod_version=v0.10.1-alpha"
set "mod_version=v0.10.1.1-alpha"
set mod_folder=EEex

REM /* MODIFY: list here which IE games the mod is compatible with, from this list of possibilities: */
Expand Down

0 comments on commit a9d4498

Please sign in to comment.