Mercurial > wow > buffalo2
comparison Modules/PetBattle.lua @ 135:4979b5cca6de
- Fixed lua error from newly obtained artifacts
author | Nenue |
---|---|
date | Thu, 25 Jan 2018 20:58:10 -0500 |
parents | Modules/GuildInfo.lua@86621c60512b |
children |
comparison
equal
deleted
inserted
replaced
134:24dc16a49b15 | 135:4979b5cca6de |
---|---|
1 | |
2 local print = DEVIAN_WORKSPACE and function(...) print('VnRoster', ...) end or nop | |
3 | |
4 | |
5 | |
6 VeneerPetBattleActionMixin = {} | |
7 VeneerPetBattleInfoMixin = {} | |
8 local pb = VeneerPetBattleInfoMixin | |
9 local action = VeneerPetBattleActionMixin | |
10 | |
11 | |
12 function pb:OnShow() | |
13 self:ClearAllPoints() | |
14 self:SetPoint('TOPLEFT', PetBattleFrame.EnemyBuffFrame, 'BOTTOMLEFT', 0, -12) | |
15 self:RegisterEvent('PET_BATTLE_PET_ROUND_PLAYBACK_COMPLETE') | |
16 self:RegisterEvent('PET_BATTLE_ACTION_SELECTED') | |
17 self:RegisterEvent('PET_BATTLE_TURN_STARTED') | |
18 print('pet on show') | |
19 self:Refresh() | |
20 end | |
21 | |
22 function pb:OnHide() | |
23 print('pet on hide') | |
24 self:UnregisterAllEvents() | |
25 end | |
26 | |
27 function pb:OnEvent(event) | |
28 print('pb event|cFFFF8800', event) | |
29 self:Refresh() | |
30 end | |
31 | |
32 function pb:Refresh() | |
33 local myPetSlot = C_PetBattles.GetActivePet(1) | |
34 local myPetType = C_PetBattles.GetPetType(1, myPetSlot) | |
35 | |
36 local index = 0 | |
37 local nonActiveIndex = 0 | |
38 local lastFrame, lastNonActive | |
39 for petSlot = 1, C_PetBattles.GetNumPets(2) do | |
40 | |
41 for abilitySlot = 1,3 do | |
42 local _, name, texture, cooldown, tooltip,_, abilityType, noStrongWeakHints = C_PetBattles.GetAbilityInfo(2, petSlot, abilitySlot) | |
43 local petHealth = C_PetBattles.GetHealth(2, petSlot) | |
44 | |
45 if petHealth >= 1 then | |
46 local isUsable, currentCooldown, currentLockdown = C_PetBattles.GetAbilityState(2, petSlot, abilitySlot); | |
47 --print(index, petSlot, abilitySlot, name, currentCooldown, currentLockdown, cooldown, petHealth) | |
48 | |
49 index = index + 1 | |
50 local frame = self.Abilities[index] | |
51 | |
52 frame.ownerID = 2 | |
53 frame.petIndex = petSlot | |
54 frame.abIndex = abilitySlot | |
55 frame.tooltip = tooltip | |
56 frame.Name:SetText(name) | |
57 frame.Icon:SetTexture(texture) | |
58 frame.TypeIcon:SetTexture("Interface\\PetBattles\\PetIcon-"..PET_TYPE_SUFFIX[abilityType]) | |
59 | |
60 | |
61 for i = 1,C_PetBattles.GetNumPets(1) do | |
62 local myPetType = C_PetBattles.GetPetType(1, i) | |
63 if not (myPetType or abilityType) then | |
64 frame.BetterIcon[i]:Hide(); | |
65 else | |
66 local modifier = C_PetBattles.GetAttackModifier(abilityType, myPetType) | |
67 if ( noStrongWeakHints or modifier == 1 ) then | |
68 frame.BetterIcon[i]:Hide(); | |
69 elseif (modifier > 1) then | |
70 frame.BetterIcon[i]:SetTexture("Interface\\PetBattles\\BattleBar-AbilityBadge-Strong"); | |
71 frame.BetterIcon[i]:Show(); | |
72 elseif (modifier < 1) then | |
73 frame.BetterIcon[i]:SetTexture("Interface\\PetBattles\\BattleBar-AbilityBadge-Weak"); | |
74 frame.BetterIcon[i]:Show(); | |
75 end | |
76 | |
77 end | |
78 end | |
79 | |
80 | |
81 if cooldown >= 1 then | |
82 frame.Border2:Show() | |
83 else | |
84 | |
85 frame.Border2:Hide() | |
86 end | |
87 | |
88 | |
89 currentCooldown = (currentCooldown >= 1) and currentCooldown or 0 | |
90 if petHealth == 0 then | |
91 frame.Cooldown:SetText(nil) | |
92 frame.Cooldown:SetTextColor(1,0,0) | |
93 else | |
94 if currentLockdown >= 1 and currentLockdown > currentCooldown then | |
95 frame.Cooldown:SetTextColor(1,0,0) | |
96 else | |
97 frame.Cooldown:SetTextColor(1,1,1) | |
98 end | |
99 frame.Cooldown:SetText((currentCooldown >= 1) and currentCooldown or nil) | |
100 end | |
101 | |
102 frame:ClearAllPoints() | |
103 if petSlot == C_PetBattles.GetActivePet(2) then | |
104 frame:SetSize(48,48) | |
105 frame.Border2:SetSize(72,72) | |
106 frame.Icon:SetDesaturated(false) | |
107 frame.Name:SetTextColor(1,1,0) | |
108 if lastFrame then | |
109 frame:SetPoint('TOPLEFT', lastFrame, 'BOTTOMLEFT', 0, -4) | |
110 else | |
111 frame:SetPoint('TOPLEFT', self, 'TOPLEFT') | |
112 end | |
113 lastFrame = frame | |
114 else | |
115 frame:SetSize(24,24) | |
116 frame.Border2:SetSize(36,36) | |
117 frame.Name:SetTextColor(0.5,0.5,0.5) | |
118 frame.Icon:SetDesaturated(true) | |
119 if lastNonActive then | |
120 frame:SetPoint('TOPLEFT', lastNonActive, 'BOTTOMLEFT', 0, -2) | |
121 else | |
122 frame:SetPoint('TOPLEFT', self, 'TOPLEFT', 128, 0) | |
123 end | |
124 lastNonActive = frame | |
125 end | |
126 frame:Show() | |
127 end | |
128 end | |
129 end | |
130 | |
131 for i = index + 1, #self.Abilities do | |
132 self.Abilities[i]:Hide() | |
133 end | |
134 end | |
135 | |
136 function action:OnEnter() | |
137 PetBattleAbilityTooltip_SetAbility(self.ownerID, self.petIndex, self.abIndex); | |
138 PetBattleAbilityTooltip_Show("TOPRIGHT", self:GetParent(), "TOPLEFT", -5, 0, self.additionalText); | |
139 end | |
140 | |
141 function action:OnLeave() | |
142 PetBattlePrimaryAbilityTooltip:Hide(); | |
143 end |