├── .gitignore
├── Textures
├── Overlay.tga
└── Square_FullWhite.tga
├── Controller.xml
├── .github
└── workflows
│ └── release.yml
├── embeds.xml
├── Overlay.xml
├── pkgmeta.yaml
├── fetchlocale.sh
├── LiteButtonAuras.toc
├── UI
├── AceGUIWidgets-LBAInputFocus.lua
├── AceGUIWidgets-LBAAnchorButtons.lua
├── AceGUIWidgets-LBAInputValidSpell.lua
├── AceGUIWidgets-LBAInputSpellID.lua
└── Options.lua
├── get-libs.sh
├── .luacheckrc
├── ColorGradient.lua
├── ClassicCompat.lua
├── SpellData.lua
├── README.md
├── SlashCommand.lua
├── Options.lua
├── UnitState.lua
├── BarIntegrations.lua
├── Controller.lua
├── Localization.lua
├── Overlay.lua
└── LICENSE.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | .release
2 | Libs/*
3 |
--------------------------------------------------------------------------------
/Textures/Overlay.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xod-wow/LiteButtonAuras/HEAD/Textures/Overlay.tga
--------------------------------------------------------------------------------
/Textures/Square_FullWhite.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xod-wow/LiteButtonAuras/HEAD/Textures/Square_FullWhite.tga
--------------------------------------------------------------------------------
/Controller.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Package and release
2 |
3 | on:
4 | push:
5 | tags:
6 | - '**'
7 |
8 | jobs:
9 |
10 | release:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | env:
15 | CF_API_KEY: ${{ secrets.CF_API_KEY }}
16 | WOWI_API_TOKEN: ${{ secrets.WOWI_API_TOKEN }}
17 | WAGO_API_TOKEN: ${{ secrets.WAGO_API_TOKEN }}
18 | GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }}
19 |
20 | steps:
21 |
22 | - name: Clone project
23 | uses: actions/checkout@v3
24 | with:
25 | fetch-depth: 0
26 |
27 | - name: Package and release
28 | uses: BigWigsMods/packager@v2
29 |
--------------------------------------------------------------------------------
/embeds.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Overlay.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/pkgmeta.yaml:
--------------------------------------------------------------------------------
1 | externals:
2 | Libs/AceConfig-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceConfig-3.0
3 | Libs/AceDB-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceDB-3.0
4 | Libs/AceDBOptions-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceDBOptions-3.0
5 | Libs/AceGUI-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceGUI-3.0
6 | Libs/AceGUI-3.0-SharedMediaWidgets: https://repos.wowace.com/wow/ace-gui-3-0-shared-media-widgets/trunk/AceGUI-3.0-SharedMediaWidgets
7 | Libs/AceConsole-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceConsole-3.0
8 | Libs/CallbackHandler-1.0: https://repos.curseforge.com/wow/callbackhandler/trunk/CallbackHandler-1.0
9 | Libs/LibSharedMedia-3.0: https://repos.curseforge.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
10 | Libs/LibStub: https://repos.curseforge.com/wow/libstub/trunk
11 | Libs/LibButtonGlow-1.0: https://repos.curseforge.com/wow/libbuttonglow-1-0
12 |
13 | enable-nolib-creation: no
14 |
--------------------------------------------------------------------------------
/fetchlocale.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | DASHES=--------------------------------------------------------------------------------
4 |
5 | header () {
6 | _LINE="-- $1 "
7 | _LEN=$(( 1 + 80 - $(echo "$_LINE" | wc -c) ))
8 | printf "%s%.*s\n" "$_LINE" $_LEN $DASHES
9 | echo
10 | }
11 |
12 | fetch () {
13 | curl \
14 | -s -H "X-Api-Token: $APIKEY" \
15 | "https://wow.curseforge.com/api/projects/526431/localization/export?export-type=TableAdditions&lang=$1&unlocalized=ShowBlankAsComment" \
16 | | grep -v 'Translation missing' \
17 | | sed -e 's/^/ /; s/ *$//;'
18 | }
19 |
20 | for locale in "deDE" "esES" "frFR" "itIT" "koKR" "ptBR" "ruRU" "zhCN" "zhTW"; do
21 |
22 | # As far as I can tell everyone treats esES and esMX as identical
23 | case $locale in
24 | esES)
25 | header "esES / esMX"
26 | echo 'if locale == "esES" or locale == "esMX" then'
27 | ;;
28 | *)
29 | header $locale
30 | echo "if locale == \"$locale\" then"
31 | ;;
32 | esac
33 |
34 | fetch $locale
35 |
36 | echo "end"
37 | if [ "$locale" != "zhTW" ]; then
38 | echo
39 | fi
40 | done
41 |
--------------------------------------------------------------------------------
/LiteButtonAuras.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 110207, 50502, 11508
2 | ## Title: LiteButtonAuras
3 | ## IconTexture: Interface\Icons\ability_deathknight_heartstopaura
4 | ## AddonCompartmentFunc: LiteButtonAuras_AddonCompartmentFunc
5 | ## Version: @project-version@
6 | ## Author: Xodiv-Nagrand
7 | ## Email: mib@post.com
8 | ## OptionalDeps: Masque
9 | ## SavedVariables: LiteButtonAurasDB
10 | ## X-Category: Interface
11 | ## X-Curse-Project-ID: 526431
12 | ## X-WoWI-ID: 26528
13 | ## X-Wago-ID: QNlq296e
14 | ## Category: Buffs & Debuffs
15 | ## Category-deDE: Buffs & Debuffs
16 | ## Category-esES: Beneficios y Perjuicios
17 | ## Category-esMX: Beneficios y Perjuicios
18 | ## Category-frFR: Améliorations et Affaiblissements
19 | ## Category-itIT: Benefici e penalità
20 | ## Category-koKR: 강화 및 약화 효과
21 | ## Category-ptBR: Bônus e Penalidades
22 | ## Category-ruRU: Баффы и дебаффы
23 | ## Category-zhCN: 增益和减益
24 | ## Category-zhTW: 增益與減益
25 | embeds.xml
26 |
27 | Localization.lua
28 | ClassicCompat.lua
29 | SpellData.lua
30 | ColorGradient.lua
31 | BarIntegrations.lua
32 | SlashCommand.lua
33 | Options.lua
34 | UnitState.lua
35 | Overlay.xml
36 | Controller.xml
37 |
38 | UI\AceGUIWidgets-LBAAnchorButtons.lua
39 | UI\AceGUIWidgets-LBAInputFocus.lua
40 | UI\AceGUIWidgets-LBAInputSpellID.lua
41 | UI\Options.lua
42 |
--------------------------------------------------------------------------------
/UI/AceGUIWidgets-LBAInputFocus.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | From WeakAuras2
3 | Input Widget that allows to show an alternative text when it does not have focus
4 | Uses \0 to separate the without and with focus texts.
5 | -------------------------------------------------------------------------------]]
6 |
7 | local Type, Version = "LBAInputFocus", 1
8 | local AceGUI = LibStub("AceGUI-3.0", true)
9 |
10 | local OnEditFocusGained = function(self)
11 | local textWithFocus = self.obj.textWithFocus
12 | if textWithFocus and self:GetText() == self.obj.textWithoutFocus then
13 | self:SetText(textWithFocus)
14 | end
15 | AceGUI:SetFocus(self.obj)
16 | end
17 |
18 | local function Constructor()
19 | local frame = AceGUI:Create("EditBox")
20 | frame.type = Type
21 |
22 | frame.editbox:SetScript("OnEditFocusGained", OnEditFocusGained)
23 |
24 | local oldSetText = frame.SetText
25 | frame.SetText = function(self, text)
26 | text = text or ""
27 | local pos = string.find(text, "\0", nil, true)
28 | if pos then
29 | self.textWithoutFocus = text:sub(1, pos -1)
30 | self.textWithFocus = text:sub(pos + 1)
31 | oldSetText(self, self.textWithoutFocus)
32 | else
33 | self.textWithFocus = nil
34 | self.textWithoutFocus = nil
35 | oldSetText(self, text)
36 | end
37 | end
38 |
39 | return frame
40 | end
41 |
42 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
43 |
--------------------------------------------------------------------------------
/get-libs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # I think most devs just get curse updater or something to keep the libs
4 | # globally. I don't know if that's a good idea or not. Honestly I feel
5 | # pretty nervous about packaging "the newest version" all the time.
6 | #
7 |
8 | indent () {
9 | sed -e 's/^/ /'
10 | }
11 |
12 | get_repotype () {
13 | case "$1" in
14 | *libbuttonglow-1-0)
15 | echo git
16 | ;;
17 | *://repos.curseforge.com/*)
18 | echo svn
19 | ;;
20 | *://repos.wowace.com/*)
21 | echo svn
22 | ;;
23 | *://svn*)
24 | echo svn
25 | ;;
26 | svn:*)
27 | echo svn
28 | ;;
29 | *://git*)
30 | echo git
31 | ;;
32 | git:*)
33 | echo git
34 | ;;
35 | *) # I guess
36 | echo git
37 | ;;
38 | esac
39 | }
40 |
41 | get_libs () {
42 | local INLIBS=0
43 | local FILE
44 | if [ -f pkgmeta.yaml ]; then
45 | FILE=pkgmeta.yaml
46 | else
47 | FILE=.pkgmeta
48 | fi
49 |
50 | cat $FILE | while read k v; do
51 | case $k in
52 | externals:)
53 | INLIBS=1
54 | ;;
55 | "")
56 | INLIBS=0
57 | ;;
58 | *)
59 | if [ $INLIBS -eq 1 ]; then
60 | echo ${v} $( get_repotype $v ) ${k/:/}
61 | fi
62 | ;;
63 | esac
64 | done
65 | }
66 |
67 | update_repo () {
68 | local repotype=$1
69 | local dir=$2
70 |
71 | case $repotype in
72 | git)
73 | (cd $dir && git pull && git reset --hard)
74 | ;;
75 | svn)
76 | (cd $dir && svn up)
77 | ;;
78 | esac
79 | }
80 |
81 | fetch_repo () {
82 | local uri=$1
83 | local repotype=$2
84 | local dir=$3
85 |
86 | case $repotype in
87 | git)
88 | git clone $uri $dir
89 | ;;
90 | svn)
91 | svn co $uri $dir
92 | ;;
93 | esac
94 | }
95 |
96 |
97 | get_libs | while read uri repotype dir; do
98 | if [ -d $dir ]; then
99 | echo "Updating $dir"
100 | update_repo $repotype $dir 2>&1 | indent
101 | else
102 | echo "Cloning $uri into $dir"
103 | fetch_repo $uri $repotype $dir 2>&1 | indent
104 | fi
105 | done
106 |
--------------------------------------------------------------------------------
/.luacheckrc:
--------------------------------------------------------------------------------
1 | exclude_files = {
2 | ".luacheckrc",
3 | "Tests/",
4 | "Libs/",
5 | }
6 |
7 | -- https://luacheck.readthedocs.io/en/stable/warnings.html
8 |
9 | ignore = {
10 | "11./BINDING_.*", -- Setting an undefined (Keybinding) global variable
11 | "211", -- Unused local variable
12 | "212", -- Unused argument
13 | "213", -- Unused loop variable
14 | "432/self", -- Shadowing a local variable
15 | "542", -- empty if branch
16 | "631", -- line too long
17 | }
18 |
19 | globals = {
20 | "LiteButtonAurasController",
21 | "LiteButtonAurasControllerMixin",
22 | "LiteButtonAurasDB",
23 | "LiteButtonAurasOverlayMixin",
24 | "LiteButtonAuras_AddonCompartmentFunc",
25 | "SlashCmdList",
26 | }
27 |
28 | read_globals = {
29 | "ABP_NS",
30 | "ADD",
31 | "ActionBarButtonEventsFrame",
32 | "ActionButtonSpellAlertManager",
33 | "ActionButton_HideOverlayGlow",
34 | "ActionButton_SetupOverlayGlow",
35 | "AuraUtil",
36 | "C_ActionBar",
37 | "C_Item",
38 | "C_Spell",
39 | "C_SpellBook",
40 | "C_UnitAuras",
41 | "ChatFontNormal",
42 | "ContinuableContainer",
43 | "CopyTable",
44 | "CreateFrame",
45 | "CreateFromMixins",
46 | "DEFAULT",
47 | "DELETE",
48 | "DebuffTypeColor",
49 | "Dominos",
50 | "GAMEMENU_HELP",
51 | "GENERAL",
52 | "GRAY_FONT_COLOR",
53 | "GameFontHighlight",
54 | "GameFontNormal",
55 | "GameTooltip",
56 | "GameTooltip_Hide",
57 | "GetActionInfo",
58 | "GetActionText",
59 | "GetCVarBool",
60 | "GetKeysArray",
61 | "GetLocale",
62 | "GetMacroBody",
63 | "GetMacroIndexByName",
64 | "GetMacroItem",
65 | "GetMacroSpell",
66 | "GetModifiedClick",
67 | "GetNumArenaOpponents",
68 | "GetNumGroupMembers",
69 | "GetTime",
70 | "GetTotemInfo",
71 | "GetValuesArray",
72 | "GetWeaponEnchantInfo",
73 | "HIGHLIGHT_FONT_COLOR",
74 | "HasAction",
75 | "IsModifiedClick",
76 | "IsMouseButtonDown",
77 | "IsPlayerSpell",
78 | "IsSpellOverlayed",
79 | "LE_EXPANSION_LEVEL_CURRENT",
80 | "LibStub",
81 | "MAX_BOSS_FRAMES",
82 | "MAX_TOTEMS",
83 | "Mixin",
84 | "NONE",
85 | "NORMAL_FONT_COLOR",
86 | "NumberFontNormal",
87 | "OKAY",
88 | "ORANGE_FONT_COLOR",
89 | "PLAYER",
90 | "PixelUtil",
91 | "REMOVE",
92 | "SELECTED_CHAT_FRAME",
93 | "SETTINGS",
94 | "SPELLS",
95 | "SecureCmdOptionParse",
96 | "Settings",
97 | "Spell",
98 | "TARGET",
99 | "UIParent",
100 | "UnitCanAttack",
101 | "UnitCastingInfo",
102 | "UnitChannelInfo",
103 | "UnitExists",
104 | "UnitIsFriend",
105 | "UnitIsUnit",
106 | "WOW_PROJECT_CLASSIC",
107 | "WOW_PROJECT_ID",
108 | "WithinRange",
109 | "format",
110 | "hooksecurefunc",
111 | "sort",
112 | "strsplit",
113 | "tContains",
114 | "tDeleteItem",
115 | "table",
116 | }
117 |
--------------------------------------------------------------------------------
/ColorGradient.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | I took the idea for the HLS gradients from AdiButtonAuras. The code
7 | is adapated from the python colorsys module but you can find the same
8 | algorithm on StackOverflow.
9 |
10 | Benchmarking this looks like LBA.TimerRGB takes about 0.5ns to run
11 | when the timer is >10s, and 2ns to run when it has to interpolate.
12 | At 100fps this is 200ns per second which seems fine to me.
13 |
14 | That's just the color calcuating though, whether or not its a good idea
15 | to run run SetFormattedText and SetTextColor every frame is different
16 | matter. BuffFrame does it though, so I do too!
17 |
18 | ----------------------------------------------------------------------------]]--
19 |
20 | local _, LBA = ...
21 |
22 | LBA = LBA or {}
23 |
24 | local min, max = math.min, math.max
25 |
26 | local function hueToV(m1, m2, hue)
27 | hue = hue % 1
28 | if hue < 1/6 then
29 | return m1 + (m2-m1)*hue*6
30 | elseif hue < 1/2 then
31 | return m2
32 | elseif hue < 2/3 then
33 | return m1 + (m2-m1)*(2/3-hue)*6
34 | else
35 | return m1
36 | end
37 | end
38 |
39 | local function hlsToRgb(h, l, s)
40 | if s == 0 then
41 | return l, l, l
42 | end
43 | local m2
44 | if l < 0.5 then
45 | m2 = l * (1+s)
46 | else
47 | m2 = (l+s) - (l*s)
48 | end
49 | local m1 = 2*l - m2
50 | return hueToV(m1, m2, h+1/3), hueToV(m1, m2, h), hueToV(m1, m2, h-1/3)
51 | end
52 |
53 | local function rgbToHls(r, g, b)
54 | local minC, maxC = min(r, g, b), max(r, g, b)
55 | local l = (minC + maxC)/2
56 | if minC == maxC then
57 | return 0, l, 0
58 | end
59 | local h, s
60 | if l < 0.5 then
61 | s = (maxC-minC) / (maxC+minC)
62 | else
63 | s = (maxC-minC) / (2-maxC-minC)
64 | end
65 | local rc = (maxC-r) / (maxC-minC)
66 | local gc = (maxC-g) / (maxC-minC)
67 | local bc = (maxC-b) / (maxC-minC)
68 | if r == maxC then
69 | h = bc - gc
70 | elseif g == maxC then
71 | h = 2 + rc - bc
72 | else
73 | h = 4 + gc - rc
74 | end
75 | return (h/6) % 1, l, s
76 | end
77 |
78 | local function interpolateHls(perc, h1, l1, s1, h2, l2, s2)
79 | -- L and S are linear interpolated
80 | local l = l1 + (l2-l1) * perc
81 | local s = s1 + (s2-s1) * perc
82 |
83 | -- Hue is a degree coordinate in radians on a circle that wraps. We want
84 | -- the smallest of the two angles between them.
85 | local dh = h2 - h1
86 | if dh < -0.5 then
87 | dh = dh + 1
88 | elseif dh > 0.5 then
89 | dh = dh - 1
90 | end
91 |
92 | local h = (h1 + dh*perc) % 1
93 | return h, l, s
94 | end
95 |
96 | -- Colors in HLS so we don't have to do the math to convert them every frame.
97 | -- These are brighter than the pure rgb because the 1,0,0 red is too hard to
98 | -- see.
99 |
100 | local Red = { 0, 0.75, 1 }
101 | local Yellow = { 1/6, 0.75, 1 }
102 | local White = { 0, 1, 0 }
103 |
104 | -- In theory this could be memoized for the values < 10s because they are
105 | -- truncated to 0.1 of a second before this is called. But I don't know
106 | -- enough about math.ceil to know if that's safe, and I'm guaranteed to
107 | -- forget that at some point and blow out memory infinitely.
108 |
109 | function LBA.TimerRGB(duration)
110 | if duration <= 3 then
111 | return hlsToRgb(
112 | interpolateHls(
113 | duration/3,
114 | Red[1], Red[2], Red[3],
115 | Yellow[1], Yellow[2], Yellow[3]
116 | )
117 | )
118 | elseif duration <= 10 then
119 | return hlsToRgb(
120 | interpolateHls(
121 | (duration-3)/7,
122 | Yellow[1], Yellow[2], Yellow[3],
123 | White[1], White[2], White[3]
124 | )
125 | )
126 | else
127 | return 1, 1, 1
128 | end
129 | end
130 |
131 | --@debug@
132 | LBA.interpolateHls = interpolateHls
133 | LBA.rgbToHls = rgbToHls
134 | LBA.hlsToRgb = hlsToRgb
135 | --@end-debug@
136 |
--------------------------------------------------------------------------------
/UI/AceGUIWidgets-LBAAnchorButtons.lua:
--------------------------------------------------------------------------------
1 | -- From WeakAuras2
2 |
3 | local Type, Version = "LBAAnchorButtons", 2
4 | local AceGUI = LibStub("AceGUI-3.0")
5 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
6 |
7 | local directions = { "TOPLEFT", "TOP", "TOPRIGHT", "LEFT", "CENTER", "RIGHT", "BOTTOMLEFT", "BOTTOM", "BOTTOMRIGHT" }
8 | local buttonSize = 10
9 | local frameWidth = 100
10 | local frameHeight = 50
11 | local titleHeight = 22
12 |
13 | local methods = {
14 | ["OnAcquire"] = function(self)
15 | self:SetWidth(frameWidth + buttonSize)
16 | self:SetHeight(frameHeight + buttonSize + titleHeight + 2)
17 | self:SetDisabled(false)
18 | end,
19 |
20 | ["SetValue"] = function(self, text)
21 | if not tContains(directions, text) then return end
22 | for direction, button in pairs(self.buttons) do
23 | if direction == text then
24 | button.tex:SetVertexColor(0.9, 0.9, 0, 1)
25 | else
26 | button.tex:SetVertexColor(0.3, 0.3, 0.3, 1)
27 | end
28 | button:SetNormalTexture(button.tex)
29 | end
30 | self.value = text
31 | end,
32 |
33 | ["GetValue"] = function(self)
34 | return self.value
35 | end,
36 |
37 | ["SetLabel"] = function(self, text)
38 | if text and text ~= "" then
39 | self.label:SetText(text);
40 | self.label:Show()
41 | else
42 | self.label:SetText("")
43 | self.label:Hide()
44 | end
45 | end,
46 |
47 | ["SetList"] = function() end,
48 |
49 | ["SetDisabled"] = function(self, disabled)
50 | self.disabled = disabled
51 | if disabled then
52 | self.label:SetTextColor(0.5,0.5,0.5)
53 | for _, button in pairs(self.buttons) do
54 | button:EnableMouse(false)
55 | end
56 | else
57 | self.label:SetTextColor(1,.82,0)
58 | for _, button in pairs(self.buttons) do
59 | button:EnableMouse(true)
60 | end
61 | end
62 | end,
63 | }
64 |
65 | local function buttonClicked(self)
66 | AceGUI:ClearFocus()
67 | local frame = self:GetParent()
68 | local widget = frame.obj
69 | widget:SetValue(self.value)
70 | widget:Fire("OnValueChanged", self.value)
71 | end
72 |
73 | local function Constructor()
74 | local name = "LBAAnchorButtons" .. AceGUI:GetNextWidgetNum(Type)
75 | local frame = CreateFrame("Frame", name, UIParent)
76 | frame:SetSize(frameWidth, frameHeight)
77 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
78 |
79 | local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall");
80 | label:SetHeight(titleHeight);
81 | label:SetJustifyH("CENTER");
82 | label:SetPoint("TOP", frame, "TOP");
83 |
84 | local background = CreateFrame("Frame", nil, frame, "BackdropTemplate")
85 | background:SetSize(frameWidth, frameHeight)
86 | background:SetPoint("TOP", frame, "TOP", 0, -(titleHeight + 4))
87 | background:SetBackdrop({
88 | bgFile = "Interface\\AddOns\\LiteButtonAuras\\Textures\\Square_FullWhite.tga",
89 | edgeFile = "Interface\\AddOns\\LiteButtonAuras\\Textures\\Square_FullWhite.tga",
90 | tile = true,
91 | tileEdge = true,
92 | --tileSize = 8,
93 | edgeSize = 2
94 | --insets = { left = 1, right = 1, top = 1, bottom = 1 },
95 | })
96 | background:SetBackdropColor(0.2,0.2,0.2,0.5)
97 | background:SetBackdropBorderColor(1,1,1,0.6)
98 |
99 | local buttons = {}
100 | for _, direction in ipairs(directions) do
101 | local button = CreateFrame("Button", nil, frame)
102 | button:SetSize(buttonSize, buttonSize)
103 | button:SetPoint(
104 | "CENTER",
105 | background,
106 | direction
107 | )
108 |
109 | local buttonTex = button:CreateTexture()
110 | buttonTex:SetAllPoints()
111 | buttonTex:SetTexture("Interface\\AddOns\\LiteButtonAuras\\Textures\\Square_FullWhite.tga")
112 | buttonTex:SetVertexColor(0.3, 0.3, 0.3, 1)
113 | button:SetNormalTexture(buttonTex)
114 | button.tex = buttonTex
115 | button.value = direction
116 |
117 | button:SetScript("OnClick", buttonClicked)
118 | buttons[direction] = button
119 | end
120 |
121 | --- @type table
122 | local widget = {
123 | frame = frame,
124 | type = Type,
125 | buttons = buttons,
126 | label = label
127 | }
128 | for method, func in pairs(methods) do
129 | widget[method] = func
130 | end
131 |
132 | return AceGUI:RegisterAsWidget(widget);
133 | end
134 |
135 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
136 |
--------------------------------------------------------------------------------
/ClassicCompat.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | For better or worse, try to back-port a minimal amount of compatibility
7 | for the 11.0 rework into classic, on the assumption that it will eventually
8 | go in there properly and this is the right approach rather than making the
9 | new way look like the old.
10 |
11 | ----------------------------------------------------------------------------]]--
12 |
13 | local _, LBA = ...
14 |
15 |
16 | -- C_Spell ---------------------------------------------------------------------
17 |
18 | LBA.C_Spell = CopyTable(C_Spell or {})
19 |
20 | if not LBA.C_Spell.GetSpellInfo then
21 | local GetSpellInfo = _G.GetSpellInfo
22 |
23 | function LBA.C_Spell.GetSpellInfo(spellIdentifier)
24 | local name, _, iconID, castTime, minRange, maxRange, spellID, originalIconID = GetSpellInfo(spellIdentifier)
25 | if name then
26 | return {
27 | name = name,
28 | iconID = iconID,
29 | originalIconID = originalIconID,
30 | castTime = castTime,
31 | minRange = minRange,
32 | maxRange = maxRange,
33 | spellID = spellID,
34 | }
35 | end
36 | end
37 | end
38 |
39 | if not LBA.C_Spell.GetSpellName then
40 | local GetSpellInfo = _G.GetSpellInfo
41 |
42 | function LBA.C_Spell.GetSpellName(spellIdentifier)
43 | local name = GetSpellInfo(spellIdentifier)
44 | return name
45 | end
46 | end
47 |
48 | if not LBA.C_Spell.GetSpellTexture then
49 | local GetSpellInfo = _G.GetSpellInfo
50 |
51 | function LBA.C_Spell.GetSpellTexture(spellIdentifier)
52 | local _, _, iconID = GetSpellInfo(spellIdentifier)
53 | return iconID
54 | end
55 | end
56 |
57 | if not LBA.C_Spell.GetSpellCooldown then
58 | local GetSpellCooldown = _G.GetSpellCooldown
59 |
60 | function LBA.C_Spell.GetSpellCooldown(spellIdentifier)
61 | local startTime, duration, isEnabled, modRate = GetSpellCooldown(spellIdentifier)
62 | if startTime then
63 | return {
64 | startTime = startTime,
65 | duration = duration,
66 | isEnabled = isEnabled,
67 | modRate = modRate,
68 | }
69 | end
70 | end
71 | end
72 |
73 |
74 | -- C_Item ----------------------------------------------------------------------
75 |
76 | LBA.C_Item = CopyTable(C_Item or {})
77 |
78 | if not LBA.C_Item.GetItemInfoInstant then
79 | LBA.C_Item.GetItemInfoInstant = _G.GetItemInfoInstant
80 | end
81 |
82 | if not LBA.C_Item.GetItemSpell then
83 | LBA.C_Item.GetItemSpell = _G.GetItemSpell
84 | end
85 |
86 |
87 | -- AuraUtil --------------------------------------------------------------------
88 |
89 | -- Classic doesn't have ForEachAura even though it has AuraUtil.
90 |
91 | LBA.AuraUtil = CopyTable(AuraUtil or {})
92 |
93 | if not AuraUtil.ForEachAura then
94 |
95 | local UnitAura = _G.UnitAura
96 |
97 | -- Turn the UnitAura returns into a facsimile of the UnitAuraInfo struct
98 | -- returned by C_UnitAuras.GetAuraDataBySlot(unit, slot)
99 |
100 | local auraInstanceID = 0
101 |
102 | local function UnitAuraData(unit, i, filter)
103 | local name, icon, count, dispelType, duration, expirationTime, source, isStealable, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, castByPlayer, nameplateShowAll, timeMod = UnitAura(unit, i, filter)
104 |
105 | local isHarmful = filter:find('HARMFUL') and true or false
106 | local isHelpful = filter:find('HELPFUL') and true or false
107 |
108 | auraInstanceID = auraInstanceID + 1
109 | return {
110 | applications = count,
111 | auraInstanceID = auraInstanceID,
112 | canApplyAura = canApplyAura,
113 | -- charges = ,
114 | dispelName = dispelType,
115 | duration = duration,
116 | expirationTime = expirationTime,
117 | icon = icon,
118 | isBossAura = isBossDebuff,
119 | isFromPlayerOrPlayerPet = castByPlayer, -- player = me vs player = a player?
120 | isHarmful = isHarmful,
121 | isHelpful = isHelpful,
122 | -- isNameplateOnly =
123 | -- isRaid =
124 | isStealable = isStealable,
125 | -- maxCharges =
126 | name = name,
127 | nameplateShowAll = nameplateShowAll,
128 | nameplateShowPersonal = nameplateShowPersonal,
129 | -- points =
130 | sourceUnit = source,
131 | spellId = spellId,
132 | timeMod = timeMod,
133 | }
134 | end
135 |
136 | function LBA.AuraUtil.ForEachAura(unit, filter, maxCount, func, usePackedAura)
137 | local i = 1
138 | while true do
139 | if maxCount and i > maxCount then
140 | return
141 | elseif UnitAura(unit, i, filter) then
142 | if usePackedAura then
143 | func(UnitAuraData(unit, i, filter))
144 | else
145 | func(UnitAura(unit, i, filter))
146 | end
147 | else
148 | return
149 | end
150 | i = i + 1
151 | end
152 | end
153 |
154 | end
155 |
--------------------------------------------------------------------------------
/SpellData.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | This is a register of spells that match a few criteria for special
7 | display: interrupts, soothes, dispels. Also a list of model IDs to
8 | match totem/guardians to spells (5th return value of GetTotemInfo)
9 | since the names differ a lot.
10 |
11 | ----------------------------------------------------------------------------]]--
12 |
13 | local _, LBA = ...
14 |
15 | local C_Spell = LBA.C_Spell or C_Spell
16 |
17 | -- Now these are matched by name don't worry about finding all the spell IDs
18 | -- for all the versions. On classic_era this is ranks, but even on live
19 | -- there are multiple Singe Magic (for example).
20 |
21 | LBA.Interrupts = {
22 | [ 47528] = true, -- Mind Freeze (Death Knight)
23 | [183752] = true, -- Disrupt (Demon Hunter)
24 | -- [202137] = true, -- Sigil of Silence (Demon Hunter)
25 | [ 78675] = true, -- Solar Beam (Druid)
26 | [106839] = true, -- Skull Bash (Druid)
27 | [147362] = true, -- Counter Shot (Hunter)
28 | [187707] = true, -- Muzzle (Hunter)
29 | [ 2139] = true, -- Counterspell (Mage)
30 | [116705] = true, -- Spear Hand Strike (Monk)
31 | [ 96231] = true, -- Rebuke (Paladin)
32 | -- [ 31935] = true, -- Avenger's Shield (Paladin)
33 | [ 15487] = true, -- Silence (Priest)
34 | [ 1766] = true, -- Kick (Rogue)
35 | [ 57994] = true, -- Wind Shear (Shaman)
36 | [ 19647] = true, -- Spell Lock (Warlock Felhunter Pet)
37 | [ 89766] = true, -- Axe Toss (Warlock Felguard Pet)
38 | [ 6552] = true, -- Pummel (Warrior)
39 | [351338] = true, -- Quell (Evoker)
40 | }
41 |
42 | LBA.Soothes = {
43 | [ 2908] = true, -- Soothe (Druid)
44 | [ 19801] = true, -- Tranquilizing Shot (Hunter)
45 | [ 5938] = true, -- Shiv (Rogue)
46 | [115078] = function () -- Paralysis (Monk) with Pressure Points
47 | return IsPlayerSpell(450432)
48 | end,
49 | }
50 |
51 | LBA.HostileDispels = {
52 | [278326] = { Magic = true }, -- Consume Magic (Demon Hunter)
53 | [ 19801] = { Magic = true }, -- Tranquilizing Shot (Hunter)
54 | [ 30449] = { Magic = true }, -- Spellsteal (Mage)
55 | [ 527] = { Magic = true }, -- Dispel Magic (Priest) Classic to Cata
56 | [ 528] = { Magic = true }, -- Dispel Magic (Priest) Mists and onwards
57 | [ 32375] = { Magic = true }, -- Mass Dispel (Priest)
58 | [ 370] = { Magic = true }, -- Purge (Shaman)
59 | [ 19505] = { Magic = true }, -- Devour Magic (Warlock)
60 | [ 25046] = { Magic = true }, -- Arcane Torrent (Blood Elf Rogue)
61 | -- [ 28730] = { Magic = true }, -- Arcane Torrent (Blood Elf Mage/Warlock)
62 | -- [ 50613] = { Magic = true }, -- Arcane Torrent (Blood Elf Death Knight)
63 | -- [ 69179] = { Magic = true }, -- Arcane Torrent (Blood Elf Warrior)
64 | -- [ 80483] = { Magic = true }, -- Arcane Torrent (Blood Elf Hunter)
65 | -- [129597] = { Magic = true }, -- Arcane Torrent (Blood Elf Monk)
66 | -- [155145] = { Magic = true }, -- Arcane Torrent (Blood Elf Paladin)
67 | -- [202719] = { Magic = true }, -- Arcane Torrent (Blood Elf Demon Hunter)
68 | -- [232633] = { Magic = true }, -- Arcane Torrent (Blood Elf Priest)
69 | }
70 |
71 | if LE_EXPANSION_LEVEL_CURRENT >= 4 then
72 | -- Remove Classic-Cataclysm version of Dispel Magic
73 | LBA.HostileDispels[527] = nil
74 | else
75 | -- Remove Mists of Pandaria and onwards Dispel Magic
76 | LBA.HostileDispels[528] = nil
77 | end
78 |
79 | LBA.Taunts = {
80 | [ 355] = true, -- Taunt (Warrior)
81 | [ 51399] = true, -- Death Grip (Death Knight)
82 | [ 56222] = true, -- Dark Command (Death Knight)
83 | [116189] = true, -- Provoke (Monk)
84 | [ 62124] = true, -- Hand of Reckoning (Paladin)
85 | [185245] = true, -- Torment (Demon Hunter)
86 | [ 6795] = true, -- Growl (Druid)
87 | [ 17735] = true, -- Suffering (Warlock Voidwalker Pet)
88 | [ 2649] = true, -- Growl (Hunter Pet)
89 | [ 1161] = true, -- Challenging Shout (Warrior)
90 | [386071] = true, -- Disrupting Shout (Warrior)
91 | }
92 |
93 | -- Where the totem name does not match the spell name. There's few enough
94 | -- of these that I think it's possible to maintain it.
95 | --
96 | -- [model] = Summoning Spell Name
97 | --
98 | -- for i = 1, MAX_TOTEMS do
99 | -- local exists, name, startTime, duration, model = GetTotemInfo(i)
100 |
101 | LBA.TotemOrGuardianModels = {
102 | [ 136119] = C_Spell.GetSpellName(46584), -- Raise Dead (DK)
103 | [ 627607] = C_Spell.GetSpellName(115315), -- Black Ox Statue (Monk)
104 | [ 620831] = C_Spell.GetSpellName(115313), -- Jade Serpent Statue (Monk)
105 | [4667418] = C_Spell.GetSpellName(388686), -- White Tiger Statue (Monk)
106 | [ 620832] = C_Spell.GetSpellName(123904), -- Xuen,the White Tiger (Monk)
107 | [ 574571] = C_Spell.GetSpellName(322118), -- Yu'lon, The Jade Serpent (Monk)
108 | -- [ 608951] = C_Spell.GetSpellName(132578), -- Niuzao, the Black Ox (Monk)
109 | [ 877514] = C_Spell.GetSpellName(325197), -- Chi-ji, The Red Crane (Monk)
110 | [ 136024] = C_Spell.GetSpellName(198103), -- Earth Elemental (Shaman)
111 | [ 135790] = C_Spell.GetSpellName(198067), -- Fire Elemental (Shaman)
112 | [1020304] = C_Spell.GetSpellName(192249), -- Storm Elemental (Shaman)
113 | [ 237577] = C_Spell.GetSpellName(51533), -- Feral Spirit (Shaman)
114 | [ 237562] = C_Spell.GetSpellName(111898), -- Grimoire: Felguard (Warlock)
115 | [1378282] = C_Spell.GetSpellName(104316), -- Call Dreadstalkers (Warlock)
116 | [1616211] = C_Spell.GetSpellName(264119), -- Summon Vilefiend (Warlock)
117 | [1709931] = C_Spell.GetSpellName(455476), -- Summon Charhound (Warlock)
118 | [1709932] = C_Spell.GetSpellName(455465), -- Summon Gloomhound (Warlock)
119 | [ 132129] = C_Spell.GetSpellName(102693), -- Grove Guardians (Druid)
120 | }
121 |
122 | LBA.WeaponEnchantSpellID = {
123 | [ 5400] = C_Spell.GetSpellName(318038), -- Flametongue Weapon
124 | [ 5401] = C_Spell.GetSpellName(33757), -- Windfury Weapon
125 | [ 6498] = C_Spell.GetSpellName(382021), -- Earthliving Weapon
126 | [ 7528] = C_Spell.GetSpellName(457481), -- Tidecaller's Guard
127 | [ 7587] = C_Spell.GetSpellName(462757), -- Thunderstrike Ward
128 | }
129 |
130 | -- The main reason for this is that Classic Era still has spell ranks,
131 | -- each rank has a different spell ID, and the tables above only have the
132 | -- first rank since that's what retail/wotlk use. It is generally more in
133 | -- keeping with our "match by name" anyway.
134 |
135 | -- Note: due to https://github.com/Stanzilla/WoWUIBugs/issues/373 it's not
136 | -- safe to use ContinueOnSpellLoad as it taints the spellbook if we're the
137 | -- first to query the spell. Fingers crossed that C_Spell.GetSpellName always
138 | -- return true for spellbook spells, even at load time. Otherwise I'll have
139 | -- to build my own SpellEventListener.
140 |
141 | do
142 | local function AddSpellNames(t)
143 | local spellIDs = GetKeysArray(t)
144 | for _, spellID in ipairs(spellIDs) do
145 | local name = C_Spell.GetSpellName(spellID)
146 | if name then
147 | t[name] = t[spellID]
148 | --@debug@
149 | else
150 | print('Missing ' .. tostring(spellID))
151 | --@end-debug@
152 | end
153 | end
154 | end
155 |
156 | AddSpellNames(LBA.Interrupts)
157 | AddSpellNames(LBA.Soothes)
158 | AddSpellNames(LBA.HostileDispels)
159 | AddSpellNames(LBA.Taunts)
160 | end
161 |
162 | --@debug@
163 | _G.LBA = LBA
164 | --@end-debug@
165 |
--------------------------------------------------------------------------------
/UI/AceGUIWidgets-LBAInputValidSpell.lua:
--------------------------------------------------------------------------------
1 | local _, LBA = ...
2 |
3 | local AceGUI = LibStub("AceGUI-3.0")
4 |
5 | local C_Spell = LBA.C_Spell or C_Spell
6 |
7 | local Type = "LBAInputValidSpell"
8 | local Version = 1
9 |
10 | -- [[ SpellCache ]] ------------------------------------------------------------
11 |
12 | local SpellCache = CreateFrame("Frame")
13 |
14 | function SpellCache.BuildCoRoutine()
15 | local id = 0
16 | local misses = 0
17 | while misses < 80000 do
18 | id = id + 1
19 | local info = C_Spell.GetSpellInfo(id)
20 |
21 | if not info then
22 | misses = misses + 1
23 | elseif info.iconID == 136243 then
24 | -- 136243 is the a gear icon, we can ignore those spells
25 | misses = 0;
26 | elseif info.name and info.name ~= "" and info.iconID then
27 | local name = info.name:lower()
28 | SpellCache.spells[name] = SpellCache.spells[name] or {}
29 | table.insert(SpellCache.spells[name], id)
30 | if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC and id == 81748 then
31 | -- jump around big hole with classic SoD
32 | id = 219002
33 | end
34 | misses = 0
35 | else
36 | misses = misses + 1
37 | end
38 | if id % 1000 == 0 then
39 | coroutine.yield()
40 | end
41 | end
42 | for _, cacheLine in pairs(SpellCache.spells) do
43 | table.sort(cacheLine)
44 | end
45 | end
46 |
47 | function SpellCache:Build()
48 |
49 | if self.spells then return end
50 |
51 | self.spells = {}
52 |
53 | local co = coroutine.create(self.BuildCoRoutine)
54 | coroutine.resume(co)
55 |
56 | self:SetScript("OnUpdate",
57 | function (self, elapsed)
58 | if coroutine.status(co) == "dead" then
59 | self:SetScript("OnUpdate", nil)
60 | else
61 | coroutine.resume(co)
62 | end
63 | end)
64 | end
65 |
66 | function SpellCache:IsValidSpell(v)
67 | if C_Spell.GetSpellName(v) then
68 | return true
69 | elseif type(v) == 'string' then
70 | v = v:lower()
71 | return self.spells[v] ~= nil
72 | end
73 | end
74 |
75 |
76 | -- [[ OkayButton ]] ------------------------------------------------------------
77 |
78 | local OkayButtonMixin = {}
79 |
80 | function OkayButtonMixin:Initialize(obj)
81 | self.obj = obj
82 | self:SetWidth(40)
83 | self:SetHeight(20)
84 | self:SetText(OKAY)
85 | self:SetScript("OnClick", self.OnClick)
86 | self:SetScript("OnShow", self.OnShow)
87 | self:SetScript("OnHide", self.OnHide)
88 | self:Hide()
89 | end
90 |
91 | function OkayButtonMixin:OnClick()
92 | local editBox = self.obj.editBox
93 | editBox:OnEnterPressed()
94 | end
95 |
96 | function OkayButtonMixin:OnShow()
97 | self.obj.editBox:SetTextInsets(0, 20, 3, 3)
98 | end
99 |
100 | function OkayButtonMixin:OnHide()
101 | self.obj.editBox:SetTextInsets(0, 0, 3, 3)
102 | end
103 |
104 | -- [[ EditBox ]] ---------------------------------------------------------------
105 |
106 | local EditBoxMixin = {}
107 |
108 | function EditBoxMixin:OnTextChanged()
109 | local value = self:GetText()
110 | if value ~= self.lastText then
111 | self.lastText = value
112 | if SpellCache:IsValidSpell(value) then
113 | self.obj.okayButton:Show()
114 | end
115 | self.obj:Fire("OnTextChanged", value)
116 | end
117 | end
118 |
119 | function EditBoxMixin:OnEditFocusGained()
120 | AceGUI:SetFocus(self.obj)
121 | end
122 |
123 | function EditBoxMixin:OnEscapePressed()
124 | self:ClearFocus()
125 | end
126 |
127 | function EditBoxMixin:OnEnterPressed()
128 | local value = self:GetText()
129 | if SpellCache:IsValidSpell(value) then
130 | local isInvalid = self.obj:Fire("OnEnterPressed", value)
131 | if isInvalid then
132 | self:SetFocus()
133 | else
134 | self.obj.okayButton:Hide()
135 | end
136 | end
137 | end
138 |
139 | function EditBoxMixin:OnEnter()
140 | self.obj:Fire("OnEnter")
141 | end
142 |
143 | function EditBoxMixin:OnLeave()
144 | self.obj:Fire("OnLeave")
145 | end
146 |
147 | function EditBoxMixin:Initialize(obj)
148 | self.obj = obj
149 | self:SetAutoFocus(false)
150 | self:SetFontObject(ChatFontNormal)
151 | self:SetScript("OnEnter", self.OnEnter)
152 | self:SetScript("OnLeave", self.OnLeave)
153 | self:SetScript("OnEscapePressed", self.OnEscapePressed)
154 | self:SetScript("OnEnterPressed", self.OnEnterPressed)
155 | self:SetScript("OnTextChanged", self.OnTextChanged)
156 | self:SetScript("OnEditFocusGained", self.OnEditFocusGained)
157 | self:SetTextInsets(0, 0, 3, 3)
158 | self:SetMaxLetters(256)
159 | end
160 |
161 |
162 | --[[ Main Widget ]] ------------------------------------------------------------
163 |
164 | local methods = {
165 |
166 | OnAcquire =
167 | function (self)
168 | self:SetHeight(26)
169 | self:SetWidth(200)
170 | self:SetDisabled(false)
171 | self:SetLabel()
172 | end,
173 |
174 | OnRelease =
175 | function (self)
176 | self.frame:ClearAllPoints()
177 | self.frame:Hide()
178 | self:SetDisabled(false)
179 | end,
180 |
181 | SetDisabled =
182 | function (self, disabled)
183 | self.disabled = disabled
184 | if disabled then
185 | self.editBox:EnableMouse(false)
186 | self.editBox:ClearFocus()
187 | self.editBox:SetTextColor(0.5, 0.5, 0.5)
188 | self.label:SetTextColor(0.5, 0.5, 0.5)
189 | else
190 | self.editBox:EnableMouse(true)
191 | self.editBox:SetTextColor(1, 1, 1)
192 | self.label:SetTextColor(1, 0.82, 0)
193 | end
194 | end,
195 |
196 | SetText =
197 | function (self, text, cursor)
198 | self.editBox:SetText(text)
199 | self.editBox:SetCursorPosition(cursor or 0)
200 | end,
201 |
202 | SetLabel =
203 | function (self, text)
204 | if text and text ~= "" then
205 | self.label:SetText(text)
206 | self.label:Show()
207 | self.editBox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, -18)
208 | self:SetHeight(44)
209 | self.alignoffset = 30
210 | else
211 | self.label:SetText("")
212 | self.label:Hide()
213 | self.editBox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, 0)
214 | self:SetHeight(26)
215 | self.alignoffset = 12
216 | end
217 | end,
218 | }
219 |
220 |
221 | local function Constructor()
222 | SpellCache:Build()
223 |
224 | local self = CreateFromMixins(methods)
225 | self.type = Type
226 | self.num = AceGUI:GetNextWidgetNum(Type)
227 |
228 | self.frame = CreateFrame("Frame", nil, UIParent)
229 | self.frame:SetHeight(44)
230 | self.frame:SetWidth(200)
231 | self.frame.obj = self
232 |
233 | self.editBox = CreateFrame("EditBox", "AceGUI30SpellEditBox" .. self.num, self.frame, "InputBoxTemplate")
234 | Mixin(self.editBox, EditBoxMixin)
235 | self.editBox:Initialize(self)
236 | self.editBox:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", 6, 0)
237 | self.editBox:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", 0, 0)
238 | self.editBox:SetHeight(19)
239 |
240 | self.label = self.frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
241 | self.label:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -2)
242 | self.label:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, -2)
243 | self.label:SetJustifyH("LEFT")
244 | self.label:SetHeight(18)
245 |
246 | self.okayButton = CreateFrame("Button", nil, self.editBox, "UIPanelButtonTemplate")
247 | Mixin(self.okayButton, OkayButtonMixin)
248 | self.okayButton:Initialize(self)
249 | self.okayButton:SetPoint("RIGHT", self.editBox, "RIGHT", -2, 0)
250 |
251 | self.alignoffset = 30
252 |
253 | AceGUI:RegisterAsWidget(self)
254 | return self
255 | end
256 |
257 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
258 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LiteButtonAuras WoW AddOn
2 |
3 | LiteButtonAuras shows your buffs on you and your debuffs on your target inside your action buttons with a
4 | colored border and timer. It is like AdiButtonAuras, and Inline Aura before it, just much dumber and much
5 | easier to maintain.
6 |
7 | Supports WoW retail, classic era (Vanilla) and classic (WotLK/MoP).
8 |
9 | ## Display
10 |
11 | A buff you cast on yourself shows a green highlight in ability button:
12 |
13 | 
14 |
15 | A buff you cast on your pet shows a blue highlight in the ability button (unless disabled in settings).
16 |
17 | A debuff you cast on your target shows red highlight in ability button:
18 |
19 | 
20 |
21 | For all of your action buttons:
22 |
23 | - Suggest button (border glow/ants) with timer if:
24 | - your target is casting a spell you can interrupt and the button action is an interrupt; or
25 | - your target is enraged and the button action is a soothe; or
26 | - your target has a buff you can purge and the button action is a purge/spellsteal.
27 | - Show a green highlight and timer if:
28 | - the action name matches a buff on you that you cast; or
29 | - the action is a totem or guardian and it is summoned.
30 | - Show a blue highlight and timer if:
31 | - the action name matches a buff on your pet that you cast
32 | - Show a red highlight and timer if:
33 | - the action name matches a debuff that you cast on your target; or
34 | - the action is a taunt and another player has taunted your target.
35 |
36 | LiteButtonAuras works with the default Blizzard action bars, ElvUI, Dominos, Bartender, ButtonForge, ActionbarPlus, and anything that uses LibActionButton.
37 |
38 | ## Support for macro units (focus/mouseover/etc)
39 |
40 | LiteButtonAuras has limited support for macros that use the '@unit' conditionals to change the unit that will be the target of the ability.
41 |
42 | The following units are supported:
43 | - arena1-5
44 | - boss1-8
45 | - focus
46 | - mouseover
47 | - party1-4
48 | - pet
49 | - player
50 | - target
51 |
52 | The limitations are:
53 | 1. Only the above units are supported.
54 | 1. You can't have /cast or /use lines without [@unit] before ones that do.
55 | 1. You can't use macro commands that change target.
56 |
57 | For example, these work:
58 |
59 | ```
60 | #showtooltip
61 | /cast [@focus,harm][@mouseover,harm][] Kick
62 | ```
63 |
64 | ```
65 | #showtooltip
66 | /focus [mod:ctrl,nodead,harm]
67 | /cast [@focus,harm] Kick
68 | /cast [@mouseover,harm] Kick
69 | /cast Kick
70 | ```
71 |
72 | ```
73 | #showtooltip
74 | /cast [@mousover,harm][harm] Paralysis
75 | /cast [@mouseover,help][] Detox
76 | ```
77 |
78 | These __do not work__:
79 | ```
80 | #showtooltip
81 | /cast Kick
82 | /cast [@focus] Tricks of the Trade
83 | ```
84 |
85 | ```
86 | #showtooltip
87 | /cleartarget
88 | /targetenemyplayer
89 | /cast Sap
90 | ```
91 |
92 | ## Support for Blizzard mouseover/focus casting
93 |
94 | There is experimental support for the Blizzard automatic mouseover casting and focus casting. I don't use it,
95 | I don't know how it works and I never tested it. If you do let me know how it went.
96 |
97 | ## Comparison with AdiButtonAuras
98 |
99 | Compared to AdiButtonAuras (which this addon was modeled on), LiteButtonAuras:
100 |
101 | 1. matches buffs/debuffs by name, so it doesn't require manually maintaining spells every expansion.
102 | 1. has less code and hopefully uses less CPU (probably not though).
103 | 1. has limited support for custom rules (only "show aura on ability").
104 | 1. doesn't show buffs/debuffs on abilities that have a different name unless manually configured.
105 | 1. limited support for customizing (timer appearance, location, show stacks or not).
106 | 1. doesn't show hints for using abilities, except for interrupt, purge and soothe.
107 | 1. doesn't show holy power/chi/combo points/soul shards.
108 |
109 | AdiButtonAuras seems to be maintained again, so if you want some extra features give it a look.
110 |
111 | ## Options Panel
112 |
113 | LiteButtonAuras has a configuration panel that you can open from the Blizzard settings or by using the `/lba opt` slash command.
114 |
115 | You can adjust the visual appearance of the ability overlay, as well as add and remove extra aura displays where the name doesn't match.
116 |
117 | 
118 |
119 | 
120 |
121 | 
122 |
123 | ## Slash Command Options
124 |
125 | You can also adjust the options via slash command.
126 |
127 | ### Appearance Options
128 |
129 | ```
130 | /lba - print current settings
131 | /lba help - print help
132 | /lba colortimers on | off | default - turn on/off using colors for timers (default on)
133 | /lba decimaltimers on | off | default - turn on/off showing 10ths of a second on low timers (default on)
134 | /lba stacks on | off | default - turn on/off showing buff/debuff stacks (default off)
135 | /lba font default - set font to default (NumberFontNormal)
136 | /lba font FontName - set font by name (e.g., GameFontNormalOutline)
137 | /lba font FontPath - set font by path (e.g., Fonts\ARIALN.TTF)
138 | /lba font Size - set font size (default 14)
139 | /lba font FontFlag - set font flag (OUTLINE or THICKOUTLINE)
140 | /lba font FontNameOrPath Size FontFlag - set font by name/path, size and flag
141 | ```
142 |
143 | ### Fonts
144 |
145 | If you are changing the font from the default, you will (almost certainly) want to use
146 | fonts with the __OUTLINE__ flag (shows a dark border around) for them to be visible.
147 |
148 | The default LBA font `NumberFontNormal` has an outline, but (for example)
149 | `GameFontNormal` doesn't and you'd need to use `GameFontNormalOutline`
150 | instead or explicitly set the __OUTLINE__ flag.
151 |
152 | Note that setting colored fonts will __not__ use the color, only the font, size,
153 | and flags. There is no difference in LBA between `NumberFontNormal` and `NumberFontNormalYellow`.
154 |
155 | ## Show Highlights for Other Auras
156 |
157 | By default LiteButtonAuras only shows highlights when the name of the buff/debuff:
158 | - matches the name of the button action; or
159 | - matches the name of the button action's base spell that was overridden; or
160 | - matches a hard-coded list of totems/guardians like monk statues.
161 |
162 | Using the `/lba aura` command you can add extra auras that will highlight your abilities (for
163 | example, to show a debuff on the ability that triggers it).
164 |
165 | ```
166 | /lba aura list - list current extra aura mappings
167 | /lba aura add on
168 | /lba aura remove on
169 | ```
170 |
171 | If an ability is in your spell book you can use it by name otherwise by spell ID.
172 |
173 | You can only add auras using this, or remove ones you previously added. You can't use "hide" to
174 | change the default behaviour of showing buffs/debuffs that match the ability name.
175 |
176 | ### Never Highlight An Ability
177 |
178 | You can stop an ability from ever getting highlighted due to the default name matching.
179 |
180 | ```
181 | /lba ignore list - list abilities never to highlight
182 | /lba ignore add
183 | /lba ignore remove
184 | ```
185 |
186 | If ability is in your spell book you can use it by name otherwise spell ID.
187 |
188 | ## How to find spell IDs
189 |
190 | Every ability and every buff/debuff has an associated Spell ID, which you need to know to
191 | configure custom highlights (above).
192 |
193 | LiteButtonAuras doesn't include any helpers for finding spell IDs, you'll need to do it
194 | yourself. Here are three ways to do this:
195 |
196 | 1. Look up wowhead.com. The spell ID is the number after spell= in the URL.
197 | 1. Get an addon that adds Spell IDs to the tooltip.
198 | 1. If you have the _Details!_ addon, it keeps a list of spells you can view with `/details spells`
199 |
200 | ## Features I can't or won't support, and why
201 |
202 | 1. __Non-Auras__. E.g. channeling time, combo/chi/holy power/etc points. A lot of these
203 | could be done, but LBA's focus is on auras only and I personally feel those are better
204 | done in other ways or by other addons.
205 |
206 | In general a lot of not supporting things involves keeping LiteButtonAuras small and
207 | simple enough that when a major WoW release comes out I can update it without causing
208 | myself so much stress I give up.
209 |
210 | ## If This AddOn Seems Abandoned
211 |
212 | If more than two weeks go by after a major patch and this addon isn't updated, I've probably been
213 | hit by a bus. In that case I encourage anyone with the necessary ability to take over maintenance of
214 | the addon. It is released under the terms of the GNU General Public License, which means anyone can
215 | take it and do whatever they want with it, as long as they don't claim they wrote it and they too
216 | release their code under the same terms.
217 |
--------------------------------------------------------------------------------
/SlashCommand.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | Slash command just allows setting and displaying the options since
7 | there is no GUI for it.
8 |
9 | ----------------------------------------------------------------------------]]--
10 |
11 | local addonName, LBA = ...
12 |
13 | local C_Spell = LBA.C_Spell or C_Spell
14 |
15 | local L = LBA.L
16 |
17 | local function TrueStr(x)
18 | return x and "on" or "off"
19 | end
20 |
21 | local header = ORANGE_FONT_COLOR:WrapTextInColorCode(addonName..': ')
22 |
23 | local function printf(...)
24 | local msg = string.format(...)
25 | SELECTED_CHAT_FRAME:AddMessage(header .. msg)
26 | end
27 |
28 | local function PrintUsage()
29 | printf(GAMEMENU_HELP .. ":")
30 | printf(" /lba options")
31 | printf(" /lba stack on|off|default")
32 | printf(" /lba stackposition point [offset]")
33 | printf(" /lba timer on|off|default")
34 | printf(" /lba colortimer on|off|default")
35 | printf(" /lba decimaltimer on|off|default")
36 | printf(" /lba timerposition point [offset]")
37 | printf(" /lba font FontName|default")
38 | printf(" /lba font path [ size [ flags ] ]")
39 | printf(" /lba glowalpha 0-1")
40 | printf(" /lba aura help")
41 | printf(" /lba ignore help")
42 | end
43 |
44 | local function PrintAuraUsage()
45 | printf(GAMEMENU_HELP .. ":")
46 | printf(" /lba aura list")
47 | printf(" /lba aura add on ")
48 | printf(" /lba aura remove on ")
49 | printf(" /lba aura wipe")
50 | end
51 |
52 | local function PrintIgnoreUsage()
53 | printf(GAMEMENU_HELP .. ":")
54 | printf(" /lba ignore list")
55 | printf(" /lba ignore add ")
57 | printf(" /lba ignore default")
58 | printf(" /lba ignore wipe")
59 | end
60 |
61 | local function PrintOptions()
62 | local p = LBA.db.profile
63 | printf(SETTINGS .. ':')
64 | printf(" stack = " .. TrueStr(p.showStacks))
65 | printf(" stackPosition = %s %d", p.stacksAnchor, p.stacksAdjust)
66 | printf(" timer = " .. TrueStr(p.showTimers))
67 | printf(" colorTimer = " .. TrueStr(p.colorTimers))
68 | printf(" decimalTimer = " .. TrueStr(p.decimalTimers))
69 | printf(" timerPosition = %s %d", p.timerAnchor, p.timerAdjust)
70 | printf(" font = [ '%s', %.1f, '%s' ]", p.fontPath, p.fontSize, p.fontFlags)
71 | end
72 |
73 | local function SetFont(args)
74 | local path, size, flags
75 | for _,arg in ipairs(args) do
76 | if arg == 'default' then
77 | path, size, flags = 'default', 'default', 'default'
78 | elseif _G[arg] and _G[arg].GetFont then
79 | path, size, flags = _G[arg]:GetFont()
80 | elseif tonumber(arg) then
81 | size = math.floor(tonumber(arg) + 0.5)
82 | elseif arg:find("\\") then
83 | path = arg
84 | else
85 | flags = arg
86 | end
87 | end
88 | if path then LBA.SetOptionOutsideUI('fontPath', path) end
89 | if size then LBA.SetOptionOutsideUI('fontSize', size) end
90 | if flags then LBA.SetOptionOutsideUI('fontFlags', flags) end
91 | end
92 |
93 | local function ParseAuraMap(cmdarg)
94 | local aura, ability = cmdarg:match('^(.+) on (.+)$')
95 | local auraInfo = C_Spell.GetSpellInfo(aura)
96 | local abilityInfo = C_Spell.GetSpellInfo(ability)
97 | return
98 | auraInfo and auraInfo.spellID,
99 | auraInfo and auraInfo.name or aura,
100 | abilityInfo and abilityInfo.spellID,
101 | abilityInfo and abilityInfo.name or ability
102 | end
103 |
104 | local function PrintAuraMapList()
105 | printf(L["Aura list"] .. ":")
106 | for i, entry in ipairs(LBA.GetAuraMapList()) do
107 | printf("%3d. %s", i, LBA.AuraMapString(unpack(entry)))
108 | end
109 | end
110 |
111 | local function AuraCommand(argstr)
112 | local _, cmd, cmdarg = strsplit(" ", argstr, 3)
113 | if cmd == 'list' then
114 | PrintAuraMapList()
115 | elseif cmd == 'add' and cmdarg then
116 | local aura, auraName, ability, abilityName = ParseAuraMap(cmdarg)
117 | if not aura then
118 | printf(L["Error: unknown aura spell: %s"], NORMAL_FONT_COLOR:WrapTextInColorCode(auraName))
119 | elseif not ability then
120 | printf(L["Error: unknown ability spell: %s"], NORMAL_FONT_COLOR:WrapTextInColorCode(abilityName))
121 | else
122 | printf(ADD.." %s", LBA.AuraMapString(aura, auraName, ability, abilityName))
123 | LBA.AddAuraMap(aura, ability)
124 | end
125 | elseif cmd == 'remove' and cmdarg then
126 | local aura, auraName, ability, abilityName = ParseAuraMap(cmdarg)
127 | if not aura then
128 | printf(L["Error: unknown aura spell: %s"], NORMAL_FONT_COLOR:WrapTextInColorCode(auraName))
129 | elseif not ability then
130 | printf(L["Error: unknown ability spell: %s"], NORMAL_FONT_COLOR:WrapTextInColorCode(abilityName))
131 | else
132 | printf(REMOVE.." %s", LBA.AuraMapString(aura, auraName, ability, abilityName))
133 | LBA.RemoveAuraMap(aura, ability)
134 | end
135 | elseif cmd == 'wipe' then
136 | printf(L["Wiping aura list."])
137 | LBA.WipeAuraMap()
138 | else
139 | PrintAuraUsage()
140 | end
141 |
142 | return true
143 | end
144 |
145 | local function PrintIgnoreList()
146 | local spells = { }
147 | for spellID in pairs(LBA.db.profile.ignoreSpells) do
148 | local spell = Spell:CreateFromSpellID(spellID)
149 | if not spell:IsSpellEmpty() then
150 | spell:ContinueOnSpellLoad(function () table.insert(spells, spell) end)
151 | end
152 | end
153 | table.sort(spells, function (a, b) return a:GetSpellName() < b:GetSpellName() end)
154 | printf(L["Ignored abilities"]..":")
155 | for i, spell in ipairs(spells) do
156 | printf("%3d. %s (%d)", i, spell:GetSpellName() or "?", spell:GetSpellID())
157 | end
158 | end
159 |
160 | local function IgnoreCommand(argstr)
161 | local _, cmd, spell = strsplit(" ", argstr, 3)
162 | if cmd == 'list' then
163 | PrintIgnoreList()
164 | elseif cmd == 'default' then
165 | LBA.DefaultIgnoreSpells()
166 | elseif cmd == 'wipe' then
167 | LBA.WipeIgnoreSpells()
168 | elseif cmd == 'add' and spell then
169 | local info = C_Spell.GetSpellInfo(spell)
170 | if info then
171 | LBA.SetIgnoreSpell(info.spellID, { ability = true })
172 | else
173 | printf(L["Error: unknown spell: %s"], spell)
174 | end
175 | elseif cmd == 'remove' and spell then
176 | local info = C_Spell.GetSpellInfo(spell)
177 | if info then
178 | LBA.RemoveIgnoreSpell(info.spellID)
179 | else
180 | printf(L["Error: unknown spell: %s"], spell)
181 | end
182 | else
183 | PrintIgnoreUsage()
184 | end
185 | return true
186 | end
187 |
188 | local function SlashCommand(argstr)
189 | local args = { strsplit(" ", argstr) }
190 | local cmd = table.remove(args, 1)
191 | local n = cmd:len()
192 |
193 | if cmd == '' then
194 | PrintOptions()
195 | elseif cmd == ('options'):sub(1,n) then
196 | LBA.OpenOptions()
197 | elseif cmd:lower() == 'stack' and #args == 1 then
198 | LBA.SetOptionOutsideUI('showStacks', args[1])
199 | elseif cmd:lower() == 'stackposition' and WithinRange(#args, 1, 2) then
200 | LBA.SetOptionOutsideUI('stacksAnchor', args[1])
201 | if args[2] then LBA.SetOptionOutsideUI('stacksAdjust', args[2]) end
202 | elseif cmd:lower() == 'timer' and #args == 1 then
203 | LBA.SetOptionOutsideUI('showTimers', args[1])
204 | elseif cmd:lower() == 'colortimer' and #args == 1 then
205 | LBA.SetOptionOutsideUI('colorTimers', args[1])
206 | elseif cmd:lower() == 'decimaltimer' and #args == 1 then
207 | LBA.SetOptionOutsideUI('decimalTimers', args[1])
208 | elseif cmd:lower() == 'font' and WithinRange(#args, 1, 3) then
209 | SetFont(args)
210 | elseif cmd:lower() == 'timerposition' and WithinRange(#args, 1, 2) then
211 | LBA.SetOptionOutsideUI('timerAnchor', args[1])
212 | if args[2] then LBA.SetOptionOutsideUI('timerAdjust', args[2]) end
213 | elseif cmd:lower() == 'glowalpha' and #args == 1 and WithinRange(tonumber(args[1]), 0, 1) then
214 | LBA.SetOptionOutsideUI('glowAlpha', args[1])
215 | elseif cmd:lower() == 'aura' then
216 | AuraCommand(argstr)
217 | elseif cmd:lower() == 'ignore' then
218 | IgnoreCommand(argstr)
219 | elseif cmd:lower() == 'style' then
220 | LiteButtonAurasController:StyleAllOverlays()
221 | elseif cmd:lower() == 'dump' then
222 | LiteButtonAurasController:DumpAllOverlays()
223 | else
224 | PrintUsage()
225 | end
226 | return true
227 | end
228 |
229 | function LBA.SetupSlashCommand()
230 | SlashCmdList['LiteButtonAuras'] = SlashCommand
231 | _G.SLASH_LiteButtonAuras1 = "/litebuttonauras"
232 | _G.SLASH_LiteButtonAuras1 = "/lba"
233 | end
234 |
--------------------------------------------------------------------------------
/Options.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | ----------------------------------------------------------------------------]]--
7 |
8 | local addonName, LBA = ...
9 |
10 | local L = LBA.L
11 |
12 | local C_Spell = LBA.C_Spell or C_Spell
13 |
14 | local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
15 |
16 | local fontPath, fontSize, fontFlags = NumberFontNormal:GetFont()
17 |
18 | local defaultAdjust = ( WOW_PROJECT_ID == 1 and 5 or 2 )
19 |
20 | local defaults = {
21 | global = {
22 | },
23 | profile = {
24 | defaultNameMatching = true,
25 | playerPetBuffs = true,
26 | ignoreSpells = {
27 | -- { ability = true, player = true, unit = true }
28 | [59638] = { unit = true }, -- Frostbolt (Mage Pet)
29 | [152175] = { ability = true }, -- Whirling Dragon Punch (Monk)
30 | [190356] = { ability = true }, -- Blizzard (Mage)
31 | [425782] = { ability = true }, -- Second Wind (Warrior passive / Skyriding)
32 | },
33 | auraMap = { },
34 | color = {
35 | buff = { r=0.00, g=0.70, b=0.00 },
36 | petBuff = { r=0.00, g=0.00, b=0.70 },
37 | debuff = { r=1.00, g=0.00, b=0.00 },
38 | enrage = { r=1.00, g=0.25, b=0.00 }, -- unused
39 | },
40 | glowTexture = [[Interface\Addons\LiteButtonAuras\Textures\Overlay]],
41 | glowUseMasque = true,
42 | glowAlpha = 0.5,
43 | minAuraDuration = 1.5,
44 | showTimers = true,
45 | showStacks = true,
46 | showSuggestions = true,
47 | colorTimers = true,
48 | decimalTimers = true,
49 | timerAnchor = "BOTTOMLEFT",
50 | timerAdjust = defaultAdjust,
51 | stacksAnchor = "TOPLEFT",
52 | stacksAdjust = defaultAdjust,
53 | fontPath = fontPath,
54 | fontSize = math.floor(fontSize + 0.5),
55 | fontFlags = fontFlags,
56 | },
57 | char = {
58 | },
59 | }
60 |
61 | LBA.anchorSettings = {
62 | TOPLEFT = { "TOPLEFT", 1, -1, "LEFT" },
63 | TOP = { "TOP", 0, -1, "CENTER" },
64 | TOPRIGHT = { "TOPRIGHT", -1, -1, "RIGHT" },
65 | LEFT = { "LEFT", 1, 0, "LEFT", },
66 | CENTER = { "CENTER", 0, 0, "CENTER" },
67 | RIGHT = { "RIGHT", -1, 0, "RIGHT" },
68 | BOTTOMLEFT = { "BOTTOMLEFT", 1, 1, "LEFT" },
69 | BOTTOM = { "BOTTOM", 0, 1, "CENTER" },
70 | BOTTOMRIGHT = { "BOTTOMRIGHT", -1, 1, "RIGHT" },
71 | }
72 |
73 | local function IsTrue(x)
74 | if x == nil or x == false or x == "0" or x == "off" or x == "false" then
75 | return false
76 | else
77 | return true
78 | end
79 | end
80 |
81 | local function MigrateOptions(sv)
82 | if sv == nil then return end
83 |
84 | for n,p in pairs(sv.profiles) do
85 | if p.font then
86 | if type(p.font) == 'string' then
87 | if _G[p.font] and _G[p.font].GetFont then
88 | p.fontPath, p.fontSize, p.fontFlags = _G[p.font]:GetFont()
89 | p.fontSize = math.floor(p.fontSize + 0.5)
90 | end
91 | elseif type(p.font) == 'table' then
92 | p.fontPath, p.fontSize, p.fontFlags = unpack(p.font)
93 | p.fontSize = math.floor(p.fontSize + 0.5)
94 | end
95 | p.font = nil
96 | end
97 | if p.denySpells then
98 | p.ignoreSpells = p.ignoreSpells or {}
99 | for spellID in pairs(p.denySpells) do
100 | p.ignoreSpells[spellID] = { ability = true }
101 | end
102 | p.denySpells = nil
103 | end
104 | end
105 | end
106 |
107 | function LBA.InitializeOptions()
108 | MigrateOptions(LiteButtonAurasDB)
109 | LBA.db = LibStub("AceDB-3.0"):New("LiteButtonAurasDB", defaults, true)
110 | -- Profile change hooks, would be needed to change profiles outside gui
111 | --[[
112 | local function notify () AceConfigRegistry:NotifyChange(addonName) end
113 | LBA.db.RegisterCallback(LBA, "OnProfileChanged", notify)
114 | LBA.db.RegisterCallback(LBA, "OnProfileCopied", notify)
115 | LBA.db.RegisterCallback(LBA, "OnProfileReset", notify
116 | ]]
117 | end
118 |
119 | function LBA.SetOption(option, value, key)
120 | key = key or "profile"
121 | if not defaults[key] then return end
122 | if value == "default" or value == DEFAULT:lower() or value == nil then
123 | value = defaults[key][option]
124 | end
125 | if type(defaults[key][option]) == 'boolean' then
126 | LBA.db[key][option] = IsTrue(value)
127 | elseif type(defaults[key][option]) == 'number' then
128 | if tonumber(value) then
129 | LBA.db[key][option] = tonumber(value)
130 | end
131 | elseif LBA.anchorSettings[defaults[key][option]] then
132 | if LBA.anchorSettings[value] then
133 | LBA.db[key][option] = value
134 | end
135 | else
136 | LBA.db[key][option] = value
137 | end
138 | LBA.db.callbacks:Fire('OnModified')
139 | end
140 |
141 | function LBA.SetOptionOutsideUI(option, value, key)
142 | LBA.SetOption(option, value, key)
143 | AceConfigRegistry:NotifyChange(addonName)
144 | end
145 |
146 | function LBA.AddAuraMap(auraSpell, abilitySpell)
147 | auraSpell = tonumber(auraSpell) or auraSpell
148 | abilitySpell = tonumber(abilitySpell) or abilitySpell
149 |
150 | if LBA.db.profile.auraMap[auraSpell] then
151 | table.insert(LBA.db.profile.auraMap[auraSpell], abilitySpell)
152 | else
153 | LBA.db.profile.auraMap[auraSpell] = { abilitySpell }
154 | end
155 | LBA.UpdateAuraMap()
156 | AceConfigRegistry:NotifyChange(addonName)
157 | end
158 |
159 | function LBA.RemoveAuraMap(auraSpell, abilitySpell)
160 | auraSpell = tonumber(auraSpell) or auraSpell
161 | abilitySpell = tonumber(abilitySpell) or abilitySpell
162 | if not LBA.db.profile.auraMap[auraSpell] then return end
163 |
164 | tDeleteItem(LBA.db.profile.auraMap[auraSpell], abilitySpell)
165 |
166 | if next(LBA.db.profile.auraMap[auraSpell]) == nil then
167 | if not defaults.profile.auraMap[auraSpell] then
168 | LBA.db.profile.auraMap[auraSpell] = nil
169 | else
170 | LBA.db.profile.auraMap[auraSpell] = { false }
171 | end
172 | end
173 | LBA.UpdateAuraMap()
174 | AceConfigRegistry:NotifyChange(addonName)
175 | end
176 |
177 | function LBA.DefaultAuraMap()
178 | LBA.db.profile.auraMap = CopyTable(defaults.profile.auraMap)
179 | LBA.UpdateAuraMap()
180 | AceConfigRegistry:NotifyChange(addonName)
181 | end
182 |
183 | function LBA.WipeAuraMap()
184 | LBA.db.profile.auraMap = {}
185 | LBA.UpdateAuraMap()
186 | AceConfigRegistry:NotifyChange(addonName)
187 | end
188 |
189 | function LBA.SetIgnoreSpell(spellID, data)
190 | LBA.db.profile.ignoreSpells[spellID] = data
191 | AceConfigRegistry:NotifyChange(addonName)
192 | end
193 |
194 | function LBA.RemoveIgnoreSpell(spellID)
195 | LBA.db.profile.ignoreSpells[spellID] = nil
196 | AceConfigRegistry:NotifyChange(addonName)
197 | end
198 |
199 | function LBA.DefaultIgnoreSpells()
200 | LBA.db.profile.ignoreSpells = CopyTable(defaults.profile.ignoreSpells)
201 | AceConfigRegistry:NotifyChange(addonName)
202 | end
203 |
204 | function LBA.WipeIgnoreSpells()
205 | table.wipe(LBA.db.profile.ignoreSpells)
206 | AceConfigRegistry:NotifyChange(addonName)
207 | end
208 |
209 | function LBA.SpellString(spellID, spellName)
210 | spellName = NORMAL_FONT_COLOR:WrapTextInColorCode(spellName)
211 | if spellID then
212 | return format("%s (%d)", spellName, spellID)
213 | else
214 | return spellName
215 | end
216 | end
217 |
218 | function LBA.AuraMapString(auraID, auraName, abilityID, abilityName)
219 | return format(
220 | "%s %s %s",
221 | LBA.SpellString(auraID, auraName),
222 | L["on"],
223 | LBA.SpellString(abilityID, abilityName)
224 | )
225 | end
226 |
227 | function LBA.GetAuraMapList()
228 | local out = { }
229 | for showAura, onAbilityTable in pairs(LBA.db.profile.auraMap) do
230 | for _, onAbility in ipairs(onAbilityTable) do
231 | local auraName, auraID, abilityName, abilityID
232 | if type(showAura) == 'number' then
233 | local info = C_Spell.GetSpellInfo(showAura)
234 | if info then
235 | auraName = info.name
236 | auraID = info.spellID
237 | end
238 | else
239 | auraName = showAura
240 | end
241 | if type(onAbility) == 'number' then
242 | local info = C_Spell.GetSpellInfo(onAbility)
243 | if info then
244 | abilityName = info.name
245 | abilityID = info.spellID
246 | end
247 | else
248 | abilityName = onAbility
249 | end
250 | if auraName and abilityName then
251 | table.insert(out, { auraID, auraName, abilityID, abilityName })
252 | end
253 | end
254 | end
255 | sort(out, function (a, b) return a[2]..a[4] < b[2]..b[4] end)
256 | return out
257 | end
258 |
259 | function LBA.ApplyDefaultSettings()
260 | LBA.db:ResetProfile()
261 | AceConfigRegistry:NotifyChange(addonName)
262 | end
263 |
--------------------------------------------------------------------------------
/UnitState.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | State recording class.
7 |
8 | ----------------------------------------------------------------------------]]--
9 |
10 | local addonName, LBA = ...
11 |
12 | local C_Spell = LBA.C_Spell or C_Spell
13 |
14 | local L = LBA.L
15 |
16 | LBA.state = {}
17 |
18 |
19 | --[[------------------------------------------------------------------------]]--
20 |
21 | -- Cache some things to be faster. This is annoying but it's really a lot
22 | -- faster. Only do this for things that are called in the event loop otherwise
23 | -- it's just a pain to maintain.
24 |
25 | local AuraUtil = LBA.AuraUtil or AuraUtil
26 | local GetTotemInfo = GetTotemInfo
27 | local MAX_TOTEMS = MAX_TOTEMS
28 | local UnitCanAttack = UnitCanAttack
29 | local UnitCastingInfo = UnitCastingInfo
30 | local UnitChannelInfo = UnitChannelInfo
31 | local WOW_PROJECT_ID = WOW_PROJECT_ID
32 |
33 |
34 | --[[------------------------------------------------------------------------]]--
35 |
36 | -- State updating functions
37 |
38 | -- This could be made (probably) more efficient by using the 10.0 event
39 | -- argument auraUpdateInfo at the price of losing classic compatibility.
40 | --
41 | -- "Probably" because once you do that you have to do your own "filtering"
42 | -- duplicating the 'HELPFUL PLAYER' etc. and iterate over a bunch of auras
43 | -- that aren't relevant here. It depends on how efficient the filter in
44 | -- UnitAuraSlots is (and by extension AuraUtil.ForEachAura). Would also have
45 | -- to either index them by auraInstanceID + scan for name in overlay, or
46 | -- keep indexing them by name and scan for auraInstanceID when updating.
47 |
48 | -- There's no point guessing at what would be better performance, if you're
49 | -- going to try to improve then measure it. Potentials for performance
50 | -- improvement (but measure!):
51 | --
52 | -- * limit the aura scans by using a dirty/sweep
53 | -- * use the UNIT_AURA push data (as above)
54 | --
55 | -- Overall the 10.0 changes are not that helpful for matching by name.
56 | --
57 | -- It's worth noting that the 10.0 BuffFrame still uses the same mechanism
58 | -- as used here, but both the CompactUnitFrame and the TargetFrame have
59 | -- switched to using the new ways.
60 | --
61 | -- {
62 | -- applications = 0,
63 | -- auraInstanceID = 154047,
64 | -- canApplyAura = true,
65 | -- duration = 3600,
66 | -- expirationTime = 9109.109,
67 | -- icon = 136051,
68 | -- isBossAura = false,
69 | -- isFromPlayerOrPlayerPet = true,
70 | -- isHarmful = false,
71 | -- isHelpful = true,
72 | -- isNameplateOnly = false,
73 | -- isRaid = false,
74 | -- isStealable = false
75 | -- name = "Lightning Shield",
76 | -- nameplateShowAll = false,
77 | -- nameplateShowPersonal = false,
78 | -- points = { },
79 | -- sourceUnit = "player",
80 | -- spellId = 192106,
81 | -- timeMod = 1,
82 | -- }
83 | --
84 | -- https://warcraft.wiki.gg/wiki/API_C_UnitAuras.GetAuraDataBySlot
85 |
86 | -- Fake AuraData for weapon enchants, see BuffFrame.lua for how WoW does it
87 | local function WeaponEnchantAuraData(duration, charges, id)
88 | local name = LBA.WeaponEnchantSpellID[id]
89 | if name then
90 | return {
91 | isTempEnchant = true,
92 | auraType = "TempEnchant",
93 | applications = charges,
94 | duration = 0,
95 | expirationTime = GetTime() + duration/1000,
96 | name = name,
97 | }
98 | end
99 | end
100 |
101 | --[[------------------------------------------------------------------------]]--
102 |
103 | LBA.UnitState = {}
104 |
105 | function LBA.UnitState:Create(unit)
106 | local unitState = {
107 | unit = unit,
108 | buffs = {},
109 | debuffs = {},
110 | weaponEnchants = {},
111 | totems = {},
112 | channel = nil,
113 | taunt = nil,
114 | }
115 | setmetatable(unitState, { __index=self })
116 | return unitState
117 | end
118 |
119 | -- There is only "player" (which includes pet) and "not player"
120 |
121 | function LBA.UnitState:IsIgnoredAura(auraData)
122 | local ignoreData = LBA.db.profile.ignoreSpells[auraData.spellId]
123 | if ignoreData then
124 | if self.unit == 'player' or self.unit == 'pet' then
125 | return ignoreData.player == true
126 | else
127 | return ignoreData.unit == true
128 | end
129 | end
130 | return false
131 | end
132 |
133 | -- Also add a duplicate with any override name. This is awkward but there's no
134 | -- inverse of C_Spell.GetOverrideSpell.
135 | --
136 | -- C_Spell.GetOverrideSpell returns the same ID if passed in an ID that's not
137 | -- overridden (seems like no check is done if it's a valid spell or not).
138 | --
139 | -- It will return 0 if given a string that doesn't match to an ID (and not nil
140 | -- like all the other C_Spell.GetX functions).
141 | --
142 | -- We call it with auraData.name because some of our faked up auraData (like
143 | -- for weapon enchants) doesn't have a spellId in it.
144 |
145 | function LBA.UnitState:UpdateTableAura(t, auraData)
146 | if self:IsIgnoredAura(auraData) then
147 | return
148 | end
149 | t[auraData.name] = auraData
150 | if C_Spell.GetOverrideSpell then
151 | local overrideID = C_Spell.GetOverrideSpell(auraData.name)
152 | local overrideName = C_Spell.GetSpellName(overrideID)
153 | if overrideName and overrideName ~= auraData.name then
154 | -- Doesn't update the spell name in the auraData only the index name
155 | t[overrideName] = auraData
156 | end
157 | end
158 | end
159 |
160 | function LBA.UnitState:UpdateAuras(auraInfo)
161 |
162 | -- XXX TODO handle auraInfo for efficiency
163 |
164 | self.buffs = {}
165 | self.debuffs = {}
166 | self.taunt = nil
167 |
168 | if UnitCanAttack('player', self.unit) then
169 | -- Hostile target buffs are only for dispels
170 | AuraUtil.ForEachAura(self.unit, 'HELPFUL', nil,
171 | function (auraData)
172 | self:UpdateTableAura(self.buffs, auraData)
173 | end,
174 | true)
175 | AuraUtil.ForEachAura(self.unit, 'HARMFUL PLAYER', nil,
176 | function (auraData)
177 | self:UpdateTableAura(self.debuffs, auraData)
178 | end,
179 | true)
180 | AuraUtil.ForEachAura(self.unit, 'HARMFUL', nil,
181 | function (auraData)
182 | if LBA.Taunts[auraData.spellId] and auraData.expirationTime then
183 | if not self.taunt or auraData.expirationTime > self.taunt.expirationTime then
184 | self.taunt = auraData
185 | end
186 | end
187 | end,
188 | true)
189 | else
190 | AuraUtil.ForEachAura(self.unit, 'HELPFUL', nil,
191 | function (auraData)
192 | if auraData.isFromPlayerOrPlayerPet then
193 | self:UpdateTableAura(self.buffs, auraData)
194 | end
195 | end,
196 | true)
197 | -- Inclue long-lasting buffs we can cast even if applied
198 | -- by someone else, since we don't care who cast Battle Shout, etc.
199 | AuraUtil.ForEachAura(self.unit, 'HELPFUL RAID', nil,
200 | function (auraData)
201 | if auraData.duration >= 10*60 then
202 | self:UpdateTableAura(self.buffs, auraData)
203 | end
204 | end,
205 | true)
206 | end
207 | end
208 |
209 | function LBA.UnitState:UpdateWeaponEnchants()
210 | -- Classic doesn't have the events to do this efficiently
211 | if WOW_PROJECT_ID ~= 1 then return end
212 |
213 | if self.unit == 'player' then
214 | self.weaponEnchants = {}
215 |
216 | local mhEnchant, mhDuration, mhCharges, mhID,
217 | ohEnchant, ohDuration, ohCharges, ohID = GetWeaponEnchantInfo()
218 |
219 | if mhEnchant then
220 | local auraData = WeaponEnchantAuraData(mhDuration, mhCharges, mhID)
221 | if auraData then
222 | self:UpdateTableAura(self.weaponEnchants, auraData)
223 | end
224 | end
225 | if ohEnchant then
226 | local auraData = WeaponEnchantAuraData(ohDuration, ohCharges, ohID)
227 | if auraData then
228 | self:UpdateTableAura(self.weaponEnchants, auraData)
229 | end
230 | end
231 | end
232 | end
233 |
234 | function LBA.UnitState:UpdateChannel()
235 | self.channel = UnitChannelInfo(self.unit)
236 | end
237 |
238 | function LBA.UnitState:UpdateTotems()
239 | if self.unit == 'player' then
240 | self.totems = {}
241 | for i = 1, MAX_TOTEMS do
242 | local exists, name, startTime, duration, model = GetTotemInfo(i)
243 | if exists and name then
244 | if model then
245 | name = LBA.TotemOrGuardianModels[model] or name
246 | end
247 | self.totems[name] = startTime + duration
248 | end
249 | end
250 | end
251 | end
252 |
253 | function LBA.UnitState:UpdateInterrupt()
254 | local name, endTime, cantInterrupt, _
255 |
256 | if UnitCanAttack('player', self.unit) then
257 | name, _, _, _, endTime, _, _, cantInterrupt = UnitCastingInfo(self.unit)
258 | if name and not cantInterrupt then
259 | self.interrupt = endTime / 1000
260 | return
261 | end
262 |
263 | name, _, _, _, endTime, _, cantInterrupt = UnitChannelInfo(self.unit)
264 | if name and not cantInterrupt then
265 | self.interrupt = endTime / 1000
266 | return
267 | end
268 | end
269 |
270 | self.interrupt = nil
271 | end
272 |
273 | -- Overlay is reading the states directly but we could add some accessors
274 | -- here and/or move some of the matching logic here as well.
275 |
276 |
--------------------------------------------------------------------------------
/BarIntegrations.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | Create overlays for actionbuttons and hook update when they change. Note
7 | that hooksecurefunc() is kinda slow and should be avoided in cases where
8 | the actionbutton provides its own hook.
9 |
10 | ----------------------------------------------------------------------------]]--
11 |
12 | local _, LBA = ...
13 |
14 | LBA.BarIntegrations = {}
15 |
16 | local C_Item = LBA.C_Item or C_Item
17 | local C_Spell = LBA.C_Spell or C_Spell
18 |
19 | local GetActionInfo = GetActionInfo
20 | local HasAction = HasAction
21 |
22 | -- Generic ---------------------------------------------------------------------
23 |
24 | local function GenericGetActionID(overlay)
25 | return overlay:GetParent().action
26 | end
27 |
28 | local function GenericGetActionInfo(overlay)
29 | return GetActionInfo(overlay:GetParent().action)
30 | end
31 |
32 | local function GenericHasAction(overlay)
33 | return HasAction(overlay:GetParent().action)
34 | end
35 |
36 | local function GenericInitButton(actionButton)
37 | local overlay = LiteButtonAurasController:CreateOverlay(actionButton)
38 | overlay.GetActionID = GenericGetActionID
39 | overlay.GetActionInfo = GenericGetActionInfo
40 | overlay.HasAction = GenericHasAction
41 |
42 | if not overlay.isHooked then
43 | hooksecurefunc(actionButton, 'Update', function () overlay:Update() end)
44 | overlay.isHooked = true
45 | end
46 | end
47 |
48 | -- Blizzard Classic ------------------------------------------------------------
49 |
50 | -- Classic doesn't have an 'Update' method on the ActionButtons to hook
51 | -- so we have to hook the global function ActionButton_Update
52 |
53 | local function ClassicButtonUpdate(actionButton)
54 | local overlay = LiteButtonAurasController:GetOverlay(actionButton)
55 | if overlay then overlay:Update() end
56 | end
57 |
58 | local function ClassicInitButton(actionButton)
59 | local overlay = LiteButtonAurasController:CreateOverlay(actionButton)
60 | overlay.GetActionID = GenericGetActionID
61 | overlay.GetActionInfo = GenericGetActionInfo
62 | overlay.HasAction = GenericHasAction
63 | end
64 |
65 | function LBA.BarIntegrations:ClassicInit()
66 | if WOW_PROJECT_ID == 1 then return end
67 | for _, actionButton in pairs(ActionBarButtonEventsFrame.frames) do
68 | if actionButton:GetName():sub(1,8) ~= 'Override' then
69 | ClassicInitButton(actionButton)
70 | end
71 | end
72 | hooksecurefunc('ActionButton_Update', ClassicButtonUpdate)
73 | end
74 |
75 | -- Blizzard Retail -------------------------------------------------------------
76 |
77 | -- The OverrideActionButtons have the same action (ID) as the main buttons and
78 | -- we don't want to handle them.
79 |
80 | function LBA.BarIntegrations:RetailInit()
81 | if WOW_PROJECT_ID ~= 1 then return end
82 | for _, actionButton in pairs(ActionBarButtonEventsFrame.frames) do
83 | if actionButton:GetName():sub(1,8) ~= 'Override' then
84 | GenericInitButton(actionButton)
85 | end
86 | end
87 | end
88 |
89 |
90 | -- Button Forge ----------------------------------------------------------------
91 |
92 | -- These are ActionButton but they don't use the action ID they are set up as per
93 | -- SecureActionButtonTemplate with SetAttribute("type", ...) etc.
94 | --
95 | -- The hook here on widget.icon.SetTexture is not exactly kosher but it does work.
96 | -- Hoping the author will add a BUTTON_UPDATE calback hook or similar.
97 |
98 | -- Localize for Minor speedup
99 | local ButtonForge_API1
100 |
101 | local function ButtonForgeGetActionID(overlay)
102 | return 0
103 | end
104 |
105 | -- Note that this returns the old-style Blizzard GetActionInfo where macro
106 | -- never returns a subType and id is always the macro ID. So it doesn't have the
107 | -- bugs that the new style does with item macros.
108 | -- See LiteButtonAurasOverlayMixin:SetUpAction() where type == "macro"
109 |
110 | local function ButtonForgeGetActionInfo(overlay)
111 | local widget = overlay:GetParent()
112 | return ButtonForge_API1.GetButtonActionInfo(widget:GetName())
113 | end
114 |
115 | -- The buttons are re-used, but it's ok because CreateOverlay checks for that
116 |
117 | local function ButtonForgeInitButton(widget)
118 | local overlay = LiteButtonAurasController:CreateOverlay(widget)
119 | overlay.GetActionID = ButtonForgeGetActionID
120 | overlay.GetActionInfo = ButtonForgeGetActionInfo
121 | overlay.HasAction = ButtonForgeGetActionInfo
122 | hooksecurefunc(widget.icon, 'SetTexture', function () overlay:Update() end)
123 | end
124 |
125 | local function ButtonForgeCallback(_, event, actionButtonName)
126 | if event == "BUTTON_ALLOCATED" then
127 | local widget = _G[actionButtonName]
128 | ButtonForgeInitButton(widget)
129 | --[[
130 | -- This would be nicer than hooking .icon.SetTexture if it got implemented.
131 | elseif event == "BUTTON_UPDATED" then
132 | local widget = _G[actionButtonName]
133 | local overlay = LiteButtonAurasController:GetOverlay(widget)
134 | if overlay then overlay:Update() end
135 | ]]
136 | end
137 | end
138 |
139 | function LBA.BarIntegrations:ButtonForgeInit()
140 | ButtonForge_API1 = _G.ButtonForge_API1
141 | if ButtonForge_API1 then
142 | ButtonForge_API1.RegisterCallback(ButtonForgeCallback)
143 | end
144 | end
145 |
146 |
147 | -- Dominos ---------------------------------------------------------------------
148 |
149 | -- On classic Dominos re-uses the Blizzard action buttons and then adds some
150 | -- more of its own. On retail it uses all its own buttons, but they still use
151 | -- the ActionBarButton API enough for us.
152 |
153 | function LBA.BarIntegrations:DominosInit()
154 | local Init = WOW_PROJECT_ID == 1 and GenericInitButton or ClassicInitButton
155 | if Dominos and not Dominos.BlizzardActionButtons then
156 | -- "New" dominos with their own buttons
157 | for actionButton in pairs(Dominos.ActionButtons.buttons) do
158 | Init(actionButton)
159 | end
160 | hooksecurefunc(Dominos.ActionButton, 'OnCreate',
161 | function (button, id) Init(button) end)
162 | end
163 | end
164 |
165 |
166 | -- ActionBarPlus ---------------------------------------------------------------
167 |
168 | -- All SecureActionButton without any actionID
169 |
170 | -- I'm not 100% convinced about the wisdom of supporting this. The addon is
171 | -- overengineered and still doesn't support basic things like putting a pet
172 | -- action on a button. The code is inscrutable to me and looks like the kind
173 | -- of thing you get when you believe boolean should be a class and have a
174 | -- BooleanFactory to create one. But this does seem to work.
175 |
176 | local function ABPGetActionID(overlay)
177 | return 0
178 | end
179 |
180 | local function ABPGetActionInfo(overlay)
181 | local button = overlay:GetParent()
182 | local type = button:GetAttribute("type")
183 | if type == 'spell' then
184 | local spell = button:GetAttribute('spell')
185 | local info = C_Spell.GetSpellInfo(spell)
186 | if info then return type, info.spellID end
187 | elseif type == 'macro' then
188 | local id = button:GetAttribute('macro')
189 | if id then return type, id end
190 | elseif type == 'item' then
191 | local item = button:GetAttribute('item')
192 | local id = C_Item.GetItemInfoInstant(item)
193 | if id then return type, id end
194 | end
195 | end
196 |
197 | local function ABPHasAction(overlay)
198 | local button = overlay:GetParent()
199 | return not button.widget:IsEmpty()
200 | end
201 |
202 | local function ABPInitButton(actionButton)
203 | local overlay = LiteButtonAurasController:CreateOverlay(actionButton)
204 | overlay:SetFrameLevel(actionButton.widget.cooldown():GetFrameLevel() + 1)
205 |
206 | overlay.GetActionID = ABPGetActionID
207 | overlay.GetActionInfo = ABPGetActionInfo
208 | overlay.HasAction = ABPHasAction
209 |
210 | if not overlay.isHooked then
211 | actionButton:HookScript('OnAttributeChanged', function () overlay:Update() end)
212 | hooksecurefunc(actionButton.widget, 'UpdateMacroState', function () overlay:Update() end)
213 | overlay.isHooked = true
214 | end
215 | end
216 |
217 | local function ABPInitFrameWidget(actionBar)
218 | for _, actionButton in ipairs(actionBar.buttonFrames) do
219 | ABPInitButton(actionButton)
220 | end
221 | end
222 |
223 | function LBA.BarIntegrations:ActionbarPlusInit()
224 | if ABP_NS then
225 | for _, actionBar in ipairs(ABP_NS.O.ButtonFactory.FRAMES) do
226 | ABPInitFrameWidget(actionBar)
227 | end
228 | hooksecurefunc(ABP_NS.O.ButtonFactory, 'CreateButtons',
229 | function (self, fw, rowSize, colSize)
230 | ABPInitFrameWidget(fw)
231 | end)
232 | end
233 | end
234 |
235 |
236 | -- LibActionButton-1.0 and derivatives -----------------------------------------
237 |
238 | -- Covers ElvUI, Bartender. TukUI reuses the Blizzard buttons
239 |
240 | local function LABGetActionID(overlay)
241 | local actionType, action = overlay:GetParent():GetAction()
242 | if actionType == "action" then
243 | return action
244 | end
245 | end
246 |
247 | local function LABGetActionInfo(overlay)
248 | local actionType, action = overlay:GetParent():GetAction()
249 | if actionType == "action" then
250 | return GetActionInfo(action)
251 | else
252 | return actionType, action
253 | end
254 | end
255 |
256 | local function LABHasAction(overlay)
257 | local actionType, action = overlay:GetParent():GetAction()
258 | if actionType == "action" then
259 | return HasAction(action)
260 | end
261 | end
262 |
263 | local function LABInitButton(event, actionButton)
264 | local overlay = LiteButtonAurasController:CreateOverlay(actionButton)
265 | overlay.GetActionID = LABGetActionID
266 | overlay.GetActionInfo = LABGetActionInfo
267 | overlay.HasAction = LABHasAction
268 | -- Only call for dynamically created buttons, at Initialize() time the
269 | -- UnitState hasn't be set up yet and will error due to missing units.
270 | if event ~= nil then overlay:Update() end
271 | end
272 |
273 | -- LAB doesn't fire OnButtonCreated until the end of CreateButton but
274 | -- fires OnButtonUpdate in the middle, so we get Update before Create,
275 | -- hence the "if".
276 |
277 | local function LABButtonUpdate(event, actionButton)
278 | local overlay = LiteButtonAurasController:GetOverlay(actionButton)
279 | if overlay then overlay:Update() end
280 | end
281 |
282 | -- As far as I can tell there aren't any buttons at load time but just
283 | -- in case.
284 |
285 | local function LABInitAllButtons(lib)
286 | for actionButton in pairs(lib:GetAllButtons()) do
287 | LABInitButton(nil, actionButton)
288 | end
289 | end
290 |
291 | -- The %- here is a literal - instead of "zero or more repetitions". A
292 | -- few addons (most noteably ElvUI) use their own private version of
293 | -- LibActionButton with a suffix added to the name.
294 |
295 | function LBA.BarIntegrations:LABInit()
296 | for name, lib in LibStub:IterateLibraries() do
297 | if name:match('^LibActionButton%-1.0') then
298 | LABInitAllButtons(lib)
299 | lib.RegisterCallback(self, 'OnButtonCreated', LABInitButton)
300 | lib.RegisterCallback(self, 'OnButtonUpdate', LABButtonUpdate)
301 | end
302 | end
303 | end
304 |
305 | -- Init ------------------------------------------------------------------------
306 |
307 | function LBA.BarIntegrations:Initialize()
308 | self:RetailInit()
309 | self:ClassicInit()
310 | self:DominosInit()
311 | self:ButtonForgeInit()
312 | self:LABInit()
313 | self:ActionbarPlusInit()
314 | end
315 |
--------------------------------------------------------------------------------
/Controller.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | This is the event handler and state updater. Watches for the buffs and
7 | updates LBA.state, then calls overlay:Update() on all actionbutton overlays
8 | when required.
9 |
10 | ----------------------------------------------------------------------------]]--
11 |
12 | local addonName, LBA = ...
13 |
14 | local C_Spell = LBA.C_Spell or C_Spell
15 |
16 | local L = LBA.L
17 |
18 | local AlwaysTrackedUnits = {
19 | focus = true,
20 | mouseover = true,
21 | pet = true,
22 | player = true,
23 | target = true,
24 | }
25 |
26 | LBA.state = {}
27 |
28 |
29 | --[[------------------------------------------------------------------------]]--
30 |
31 | -- Cache some things to be faster. This is annoying but it's really a lot
32 | -- faster. Only do this for things that are called in the event loop otherwise
33 | -- it's just a pain to maintain.
34 |
35 | local UnitIsUnit = UnitIsUnit
36 | local WOW_PROJECT_ID = WOW_PROJECT_ID
37 |
38 | --[[------------------------------------------------------------------------]]--
39 |
40 | -- Load and set up dependencies for Masque support. Because we make our own
41 | -- frame and don't touch the ActionButton itself (avoids a LOT of taint issues)
42 | -- we have to make our own masque group. It's a bit weird because it lets you
43 | -- style LBA differently from the ActionButton, but it's the simplest way.
44 |
45 | -- local Masque = LibStub('Masque', true)
46 |
47 |
48 | --[[------------------------------------------------------------------------]]--
49 |
50 | LiteButtonAurasControllerMixin = {}
51 |
52 | function LiteButtonAurasControllerMixin:OnLoad()
53 | self.overlayFrames = {}
54 | self:RegisterEvent('PLAYER_LOGIN')
55 | end
56 |
57 | function LiteButtonAurasControllerMixin:Initialize()
58 |
59 | LBA.InitializeOptions()
60 | LBA.InitializeGUIOptions()
61 | LBA.SetupSlashCommand()
62 | LBA.UpdateAuraMap()
63 |
64 | LBA.BarIntegrations:Initialize()
65 | self:UpdateTrackedUnitList()
66 |
67 | self:RegisterEvent('PLAYER_ENTERING_WORLD')
68 | self:RegisterEvent('UNIT_AURA')
69 | self:RegisterEvent('PLAYER_TOTEM_UPDATE')
70 | if WOW_PROJECT_ID == 1 then
71 | self:RegisterEvent('WEAPON_ENCHANT_CHANGED')
72 | self:RegisterEvent('WEAPON_SLOT_CHANGED')
73 | end
74 |
75 | -- These are for noticing that the unit changed
76 | self:RegisterEvent('INSTANCE_ENCOUNTER_ENGAGE_UNIT') -- @bossN
77 | self:RegisterEvent('ARENA_OPPONENT_UPDATE') -- @arenaN
78 | self:RegisterEvent('GROUP_ROSTER_UPDATE') -- @partyN
79 | self:RegisterEvent('PLAYER_TARGET_CHANGED') -- @target
80 | self:RegisterEvent('PLAYER_FOCUS_CHANGED') -- @focus
81 | self:RegisterEvent('UPDATE_MOUSEOVER_UNIT') -- @mouseover
82 |
83 | -- All of these are for the interrupt and player channel detection
84 | self:RegisterEvent('UNIT_SPELLCAST_START')
85 | self:RegisterEvent('UNIT_SPELLCAST_STOP')
86 | self:RegisterEvent('UNIT_SPELLCAST_DELAYED')
87 | self:RegisterEvent('UNIT_SPELLCAST_FAILED')
88 | self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED')
89 | self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START')
90 | self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP')
91 | self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE')
92 | self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTIBLE')
93 | self:RegisterEvent('UNIT_SPELLCAST_NOT_INTERRUPTIBLE')
94 |
95 | -- At init time C_Item.GetItemSpell might not work because they are not
96 | -- in the cache. I think the actionbar will keep them in the cache the rest
97 | -- of the time. Mark overlays as dirty when item results come in (overkill
98 | -- but easier than tracking our itemIDs and rare enough).
99 | self:RegisterEvent('ITEM_DATA_LOAD_RESULT')
100 |
101 | -- These are for tracking that we need to rescan the current overlays to
102 | -- find what extra units we are tracking.
103 | self:RegisterEvent('ACTIONBAR_SLOT_CHANGED')
104 | self:RegisterEvent('UPDATE_MACROS')
105 |
106 | -- Need to track modifier key state for mouseover/focus/self cast modifiers
107 | self:RegisterEvent('MODIFIER_STATE_CHANGED')
108 |
109 | LBA.db.RegisterCallback(self, 'OnModified', 'StyleAllOverlays')
110 | end
111 |
112 | function LiteButtonAurasControllerMixin:CreateOverlay(actionButton)
113 | if not self.overlayFrames[actionButton] then
114 | local name = actionButton:GetName() .. "LiteButtonAurasOverlay"
115 | local overlay = CreateFrame('Frame', name, actionButton, "LiteButtonAurasOverlayTemplate")
116 | self.overlayFrames[actionButton] = overlay
117 | end
118 | return self.overlayFrames[actionButton]
119 | end
120 |
121 | function LiteButtonAurasControllerMixin:GetOverlay(actionButton)
122 | return self.overlayFrames[actionButton]
123 | end
124 |
125 | function LiteButtonAurasControllerMixin:UpdateAllOverlays(stateOnly)
126 | for _, overlay in pairs(self.overlayFrames) do
127 | overlay:Update(stateOnly)
128 | end
129 | end
130 |
131 | -- Triggered when the style options change in the DB
132 | function LiteButtonAurasControllerMixin:StyleAllOverlays()
133 | for _, overlay in pairs(self.overlayFrames) do
134 | overlay:Style()
135 | overlay:Update()
136 | end
137 | end
138 |
139 | function LiteButtonAurasControllerMixin:DumpAllOverlays()
140 | self:UpdateAllOverlays()
141 | local sortedOverlays = GetValuesArray(self.overlayFrames)
142 | table.sort(sortedOverlays, function (a, b) return a:GetActionID() < b:GetActionID() end)
143 | for _, overlay in pairs(sortedOverlays) do
144 | overlay:Dump()
145 | end
146 | end
147 |
148 | function LiteButtonAurasControllerMixin:UpdateTrackedUnitList()
149 | self.trackedUnitList = CopyTable(AlwaysTrackedUnits)
150 | for _, overlay in pairs(self.overlayFrames) do
151 | Mixin(self.trackedUnitList, overlay:GetTrackedUnits())
152 | end
153 | local newState = {}
154 | for unit in pairs(self.trackedUnitList) do
155 | newState[unit] = LBA.state[unit] or LBA.UnitState:Create(unit)
156 | end
157 | LBA.state = newState
158 | end
159 |
160 |
161 | --[[------------------------------------------------------------------------]]--
162 |
163 | function LiteButtonAurasControllerMixin:MarkOverlaysDirty(stateOnly)
164 | -- Tri-state encodes stateOnly : nil / true / false
165 | self.isOverlayDirty = ( stateOnly == true and self.isOverlayDirty ~= false )
166 | end
167 |
168 | -- Limit UNIT_AURA and UNIT_SPELLCAST overlay updates to one per frame
169 | function LiteButtonAurasControllerMixin:OnUpdate()
170 | if self.isOverlayDirty ~= nil then
171 | self:UpdateAllOverlays(self.isOverlayDirty)
172 | self.isOverlayDirty = nil
173 | end
174 | end
175 |
176 | function LiteButtonAurasControllerMixin:IsTrackedUnit(unit)
177 | return self.trackedUnitList[unit] == true
178 | end
179 |
180 | function LiteButtonAurasControllerMixin:OnEvent(event, ...)
181 | if event == 'PLAYER_LOGIN' then
182 | self:Initialize()
183 | self:UnregisterEvent('PLAYER_LOGIN')
184 | self:MarkOverlaysDirty()
185 | elseif event == 'PLAYER_ENTERING_WORLD' then
186 | self:UpdateTrackedUnitList()
187 | for unit in pairs(self.trackedUnitList) do
188 | LBA.state[unit]:UpdateAuras()
189 | LBA.state[unit]:UpdateInterrupt()
190 | end
191 | LBA.state.player:UpdateWeaponEnchants()
192 | LBA.state.player:UpdateChannel()
193 | LBA.state.player:UpdateTotems()
194 | self:MarkOverlaysDirty()
195 | elseif event == 'PLAYER_TARGET_CHANGED' then
196 | LBA.state.target:UpdateAuras()
197 | LBA.state.target:UpdateInterrupt()
198 | self:MarkOverlaysDirty(true)
199 | elseif event == 'PLAYER_FOCUS_CHANGED' then
200 | if self:IsTrackedUnit('focus') then
201 | LBA.state.focus:UpdateAuras()
202 | LBA.state.focus:UpdateInterrupt()
203 | self:MarkOverlaysDirty(true)
204 | end
205 | elseif event == 'UPDATE_MOUSEOVER_UNIT' then
206 | if self:IsTrackedUnit('mouseover') then
207 | LBA.state.mouseover:UpdateAuras()
208 | LBA.state.mouseover:UpdateInterrupt()
209 | self:MarkOverlaysDirty(true)
210 | end
211 | elseif event == 'GROUP_ROSTER_UPDATE' then
212 | for i = 1, GetNumGroupMembers() do
213 | local unit = "party"..i
214 | if self:IsTrackedUnit(unit) then
215 | LBA.state[unit]:UpdateAuras()
216 | LBA.state[unit]:UpdateInterrupt()
217 | self:MarkOverlaysDirty(true)
218 | end
219 | end
220 | elseif event == 'INSTANCE_ENCOUNTER_ENGAGE_UNIT' then
221 | for i = 1, MAX_BOSS_FRAMES do
222 | local unit = "boss"..i
223 | if self:IsTrackedUnit(unit) then
224 | LBA.state[unit]:UpdateAuras()
225 | LBA.state[unit]:UpdateInterrupt()
226 | self:MarkOverlaysDirty(true)
227 | end
228 | end
229 | elseif event == 'ARENA_OPPONENT_UPDATE' then
230 | for i = 1, GetNumArenaOpponents() do
231 | local unit = "arena"..i
232 | if self:IsTrackedUnit(unit) then
233 | LBA.state[unit]:UpdateAuras()
234 | LBA.state[unit]:UpdateInterrupt()
235 | self:MarkOverlaysDirty(true)
236 | end
237 | end
238 | elseif event == 'UNIT_AURA' then
239 | -- This fires a lot. Be careful. In DF, UNIT_AURA seems to tick every
240 | -- second for 'player' with no updates
241 | local unit, unitAuraUpdateInfo = ...
242 | if self:IsTrackedUnit(unit) then
243 | LBA.state[unit]:UpdateAuras(unitAuraUpdateInfo)
244 | -- Shouldn't be needed but weapon enchant duration is returned
245 | -- wrongly as 0 at PLAYER_LOGIN. This is how Blizzard works around
246 | -- it too. Their server code must be a nightmare.
247 | if unit == 'player' then
248 | LBA.state.player:UpdateWeaponEnchants()
249 | end
250 | self:MarkOverlaysDirty(true)
251 | end
252 | -- There are no separate UNIT_AURA events for mouseover (there are for
253 | -- focus though).
254 | if UnitIsUnit(unit, 'mouseover') and self:IsTrackedUnit('mouseover') then
255 | LBA.state.mouseover:UpdateAuras(unitAuraUpdateInfo)
256 | self:MarkOverlaysDirty(true)
257 | end
258 | elseif event == 'PLAYER_TOTEM_UPDATE' then
259 | LBA.state.player:UpdateTotems()
260 | self:MarkOverlaysDirty(true)
261 | elseif event == 'WEAPON_ENCHANT_CHANGED' or event == 'WEAPON_SLOT_CHANGED' then
262 | LBA.state.player:UpdateWeaponEnchants()
263 | self:MarkOverlaysDirty(true)
264 | elseif event:sub(1, 14) == 'UNIT_SPELLCAST' then
265 | -- This fires a lot too, same applies as UNIT_AURA.
266 | local unit = ...
267 | if unit == 'player' then
268 | LBA.state.player:UpdateChannel()
269 | self:MarkOverlaysDirty(true)
270 | else
271 | if self:IsTrackedUnit(unit) then
272 | LBA.state[unit]:UpdateInterrupt()
273 | self:MarkOverlaysDirty(true)
274 | end
275 | if UnitIsUnit(unit, 'mouseover') and self:IsTrackedUnit('mouseover') then
276 | LBA.state.mouseover:UpdateInterrupt()
277 | self:MarkOverlaysDirty(true)
278 | end
279 | end
280 | elseif event == 'ITEM_DATA_LOAD_RESULT' then
281 | self:MarkOverlaysDirty()
282 | elseif event == 'ACTIONBAR_SLOT_CHANGED' or event == 'UPDATE_MACROS' then
283 | self:UpdateTrackedUnitList()
284 | for unit in pairs(self.trackedUnitList) do
285 | LBA.state[unit]:UpdateAuras()
286 | LBA.state[unit]:UpdateInterrupt()
287 | self:MarkOverlaysDirty()
288 | end
289 | elseif event == 'MODIFIER_STATE_CHANGED' then
290 | local key = select(1, ...):sub(2)
291 | if key == GetModifiedClick('MOUSEOVERCAST') then
292 | LBA.state.mouseover:UpdateAuras()
293 | LBA.state.mouseover:UpdateInterrupt()
294 | self:MarkOverlaysDirty(true)
295 | elseif key == GetModifiedClick('FOCUSCAST') then
296 | LBA.state.focus:UpdateAuras()
297 | LBA.state.focus:UpdateInterrupt()
298 | self:MarkOverlaysDirty(true)
299 | end
300 | end
301 | end
302 |
--------------------------------------------------------------------------------
/UI/AceGUIWidgets-LBAInputSpellID.lua:
--------------------------------------------------------------------------------
1 | local _, LBA = ...
2 |
3 | local C_Spell = LBA.C_Spell or C_Spell
4 |
5 | local AceGUI = LibStub("AceGUI-3.0")
6 |
7 | local Type = "LBAInputSpellID"
8 | local Version = 1
9 | local PREDICTION_ROWS = 20
10 |
11 | local function GetSpellText(id)
12 | local info = C_Spell.GetSpellInfo(id or 0)
13 | if info then
14 | local idText = HIGHLIGHT_FONT_COLOR:WrapTextInColorCode(string.format('(%d)', info.spellID))
15 | return string.format("%s %s", info.name, idText)
16 | else
17 | return ''
18 | end
19 | end
20 |
21 | -- [[ SpellCache ]] ------------------------------------------------------------
22 |
23 | local SpellCache = CreateFrame("Frame")
24 |
25 | function SpellCache.BuildCoRoutine()
26 | local id = 0
27 | local misses = 0
28 | while misses < 80000 do
29 | id = id + 1
30 | local info = C_Spell.GetSpellInfo(id)
31 |
32 | if not info then
33 | misses = misses + 1
34 | elseif info.iconID == 136243 then
35 | -- 136243 is the a gear icon, we can ignore those spells
36 | misses = 0;
37 | elseif info.name and info.name ~= "" and info.iconID then
38 | local name = info.name:lower()
39 | SpellCache.spells[name] = SpellCache.spells[name] or {}
40 | table.insert(SpellCache.spells[name], id)
41 | if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC and id == 81748 then
42 | -- jump around big hole with classic SoD
43 | id = 219002
44 | end
45 | misses = 0
46 | else
47 | misses = misses + 1
48 | end
49 | if id % 1000 == 0 then
50 | coroutine.yield()
51 | end
52 | end
53 | for _, cacheLine in pairs(SpellCache.spells) do
54 | table.sort(cacheLine)
55 | end
56 | end
57 |
58 | function SpellCache:Build()
59 |
60 | if self.spells then return end
61 |
62 | self.spells = {}
63 |
64 | local co = coroutine.create(self.BuildCoRoutine)
65 | coroutine.resume(co)
66 |
67 | self:SetScript("OnUpdate",
68 | function (self, elapsed)
69 | if coroutine.status(co) == "dead" then
70 | self:SetScript("OnUpdate", nil)
71 | else
72 | coroutine.resume(co)
73 | end
74 | end)
75 | end
76 |
77 | function SpellCache:Get(name)
78 | if name then
79 | name = name:lower()
80 | return self.spells[name]
81 | end
82 | end
83 |
84 |
85 | -- [[ OkayButton ]] ------------------------------------------------------------
86 |
87 | local OkayButtonMixin = {}
88 |
89 | function OkayButtonMixin:Initialize(obj)
90 | self.obj = obj
91 | self:SetWidth(40)
92 | self:SetHeight(20)
93 | self:SetText(OKAY)
94 | self:SetScript("OnClick", self.OnClick)
95 | self:Hide()
96 | end
97 |
98 | function OkayButtonMixin:OnClick()
99 | local editBox = self.obj.editBox
100 | editBox:OnEnterPressed()
101 | editBox:ClearFocus()
102 | end
103 |
104 |
105 | -- [[ PredictSpellButton ]] ----------------------------------------------------
106 |
107 | local PredictSpellButtonMixin = {}
108 |
109 | function PredictSpellButtonMixin:OnEnter()
110 | GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT")
111 | GameTooltip:SetHyperlink("spell:" .. self.spellID)
112 | end
113 |
114 | function PredictSpellButtonMixin:OnClick()
115 | self.obj:SetValue(self.spellID)
116 | self.obj:SubmitValue()
117 | self.obj:Update()
118 | end
119 |
120 | function PredictSpellButtonMixin:SetSpell(id)
121 | self.spellID = id
122 | local info = C_Spell.GetSpellInfo(id)
123 | self:SetFormattedText("|T%s:18:18:0:0|t %s", info.iconID, GetSpellText(id))
124 | end
125 |
126 | function PredictSpellButtonMixin:Initialize(obj)
127 | self.obj = obj
128 | self:SetHeight(22)
129 | self:SetScript("OnClick", self.OnClick)
130 | self:SetScript("OnEnter", self.OnEnter)
131 | self:SetScript("OnLeave", GameTooltip_Hide)
132 |
133 | -- Create the actual text
134 | self.text = self:CreateFontString(nil, "ARTWORK", "GameFontNormal")
135 | self.text:SetJustifyH("LEFT")
136 | self.text:SetAllPoints(self)
137 | self:SetFontString(self.text)
138 |
139 | -- Setup the highlighting
140 | self.highlightTexture = self:CreateTexture(nil, "ARTWORK")
141 | self.highlightTexture:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
142 | self.highlightTexture:ClearAllPoints()
143 | self.highlightTexture:SetPoint("TOPLEFT", self, 0, -2)
144 | self.highlightTexture:SetPoint("BOTTOMRIGHT", self, 5, 2)
145 | self.highlightTexture:SetAlpha(0.70)
146 |
147 | self:SetHighlightTexture(self.highlightTexture)
148 | self:SetHighlightFontObject(GameFontHighlight)
149 | self:SetNormalFontObject(GameFontNormal)
150 | end
151 |
152 |
153 | -- [[ PredictFrame ]] ----------------------------------------------------------
154 |
155 | local PredictFrameMixin = {}
156 |
157 | local backdrop = {
158 | bgFile = "Interface/Tooltips/UI-Tooltip-Background",
159 | tile = true,
160 | tileSize = 16,
161 | edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
162 | tileEdge = true,
163 | edgeSize = 16,
164 | insets = { left = 4, right = 4, top = 4, bottom = 4 },
165 | }
166 |
167 | function PredictFrameMixin:Initialize(obj)
168 | self.obj = obj
169 |
170 | self:SetBackdrop(backdrop)
171 | self:SetBackdropColor(0, 0, 0, 0.85)
172 | self:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
173 | self:SetFrameStrata("TOOLTIP")
174 |
175 | self.buttons = {}
176 |
177 | for i = 1, PREDICTION_ROWS do
178 | local button = CreateFrame("Button", self:GetName() .. "Button" .. i, self)
179 | Mixin(button, PredictSpellButtonMixin)
180 | button:Initialize(obj)
181 |
182 | if i > 1 then
183 | button:SetPoint("TOPLEFT", self.buttons[i - 1], "BOTTOMLEFT", 0, 0)
184 | button:SetPoint("TOPRIGHT", self.buttons[i - 1], "BOTTOMRIGHT", 0, 0)
185 | else
186 | -- Total vOff here 8+7 = 15 matches the 15 + for SetHeight
187 | button:SetPoint("TOPLEFT", self, 8, -8)
188 | button:SetPoint("TOPRIGHT", self, -7, 0)
189 | end
190 |
191 | self.buttons[i] = button
192 | end
193 | end
194 |
195 | function PredictFrameMixin:UpdateSearch(name)
196 | for _, button in pairs(self.buttons) do
197 | button:Hide()
198 | end
199 |
200 | local spellIDList = SpellCache:Get(name)
201 | local nShown = 0
202 |
203 | if spellIDList then
204 | for i, spellID in ipairs(spellIDList) do
205 | local button = self.buttons[i]
206 | button:SetSpell(spellID)
207 | button:Show()
208 |
209 | button:UnlockHighlight()
210 | if GameTooltip:IsOwned(button) then
211 | GameTooltip_Hide()
212 | end
213 |
214 | nShown = i
215 |
216 | if i >= PREDICTION_ROWS then
217 | break
218 | end
219 | end
220 | self:SetHeight(15 + nShown * self.buttons[1]:GetHeight())
221 | self:Show()
222 | else
223 | self:Hide()
224 | end
225 | end
226 |
227 |
228 | -- [[ EditBox ]] ---------------------------------------------------------------
229 |
230 | local EditBoxMixin = {}
231 |
232 | function EditBoxMixin:OnTextChanged()
233 | local value = self:GetText()
234 | self.obj:Fire("OnTextChanged", value)
235 | self.obj:Update()
236 | end
237 |
238 | function EditBoxMixin:OnEditFocusLost()
239 | self.obj:Update()
240 | end
241 |
242 | function EditBoxMixin:OnEditFocusGained()
243 | self:SetText(self.obj.value or '')
244 | self.obj:Update()
245 | end
246 |
247 | function EditBoxMixin:OnEscapePressed()
248 | self:ClearFocus()
249 | end
250 |
251 | function EditBoxMixin:OnEnterPressed()
252 | local value = self:GetText()
253 | self.obj:SetValue(value)
254 | local isInvalid = self.obj:SubmitValue()
255 | if isInvalid then self:SetFocus() end
256 | self.obj:Update()
257 | end
258 |
259 | function EditBoxMixin:OnEnter()
260 | self.obj:Fire("OnEnter")
261 | end
262 |
263 | function EditBoxMixin:OnLeave()
264 | self.obj:Fire("OnLeave")
265 | end
266 |
267 | function EditBoxMixin:Initialize(obj)
268 | self.obj = obj
269 | self:SetAutoFocus(false)
270 | self:SetFontObject(ChatFontNormal)
271 | self:SetScript("OnEnter", self.OnEnter)
272 | self:SetScript("OnLeave", self.OnLeave)
273 | self:SetScript("OnEscapePressed", self.OnEscapePressed)
274 | self:SetScript("OnEnterPressed", self.OnEnterPressed)
275 | self:SetScript("OnTextChanged", self.OnTextChanged)
276 | self:SetScript("OnEditFocusGained", self.OnEditFocusGained)
277 | self:SetScript("OnEditFocusLost", self.OnEditFocusLost)
278 | self:SetTextInsets(0, 0, 3, 3)
279 | self:SetMaxLetters(256)
280 | end
281 |
282 |
283 | --[[ Main Widget ]] ------------------------------------------------------------
284 |
285 | local methods = {
286 |
287 | OnAcquire =
288 | function (self)
289 | self:SetHeight(26)
290 | self:SetWidth(200)
291 | self:SetDisabled(false)
292 | self:SetLabel()
293 | end,
294 |
295 | OnRelease =
296 | function (self)
297 | self.frame:ClearAllPoints()
298 | self.frame:Hide()
299 | self.predictFrame:Hide()
300 | self:SetDisabled(false)
301 | end,
302 |
303 | Update =
304 | function (self)
305 | if self.predictFrame:IsMouseOver() and IsMouseButtonDown('LeftButton') then
306 | -- In the middle of a predict spell click, don't mess it up.
307 | return
308 | end
309 | if self.editBox:HasFocus() then
310 | self.predictFrame:UpdateSearch(self.editBox:GetText())
311 | self.okayButton:Show()
312 | else
313 | self.predictFrame:Hide()
314 | self.editBox:SetText(GetSpellText(self.value))
315 | self.okayButton:Hide()
316 | end
317 | end,
318 |
319 | SetDisabled =
320 | function (self, disabled)
321 | self.disabled = disabled
322 | if disabled then
323 | self.editBox:EnableMouse(false)
324 | self.editBox:ClearFocus()
325 | self.editBox:SetTextColor(0.5, 0.5, 0.5)
326 | self.label:SetTextColor(0.5, 0.5, 0.5)
327 | else
328 | self.editBox:EnableMouse(true)
329 | self.editBox:SetTextColor(1, 1, 1)
330 | self.label:SetTextColor(1, 0.82, 0)
331 | end
332 | end,
333 |
334 | SetText =
335 | function (self, text, cursor)
336 | self.editBox:SetText(text)
337 | self.editBox:SetCursorPosition(cursor or 0)
338 | self:Update()
339 | end,
340 |
341 | SetLabel =
342 | function (self, text)
343 | if text and text ~= "" then
344 | self.label:SetText(text)
345 | self.label:Show()
346 | self.editBox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, -18)
347 | self:SetHeight(44)
348 | self.alignoffset = 30
349 | else
350 | self.label:SetText("")
351 | self.label:Hide()
352 | self.editBox:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 7, 0)
353 | self:SetHeight(26)
354 | self.alignoffset = 12
355 | end
356 | end,
357 |
358 | SetValue =
359 | function (self, value)
360 | if tonumber(value) then
361 | self.value = value
362 | else
363 | local info = C_Spell.GetSpellInfo(value)
364 | self.value = info and info.name or ''
365 | end
366 | end,
367 |
368 | SubmitValue =
369 | function (self)
370 | return self:Fire("OnEnterPressed", self.value or '')
371 | end,
372 | }
373 |
374 |
375 | local function Constructor()
376 | SpellCache:Build()
377 |
378 | local self = CreateFromMixins(methods)
379 | self.type = Type
380 | self.num = AceGUI:GetNextWidgetNum(Type)
381 |
382 | self.frame = CreateFrame("Frame", nil, UIParent)
383 | self.frame:SetHeight(44)
384 | self.frame:SetWidth(200)
385 | self.frame.obj = self
386 |
387 | self.editBox = CreateFrame("EditBox", "AceGUI30SpellEditBox" .. self.num, self.frame, "InputBoxTemplate")
388 | Mixin(self.editBox, EditBoxMixin)
389 | self.editBox:Initialize(self)
390 | self.editBox:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", 6, 0)
391 | self.editBox:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", 0, 0)
392 | self.editBox:SetHeight(19)
393 |
394 | self.predictFrame = CreateFrame("Frame", "AceGUI30SpellEditBox" .. self.num .. "PredictFrame", UIParent, "BackdropTemplate")
395 | Mixin(self.predictFrame, PredictFrameMixin)
396 | self.predictFrame:Initialize(self)
397 | self.predictFrame:SetPoint("TOPLEFT", self.editBox, "BOTTOMLEFT", -6, 0)
398 | self.predictFrame:SetPoint("TOPRIGHT", self.editBox, "BOTTOMRIGHT", 0, 0)
399 |
400 | self.alignoffset = 30
401 |
402 | self.label = self.frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
403 | self.label:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -2)
404 | self.label:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", 0, -2)
405 | self.label:SetJustifyH("LEFT")
406 | self.label:SetHeight(18)
407 |
408 | self.okayButton = CreateFrame("Button", nil, self.editBox, "UIPanelButtonTemplate")
409 | Mixin(self.okayButton, OkayButtonMixin)
410 | self.okayButton:Initialize(self)
411 | self.okayButton:SetPoint("RIGHT", self.editBox, "RIGHT", -2, 0)
412 |
413 | AceGUI:RegisterAsWidget(self)
414 | return self
415 | end
416 |
417 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
418 |
--------------------------------------------------------------------------------
/Localization.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2024 Mike "Xodiv" Battersby
5 |
6 | 您好,請幫忙翻譯一下
7 | https://legacy.curseforge.com/wow/addons/litebuttonauras/localization
8 | https://github.com/xod-wow/LiteButtonAuras/issues
9 |
10 | ----------------------------------------------------------------------------]]--
11 |
12 | local _, LBA = ...
13 |
14 | LBA.L = setmetatable({}, { __index = function (_,k) return k end })
15 |
16 | local L = LBA.L
17 |
18 | local locale = GetLocale()
19 |
20 | -- :r! sh fetchlocale.sh -------------------------------------------------------
21 |
22 | -- deDE ------------------------------------------------------------------------
23 |
24 | if locale == "deDE" then
25 | L = L or {}
26 | --[[ L["Add ability"] = ""--]]
27 | --[[ L["Aura list"] = ""--]]
28 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
29 | L["Bottom"] = "Unten"
30 | L["Bottom left"] = "Unten Links"
31 | L["Bottom right"] = "Unten Rechts"
32 | L["Center"] = "Mitte"
33 | L["Color aura duration timers based on remaining time."] = "Timer für die Dauer der Farbaura basierend auf der verbleibenden Zeit."
34 | L["Display aura duration timers."] = "Zeigt Timer für die Dauer der Aura an."
35 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
36 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
37 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
38 | --[[ L["Error: unknown spell: %s"] = ""--]]
39 | L["Extra aura displays"] = "Zusätzliche Aura-Displays"
40 | L["Font name"] = "Schriftartenname"
41 | L["Font size"] = "Schriftgröße"
42 | L["For spells that aren't in your spell book use the spell ID number."] = "Verwenden Sie für Zaubersprüche, die nicht in Ihrem Zauberbuch enthalten sind, die Zauber-ID-Nummer."
43 | L["Highlight buttons for interrupt and soothe."] = "Markieren Sie die Schaltflächen zum Tritt und Besänftigen"
44 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
45 | L["Ignored abilities"] = "Ignorierte Fähigkeiten"
46 | L["Left"] = "Links"
47 | --[[ L["on"] = ""--]]
48 | L["On ability"] = "bei Fähigkeit"
49 | L["Right"] = "Rechts"
50 | L["Show aura"] = "Zeige Aura"
51 | L["Show aura stacks."] = "Aura-Stapel anzeigen."
52 | L["Show fractions of a second on timers."] = "Zeigen Sie Sekundenbruchteile auf Timern an."
53 | L["Stack text offset"] = "Stapelversatz"
54 | L["Stack text position"] = "Stapelanker"
55 | --[[ L["Text positions"] = ""--]]
56 | L["Timer text offset"] = "Zeitgeberort Offset"
57 | L["Timer text position"] = "Timer-Anker"
58 | L["Top"] = "Oben"
59 | L["Top left"] = "Oben Links"
60 | L["Top right"] = "Oben Rechts"
61 | --[[ L["Wiping aura list."] = ""--]]
62 | end
63 |
64 | -- esES / esMX -----------------------------------------------------------------
65 |
66 | if locale == "esES" or locale == "esMX" then
67 | L = L or {}
68 | --[[ L["Add ability"] = ""--]]
69 | --[[ L["Aura list"] = ""--]]
70 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
71 | L["Bottom"] = "Abajo"
72 | L["Bottom left"] = "Abajo Izquierda"
73 | L["Bottom right"] = "Abajo Derecha"
74 | L["Center"] = "Centro"
75 | --[[ L["Color aura duration timers based on remaining time."] = ""--]]
76 | --[[ L["Display aura duration timers."] = ""--]]
77 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
78 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
79 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
80 | --[[ L["Error: unknown spell: %s"] = ""--]]
81 | --[[ L["Extra aura displays"] = ""--]]
82 | --[[ L["Font name"] = ""--]]
83 | L["Font size"] = "Tamaño de fuente"
84 | --[[ L["For spells that aren't in your spell book use the spell ID number."] = ""--]]
85 | --[[ L["Highlight buttons for interrupt and soothe."] = ""--]]
86 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
87 | --[[ L["Ignored abilities"] = ""--]]
88 | L["Left"] = "Izquierda"
89 | --[[ L["on"] = ""--]]
90 | --[[ L["On ability"] = ""--]]
91 | L["Right"] = "Derecha"
92 | --[[ L["Show aura"] = ""--]]
93 | --[[ L["Show aura stacks."] = ""--]]
94 | --[[ L["Show fractions of a second on timers."] = ""--]]
95 | --[[ L["Stack text offset"] = ""--]]
96 | --[[ L["Stack text position"] = ""--]]
97 | --[[ L["Text positions"] = ""--]]
98 | --[[ L["Timer text offset"] = ""--]]
99 | --[[ L["Timer text position"] = ""--]]
100 | L["Top"] = "Superior"
101 | L["Top left"] = "Superior izquierda"
102 | L["Top right"] = "Superior derecha"
103 | --[[ L["Wiping aura list."] = ""--]]
104 | end
105 |
106 | -- frFR ------------------------------------------------------------------------
107 |
108 | if locale == "frFR" then
109 | L = L or {}
110 | --[[ L["Add ability"] = ""--]]
111 | --[[ L["Aura list"] = ""--]]
112 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
113 | L["Bottom"] = "Bas"
114 | L["Bottom left"] = "Bas Gauche"
115 | L["Bottom right"] = "Bas Droite"
116 | L["Center"] = "Centre"
117 | --[[ L["Color aura duration timers based on remaining time."] = ""--]]
118 | --[[ L["Display aura duration timers."] = ""--]]
119 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
120 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
121 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
122 | --[[ L["Error: unknown spell: %s"] = ""--]]
123 | --[[ L["Extra aura displays"] = ""--]]
124 | --[[ L["Font name"] = ""--]]
125 | L["Font size"] = "Taille de Police"
126 | --[[ L["For spells that aren't in your spell book use the spell ID number."] = ""--]]
127 | --[[ L["Highlight buttons for interrupt and soothe."] = ""--]]
128 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
129 | --[[ L["Ignored abilities"] = ""--]]
130 | L["Left"] = "Gauche"
131 | --[[ L["on"] = ""--]]
132 | --[[ L["On ability"] = ""--]]
133 | L["Right"] = "Droite"
134 | --[[ L["Show aura"] = ""--]]
135 | --[[ L["Show aura stacks."] = ""--]]
136 | --[[ L["Show fractions of a second on timers."] = ""--]]
137 | --[[ L["Stack text offset"] = ""--]]
138 | --[[ L["Stack text position"] = ""--]]
139 | --[[ L["Text positions"] = ""--]]
140 | --[[ L["Timer text offset"] = ""--]]
141 | --[[ L["Timer text position"] = ""--]]
142 | L["Top"] = "Haut"
143 | L["Top left"] = "Haut Gauche"
144 | L["Top right"] = "Haut Droite"
145 | --[[ L["Wiping aura list."] = ""--]]
146 | end
147 |
148 | -- itIT ------------------------------------------------------------------------
149 |
150 | if locale == "itIT" then
151 | L = L or {}
152 | --[[ L["Add ability"] = ""--]]
153 | --[[ L["Aura list"] = ""--]]
154 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
155 | L["Bottom"] = "Basso"
156 | L["Bottom left"] = "Basso a sinistra"
157 | L["Bottom right"] = "Basso a destra"
158 | L["Center"] = "Centro"
159 | --[[ L["Color aura duration timers based on remaining time."] = ""--]]
160 | --[[ L["Display aura duration timers."] = ""--]]
161 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
162 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
163 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
164 | --[[ L["Error: unknown spell: %s"] = ""--]]
165 | --[[ L["Extra aura displays"] = ""--]]
166 | --[[ L["Font name"] = ""--]]
167 | --[[ L["Font size"] = ""--]]
168 | --[[ L["For spells that aren't in your spell book use the spell ID number."] = ""--]]
169 | --[[ L["Highlight buttons for interrupt and soothe."] = ""--]]
170 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
171 | --[[ L["Ignored abilities"] = ""--]]
172 | L["Left"] = "Left"
173 | --[[ L["on"] = ""--]]
174 | --[[ L["On ability"] = ""--]]
175 | L["Right"] = "Right"
176 | --[[ L["Show aura"] = ""--]]
177 | --[[ L["Show aura stacks."] = ""--]]
178 | --[[ L["Show fractions of a second on timers."] = ""--]]
179 | --[[ L["Stack text offset"] = ""--]]
180 | --[[ L["Stack text position"] = ""--]]
181 | --[[ L["Text positions"] = ""--]]
182 | --[[ L["Timer text offset"] = ""--]]
183 | --[[ L["Timer text position"] = ""--]]
184 | L["Top"] = "Top"
185 | L["Top left"] = "Top Left"
186 | L["Top right"] = "Top Right"
187 | --[[ L["Wiping aura list."] = ""--]]
188 | end
189 |
190 | -- koKR ------------------------------------------------------------------------
191 |
192 | if locale == "koKR" then
193 | L = L or {}
194 | --[[ L["Add ability"] = ""--]]
195 | --[[ L["Aura list"] = ""--]]
196 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
197 | L["Bottom"] = "아래"
198 | L["Bottom left"] = "왼쪽 아래"
199 | L["Bottom right"] = "오른쪽 아래"
200 | L["Center"] = "중앙"
201 | L["Color aura duration timers based on remaining time."] = "남은 시간을 기준으로 오라 지속 시간 타이머에 색상을 지정합니다."
202 | L["Display aura duration timers."] = "오라 지속 시간 타이머를 표시합니다."
203 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
204 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
205 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
206 | --[[ L["Error: unknown spell: %s"] = ""--]]
207 | --[[ L["Extra aura displays"] = ""--]]
208 | L["Font name"] = "글꼴"
209 | L["Font size"] = "글꼴 크기"
210 | --[[ L["For spells that aren't in your spell book use the spell ID number."] = ""--]]
211 | --[[ L["Highlight buttons for interrupt and soothe."] = ""--]]
212 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
213 | --[[ L["Ignored abilities"] = ""--]]
214 | L["Left"] = "왼쪽"
215 | --[[ L["on"] = ""--]]
216 | --[[ L["On ability"] = ""--]]
217 | L["Right"] = "오른쪽"
218 | --[[ L["Show aura"] = ""--]]
219 | --[[ L["Show aura stacks."] = ""--]]
220 | --[[ L["Show fractions of a second on timers."] = ""--]]
221 | --[[ L["Stack text offset"] = ""--]]
222 | --[[ L["Stack text position"] = ""--]]
223 | --[[ L["Text positions"] = ""--]]
224 | --[[ L["Timer text offset"] = ""--]]
225 | --[[ L["Timer text position"] = ""--]]
226 | L["Top"] = "위"
227 | L["Top left"] = "왼쪽 위"
228 | L["Top right"] = "오른쪽 위"
229 | --[[ L["Wiping aura list."] = ""--]]
230 | end
231 |
232 | -- ptBR ------------------------------------------------------------------------
233 |
234 | if locale == "ptBR" then
235 | L = L or {}
236 | --[[ L["Add ability"] = ""--]]
237 | --[[ L["Aura list"] = ""--]]
238 | --[[ L["Automatically match auras to abilities by name."] = ""--]]
239 | L["Bottom"] = "Embaixo"
240 | L["Bottom left"] = "Embaixo à esquerda"
241 | L["Bottom right"] = "Embaixo à direita"
242 | L["Center"] = "Centro"
243 | --[[ L["Color aura duration timers based on remaining time."] = ""--]]
244 | --[[ L["Display aura duration timers."] = ""--]]
245 | --[[ L["Display buffs cast by you on your pet."] = ""--]]
246 | --[[ L["Error: unknown ability spell: %s"] = ""--]]
247 | --[[ L["Error: unknown aura spell: %s"] = ""--]]
248 | --[[ L["Error: unknown spell: %s"] = ""--]]
249 | --[[ L["Extra aura displays"] = ""--]]
250 | --[[ L["Font name"] = ""--]]
251 | --[[ L["Font size"] = ""--]]
252 | --[[ L["For spells that aren't in your spell book use the spell ID number."] = ""--]]
253 | --[[ L["Highlight buttons for interrupt and soothe."] = ""--]]
254 | --[[ L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = ""--]]
255 | --[[ L["Ignored abilities"] = ""--]]
256 | L["Left"] = "Esquerda"
257 | --[[ L["on"] = ""--]]
258 | --[[ L["On ability"] = ""--]]
259 | L["Right"] = "Direita"
260 | --[[ L["Show aura"] = ""--]]
261 | --[[ L["Show aura stacks."] = ""--]]
262 | --[[ L["Show fractions of a second on timers."] = ""--]]
263 | --[[ L["Stack text offset"] = ""--]]
264 | --[[ L["Stack text position"] = ""--]]
265 | --[[ L["Text positions"] = ""--]]
266 | --[[ L["Timer text offset"] = ""--]]
267 | --[[ L["Timer text position"] = ""--]]
268 | L["Top"] = "Topo"
269 | L["Top left"] = "Topo à esquerda"
270 | L["Top right"] = "Topo à direita"
271 | --[[ L["Wiping aura list."] = ""--]]
272 | end
273 |
274 | -- ruRU ------------------------------------------------------------------------
275 |
276 | if locale == "ruRU" then
277 | L = L or {}
278 | L["Add ability"] = "Добавить способность"
279 | L["Aura list"] = "Список аур"
280 | L["Automatically match auras to abilities by name."] = "Автоматически сопоставлять ауры со способностями по названию."
281 | L["Bottom"] = "Снизу"
282 | L["Bottom left"] = "Снизу слева"
283 | L["Bottom right"] = "Снизу справа"
284 | L["Center"] = "Центр"
285 | L["Color aura duration timers based on remaining time."] = "Таймеры длительности цветной ауры основаны на оставшемся времени."
286 | L["Display aura duration timers."] = "Отображение таймеров длительности ауры."
287 | L["Display buffs cast by you on your pet."] = "Отображение усилений, наложенных вами на вашего питомца."
288 | L["Error: unknown ability spell: %s"] = "Ошибка: неизвестная способность заклинания: %s"
289 | L["Error: unknown aura spell: %s"] = "Ошибка: неизвестное заклинание ауры: %s"
290 | L["Error: unknown spell: %s"] = "Ошибка: неизвестное заклинание: %s"
291 | L["Extra aura displays"] = "Дополнительные дисплеи аур"
292 | L["Font name"] = "Шрифт"
293 | L["Font size"] = "Размер шрифта"
294 | L["For spells that aren't in your spell book use the spell ID number."] = "Для заклинаний, которых нет в вашей книге заклинаний, используйте ID заклинания."
295 | L["Highlight buttons for interrupt and soothe."] = "Выделите кнопки для прерывания и успокоения."
296 | L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = "Если отключить эту опцию, будут отображаться только ауры, явно настроенные в разделе «Дополнительные отображения аур»."
297 | L["Ignored abilities"] = "Игнорируемые способности"
298 | L["Left"] = "Слева"
299 | L["on"] = "на"
300 | L["On ability"] = "По способности"
301 | L["Right"] = "Справа"
302 | L["Show aura"] = "Показать ауру"
303 | L["Show aura stacks."] = "Показать стаки ауры."
304 | L["Show fractions of a second on timers."] = "Показывать доли секунды на таймерах."
305 | L["Stack text offset"] = "Смещение текста стака"
306 | L["Stack text position"] = "Положение текста в стаке"
307 | L["Text positions"] = "Текстовые позиции"
308 | L["Timer text offset"] = "Смещение текста таймера"
309 | L["Timer text position"] = "Положение текста таймера"
310 | L["Top"] = "Сверху"
311 | L["Top left"] = "Вверху слева"
312 | L["Top right"] = "Сверху справа"
313 | L["Wiping aura list."] = "Очистка списка аур."
314 | end
315 |
316 | -- zhCN ------------------------------------------------------------------------
317 |
318 | if locale == "zhCN" then
319 | L = L or {}
320 | L["Add ability"] = "添加技能"
321 | L["Aura list"] = "光环清单"
322 | L["Automatically match auras to abilities by name."] = "自动将名称相同的光环与技能配对"
323 | L["Bottom"] = "下"
324 | L["Bottom left"] = "左下"
325 | L["Bottom right"] = "右下"
326 | L["Center"] = "中间"
327 | L["Color aura duration timers based on remaining time."] = "依据剩余时间变化文字颜色"
328 | L["Display aura duration timers."] = "显示光环持续时间"
329 | L["Display buffs cast by you on your pet."] = "显示你施放在你的宠物身上的增益"
330 | L["Error: unknown ability spell: %s"] = "错误: 未知的技能法术: %s"
331 | L["Error: unknown aura spell: %s"] = "错误: 未知的光环法术: %s"
332 | L["Error: unknown spell: %s"] = "错误: 未知的法术: %s"
333 | L["Extra aura displays"] = "额外显示光环"
334 | L["Font name"] = "字体"
335 | L["Font size"] = "文字大小"
336 | L["For spells that aren't in your spell book use the spell ID number."] = "不在你的法术书里面的法术请使用法术 ID 数字"
337 | L["Highlight buttons for interrupt and soothe."] = "断法和安抚按钮发光"
338 | L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = "停用此选项时,只会显示在\\\"额外显示光环\\\" 中有明确设定的光环。"
339 | L["Ignored abilities"] = "忽略技能"
340 | L["Left"] = "左"
341 | L["on"] = "于"
342 | L["On ability"] = "于技能"
343 | L["Right"] = "右"
344 | L["Show aura"] = "显示光环"
345 | L["Show aura stacks."] = "显示光环层数"
346 | L["Show fractions of a second on timers."] = "时间显示小数点"
347 | L["Stack text offset"] = "层数位置偏移"
348 | L["Stack text position"] = "层数位置"
349 | L["Text positions"] = "位置"
350 | L["Timer text offset"] = "时间位置偏移"
351 | L["Timer text position"] = "时间位置"
352 | L["Top"] = "上"
353 | L["Top left"] = "左上"
354 | L["Top right"] = "右上"
355 | L["Wiping aura list."] = "正在清空光环清单。"
356 | end
357 |
358 | -- zhTW ------------------------------------------------------------------------
359 |
360 | if locale == "zhTW" then
361 | L = L or {}
362 | L["Add ability"] = "添加技能"
363 | L["Aura list"] = "光環清單"
364 | L["Automatically match auras to abilities by name."] = "自動將名稱相同的光環與技能配對"
365 | L["Bottom"] = "下"
366 | L["Bottom left"] = "左下"
367 | L["Bottom right"] = "右下"
368 | L["Center"] = "中間"
369 | L["Color aura duration timers based on remaining time."] = "依據剩餘時間變化文字顏色"
370 | L["Display aura duration timers."] = "顯示光環持續時間"
371 | L["Display buffs cast by you on your pet."] = "顯示你施放在你的寵物身上的增益"
372 | L["Error: unknown ability spell: %s"] = "錯誤: 未知的技能法術: %s"
373 | L["Error: unknown aura spell: %s"] = "錯誤: 未知的光環法術: %s"
374 | L["Error: unknown spell: %s"] = "錯誤: 未知的法術: %s"
375 | L["Extra aura displays"] = "額外顯示光環"
376 | L["Font name"] = "字體"
377 | L["Font size"] = "文字大小"
378 | L["For spells that aren't in your spell book use the spell ID number."] = "不在你的法術書裡面的法術請使用法術 ID 數字"
379 | L["Highlight buttons for interrupt and soothe."] = "斷法和安撫按鈕發光"
380 | L["If you disable this option, only auras explicitly configured under \"Extra aura displays\" will be shown."] = "停用此選項時,只會顯示在 \"額外顯示光環\" 中有明確設定的光環。"
381 | L["Ignored abilities"] = "忽略技能"
382 | L["Left"] = "左"
383 | L["on"] = "於"
384 | L["On ability"] = "於技能"
385 | L["Right"] = "右"
386 | L["Show aura"] = "顯示光環"
387 | L["Show aura stacks."] = "顯示光環層數"
388 | L["Show fractions of a second on timers."] = "時間顯示小數點"
389 | L["Stack text offset"] = "層數位置偏移"
390 | L["Stack text position"] = "層數位置"
391 | L["Text positions"] = "位置"
392 | L["Timer text offset"] = "時間位置偏移"
393 | L["Timer text position"] = "時間位置"
394 | L["Top"] = "上"
395 | L["Top left"] = "左上"
396 | L["Top right"] = "右上"
397 | L["Wiping aura list."] = "正在清空光環清單。"
398 | end
399 |
--------------------------------------------------------------------------------
/UI/Options.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras/Options.lua
4 |
5 | Copyright 2015 Mike Battersby
6 |
7 | ----------------------------------------------------------------------------]]--
8 |
9 | local addonName, LBA = ...
10 |
11 | local L = LBA.L
12 |
13 | local C_Spell = LBA.C_Spell or C_Spell
14 |
15 | local LSM = LibStub('LibSharedMedia-3.0')
16 | local FONT = LSM.MediaType.FONT
17 | local ALL_FONTS = LSM:HashTable(FONT)
18 |
19 | local ANCHOR_SELECT_VALUES = {
20 | BOTTOMLEFT = L["Bottom left"],
21 | BOTTOM = L["Bottom"],
22 | BOTTOMRIGHT = L["Bottom right"],
23 | RIGHT = L["Right"],
24 | TOPRIGHT = L["Top right"],
25 | TOP = L["Top"],
26 | TOPLEFT = L["Top left"],
27 | LEFT = L["Left"],
28 | CENTER = L["Center"]
29 | }
30 |
31 | local function Getter(info)
32 | local k = info[#info]
33 | return LBA.db.profile[k]
34 | end
35 |
36 | local function Setter(info, val ,...)
37 | local k = info[#info]
38 | LBA.SetOption(k, val)
39 | end
40 |
41 | local function FontPathGetter(info)
42 | for name, path in pairs(ALL_FONTS) do
43 | if path == LBA.db.profile.fontPath then
44 | return name
45 | end
46 | end
47 | end
48 |
49 | local function FontPathSetter(info, name)
50 | if ALL_FONTS[name] then
51 | LBA.SetOption('fontPath', ALL_FONTS[name])
52 | end
53 | end
54 |
55 | local function ValidateSpellValue(_, v)
56 | if v == "" then
57 | return true
58 | elseif v and C_Spell.GetSpellInfo(v) ~= nil then
59 | return true
60 | else
61 | return format(
62 | L["Error: unknown spell: %s"] ..
63 | "\n\n" ..
64 | L["For spells that aren't in your spell book use the spell ID number."],
65 | ORANGE_FONT_COLOR:WrapTextInColorCode(v))
66 | end
67 | end
68 |
69 | local order
70 | do
71 | local n = 0
72 | order = function () n = n + 1 return n end
73 | end
74 |
75 | local addAuraMap = { }
76 | local addIgnoreAbility
77 |
78 | local ValidateTexture = UIParent:CreateTexture()
79 |
80 | local options = {
81 | type = "group",
82 | childGroups = "tab",
83 | args = {
84 | GeneralGroup = {
85 | type = "group",
86 | name = GENERAL,
87 | order = order(),
88 | get = Getter,
89 | set = Setter,
90 | args = {
91 | topGap = {
92 | type = "description",
93 | name = "\n",
94 | width = "full",
95 | order = order(),
96 | },
97 | defaultNameMatching = {
98 | type = "toggle",
99 | name = L["Automatically match auras to abilities by name."],
100 | desc = L['If you disable this option, only auras explicitly configured under "Extra aura displays" will be shown.'],
101 | order = order(),
102 | width = "full",
103 | },
104 | playerPetBuffs = {
105 | type = "toggle",
106 | name = L["Display buffs cast by you on your pet."],
107 | order = order(),
108 | width = "full",
109 | },
110 | showTimers = {
111 | type = "toggle",
112 | name = L["Display aura duration timers."],
113 | order = order(),
114 | width = "full",
115 | },
116 | colorTimers = {
117 | type = "toggle",
118 | name = L["Color aura duration timers based on remaining time."],
119 | order = order(),
120 | width = "full",
121 | },
122 | decimalTimers = {
123 | type = "toggle",
124 | name = L["Show fractions of a second on timers."],
125 | order = order(),
126 | width = "full",
127 | },
128 | showStacks = {
129 | type = "toggle",
130 | name = L["Show aura stacks."],
131 | order = order(),
132 | width = "full",
133 | },
134 | showSuggestions = {
135 | type = "toggle",
136 | name = L["Highlight buttons for interrupt and soothe."],
137 | order = order(),
138 | width = "full",
139 | },
140 | preFontHeaderGap = {
141 | name = "\n",
142 | type = "description",
143 | width = 'full',
144 | order = order(),
145 | },
146 | FontHeader = {
147 | type = "header",
148 | name = L["Font"],
149 | order = order(),
150 | },
151 | postFontHeaderGap = {
152 | name = "",
153 | type = "description",
154 | width = 'full',
155 | order = order(),
156 | },
157 | fontRestoreDefaults = {
158 | name = L["Restore font defaults"],
159 | type = "execute",
160 | width = "full",
161 | order = order(),
162 | func =
163 | function ()
164 | LBA.SetOption("fontPath", "default")
165 | LBA.SetOption("fontSize", "default")
166 | end,
167 | },
168 | preFontPathSpacer = {
169 | name = "",
170 | type = "description",
171 | width = 0.05,
172 | order = order(),
173 | },
174 | fontPath = {
175 | type = "select",
176 | name = L["Font name"],
177 | order = order(),
178 | dialogControl = 'LSM30_Font',
179 | values = ALL_FONTS,
180 | get = FontPathGetter,
181 | set = FontPathSetter,
182 | },
183 | fontSizePreGap = {
184 | type = "description",
185 | name = "",
186 | width = 0.1,
187 | order = order(),
188 | },
189 | fontSize = {
190 | type = "range",
191 | name = L["Font size"],
192 | order = order(),
193 | min = 6,
194 | max = 24,
195 | step = 1,
196 | },
197 | preAnchorHeaderGap = {
198 | name = "\n",
199 | type = "description",
200 | width = 'full',
201 | order = order(),
202 | },
203 | AnchorHeader = {
204 | type = "header",
205 | name = L["Text positions"],
206 | order = order(),
207 | },
208 | postAnchorHeaderGap = {
209 | name = "",
210 | type = "description",
211 | width = 'full',
212 | order = order(),
213 | },
214 | anchorRestoreDefaults = {
215 | name = L["Restore text defaults"],
216 | type = "execute",
217 | width = "full",
218 | order = order(),
219 | func =
220 | function ()
221 | LBA.SetOption("timerAnchor", "default")
222 | LBA.SetOption("timerAdjust", "default")
223 | LBA.SetOption("stacksAnchor", "default")
224 | LBA.SetOption("stacksAdjust", "default")
225 | end,
226 | },
227 | preTimerAnchorGap = {
228 | name = "",
229 | type = "description",
230 | width = 0.1,
231 | order = order(),
232 | },
233 | timerAnchor = {
234 | name = L["Timer text position"],
235 | type = "select",
236 | control = 'LBAAnchorButtons',
237 | values = ANCHOR_SELECT_VALUES,
238 | order = order(),
239 | },
240 | preStacksAnchorGap = {
241 | name = "",
242 | type = "description",
243 | width = 0.25,
244 | order = order(),
245 | },
246 | stacksAnchor = {
247 | name = L["Stack text position"],
248 | type = "select",
249 | control = 'LBAAnchorButtons',
250 | values = ANCHOR_SELECT_VALUES,
251 | order = order(),
252 | },
253 | AnchorsGap = {
254 | name = "",
255 | type = "description",
256 | width = 'full',
257 | order = order(),
258 | },
259 | preTimerAdjustGap = {
260 | name = "",
261 | type = "description",
262 | width = 0.1,
263 | order = order(),
264 | },
265 | timerAdjust = {
266 | name = L["Timer text offset"],
267 | type = "range",
268 | order = order(),
269 | min = -16,
270 | max = 16,
271 | step = 1,
272 | },
273 | preStacksAdjustGap = {
274 | name = "",
275 | type = "description",
276 | width = 0.25,
277 | order = order(),
278 | },
279 | stacksAdjust = {
280 | name = L["Stack text offset"],
281 | type = "range",
282 | order = order(),
283 | min = -16,
284 | max = 16,
285 | step = 1,
286 | },
287 | preGlowHeaderGap = {
288 | name = "\n",
289 | type = "description",
290 | width = 'full',
291 | order = order(),
292 | },
293 | GlowHeader = {
294 | type = "header",
295 | name = L["Glow"],
296 | order = order(),
297 | },
298 | postGlowHeaderGap = {
299 | name = "",
300 | type = "description",
301 | width = 'full',
302 | order = order(),
303 | },
304 | glowRestoreDefaults = {
305 | name = L["Restore glow defaults"],
306 | type = "execute",
307 | width = "full",
308 | order = order(),
309 | func =
310 | function ()
311 | LBA.SetOption("glowTexture", "default")
312 | LBA.SetOption("glowAlpha", "default")
313 | LBA.SetOption("glowUseMasque", "default")
314 | end,
315 | },
316 | glowTexture = {
317 | name = L["Glow texture"],
318 | type = "input",
319 | width = "full",
320 | order = order(),
321 | validate =
322 | function (info, value)
323 | ValidateTexture:SetTexture(value)
324 | if ValidateTexture:GetTexture() then
325 | return true
326 | else
327 | return L["Texture not found"]
328 | end
329 | end,
330 | },
331 | glowAlpha = {
332 | type = "range",
333 | name = L["Glow alpha"],
334 | order = order(),
335 | min = 0,
336 | max = 1,
337 | step = 0.01,
338 | },
339 | preGlowUseMasqueSpacer = {
340 | name = "",
341 | type = "description",
342 | width = 0.5,
343 | order = order(),
344 | },
345 | glowUseMasque = {
346 | name = L["Automatically use Masque textures"],
347 | type = "toggle",
348 | width = 2,
349 | order = order(),
350 | },
351 | },
352 | },
353 | MappingGroup = {
354 | type = "group",
355 | name = L["Extra aura displays"],
356 | inline = false,
357 | order = order(),
358 | args = {
359 | showAura = {
360 | name = L["Show aura"],
361 | type = "input",
362 | width = 1.4,
363 | order = order(),
364 | get =
365 | function ()
366 | if addAuraMap[1] then
367 | local info = C_Spell.GetSpellInfo(addAuraMap[1])
368 | return ("%s (%s)"):format(info.name, info.spellID) .. "\0" .. addAuraMap[1]
369 | end
370 | end,
371 | set =
372 | function (_, v)
373 | local info = C_Spell.GetSpellInfo(v)
374 | addAuraMap[1] = info and info.spellID or nil
375 | end,
376 | control = 'LBAInputFocus',
377 | validate = ValidateSpellValue,
378 | },
379 | preOnAbilityGap = {
380 | name = "",
381 | type = "description",
382 | width = 0.1,
383 | order = order(),
384 | },
385 | onAbility = {
386 | name = L["On ability"],
387 | type = "input",
388 | width = 1.4,
389 | order = order(),
390 | get =
391 | function ()
392 | if addAuraMap[2] then
393 | local info = C_Spell.GetSpellInfo(addAuraMap[2])
394 | return ("%s (%s)"):format(info.name, info.spellID) .. "\0" .. addAuraMap[2]
395 | end
396 | end,
397 | set =
398 | function (_, v)
399 | local info = C_Spell.GetSpellInfo(v)
400 | addAuraMap[2] = info and info.spellID or nil
401 | end,
402 | control = 'LBAInputFocus',
403 | validate = ValidateSpellValue,
404 | },
405 | preAddButtonGap = {
406 | name = "",
407 | type = "description",
408 | width = 0.1,
409 | order = order(),
410 | },
411 | AddButton = {
412 | name = ADD,
413 | type = "execute",
414 | width = 0.5,
415 | order = order(),
416 | disabled =
417 | function (info, v)
418 | local auraName = addAuraMap[1] and C_Spell.GetSpellName(addAuraMap[1])
419 | local abilityName = addAuraMap[2] and C_Spell.GetSpellName(addAuraMap[2])
420 | if auraName and abilityName and auraName ~= abilityName then
421 | return false
422 | else
423 | return true
424 | end
425 | end,
426 | func =
427 | function ()
428 | local auraInfo = addAuraMap[1] and C_Spell.GetSpellInfo(addAuraMap[1])
429 | local abilityInfo = addAuraMap[2] and C_Spell.GetSpellInfo(addAuraMap[2])
430 | if auraInfo and abilityInfo then
431 | LBA.AddAuraMap(auraInfo.spellID, abilityInfo.spellID)
432 | addAuraMap[1] = nil
433 | addAuraMap[2] = nil
434 | end
435 | end,
436 | },
437 | Mappings = {
438 | name = L["Extra aura displays"],
439 | type = "group",
440 | order = order(),
441 | inline = true,
442 | args = {},
443 | plugins = {},
444 | }
445 | }
446 | },
447 | IgnoreGroup = {
448 | type = "group",
449 | name = L["Ignored spell IDs"],
450 | order = order(),
451 | inline = false,
452 | args = {
453 | ignoreAbility = {
454 | name = L["Add spell ID"],
455 | type = "input",
456 | width = 1,
457 | order = order(),
458 | get =
459 | function ()
460 | if addIgnoreAbility then
461 | local info = C_Spell.GetSpellInfo(addIgnoreAbility)
462 | return ("%s (%s)"):format(info.name, info.spellID) .. "\0" .. addIgnoreAbility
463 | end
464 | end,
465 | set =
466 | function (_, v)
467 | local info = C_Spell.GetSpellInfo(v)
468 | addIgnoreAbility = info and info.spellID or nil
469 | end,
470 | control = 'LBAInputFocus',
471 | validate = ValidateSpellValue,
472 | },
473 | AddButton = {
474 | name = ADD,
475 | type = "execute",
476 | width = 1,
477 | order = order(),
478 | disabled =
479 | function ()
480 | if addIgnoreAbility then
481 | return not C_Spell.GetSpellInfo(addIgnoreAbility)
482 | end
483 | end,
484 | func =
485 | function ()
486 | local info = addIgnoreAbility and C_Spell.GetSpellInfo(addIgnoreAbility)
487 | if info then
488 | LBA.SetIgnoreSpell(info.spellID, { ability = true })
489 | addIgnoreAbility = nil
490 | end
491 | end,
492 | },
493 | Abilities = {
494 | name = L["Ignored abilities"],
495 | type = "group",
496 | order = order(),
497 | inline = true,
498 | args = {},
499 | plugins = {},
500 | }
501 | }
502 | },
503 | },
504 | }
505 |
506 | local function GenerateOptions()
507 | local auraMapList = LBA.GetAuraMapList()
508 | local auraMaps = { }
509 | for i, entry in ipairs(auraMapList) do
510 | auraMaps["mapAura"..i] = {
511 | order = 10*i+1,
512 | name = LBA.SpellString(entry[1], entry[2]),
513 | type = "description",
514 | image = C_Spell.GetSpellTexture(entry[1] or entry[2]),
515 | imageWidth = 22,
516 | imageHeight = 22,
517 | width = 1.4,
518 | }
519 | auraMaps["onText"..i] = {
520 | order = 10*i+2,
521 | name = GRAY_FONT_COLOR:WrapTextInColorCode(L["on"]),
522 | type = "description",
523 | width = 0.15,
524 | }
525 | auraMaps["mapAbility"..i] = {
526 | order = 10*i+3,
527 | name = LBA.SpellString(entry[3], entry[4]),
528 | type = "description",
529 | image = C_Spell.GetSpellTexture(entry[3] or entry[4]),
530 | imageWidth = 22,
531 | imageHeight = 22,
532 | width = 1.4,
533 | }
534 | auraMaps["delete"..i] = {
535 | order = 10*i+4,
536 | name = DELETE,
537 | type = "execute",
538 | func = function () LBA.RemoveAuraMap(entry[1], entry[3]) end,
539 | width = 0.45,
540 | }
541 | end
542 | options.args.MappingGroup.args.Mappings.plugins.auraMaps = auraMaps
543 |
544 | local ignoreSpellList = {}
545 | local cc = ContinuableContainer:Create()
546 | for spellID, spellIgnoreData in pairs(LBA.db.profile.ignoreSpells) do
547 | local spell = Spell:CreateFromSpellID(spellID)
548 | if not spell:IsSpellEmpty() then
549 | if WOW_PROJECT_ID ~= 1 then
550 | spell.IsDataEvictable = function () return true end
551 | spell.IsItemDataCached = spell.IsSpellDataCached
552 | spell.ContinueWithCancelOnItemLoad = spell.ContinueWithCancelOnSpellLoad
553 | end
554 | cc:AddContinuable(spell)
555 | local data = CopyTable(spellIgnoreData)
556 | data.spell = spell
557 | table.insert(ignoreSpellList, data)
558 | end
559 | end
560 |
561 | local ignoreAbilities = {}
562 | local function ignoreSort(a, b) return a.spell:GetSpellName() < b.spell:GetSpellName() end
563 |
564 | cc:ContinueOnLoad(
565 | function ()
566 | table.sort(ignoreSpellList, ignoreSort)
567 | for i, data in ipairs(ignoreSpellList) do
568 | local spellName = data.spell:GetSpellName()
569 | local spellID = data.spell:GetSpellID()
570 | local newData = CopyTable(data)
571 | ignoreAbilities["spell"..i] = {
572 | name = format("%s (%d)",
573 | NORMAL_FONT_COLOR:WrapTextInColorCode(spellName),
574 | spellID),
575 | type = "description",
576 | image = C_Spell.GetSpellTexture(spellID),
577 | imageWidth = 22,
578 | imageHeight = 22,
579 | width = 1.5,
580 | order = 10*i+1,
581 | }
582 | ignoreAbilities["ability"..i] = {
583 | name = SPELLS,
584 | desc = L["Spells and abilities on your action bars"],
585 | type = "toggle",
586 | order = 10*i+2,
587 | width = 0.5,
588 | get = function () return data.ability == true end,
589 | set =
590 | function (info, val)
591 | newData.ability = val and true or nil
592 | LBA.SetIgnoreSpell(spellID, newData)
593 | end
594 | }
595 | ignoreAbilities["player"..i] = {
596 | name = PLAYER,
597 | desc = L["Buffs and debuffs on player unit"],
598 | type = "toggle",
599 | order = 10*i+3,
600 | width = 0.5,
601 | get = function () return data.player == true end,
602 | set =
603 | function (info, val)
604 | newData.player = val and true or nil
605 | LBA.SetIgnoreSpell(spellID, newData)
606 | end
607 | }
608 | ignoreAbilities["unit"..i] = {
609 | name = TARGET,
610 | type = "toggle",
611 | desc = L["Buffs and debuffs on target unit"],
612 | order = 10*i+4,
613 | width = 0.5,
614 | get = function () return data.unit == true end,
615 | set =
616 | function (info, val)
617 | newData.unit = val and true or nil
618 | LBA.SetIgnoreSpell(spellID, newData)
619 | end
620 | }
621 | ignoreAbilities["delete"..i] = {
622 | name = DELETE,
623 | type = "execute",
624 | func = function () LBA.RemoveIgnoreSpell(data.spell:GetSpellID()) end,
625 | width = 0.5,
626 | order = 10*i+6,
627 | }
628 | end
629 | options.args.IgnoreGroup.args.Abilities.plugins.ignoreAbilites = ignoreAbilities
630 | end)
631 | return options
632 | end
633 |
634 | -- The sheer amount of crap required here is ridiculous. I bloody well hate
635 | -- frameworks, just give me components I can assemble. Dot-com weenies ruined
636 | -- everything, even WoW.
637 |
638 | local AceConfig = LibStub("AceConfig-3.0")
639 | local AceConfigCmd = LibStub("AceConfigCmd-3.0")
640 | local AceConfigRegistry = LibStub("AceConfigRegistry-3.0")
641 | local AceConfigDialog = LibStub("AceConfigDialog-3.0")
642 | local AceDBOptions = LibStub("AceDBOptions-3.0")
643 |
644 | -- AddOns are listed in the Blizzard panel in the order they are
645 | -- added, not sorted by name. In order to mostly get them to
646 | -- appear in the right order, add the main panel when loaded.
647 |
648 | AceConfig:RegisterOptionsTable(addonName, GenerateOptions, { "litebuttonauras", "lba" })
649 | local optionsPanel, category = AceConfigDialog:AddToBlizOptions(addonName)
650 |
651 | function LBA.InitializeGUIOptions()
652 | local profileOptions = AceDBOptions:GetOptionsTable(LBA.db)
653 | AceConfig:RegisterOptionsTable(addonName.."Profiles", profileOptions)
654 | AceConfigDialog:AddToBlizOptions(addonName.."Profiles", profileOptions.name, addonName)
655 | end
656 |
657 | function LBA.OpenOptions()
658 | Settings.OpenToCategory(category)
659 | end
660 |
661 | LiteButtonAuras_AddonCompartmentFunc = function () LBA.OpenOptions() end
662 |
--------------------------------------------------------------------------------
/Overlay.lua:
--------------------------------------------------------------------------------
1 | --[[----------------------------------------------------------------------------
2 |
3 | LiteButtonAuras
4 | Copyright 2021 Mike "Xodiv" Battersby
5 |
6 | Code for one overlay frame on top of a button. Most of this code is the
7 | logic for what to display depending on what auras are in LBA.state, see
8 | LiteButtonAurasOverlayMixin:Update() for the entry point.
9 |
10 | ----------------------------------------------------------------------------]]--
11 |
12 | local _, LBA = ...
13 |
14 | local C_Spell = LBA.C_Spell or C_Spell
15 | local C_Item = LBA.C_Item or C_Item
16 |
17 | local LibBG = LibStub("LibButtonGlow-1.0")
18 |
19 | local MasqueTextureFormat = "Interface/AddOns/Masque/Textures/%s/AutoCast-Mask"
20 |
21 |
22 | --[[------------------------------------------------------------------------]]--
23 |
24 | -- Cache a some things to be faster. This is annoying but it's really a lot
25 | -- faster. Only do this for things that are called in the event loop otherwise
26 | -- it's a pain to maintain.
27 |
28 | local C_ActionBar = C_ActionBar
29 | local DebuffTypeColor = DebuffTypeColor
30 | local GetActionText = GetActionText
31 | local GetCVarBool = GetCVarBool
32 | local GetMacroBody = GetMacroBody
33 | local GetMacroItem = GetMacroItem
34 | local GetMacroSpell = GetMacroSpell
35 | local GetModifiedClick = GetModifiedClick
36 | local GetTime = GetTime
37 | local IsModifiedClick = IsModifiedClick
38 | local IsSpellOverlayed = IsSpellOverlayed
39 | local PixelUtil = PixelUtil
40 | local SecureCmdOptionParse = SecureCmdOptionParse
41 | local UnitCanAttack = UnitCanAttack
42 | local UnitExists = UnitExists
43 | local UnitIsFriend = UnitIsFriend
44 | local WOW_PROJECT_ID = WOW_PROJECT_ID
45 |
46 | --[[------------------------------------------------------------------------]]--
47 |
48 | -- LBA matches auras by name, but the profile auraMap is by ID so that it works
49 | -- in all locales. Translate it into the names at load time and when the player
50 | -- adds more mappings. Also invert so we don't have to loop in overlay update.
51 |
52 | LBA.AuraMap = {}
53 |
54 | function LBA.UpdateAuraMap()
55 | LBA.AuraMap = {}
56 | for showAura, onAbilityTable in pairs(LBA.db.profile.auraMap) do
57 | if type(showAura) == 'number' then
58 | showAura = C_Spell.GetSpellName(showAura)
59 | end
60 | for _, onAbility in ipairs(onAbilityTable) do
61 | if type(onAbility) == 'number' then
62 | onAbility = C_Spell.GetSpellName(onAbility)
63 | end
64 | if showAura and onAbility then
65 | LBA.AuraMap[onAbility] = LBA.AuraMap[onAbility] or {}
66 | table.insert(LBA.AuraMap[onAbility], showAura)
67 | end
68 | end
69 | end
70 | end
71 |
72 |
73 | --[[------------------------------------------------------------------------]]--
74 |
75 | -- This is wrong for any kind of complex macro that contains multiple commands
76 | -- that execute, or one command that executes and has no conditions but then
77 | -- subsequent commands with conditions that don't. But it should be good enough
78 | -- for basic macros that do CC and interrupts, and a full macro parser would be
79 | -- complex. And not significantly better since you can't tell what spell is
80 | -- going to end the macro from the client.
81 |
82 | -- I tried caching the gmatch split but it wasn't any faster.
83 |
84 | local function GetMacroUnit(macroIdentifier)
85 | local macroBody = GetMacroBody(macroIdentifier)
86 | if macroBody == nil then return end
87 |
88 | for cmd, conditionsAndArgs in macroBody:gmatch("/(%w+)%s+([^\n]+)") do
89 | if cmd == "cast" or cmd == "use" then
90 | local result, unit = SecureCmdOptionParse(conditionsAndArgs)
91 | if result then
92 | return unit
93 | end
94 | end
95 | end
96 | end
97 |
98 |
99 | --[[------------------------------------------------------------------------]]--
100 |
101 | LiteButtonAurasOverlayMixin = {}
102 |
103 | function LiteButtonAurasOverlayMixin:OnLoad()
104 | -- Bump it so it's on top of the cooldown frame, otherwise the individual
105 | -- bar integration will need to adjust the level accordingly
106 | local parent = self:GetParent()
107 | if parent.cooldown then
108 | self:SetFrameLevel(parent.cooldown:GetFrameLevel() + 1)
109 | end
110 | self:Style()
111 | end
112 |
113 | function LiteButtonAurasOverlayMixin:StyleMasqueOverrides(parent, useTexture)
114 | if parent.__MSQ_Enabled then
115 | if useTexture and parent.__MSQ_Shape and parent.__MSQ_Shape ~= "Blizzard" then
116 | self.Glow:SetTexture(string.format(MasqueTextureFormat, parent.__MSQ_Shape))
117 | end
118 | if parent.__MSQ_Scale then
119 | self:SetScale(parent.__MSQ_Scale)
120 | end
121 | end
122 | end
123 |
124 | function LiteButtonAurasOverlayMixin:Style()
125 | local p = LBA.db.profile
126 |
127 | local parent = self:GetParent()
128 | PixelUtil.SetSize(self, parent:GetSize())
129 |
130 | local point, x, y, justifyH
131 |
132 | self.Timer:SetFont(p.fontPath, p.fontSize, p.fontFlags)
133 | point, x, y, justifyH = unpack(LBA.anchorSettings[p.timerAnchor])
134 | self.Timer:ClearAllPoints()
135 | self.Timer:SetPoint(point, self, x*p.timerAdjust, y*p.timerAdjust)
136 | self.Timer:SetJustifyH(justifyH)
137 |
138 | self.Stacks:SetFont(p.fontPath, p.fontSize, p.fontFlags)
139 | point, x, y, justifyH = unpack(LBA.anchorSettings[p.stacksAnchor])
140 | self.Stacks:ClearAllPoints()
141 | self.Stacks:SetPoint(point, self, x*p.stacksAdjust, y*p.stacksAdjust)
142 | self.Stacks:SetJustifyH(justifyH)
143 |
144 | -- Defaults before Masque gets its dirty mitts on things
145 | self.Glow:SetTexture(p.glowTexture)
146 | self.Glow:SetAlpha(p.glowAlpha)
147 | self:SetScale(1)
148 |
149 | self:StyleMasqueOverrides(parent, p.glowUseMasque)
150 | end
151 |
152 | -- From: https://warcraft.wiki.gg/wiki/UnitId
153 | -- Not all units make sense to care about, nobody is going to write [@raid23]
154 | -- The soft targeting isn't really valid either, all of the cases I think we
155 | -- care about are just covered by @target.
156 |
157 | local ValidTrackedUnits = {
158 | "arena1", "arena2", "arena3", "arena4", "arena5",
159 | "boss1", "boss2", "boss3", "boss4", "boss5", "boss6", "boss7", "boss8",
160 | "party1", "party2", "party3", "party4",
161 | }
162 |
163 | -- Assumes player, pet, mouseover, focus and target are already watched. This
164 | -- is slow don't call this very often.
165 |
166 | function LiteButtonAurasOverlayMixin:GetTrackedUnits()
167 | local type = self:GetActionInfo()
168 | local trackedUnits = {}
169 | if type == 'macro' then
170 | local macroName = GetActionText(self:GetActionID())
171 | local macroBody = GetMacroBody(macroName)
172 | if macroBody then
173 | for conditionExpr in macroBody:gmatch('%[(.-)%]') do
174 | for condition in conditionExpr:gmatch('[^,]+') do
175 | local unit
176 | if condition:sub(1,1) == '@' then
177 | unit = condition:sub(2)
178 | elseif condition:sub(1,7) == 'target=' then
179 | unit = condition:sub(8)
180 | end
181 | if unit and tContains(ValidTrackedUnits, unit) then
182 | trackedUnits[unit] = true
183 | end
184 | end
185 | end
186 | end
187 | end
188 | return trackedUnits
189 | end
190 |
191 | -- In an ideal world GetActionInfo would return the unit as well. Or there
192 | -- would be a GetActionUnit function. This is a hack to try to figure it
193 | -- out in a limited fashion. If this returns something that's not in
194 | -- self:GetTrackedUnits() we could be in trouble.
195 |
196 | function LiteButtonAurasOverlayMixin:GetActionUnit()
197 |
198 | local actionID = self:GetActionID()
199 |
200 | if self:GetActionInfo() == 'macro' then
201 | local macroName = GetActionText(actionID)
202 | local unit = GetMacroUnit(macroName)
203 | if unit then
204 | return unit
205 | end
206 | end
207 |
208 | -- Adapted from SecureButton_GetModifiedUnit
209 |
210 | if C_ActionBar.IsHarmfulAction(actionID, true) then
211 | -- You can mouseover cast by enabling and either setting a key, OR by
212 | -- setting no key in which case it always applies. In both cases it
213 | -- will fall through to target.
214 | local useMouseoverCasting = GetCVarBool('enableMouseoverCast') and
215 | (GetModifiedClick('MOUSEOVERCAST') == "NONE" or
216 | IsModifiedClick('MOUSEOVERCAST'))
217 |
218 | if useMouseoverCasting and UnitExists('mouseover') then
219 | if not UnitIsFriend('player', 'mouseover') then
220 | return 'mouseover'
221 | end
222 | end
223 |
224 | -- Unlike mouseover, requires a modifier key and no fallthrough.
225 | if IsModifiedClick('FOCUSCAST') then
226 | return 'focus'
227 | end
228 | end
229 |
230 | return 'target'
231 | end
232 |
233 | -- This could be optimized (?) slightly be checking if type, id, subType
234 | -- are all the same as before and doing nothing
235 |
236 | function LiteButtonAurasOverlayMixin:SetUpAction()
237 |
238 | local type, id, subType = self:GetActionInfo()
239 |
240 | if type == 'spell' then
241 | self.name = C_Spell.GetSpellName(id)
242 | self.spellID = id
243 | self.type = type
244 | return
245 | end
246 |
247 | if type == 'item' then
248 | self.name, self.spellID = C_Item.GetItemSpell(id)
249 | self.type = type
250 | return
251 | end
252 |
253 | if type == 'macro' then
254 | if subType == 'spell' then
255 | self.spellID = id
256 | self.name = C_Spell.GetSpellName(self.spellID)
257 | self.type = subType
258 | return
259 | elseif subType == 'item' then
260 | -- 10.2 GetActionInfo() seems bugged for this case. In an ideal
261 | -- world id would be the itemID but it seemds to be actionID-1.
262 | -- This workaround assumes no two macros have the same name. Maybe
263 | -- there's a better way.
264 | local actionID = self:GetActionID()
265 | if actionID then
266 | local macroName = GetActionText(actionID)
267 | local macroID = GetMacroIndexByName(macroName or "")
268 | if macroID then
269 | local _, itemLink = GetMacroItem(macroID)
270 | if itemLink then
271 | self.name, self.spellID = C_Item.GetItemSpell(itemLink)
272 | end
273 | end
274 | self.type = subType
275 | return
276 | end
277 | elseif not subType then
278 | local itemName = GetMacroItem(id)
279 | if itemName then
280 | local name, spellID = C_Item.GetItemSpell(itemName)
281 | self.spellID = spellID
282 | self.name = name or itemName
283 | self.type = 'item'
284 | return
285 | end
286 | local spellID = GetMacroSpell(id)
287 | if spellID then
288 | self.spellID = spellID
289 | self.name = C_Spell.GetSpellName(spellID)
290 | self.type = 'spell'
291 | return
292 | end
293 | end
294 | end
295 |
296 | self.spellID = nil
297 | self.name = nil
298 | self.type = nil
299 | end
300 |
301 | function LiteButtonAurasOverlayMixin:IsKnown()
302 | if self.type == 'item' then
303 | -- Assume if you have an item on your bars you know it. Could check
304 | -- the owned item count but it would only matter if an item was an
305 | -- interrupt or soothe, which is always false.
306 | return true
307 | elseif not self.spellID then
308 | return false
309 | elseif C_SpellBook and C_SpellBook.FindSpellBookSlotForSpell then
310 | -- This is trying to account for Pet spells as well which don't count
311 | -- as IsPlayerSpell() or IsSpellKnown(). I am very much hoping this is not
312 | -- super slow.
313 | return C_SpellBook.FindSpellBookSlotForSpell(self.spellID) ~= nil
314 | else
315 | return true
316 | end
317 | end
318 |
319 | function LiteButtonAurasOverlayMixin:IsIgnoreAbility()
320 | local p = LBA.db.profile
321 | if p.ignoreSpells[self.spellID] and p.ignoreSpells[self.spellID].ability == true then
322 | return true
323 | end
324 | return false
325 | end
326 |
327 | function LiteButtonAurasOverlayMixin:GetMatchingAura(t)
328 | if LBA.AuraMap[self.name] then
329 | for _, extraAuraName in ipairs(LBA.AuraMap[self.name]) do
330 | if t[extraAuraName] then
331 | return t[extraAuraName]
332 | end
333 | end
334 | end
335 | if self:IsIgnoreAbility(t) then
336 | return
337 | elseif LBA.db.profile.defaultNameMatching and t[self.name] then
338 | return t[self.name]
339 | end
340 | end
341 |
342 | function LiteButtonAurasOverlayMixin:AlreadyOverlayed()
343 | if WOW_PROJECT_ID == 1 then
344 | return (self.spellID and IsSpellOverlayed(self.spellID))
345 | else
346 | local parent = self:GetParent()
347 | return (parent.overlay and parent.overlay:IsShown())
348 | end
349 | end
350 |
351 | function LiteButtonAurasOverlayMixin:Update(stateOnly)
352 | local show = false
353 |
354 | self.expireTime = nil
355 | self.stackCount = nil
356 | self.displayGlow = nil
357 | self.displaySuggestion = nil
358 |
359 | if self:HasAction() then
360 |
361 | -- Even though the action might be the same, what it contains could have
362 | -- changed due to the dynamic nature of macros and some spells.
363 | if not stateOnly then
364 | self:SetUpAction()
365 | end
366 |
367 | -- Because mouseover cast and focus cast are very dynamic based on
368 | -- modifier keypress, this can't be done in SetUpAction(), even though
369 | -- it's much slower than I'd like for something in the inner loop.
370 | local destUnit = self:GetActionUnit()
371 |
372 | -- It's worth keeping in mind that there are two units per spell, source
373 | -- and dest. Source is nearly always player.
374 |
375 | if self:IsKnown() then
376 | local destOk = LBA.state[destUnit] ~= nil
377 | -- These are theoretically in priority order but I haven't put a
378 | -- lot of thought into it because the overlap cases are super rare.
379 | if destOk and self:TrySetAsSoothe(destUnit) then
380 | show = true
381 | elseif destOk and self:TrySetAsInterrupt(destUnit) then
382 | show = true
383 | elseif destOk and self:TrySetAsHostileDispel(destUnit) then
384 | show = true
385 | elseif destOk and self:TrySetAsTaunt(destUnit) then
386 | show = true
387 | elseif self:TrySetAsPlayerBuff() then
388 | show = true
389 | elseif self:TrySetAsPlayerTotem() then
390 | show = true
391 | elseif self:TrySetAsWeaponEnchant() then
392 | show = true
393 | elseif destOk and self:TrySetAsDebuff(destUnit) then
394 | show = true
395 | elseif self:TrySetAsPetBuff() then
396 | show = true
397 | end
398 | end
399 | end
400 |
401 | self:ShowGlow(self.displayGlow and not self:AlreadyOverlayed())
402 | self:ShowTimer(self.expireTime ~= nil and LBA.db.profile.showTimers)
403 | self:ShowStacks(self.stackCount ~= nil and LBA.db.profile.showStacks)
404 | self:ShowSuggestion(self.displaySuggestion and LBA.db.profile.showSuggestions)
405 | self:SetShown(show)
406 | end
407 |
408 |
409 | -- Aura Config -----------------------------------------------------------------
410 |
411 | -- auraData = {
412 | -- applications = 0,
413 | -- auraInstanceID = 154047,
414 | -- canApplyAura = true,
415 | -- duration = 3600,
416 | -- expirationTime = 9109.109,
417 | -- icon = 136051,
418 | -- isBossAura = false,
419 | -- isFromPlayerOrPlayerPet = true,
420 | -- isHarmful = false,
421 | -- isHelpful = true,
422 | -- isNameplateOnly = false,
423 | -- isRaid = false,
424 | -- isStealable = false
425 | -- name = "Lightning Shield",
426 | -- nameplateShowAll = false,
427 | -- nameplateShowPersonal = false,
428 | -- points = { },
429 | -- sourceUnit = "player",
430 | -- spellId = 192106,
431 | -- timeMod = 1,
432 | -- }
433 |
434 | function LiteButtonAurasOverlayMixin:SetAsAuraCommon(auraData)
435 | -- Anything that's too short is just annoying
436 | if auraData.duration > 0 and auraData.duration < LBA.db.profile.minAuraDuration then
437 | return
438 | end
439 | self.displayGlow = true
440 | if auraData.expirationTime and auraData.expirationTime ~= 0 then
441 | self.expireTime = auraData.expirationTime
442 | self.timeMod = auraData.timeMod
443 | end
444 | if auraData.applications and auraData.applications > 1 then
445 | self.stackCount = auraData.applications
446 | end
447 | end
448 |
449 | function LiteButtonAurasOverlayMixin:SetAsPlayerBuff(auraData)
450 | local color = LBA.db.profile.color.buff
451 | self.Glow:SetVertexColor(color.r, color.g, color.b)
452 | self:SetAsAuraCommon(auraData)
453 | end
454 |
455 | function LiteButtonAurasOverlayMixin:TrySetAsPlayerBuff()
456 | local aura = self:GetMatchingAura(LBA.state.player.buffs)
457 | if aura then
458 | self:SetAsPlayerBuff(aura)
459 | return true
460 | end
461 | end
462 |
463 | function LiteButtonAurasOverlayMixin:SetAsPetBuff(auraData)
464 | local color = LBA.db.profile.color.petBuff
465 | self.Glow:SetVertexColor(color.r, color.g, color.b)
466 | self:SetAsAuraCommon(auraData)
467 | end
468 |
469 | function LiteButtonAurasOverlayMixin:TrySetAsPetBuff()
470 | if LBA.db.profile.playerPetBuffs then
471 | local aura = self:GetMatchingAura(LBA.state.pet.buffs)
472 | if aura and aura.sourceUnit == 'player' then
473 | self:SetAsPetBuff(aura)
474 | return true
475 | end
476 | end
477 | end
478 |
479 | function LiteButtonAurasOverlayMixin:SetAsDebuff(auraData)
480 | local color = LBA.db.profile.color.debuff
481 | self.Glow:SetVertexColor(color.r, color.g, color.b)
482 | self:SetAsAuraCommon(auraData)
483 | end
484 |
485 | function LiteButtonAurasOverlayMixin:TrySetAsDebuff(unit)
486 | local aura = self:GetMatchingAura(LBA.state[unit].debuffs)
487 | if aura then
488 | self:SetAsDebuff(aura)
489 | return true
490 | end
491 | end
492 |
493 | function LiteButtonAurasOverlayMixin:TrySetAsWeaponEnchant()
494 | if LBA.state.player.weaponEnchants[self.name] then
495 | self:SetAsPlayerBuff(LBA.state.player.weaponEnchants[self.name])
496 | return true
497 | end
498 | end
499 |
500 | -- Totem Config ----------------------------------------------------------------
501 |
502 | function LiteButtonAurasOverlayMixin:SetAsPlayerTotem(expireTime)
503 | local color = LBA.db.profile.color.buff
504 | self.Glow:SetVertexColor(color.r, color.g, color.b)
505 | self.expireTime, self.modTime = expireTime, nil
506 | self.displayGlow = true
507 | end
508 |
509 | function LiteButtonAurasOverlayMixin:TrySetAsPlayerTotem()
510 | if self:IsIgnoreAbility() or not LBA.db.profile.defaultNameMatching then
511 | return
512 | elseif LBA.state.player.totems[self.name] then
513 | self:SetAsPlayerTotem(LBA.state.player.totems[self.name])
514 | return true
515 | end
516 | end
517 |
518 |
519 | -- Interrupt Config ------------------------------------------------------------
520 |
521 | -- Assuming no interrupt spells are of the "enabled" type
522 | -- https://wowpedia.fandom.com/wiki/API_GetSpellCooldown
523 |
524 | function LiteButtonAurasOverlayMixin:ReadyBefore(endTime)
525 | if endTime == 0 then
526 | -- Indefinite enrage, such as from the Raging M+ affix
527 | return true
528 | else
529 | local info = C_Spell.GetSpellCooldown(self.spellID)
530 | return info and info.startTime + info.duration < endTime
531 | end
532 | end
533 |
534 | function LiteButtonAurasOverlayMixin:TrySetAsInterrupt(unit)
535 | if self.name and LBA.Interrupts[self.name] then
536 | if LBA.state[unit].interrupt then
537 | local castEnds = LBA.state[unit].interrupt
538 | if self:ReadyBefore(castEnds) then
539 | self.expireTime = castEnds
540 | self.displaySuggestion = true
541 | return true
542 | end
543 | end
544 | end
545 | end
546 |
547 | -- Soothe Config ---------------------------------------------------------------
548 |
549 | --[[
550 | -- Unused, Soothe is suggestion only now
551 | function LiteButtonAurasOverlayMixin:SetAsSoothe(auraData)
552 | local color = LBA.db.profile.color.enrage
553 | self.Glow:SetVertexColor(color.r, color.g, color.b, 0.7)
554 | self:SetAsAuraCommon(auraData)
555 | end
556 | ]]
557 |
558 | function LiteButtonAurasOverlayMixin:IsSoothe()
559 | -- Note this is handling self.name == nil case as well
560 | local v = LBA.Soothes[self.name]
561 | if type(v) == 'function' then
562 | return not not v()
563 | else
564 | return not not v
565 | end
566 | end
567 |
568 | function LiteButtonAurasOverlayMixin:TrySetAsSoothe(unit)
569 | if not self:IsSoothe() then return end
570 | if not UnitCanAttack('player', unit) then return end
571 |
572 | for _, auraData in pairs(LBA.state[unit].buffs) do
573 | if auraData.isStealable and auraData.dispelName == "" and self:ReadyBefore(auraData.expirationTime) then
574 | self.expireTime = auraData.expirationTime
575 | self.displaySuggestion = true
576 | return true
577 | end
578 | end
579 | end
580 |
581 | -- Taunt Config ----------------------------------------------------------------
582 |
583 | function LiteButtonAurasOverlayMixin:TrySetAsTaunt(unit)
584 | if self.name and LBA.Taunts[self.name] and LBA.state[unit].taunt then
585 | self:SetAsDebuff(LBA.state[unit].taunt)
586 | return true
587 | end
588 | end
589 |
590 | -- Dispel Config ---------------------------------------------------------------
591 |
592 | function LiteButtonAurasOverlayMixin:SetAsHostileDispel(auraData)
593 | local color = DebuffTypeColor[auraData.dispelName or ""]
594 | self.Glow:SetVertexColor(color.r, color.g, color.b)
595 | self:SetAsAuraCommon(auraData)
596 | end
597 |
598 | function LiteButtonAurasOverlayMixin:TrySetAsHostileDispel(unit)
599 | if not self.name then
600 | return
601 | end
602 |
603 | if not UnitCanAttack('player', unit) then
604 | return
605 | end
606 |
607 | local dispels = LBA.HostileDispels[self.name]
608 | if dispels then
609 | for dispelName in pairs(dispels) do
610 | for _, auraData in pairs(LBA.state[unit].buffs) do
611 | if auraData.dispelName == dispelName then
612 | self:SetAsHostileDispel(auraData)
613 | self.displaySuggestion = true
614 | return true
615 | end
616 | end
617 | end
618 | end
619 | end
620 |
621 | -- Glow Display ----------------------------------------------------------------
622 |
623 | function LiteButtonAurasOverlayMixin:ShowGlow(isShown)
624 | self.Glow:SetShown(isShown)
625 | end
626 |
627 | -- Suggestion Display-----------------------------------------------------------
628 |
629 | if ActionButtonSpellAlertManager then
630 | function LiteButtonAurasOverlayMixin:ShowSuggestion(isShown)
631 | if isShown then
632 | ActionButtonSpellAlertManager:ShowAlert(self)
633 | self.SpellActivationAlert.ProcStartFlipbook:SetAlpha(0)
634 | self.SpellActivationAlert.ProcLoop:Play()
635 | self.SpellActivationAlert:Show()
636 | else
637 | ActionButtonSpellAlertManager:HideAlert(self)
638 | end
639 | end
640 | elseif ActionButton_SetupOverlayGlow then
641 | function LiteButtonAurasOverlayMixin:ShowSuggestion(isShown)
642 | if isShown then
643 | -- Taken from ActionButton_ShowOverlayGlow(self) but we don't want the
644 | -- start animation because it takes 0.7s before the button starts to
645 | -- glow which is awful for time-sensitive things like interrupts (and
646 | -- in my opinion awful in general).
647 | ActionButton_SetupOverlayGlow(self)
648 | self.SpellActivationAlert.ProcStartFlipbook:SetAlpha(0)
649 | self.SpellActivationAlert.ProcLoop:Play()
650 | self.SpellActivationAlert:Show()
651 | else
652 | ActionButton_HideOverlayGlow(self)
653 | end
654 | end
655 | else
656 | function LiteButtonAurasOverlayMixin:ShowSuggestion(isShown)
657 | if isShown then
658 | LibBG.ShowOverlayGlow(self)
659 | else
660 | LibBG.HideOverlayGlow(self)
661 | end
662 | end
663 | end
664 |
665 |
666 | -- Count Display ---------------------------------------------------------------
667 |
668 | function LiteButtonAurasOverlayMixin:ShowStacks(isShown)
669 | if isShown then
670 | self.Stacks:SetText(self.stackCount)
671 | end
672 | self.Stacks:SetShown(isShown)
673 | end
674 |
675 |
676 | -- Timer Display ---------------------------------------------------------------
677 |
678 | local ceil = math.ceil
679 |
680 | local function TimerAbbrev(duration)
681 | if duration >= 86400 then
682 | return "%dd", ceil(duration/86400)
683 | elseif duration >= 3600 then
684 | return "%dh", ceil(duration/3600)
685 | elseif duration >= 60 then
686 | return "%dm", ceil(duration/60)
687 | elseif duration >= 3 or not LBA.db.profile.decimalTimers then
688 | return "%d", ceil(duration)
689 | else
690 | -- printf uses round (not available in lua) so do our own
691 | -- ceil and avoid a discontinuity at the break
692 | duration = ceil(duration*10)/10
693 | return "%.1f", duration
694 | end
695 | end
696 |
697 | -- BuffFrame does it this way, SetFormattedText on every frame. If its
698 | -- good enough for them it's good enough for me.
699 | --
700 | -- /console scriptprofile 1
701 | -- /reload
702 | --
703 | -- UpdateAddOnCPUUsage()
704 | -- t,n = GetFunctionCPUUsage(LiteButtonAurasOverlayMixin.UpdateTimer, true)
705 | -- print(t*1000/n) -> ~14 ns
706 | --
707 |
708 | function LiteButtonAurasOverlayMixin:UpdateTimer()
709 | local duration = self.expireTime - GetTime()
710 | if self.timeMod and self.timeMod > 0 then
711 | duration = duration / self.timeMod
712 | end
713 | if duration >= 0 then
714 | self.Timer:SetFormattedText(TimerAbbrev(duration))
715 | if LBA.db.profile.colorTimers then
716 | self.Timer:SetTextColor(LBA.TimerRGB(duration))
717 | else
718 | self.Timer:SetTextColor(1, 1, 1)
719 | end
720 | else
721 | self.Timer:Hide()
722 | self:SetScript('OnUpdate', nil)
723 | end
724 | end
725 |
726 | function LiteButtonAurasOverlayMixin:ShowTimer(isShown)
727 | if isShown then
728 | self:SetScript('OnUpdate', self.UpdateTimer)
729 | self.Timer:Show()
730 | else
731 | self:SetScript('OnUpdate', nil)
732 | self.Timer:Hide()
733 | end
734 | end
735 |
736 | function LiteButtonAurasOverlayMixin:Dump(force)
737 | if self.name or force then
738 | print(string.format("%d. %s = %s (%d)",
739 | self:GetActionID(),
740 | self:GetParent():GetName(),
741 | self.name or NONE,
742 | self.spellID or 0))
743 | end
744 | end
745 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------