Nick@108: Nick@108: local print = DEVIAN_WORKSPACE and function(...) print('VnRoster', ...) end or nop Nick@108: Nenue@133: Nenue@133: Nenue@133: VeneerPetBattleActionMixin = {} Nenue@133: VeneerPetBattleInfoMixin = {} Nenue@133: local pb = VeneerPetBattleInfoMixin Nenue@133: local action = VeneerPetBattleActionMixin Nenue@133: Nenue@133: Nenue@133: function pb:OnShow() Nenue@133: self:ClearAllPoints() Nenue@133: self:SetPoint('TOPLEFT', PetBattleFrame.EnemyBuffFrame, 'BOTTOMLEFT', 0, -12) Nenue@133: self:RegisterEvent('PET_BATTLE_PET_ROUND_PLAYBACK_COMPLETE') Nenue@133: self:RegisterEvent('PET_BATTLE_ACTION_SELECTED') Nenue@133: self:RegisterEvent('PET_BATTLE_TURN_STARTED') Nenue@133: print('pet on show') Nenue@133: self:Refresh() Nenue@133: end Nenue@133: Nenue@133: function pb:OnHide() Nenue@133: print('pet on hide') Nenue@133: self:UnregisterAllEvents() Nenue@133: end Nenue@133: Nenue@133: function pb:OnEvent(event) Nenue@133: print('pb event|cFFFF8800', event) Nenue@133: self:Refresh() Nenue@133: end Nenue@133: Nenue@133: function pb:Refresh() Nenue@133: local myPetSlot = C_PetBattles.GetActivePet(1) Nenue@133: local myPetType = C_PetBattles.GetPetType(1, myPetSlot) Nenue@133: Nenue@133: local index = 0 Nenue@133: local nonActiveIndex = 0 Nenue@133: local lastFrame, lastNonActive Nenue@133: for petSlot = 1, C_PetBattles.GetNumPets(2) do Nenue@133: Nenue@133: for abilitySlot = 1,3 do Nenue@133: local _, name, texture, cooldown, tooltip,_, abilityType, noStrongWeakHints = C_PetBattles.GetAbilityInfo(2, petSlot, abilitySlot) Nenue@133: local petHealth = C_PetBattles.GetHealth(2, petSlot) Nenue@133: Nenue@133: if petHealth >= 1 then Nenue@133: local isUsable, currentCooldown, currentLockdown = C_PetBattles.GetAbilityState(2, petSlot, abilitySlot); Nenue@133: --print(index, petSlot, abilitySlot, name, currentCooldown, currentLockdown, cooldown, petHealth) Nenue@133: Nenue@133: index = index + 1 Nenue@133: local frame = self.Abilities[index] Nenue@133: Nenue@133: frame.ownerID = 2 Nenue@133: frame.petIndex = petSlot Nenue@133: frame.abIndex = abilitySlot Nenue@133: frame.tooltip = tooltip Nenue@133: frame.Name:SetText(name) Nenue@133: frame.Icon:SetTexture(texture) Nenue@133: frame.TypeIcon:SetTexture("Interface\\PetBattles\\PetIcon-"..PET_TYPE_SUFFIX[abilityType]) Nenue@133: Nenue@133: Nenue@133: for i = 1,C_PetBattles.GetNumPets(1) do Nenue@133: local myPetType = C_PetBattles.GetPetType(1, i) Nenue@133: if not (myPetType or abilityType) then Nenue@133: frame.BetterIcon[i]:Hide(); Nenue@133: else Nenue@133: local modifier = C_PetBattles.GetAttackModifier(abilityType, myPetType) Nenue@133: if ( noStrongWeakHints or modifier == 1 ) then Nenue@133: frame.BetterIcon[i]:Hide(); Nenue@133: elseif (modifier > 1) then Nenue@133: frame.BetterIcon[i]:SetTexture("Interface\\PetBattles\\BattleBar-AbilityBadge-Strong"); Nenue@133: frame.BetterIcon[i]:Show(); Nenue@133: elseif (modifier < 1) then Nenue@133: frame.BetterIcon[i]:SetTexture("Interface\\PetBattles\\BattleBar-AbilityBadge-Weak"); Nenue@133: frame.BetterIcon[i]:Show(); Nenue@133: end Nenue@133: Nenue@133: end Nenue@133: end Nenue@133: Nenue@133: Nenue@133: if cooldown >= 1 then Nenue@133: frame.Border2:Show() Nenue@133: else Nenue@133: Nenue@133: frame.Border2:Hide() Nenue@133: end Nenue@133: Nenue@133: Nenue@133: currentCooldown = (currentCooldown >= 1) and currentCooldown or 0 Nenue@133: if petHealth == 0 then Nenue@133: frame.Cooldown:SetText(nil) Nenue@133: frame.Cooldown:SetTextColor(1,0,0) Nenue@133: else Nenue@133: if currentLockdown >= 1 and currentLockdown > currentCooldown then Nenue@133: frame.Cooldown:SetTextColor(1,0,0) Nenue@133: else Nenue@133: frame.Cooldown:SetTextColor(1,1,1) Nenue@133: end Nenue@133: frame.Cooldown:SetText((currentCooldown >= 1) and currentCooldown or nil) Nenue@133: end Nenue@133: Nenue@133: frame:ClearAllPoints() Nenue@133: if petSlot == C_PetBattles.GetActivePet(2) then Nenue@133: frame:SetSize(48,48) Nenue@133: frame.Border2:SetSize(72,72) Nenue@133: frame.Icon:SetDesaturated(false) Nenue@133: frame.Name:SetTextColor(1,1,0) Nenue@133: if lastFrame then Nenue@133: frame:SetPoint('TOPLEFT', lastFrame, 'BOTTOMLEFT', 0, -4) Nenue@133: else Nenue@133: frame:SetPoint('TOPLEFT', self, 'TOPLEFT') Nenue@133: end Nenue@133: lastFrame = frame Nenue@133: else Nenue@133: frame:SetSize(24,24) Nenue@133: frame.Border2:SetSize(36,36) Nenue@133: frame.Name:SetTextColor(0.5,0.5,0.5) Nenue@133: frame.Icon:SetDesaturated(true) Nenue@133: if lastNonActive then Nenue@133: frame:SetPoint('TOPLEFT', lastNonActive, 'BOTTOMLEFT', 0, -2) Nenue@133: else Nenue@133: frame:SetPoint('TOPLEFT', self, 'TOPLEFT', 128, 0) Nenue@133: end Nenue@133: lastNonActive = frame Nenue@133: end Nenue@133: frame:Show() Nenue@133: end Nenue@133: end Nenue@133: end Nenue@133: Nenue@133: for i = index + 1, #self.Abilities do Nenue@133: self.Abilities[i]:Hide() Nenue@133: end Nenue@133: end Nenue@133: Nenue@133: function action:OnEnter() Nenue@133: PetBattleAbilityTooltip_SetAbility(self.ownerID, self.petIndex, self.abIndex); Nenue@133: PetBattleAbilityTooltip_Show("TOPRIGHT", self:GetParent(), "TOPLEFT", -5, 0, self.additionalText); Nenue@133: end Nenue@133: Nenue@133: function action:OnLeave() Nenue@133: PetBattlePrimaryAbilityTooltip:Hide(); Nenue@133: end