diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c29a356 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,31 @@ +name: Release + +on: + push: + tags: + - '[0-9]*' + - 'v[0-9]*' + +jobs: + build: + + runs-on: ubuntu-latest + env: + CF_API_KEY: ${{ secrets.CF_API_KEY }} + GITHUB_OAUTH: ${{ secrets.GH_OAUTH }} + WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }} + steps: + - uses: actions/checkout@v1 + - name: Install and run Luacheck + run: | + sudo apt-get install luarocks + luarocks install --local luacheck + /home/runner/.luarocks/bin/luacheck . --no-color -q + + - name: Create Package + run: curl -s https://raw.githubusercontent.com/BigWigsMods/packager/master/release.sh | bash; + if: '!contains( github.ref, ''beta'')' + + - name: Create Pre-Release Package + run: curl -s https://raw.githubusercontent.com/BigWigsMods/packager/master/release.sh | bash -s -- -p 0 -w 0; + if: 'contains( github.ref, ''beta'')' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ad4037 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.orig +Libs/ diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..592998b --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,134 @@ +std = "lua51" +max_line_length = false +exclude_files = { + "**/Libs", +} +only = { + "011", -- syntax + "1", -- globals +} +ignore = { + "11/SLASH_.*", -- slash handlers + "1/[A-Z][A-Z][A-Z0-9_]+", -- three letter+ constants +} +globals = { + -- wow std api + "abs", + "acos", + "asin", + "atan", + "atan2", + "bit", + "ceil", + "cos", + "date", + "debuglocals", + "debugprofilestart", + "debugprofilestop", + "debugstack", + "deg", + "difftime", + "exp", + "fastrandom", + "floor", + "forceinsecure", + "foreach", + "foreachi", + "format", + "frexp", + "geterrorhandler", + "getn", + "gmatch", + "gsub", + "hooksecurefunc", + "issecure", + "issecurevariable", + "ldexp", + "log", + "log10", + "max", + "min", + "mod", + "rad", + "random", + "scrub", + "securecall", + "seterrorhandler", + "sin", + "sort", + "sqrt", + "strbyte", + "strchar", + "strcmputf8i", + "strconcat", + "strfind", + "string.join", + "strjoin", + "strlen", + "strlenutf8", + "strlower", + "strmatch", + "strrep", + "strrev", + "strsplit", + "strsub", + "strtrim", + "strupper", + "table.wipe", + "tan", + "time", + "tinsert", + "tremove", + "wipe", + + -- everything else + "NugHealth", + "NugHealthDB", + + "C_Timer", + "UIParent", + "SlashCmdList", + "LibStub", + "GetLocale", + "GameTooltip", + "Mixin", + "PixelUtil", + "ColorPickerFrame", + + + "Enum", + "UnitPower", + "GetTime", + + "InterfaceOptionsFrame", + "InterfaceOptionsFrame_OpenToCategory", + "InterfaceOptions_AddCategory", + "LoadAddOn", + "ActionButton_GetOverlayGlow", + "Mixin", + + "GetBuildnfo", + "CreateFrame", + "IsPlayerSpell", + "GetSpellInfo", + "UnitHealth", + "UnitHealthMax", + "UnitAura", + "UnitGUID", + "CopyTable", + "UnitGetTotalAbsorbs", + "UnitGetIncomingHeals", + "UnitClass", + "GetBuildInfo", + "InCombatLockdown", + "UnitClass", + "UnitStagger", + "UnitGetTotalHealAbsorbs", + "InCombatLockdown", + "CombatLogGetCurrentEventInfo", + "GetCVar", + "UnitClass", + "CreateTexturePool", + "C_NamePlate", + "GetSpellTexture", +} diff --git a/.pkgmeta b/.pkgmeta new file mode 100644 index 0000000..ff40053 --- /dev/null +++ b/.pkgmeta @@ -0,0 +1,3 @@ +package-as: NugTotemIcons + +enable-nolib-creation: no diff --git a/NugTotemIcon.toc b/NugTotemIcon.toc new file mode 100644 index 0000000..b1e2cf4 --- /dev/null +++ b/NugTotemIcon.toc @@ -0,0 +1,3 @@ +## Interface: 90000 +## Title: NugTotemIcon +core.lua diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..f5f178e --- /dev/null +++ b/core.lua @@ -0,0 +1,90 @@ +local f = CreateFrame("Frame", nil, UIParent) +f:RegisterEvent("NAME_PLATE_UNIT_ADDED") +f:RegisterEvent("NAME_PLATE_UNIT_REMOVED") + +f:SetScript("OnEvent", function(self, event, ...) + return self[event](self, event, ...) +end) + +-- nameplateShowEnemyGuardians = "0", +-- nameplateShowEnemyMinions = "0", +-- nameplateShowEnemyMinus = "0", +-- nameplateShowEnemyPets = "1", +-- nameplateShowEnemyTotems = "1", + +local function GetUnitNPCID(unit) + local guid = UnitGUID(unit) + local _, _, _, _, _, npcID = strsplit("-", guid); + return tonumber(npcID) +end + +local totemNpcIDs = { + -- [npcID] = { spellID, duration } + [2630] = { 2484, 20 }, -- Earthbind + [3527] = { 5394, 15 }, -- Healing Stream + [6112] = { 8512, 120 }, -- Windfury + [97369] = { 192222, 15 }, -- Liquid Magma + [5913] = { 8143, 10 }, -- Tremor + [5925] = { 204336, 3 }, -- Grounding + [78001] = { 157153, 15 }, -- Cloudburst + [53006] = { 98008, 6 }, -- Spirit Link + [59764] = { 108280, 12 }, -- Healing Tide + [61245] = { 192058, 2 }, -- Static Charge + [100943] = { 198838, 15 }, -- Earthen Wall + [97285] = { 192077, 15 }, -- Wind Rush + [105451] = { 204331, 15 }, -- Counterstrike + [104818] = { 207399, 30 }, -- Ancestral + [105427] = { 204330, 15 }, -- Skyfury + + -- Warrior + [119052] = { 236320, 15 }, -- War Banner +} + +local function CreateIcon(nameplate) + local frame = CreateFrame("Frame", nil, nameplate) + frame:SetSize(63, 63) + frame:SetPoint("BOTTOM", nameplate, "TOP", 0, 5) + + local icon = frame:CreateTexture(nil, "ARTWORK") + icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) + icon:SetAllPoints() + + local bg = frame:CreateTexture(nil, "BACKGROUND") + bg:SetTexture("Interface\\BUTTONS\\WHITE8X8") + bg:SetVertexColor(0, 0, 0, 0.5) + bg:SetPoint("TOPLEFT", frame, "TOPLEFT", -2, 2) + bg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 2, -2) + + frame.icon = icon + frame.bg = bg + + return frame +end + +function f.NAME_PLATE_UNIT_ADDED(self, event, unit) + local np = C_NamePlate.GetNamePlateForUnit(unit) + local npcID = GetUnitNPCID(unit) + + if npcID and totemNpcIDs[npcID] then + if not np.NugTotemIcon then + np.NugTotemIcon = CreateIcon(np) + end + + local iconFrame = np.NugTotemIcon + iconFrame:Show() + + local totemData = totemNpcIDs[npcID] + local spellID, duration = unpack(totemData) + + local tex = GetSpellTexture(spellID) + + iconFrame.icon:SetTexture(tex) + end +end + +function f.NAME_PLATE_UNIT_REMOVED(self, event, unit) + local np = C_NamePlate.GetNamePlateForUnit(unit) + if np.NugTotemIcon then + np.NugTotemIcon:Hide() + end +end