Last active
April 24, 2021 15:43
-
-
Save vinevi/bbd5c85a459f658112043505c6eb1faa to your computer and use it in GitHub Desktop.
MM6 - MMExtension - UI Toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local UIManager = { | |
isShown = true, | |
toggleState = true | |
} | |
UIManager.init = function(self) | |
self:initHooks() | |
function Keys.F12(t) | |
self:toggle() | |
end | |
end | |
UIManager.initHooks = function(self) | |
-- return to the toggle state when rendering | |
mem.autohook(0x00435267, function() | |
self:set(self.toggleState) | |
end) | |
-- show UI when not rendering | |
mem.autohook(0x00435130, function() | |
self:set(true) | |
end) | |
end | |
UIManager.toggle = function(self) | |
self.toggleState = not self.isShown | |
self:set(self.toggleState) | |
end | |
UIManager.set = function(self, state) | |
if(state == true) then | |
self:show() | |
else | |
self:hide() | |
end | |
self.isShown = state | |
mem.call(0x004580ef) | |
Game.NeedRedraw = true | |
end | |
UIManager.show = function(self) | |
if(self.isShown == false) then | |
-- viewport offset | |
mem.u4[0x0052d268] = 8 | |
mem.u4[0x0052d26c] = 8 | |
-- viewport width and height | |
mem.u4[0x0052d270] = 468 | |
mem.u4[0x0052d274] = 351 | |
-- footer graphics | |
mem.asmpatch(0x00435159, [[ | |
CALL absolute 0x00417df0 | |
]]) | |
mem.asmpatch(0x0043515e, [[ | |
CALL absolute 0x00418e50 | |
]]) | |
-- character portraits | |
mem.asmpatch(0x004352e0, [[ | |
CALL absolute 0x00486840 | |
]]) | |
-- character frames | |
mem.asmpatch(0x004352eb, [[ | |
CALL absolute 0x004353f0 | |
]]) | |
-- character portrait overlay | |
mem.asmpatch(0x004352fa, [[ | |
CALL absolute 0x00484980 | |
]]) | |
-- turnbased graphics | |
mem.asmpatch(0x00435307, [[ | |
PUSH ESI | |
]]) | |
mem.asmpatch(0x0043530d, [[ | |
CALL absolute 0x00435ed0 | |
]]) | |
-- active party spells | |
mem.asmpatch(0x004352d0, [[ | |
CALL absolute 0x004354e0 | |
]]) | |
-- overlay graphics | |
mem.asmpatch(0x004352af, [[ | |
CALL absolute 0x00417dc0 | |
]]) | |
-- hired NPCs | |
mem.asmpatch(0x004352d9, [[ | |
CALL absolute 0x00486630 | |
]]) | |
end | |
end | |
UIManager.hide = function(self) | |
if(self.isShown == true) then | |
-- viewport offset | |
mem.u4[0x0052d268] = 0 | |
mem.u4[0x0052d26c] = 0 | |
-- viewport width and height | |
mem.u4[0x0052d270] = 640 | |
mem.u4[0x0052d274] = 479 | |
-- footer graphics | |
mem.nop(0x00435159) | |
mem.nop(0x0043515e) | |
-- character portraits | |
mem.nop(0x004352e0) | |
-- character frames | |
mem.nop(0x004352eb) | |
-- chracter portrait overlay | |
mem.nop(0x004352fa) | |
-- turnbased graphics | |
mem.nop(0x00435307) | |
mem.nop(0x0043530d) | |
-- active party spells | |
mem.nop(0x004352d0) | |
-- overlay graphics | |
mem.nop(0x004352af) | |
-- hired NPCs | |
mem.nop(0x004352d9) | |
end | |
end | |
UIManager:init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment