If you want help learning to write hooked / non-destructive code, or help hooking any individual files or functions, I'll be glad to assist with that - but I don't have any interest in digging through entire files to find changes. At the very least, always leave tagged comments next to all of your changes, so that it's easy to find them (e.g. --pacov: etc etc).
Since I know what to look for in this particular instance, I'll write a hook for it for demonstration purposes, but in the future I'd highly recommend starting with a blank file and learning to do proper hooks - it's actually pretty simple, and it makes troubleshooting and debugging a lot easier (especially for people trying to help you):
Code: c++
- --save a local copy of the original OnHeroChange
- local prevOnHeroChange = OnHeroChange
- --re-define the function
- function OnHeroChange(unit)
- --call the saved instance
- prevOnHeroChange(unit)
- --make sure the saved instance set the 'hero' variable
- --that is declared at the top of the original file
- --if it's nil, that means we're in observer mode
- --we could also check 'unit', as that's what the original
- --sets 'hero' to, I'm just mimicking the check that
- --the original does in case I missed something
- if hero then
- --these will have all been hidden by the original
- --instance of the function that we just ran, but
- --we can just Show() them afterward without any
- --visual disruption
- xpTxt:Show()
- xptolevelTxt:Show()
- else
- --if no hero, then insure that the bar is hidden
- bar:Hide()
- end
- end
- local prevCreate = Create
- function Create(parent)
- --call saved, storing what it returns in a local
- local xpBarImg = prevCreate(parent)
- --change the position of the controls the original function created
- --in this particular case, their reference variables are defined
- --at the top of the file, so we don't need to reference them
- --within the table/control that the saved function returns
- LayoutHelpers.AtLeftIn(xptolevelTxt, bar, 76)
-
- --un-do the Hide() that the bar's HandleEvent does on mouseover
- --first we need to save a copy of the original HandleEvent so that
- --other mods' hooks of this function are preserved
- --we could just nil this function out - the whole dummy object,
- --in fact - but then if another mod attempted to hook it, it would
- --generate an error and/or not work at all, so we need to play nice
- local prevHandleEvent = bar.dummy.HandleEvent
- --redefine it
- bar.dummy.HandleEvent = function(self, event)
- --call the saved copy
- prevHandleEvent(self, event)
- --counteract the appropriate Hide() on mouse enter/exit
- if event == 'MouseEnter' then
- xpTxt:Show()
- elseif event == 'MouseExit' then
- xptolevelTxt:Show()
- end
- end
-
- --return stored local, i.e. what the original function returned
- --this must be done, because the UI function that calls Create
- --uses the control object it returns
- return xpBarImg
- end
Hopefully you can figure out what is being done and why from the comments. I'd highly recommend downloading an editor like Notepad++ that does lua syntax highlighting, if you don't already have one. It makes the comments more obvious and readable, if nothing else.
Take a stab at doing your next hook from a blank file, and post if you need help with anything. Most of the UI isn't too difficult to hook, and changing the layout is usually just a matter of hooking a file's Create and adjusting positions etc after running the original function.