NanamiPlates_ComboPoints = {} local NP = NanamiPlates local Settings = NP.Settings local GetComboPoints = GetComboPoints local UnitExists = UnitExists local CreateFrame = CreateFrame local MAX_COMBO_POINTS = 5 local CP_SIZE = 10 local CP_SPACING = 3 local COMBO_COLORS = { {0.3, 1.0, 0.3, 1}, {0.6, 1.0, 0.0, 1}, {1.0, 0.85, 0.0, 1}, {1.0, 0.45, 0.0, 1}, {1.0, 0.1, 0.1, 1}, } local _, playerClass = UnitClass("player") playerClass = playerClass or "" local canUseComboPoints = (playerClass == "ROGUE" or playerClass == "DRUID") function NanamiPlates_ComboPoints:CanUseComboPoints() return canUseComboPoints end function NanamiPlates_ComboPoints:CreateComboPointFrames(nameplate) if not canUseComboPoints then return end nameplate.comboPoints = {} local plateName = nameplate:GetName() or "UnknownPlate" local size = Settings.comboPointsSize or CP_SIZE for i = 1, MAX_COMBO_POINTS do local cp = CreateFrame("Frame", plateName .. "CP" .. i, nameplate) cp:SetWidth(size) cp:SetHeight(size) cp:SetFrameLevel(nameplate.health:GetFrameLevel() + 6) cp:EnableMouse(false) -- Outer glow/shadow cp.glow = cp:CreateTexture(nil, "BACKGROUND") cp.glow:SetTexture("Interface\\Buttons\\WHITE8X8") cp.glow:SetPoint("CENTER", cp, "CENTER", 0, 0) cp.glow:SetWidth(size + 4) cp.glow:SetHeight(size + 4) cp.glow:SetVertexColor(0, 0, 0, 0.6) cp.glow:SetDrawLayer("BACKGROUND") -- Border (themed) cp.border = cp:CreateTexture(nil, "BORDER") cp.border:SetTexture("Interface\\Buttons\\WHITE8X8") cp.border:SetPoint("CENTER", cp, "CENTER", 0, 0) cp.border:SetWidth(size + 2) cp.border:SetHeight(size + 2) local brR, brG, brB = NP.GetThemeColor("panelBorder", 0.55, 0.30, 0.42, 1) cp.border:SetVertexColor(brR, brG, brB, 1) cp.border:SetDrawLayer("BORDER") -- Main fill cp.icon = cp:CreateTexture(nil, "ARTWORK") cp.icon:SetTexture("Interface\\Buttons\\WHITE8X8") cp.icon:SetPoint("CENTER", cp, "CENTER", 0, 0) cp.icon:SetWidth(size) cp.icon:SetHeight(size) cp.icon:SetVertexColor(0.12, 0.08, 0.12, 0.6) cp.icon:SetDrawLayer("ARTWORK") -- Number text cp.text = cp:CreateFontString(nil, "OVERLAY") cp.text:SetFont(NP.GetFont(), size - 2, NP.GetFontOutline()) cp.text:SetPoint("CENTER", cp, "CENTER", 0, 0) cp.text:SetText("") cp.text:SetDrawLayer("OVERLAY") cp.active = false cp:Hide() nameplate.comboPoints[i] = cp end end function NanamiPlates_ComboPoints:UpdateComboPoints(nameplate, isTarget) if not canUseComboPoints then return 0 end if not nameplate.comboPoints then return 0 end if not Settings.showComboPoints then for i = 1, MAX_COMBO_POINTS do if nameplate.comboPoints[i] then nameplate.comboPoints[i]:Hide() end end return 0 end local numPoints = 0 if isTarget and UnitExists("target") then numPoints = GetComboPoints("player", "target") or 0 end local size = Settings.comboPointsSize or CP_SIZE for i = 1, MAX_COMBO_POINTS do local cp = nameplate.comboPoints[i] if cp then cp:SetWidth(size) cp:SetHeight(size) cp.glow:SetWidth(size + 4) cp.glow:SetHeight(size + 4) cp.border:SetWidth(size + 2) cp.border:SetHeight(size + 2) cp.icon:SetWidth(size) cp.icon:SetHeight(size) cp.text:SetFont(NP.GetFont(), size - 2 > 6 and size - 2 or 6, NP.GetFontOutline()) if i <= numPoints then local color = COMBO_COLORS[i] or COMBO_COLORS[MAX_COMBO_POINTS] cp.icon:SetVertexColor(color[1], color[2], color[3], 1) cp.glow:SetVertexColor(color[1] * 0.4, color[2] * 0.4, color[3] * 0.4, 0.7) cp.text:SetText(i) cp.text:SetTextColor(1, 1, 1, 0.9) cp.active = true cp:Show() elseif numPoints > 0 then cp.icon:SetVertexColor(0.12, 0.08, 0.12, 0.5) cp.glow:SetVertexColor(0, 0, 0, 0.4) cp.text:SetText("") cp.active = false cp:Show() else cp:Hide() end end end return numPoints end function NanamiPlates_ComboPoints:UpdateComboPointPositions(nameplate, numDebuffs) if not canUseComboPoints then return end if not nameplate.comboPoints then return end if not Settings.showComboPoints then return end if not nameplate.healthBG then return end local numVisible = 0 for i = 1, MAX_COMBO_POINTS do if nameplate.comboPoints[i] and nameplate.comboPoints[i]:IsShown() then numVisible = MAX_COMBO_POINTS break end end if numVisible == 0 then if nameplate.name and nameplate._cpNameOffset then nameplate.name:ClearAllPoints() nameplate.name:SetPoint("BOTTOM", nameplate.healthBG, "TOP", 0, 2) nameplate._cpNameOffset = nil end return end local size = Settings.comboPointsSize or CP_SIZE local spacing = CP_SPACING local totalWidth = (size * MAX_COMBO_POINTS) + (spacing * (MAX_COMBO_POINTS - 1)) local startOffset = -totalWidth / 2 + size / 2 for i = 1, MAX_COMBO_POINTS do local cp = nameplate.comboPoints[i] if cp then cp:ClearAllPoints() local xOffset = startOffset + (i - 1) * (size + spacing) cp:SetPoint("BOTTOM", nameplate.healthBG, "TOP", xOffset, 2) end end if nameplate.name then nameplate.name:ClearAllPoints() nameplate.name:SetPoint("BOTTOM", nameplate.healthBG, "TOP", 0, 2 + size + 2) nameplate._cpNameOffset = true end end function NanamiPlates_ComboPoints:HideComboPoints(nameplate) if not nameplate.comboPoints then return end for i = 1, MAX_COMBO_POINTS do if nameplate.comboPoints[i] then nameplate.comboPoints[i]:Hide() end end if nameplate.name and nameplate._cpNameOffset then nameplate.name:ClearAllPoints() nameplate.name:SetPoint("BOTTOM", nameplate.healthBG, "TOP", 0, 2) nameplate._cpNameOffset = nil end end NanamiPlates.ComboPoints = NanamiPlates_ComboPoints