12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

530 Part III ■ Advanced Addon TechniquesRegisterUnitWatch(frame.pet)frame.pet:SetFrameRef(“unit“, frame.unit)frame.pet:SetAttribute(“_onshow“, [[local unit = self:GetFrameRef(“unit“)unit:SetHeight(28)]])frame.pet:SetAttribute(“_onhide“, [[local unit = self:GetFrameRef(“unit“)unit:SetHeight(34)]])frame.pet.unit = frame.unitframe.pet:HookScript(“OnShow“, SquareUnitFrames_Pet_OnShow)frame.pet:HookScript(“OnHide“, SquareUnitFrames_Pet_OnHide)endfunction SquareUnitFrames_Frame_OnShow(button)local unit = button:GetAttribute(“unit“)if unit thenlocal guid = UnitGUID(unit)if guid ~= button.guid thenSquareUnitFrames_ResetUnitButton(button.unit, unit)SquareUnitFrames_ResetPetButton(button.pet, unit .. “pet“)button.guid = guidendendendfunction SquareUnitFrames_ResetUnitButton(button, unit)SquareUnitFrames_ResetHealthBar(button, unit)SquareUnitFrames_ResetPowerBar(button, unit)SquareUnitFrames_ResetName(button, unit)if UnitIsUnit(unit, “target“) thenbutton.selected:Show()elsebutton.selected:Hide()endlocal status = UnitThreatSituation(unit)if status <strong>and</strong> status > 0 thenlocal r, g, b = GetThreatStatusColor(status)button.name:SetTextColor(r, g, b)elsebutton.name:SetTextColor(1, 1, 1)endend

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!