Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 162 lines (147 sloc) 5.373 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
NUM_PET_RESISTANCE_TYPES = 5;
NUM_PET_STATS = 5;

PETPAPERDOLL_STATCATEGORY_DEFAULTORDER = {
"GENERAL",
"MELEE",
"SPELL",
"DEFENSE",
};

function PetPaperDollFrame_OnLoad (self)
self:RegisterEvent("PET_UI_UPDATE");
self:RegisterEvent("PET_BAR_UPDATE");
self:RegisterEvent("PET_UI_CLOSE");
self:RegisterEvent("UNIT_NAME_UPDATE");
self:RegisterEvent("UNIT_PET");
self:RegisterEvent("UNIT_PET_EXPERIENCE");
self:RegisterEvent("UNIT_MODEL_CHANGED");
self:RegisterEvent("UNIT_LEVEL");
self:RegisterEvent("UNIT_RESISTANCES");
self:RegisterEvent("UNIT_STATS");
self:RegisterEvent("UNIT_DAMAGE");
self:RegisterEvent("UNIT_RANGEDDAMAGE");
self:RegisterEvent("UNIT_ATTACK_SPEED");
self:RegisterEvent("UNIT_ATTACK_POWER");
self:RegisterEvent("UNIT_RANGED_ATTACK_POWER");
self:RegisterEvent("UNIT_DEFENSE");
self:RegisterEvent("UNIT_ATTACK");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PET_SPELL_POWER_UPDATE");
self:RegisterEvent("VARIABLES_LOADED");

SetTextStatusBarTextPrefix(PetPaperDollFrameExpBar, XP);
end

function PetPaperDollFrame_UpdateIsAvailable()
if ( (not HasPetUI()) ) then
PetPaperDollFrame.hidden = true;
CharacterFrameTab2:Hide();
CharacterFrameTab3:SetPoint("LEFT", "CharacterFrameTab2", "LEFT", 0, 0);
if ( PetPaperDollFrame:IsVisible() ) then --We have the pet frame selected, but nothing to show on it
ToggleCharacter("PaperDollFrame");
end
else
PetPaperDollFrame.hidden = false;
CharacterFrameTab2:Show();
CharacterFrameTab3:SetPoint("LEFT", "CharacterFrameTab2", "RIGHT", -16, 0);
end
end

-- This makes sure the update only happens once at the end of the frame
function PetPaperDollFrame_QueuedUpdate(self)
self:SetScript("OnUpdate", nil);
PetPaperDollFrame_Update();
end

function PetPaperDollFrame_OnEvent (self, event, ...)
local arg1, arg2 = ...;
if ( event == "PET_UI_UPDATE" or event == "PET_UI_CLOSE" or event == "PET_BAR_UPDATE" or (event == "UNIT_PET" and arg1 == "player") or
(event == "UNIT_NAME_UPDATE" and arg1 == "pet") ) then
if (self:IsVisible()) then
self:SetScript("OnUpdate", PetPaperDollFrame_QueuedUpdate);
else
PetPaperDollFrame_UpdateIsAvailable();
end
elseif ( event == "UNIT_PET_EXPERIENCE" ) then
PetExpBar_Update();
elseif( event == "PET_SPELL_POWER_UPDATE" ) then
if (self:IsVisible()) then
self:SetScript("OnUpdate", PetPaperDollFrame_QueuedUpdate);
end
elseif (event == "VARIABLES_LOADED") then
if (self:IsVisible()) then
if (GetCVar("characterFrameCollapsed") ~= "0") then
CharacterFrame_Collapse();
else
CharacterFrame_Expand();
end
PaperDoll_InitStatCategories(PETPAPERDOLL_STATCATEGORY_DEFAULTORDER, "petStatCategoryOrder", "petStatCategoriesCollapsed", "pet");
end
PetPaperDollFrame_UpdateIsAvailable();
elseif ( arg1 == "pet" ) then
if (self:IsVisible()) then
self:SetScript("OnUpdate", PetPaperDollFrame_QueuedUpdate);
else
PetPaperDollFrame_UpdateIsAvailable();
end
end
end

PetPaperDollFrame_BeenViewed = false;
function PetPaperDollFrame_OnShow(self)
if ( self:IsVisible() ) then
PetPaperDollFrame_BeenViewed = true;
end
SetButtonPulse(CharacterFrameTab2, 0, 1); --Stop the button pulse

if (GetCVar("characterFrameCollapsed") ~= "0") then
CharacterFrame_Collapse();
else
CharacterFrame_Expand();
end
CharacterFrameExpandButton:Show();
CharacterFrameExpandButton.collapseTooltip = PET_STATS_COLLAPSE_TOOLTIP;
CharacterFrameExpandButton.expandTooltip = PET_STATS_EXPAND_TOOLTIP;

local hasPetUI, canGainXP = HasPetUI();
if ( hasPetUI ) then --We've already decided that we're going to be hidden, but it hasn't happened yet.
PaperDoll_InitStatCategories(PETPAPERDOLL_STATCATEGORY_DEFAULTORDER, "petStatCategoryOrder", "petStatCategoriesCollapsed", "pet");
end

PetPaperDollFrame_Update();
end

function PetPaperDollFrame_OnHide()
CharacterFrame_Collapse();
CharacterFrameExpandButton:Hide();
end

function PetPaperDollFrame_Update()
local hasPetUI, canGainXP = HasPetUI();
PetPaperDollFrame_UpdateIsAvailable();
if ( not hasPetUI ) then
return;
end
PetModelFrame:SetUnit("pet");
if ( UnitCreatureFamily("pet") ) then
PetLevelText:SetFormattedText(UNIT_TYPE_LEVEL_TEMPLATE,UnitLevel("pet"),UnitCreatureFamily("pet"));
end
CharacterFrameTitleText:SetText(UnitName("pet"));
PetExpBar_Update();
PaperDollFrame_UpdateStats();

local _, playerClass = UnitClass("player");
if (playerClass == "HUNTER") then
PetPaperDollPetModelBg:Show();
PetPaperDollPetModelBg:SetTexture("Interface\\PetPaperDollFrame\\PetStatsBG-Hunter");
elseif (playerClass == "WARLOCK") then
PetPaperDollPetModelBg:Show();
PetPaperDollPetModelBg:SetTexture("Interface\\PetPaperDollFrame\\PetStatsBG-Warlock");
elseif (playerClass == "MAGE") then
PetPaperDollPetModelBg:Show();
PetPaperDollPetModelBg:SetTexture("Interface\\PetPaperDollFrame\\PetStatsBG-Mage");
elseif (playerClass == "DEATHKNIGHT") then
PetPaperDollPetModelBg:Show();
PetPaperDollPetModelBg:SetTexture("Interface\\PetPaperDollFrame\\PetStatsBG-DeathKnight");
else
PetPaperDollPetModelBg:Hide();
end

if ( canGainXP ) then
PetPaperDollPetInfo:Show();
else
PetPaperDollPetInfo:Hide();
end
end

function PetExpBar_Update()
local currXP, nextXP = GetPetExperience();
PetPaperDollFrameExpBar:SetMinMaxValues(min(0, currXP), nextXP);
PetPaperDollFrameExpBar:SetValue(currXP);
end
Something went wrong with that request. Please try again.