Advertisement
architekt909

Untitled

Mar 31st, 2021
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.13 KB | None | 0 0
  1. --[[
  2. -- Custom code injector template for Kui_Nameplates_Core
  3. --]]
  4. local folder,ns=...
  5. local addon = KuiNameplates
  6. local core = KuiNameplatesCore
  7.  
  8. -- Position and size
  9. local PvPClassificationIndicator = self:CreateTexture(nil, 'OVERLAY')
  10. PvPClassificationIndicator:SetSize(24, 24)
  11. PvPClassificationIndicator:SetPoint('CENTER')
  12.  
  13. -- sourced from FrameXML/CompactUnitFrame.lua
  14. local ICONS = {
  15.     [Enum.PvPUnitClassification.FlagCarrierHorde or 0] = "nameplates-icon-flag-horde",
  16.     [Enum.PvPUnitClassification.FlagCarrierAlliance or 1] = "nameplates-icon-flag-alliance",
  17.     [Enum.PvPUnitClassification.FlagCarrierNeutral or 2] = "nameplates-icon-flag-neutral",
  18.     [Enum.PvPUnitClassification.CartRunnerHorde or 3] = "nameplates-icon-cart-horde",
  19.     [Enum.PvPUnitClassification.CartRunnerAlliance or 4] = "nameplates-icon-cart-alliance",
  20.     [Enum.PvPUnitClassification.AssassinHorde or 5] = "nameplates-icon-bounty-horde",
  21.     [Enum.PvPUnitClassification.AssassinAlliance or 6] = "nameplates-icon-bounty-alliance",
  22.     [Enum.PvPUnitClassification.OrbCarrierBlue or 7] = "nameplates-icon-orb-blue",
  23.     [Enum.PvPUnitClassification.OrbCarrierGreen or 8] = "nameplates-icon-orb-green",
  24.     [Enum.PvPUnitClassification.OrbCarrierOrange or 9] = "nameplates-icon-orb-orange",
  25.     [Enum.PvPUnitClassification.OrbCarrierPurple or 10] = "nameplates-icon-orb-purple",
  26. }
  27.  
  28. local mod = addon:NewPlugin('CustomPVPCarriers',101)
  29. if not mod then return end
  30.  
  31. local function Update(self, event, unit)
  32.     if(unit ~= self.unit) then return end
  33.  
  34.     local element = self.PvPClassificationIndicator
  35.  
  36.     --[[ Callback: PvPClassificationIndicator:PreUpdate(unit)
  37.     Called before the element has been updated.
  38.  
  39.     * self - the PvPClassificationIndicator element
  40.     * unit - the unit for which the update has been triggered (string)
  41.     --]]
  42.     if(element.PreUpdate) then
  43.         element:PreUpdate(unit)
  44.     end
  45.  
  46.     local class = UnitPvpClassification(unit)
  47.     local icon = ICONS[class]
  48.     if(icon) then
  49.         element:SetAtlas(icon, element.useAtlasSize)
  50.         element:Show()
  51.     else
  52.         element:Hide()
  53.     end
  54.  
  55.     --[[ Callback: PvPClassificationIndicator:PostUpdate(unit, class)
  56.     Called after the element has been updated.
  57.  
  58.     * self  - the PvPClassificationIndicator element
  59.     * unit  - the unit for which the update has been triggered (string)
  60.     * class - the pvp classification of the unit (number?)
  61.     --]]
  62.     if(element.PostUpdate) then
  63.         return element:PostUpdate(unit, class)
  64.     end
  65. end
  66.  
  67. -- create ######################################################################
  68. function mod:Create(frame)
  69.     -- Place code to be performed after a frame is created here.
  70. end
  71.  
  72. -- show ########################################################################
  73. function mod:Show(frame)
  74.     -- Place code to be performed after a frame is shown here.
  75. end
  76.  
  77. -- hide ########################################################################
  78. function mod:Hide(frame)
  79.     -- Place code to be performed after a frame is hidden here.
  80. end
  81.  
  82. -- initialise ##################################################################
  83. function mod:Initialise()
  84.     self:RegisterMessage('Create')
  85.     self:RegisterMessage('Show')
  86.     self:RegisterMessage('Hide')
  87. end
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement