mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-27 10:06:17 +00:00
v1.2.0
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
local MTH_AutoBuy = {
|
||||
name = "autobuy",
|
||||
enabled = false,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"MERCHANT_SHOW",
|
||||
@@ -33,7 +33,7 @@ local function AB_EnsureBridgeFrame(moduleRef)
|
||||
return MTH_AutoBuy._bridgeFrame
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame", "MTH_AutoBuyBridgeFrame")
|
||||
local frame = CreateFrame("Frame", "MTH_AutoBuyBridge")
|
||||
if not frame then
|
||||
AB_Log("failed to create bridge frame", "error")
|
||||
return nil
|
||||
@@ -42,8 +42,8 @@ local function AB_EnsureBridgeFrame(moduleRef)
|
||||
frame:RegisterEvent("MERCHANT_SHOW")
|
||||
frame:RegisterEvent("MERCHANT_UPDATE")
|
||||
frame:RegisterEvent("MERCHANT_CLOSED")
|
||||
frame:SetScript("OnEvent", function(_, eventName)
|
||||
eventName = eventName or event
|
||||
frame:SetScript("OnEvent", function()
|
||||
local eventName = event
|
||||
local engine = AB_Engine()
|
||||
if not engine then
|
||||
AB_Trace("bridge event=" .. tostring(eventName) .. " engine missing")
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
local MTH_AutoQuest = {
|
||||
name = "autoquest",
|
||||
enabled = false,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"GOSSIP_SHOW",
|
||||
"QUEST_GREETING",
|
||||
@@ -34,7 +34,6 @@ local QA_ITEM_BLASTED_BOAR_LUNG_NAME = "Blasted Boar Lung"
|
||||
local QA_ITEM_VULTURE_GIZZARD_NAME = "Vulture Gizzard"
|
||||
local QA_ITEM_GROUND_SCORPOK_ASSAY_NAME = "Ground Scorpok Assay"
|
||||
|
||||
local QA_DirectEventFrame = nil
|
||||
local QA_TooltipHooked = false
|
||||
local QA_TooltipPollFrame = nil
|
||||
local QA_TooltipRefreshFrame = nil
|
||||
@@ -292,7 +291,8 @@ local function QA_CountItemInBags(expectedId, expectedName)
|
||||
for slot = 1, slots do
|
||||
local link = getContainerItemLink(bag, slot)
|
||||
if type(link) == "string" and link ~= "" then
|
||||
local itemId = tonumber(string.match(link, "item:(%d+)"))
|
||||
local _, _, itemIdStr = string.find(link, "item:(%d+)")
|
||||
local itemId = tonumber(itemIdStr)
|
||||
local itemName = nil
|
||||
if type(getItemInfo) == "function" then
|
||||
itemName = getItemInfo(link)
|
||||
@@ -456,8 +456,8 @@ local function QA_EnsureTooltipHook()
|
||||
|
||||
if hasHookScript and onTooltipSetUnitExists then
|
||||
pcall(function()
|
||||
GameTooltip:HookScript("OnTooltipSetUnit", function(self)
|
||||
QA_AppendDrazialTooltip(self, "hook:setunit")
|
||||
GameTooltip:HookScript("OnTooltipSetUnit", function()
|
||||
QA_AppendDrazialTooltip(this, "hook:setunit")
|
||||
end)
|
||||
end)
|
||||
elseif hasSetScript and hasGetScript and onTooltipSetUnitExists then
|
||||
@@ -466,11 +466,11 @@ local function QA_EnsureTooltipHook()
|
||||
end)
|
||||
if okGetPrev then
|
||||
pcall(function()
|
||||
GameTooltip:SetScript("OnTooltipSetUnit", function(self)
|
||||
GameTooltip:SetScript("OnTooltipSetUnit", function()
|
||||
if type(previous) == "function" then
|
||||
previous(self)
|
||||
previous()
|
||||
end
|
||||
QA_AppendDrazialTooltip(self, "script:setunit")
|
||||
QA_AppendDrazialTooltip(this, "script:setunit")
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -478,8 +478,8 @@ local function QA_EnsureTooltipHook()
|
||||
|
||||
if hasHookScript and onShowExists then
|
||||
pcall(function()
|
||||
GameTooltip:HookScript("OnShow", function(self)
|
||||
QA_AppendDrazialTooltip(self, "hook:show")
|
||||
GameTooltip:HookScript("OnShow", function()
|
||||
QA_AppendDrazialTooltip(this, "hook:show")
|
||||
end)
|
||||
end)
|
||||
elseif hasSetScript and hasGetScript and onShowExists then
|
||||
@@ -488,11 +488,11 @@ local function QA_EnsureTooltipHook()
|
||||
end)
|
||||
if okGetPrevShow then
|
||||
pcall(function()
|
||||
GameTooltip:SetScript("OnShow", function(self)
|
||||
GameTooltip:SetScript("OnShow", function()
|
||||
if type(previousShow) == "function" then
|
||||
previousShow(self)
|
||||
previousShow()
|
||||
end
|
||||
QA_AppendDrazialTooltip(self, "script:show")
|
||||
QA_AppendDrazialTooltip(this, "script:show")
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -505,17 +505,17 @@ local function QA_EnsureTooltipPoller()
|
||||
if QA_TooltipPollFrame then
|
||||
return
|
||||
end
|
||||
local frame = CreateFrame("Frame", "MTH_AutoQuestTooltipPollFrame")
|
||||
local frame = CreateFrame("Frame", "MTH_AQTooltipPoll")
|
||||
if not frame then
|
||||
return
|
||||
end
|
||||
frame._mthElapsed = 0
|
||||
frame:SetScript("OnUpdate", function(self, elapsed)
|
||||
self._mthElapsed = (self._mthElapsed or 0) + (elapsed or arg1 or 0)
|
||||
if self._mthElapsed < 0.20 then
|
||||
frame:SetScript("OnUpdate", function()
|
||||
this._mthElapsed = (this._mthElapsed or 0) + (arg1 or 0)
|
||||
if this._mthElapsed < 0.20 then
|
||||
return
|
||||
end
|
||||
self._mthElapsed = 0
|
||||
this._mthElapsed = 0
|
||||
if not (MTH_AutoQuest and MTH_AutoQuest.enabled) then
|
||||
return
|
||||
end
|
||||
@@ -591,16 +591,16 @@ end
|
||||
local function QA_RequestTooltipRefresh(delaySeconds)
|
||||
delaySeconds = tonumber(delaySeconds) or 0.10
|
||||
if not QA_TooltipRefreshFrame then
|
||||
QA_TooltipRefreshFrame = CreateFrame("Frame", "MTH_AutoQuestTooltipRefreshFrame")
|
||||
QA_TooltipRefreshFrame = CreateFrame("Frame", "MTH_AQTooltipRefresh")
|
||||
if not QA_TooltipRefreshFrame then
|
||||
return
|
||||
end
|
||||
QA_TooltipRefreshFrame:SetScript("OnUpdate", function(self, elapsed)
|
||||
local frameRef = self or this or QA_TooltipRefreshFrame
|
||||
QA_TooltipRefreshFrame:SetScript("OnUpdate", function()
|
||||
local frameRef = this or QA_TooltipRefreshFrame
|
||||
if not frameRef then
|
||||
return
|
||||
end
|
||||
frameRef._elapsed = (frameRef._elapsed or 0) + (elapsed or arg1 or 0)
|
||||
frameRef._elapsed = (frameRef._elapsed or 0) + (arg1 or 0)
|
||||
if frameRef._elapsed < (frameRef._delay or 0.10) then
|
||||
return
|
||||
end
|
||||
@@ -915,48 +915,14 @@ local function QA_RunProfileAutomation(eventName, profile)
|
||||
end
|
||||
end
|
||||
|
||||
local function QA_SetDirectEventFrameActive(active)
|
||||
if not QA_DirectEventFrame then
|
||||
return
|
||||
end
|
||||
if active then
|
||||
QA_DirectEventFrame:RegisterEvent("GOSSIP_SHOW")
|
||||
QA_DirectEventFrame:RegisterEvent("QUEST_GREETING")
|
||||
QA_DirectEventFrame:RegisterEvent("QUEST_DETAIL")
|
||||
QA_DirectEventFrame:RegisterEvent("QUEST_PROGRESS")
|
||||
QA_DirectEventFrame:RegisterEvent("QUEST_COMPLETE")
|
||||
else
|
||||
QA_DirectEventFrame:UnregisterAllEvents()
|
||||
end
|
||||
end
|
||||
|
||||
local function QA_EnsureDirectEventFrame(moduleRef)
|
||||
if QA_DirectEventFrame then
|
||||
return QA_DirectEventFrame
|
||||
end
|
||||
local frame = CreateFrame("Frame", "MTH_AutoQuestEventFrame")
|
||||
if not frame then
|
||||
QA_Debug("direct frame create failed")
|
||||
return nil
|
||||
end
|
||||
frame:SetScript("OnEvent", function(_, eventName)
|
||||
eventName = eventName or event
|
||||
if not (moduleRef and moduleRef.enabled) then
|
||||
return
|
||||
end
|
||||
QA_Debug("directEvent=" .. tostring(eventName))
|
||||
QA_RunProfileAutomation(eventName, QA_PROFILE_SCORPOK)
|
||||
QA_RunProfileAutomation(eventName, QA_PROFILE_SISSIES)
|
||||
end)
|
||||
QA_DirectEventFrame = frame
|
||||
return frame
|
||||
end
|
||||
-- NOTE: QA_DirectEventFrame removed (Phase 2 fix #22b)
|
||||
-- The central event router already dispatches GOSSIP_SHOW, QUEST_GREETING,
|
||||
-- QUEST_DETAIL, QUEST_PROGRESS, QUEST_COMPLETE to MTH_AutoQuest:onEvent().
|
||||
-- Having a second frame register the same events caused double-dispatch.
|
||||
|
||||
function MTH_AutoQuest:init()
|
||||
local store = QA_GetOptionsStore()
|
||||
self.initialized = true
|
||||
QA_EnsureDirectEventFrame(self)
|
||||
QA_SetDirectEventFrameActive(self.enabled and true or false)
|
||||
QA_Debug("init: module active=" .. tostring(self.enabled and true or false)
|
||||
.. ", option scorpokDrazial=" .. tostring(store and store.scorpokDrazial and true or false)
|
||||
.. ", option arrowsForSissies=" .. tostring(store and store.arrowsForSissies and true or false)
|
||||
@@ -965,7 +931,6 @@ end
|
||||
|
||||
function MTH_AutoQuest:setEnabled(enabled)
|
||||
self.enabled = enabled and true or false
|
||||
QA_SetDirectEventFrameActive(self.enabled and true or false)
|
||||
end
|
||||
|
||||
function MTH_AutoQuest:onEvent(eventName)
|
||||
@@ -981,7 +946,7 @@ function MTH_AutoQuest:onEvent(eventName)
|
||||
end
|
||||
|
||||
function MTH_AutoQuest:cleanup()
|
||||
QA_SetDirectEventFrameActive(false)
|
||||
-- no-op: direct event frame removed in Phase 2
|
||||
end
|
||||
|
||||
MTH:RegisterModule("autoquest", MTH_AutoQuest)
|
||||
|
||||
@@ -485,16 +485,22 @@ local function getActionSpell(slot)
|
||||
end
|
||||
|
||||
if not Chronometer._scanTooltip then
|
||||
Chronometer._scanTooltip = CreateFrame("GameTooltip", "MTH_ChronometerScanTooltip", UIParent, "GameTooltipTemplate")
|
||||
Chronometer._scanTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
local tip = CreateFrame("GameTooltip", "MTH_ChrBarProbe", UIParent)
|
||||
tip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
for i = 1, 4 do
|
||||
local L = tip:CreateFontString("MTH_ChrBarProbeTextLeft"..i, "ARTWORK", "GameTooltipText")
|
||||
local R = tip:CreateFontString("MTH_ChrBarProbeTextRight"..i, "ARTWORK", "GameTooltipText")
|
||||
tip:AddFontStrings(L, R)
|
||||
end
|
||||
Chronometer._scanTooltip = tip
|
||||
end
|
||||
|
||||
local tooltip = Chronometer._scanTooltip
|
||||
tooltip:ClearLines()
|
||||
tooltip:SetAction(slot)
|
||||
|
||||
local left1 = getglobal("MTH_ChronometerScanTooltipTextLeft1")
|
||||
local left2 = getglobal("MTH_ChronometerScanTooltipTextLeft2")
|
||||
local left1 = getglobal("MTH_ChrBarProbeTextLeft1")
|
||||
local left2 = getglobal("MTH_ChrBarProbeTextLeft2")
|
||||
local spellName = left1 and left1:GetText() or nil
|
||||
if not spellName or spellName == "" then
|
||||
return nil, 0
|
||||
@@ -1191,7 +1197,7 @@ function Chronometer:ToggleAnchor()
|
||||
end
|
||||
|
||||
function Chronometer:CreateAnchor(text, r, g, b)
|
||||
local frame = CreateFrame("Button", "MTHChronometerAnchor", UIParent)
|
||||
local frame = CreateFrame("Button", "MTH_ChronometerAnchor", UIParent)
|
||||
frame:SetWidth(220)
|
||||
frame:SetHeight(25)
|
||||
frame.owner = self
|
||||
@@ -1219,25 +1225,23 @@ function Chronometer:CreateAnchor(text, r, g, b)
|
||||
MTH_CHRON_Trace("CreateAnchor default point=" .. MTH_CHRON_DescribePoint(frame))
|
||||
end
|
||||
|
||||
frame:SetScript("OnDragStart", function(self)
|
||||
self = self or this
|
||||
if not self or not self.StartMoving then
|
||||
frame:SetScript("OnDragStart", function()
|
||||
if not this or not this.StartMoving then
|
||||
return
|
||||
end
|
||||
MTH_CHRON_Trace("anchor drag-start point=" .. MTH_CHRON_DescribePoint(self))
|
||||
self:StartMoving()
|
||||
MTH_CHRON_Trace("anchor drag-start point=" .. MTH_CHRON_DescribePoint(this))
|
||||
this:StartMoving()
|
||||
end)
|
||||
frame:SetScript("OnDragStop", function(self)
|
||||
self = self or this
|
||||
if not self then
|
||||
frame:SetScript("OnDragStop", function()
|
||||
if not this then
|
||||
return
|
||||
end
|
||||
|
||||
if self.StopMovingOrSizing then
|
||||
self:StopMovingOrSizing()
|
||||
if this.StopMovingOrSizing then
|
||||
this:StopMovingOrSizing()
|
||||
end
|
||||
|
||||
local point, _, _, x, y = self:GetPoint()
|
||||
local point, _, _, x, y = this:GetPoint()
|
||||
x = tonumber(x)
|
||||
y = tonumber(y)
|
||||
if not x or not y then
|
||||
@@ -1246,16 +1250,16 @@ function Chronometer:CreateAnchor(text, r, g, b)
|
||||
|
||||
x = math.floor(x + 0.5)
|
||||
y = math.floor(y + 0.5)
|
||||
self:ClearAllPoints()
|
||||
self:SetPoint(point or "TOPLEFT", UIParent, point or "TOPLEFT", x, y)
|
||||
this:ClearAllPoints()
|
||||
this:SetPoint(point or "TOPLEFT", UIParent, point or "TOPLEFT", x, y)
|
||||
|
||||
if self.owner and self.owner.profile and type(self.owner.profile.barposition) == "table" then
|
||||
self.owner.profile.barposition.point = point or "TOPLEFT"
|
||||
self.owner.profile.barposition.relativePoint = point or "TOPLEFT"
|
||||
self.owner.profile.barposition.x = x
|
||||
self.owner.profile.barposition.y = y
|
||||
MTH_CHRON_Trace("anchor drag-stop saved profile=" .. MTH_CHRON_FormatBarPosition(self.owner.profile)
|
||||
.. " frame=" .. MTH_CHRON_DescribePoint(self))
|
||||
if this.owner and this.owner.profile and type(this.owner.profile.barposition) == "table" then
|
||||
this.owner.profile.barposition.point = point or "TOPLEFT"
|
||||
this.owner.profile.barposition.relativePoint = point or "TOPLEFT"
|
||||
this.owner.profile.barposition.x = x
|
||||
this.owner.profile.barposition.y = y
|
||||
MTH_CHRON_Trace("anchor drag-stop saved profile=" .. MTH_CHRON_FormatBarPosition(this.owner.profile)
|
||||
.. " frame=" .. MTH_CHRON_DescribePoint(this))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ Documentation: http://web.archive.org/web/20070314234510/http://wowace.com/wiki/
|
||||
Description: A timer bars library.
|
||||
Dependencies: AceLibrary, AceOO-2.0, PaintChips-2.0
|
||||
]]
|
||||
local match = string.match
|
||||
local getn,setn,tinsert = table.getn, table.setn,table.insert
|
||||
local vmajor, vminor = "CandyBar-2.0", "$Revision: 16011 $"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local MTH_ChronometerModule = {
|
||||
name = "chronometer",
|
||||
enabled = true,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {},
|
||||
initialized = false,
|
||||
}
|
||||
|
||||
@@ -780,7 +780,7 @@ local function FOM_DebugLogMerchantFoods(sourceEvent)
|
||||
end
|
||||
end
|
||||
|
||||
function FOM_FeedButton_OnClick()
|
||||
function MTH_FOM_FeedButton_OnClick()
|
||||
if (arg1 == "RightButton") then
|
||||
if (MTH_OpenOptions) then
|
||||
MTH_OpenOptions("FeedOMatic");
|
||||
@@ -790,7 +790,7 @@ function FOM_FeedButton_OnClick()
|
||||
end
|
||||
end
|
||||
|
||||
function FOM_FeedButton_OnEnter()
|
||||
function MTH_FOM_FeedButton_OnEnter()
|
||||
if ( PetFrameHappiness.tooltip ) then
|
||||
GameTooltip:SetOwner(PetFrameHappiness, "ANCHOR_RIGHT");
|
||||
GameTooltip:SetText(PetFrameHappiness.tooltip);
|
||||
@@ -807,7 +807,7 @@ function FOM_FeedButton_OnEnter()
|
||||
end
|
||||
end
|
||||
|
||||
function FOM_FeedButton_OnLeave()
|
||||
function MTH_FOM_FeedButton_OnLeave()
|
||||
GameTooltip:Hide();
|
||||
end
|
||||
|
||||
@@ -985,13 +985,13 @@ function FOM_OnEvent(event, arg1)
|
||||
this:RegisterEvent("PLAYER_REGEN_ENABLED");
|
||||
end
|
||||
|
||||
if (FOM_FeedButton == nil) then
|
||||
FOM_FeedButton = CreateFrame("Button", "FOM_FeedButton", PetFrameHappiness);
|
||||
FOM_FeedButton:SetAllPoints(PetFrameHappiness);
|
||||
FOM_FeedButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
|
||||
FOM_FeedButton:SetScript("OnClick", FOM_FeedButton_OnClick);
|
||||
FOM_FeedButton:SetScript("OnEnter", FOM_FeedButton_OnEnter);
|
||||
FOM_FeedButton:SetScript("OnLeave", FOM_FeedButton_OnLeave);
|
||||
if (MTH_FOM_FeedButton == nil) then
|
||||
MTH_FOM_FeedButton = CreateFrame("Button", "MTH_FOM_FeedButton", PetFrameHappiness);
|
||||
MTH_FOM_FeedButton:SetAllPoints(PetFrameHappiness);
|
||||
MTH_FOM_FeedButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
|
||||
MTH_FOM_FeedButton:SetScript("OnClick", MTH_FOM_FeedButton_OnClick);
|
||||
MTH_FOM_FeedButton:SetScript("OnEnter", MTH_FOM_FeedButton_OnEnter);
|
||||
MTH_FOM_FeedButton:SetScript("OnLeave", MTH_FOM_FeedButton_OnLeave);
|
||||
end
|
||||
|
||||
if (FOM_Config.Level == "happy") then
|
||||
@@ -1236,16 +1236,27 @@ function FOM_DifficultyToNum(level)
|
||||
end
|
||||
end
|
||||
|
||||
local FOM_CachedPlayerClass = nil
|
||||
local FOM_OnUpdateElapsed = 0
|
||||
|
||||
function FOM_OnUpdate(elapsed)
|
||||
|
||||
_, realClass = UnitClass("player");
|
||||
if (realClass ~= "HUNTER") then return; end
|
||||
FOM_OnUpdateElapsed = FOM_OnUpdateElapsed + (elapsed or 0)
|
||||
if FOM_OnUpdateElapsed < 0.05 then
|
||||
return
|
||||
end
|
||||
local dt = FOM_OnUpdateElapsed
|
||||
FOM_OnUpdateElapsed = 0
|
||||
|
||||
if not FOM_CachedPlayerClass then
|
||||
_, FOM_CachedPlayerClass = UnitClass("player")
|
||||
end
|
||||
if (FOM_CachedPlayerClass ~= "HUNTER") then return; end
|
||||
|
||||
-- If it's been more than a second since our last tradeskill update,
|
||||
-- we can allow the event to process again.
|
||||
FOM_TradeSkillLock.EventTimer = FOM_TradeSkillLock.EventTimer + elapsed;
|
||||
FOM_TradeSkillLock.EventTimer = FOM_TradeSkillLock.EventTimer + dt;
|
||||
if (FOM_TradeSkillLock.Locked) then
|
||||
FOM_TradeSkillLock.EventCooldown = FOM_TradeSkillLock.EventCooldown + elapsed;
|
||||
FOM_TradeSkillLock.EventCooldown = FOM_TradeSkillLock.EventCooldown + dt;
|
||||
if (FOM_TradeSkillLock.EventCooldown > FOM_TradeSkillLock.EventCooldownTime) then
|
||||
|
||||
FOM_TradeSkillLock.EventCooldown = 0;
|
||||
@@ -1415,8 +1426,8 @@ function FOM_CanFeed()
|
||||
if ( UnitLevel("player") >= 40 ) then
|
||||
for _, buffTexture in mountTextureSubStrings do
|
||||
if ( string.find(buff, buffTexture) ) then
|
||||
FOMTooltip:SetUnitBuff("player", buffIndex+1);
|
||||
local msg = FOMTooltipTextLeft1:GetText();
|
||||
MTH_FOM_Tooltip:SetUnitBuff("player", buffIndex+1);
|
||||
local msg = MTH_FOM_TooltipTextLeft1:GetText();
|
||||
if (msg ~= nil) then
|
||||
msg = string.lower(msg);
|
||||
for _, mountName in FOM_MOUNT_NAME_SUBSTRINGS do
|
||||
@@ -2567,9 +2578,9 @@ function FOM_IsTemporaryFood(itemLink)
|
||||
end
|
||||
return false;
|
||||
end
|
||||
FOMTooltip:ClearLines();
|
||||
FOMTooltip:SetHyperlink(link);
|
||||
if (FOMTooltipTextLeft2:GetText() == ITEM_CONJURED) then
|
||||
MTH_FOM_Tooltip:ClearLines();
|
||||
MTH_FOM_Tooltip:SetHyperlink(link);
|
||||
if (MTH_FOM_TooltipTextLeft2:GetText() == ITEM_CONJURED) then
|
||||
if (numericItemId ~= nil) then
|
||||
FOM_TEMP_FOOD_CACHE[numericItemId] = true;
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
------------------------------------------------------
|
||||
|
||||
-- Key bindings
|
||||
BINDING_HEADER_FEEDOMATIC = "Fizzwidget Feed-O-Matic";
|
||||
-- NOTE: BINDING_HEADER_FEEDOMATIC is defined in api/localization.lua via the MTH_L() system.
|
||||
BINDING_NAME_FEEDOMATIC = "Feed Pet";
|
||||
|
||||
-- Diet names. These should be the all-lowercase versions of the six diets returned from GetPetFoodTypes(). (Want to get them all nice and quick for your localization? Go tame a bear... they eat anything.)
|
||||
@@ -111,110 +111,6 @@ FOM_OptionsButtonText = {
|
||||
};
|
||||
------------------------------------------------------
|
||||
|
||||
if (GetLocale() == "frFR") then
|
||||
|
||||
-- Diet names. These should be the all-lowercase versions of the six diets returned from GetPetFoodTypes(). (Want to get them all nice and quick for your localization? Go tame a bear... they eat anything.)
|
||||
-- THESE STRINGS MUST BE LOCALIZED for Feed-O-Matic to work properly in other locales.
|
||||
FOM_DIET_MEAT = "viande";
|
||||
FOM_DIET_FISH = "poisson";
|
||||
FOM_DIET_BREAD = "pain";
|
||||
FOM_DIET_CHEESE = "fromage";
|
||||
FOM_DIET_FRUIT = "fruit";
|
||||
FOM_DIET_FUNGUS = "champignon";
|
||||
|
||||
-- If the player has a buff whose icon name contains "Ability_Mount" and whose name contains one of these substrings, we assume the player is mounted. We have to use this rather oblique way to check for mounted because some other buffs use the Ability_Mount_* icons. If these aren't localized, we may not recognize when the player is mounted and still try to feed the pet.
|
||||
FOM_MOUNT_NAME_SUBSTRINGS = { "kodo", "loup", "raptor", "steed", "cheval", "bélier", "tigre", "mécanotrotteur", };
|
||||
|
||||
-- It's not clear whether the 5th and 6th returns from GetItemInfo() are supposed to be localized... so we have localized keys for them just in case. If these aren't localized, we'll just needlessly search your ammo bags for food.
|
||||
FOM_AMMO_POUCH = "Giberne";
|
||||
FOM_QUIVER = "Carquois";
|
||||
|
||||
|
||||
-- From here on down, the localized strings are just for readability... they don't affect whether Feed-O-Matic works.
|
||||
|
||||
-- Two special diets; one is used for tracking food that provides a bonus (or at least, that you don't want to have fed to your pet when the 'savebonus' option is on), and another that's used in the chat-line interface for listing all diets.
|
||||
FOM_DIET_BONUS = "bonus";
|
||||
FOM_DIET_ALL = "tous";
|
||||
|
||||
-- Used in tooltips to indicate food quality.
|
||||
FOM_QUALITY_UNKNOWN = "%s peut le manger, mais n'a jamais essayé.";
|
||||
FOM_QUALITY_UNDER = "%s n'en mange plus désormais.";
|
||||
FOM_QUALITY_MIGHT = "%s en mangera peut-être.";
|
||||
FOM_QUALITY_WILL = "%s en mangera.";
|
||||
FOM_QUALITY_LIKE = "%s aime en manger.";
|
||||
FOM_QUALITY_LOVE = "%s adore en manger.";
|
||||
|
||||
-- User-visible errors
|
||||
FOM_ERROR_NO_PET = "Vous n'avez pas de familier.";
|
||||
FOM_ERROR_PET_DEAD = "Votre familier est mort.";
|
||||
FOM_ERROR_NO_FEEDABLE_PET = "Vous n'avez pas de familier capable de manger.";
|
||||
FOM_ERROR_FOOD_NOT_FOUND = "%s n'a pas trouvé de %s dans votre sac.";
|
||||
FOM_ERROR_NO_FOOD = "%s n'a pas trouvé de nourriture dans votre sac.";
|
||||
|
||||
-- Feeding status messages
|
||||
FOM_FEEDING_EAT_ANOTHER = "%s n'aime pas cette nourriture et va essayer autre chose..."
|
||||
FOM_FEEDING_FEED_ANOTHER = "cherche autre chose à donner à %s...";
|
||||
FOM_FEEDING_EAT = "%s mange un(e) %s.";
|
||||
FOM_FEEDING_FEED = "donne à %s à manger un(e) %s. ";
|
||||
|
||||
-- Beast family names
|
||||
BAT = "Chauve-souris";
|
||||
BEAR = "Ours";
|
||||
BOAR = "Sanglier";
|
||||
CARRION_BIRD = "Charognard";
|
||||
CAT = "Félin";
|
||||
CRAB = "Crabe";
|
||||
CROCOLISK = "Crocilisque";
|
||||
GORILLA = "Gorille";
|
||||
HYENA = "Hyène";
|
||||
OWL = "Chouette";
|
||||
RAPTOR = "Raptor";
|
||||
SCORPID = "Scorpide";
|
||||
SPIDER = "Araignée";
|
||||
TALLSTRIDER = "Haut-trotteur";
|
||||
TURTLE = "Tortue";
|
||||
WIND_SERPENT = "Serpent des vents";
|
||||
WOLF = "Loup";
|
||||
|
||||
FOM_PET_HUNGRY = "%s a faim!";
|
||||
FOM_PET_VERY_HUNGRY = "%s a très faim!";
|
||||
|
||||
FOM_OPTIONS_HEADER = "Feed-O-Matic Options";
|
||||
FOM_OPTIONS_GENERAL = "Options générales:";
|
||||
FOM_OPTIONS_FOOD_CHOICE = "Eviter la nourriture utilisée en cuisine:";
|
||||
FOM_OPTIONS_FEED_NOTIFY = "Prévenir lorsque votre familier est nourrit:";
|
||||
FOM_OPTIONS_WARNING = "Avertir quand votre familier a besoin d'être nourrit:";
|
||||
|
||||
FOM_KEEPOPEN = "Essayer de garder au moins";
|
||||
FOM_KEEPOPEN_SLOTS = "emplacements de sac libres";
|
||||
FOM_KEEPOPEN_INFO = "(Le familier choisira la nourriture des piles les plus petites, sans tenir compte de ses préférences.)";
|
||||
|
||||
FOM_OptionsButtonText = {
|
||||
["Tooltip"] = "Afficher l'avis de votre familier concernant la nourriture",
|
||||
["AvoidQuestFood"] = "Eviter la nourriture utile dans les quêtes",
|
||||
["AvoidBonusFood"] = "Eviter la nourriture donnant un bonus",
|
||||
["PreferHigherQuality"] = "Privilégier la nourriture que votre familier préfère",
|
||||
["Fallback"] = "Utiliser la nourriture évitée s'il n'y en a plus d'autres",
|
||||
["SaveForCook_All"] = "Toutes nourritures utilisées pour la cuisine",
|
||||
["SaveForCook_Green"] = "si elle est utilisée dans les recettes |cff3fbf3f\"faciles\"|r ou supérieures",
|
||||
["SaveForCook_Yellow"] = "si elle est utilisée dans les recettes |cffffff00\"moyennes\"|r ou supérieures",
|
||||
["SaveForCook_Orange"] = "si elle est utilisée dans les recettes |cffff7f3f\"difficiles\"|r",
|
||||
["SaveForCook_None"] = "Ne pas éviter la nourriture utilisée en cuisine",
|
||||
["IconWarning"] = "Clignoter l'icône",
|
||||
["TextWarning"] = "Afficher un texte",
|
||||
["AudioWarning"] = "Jouer un son",
|
||||
["AudioWarningBell"] = "Un son de cloche au lieu du cri du familier",
|
||||
["AlertEmote"] = "Via emote (visible par les autres)",
|
||||
["AlertChat"] = "Dans la fenêtre de discussion (visible uniquement par vous)",
|
||||
["AlertNone"] = "Ne pas prévenir",
|
||||
["LevelContent"] = "quand \"content\"",
|
||||
["LevelUnhappy"] = "quand \"mécontent\"",
|
||||
["LevelOff"] = "Ne pas avertir",
|
||||
};
|
||||
end
|
||||
|
||||
------------------------------------------------------
|
||||
|
||||
if (GetLocale() == "deDE") then
|
||||
|
||||
-- Diet names. These should be the all-lowercase versions of the six diets returned from GetPetFoodTypes(). (Want to get them all nice and quick for your localization? Go tame a bear... they eat anything.)
|
||||
@@ -279,26 +175,4 @@ if (GetLocale() == "deDE") then
|
||||
WIND_SERPENT = "Windnatter";
|
||||
-- WOLF = "Wolf"; -- same as enUS
|
||||
|
||||
end
|
||||
|
||||
------------------------------------------------------
|
||||
|
||||
if (GetLocale() == "koKR") then
|
||||
|
||||
-- Diet names. These should be the all-lowercase versions of the six diets returned from GetPetFoodTypes(). (Want to get them all nice and quick for your localization? Go tame a bear... they eat anything.)
|
||||
-- THESE STRINGS MUST BE LOCALIZED for Feed-O-Matic to work properly in other locales.
|
||||
-- FOM_DIET_MEAT = "meat";
|
||||
-- FOM_DIET_FISH = "fish";
|
||||
-- FOM_DIET_BREAD = "bread";
|
||||
-- FOM_DIET_CHEESE = "cheese";
|
||||
-- FOM_DIET_FRUIT = "fruit";
|
||||
-- FOM_DIET_FUNGUS = "fungus";
|
||||
|
||||
-- If the player has a buff whose icon name contains "Ability_Mount" and whose name contains one of these substrings, we assume the player is mounted. We have to use this rather oblique way to check for mounted because some other buffs use the Ability_Mount_* icons.
|
||||
-- FOM_MOUNT_NAME_SUBSTRINGS = { "kodo", "wolf", "raptor", "steed", "horse", "ram", "saber", "mechanostrider" };
|
||||
|
||||
-- It's not clear whether the 5th and 6th returns from GetItemInfo() are supposed to be localized... so we have localized keys for them just in case.
|
||||
-- FOM_AMMO_POUCH = "Ammo Pouch";
|
||||
FOM_QUIVER = "화살통";
|
||||
|
||||
end
|
||||
@@ -6,7 +6,7 @@
|
||||
local MTH_FeedOMatic = {
|
||||
name = "feedomatic",
|
||||
enabled = false,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"MERCHANT_SHOW",
|
||||
@@ -32,7 +32,7 @@ local MTH_FeedOMatic = {
|
||||
}
|
||||
|
||||
local MTH_PETL_HOOK_BOUNDARY_KEY = "pet-lifecycle-hooks"
|
||||
local MTH_FeedOMatic_MerchantProbeFrame = nil
|
||||
local MTH_FOM_MerchantProbe = nil
|
||||
|
||||
function MTH_FeedOMatic_OnUpdate(elapsed)
|
||||
if not elapsed then
|
||||
@@ -47,7 +47,7 @@ function MTH_FeedOMatic_OnUpdate(elapsed)
|
||||
end
|
||||
|
||||
local function MTH_FeedOMatic_GetRuntimeFrame()
|
||||
return getglobal("Frame_GFW_FeedOMatic")
|
||||
return getglobal("MTH_FOM_OnUpdateFrame")
|
||||
end
|
||||
|
||||
local function MTH_FeedOMatic_CaptureHookBoundary()
|
||||
@@ -216,16 +216,16 @@ end
|
||||
|
||||
local function MTH_FeedOMatic_SetMerchantProbeEnabled(enabled)
|
||||
if not enabled then
|
||||
if MTH_FeedOMatic_MerchantProbeFrame then
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_UPDATE")
|
||||
if MTH_FOM_MerchantProbe then
|
||||
MTH_FOM_MerchantProbe:UnregisterEvent("MERCHANT_SHOW")
|
||||
MTH_FOM_MerchantProbe:UnregisterEvent("MERCHANT_UPDATE")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not MTH_FeedOMatic_MerchantProbeFrame then
|
||||
MTH_FeedOMatic_MerchantProbeFrame = CreateFrame("Frame", "MTH_FeedOMatic_MerchantProbeFrame")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:SetScript("OnEvent", function()
|
||||
if not MTH_FOM_MerchantProbe then
|
||||
MTH_FOM_MerchantProbe = CreateFrame("Frame", "MTH_FOM_MerchantProbe")
|
||||
MTH_FOM_MerchantProbe:SetScript("OnEvent", function()
|
||||
local evt = event
|
||||
if evt == "MERCHANT_SHOW" or evt == "MERCHANT_UPDATE" then
|
||||
MTH_FeedOMatic_Log("probe event received: " .. tostring(evt), "debug")
|
||||
@@ -234,8 +234,8 @@ local function MTH_FeedOMatic_SetMerchantProbeEnabled(enabled)
|
||||
end)
|
||||
end
|
||||
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_UPDATE")
|
||||
MTH_FOM_MerchantProbe:RegisterEvent("MERCHANT_SHOW")
|
||||
MTH_FOM_MerchantProbe:RegisterEvent("MERCHANT_UPDATE")
|
||||
MTH_FeedOMatic_Log("merchant probe enabled", "debug")
|
||||
end
|
||||
|
||||
@@ -277,8 +277,8 @@ function MTH_FeedOMatic:setEnabled(enabled)
|
||||
MTH_FeedOMatic_SyncSavedVariables()
|
||||
MTH_FeedOMatic_EnsureVariablesLoaded(self)
|
||||
MTH_FeedOMatic_SetMerchantProbeEnabled(false)
|
||||
if FOM_FeedButton then
|
||||
FOM_FeedButton:Show()
|
||||
if MTH_FOM_FeedButton then
|
||||
MTH_FOM_FeedButton:Show()
|
||||
end
|
||||
else
|
||||
-- Disable FeedOMatic functionality
|
||||
@@ -287,8 +287,8 @@ function MTH_FeedOMatic:setEnabled(enabled)
|
||||
FOM_State.ShouldFeed = false
|
||||
end
|
||||
MTH_FeedOMatic_SetMerchantProbeEnabled(false)
|
||||
if FOM_FeedButton then
|
||||
FOM_FeedButton:Hide()
|
||||
if MTH_FOM_FeedButton then
|
||||
MTH_FOM_FeedButton:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -316,8 +316,8 @@ function MTH_FeedOMatic:cleanup()
|
||||
FOM_State.ShouldFeed = false
|
||||
end
|
||||
MTH_FeedOMatic_SetMerchantProbeEnabled(false)
|
||||
if FOM_FeedButton then
|
||||
FOM_FeedButton:Hide();
|
||||
if MTH_FOM_FeedButton then
|
||||
MTH_FOM_FeedButton:Hide();
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ FeedOMatic Runtime Frame Loader (MetaHunt)
|
||||
Minimal runtime XML without legacy options window definitions.
|
||||
-->
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\..\FrameXML\UI.xsd">
|
||||
<Frame name="Frame_GFW_FeedOMatic">
|
||||
<Frame name="MTH_FOM_OnUpdateFrame">
|
||||
<Scripts>
|
||||
<OnUpdate>
|
||||
if (MTH_FOM_OnUpdate) then
|
||||
@@ -15,7 +15,7 @@ Minimal runtime XML without legacy options window definitions.
|
||||
</Scripts>
|
||||
</Frame>
|
||||
|
||||
<GameTooltip name="FOMTooltip" frameStrata="TOOLTIP" hidden="true" parent="UIParent" inherits="GameTooltipTemplate">
|
||||
<GameTooltip name="MTH_FOM_Tooltip" frameStrata="TOOLTIP" hidden="true" parent="UIParent" inherits="GameTooltipTemplate">
|
||||
<Scripts>
|
||||
<OnLoad>
|
||||
this:SetOwner(UIParent, "ANCHOR_NONE");
|
||||
|
||||
+1127
-1127
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
local MTH_ICU = {
|
||||
name = "icu",
|
||||
enabled = false,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
},
|
||||
|
||||
+790
-774
File diff suppressed because it is too large
Load Diff
@@ -7,10 +7,10 @@ MTH_SA_MANAGED_HOOKS = true
|
||||
local MTH_SmartAmmo = {
|
||||
name = "smartammo",
|
||||
enabled = true,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"PLAYER_ENTERING_WORLD",
|
||||
-- PLAYER_ENTERING_WORLD handled by engine's own frame
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+13
-16
@@ -6,7 +6,7 @@
|
||||
local MTH_Tooltips = {
|
||||
name = "tooltips",
|
||||
enabled = true,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"UPDATE_MOUSEOVER_UNIT",
|
||||
"UNIT_NAME_UPDATE",
|
||||
@@ -1545,19 +1545,18 @@ local function MTH_TT_EnsureInjectFrame()
|
||||
if MTH_Tooltips.injectFrame then
|
||||
return MTH_Tooltips.injectFrame
|
||||
end
|
||||
local frame = CreateFrame("Frame", "MTH_TooltipsInjectFrame")
|
||||
local frame = CreateFrame("Frame", "MTH_TooltipsInject")
|
||||
frame.pending = false
|
||||
frame.onUpdate = function(self)
|
||||
self = self or this
|
||||
if not self then
|
||||
frame.onUpdate = function()
|
||||
if not this then
|
||||
return
|
||||
end
|
||||
if not self.pending then
|
||||
self:SetScript("OnUpdate", nil)
|
||||
if not this.pending then
|
||||
this:SetScript("OnUpdate", nil)
|
||||
return
|
||||
end
|
||||
self.pending = false
|
||||
self:SetScript("OnUpdate", nil)
|
||||
this.pending = false
|
||||
this:SetScript("OnUpdate", nil)
|
||||
if MTH_Tooltips and MTH_Tooltips.enabled then
|
||||
MTH_TT_AddTooltip("mouseover")
|
||||
end
|
||||
@@ -1581,14 +1580,13 @@ local function MTH_TT_EnsurePollFrame()
|
||||
return MTH_Tooltips.pollFrame
|
||||
end
|
||||
|
||||
local frame = CreateFrame("Frame", "MTH_TooltipsPollFrame")
|
||||
frame:SetScript("OnUpdate", function(_, elapsed)
|
||||
local frame = CreateFrame("Frame", "MTH_TooltipsPoll")
|
||||
frame:SetScript("OnUpdate", function()
|
||||
if not (MTH_Tooltips and MTH_Tooltips.enabled) then
|
||||
return
|
||||
end
|
||||
|
||||
elapsed = elapsed or arg1
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (elapsed or 0)
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (arg1 or 0)
|
||||
if MTH_Tooltips.hintElapsed >= 0.25 then
|
||||
MTH_Tooltips.hintElapsed = 0
|
||||
if GameTooltip and GameTooltip.IsShown and GameTooltip:IsShown() then
|
||||
@@ -1648,13 +1646,12 @@ local function MTH_TT_SetRuntimeActive(active)
|
||||
local pollFrame = MTH_Tooltips.pollFrame
|
||||
if pollFrame then
|
||||
if active then
|
||||
pollFrame:SetScript("OnUpdate", pollFrame:GetScript("OnUpdate") or function(_, elapsed)
|
||||
pollFrame:SetScript("OnUpdate", pollFrame:GetScript("OnUpdate") or function()
|
||||
if not (MTH_Tooltips and MTH_Tooltips.enabled) then
|
||||
return
|
||||
end
|
||||
|
||||
elapsed = elapsed or arg1
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (elapsed or 0)
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (arg1 or 0)
|
||||
if MTH_Tooltips.hintElapsed >= 0.25 then
|
||||
MTH_Tooltips.hintElapsed = 0
|
||||
if GameTooltip and GameTooltip.IsShown and GameTooltip:IsShown() then
|
||||
|
||||
+217
-217
@@ -1,217 +1,217 @@
|
||||
if not ZHunterMod_Saved then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
|
||||
BINDING_HEADER_ZAspectHeader = "ZAspect Buttons"
|
||||
BINDING_HEADER_ZTrackHeader = "ZTrack Buttons"
|
||||
BINDING_HEADER_ZTrapHeader = "ZTrap Buttons"
|
||||
BINDING_HEADER_ZPetHeader = "ZPet Buttons"
|
||||
BINDING_HEADER_ZAmmoHeader = "ZAmmo Buttons"
|
||||
BINDING_HEADER_ZMountsHeader = "ZMounts Buttons"
|
||||
BINDING_HEADER_ZCompanionsHeader = "ZCompanions Buttons"
|
||||
BINDING_HEADER_ZToysHeader = "ZToys Buttons"
|
||||
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "ZHunterModScan", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltipTextLeft1 = getglobal("ZHunterModScanTextLeft1")
|
||||
|
||||
MTH_ZH_TRACE_ENABLED = false
|
||||
|
||||
local function MTH_ZH_DescribePoint(frame)
|
||||
if not (frame and frame.GetPoint) then
|
||||
return "<no-frame>"
|
||||
end
|
||||
local point, relTo, relPoint, x, y = frame:GetPoint()
|
||||
local relName = "nil"
|
||||
if type(relTo) == "table" and relTo.GetName then
|
||||
relName = tostring(relTo:GetName() or "<anon>")
|
||||
elseif relTo then
|
||||
relName = tostring(relTo)
|
||||
end
|
||||
return tostring(point or "nil")
|
||||
.. "->" .. relName
|
||||
.. ":" .. tostring(relPoint or "nil")
|
||||
.. " @(" .. tostring(x) .. "," .. tostring(y) .. ")"
|
||||
end
|
||||
|
||||
function MTH_ZH_Trace(msg)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print("[ZHTRACE] " .. tostring(msg), "debug")
|
||||
elseif DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[ZHTRACE] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceButtonPoint(frame, reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if not frame then
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " frame=nil")
|
||||
return
|
||||
end
|
||||
local name = frame.GetName and frame:GetName() or "<unnamed>"
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " " .. tostring(name) .. " " .. MTH_ZH_DescribePoint(frame))
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceAllButtonPoints(reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
local names = {
|
||||
"zButtonAspect",
|
||||
"zButtonAmmo",
|
||||
"zButtonTrack",
|
||||
"zButtonTrap",
|
||||
"zButtonRanged",
|
||||
"zButtonPet",
|
||||
"zButtonMounts",
|
||||
"zButtonCompanions",
|
||||
"zButtonToys",
|
||||
}
|
||||
MTH_ZH_Trace("snapshot begin reason=" .. tostring(reason or ""))
|
||||
for i = 1, table.getn(names) do
|
||||
local frame = getglobal(names[i])
|
||||
MTH_ZH_TraceButtonPoint(frame, tostring(reason or "") .. ":" .. tostring(names[i]))
|
||||
end
|
||||
MTH_ZH_Trace("snapshot end reason=" .. tostring(reason or ""))
|
||||
end
|
||||
|
||||
function MTH_ZH_IsModuleEnabled()
|
||||
if not (MTH and MTH.IsModuleEnabled) then
|
||||
return true
|
||||
end
|
||||
return MTH:IsModuleEnabled("zhunter", true)
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedRoot()
|
||||
if type(ZHunterMod_Saved) ~= "table" then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
return ZHunterMod_Saved
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedTable(key)
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(key) ~= "string" or key == "" then
|
||||
return root
|
||||
end
|
||||
if type(root[key]) ~= "table" then
|
||||
root[key] = {}
|
||||
end
|
||||
return root[key]
|
||||
end
|
||||
|
||||
local function MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(root) ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
local mapping = {
|
||||
{"ZHunterButtonAspect", "zButtonAspect"},
|
||||
{"ZHunterButtonTrack", "zButtonTrack"},
|
||||
{"ZHunterButtonTrap", "zButtonTrap"},
|
||||
{"ZHunterButtonAmmo", "zButtonAmmo"},
|
||||
{"ZHunterButtonPet", "zButtonPet"},
|
||||
{"ZHunterButtonMounts", "zButtonMounts"},
|
||||
{"ZHunterButtonCompanions", "zButtonCompanions"},
|
||||
{"ZHunterButtonToys", "zButtonToys"},
|
||||
}
|
||||
|
||||
for i = 1, table.getn(mapping) do
|
||||
local oldKey = mapping[i][1]
|
||||
local newKey = mapping[i][2]
|
||||
if root[oldKey] ~= nil then
|
||||
root[newKey] = root[oldKey]
|
||||
root[oldKey] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
|
||||
function MTH_ZH_Print(message, severity)
|
||||
if type(MTH_Log) == "function" then
|
||||
MTH_Log(message, severity)
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print(message, severity)
|
||||
return
|
||||
end
|
||||
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[MetaHunt] " .. tostring(message or ""), 1, 0.9, 0.3)
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_HandleDisabledSlash(message, tableKey, fieldKey)
|
||||
if MTH_ZH_IsModuleEnabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tableKey) == "string" and tableKey ~= "" then
|
||||
if fieldKey then
|
||||
local tbl = MTH_ZH_GetSavedTable(tableKey)
|
||||
tbl[fieldKey] = nil
|
||||
else
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
root[tableKey] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if message then
|
||||
MTH_ZH_Print(message)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ZHunterMod_AlignButtons()
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:before")
|
||||
zButtonAmmo:ClearAllPoints()
|
||||
zButtonAmmo:SetPoint("TOP", zButtonAspect, "BOTTOM", 0, -15)
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("TOP", zButtonAmmo, "BOTTOM", 0, -15)
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("TOP", zButtonTrack, "BOTTOM", 0, -15)
|
||||
zButtonPet:ClearAllPoints()
|
||||
zButtonPet:SetPoint("TOP", zButtonTrap, "BOTTOM", 0, -15)
|
||||
zButtonMounts:ClearAllPoints()
|
||||
zButtonMounts:SetPoint("TOP", zButtonPet, "BOTTOM", 0, -15)
|
||||
zButtonCompanions:ClearAllPoints()
|
||||
zButtonCompanions:SetPoint("TOP", zButtonMounts, "BOTTOM", 0, -15)
|
||||
zButtonToys:ClearAllPoints()
|
||||
zButtonToys:SetPoint("TOP", zButtonCompanions, "BOTTOM", 0, -15)
|
||||
if AutoStripDisplay then
|
||||
AutoStripDisplay:ClearAllPoints()
|
||||
AutoStripDisplay:SetPoint("TOP", zButtonToys, "BOTTOM", 0, -10)
|
||||
end
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:after")
|
||||
end
|
||||
|
||||
function ZMarkTarget()
|
||||
if not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
if not UnitExists("target") then return end
|
||||
for i=1, 40 do
|
||||
if not UnitDebuff("target", i) then break end
|
||||
ZHunterModTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
ZHunterModTooltip:SetUnitDebuff("target", i)
|
||||
local spell = ZHunterModTooltipTextLeft1:GetText()
|
||||
if spell == ZHUNTER_HUNTERSMARK then
|
||||
return
|
||||
end
|
||||
end
|
||||
CastSpellByName(ZHUNTER_HUNTERSMARK)
|
||||
return 1
|
||||
end
|
||||
|
||||
SLASH_ZHunterMod1 = "/zhunter"
|
||||
SlashCmdList["ZHunterMod"] = function(msg)
|
||||
MTH_ZH_Print("Possible Slash Commands: \"/zammo\", \"/zaspect\", \"/ztrack\", \"/ztrap\", \"/zpet\", \"/zmounts\", \"/zcompanions\", \"/zminipets\", \"/ztoys\", \"/zstrip\", \"/zantidaze\"")
|
||||
end
|
||||
if not ZHunterMod_Saved then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
|
||||
BINDING_HEADER_ZAspectHeader = "ZAspect Buttons"
|
||||
BINDING_HEADER_ZTrackHeader = "ZTrack Buttons"
|
||||
BINDING_HEADER_ZTrapHeader = "ZTrap Buttons"
|
||||
BINDING_HEADER_ZPetHeader = "ZPet Buttons"
|
||||
BINDING_HEADER_ZAmmoHeader = "ZAmmo Buttons"
|
||||
BINDING_HEADER_ZMountsHeader = "ZMounts Buttons"
|
||||
BINDING_HEADER_ZCompanionsHeader = "ZCompanions Buttons"
|
||||
BINDING_HEADER_ZToysHeader = "ZToys Buttons"
|
||||
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "MTH_ZH_AbilityProbe", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltipTextLeft1 = getglobal("MTH_ZH_AbilityProbeTextLeft1")
|
||||
|
||||
MTH_ZH_TRACE_ENABLED = false
|
||||
|
||||
local function MTH_ZH_DescribePoint(frame)
|
||||
if not (frame and frame.GetPoint) then
|
||||
return "<no-frame>"
|
||||
end
|
||||
local point, relTo, relPoint, x, y = frame:GetPoint()
|
||||
local relName = "nil"
|
||||
if type(relTo) == "table" and relTo.GetName then
|
||||
relName = tostring(relTo:GetName() or "<anon>")
|
||||
elseif relTo then
|
||||
relName = tostring(relTo)
|
||||
end
|
||||
return tostring(point or "nil")
|
||||
.. "->" .. relName
|
||||
.. ":" .. tostring(relPoint or "nil")
|
||||
.. " @(" .. tostring(x) .. "," .. tostring(y) .. ")"
|
||||
end
|
||||
|
||||
function MTH_ZH_Trace(msg)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print("[ZHTRACE] " .. tostring(msg), "debug")
|
||||
elseif DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[ZHTRACE] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceButtonPoint(frame, reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if not frame then
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " frame=nil")
|
||||
return
|
||||
end
|
||||
local name = frame.GetName and frame:GetName() or "<unnamed>"
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " " .. tostring(name) .. " " .. MTH_ZH_DescribePoint(frame))
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceAllButtonPoints(reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
local names = {
|
||||
"zButtonAspect",
|
||||
"zButtonAmmo",
|
||||
"zButtonTrack",
|
||||
"zButtonTrap",
|
||||
"zButtonRanged",
|
||||
"zButtonPet",
|
||||
"zButtonMounts",
|
||||
"zButtonCompanions",
|
||||
"zButtonToys",
|
||||
}
|
||||
MTH_ZH_Trace("snapshot begin reason=" .. tostring(reason or ""))
|
||||
for i = 1, table.getn(names) do
|
||||
local frame = getglobal(names[i])
|
||||
MTH_ZH_TraceButtonPoint(frame, tostring(reason or "") .. ":" .. tostring(names[i]))
|
||||
end
|
||||
MTH_ZH_Trace("snapshot end reason=" .. tostring(reason or ""))
|
||||
end
|
||||
|
||||
function MTH_ZH_IsModuleEnabled()
|
||||
if not (MTH and MTH.IsModuleEnabled) then
|
||||
return true
|
||||
end
|
||||
return MTH:IsModuleEnabled("zhunter", true)
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedRoot()
|
||||
if type(ZHunterMod_Saved) ~= "table" then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
return ZHunterMod_Saved
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedTable(key)
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(key) ~= "string" or key == "" then
|
||||
return root
|
||||
end
|
||||
if type(root[key]) ~= "table" then
|
||||
root[key] = {}
|
||||
end
|
||||
return root[key]
|
||||
end
|
||||
|
||||
local function MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(root) ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
local mapping = {
|
||||
{"ZHunterButtonAspect", "zButtonAspect"},
|
||||
{"ZHunterButtonTrack", "zButtonTrack"},
|
||||
{"ZHunterButtonTrap", "zButtonTrap"},
|
||||
{"ZHunterButtonAmmo", "zButtonAmmo"},
|
||||
{"ZHunterButtonPet", "zButtonPet"},
|
||||
{"ZHunterButtonMounts", "zButtonMounts"},
|
||||
{"ZHunterButtonCompanions", "zButtonCompanions"},
|
||||
{"ZHunterButtonToys", "zButtonToys"},
|
||||
}
|
||||
|
||||
for i = 1, table.getn(mapping) do
|
||||
local oldKey = mapping[i][1]
|
||||
local newKey = mapping[i][2]
|
||||
if root[oldKey] ~= nil then
|
||||
root[newKey] = root[oldKey]
|
||||
root[oldKey] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
|
||||
function MTH_ZH_Print(message, severity)
|
||||
if type(MTH_Log) == "function" then
|
||||
MTH_Log(message, severity)
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print(message, severity)
|
||||
return
|
||||
end
|
||||
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[MetaHunt] " .. tostring(message or ""), 1, 0.9, 0.3)
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_HandleDisabledSlash(message, tableKey, fieldKey)
|
||||
if MTH_ZH_IsModuleEnabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tableKey) == "string" and tableKey ~= "" then
|
||||
if fieldKey then
|
||||
local tbl = MTH_ZH_GetSavedTable(tableKey)
|
||||
tbl[fieldKey] = nil
|
||||
else
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
root[tableKey] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if message then
|
||||
MTH_ZH_Print(message)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ZHunterMod_AlignButtons()
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:before")
|
||||
zButtonAmmo:ClearAllPoints()
|
||||
zButtonAmmo:SetPoint("TOP", zButtonAspect, "BOTTOM", 0, -15)
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("TOP", zButtonAmmo, "BOTTOM", 0, -15)
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("TOP", zButtonTrack, "BOTTOM", 0, -15)
|
||||
zButtonPet:ClearAllPoints()
|
||||
zButtonPet:SetPoint("TOP", zButtonTrap, "BOTTOM", 0, -15)
|
||||
zButtonMounts:ClearAllPoints()
|
||||
zButtonMounts:SetPoint("TOP", zButtonPet, "BOTTOM", 0, -15)
|
||||
zButtonCompanions:ClearAllPoints()
|
||||
zButtonCompanions:SetPoint("TOP", zButtonMounts, "BOTTOM", 0, -15)
|
||||
zButtonToys:ClearAllPoints()
|
||||
zButtonToys:SetPoint("TOP", zButtonCompanions, "BOTTOM", 0, -15)
|
||||
if AutoStripDisplay then
|
||||
AutoStripDisplay:ClearAllPoints()
|
||||
AutoStripDisplay:SetPoint("TOP", zButtonToys, "BOTTOM", 0, -10)
|
||||
end
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:after")
|
||||
end
|
||||
|
||||
function ZMarkTarget()
|
||||
if not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
if not UnitExists("target") then return end
|
||||
for i=1, 40 do
|
||||
if not UnitDebuff("target", i) then break end
|
||||
ZHunterModTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
ZHunterModTooltip:SetUnitDebuff("target", i)
|
||||
local spell = ZHunterModTooltipTextLeft1:GetText()
|
||||
if spell == ZHUNTER_HUNTERSMARK then
|
||||
return
|
||||
end
|
||||
end
|
||||
CastSpellByName(ZHUNTER_HUNTERSMARK)
|
||||
return 1
|
||||
end
|
||||
|
||||
SLASH_ZHunterMod1 = "/zhunter"
|
||||
SlashCmdList["ZHunterMod"] = function(msg)
|
||||
MTH_ZH_Print("Possible Slash Commands: \"/zammo\", \"/zaspect\", \"/ztrack\", \"/ztrap\", \"/zpet\", \"/zmounts\", \"/zcompanions\", \"/zminipets\", \"/ztoys\", \"/zstrip\", \"/zantidaze\"")
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+36
-20
@@ -8,10 +8,10 @@ MTH_ZH_MANAGED_HOOKS = true
|
||||
local MTH_ZHunter = {
|
||||
name = "zhunter",
|
||||
enabled = true,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"PLAYER_ENTERING_WORLD",
|
||||
-- PLAYER_ENTERING_WORLD handled by bootstrap frame + adjustment frames
|
||||
"MTH_PET_LIVE_STATE_CHANGED",
|
||||
},
|
||||
features = {
|
||||
@@ -37,7 +37,7 @@ local function MTH_ZH_TraceLocal(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local MTH_ZH_PostLoginRestoreFrame = nil
|
||||
local MTH_ZH_PostLoginRestore = nil
|
||||
local MTH_ZH_BootstrapFrame = nil
|
||||
local MTH_ZH_SyncSavedVariables
|
||||
local MTH_ZH_SetButtonsVisible
|
||||
@@ -116,15 +116,15 @@ function MTH_ZH_OnDeferredInitComplete()
|
||||
end
|
||||
|
||||
MTH_ZH_QueuePostLoginRestore = function(tag)
|
||||
if not MTH_ZH_PostLoginRestoreFrame then
|
||||
MTH_ZH_PostLoginRestoreFrame = CreateFrame("Frame", "MTH_ZH_PostLoginRestoreFrame")
|
||||
if not MTH_ZH_PostLoginRestoreFrame then
|
||||
if not MTH_ZH_PostLoginRestore then
|
||||
MTH_ZH_PostLoginRestore = CreateFrame("Frame", "MTH_ZH_PostLoginRestore")
|
||||
if not MTH_ZH_PostLoginRestore then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_PostLoginRestoreFrame._mthElapsed = 0
|
||||
MTH_ZH_PostLoginRestoreFrame:SetScript("OnUpdate", function()
|
||||
MTH_ZH_PostLoginRestore._mthElapsed = 0
|
||||
MTH_ZH_PostLoginRestore:SetScript("OnUpdate", function()
|
||||
this._mthElapsed = (this._mthElapsed or 0) + (arg1 or 0)
|
||||
if this._mthElapsed < 0.2 then
|
||||
return
|
||||
@@ -149,7 +149,7 @@ local function MTH_ZH_EnsureBootstrapRestoreFrame()
|
||||
return MTH_ZH_BootstrapFrame
|
||||
end
|
||||
|
||||
MTH_ZH_BootstrapFrame = CreateFrame("Frame", "MTH_ZH_BootstrapRestoreFrame")
|
||||
MTH_ZH_BootstrapFrame = CreateFrame("Frame", "MTH_ZH_BootstrapRestore")
|
||||
if not MTH_ZH_BootstrapFrame then
|
||||
return nil
|
||||
end
|
||||
@@ -297,10 +297,26 @@ MTH_ZH_SetButtonsVisible = function(visible)
|
||||
if type(MTH_ZH_TraceButtonPoint) == "function" then
|
||||
MTH_ZH_TraceButtonPoint(button, "set-buttons-visible:before:" .. tostring(buttonName))
|
||||
end
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, visible)
|
||||
if visible then
|
||||
button:Show()
|
||||
-- Respect per-button enabled state
|
||||
local getterName = buttonName .. "_GetSaved"
|
||||
local getter = getglobal(getterName)
|
||||
local shouldShow = true
|
||||
if type(getter) == "function" then
|
||||
local ok, saved = pcall(getter)
|
||||
if ok and type(saved) == "table" and (saved["enabled"] == false or saved["enabled"] == 0) then
|
||||
shouldShow = false
|
||||
end
|
||||
end
|
||||
if shouldShow then
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, true)
|
||||
button:Show()
|
||||
else
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, false)
|
||||
button:Hide()
|
||||
end
|
||||
else
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, false)
|
||||
button:Hide()
|
||||
end
|
||||
if type(MTH_ZH_TraceButtonPoint) == "function" then
|
||||
@@ -316,15 +332,15 @@ end
|
||||
|
||||
local function MTH_ZH_SetAdjustmentHandlersActive(active)
|
||||
local frameSpecs = {
|
||||
{ frame = "zButtonAspectAdjustment", handler = "zButtonAspectAdjustment_OnEvent", getter = "zButtonAspect_GetSaved" },
|
||||
{ frame = "zButtonTrackAdjustment", handler = "zButtonTrackAdjustment_OnEvent", getter = "zButtonTrack_GetSaved" },
|
||||
{ frame = "zButtonTrapAdjustment", handler = "zButtonTrapAdjustment_OnEvent", getter = "zButtonTrap_GetSaved" },
|
||||
{ frame = "zButtonRangedAdjustment", handler = "zButtonRangedAdjustment_OnEvent", getter = "zButtonRanged_GetSaved" },
|
||||
{ frame = "zButtonAmmoAdjustment", handler = "zButtonAmmoAdjustment_OnEvent", getter = "zButtonAmmo_GetSaved" },
|
||||
{ frame = "zButtonPetAdjustment", handler = "zButtonPetAdjustment_OnEvent", getter = "zButtonPet_GetSaved" },
|
||||
{ frame = "zButtonMountsAdjustment", handler = "zButtonMountsAdjustment_OnEvent", getter = "zButtonMounts_GetSaved" },
|
||||
{ frame = "zButtonCompanionsAdjustment", handler = "zButtonCompanionsAdjustment_OnEvent", getter = "zButtonCompanions_GetSaved" },
|
||||
{ frame = "zButtonToysAdjustment", handler = "zButtonToysAdjustment_OnEvent", getter = "zButtonToys_GetSaved" },
|
||||
{ frame = "MTH_ZH_AspectAdjust", handler = "MTH_ZH_AspectAdjust_OnEvent", getter = "zButtonAspect_GetSaved" },
|
||||
{ frame = "MTH_ZH_TrackAdjust", handler = "MTH_ZH_TrackAdjust_OnEvent", getter = "zButtonTrack_GetSaved" },
|
||||
{ frame = "MTH_ZH_TrapAdjust", handler = "MTH_ZH_TrapAdjust_OnEvent", getter = "zButtonTrap_GetSaved" },
|
||||
{ frame = "MTH_ZH_RangedAdjust", handler = "MTH_ZH_RangedAdjust_OnEvent", getter = "zButtonRanged_GetSaved" },
|
||||
{ frame = "MTH_ZH_AmmoAdjust", handler = "MTH_ZH_AmmoAdjust_OnEvent", getter = "zButtonAmmo_GetSaved" },
|
||||
{ frame = "MTH_ZH_PetAdjust", handler = "MTH_ZH_PetAdjust_OnEvent", getter = "zButtonPet_GetSaved" },
|
||||
{ frame = "MTH_ZH_MountsAdjust", handler = "MTH_ZH_MountsAdjust_OnEvent", getter = "zButtonMounts_GetSaved" },
|
||||
{ frame = "MTH_ZH_CompanionsAdjust", handler = "MTH_ZH_CompanionsAdjust_OnEvent", getter = "zButtonCompanions_GetSaved" },
|
||||
{ frame = "MTH_ZH_ToysAdjust", handler = "MTH_ZH_ToysAdjust_OnEvent", getter = "zButtonToys_GetSaved" },
|
||||
}
|
||||
|
||||
local function isFeatureEnabled(getterName)
|
||||
|
||||
+1132
-1130
File diff suppressed because it is too large
Load Diff
+392
-390
@@ -1,391 +1,393 @@
|
||||
local function zButtonAspect_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonAspect_GetRoot()
|
||||
if not root["zButtonAspect"] then
|
||||
root["zButtonAspect"] = {}
|
||||
root["zButtonAspect"]["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
root["zButtonAspect"]["rows"] = 1
|
||||
root["zButtonAspect"]["horizontal"] = nil
|
||||
root["zButtonAspect"]["vertical"] = nil
|
||||
root["zButtonAspect"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonAspect"]["enabled"] = 1
|
||||
root["zButtonAspect"]["tooltip"] = 1
|
||||
root["zButtonAspect"]["parent"] = {}
|
||||
root["zButtonAspect"]["parent"]["size"] = 36
|
||||
root["zButtonAspect"]["parent"]["hide"] = nil
|
||||
root["zButtonAspect"]["parent"]["circle"] = 1
|
||||
root["zButtonAspect"]["children"] = {}
|
||||
root["zButtonAspect"]["children"]["size"] = 36
|
||||
root["zButtonAspect"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Aspect_Spells = {
|
||||
ZHUNTER_ASPECT_HAWK,
|
||||
ZHUNTER_ASPECT_MONKEY,
|
||||
ZHUNTER_ASPECT_WOLF,
|
||||
ZHUNTER_ASPECT_CHEETAH,
|
||||
ZHUNTER_ASPECT_PACK,
|
||||
ZHUNTER_ASPECT_WILD,
|
||||
ZHUNTER_ASPECT_BEAST
|
||||
}
|
||||
|
||||
local ZHUNTER_ASPECT_MAX = table.getn(ZHunterMod_Aspect_Spells)
|
||||
local zButtonAspect_LastAuraUpdateAt = 0
|
||||
local zButtonAspect_MinAuraInterval = 0.15
|
||||
local zButtonAspect_MinAuraIntervalCombat = 0.60
|
||||
local zButtonAspect_LastAuraTexture = nil
|
||||
local zButtonAspect_LastParentId = nil
|
||||
local zButtonAspect_AuraProbeTextLeft1 = nil
|
||||
|
||||
local function zButtonAspect_GetSaved()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
if not currentRoot["zButtonAspect"] then
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
end
|
||||
return currentRoot["zButtonAspect"]
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_ASPECT_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonAspect_ApplyRuntimeSettings()
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
zButtonAspect.tooltip = saved["tooltip"] and true or false
|
||||
zButtonAspect.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
local function zButtonAspect_IsKnownAspectSpellId(spellId)
|
||||
if not spellId then
|
||||
return false
|
||||
end
|
||||
local spellName = GetSpellName(spellId, "spell")
|
||||
if not spellName or spellName == "" then
|
||||
return false
|
||||
end
|
||||
for i = 1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if ZHunterMod_Aspect_Spells[i] == spellName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureValidParentId()
|
||||
if not (zButtonAspect and zButtonAspect.count) then
|
||||
return
|
||||
end
|
||||
|
||||
if zButtonAspect_IsKnownAspectSpellId(zButtonAspect.id) then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, zButtonAspect.count do
|
||||
local child = getglobal(zButtonAspect.name .. i)
|
||||
if child and child.id and zButtonAspect_IsKnownAspectSpellId(child.id) then
|
||||
zButtonAspect.id = child.id
|
||||
zButtonAspect.isspell = 1
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonAspect_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonAspect:UnregisterAllEvents()
|
||||
zButtonAspect:Hide()
|
||||
return
|
||||
end
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspectAdjustment = CreateFrame("Frame", "zButtonAspectAdjustment")
|
||||
zButtonAspectAdjustment:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonAspectAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", zButtonAspectAdjustment_OnEvent)
|
||||
zButtonAspect_Tooltip = CreateFrame("GameTooltip", "zButtonAspect_AuraProbeScan", nil, "GameTooltipTemplate")
|
||||
if zButtonAspect_Tooltip and zButtonAspect_Tooltip.GetName then
|
||||
local tooltipName = zButtonAspect_Tooltip:GetName()
|
||||
if tooltipName then
|
||||
zButtonAspect_AuraProbeTextLeft1 = getglobal(tooltipName .. "TextLeft1")
|
||||
end
|
||||
end
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_CreateButtons()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonAspect, "zButtonAspect", ZHUNTER_ASPECT_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Aspect_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Aspect_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonAspect.found = ZSpellButton_SetButtons(zButtonAspect, info)
|
||||
zButtonAspect_ApplyRuntimeSettings()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
|
||||
function zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonAspectAdjustment and zButtonAspectAdjustment.SetScript then
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAspect and zButtonAspect.Hide then
|
||||
zButtonAspect:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonAspectAdjustment and zButtonAspectAdjustment.SetScript then
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", zButtonAspectAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonAspect.found or ZHUNTER_ASPECT_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonAspect, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonAspect, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonAspect_Reset()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonAspect_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonAspectAdjustment_OnEvent()
|
||||
if not zButtonAspect or not zButtonAspect.count then
|
||||
return
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local minInterval = zButtonAspect_MinAuraInterval
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = zButtonAspect_MinAuraIntervalCombat
|
||||
end
|
||||
if now > 0 and zButtonAspect_LastAuraUpdateAt > 0 and (now - zButtonAspect_LastAuraUpdateAt) < minInterval then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraUpdateAt = now
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
if not zButtonAspect1.id then
|
||||
return
|
||||
end
|
||||
local button
|
||||
local isParentTooltipOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonAspect)
|
||||
local childrenShown = zButtonAspect.children and zButtonAspect.children.IsShown and zButtonAspect.children:IsShown()
|
||||
local needChildIconScan = (event ~= "PLAYER_AURAS_CHANGED") or childrenShown or isParentTooltipOwned
|
||||
local buttontextures = nil
|
||||
local hasDuplicateChildTexture = nil
|
||||
if needChildIconScan then
|
||||
buttontextures = {}
|
||||
local textureSeen = {}
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
button.icon = nil
|
||||
if button.id then
|
||||
local btnTexture = GetSpellTexture(button.id, "spell")
|
||||
if btnTexture then
|
||||
if textureSeen[btnTexture] then
|
||||
hasDuplicateChildTexture = true
|
||||
elseif hasDuplicateChildTexture == nil then
|
||||
hasDuplicateChildTexture = false
|
||||
end
|
||||
textureSeen[btnTexture] = 1
|
||||
buttontextures[btnTexture] = button
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local i = 1
|
||||
local texture = GetSpellTexture(zButtonAspect1.id, "spell")
|
||||
local buff = UnitBuff("player", i)
|
||||
local spellname, buffname
|
||||
local newParentId = zButtonAspect1.id
|
||||
while buff do
|
||||
if texture == buff and zButtonAspect2.id then
|
||||
newParentId = zButtonAspect2.id
|
||||
end
|
||||
if needChildIconScan and buttontextures[buff] then
|
||||
if hasDuplicateChildTexture then
|
||||
zButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
zButtonAspect_Tooltip:SetUnitBuff("player", i)
|
||||
if zButtonAspect_AuraProbeTextLeft1 and zButtonAspect_AuraProbeTextLeft1.GetText then
|
||||
buffname = zButtonAspect_AuraProbeTextLeft1:GetText()
|
||||
else
|
||||
buffname = nil
|
||||
end
|
||||
spellname = GetSpellName(buttontextures[buff].id, "spell")
|
||||
if buffname == spellname then
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
else
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
buff = UnitBuff("player", i)
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" and zButtonAspect_LastAuraTexture == texture and zButtonAspect.id == newParentId and zButtonAspect_LastParentId == newParentId and not isParentTooltipOwned then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraTexture = texture
|
||||
zButtonAspect_LastParentId = newParentId
|
||||
zButtonAspect.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
if needChildIconScan then
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
if button.id then
|
||||
ZSpellButton_UpdateButton(button)
|
||||
end
|
||||
end
|
||||
end
|
||||
if isParentTooltipOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonAspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonAspect"..index)
|
||||
else
|
||||
button = zButtonAspect
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonAspect.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonAspect, false)
|
||||
elseif zButtonAspect.children then
|
||||
zButtonAspect.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonAspect1 = "/ZAspect"
|
||||
SlashCmdList["zButtonAspect"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Aspect button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonAspect_Reset()
|
||||
zButtonAspect:ClearAllPoints()
|
||||
zButtonAspect:SetPoint("CENTER", UIParent, "CENTER", -60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Aspect")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonAspect_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonAspect_GetRoot()
|
||||
if not root["zButtonAspect"] then
|
||||
root["zButtonAspect"] = {}
|
||||
root["zButtonAspect"]["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
root["zButtonAspect"]["rows"] = 1
|
||||
root["zButtonAspect"]["horizontal"] = nil
|
||||
root["zButtonAspect"]["vertical"] = nil
|
||||
root["zButtonAspect"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonAspect"]["enabled"] = 1
|
||||
root["zButtonAspect"]["tooltip"] = 1
|
||||
root["zButtonAspect"]["parent"] = {}
|
||||
root["zButtonAspect"]["parent"]["size"] = 36
|
||||
root["zButtonAspect"]["parent"]["hide"] = nil
|
||||
root["zButtonAspect"]["parent"]["circle"] = 1
|
||||
root["zButtonAspect"]["children"] = {}
|
||||
root["zButtonAspect"]["children"]["size"] = 36
|
||||
root["zButtonAspect"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Aspect_Spells = {
|
||||
ZHUNTER_ASPECT_HAWK,
|
||||
ZHUNTER_ASPECT_MONKEY,
|
||||
ZHUNTER_ASPECT_WOLF,
|
||||
ZHUNTER_ASPECT_CHEETAH,
|
||||
ZHUNTER_ASPECT_PACK,
|
||||
ZHUNTER_ASPECT_WILD,
|
||||
ZHUNTER_ASPECT_BEAST
|
||||
}
|
||||
|
||||
local ZHUNTER_ASPECT_MAX = table.getn(ZHunterMod_Aspect_Spells)
|
||||
local zButtonAspect_LastAuraUpdateAt = 0
|
||||
local zButtonAspect_MinAuraInterval = 0.15
|
||||
local zButtonAspect_MinAuraIntervalCombat = 0.60
|
||||
local zButtonAspect_LastAuraTexture = nil
|
||||
local zButtonAspect_LastParentId = nil
|
||||
local zButtonAspect_AuraProbeTextLeft1 = nil
|
||||
|
||||
local function zButtonAspect_GetSaved()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
if not currentRoot["zButtonAspect"] then
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
end
|
||||
return currentRoot["zButtonAspect"]
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_ASPECT_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonAspect_ApplyRuntimeSettings()
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
zButtonAspect.tooltip = saved["tooltip"] and true or false
|
||||
zButtonAspect.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonAspect.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonAspect.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonAspect_IsKnownAspectSpellId(spellId)
|
||||
if not spellId then
|
||||
return false
|
||||
end
|
||||
local spellName = GetSpellName(spellId, "spell")
|
||||
if not spellName or spellName == "" then
|
||||
return false
|
||||
end
|
||||
for i = 1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if ZHunterMod_Aspect_Spells[i] == spellName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureValidParentId()
|
||||
if not (zButtonAspect and zButtonAspect.count) then
|
||||
return
|
||||
end
|
||||
|
||||
if zButtonAspect_IsKnownAspectSpellId(zButtonAspect.id) then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, zButtonAspect.count do
|
||||
local child = getglobal(zButtonAspect.name .. i)
|
||||
if child and child.id and zButtonAspect_IsKnownAspectSpellId(child.id) then
|
||||
zButtonAspect.id = child.id
|
||||
zButtonAspect.isspell = 1
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonAspect_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonAspect:UnregisterAllEvents()
|
||||
zButtonAspect:Hide()
|
||||
return
|
||||
end
|
||||
zButtonAspect_CreateButtons()
|
||||
MTH_ZH_AspectAdjust = CreateFrame("Frame", "MTH_ZH_AspectAdjust")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", MTH_ZH_AspectAdjust_OnEvent)
|
||||
zButtonAspect_Tooltip = CreateFrame("GameTooltip", "MTH_ZH_AspectProbe", nil, "GameTooltipTemplate")
|
||||
if zButtonAspect_Tooltip and zButtonAspect_Tooltip.GetName then
|
||||
local tooltipName = zButtonAspect_Tooltip:GetName()
|
||||
if tooltipName then
|
||||
zButtonAspect_AuraProbeTextLeft1 = getglobal(tooltipName .. "TextLeft1")
|
||||
end
|
||||
end
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_CreateButtons()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonAspect, "zButtonAspect", ZHUNTER_ASPECT_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Aspect_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Aspect_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonAspect.found = ZSpellButton_SetButtons(zButtonAspect, info)
|
||||
zButtonAspect_ApplyRuntimeSettings()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
|
||||
function zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_AspectAdjust and MTH_ZH_AspectAdjust.SetScript then
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAspect and zButtonAspect.Hide then
|
||||
zButtonAspect:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_AspectAdjust and MTH_ZH_AspectAdjust.SetScript then
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", MTH_ZH_AspectAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonAspect.found or ZHUNTER_ASPECT_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonAspect, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonAspect, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonAspect_Reset()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonAspect_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_AspectAdjust_OnEvent()
|
||||
if not zButtonAspect or not zButtonAspect.count then
|
||||
return
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local minInterval = zButtonAspect_MinAuraInterval
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = zButtonAspect_MinAuraIntervalCombat
|
||||
end
|
||||
if now > 0 and zButtonAspect_LastAuraUpdateAt > 0 and (now - zButtonAspect_LastAuraUpdateAt) < minInterval then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraUpdateAt = now
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
if not zButtonAspect1.id then
|
||||
return
|
||||
end
|
||||
local button
|
||||
local isParentTooltipOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonAspect)
|
||||
local childrenShown = zButtonAspect.children and zButtonAspect.children.IsShown and zButtonAspect.children:IsShown()
|
||||
local needChildIconScan = (event ~= "PLAYER_AURAS_CHANGED") or childrenShown or isParentTooltipOwned
|
||||
local buttontextures = nil
|
||||
local hasDuplicateChildTexture = nil
|
||||
if needChildIconScan then
|
||||
buttontextures = {}
|
||||
local textureSeen = {}
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
button.icon = nil
|
||||
if button.id then
|
||||
local btnTexture = GetSpellTexture(button.id, "spell")
|
||||
if btnTexture then
|
||||
if textureSeen[btnTexture] then
|
||||
hasDuplicateChildTexture = true
|
||||
elseif hasDuplicateChildTexture == nil then
|
||||
hasDuplicateChildTexture = false
|
||||
end
|
||||
textureSeen[btnTexture] = 1
|
||||
buttontextures[btnTexture] = button
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local i = 1
|
||||
local texture = GetSpellTexture(zButtonAspect1.id, "spell")
|
||||
local buff = UnitBuff("player", i)
|
||||
local spellname, buffname
|
||||
local newParentId = zButtonAspect1.id
|
||||
while buff do
|
||||
if texture == buff and zButtonAspect2.id then
|
||||
newParentId = zButtonAspect2.id
|
||||
end
|
||||
if needChildIconScan and buttontextures[buff] then
|
||||
if hasDuplicateChildTexture then
|
||||
zButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
zButtonAspect_Tooltip:SetUnitBuff("player", i)
|
||||
if zButtonAspect_AuraProbeTextLeft1 and zButtonAspect_AuraProbeTextLeft1.GetText then
|
||||
buffname = zButtonAspect_AuraProbeTextLeft1:GetText()
|
||||
else
|
||||
buffname = nil
|
||||
end
|
||||
spellname = GetSpellName(buttontextures[buff].id, "spell")
|
||||
if buffname == spellname then
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
else
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
buff = UnitBuff("player", i)
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" and zButtonAspect_LastAuraTexture == texture and zButtonAspect.id == newParentId and zButtonAspect_LastParentId == newParentId and not isParentTooltipOwned then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraTexture = texture
|
||||
zButtonAspect_LastParentId = newParentId
|
||||
zButtonAspect.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
if needChildIconScan then
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
if button.id then
|
||||
ZSpellButton_UpdateButton(button)
|
||||
end
|
||||
end
|
||||
end
|
||||
if isParentTooltipOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonAspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonAspect"..index)
|
||||
else
|
||||
button = zButtonAspect
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonAspect.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonAspect, false)
|
||||
elseif zButtonAspect.children then
|
||||
zButtonAspect.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonAspect1 = "/ZAspect"
|
||||
SlashCmdList["zButtonAspect"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Aspect button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonAspect_Reset()
|
||||
zButtonAspect:ClearAllPoints()
|
||||
zButtonAspect:SetPoint("CENTER", UIParent, "CENTER", -60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Aspect")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
@@ -93,6 +93,8 @@ local function zButtonCompanions_ApplyRuntimeSettings()
|
||||
local saved = zButtonCompanions_GetSaved()
|
||||
zButtonCompanions.tooltip = saved["tooltip"] and true or false
|
||||
zButtonCompanions.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonCompanions.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonCompanions.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonCompanions_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonCompanions_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonCompanions_CreateButtons()
|
||||
zButtonCompanionsAdjustment = CreateFrame("Frame", "zButtonCompanionsAdjustment")
|
||||
zButtonCompanionsAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonCompanionsAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", zButtonCompanionsAdjustment_OnEvent)
|
||||
MTH_ZH_CompanionsAdjust = CreateFrame("Frame", "MTH_ZH_CompanionsAdjust")
|
||||
MTH_ZH_CompanionsAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_CompanionsAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", MTH_ZH_CompanionsAdjust_OnEvent)
|
||||
zButtonCompanions_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonCompanions_SetupSizeAndPosition()
|
||||
local saved = zButtonCompanions_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonCompanionsAdjustment and zButtonCompanionsAdjustment.SetScript then
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_CompanionsAdjust and MTH_ZH_CompanionsAdjust.SetScript then
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonCompanions and zButtonCompanions.Hide then
|
||||
zButtonCompanions:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonCompanionsAdjustment and zButtonCompanionsAdjustment.SetScript then
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", zButtonCompanionsAdjustment_OnEvent)
|
||||
if MTH_ZH_CompanionsAdjust and MTH_ZH_CompanionsAdjust.SetScript then
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", MTH_ZH_CompanionsAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonCompanions.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonCompanions_Reset()
|
||||
zButtonCompanions_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonCompanionsAdjustment_OnEvent()
|
||||
function MTH_ZH_CompanionsAdjust_OnEvent()
|
||||
if not zButtonCompanions then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -93,6 +93,8 @@ local function zButtonMounts_ApplyRuntimeSettings()
|
||||
local saved = zButtonMounts_GetSaved()
|
||||
zButtonMounts.tooltip = saved["tooltip"] and true or false
|
||||
zButtonMounts.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonMounts.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonMounts.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonMounts_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonMounts_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonMounts_CreateButtons()
|
||||
zButtonMountsAdjustment = CreateFrame("Frame", "zButtonMountsAdjustment")
|
||||
zButtonMountsAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonMountsAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", zButtonMountsAdjustment_OnEvent)
|
||||
MTH_ZH_MountsAdjust = CreateFrame("Frame", "MTH_ZH_MountsAdjust")
|
||||
MTH_ZH_MountsAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_MountsAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", MTH_ZH_MountsAdjust_OnEvent)
|
||||
zButtonMounts_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonMounts_SetupSizeAndPosition()
|
||||
local saved = zButtonMounts_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonMountsAdjustment and zButtonMountsAdjustment.SetScript then
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_MountsAdjust and MTH_ZH_MountsAdjust.SetScript then
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonMounts and zButtonMounts.Hide then
|
||||
zButtonMounts:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonMountsAdjustment and zButtonMountsAdjustment.SetScript then
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", zButtonMountsAdjustment_OnEvent)
|
||||
if MTH_ZH_MountsAdjust and MTH_ZH_MountsAdjust.SetScript then
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", MTH_ZH_MountsAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonMounts.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonMounts_Reset()
|
||||
zButtonMounts_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonMountsAdjustment_OnEvent()
|
||||
function MTH_ZH_MountsAdjust_OnEvent()
|
||||
if not zButtonMounts then
|
||||
return
|
||||
end
|
||||
|
||||
+655
-653
File diff suppressed because it is too large
Load Diff
@@ -232,6 +232,8 @@ local function zButtonRanged_ApplyRuntimeSettings()
|
||||
local saved = zButtonRanged_GetSaved()
|
||||
zButtonRanged.tooltip = saved["tooltip"] and true or false
|
||||
zButtonRanged.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonRanged.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonRanged.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonRanged_UpdateDurabilityText(button)
|
||||
@@ -602,11 +604,11 @@ function zButtonRanged_OnEvent()
|
||||
zButtonRanged.customUpdateButton = zButtonRanged_UpdateButton
|
||||
zButtonRanged.beforeclick = zButtonRanged_BeforeClick
|
||||
zButtonRanged_CreateButtons()
|
||||
zButtonRangedAdjustment = CreateFrame("Frame", "zButtonRangedAdjustment")
|
||||
zButtonRangedAdjustment:RegisterEvent("UNIT_INVENTORY_CHANGED")
|
||||
zButtonRangedAdjustment:RegisterEvent("BAG_UPDATE")
|
||||
zButtonRangedAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", zButtonRangedAdjustment_OnEvent)
|
||||
MTH_ZH_RangedAdjust = CreateFrame("Frame", "MTH_ZH_RangedAdjust")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("UNIT_INVENTORY_CHANGED")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("BAG_UPDATE")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", MTH_ZH_RangedAdjust_OnEvent)
|
||||
zButtonRanged_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -635,16 +637,16 @@ end
|
||||
function zButtonRanged_SetupSizeAndPosition()
|
||||
local saved = zButtonRanged_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonRangedAdjustment and zButtonRangedAdjustment.SetScript then
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_RangedAdjust and MTH_ZH_RangedAdjust.SetScript then
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonRanged and zButtonRanged.Hide then
|
||||
zButtonRanged:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonRangedAdjustment and zButtonRangedAdjustment.SetScript then
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", zButtonRangedAdjustment_OnEvent)
|
||||
if MTH_ZH_RangedAdjust and MTH_ZH_RangedAdjust.SetScript then
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", MTH_ZH_RangedAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonRanged.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -679,7 +681,7 @@ function zButtonRanged_Reset()
|
||||
zButtonRanged_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonRangedAdjustment_OnEvent()
|
||||
function MTH_ZH_RangedAdjust_OnEvent()
|
||||
if not zButtonRanged then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -93,6 +93,8 @@ local function zButtonToys_ApplyRuntimeSettings()
|
||||
local saved = zButtonToys_GetSaved()
|
||||
zButtonToys.tooltip = saved["tooltip"] and true or false
|
||||
zButtonToys.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonToys.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonToys.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonToys_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonToys_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonToys_CreateButtons()
|
||||
zButtonToysAdjustment = CreateFrame("Frame", "zButtonToysAdjustment")
|
||||
zButtonToysAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonToysAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonToysAdjustment:SetScript("OnEvent", zButtonToysAdjustment_OnEvent)
|
||||
MTH_ZH_ToysAdjust = CreateFrame("Frame", "MTH_ZH_ToysAdjust")
|
||||
MTH_ZH_ToysAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_ToysAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", MTH_ZH_ToysAdjust_OnEvent)
|
||||
zButtonToys_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonToys_SetupSizeAndPosition()
|
||||
local saved = zButtonToys_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonToysAdjustment and zButtonToysAdjustment.SetScript then
|
||||
zButtonToysAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_ToysAdjust and MTH_ZH_ToysAdjust.SetScript then
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonToys and zButtonToys.Hide then
|
||||
zButtonToys:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonToysAdjustment and zButtonToysAdjustment.SetScript then
|
||||
zButtonToysAdjustment:SetScript("OnEvent", zButtonToysAdjustment_OnEvent)
|
||||
if MTH_ZH_ToysAdjust and MTH_ZH_ToysAdjust.SetScript then
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", MTH_ZH_ToysAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonToys.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonToys_Reset()
|
||||
zButtonToys_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonToysAdjustment_OnEvent()
|
||||
function MTH_ZH_ToysAdjust_OnEvent()
|
||||
if not zButtonToys then
|
||||
return
|
||||
end
|
||||
|
||||
+411
-409
@@ -1,410 +1,412 @@
|
||||
local function zButtonTrack_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrack_GetRoot()
|
||||
if not root["zButtonTrack"] then
|
||||
root["zButtonTrack"] = {}
|
||||
root["zButtonTrack"]["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
root["zButtonTrack"]["rows"] = 1
|
||||
root["zButtonTrack"]["horizontal"] = nil
|
||||
root["zButtonTrack"]["vertical"] = nil
|
||||
root["zButtonTrack"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrack"]["enabled"] = 1
|
||||
root["zButtonTrack"]["tooltip"] = 1
|
||||
root["zButtonTrack"]["parent"] = {}
|
||||
root["zButtonTrack"]["parent"]["size"] = 36
|
||||
root["zButtonTrack"]["parent"]["hide"] = nil
|
||||
root["zButtonTrack"]["parent"]["circle"] = 1
|
||||
root["zButtonTrack"]["children"] = {}
|
||||
root["zButtonTrack"]["children"]["size"] = 36
|
||||
root["zButtonTrack"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Track_Spells = {
|
||||
ZHUNTER_TRACK_HIDDEN,
|
||||
ZHUNTER_TRACK_HUMANOIDS,
|
||||
ZHUNTER_TRACK_UNDEAD,
|
||||
ZHUNTER_TRACK_BEASTS,
|
||||
ZHUNTER_TRACK_DEMONS,
|
||||
ZHUNTER_TRACK_ELEMENTALS,
|
||||
ZHUNTER_TRACK_DRAGONKIN,
|
||||
ZHUNTER_TRACK_GIANTS,
|
||||
ZHUNTER_TRACK_MINERALS,
|
||||
ZHUNTER_TRACK_HERBS,
|
||||
ZHUNTER_TRACK_TREASURE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRACK_MAX = table.getn(ZHunterMod_Track_Spells)
|
||||
local zButtonTrack_LastTrackingTexture = nil
|
||||
local zButtonTrack_SyncActiveChild
|
||||
local zButtonTrack_GetSaved
|
||||
|
||||
local function zButtonTrack_NormalizeTexture(texture)
|
||||
if not texture then
|
||||
return ""
|
||||
end
|
||||
local value = string.lower(tostring(texture))
|
||||
value = string.gsub(value, "\\", "/")
|
||||
local _, _, basename = string.find(value, "([^/]+)$")
|
||||
return basename or value
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingTexture(trackingTexture)
|
||||
if not trackingTexture or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
local wanted = zButtonTrack_NormalizeTexture(trackingTexture)
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellTexture = GetSpellTexture and GetSpellTexture(child.id, "spell") or nil
|
||||
if zButtonTrack_NormalizeTexture(spellTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icon and zButtonTrack_NormalizeTexture(child.icon) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icontexture and child.icontexture.GetTexture then
|
||||
local childTexture = child.icontexture:GetTexture()
|
||||
if zButtonTrack_NormalizeTexture(childTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingName(trackingName)
|
||||
if not trackingName or trackingName == "" or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellName = GetSpellName and GetSpellName(child.id, "spell") or nil
|
||||
if spellName == trackingName then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_GetActiveTrackingSpellId()
|
||||
local activeName = nil
|
||||
local activeTexture = nil
|
||||
if GetNumTrackingTypes and GetTrackingInfo then
|
||||
local numTracking = GetNumTrackingTypes() or 0
|
||||
for i = 1, numTracking do
|
||||
local name, texture, active = GetTrackingInfo(i)
|
||||
if active then
|
||||
activeName = name
|
||||
activeTexture = texture
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local byName = zButtonTrack_FindSpellIdByTrackingName(activeName)
|
||||
if byName then
|
||||
return byName, activeTexture
|
||||
end
|
||||
if activeTexture then
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(activeTexture), activeTexture
|
||||
end
|
||||
local buff = GetTrackingTexture and GetTrackingTexture() or nil
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(buff), buff
|
||||
end
|
||||
|
||||
local function zButtonTrack_AfterClick(button)
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if button and button.id then
|
||||
zButtonTrack.id = button.id
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(button.id)
|
||||
if GetSpellTexture then
|
||||
zButtonTrack_LastTrackingTexture = GetSpellTexture(button.id, "spell") or zButtonTrack_LastTrackingTexture
|
||||
end
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_SyncActiveChild = function(activeId)
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.SetChecked then
|
||||
child:SetChecked((activeId and child.id == activeId) and 1 or 0)
|
||||
end
|
||||
end
|
||||
if zButtonTrack.SetChecked then
|
||||
zButtonTrack:SetChecked(0)
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_RefreshTrackingState()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
local newId, trackingTexture = zButtonTrack_GetActiveTrackingSpellId()
|
||||
local buff = trackingTexture or (GetTrackingTexture and GetTrackingTexture() or nil)
|
||||
if not newId and not buff then
|
||||
if zButtonTrack.id then
|
||||
zButtonTrack_SyncActiveChild(zButtonTrack.id)
|
||||
else
|
||||
zButtonTrack_LastTrackingTexture = nil
|
||||
zButtonTrack_SyncActiveChild(nil)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not newId then
|
||||
newId = zButtonTrack.id or nil
|
||||
end
|
||||
if not newId then
|
||||
return
|
||||
end
|
||||
if zButtonTrack_NormalizeTexture(zButtonTrack_LastTrackingTexture) == zButtonTrack_NormalizeTexture(buff) and zButtonTrack.id == newId then
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
return
|
||||
end
|
||||
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
zButtonTrack_LastTrackingTexture = buff
|
||||
zButtonTrack.id = newId
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_GetSaved = function()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
if not currentRoot["zButtonTrack"] then
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrack"]
|
||||
end
|
||||
|
||||
local function zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRACK_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_ApplyRuntimeSettings()
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
zButtonTrack.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrack.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrack_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrack_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrack:UnregisterAllEvents()
|
||||
zButtonTrack:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack.afterclick = zButtonTrack_AfterClick
|
||||
zButtonTrackAdjustment = CreateFrame("Frame", "zButtonTrackAdjustment")
|
||||
zButtonTrackAdjustment:RegisterEvent("MINIMAP_UPDATE_TRACKING")
|
||||
zButtonTrackAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonTrackAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", zButtonTrackAdjustment_OnEvent)
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_CreateButtons()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrack, "zButtonTrack", ZHUNTER_TRACK_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Track_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Track_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Track_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrack.found = ZSpellButton_SetButtons(zButtonTrack, info)
|
||||
zButtonTrack_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrack_SetupSizeAndPosition()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonTrackAdjustment and zButtonTrackAdjustment.SetScript then
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrack and zButtonTrack.Hide then
|
||||
zButtonTrack:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonTrackAdjustment and zButtonTrackAdjustment.SetScript then
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", zButtonTrackAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrack.found or ZHUNTER_TRACK_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrack, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrack, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
|
||||
function zButtonTrack_Reset()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonTrack_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonTrackAdjustment_OnEvent()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "MINIMAP_UPDATE_TRACKING" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrack"..index)
|
||||
else
|
||||
button = zButtonTrack
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrack.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrack, false)
|
||||
elseif zButtonTrack.children then
|
||||
zButtonTrack.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrack1 = "/ZTrack"
|
||||
SlashCmdList["zButtonTrack"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Track button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
msg = tostring(msg or "")
|
||||
if msg == "reset" then
|
||||
zButtonTrack_Reset()
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Track")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonTrack_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrack_GetRoot()
|
||||
if not root["zButtonTrack"] then
|
||||
root["zButtonTrack"] = {}
|
||||
root["zButtonTrack"]["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
root["zButtonTrack"]["rows"] = 1
|
||||
root["zButtonTrack"]["horizontal"] = nil
|
||||
root["zButtonTrack"]["vertical"] = nil
|
||||
root["zButtonTrack"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrack"]["enabled"] = 1
|
||||
root["zButtonTrack"]["tooltip"] = 1
|
||||
root["zButtonTrack"]["parent"] = {}
|
||||
root["zButtonTrack"]["parent"]["size"] = 36
|
||||
root["zButtonTrack"]["parent"]["hide"] = nil
|
||||
root["zButtonTrack"]["parent"]["circle"] = 1
|
||||
root["zButtonTrack"]["children"] = {}
|
||||
root["zButtonTrack"]["children"]["size"] = 36
|
||||
root["zButtonTrack"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Track_Spells = {
|
||||
ZHUNTER_TRACK_HIDDEN,
|
||||
ZHUNTER_TRACK_HUMANOIDS,
|
||||
ZHUNTER_TRACK_UNDEAD,
|
||||
ZHUNTER_TRACK_BEASTS,
|
||||
ZHUNTER_TRACK_DEMONS,
|
||||
ZHUNTER_TRACK_ELEMENTALS,
|
||||
ZHUNTER_TRACK_DRAGONKIN,
|
||||
ZHUNTER_TRACK_GIANTS,
|
||||
ZHUNTER_TRACK_MINERALS,
|
||||
ZHUNTER_TRACK_HERBS,
|
||||
ZHUNTER_TRACK_TREASURE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRACK_MAX = table.getn(ZHunterMod_Track_Spells)
|
||||
local zButtonTrack_LastTrackingTexture = nil
|
||||
local zButtonTrack_SyncActiveChild
|
||||
local zButtonTrack_GetSaved
|
||||
|
||||
local function zButtonTrack_NormalizeTexture(texture)
|
||||
if not texture then
|
||||
return ""
|
||||
end
|
||||
local value = string.lower(tostring(texture))
|
||||
value = string.gsub(value, "\\", "/")
|
||||
local _, _, basename = string.find(value, "([^/]+)$")
|
||||
return basename or value
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingTexture(trackingTexture)
|
||||
if not trackingTexture or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
local wanted = zButtonTrack_NormalizeTexture(trackingTexture)
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellTexture = GetSpellTexture and GetSpellTexture(child.id, "spell") or nil
|
||||
if zButtonTrack_NormalizeTexture(spellTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icon and zButtonTrack_NormalizeTexture(child.icon) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icontexture and child.icontexture.GetTexture then
|
||||
local childTexture = child.icontexture:GetTexture()
|
||||
if zButtonTrack_NormalizeTexture(childTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingName(trackingName)
|
||||
if not trackingName or trackingName == "" or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellName = GetSpellName and GetSpellName(child.id, "spell") or nil
|
||||
if spellName == trackingName then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_GetActiveTrackingSpellId()
|
||||
local activeName = nil
|
||||
local activeTexture = nil
|
||||
if GetNumTrackingTypes and GetTrackingInfo then
|
||||
local numTracking = GetNumTrackingTypes() or 0
|
||||
for i = 1, numTracking do
|
||||
local name, texture, active = GetTrackingInfo(i)
|
||||
if active then
|
||||
activeName = name
|
||||
activeTexture = texture
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local byName = zButtonTrack_FindSpellIdByTrackingName(activeName)
|
||||
if byName then
|
||||
return byName, activeTexture
|
||||
end
|
||||
if activeTexture then
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(activeTexture), activeTexture
|
||||
end
|
||||
local buff = GetTrackingTexture and GetTrackingTexture() or nil
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(buff), buff
|
||||
end
|
||||
|
||||
local function zButtonTrack_AfterClick(button)
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if button and button.id then
|
||||
zButtonTrack.id = button.id
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(button.id)
|
||||
if GetSpellTexture then
|
||||
zButtonTrack_LastTrackingTexture = GetSpellTexture(button.id, "spell") or zButtonTrack_LastTrackingTexture
|
||||
end
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_SyncActiveChild = function(activeId)
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.SetChecked then
|
||||
child:SetChecked((activeId and child.id == activeId) and 1 or 0)
|
||||
end
|
||||
end
|
||||
if zButtonTrack.SetChecked then
|
||||
zButtonTrack:SetChecked(0)
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_RefreshTrackingState()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
local newId, trackingTexture = zButtonTrack_GetActiveTrackingSpellId()
|
||||
local buff = trackingTexture or (GetTrackingTexture and GetTrackingTexture() or nil)
|
||||
if not newId and not buff then
|
||||
if zButtonTrack.id then
|
||||
zButtonTrack_SyncActiveChild(zButtonTrack.id)
|
||||
else
|
||||
zButtonTrack_LastTrackingTexture = nil
|
||||
zButtonTrack_SyncActiveChild(nil)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not newId then
|
||||
newId = zButtonTrack.id or nil
|
||||
end
|
||||
if not newId then
|
||||
return
|
||||
end
|
||||
if zButtonTrack_NormalizeTexture(zButtonTrack_LastTrackingTexture) == zButtonTrack_NormalizeTexture(buff) and zButtonTrack.id == newId then
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
return
|
||||
end
|
||||
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
zButtonTrack_LastTrackingTexture = buff
|
||||
zButtonTrack.id = newId
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_GetSaved = function()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
if not currentRoot["zButtonTrack"] then
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrack"]
|
||||
end
|
||||
|
||||
local function zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRACK_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_ApplyRuntimeSettings()
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
zButtonTrack.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrack.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonTrack.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonTrack.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrack_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrack_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrack:UnregisterAllEvents()
|
||||
zButtonTrack:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack.afterclick = zButtonTrack_AfterClick
|
||||
MTH_ZH_TrackAdjust = CreateFrame("Frame", "MTH_ZH_TrackAdjust")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("MINIMAP_UPDATE_TRACKING")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", MTH_ZH_TrackAdjust_OnEvent)
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_CreateButtons()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrack, "zButtonTrack", ZHUNTER_TRACK_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Track_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Track_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Track_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrack.found = ZSpellButton_SetButtons(zButtonTrack, info)
|
||||
zButtonTrack_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrack_SetupSizeAndPosition()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_TrackAdjust and MTH_ZH_TrackAdjust.SetScript then
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrack and zButtonTrack.Hide then
|
||||
zButtonTrack:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_TrackAdjust and MTH_ZH_TrackAdjust.SetScript then
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", MTH_ZH_TrackAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrack.found or ZHUNTER_TRACK_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrack, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrack, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
|
||||
function zButtonTrack_Reset()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonTrack_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_TrackAdjust_OnEvent()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "MINIMAP_UPDATE_TRACKING" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrack"..index)
|
||||
else
|
||||
button = zButtonTrack
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrack.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrack, false)
|
||||
elseif zButtonTrack.children then
|
||||
zButtonTrack.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrack1 = "/ZTrack"
|
||||
SlashCmdList["zButtonTrack"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Track button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
msg = tostring(msg or "")
|
||||
if msg == "reset" then
|
||||
zButtonTrack_Reset()
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Track")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
+280
-278
@@ -1,279 +1,281 @@
|
||||
local function zButtonTrap_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrap_GetRoot()
|
||||
if not root["zButtonTrap"] then
|
||||
root["zButtonTrap"] = {}
|
||||
root["zButtonTrap"]["spells"] = {1, 2, 3, 4}
|
||||
root["zButtonTrap"]["rows"] = 1
|
||||
root["zButtonTrap"]["horizontal"] = nil
|
||||
root["zButtonTrap"]["vertical"] = nil
|
||||
root["zButtonTrap"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrap"]["enabled"] = 1
|
||||
root["zButtonTrap"]["tooltip"] = 1
|
||||
root["zButtonTrap"]["parent"] = {}
|
||||
root["zButtonTrap"]["parent"]["size"] = 36
|
||||
root["zButtonTrap"]["parent"]["hide"] = nil
|
||||
root["zButtonTrap"]["parent"]["circle"] = 1
|
||||
root["zButtonTrap"]["children"] = {}
|
||||
root["zButtonTrap"]["children"]["size"] = 36
|
||||
root["zButtonTrap"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Trap_Spells = {
|
||||
ZHUNTER_TRAP_FREEZING,
|
||||
ZHUNTER_TRAP_FROST,
|
||||
ZHUNTER_TRAP_IMMOLATION,
|
||||
ZHUNTER_TRAP_EXPLOSIVE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRAP_MAX = table.getn(ZHunterMod_Trap_Spells)
|
||||
local zButtonTrap_LastParentId = nil
|
||||
local zButtonTrap_LastCombatState = nil
|
||||
|
||||
local function zButtonTrap_GetSaved()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
if not currentRoot["zButtonTrap"] then
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrap"]
|
||||
end
|
||||
|
||||
local function zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRAP_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrap_ApplyRuntimeSettings()
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
zButtonTrap.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrap.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrap_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrap_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrap:UnregisterAllEvents()
|
||||
zButtonTrap:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrapAdjustment = CreateFrame("Frame", "zButtonTrapAdjustment")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonTrapAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonTrapAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", zButtonTrapAdjustment_OnEvent)
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_CreateButtons()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrap, "zButtonTrap", ZHUNTER_TRAP_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Trap_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Trap_Spells
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Trap_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrap.found = ZSpellButton_SetButtons(zButtonTrap, info)
|
||||
zButtonTrap_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrap_SetupSizeAndPosition()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonTrapAdjustment and zButtonTrapAdjustment.SetScript then
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrap and zButtonTrap.Hide then
|
||||
zButtonTrap:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonTrapAdjustment and zButtonTrapAdjustment.SetScript then
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", zButtonTrapAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrap.found or ZHUNTER_TRAP_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrap, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrap, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonTrap_Reset()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1}
|
||||
zButtonTrap_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonTrapAdjustment_OnEvent()
|
||||
if not zButtonTrap or not zButtonTrap.count then
|
||||
return
|
||||
end
|
||||
local rebuild = false
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
rebuild = true
|
||||
end
|
||||
local nextbutton
|
||||
local button
|
||||
local combat = event == "PLAYER_REGEN_DISABLED"
|
||||
for i=1, zButtonTrap.count do
|
||||
button = getglobal(zButtonTrap.name..i)
|
||||
button.customcolor = nil
|
||||
if button.id then
|
||||
if not nextbutton then
|
||||
nextbutton = button
|
||||
end
|
||||
if combat then
|
||||
button.icontexture:SetVertexColor(0.4, 0.4, 0.4)
|
||||
button.customcolor = 1
|
||||
else
|
||||
button.icontexture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
local newParentId = nextbutton and nextbutton.id or zButtonTrap1.id
|
||||
if (not rebuild) and zButtonTrap_LastParentId == newParentId and zButtonTrap_LastCombatState == combat and not GameTooltip:IsOwned(zButtonTrap) then
|
||||
return
|
||||
end
|
||||
zButtonTrap_LastParentId = newParentId
|
||||
zButtonTrap_LastCombatState = combat
|
||||
zButtonTrap.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonTrap)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrap)
|
||||
if GameTooltip:IsOwned(zButtonTrap) then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrap)
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrap"..index)
|
||||
else
|
||||
button = zButtonTrap
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrap.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrap, false)
|
||||
elseif zButtonTrap.children then
|
||||
zButtonTrap.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrap1 = "/ZTrap"
|
||||
SlashCmdList["zButtonTrap"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Trap button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonTrap_Reset()
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("CENTER", UIParent, "CENTER", 60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Trap")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonTrap_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrap_GetRoot()
|
||||
if not root["zButtonTrap"] then
|
||||
root["zButtonTrap"] = {}
|
||||
root["zButtonTrap"]["spells"] = {1, 2, 3, 4}
|
||||
root["zButtonTrap"]["rows"] = 1
|
||||
root["zButtonTrap"]["horizontal"] = nil
|
||||
root["zButtonTrap"]["vertical"] = nil
|
||||
root["zButtonTrap"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrap"]["enabled"] = 1
|
||||
root["zButtonTrap"]["tooltip"] = 1
|
||||
root["zButtonTrap"]["parent"] = {}
|
||||
root["zButtonTrap"]["parent"]["size"] = 36
|
||||
root["zButtonTrap"]["parent"]["hide"] = nil
|
||||
root["zButtonTrap"]["parent"]["circle"] = 1
|
||||
root["zButtonTrap"]["children"] = {}
|
||||
root["zButtonTrap"]["children"]["size"] = 36
|
||||
root["zButtonTrap"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Trap_Spells = {
|
||||
ZHUNTER_TRAP_FREEZING,
|
||||
ZHUNTER_TRAP_FROST,
|
||||
ZHUNTER_TRAP_IMMOLATION,
|
||||
ZHUNTER_TRAP_EXPLOSIVE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRAP_MAX = table.getn(ZHunterMod_Trap_Spells)
|
||||
local zButtonTrap_LastParentId = nil
|
||||
local zButtonTrap_LastCombatState = nil
|
||||
|
||||
local function zButtonTrap_GetSaved()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
if not currentRoot["zButtonTrap"] then
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrap"]
|
||||
end
|
||||
|
||||
local function zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRAP_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrap_ApplyRuntimeSettings()
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
zButtonTrap.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrap.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonTrap.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonTrap.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrap_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrap_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrap:UnregisterAllEvents()
|
||||
zButtonTrap:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrap_CreateButtons()
|
||||
MTH_ZH_TrapAdjust = CreateFrame("Frame", "MTH_ZH_TrapAdjust")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", MTH_ZH_TrapAdjust_OnEvent)
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_CreateButtons()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrap, "zButtonTrap", ZHUNTER_TRAP_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Trap_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Trap_Spells
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Trap_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrap.found = ZSpellButton_SetButtons(zButtonTrap, info)
|
||||
zButtonTrap_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrap_SetupSizeAndPosition()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_TrapAdjust and MTH_ZH_TrapAdjust.SetScript then
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrap and zButtonTrap.Hide then
|
||||
zButtonTrap:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_TrapAdjust and MTH_ZH_TrapAdjust.SetScript then
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", MTH_ZH_TrapAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrap.found or ZHUNTER_TRAP_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrap, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrap, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonTrap_Reset()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1}
|
||||
zButtonTrap_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_TrapAdjust_OnEvent()
|
||||
if not zButtonTrap or not zButtonTrap.count then
|
||||
return
|
||||
end
|
||||
local rebuild = false
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
rebuild = true
|
||||
end
|
||||
local nextbutton
|
||||
local button
|
||||
local combat = event == "PLAYER_REGEN_DISABLED"
|
||||
for i=1, zButtonTrap.count do
|
||||
button = getglobal(zButtonTrap.name..i)
|
||||
button.customcolor = nil
|
||||
if button.id then
|
||||
if not nextbutton then
|
||||
nextbutton = button
|
||||
end
|
||||
if combat then
|
||||
button.icontexture:SetVertexColor(0.4, 0.4, 0.4)
|
||||
button.customcolor = 1
|
||||
else
|
||||
button.icontexture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
local newParentId = nextbutton and nextbutton.id or zButtonTrap1.id
|
||||
if (not rebuild) and zButtonTrap_LastParentId == newParentId and zButtonTrap_LastCombatState == combat and not GameTooltip:IsOwned(zButtonTrap) then
|
||||
return
|
||||
end
|
||||
zButtonTrap_LastParentId = newParentId
|
||||
zButtonTrap_LastCombatState = combat
|
||||
zButtonTrap.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonTrap)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrap)
|
||||
if GameTooltip:IsOwned(zButtonTrap) then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrap)
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrap"..index)
|
||||
else
|
||||
button = zButtonTrap
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrap.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrap, false)
|
||||
elseif zButtonTrap.children then
|
||||
zButtonTrap.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrap1 = "/ZTrap"
|
||||
SlashCmdList["zButtonTrap"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Trap button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonTrap_Reset()
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("CENTER", UIParent, "CENTER", 60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Trap")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user