Originally Posted by MunkDev
I didn't really know this either, but given a copy of the UI source code, there's a method to finding what you're looking for by going to the source of something you want to modify and looking at how it works. If you haven't already, get a copy of the source code and use an editor that allows you to search in the code for the things you're interested in. In this case, it seems likely that Blizzard would at some point implement a utility function that returns the current modifier chain, because it's useful in a lot of cases.
I would actually use a table for this, partly for code clarity, and also because it's easier to modify on a whim.
Lua Code:
local dismountTypes = { spell = true, item = true, companion = true, macro = false, }
Lua Code:
if HasAction(action) then local actionType, spellID = GetActionInfo(action) if dismountTypes[actionType] and not protectedSkills[spellID] then Dismount() elseif actionType == "macro" then spellID, _ = GetMacroSpell(spellID) if spellID ~= nil and not protectedSkills[spellID] then Dismount() end end end return
I'll give you an example of how to track execution path in this case, which I don't think any tutorial brings up. If you look in Bindings.xml, you'll find that e.g. SHAPESHIFTBUTTON1 is calling StanceBar_Select(1). A quick search for this function gives you this result:
Lua Code:
-- Searching 1364 files for "function StanceBar_Select" (case sensitive) -- UISourceCode\StanceBar.lua: function StanceBar_Select (id) StanceBarFrame.lastSelected = id; CastShapeshiftForm(id); end
Casting the shapeshift form generates an event that updates the stance bar, which results in the current stance active having its button set to checked.
Lua Code:
function StanceBar_OnEvent(self, event) if(event == "UPDATE_SHAPESHIFT_COOLDOWN") then StanceBar_UpdateState(); end end function StanceBar_UpdateState () ... if ( isActive ) then StanceBarFrame.lastSelected = button:GetID(); button:SetChecked(true); else button:SetChecked(false); end ... end
|
Tack så mycket!
Ended up exporting the Interface code and adding them to Visual Studio with the NPL/Lua language service. Works well enough, but could be better. Serves its purpose at the very least, and I can actually follow the execution path for most things.
I am pleased with the dismount AddOn now, but the only downside with it is that it seems to be latency dependent (although, I haven't had an American try it on the beta yet). On retail at 40ms latency the Dismount() function seems to take about 1ms; on classic beta with 120ms latency the Dismount() function seems to take about 3ms. Which seems to cause most abilities to require two button presses, but could be due to other changes/differences between Classic and retail.
The only thing I can see myself adding to this AddOn is if there is a way to make the Dismount() function execute faster. I am not entirely sure how a hooksecurefunc works, but I would assume that it would always be executing slower than the actual Dismount() function?