Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 7 | Rilgamon-205066 | -- pong.wav source http://www.freesound.org/samplesViewSingle.php?id=88381 |
2 | Rilgamon-205066 | -- oops.wav, Laugh.wav, amazing.wav source ftp://ftp.team17.com/pub/t17/worms2/sounds/MKWorm.ZIP |
|
3 | Rilgamon-205066 | local addonname, addontable = ... |
|
4 | Rilgamon-205066 | local addon = LibStub("LibzzAddOnInit"):Init(...) |
|
5 | Rilgamon-205066 | local LBF = LibStub("LibButtonFacade", true) |
|
6 | Rilgamon-205066 | local LSM = LibStub("LibSharedMedia-3.0",true) |
|
7 | Rilgamon-205066 | local LBFGroup |
|
8 | Rilgamon-205066 | local L |
|
9 | Rilgamon-205066 | local button = {} |
|
10 | Rilgamon-205066 | local buttonCount = 0 |
|
11 | Rilgamon-205066 | local timeElapsed = 0 |
|
12 | Rilgamon-205066 | local buffs = {} |
|
13 | Rilgamon-205066 | local invSlot = 0 |
|
14 | Rilgamon-205066 | local auras = {} |
|
15 | Rilgamon-205066 | local enchantDuration = 1 |
|
16 | 9 | Rilgamon-205066 | local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges, hasThrownEnchant, thrownExpiration, thrownCharges |
17 | 7 | Rilgamon-205066 | local nameWeaponEnchant,iconWeaponEnchant,expirationTimeWeaponEnchant,countWeaponEnchant |
18 | Rilgamon-205066 | local idSpellCD, nameSpellCD, rankSpellCD, iconSpellCD, costSpellCD, isFunnelSpellCD, powerTypeSpellCD, castTimeSpellCD, minRangeSpellCD, maxRangeSpellCD, startSpellCD, durationSpellCD, enabledSpellCD |
|
19 | Rilgamon-205066 | local txt,index,lsort |
|
20 | Rilgamon-205066 | local tbl,ex = {},false |
|
21 | Rilgamon-205066 | local spellBook = {} |
|
22 | Rilgamon-205066 | local spellName, spellRank |
|
23 | Rilgamon-205066 | local checkTime, lastTime |
|
24 | Rilgamon-205066 | local spellInfoDB = {} |
|
25 | Rilgamon-205066 | local tooltipSort1, tooltipSort2,tooltipCount |
|
26 | Rilgamon-205066 | local whitelistAura = {} |
|
27 | Rilgamon-205066 | local buttonAnchor, buttonParentanchor |
|
28 | Rilgamon-205066 | local pb |
|
29 | Rilgamon-205066 | local buttonSpacing, buttonSpacing2 |
|
30 | Rilgamon-205066 | local scannedUnits = {} |
|
31 | Rilgamon-205066 | local _G = _G |
|
32 | Rilgamon-205066 | local pairs = pairs |
|
33 | Rilgamon-205066 | local type = type |
|
34 | Rilgamon-205066 | local tostring = tostring |
|
35 | Rilgamon-205066 | local GetTime = GetTime |
|
36 | Rilgamon-205066 | local GetInventoryItemTexture = GetInventoryItemTexture |
|
37 | Rilgamon-205066 | local GetWeaponEnchantInfo = GetWeaponEnchantInfo |
|
38 | Rilgamon-205066 | local GetSpellCooldown = GetSpellCooldown |
|
39 | Rilgamon-205066 | local GetSpellBookItemName = GetSpellBookItemName |
|
40 | Rilgamon-205066 | local IsUsableSpell = IsUsableSpell |
|
41 | Rilgamon-205066 | local IsSpellInRange = IsSpellInRange |
|
42 | Rilgamon-205066 | local UnitExists = UnitExists |
|
43 | Rilgamon-205066 | local UnitIsDeadOrGhost = UnitIsDeadOrGhost |
|
44 | Rilgamon-205066 | local UnitAura = UnitAura |
|
45 | Rilgamon-205066 | local PlaySoundFile = PlaySoundFile |
|
46 | Rilgamon-205066 | local PlaySound = PlaySound |
|
47 | Rilgamon-205066 | local UnitAffectingCombat = UnitAffectingCombat |
|
48 | Rilgamon-205066 | ||
49 | Rilgamon-205066 | local scanning = false |
|
50 | Rilgamon-205066 | addon['nextUpdate'] = 0 |
|
51 | Rilgamon-205066 | addon['nextEvent'] = 0 |
|
52 | Rilgamon-205066 | function addon:ADDON_LOADED() |
|
53 | Rilgamon-205066 | L = self['L'] |
|
54 | Rilgamon-205066 | addon:set("Debug",false) |
|
55 | Rilgamon-205066 | end |
|
56 | Rilgamon-205066 | ||
57 | Rilgamon-205066 | function addon:PLAYER_LOGIN() |
|
58 | Rilgamon-205066 | addon:checkDBDefault() |
|
59 | Rilgamon-205066 | if(LBF) then |
|
60 | Rilgamon-205066 | LBFGroup = LBF:Group(addon:GetName()) |
|
61 | Rilgamon-205066 | LBFGroup:Skin(addon['db']['global']['lbfSkin'] or "Blizzard",addon['db']['global']['lbfGloss'] or .4,addon['db']['global']['lbfBackdrop'],addon['db']['global']['lbfColors']) |
|
62 | Rilgamon-205066 | LBF:RegisterSkinCallback(addon:GetName(), function(a, SkinID, Gloss, Backdrop, Group, Button, Colors) |
|
63 | Rilgamon-205066 | addon['db']['global']['lbfSkin'] = SkinID ; |
|
64 | Rilgamon-205066 | addon['db']['global']['lbfGloss'] = Gloss ; |
|
65 | Rilgamon-205066 | addon['db']['global']['lbfBackdrop'] = Backdrop ; |
|
66 | Rilgamon-205066 | addon['db']['global']['lbfColors'] = Colors ; |
|
67 | Rilgamon-205066 | addon:updateBar(true) |
|
68 | Rilgamon-205066 | end, "1") |
|
69 | Rilgamon-205066 | end |
|
70 | Rilgamon-205066 | if(LSM) then |
|
71 | 9 | Rilgamon-205066 | LSM:Register("sound","ProcWatch Pong","Interface\\AddOns\\"..addon:GetName().."\\pong.ogg") |
72 | Rilgamon-205066 | LSM:Register("sound","ProcWatch Oops","Interface\\AddOns\\"..addon:GetName().."\\oops.ogg") |
|
73 | Rilgamon-205066 | LSM:Register("sound","ProcWatch Laugh","Interface\\AddOns\\"..addon:GetName().."\\Laugh.ogg") |
|
74 | Rilgamon-205066 | LSM:Register("sound","ProcWatch Amazing","Interface\\AddOns\\"..addon:GetName().."\\amazing.ogg") |
|
75 | 7 | Rilgamon-205066 | end |
76 | Rilgamon-205066 | addon['mainframe'] = addon:getMainframe() |
|
77 | Rilgamon-205066 | addon:checkDualskill() |
|
78 | Rilgamon-205066 | ||
79 | Rilgamon-205066 | addon:buildConfig() |
|
80 | Rilgamon-205066 | ||
81 | Rilgamon-205066 | addon:RegisterEvent("SPELL_UPDATE_COOLDOWN") |
|
82 | Rilgamon-205066 | addon:RegisterEvent("SPELLS_CHANGED","buildSpellBook") |
|
83 | Rilgamon-205066 | addon:RegisterEvent("PLAYER_TALENT_UPDATE","checkDualskill") |
|
84 | Rilgamon-205066 | addon:RegisterEvent("PLAYER_REGEN_ENABLED") |
|
85 | Rilgamon-205066 | addon:RegisterEvent("PLAYER_REGEN_DISABLED") |
|
86 | Rilgamon-205066 | addon['configDone'] = true |
|
87 | Rilgamon-205066 | ||
88 | Rilgamon-205066 | addon:SetScript("OnUpdate", function(self, elapsed) self:OnUpdate(elapsed) end) |
|
89 | Rilgamon-205066 | ||
90 | Rilgamon-205066 | addon:PLAYER_REGEN_ENABLED() |
|
91 | Rilgamon-205066 | end |
|
92 | Rilgamon-205066 | ||
93 | Rilgamon-205066 | local function resetDB() |
|
94 | Rilgamon-205066 | addon['db']['profile']['update'] = 0.2 |
|
95 | Rilgamon-205066 | addon['db']['global']['update'] = 0.2 |
|
96 | Rilgamon-205066 | end |
|
97 | Rilgamon-205066 | ||
98 | Rilgamon-205066 | function addon:checkUpdate() |
|
99 | Rilgamon-205066 | if(addon['db']['profile']['lastVersion'] and addon['db']['profile']['lastVersion'] ~= addon['AddOnTable']['version']) then |
|
100 | Rilgamon-205066 | if(addon['AddOnTable']['version'] == "1.4") then |
|
101 | Rilgamon-205066 | resetDB() |
|
102 | Rilgamon-205066 | end |
|
103 | Rilgamon-205066 | elseif(not addon['db']['profile']['lastVersion']) then |
|
104 | Rilgamon-205066 | resetDB() |
|
105 | Rilgamon-205066 | end |
|
106 | Rilgamon-205066 | -- print("v",addon['db']['profile']['lastVersion'],addon['AddOnTable']['version']) |
|
107 | Rilgamon-205066 | addon['db']['profile']['lastVersion'] = addon['AddOnTable']['version'] |
|
108 | Rilgamon-205066 | end |
|
109 | Rilgamon-205066 | ||
110 | Rilgamon-205066 | ||
111 | Rilgamon-205066 | function addon:buildConfig() |
|
112 | Rilgamon-205066 | addon['menu'] = addon:AddConfigMenu({ |
|
113 | Rilgamon-205066 | ['name'] = L['Spells'], |
|
114 | Rilgamon-205066 | ['order'] = 2, |
|
115 | Rilgamon-205066 | ['childGroups'] = 'tab', |
|
116 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
117 | Rilgamon-205066 | ['menuGet'] = "getPref2", |
|
118 | Rilgamon-205066 | ['menuSet'] = "setPref2" |
|
119 | Rilgamon-205066 | }) |
|
120 | Rilgamon-205066 | addon['whitelist'] = addon:AddConfigMenu({ |
|
121 | Rilgamon-205066 | ['name'] = L['Whitelist'], |
|
122 | Rilgamon-205066 | ['order'] = 1, |
|
123 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
124 | Rilgamon-205066 | ['menuGet'] = "getPref2", |
|
125 | Rilgamon-205066 | ['menuSet'] = "setPref2" |
|
126 | Rilgamon-205066 | },addon['menu']) |
|
127 | Rilgamon-205066 | addon['blacklist'] = addon:AddConfigMenu({ |
|
128 | Rilgamon-205066 | ['name'] = L['Blacklist'], |
|
129 | Rilgamon-205066 | ['order'] = 2, |
|
130 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
131 | Rilgamon-205066 | ['menuGet'] = "getPref2", |
|
132 | Rilgamon-205066 | ['menuSet'] = "setPref2" |
|
133 | Rilgamon-205066 | },addon['menu']) |
|
134 | Rilgamon-205066 | addon['spellsettings'] = addon:AddConfigMenu({ |
|
135 | Rilgamon-205066 | ['name'] = L['Spellsettings'], |
|
136 | Rilgamon-205066 | ['order'] = 2, |
|
137 | Rilgamon-205066 | ['childGroups'] = 'tab', |
|
138 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
139 | Rilgamon-205066 | ['menuGet'] = "getPref3", |
|
140 | Rilgamon-205066 | ['menuSet'] = "setPref3" |
|
141 | Rilgamon-205066 | }) |
|
142 | Rilgamon-205066 | addon['displaysetting'] = addon:AddConfigMenu({ |
|
143 | Rilgamon-205066 | ['name'] = L['Display'], |
|
144 | Rilgamon-205066 | ['order'] = 3, |
|
145 | Rilgamon-205066 | ['childGroups'] = 'tab', |
|
146 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
147 | Rilgamon-205066 | }) |
|
148 | Rilgamon-205066 | addon['listTools'] = addon:AddConfigMenu({ |
|
149 | Rilgamon-205066 | ['name'] = L['List Tools'], |
|
150 | Rilgamon-205066 | ['order'] = 3, |
|
151 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
152 | Rilgamon-205066 | },addon['menu']) |
|
153 | Rilgamon-205066 | addon['spelldefaults'] = addon:AddConfigMenu({ |
|
154 | Rilgamon-205066 | ['name'] = L['Defaults'], |
|
155 | Rilgamon-205066 | ['order'] = 4, |
|
156 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
157 | Rilgamon-205066 | ['menuGet'] = "getPref3", |
|
158 | Rilgamon-205066 | ['menuSet'] = "setPref3" |
|
159 | Rilgamon-205066 | },addon['spellsettings']) |
|
160 | Rilgamon-205066 | addon['spelllist'] = addon:AddConfigMenu({ |
|
161 | Rilgamon-205066 | ['name'] = L['Spellsettings'], |
|
162 | Rilgamon-205066 | ['order'] = 1, |
|
163 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
164 | Rilgamon-205066 | ['menuGet'] = "getPref3", |
|
165 | Rilgamon-205066 | ['menuSet'] = "setPref3" |
|
166 | Rilgamon-205066 | },addon['spellsettings']) |
|
167 | Rilgamon-205066 | addon['chargesSettings'] = addon:AddConfigMenu({ |
|
168 | Rilgamon-205066 | ['name'] = L['Charges'], |
|
169 | Rilgamon-205066 | ['order'] = 2, |
|
170 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
171 | Rilgamon-205066 | ['menuGet'] = "getPref5", |
|
172 | Rilgamon-205066 | ['menuSet'] = "setPref5" |
|
173 | Rilgamon-205066 | },addon['displaysetting']) |
|
174 | Rilgamon-205066 | addon['timerSettings'] = addon:AddConfigMenu({ |
|
175 | Rilgamon-205066 | ['name'] = L['Timer'], |
|
176 | Rilgamon-205066 | ['order'] = 3, |
|
177 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
178 | Rilgamon-205066 | ['menuGet'] = "getPref5", |
|
179 | Rilgamon-205066 | ['menuSet'] = "setPref5" |
|
180 | Rilgamon-205066 | },addon['displaysetting']) |
|
181 | Rilgamon-205066 | addon:AddConfigEntry("toggle","dragAble",L['Dragable'],L['This unlocks the spellbar'],2) |
|
182 | Rilgamon-205066 | addon:AddConfigEntry("toggle","showTooltip",L['Show Tooltip'],L['Shows the spells tooltip'],2) |
|
183 | Rilgamon-205066 | addon:AddConfigEntry("range","scale",L['Scale'],L['Scales the spellbar'],1,.25,2,.01,true) |
|
184 | Rilgamon-205066 | addon:AddConfigEntry("range","update",L['Refresh'],L['Sets Refreshrate of the spellbar.'],1,.1,2,.1,false) |
|
185 | Rilgamon-205066 | addon:AddConfigEntry("select","whitelist",L['Listmode'],L['Whitelist means only spells added to the whitelist are displayed and new spells are put on blacklist. Blacklist will add new spells to the whitelist.'],3,"buildSelect") |
|
186 | Rilgamon-205066 | addon:AddConfigEntry("select","sorting",L['Sorting'],L['Sort the displayed buffs'],3,"buildSort") |
|
187 | Rilgamon-205066 | addon:AddConfigEntry("toggle","reverse",L['Reverse'],L['Reverse the sorting.'],4) |
|
188 | Rilgamon-205066 | addon:AddConfigEntry("toggle","removeAura",L['Cancel Aura'],L['Allows Mouseclick to cancel a spell'],4) |
|
189 | Rilgamon-205066 | addon:AddConfigEntry("range","spacing",L['Spacing'],L['Sets the spacing between two spells'],5,-32,32,1,false) |
|
190 | Rilgamon-205066 | addon:AddConfigEntry("toggle","vertical",L['Vertical'],L['Display spells vertically'],6) |
|
191 | Rilgamon-205066 | addon:AddConfigEntry("toggle","growth",L['Growth'],L['Invert the growth direction of spells'],7) |
|
192 | Rilgamon-205066 | ||
193 | Rilgamon-205066 | addon:AddConfigEntry("toggle","charges",L['Charges'],L['Show charges'],1,nil,nil,nil,nil,addon['spelldefaults']) |
|
194 | Rilgamon-205066 | addon:AddConfigEntry("toggle","showTextTimer",L['Timer'],L['Show Text Timer'],4,nil,nil,nil,nil,addon['spelldefaults']) |
|
195 | Rilgamon-205066 | addon:AddConfigEntry("toggle","static",L['Static'],L['Show spell when inactive'],2,nil,nil,nil,nil,addon['spelldefaults']) |
|
196 | Rilgamon-205066 | addon:AddConfigEntry("toggle","playSound",L['Play Sound'],L['Play a sound when this spell is active'],5,nil,nil,nil,nil,addon['spelldefaults']) |
|
197 | Rilgamon-205066 | addon:AddConfigEntry("range","priority",L['Order'],L['Defines the priority on the spellbar.'],3,1,100,1,false,addon['spelldefaults']) |
|
198 | Rilgamon-205066 | addon:AddConfigEntry("select","soundEffect",L['Sound'],nil,6,"buildSoundlist",nil,nil,nil,addon['spelldefaults']) |
|
199 | Rilgamon-205066 | addon:AddConfigEntry("toggle","ignoreMeOmniCC",L['Disable OmniCC'],nil,7,nil,nil,nil,nil,addon['spelldefaults']) |
|
200 | Rilgamon-205066 | addon:AddConfigEntry("select","warning",L['Warning'],L['Show a warning when missing'],8,"buildWarning",nil,nil,nil,addon['spelldefaults']) |
|
201 | Rilgamon-205066 | addon:AddConfigEntry("toggle","warningOnly",L['Warning only'],L['Hide spell until warning'],9,nil,nil,nil,nil,addon['spelldefaults']) |
|
202 | Rilgamon-205066 | ||
203 | Rilgamon-205066 | addon:AddConfigEntry("execute","exe1",L['Reset to Blacklist'],L['All spells are moved to whitelist'],1,"resetToBlackList",nil,nil,nil,addon['listTools']) |
|
204 | Rilgamon-205066 | addon:AddConfigEntry("execute","exe2",L['Reset to Whitelist'],L['All spells are moved to blacklist'],2,"resetToWhiteList",nil,nil,nil,addon['listTools']) |
|
205 | Rilgamon-205066 | addon:AddConfigEntry("execute","exe3",L['Delete Blacklist'],L['All spells removed from blacklist'],3,"deleteBlackList",nil,nil,nil,addon['listTools']) |
|
206 | Rilgamon-205066 | addon:AddConfigEntry("execute","exe4",L['Delete Whitelist'],L['All spells removed from whitelist'],4,"deleteWhiteList",nil,nil,nil,addon['listTools']) |
|
207 | Rilgamon-205066 | ||
208 | Rilgamon-205066 | addon:AddConfigEntry("select","chargesFont",L['Font'],nil,1,"buildFontlist",nil,nil,nil,addon['chargesSettings']) |
|
209 | Rilgamon-205066 | addon:AddConfigEntry("range","chargesSize",L['Size'],nil,2,16,41,1,false,addon['chargesSettings']) |
|
210 | Rilgamon-205066 | addon:AddConfigEntry("color","chargesColor",L['Color'],nil,3, |
|
211 | Rilgamon-205066 | function() |
|
212 | Rilgamon-205066 | return addon['db']['global']['chargesColor'][1],addon['db']['global']['chargesColor'][2],addon['db']['global']['chargesColor'][3],addon['db']['global']['chargesColor'][4] |
|
213 | Rilgamon-205066 | end, |
|
214 | Rilgamon-205066 | function(self,a,b,c,d) |
|
215 | Rilgamon-205066 | addon['db']['global']['chargesColor'] = { a,b,c,d } |
|
216 | Rilgamon-205066 | addon:updateBar(true) |
|
217 | Rilgamon-205066 | end, |
|
218 | Rilgamon-205066 | nil,nil,addon['chargesSettings']) |
|
219 | Rilgamon-205066 | addon:AddConfigEntry("select","chargesAnchor",L['Anchor'],nil,4,"buildAnchor",nil,nil,nil,addon['chargesSettings']) |
|
220 | Rilgamon-205066 | addon:AddConfigEntry("range","xOffset",L['X-Offset'],nil,5,-64,64,1,false,addon['chargesSettings']) |
|
221 | Rilgamon-205066 | addon:AddConfigEntry("range","yOffset",L['Y-Offset'],nil,6,-64,64,1,false,addon['chargesSettings']) |
|
222 | Rilgamon-205066 | addon:AddConfigEntry("select","fontAnchorX",L['Font Anchor X'],nil,4,"buildFontAnchor",nil,nil,nil,addon['chargesSettings']) |
|
223 | Rilgamon-205066 | addon:AddConfigEntry("select","fontAnchorY",L['Font Anchor Y'],nil,4,"buildFontAnchorY",nil,nil,nil,addon['chargesSettings']) |
|
224 | Rilgamon-205066 | ||
225 | Rilgamon-205066 | addon:AddConfigEntry("select","timerFont",L['Font'],nil,1,"buildFontlist",nil,nil,nil,addon['timerSettings']) |
|
226 | Rilgamon-205066 | addon:AddConfigEntry("range","timerSize",L['Size'],nil,2,16,41,1,false,addon['timerSettings']) |
|
227 | Rilgamon-205066 | addon:AddConfigEntry("color","timerColor",L['Color'],nil,3, |
|
228 | Rilgamon-205066 | function() |
|
229 | Rilgamon-205066 | return addon['db']['global']['timerColor'][1],addon['db']['global']['timerColor'][2],addon['db']['global']['timerColor'][3],addon['db']['global']['timerColor'][4] |
|
230 | Rilgamon-205066 | end, |
|
231 | Rilgamon-205066 | function(self,a,b,c,d) |
|
232 | Rilgamon-205066 | addon['db']['global']['timerColor'] = { a,b,c,d } |
|
233 | Rilgamon-205066 | addon:updateBar(true) |
|
234 | Rilgamon-205066 | end, |
|
235 | Rilgamon-205066 | nil,nil,addon['timerSettings']) |
|
236 | Rilgamon-205066 | addon:AddConfigEntry("select","timerAnchor",L['Anchor'],nil,4,"buildAnchor",nil,nil,nil,addon['timerSettings']) |
|
237 | Rilgamon-205066 | addon:AddConfigEntry("range","timerxOffset",L['X-Offset'],nil,5,-64,64,1,false,addon['timerSettings']) |
|
238 | Rilgamon-205066 | addon:AddConfigEntry("range","timeryOffset",L['Y-Offset'],nil,6,-64,64,1,false,addon['timerSettings']) |
|
239 | Rilgamon-205066 | addon:AddConfigEntry("select","timerfontAnchorX",L['Font Anchor X'],nil,4,"buildFontAnchor",nil,nil,nil,addon['timerSettings']) |
|
240 | Rilgamon-205066 | addon:AddConfigEntry("select","timerfontAnchorY",L['Font Anchor Y'],nil,4,"buildFontAnchorY",nil,nil,nil,addon['timerSettings']) |
|
241 | Rilgamon-205066 | ||
242 | Rilgamon-205066 | if(GetNumTalentGroups(false, false) > 1) then |
|
243 | Rilgamon-205066 | addon['dualskill'] = addon:AddConfigMenu({ |
|
244 | Rilgamon-205066 | ['name'] = L['Dualskill'], |
|
245 | Rilgamon-205066 | ['order'] = 3, |
|
246 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
247 | Rilgamon-205066 | ['menuGet'] = "getPref4", |
|
248 | Rilgamon-205066 | ['menuSet'] = "setPref4" |
|
249 | Rilgamon-205066 | }) |
|
250 | Rilgamon-205066 | addon:AddConfigEntry("toggle","autoProfileSwitch",L['Automatic'],L['Switches profiles automaticly'],1,nil,nil,nil,nil,addon['dualskill']) |
|
251 | Rilgamon-205066 | addon:AddConfigEntry("toggle","silent",L['Quiet switching'],L['Does not announce a (needed) switch.'],2,nil,nil,nil,nil,addon['dualskill']) |
|
252 | Rilgamon-205066 | addon:AddConfigEntry("select","primaryProfile",L['Primary Profile'],nil,3,"buildProfiles",nil,nil,nil,addon['dualskill']) |
|
253 | Rilgamon-205066 | addon:AddConfigEntry("select","secondaryProfile",L['Secondary Profile'],nil,4,"buildProfiles",nil,nil,nil,addon['dualskill']) |
|
254 | Rilgamon-205066 | end |
|
255 | Rilgamon-205066 | addon:buildSpellList() |
|
256 | Rilgamon-205066 | addon:buildSpellBook() |
|
257 | Rilgamon-205066 | addon:resetSpellCDsound() |
|
258 | Rilgamon-205066 | addon.lastProfile = addon['db']:GetCurrentProfile() |
|
259 | Rilgamon-205066 | end |
|
260 | Rilgamon-205066 | ||
261 | Rilgamon-205066 | function addon:SPELL_UPDATE_COOLDOWN() |
|
262 | Rilgamon-205066 | for k,v in pairs(spellBook) do |
|
263 | Rilgamon-205066 | if(not spellInfoDB[k]) then |
|
264 | Rilgamon-205066 | nameSpellCD, rankSpellCD, iconSpellCD, costSpellCD, isFunnelSpellCD, powerTypeSpellCD, castTimeSpellCD, minRangeSpellCD, maxRangeSpellCD = GetSpellInfo(k) |
|
265 | Rilgamon-205066 | spellInfoDB[k] = { |
|
266 | Rilgamon-205066 | [1] = nameSpellCD, |
|
267 | Rilgamon-205066 | [2] = rankSpellCD, |
|
268 | Rilgamon-205066 | [3] = iconSpellCD, |
|
269 | Rilgamon-205066 | [4] = costSpellCD, |
|
270 | Rilgamon-205066 | [5] = isFunnelSpellCD, |
|
271 | Rilgamon-205066 | [6] = powerTypeSpellCD, |
|
272 | Rilgamon-205066 | [7] = castTimeSpellCD, |
|
273 | Rilgamon-205066 | [8] = minRangeSpellCD, |
|
274 | Rilgamon-205066 | [9] = maxRangeSpellCD |
|
275 | Rilgamon-205066 | } |
|
276 | Rilgamon-205066 | else |
|
277 | Rilgamon-205066 | nameSpellCD = spellInfoDB[k][1] |
|
278 | Rilgamon-205066 | rankSpellCD = spellInfoDB[k][2] |
|
279 | Rilgamon-205066 | iconSpellCD = spellInfoDB[k][3] |
|
280 | Rilgamon-205066 | costSpellCD = spellInfoDB[k][4] |
|
281 | Rilgamon-205066 | isFunnelSpellCD = spellInfoDB[k][5] |
|
282 | Rilgamon-205066 | powerTypeSpellCD = spellInfoDB[k][6] |
|
283 | Rilgamon-205066 | castTimeSpellCD = spellInfoDB[k][7] |
|
284 | Rilgamon-205066 | minRangeSpellCD = spellInfoDB[k][8] |
|
285 | Rilgamon-205066 | maxRangeSpellCD = spellInfoDB[k][9] |
|
286 | Rilgamon-205066 | end |
|
287 | Rilgamon-205066 | if(nameSpellCD) then |
|
288 | Rilgamon-205066 | spellName = "SpellCD_"..k |
|
289 | Rilgamon-205066 | startSpellCD, durationSpellCD, enabledSpellCD = GetSpellCooldown(nameSpellCD) |
|
290 | Rilgamon-205066 | if((startSpellCD and startSpellCD > 0) and ((durationSpellCD and durationSpellCD > 1.5) or (addon['db']['profile']['auras'][spellName] and addon['db']['profile']['auras'][spellName]['static']))) then |
|
291 | Rilgamon-205066 | ex = false |
|
292 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][spellName]) then |
|
293 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName] = { |
|
294 | Rilgamon-205066 | ['warning'] = addon['db']['profile']['auras'][L['Defaults']]['warning'], |
|
295 | Rilgamon-205066 | ['priority'] = addon['db']['profile']['auras'][L['Defaults']]['priority'], |
|
296 | Rilgamon-205066 | ['charges'] = addon['db']['profile']['auras'][L['Defaults']]['charges'], |
|
297 | Rilgamon-205066 | ['ignoreMeOmniCC'] = addon['db']['profile']['auras'][L['Defaults']]['ignoreMeOmniCC'], |
|
298 | Rilgamon-205066 | ['whitelist'] = 0, |
|
299 | Rilgamon-205066 | ['soundPlayed'] = true, |
|
300 | Rilgamon-205066 | ['static'] = false |
|
301 | Rilgamon-205066 | } |
|
302 | Rilgamon-205066 | ex = true |
|
303 | Rilgamon-205066 | end |
|
304 | Rilgamon-205066 | ||
305 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName] = { |
|
306 | Rilgamon-205066 | ['icon'] = iconSpellCD, |
|
307 | Rilgamon-205066 | ['duration'] = durationSpellCD, |
|
308 | Rilgamon-205066 | ['expirationTime'] = startSpellCD + durationSpellCD, |
|
309 | Rilgamon-205066 | ['unitCaster'] = "player", |
|
310 | Rilgamon-205066 | ['filter'] = "HELPFUL", |
|
311 | Rilgamon-205066 | ['target'] = "target", |
|
312 | Rilgamon-205066 | ['spellCD'] = true, |
|
313 | Rilgamon-205066 | ['spellCDName'] = nameSpellCD, |
|
314 | Rilgamon-205066 | ['spellCDId'] = v, |
|
315 | Rilgamon-205066 | ['static'] = addon['db']['profile']['auras'][spellName]['static'], |
|
316 | Rilgamon-205066 | ['priority'] = addon['db']['profile']['auras'][spellName]['priority'] or addon['db']['profile']['priority'], |
|
317 | Rilgamon-205066 | ['whitelist'] = addon['db']['profile']['auras'][spellName]['whitelist'] or 0, |
|
318 | Rilgamon-205066 | ['lastTime'] = addon['db']['profile']['auras'][spellName]['lastTime'], |
|
319 | Rilgamon-205066 | ['lastexpirationTime'] = addon['db']['profile']['auras'][spellName]['lastexpirationTime'], |
|
320 | Rilgamon-205066 | ['soundEffect'] = addon['db']['profile']['auras'][spellName]['soundEffect'], |
|
321 | Rilgamon-205066 | ['playSound'] = addon['db']['profile']['auras'][spellName]['playSound'], |
|
322 | Rilgamon-205066 | ['soundPlayed'] = addon['db']['profile']['auras'][spellName]['soundPlayed'], |
|
323 | Rilgamon-205066 | ['showTextTimer'] = addon['db']['profile']['auras'][spellName]['showTextTimer'], |
|
324 | Rilgamon-205066 | ['ignoreMeOmniCC'] = addon['db']['profile']['auras'][spellName]['ignoreMeOmniCC'], |
|
325 | Rilgamon-205066 | ['warning'] = addon['db']['profile']['auras'][spellName]['warning'], |
|
326 | Rilgamon-205066 | ['spellcounter'] = addon['db']['profile']['auras'][spellName]['spellcounter'] or 0, |
|
327 | Rilgamon-205066 | ['spellcount'] = addon['db']['profile']['auras'][spellName]['spellcount'] or 0, |
|
328 | Rilgamon-205066 | } |
|
329 | Rilgamon-205066 | if(ex == true) then |
|
330 | Rilgamon-205066 | addon:buildSpellList() |
|
331 | Rilgamon-205066 | end |
|
332 | Rilgamon-205066 | end |
|
333 | Rilgamon-205066 | end |
|
334 | Rilgamon-205066 | end |
|
335 | Rilgamon-205066 | end |
|
336 | Rilgamon-205066 | ||
337 | Rilgamon-205066 | local function addonEvent(event,arg1) |
|
338 | Rilgamon-205066 | -- print(event,"-",arg1) |
|
339 | Rilgamon-205066 | if(addon['nextEvent'] < GetTime()) then |
|
340 | Rilgamon-205066 | if(event == "UNIT_AURA") then |
|
341 | Rilgamon-205066 | if(arg1 and (UnitIsUnit(arg1,"player") or UnitIsUnit(arg1,"target") or UnitIsUnit(arg1,"focus"))) then |
|
342 | Rilgamon-205066 | -- print("sa") |
|
343 | Rilgamon-205066 | addon['nextEvent'] = GetTime() + .2 |
|
344 | Rilgamon-205066 | addon:scanAll() |
|
345 | Rilgamon-205066 | end |
|
346 | Rilgamon-205066 | elseif(event == "UNIT_INVENTORY_CHANGED") then |
|
347 | Rilgamon-205066 | if(arg1 and UnitIsUnit(arg1,"player")) then |
|
348 | Rilgamon-205066 | -- print("ic") |
|
349 | Rilgamon-205066 | addon['nextEvent'] = GetTime() + .2 |
|
350 | Rilgamon-205066 | addon:scanAll() |
|
351 | Rilgamon-205066 | end |
|
352 | Rilgamon-205066 | end |
|
353 | Rilgamon-205066 | end |
|
354 | Rilgamon-205066 | end |
|
355 | Rilgamon-205066 | ||
356 | Rilgamon-205066 | local function checkEvent(self,event,func) |
|
357 | Rilgamon-205066 | if(not self:IsEventRegistered(event) and type(func) == "function") then |
|
358 | Rilgamon-205066 | self:RegisterEvent(event,func) |
|
359 | Rilgamon-205066 | -- print("reg", event) |
|
360 | Rilgamon-205066 | elseif(not func) then |
|
361 | Rilgamon-205066 | self:UnregisterEvent(event) |
|
362 | Rilgamon-205066 | -- print("unreg", event) |
|
363 | Rilgamon-205066 | end |
|
364 | Rilgamon-205066 | end |
|
365 | Rilgamon-205066 | ||
366 | Rilgamon-205066 | function addon:destroyButtons() |
|
367 | Rilgamon-205066 | -- print("destroy") |
|
368 | Rilgamon-205066 | buttonCount = 0 |
|
369 | Rilgamon-205066 | for k,v in pairs(button) do |
|
370 | Rilgamon-205066 | addon:removeButton(k, true) |
|
371 | Rilgamon-205066 | end |
|
372 | Rilgamon-205066 | -- addon:checkDBDefault() |
|
373 | Rilgamon-205066 | addon:updateBar() |
|
374 | Rilgamon-205066 | end |
|
375 | Rilgamon-205066 | ||
376 | Rilgamon-205066 | function addon:PLAYER_REGEN_ENABLED(event) |
|
377 | Rilgamon-205066 | if(event) then |
|
378 | Rilgamon-205066 | addon:destroyButtons() |
|
379 | Rilgamon-205066 | end |
|
380 | Rilgamon-205066 | -- addon:SetScript("OnUpdate", nil) |
|
381 | Rilgamon-205066 | -- checkEvent(addon,"UNIT_AURA",addonEvent) |
|
382 | Rilgamon-205066 | -- checkEvent(addon,"UNIT_INVENTORY_CHANGED",addonEvent) |
|
383 | Rilgamon-205066 | end |
|
384 | Rilgamon-205066 | ||
385 | Rilgamon-205066 | function addon:PLAYER_REGEN_DISABLED() |
|
386 | Rilgamon-205066 | -- addon:SetScript("OnUpdate", function(self, elapsed) self:OnUpdate(elapsed) end) |
|
387 | Rilgamon-205066 | -- checkEvent(addon,"UNIT_AURA",func) |
|
388 | Rilgamon-205066 | end |
|
389 | Rilgamon-205066 | ||
390 | Rilgamon-205066 | function addon:resetToWhiteList() |
|
391 | Rilgamon-205066 | addon:resetTo(0) |
|
392 | Rilgamon-205066 | end |
|
393 | Rilgamon-205066 | ||
394 | Rilgamon-205066 | function addon:resetToBlackList() |
|
395 | Rilgamon-205066 | addon:resetTo(1) |
|
396 | Rilgamon-205066 | end |
|
397 | Rilgamon-205066 | ||
398 | Rilgamon-205066 | function addon:resetTo(list) |
|
399 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras']) do |
|
400 | Rilgamon-205066 | if(k ~= L['Defaults']) then |
|
401 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['whitelist'] = list |
|
402 | Rilgamon-205066 | end |
|
403 | Rilgamon-205066 | end |
|
404 | Rilgamon-205066 | addon:resetSpellCD() |
|
405 | Rilgamon-205066 | addon:buildSpellList() |
|
406 | Rilgamon-205066 | addon:destroyButtons() |
|
407 | Rilgamon-205066 | end |
|
408 | Rilgamon-205066 | ||
409 | Rilgamon-205066 | function addon:deleteBlackList() |
|
410 | Rilgamon-205066 | addon:deleteList(0) |
|
411 | Rilgamon-205066 | end |
|
412 | Rilgamon-205066 | ||
413 | Rilgamon-205066 | function addon:deleteWhiteList() |
|
414 | Rilgamon-205066 | addon:deleteList(1) |
|
415 | Rilgamon-205066 | end |
|
416 | Rilgamon-205066 | ||
417 | Rilgamon-205066 | function addon:deleteList(list) |
|
418 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras']) do |
|
419 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['whitelist'] == list and k ~= L['Defaults']) then |
|
420 | Rilgamon-205066 | addon['db']['profile']['auras'][k] = nil |
|
421 | Rilgamon-205066 | end |
|
422 | Rilgamon-205066 | end |
|
423 | Rilgamon-205066 | addon:buildSpellList() |
|
424 | Rilgamon-205066 | addon:destroyButtons() |
|
425 | Rilgamon-205066 | end |
|
426 | Rilgamon-205066 | ||
427 | Rilgamon-205066 | function addon:resetSpellCD() |
|
428 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras']) do |
|
429 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['SpellCD'] and k ~= L['Defaults']) then |
|
430 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['whitelist'] = 0 |
|
431 | Rilgamon-205066 | end |
|
432 | Rilgamon-205066 | end |
|
433 | Rilgamon-205066 | end |
|
434 | Rilgamon-205066 | ||
435 | Rilgamon-205066 | function addon:buildSpellBook() |
|
436 | Rilgamon-205066 | spellBook = {} |
|
437 | Rilgamon-205066 | spellBookCount = 0 |
|
438 | Rilgamon-205066 | while true do |
|
439 | Rilgamon-205066 | spellBookCount = spellBookCount + 1 |
|
440 | Rilgamon-205066 | spellName, spellRank = GetSpellBookItemName(spellBookCount, BOOKTYPE_SPELL) |
|
441 | Rilgamon-205066 | if(not spellName) then |
|
442 | Rilgamon-205066 | break |
|
443 | Rilgamon-205066 | end |
|
444 | Rilgamon-205066 | spellBook[spellName] = spellBookCount |
|
445 | Rilgamon-205066 | end |
|
446 | Rilgamon-205066 | addon:SPELL_UPDATE_COOLDOWN() |
|
447 | Rilgamon-205066 | end |
|
448 | Rilgamon-205066 | ||
449 | Rilgamon-205066 | function addon:resetSpellCDsound() |
|
450 | Rilgamon-205066 | for k,v in pairs(spellBook) do |
|
451 | Rilgamon-205066 | spellName = "SpellCD_"..k |
|
452 | Rilgamon-205066 | if(addon['db']['profile']['auras'][spellName]) then |
|
453 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName]['soundPlayed'] = true |
|
454 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName]['expirationTime'] = 0 |
|
455 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName]['lastexpirationTime'] = 0 |
|
456 | Rilgamon-205066 | end |
|
457 | Rilgamon-205066 | end |
|
458 | Rilgamon-205066 | end |
|
459 | Rilgamon-205066 | ||
460 | Rilgamon-205066 | function addon:checkButtonSpellCD() |
|
461 | Rilgamon-205066 | if(button) then |
|
462 | Rilgamon-205066 | for k,v in pairs(button) do |
|
463 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]) then |
|
464 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['spellCD']) then |
|
465 | Rilgamon-205066 | startSpellCD, durationSpellCD, enabledSpellCD = GetSpellCooldown(addon['db']['profile']['auras'][k]['spellCDName']) |
|
466 | Rilgamon-205066 | if(type(durationSpellCD) == "number" and type(startSpellCD) == "number" and startSpellCD > 0 and durationSpellCD > 1.5) then |
|
467 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['soundPlayed'] = false |
|
468 | Rilgamon-205066 | elseif(type(enabledSpellCD) == "number" and type(startSpellCD) == "number" and type(durationSpellCD) == "number" and enabledSpellCD == 1 and startSpellCD == 0 and durationSpellCD == 0) then |
|
469 | Rilgamon-205066 | addon:auraAdded(k,false,true) |
|
470 | Rilgamon-205066 | end |
|
471 | Rilgamon-205066 | end |
|
472 | Rilgamon-205066 | end |
|
473 | Rilgamon-205066 | end |
|
474 | Rilgamon-205066 | end |
|
475 | Rilgamon-205066 | end |
|
476 | Rilgamon-205066 | ||
477 | Rilgamon-205066 | function addon:buildWarning() |
|
478 | Rilgamon-205066 | return { |
|
479 | Rilgamon-205066 | [1] = L['Dont warn'], |
|
480 | Rilgamon-205066 | [2] = L['Only in Combat'], |
|
481 | Rilgamon-205066 | [3] = L['Only out of Combat'], |
|
482 | Rilgamon-205066 | [4] = L['Always'], |
|
483 | Rilgamon-205066 | } |
|
484 | Rilgamon-205066 | end |
|
485 | Rilgamon-205066 | ||
486 | Rilgamon-205066 | function addon:buildFontAnchor() |
|
487 | Rilgamon-205066 | return { |
|
488 | Rilgamon-205066 | ['LEFT'] = "LEFT", |
|
489 | Rilgamon-205066 | ['RIGHT'] = "RIGHT", |
|
490 | Rilgamon-205066 | ['CENTER'] = "CENTER" |
|
491 | Rilgamon-205066 | } |
|
492 | Rilgamon-205066 | end |
|
493 | Rilgamon-205066 | ||
494 | Rilgamon-205066 | function addon:buildFontAnchorY() |
|
495 | Rilgamon-205066 | return { |
|
496 | Rilgamon-205066 | ['TOP'] = "TOP", |
|
497 | Rilgamon-205066 | ['BOTTOM'] = "BOTTOM", |
|
498 | Rilgamon-205066 | ['MIDDLE'] = "MIDDLE" |
|
499 | Rilgamon-205066 | } |
|
500 | Rilgamon-205066 | end |
|
501 | Rilgamon-205066 | ||
502 | Rilgamon-205066 | function addon:buildAnchor() |
|
503 | Rilgamon-205066 | return { |
|
504 | Rilgamon-205066 | "TOPLEFT", |
|
505 | Rilgamon-205066 | "TOP", |
|
506 | Rilgamon-205066 | "TOPRIGHT", |
|
507 | Rilgamon-205066 | "LEFT", |
|
508 | Rilgamon-205066 | "CENTER", |
|
509 | Rilgamon-205066 | "RIGHT", |
|
510 | Rilgamon-205066 | "BOTTOMLEFT", |
|
511 | Rilgamon-205066 | "BOTTOM", |
|
512 | Rilgamon-205066 | "BOTTOMRIGHT" |
|
513 | Rilgamon-205066 | } |
|
514 | Rilgamon-205066 | end |
|
515 | Rilgamon-205066 | ||
516 | Rilgamon-205066 | function addon:buildSoundlist() |
|
517 | Rilgamon-205066 | if(LSM) then |
|
518 | Rilgamon-205066 | return LSM:List("sound") |
|
519 | Rilgamon-205066 | else |
|
520 | Rilgamon-205066 | return {} |
|
521 | Rilgamon-205066 | end |
|
522 | Rilgamon-205066 | end |
|
523 | Rilgamon-205066 | ||
524 | Rilgamon-205066 | function addon:buildFontlist() |
|
525 | Rilgamon-205066 | if(LSM) then |
|
526 | Rilgamon-205066 | return LSM:List("font") |
|
527 | Rilgamon-205066 | else |
|
528 | Rilgamon-205066 | return { |
|
529 | Rilgamon-205066 | "FRIZQT__.TTF", |
|
530 | Rilgamon-205066 | "ARIALN.TTF", |
|
531 | Rilgamon-205066 | "skurri.ttf", |
|
532 | Rilgamon-205066 | "MORPHEUS.ttf", |
|
533 | Rilgamon-205066 | } |
|
534 | Rilgamon-205066 | end |
|
535 | Rilgamon-205066 | end |
|
536 | Rilgamon-205066 | ||
537 | Rilgamon-205066 | function addon:buildProfiles() |
|
538 | Rilgamon-205066 | ex = {} |
|
539 | Rilgamon-205066 | for k,v in pairs(addon['db']['profiles']) do |
|
540 | Rilgamon-205066 | ex[k] = k |
|
541 | Rilgamon-205066 | end |
|
542 | Rilgamon-205066 | return ex |
|
543 | Rilgamon-205066 | end |
|
544 | Rilgamon-205066 | ||
545 | Rilgamon-205066 | function addon:checkDualskill() |
|
546 | Rilgamon-205066 | addon['TalentGroup'] = GetActiveTalentGroup(false,false) |
|
547 | Rilgamon-205066 | addon['db']['global']['primaryProfile'] = addon['db']['global']['primaryProfile'] or addon['db']:GetCurrentProfile() |
|
548 | Rilgamon-205066 | addon['db']['global']['secondaryProfile'] = addon['db']['global']['secondaryProfile'] or addon['db']:GetCurrentProfile() |
|
549 | Rilgamon-205066 | if(addon['TalentGroup'] == 1 and addon['db']['global']['primaryProfile'] ~= self['db']:GetCurrentProfile()) then |
|
550 | Rilgamon-205066 | if(addon['db']['global']['autoProfileSwitch']) then |
|
551 | Rilgamon-205066 | if(not addon['db']['global']['silent']) then |
|
552 | Rilgamon-205066 | addon:Print(L['Detected a talent spec change. Switching profile.']) |
|
553 | Rilgamon-205066 | end |
|
554 | Rilgamon-205066 | addon['db']:SetProfile(addon['db']['global']['primaryProfile']) |
|
555 | Rilgamon-205066 | addon:buildSpellList() |
|
556 | Rilgamon-205066 | addontable['loadFrame'](addon.mainframe) |
|
557 | Rilgamon-205066 | else |
|
558 | Rilgamon-205066 | if(not addon['db']['global']['silent']) then |
|
559 | Rilgamon-205066 | addon:Print(L['Detected a talent spec change. You should switch profile.']) |
|
560 | Rilgamon-205066 | end |
|
561 | Rilgamon-205066 | end |
|
562 | Rilgamon-205066 | elseif(addon['TalentGroup'] == 2 and addon['db']['global']['secondaryProfile'] ~= self['db']:GetCurrentProfile()) then |
|
563 | Rilgamon-205066 | if(addon['db']['global']['autoProfileSwitch']) then |
|
564 | Rilgamon-205066 | if(not addon['db']['global']['silent']) then |
|
565 | Rilgamon-205066 | addon:Print(L['Detected a talent spec change. Switching profile.']) |
|
566 | Rilgamon-205066 | end |
|
567 | Rilgamon-205066 | addon['db']:SetProfile(addon['db']['global']['secondaryProfile']) |
|
568 | Rilgamon-205066 | addon:buildSpellList() |
|
569 | Rilgamon-205066 | addontable['loadFrame'](addon.mainframe) |
|
570 | Rilgamon-205066 | else |
|
571 | Rilgamon-205066 | if(not addon['db']['global']['silent']) then |
|
572 | Rilgamon-205066 | addon:Print(L['Detected a talent spec change. You should switch profile.']) |
|
573 | Rilgamon-205066 | end |
|
574 | Rilgamon-205066 | end |
|
575 | Rilgamon-205066 | end |
|
576 | Rilgamon-205066 | addon:checkUpdate() |
|
577 | Rilgamon-205066 | end |
|
578 | Rilgamon-205066 | ||
579 | Rilgamon-205066 | function addon:checkDBDefault() |
|
580 | Rilgamon-205066 | addon['db']['global']['displayMode'] = addon['db']['global']['displayMode'] or 1 |
|
581 | Rilgamon-205066 | addon['db']['global']['spacing'] = addon['db']['profile']['spacing'] or 8 |
|
582 | Rilgamon-205066 | addon['db']['profile']['spacing'] = addon['db']['global']['spacing'] |
|
583 | Rilgamon-205066 | addon['db']['global']['vertical'] = addon['db']['profile']['vertical'] or false |
|
584 | Rilgamon-205066 | addon['db']['profile']['vertical'] = addon['db']['global']['vertical'] |
|
585 | Rilgamon-205066 | addon['db']['global']['growth'] = addon['db']['profile']['growth'] or false |
|
586 | Rilgamon-205066 | addon['db']['profile']['growth'] = addon['db']['global']['growth'] |
|
587 | Rilgamon-205066 | addon['db']['global']['fontAnchorX'] = addon['db']['global']['fontAnchorX'] or "RIGHT" |
|
588 | Rilgamon-205066 | addon['db']['global']['fontAnchorY'] = addon['db']['global']['fontAnchorY'] or "BOTTOM" |
|
589 | Rilgamon-205066 | addon['db']['global']['chargesFont'] = addon['db']['global']['chargesFont'] or "Fonts\\SKURRI.TTF" |
|
590 | Rilgamon-205066 | addon['db']['global']['chargesSize'] = addon['db']['global']['chargesSize'] or 32 |
|
591 | Rilgamon-205066 | addon['db']['global']['chargesMode'] = addon['db']['global']['chargesMode'] or "OUTLINE" |
|
592 | Rilgamon-205066 | addon['db']['global']['chargesColor'] = addon['db']['global']['chargesColor'] or { 1,1,1,1 } |
|
593 | Rilgamon-205066 | addon['db']['global']['timerfontAnchorX'] = addon['db']['global']['timerfontAnchorX'] or "LEFT" |
|
594 | Rilgamon-205066 | addon['db']['global']['timerfontAnchorY'] = addon['db']['global']['timerfontAnchorY'] or "TOP" |
|
595 | Rilgamon-205066 | addon['db']['global']['timerxOffset'] = addon['db']['global']['timerxOffset'] or -10 |
|
596 | Rilgamon-205066 | addon['db']['global']['timeryOffset'] = addon['db']['global']['timeryOffset'] or 10 |
|
597 | Rilgamon-205066 | addon['db']['global']['timerFont'] = addon['db']['global']['timerFont'] or "Fonts\\FRIZQT__.TTF" |
|
598 | Rilgamon-205066 | addon['db']['global']['timerSize'] = addon['db']['global']['timerSize'] or 20 |
|
599 | Rilgamon-205066 | addon['db']['global']['timerMode'] = addon['db']['global']['timerMode'] or "OUTLINE" |
|
600 | Rilgamon-205066 | addon['db']['global']['timerColor'] = addon['db']['global']['timerColor'] or { 1,1,0,1 } |
|
601 | Rilgamon-205066 | addon['db']['profile']['update'] = addon['db']['profile']['update'] or 1 |
|
602 | Rilgamon-205066 | addon['db']['profile']['scale'] = addon['db']['profile']['scale'] or .75 |
|
603 | Rilgamon-205066 | addon['db']['profile']['whitelist'] = addon['db']['profile']['whitelist'] or 0 |
|
604 | Rilgamon-205066 | addon['db']['profile']['priority'] = addon['db']['profile']['priority'] or 0 |
|
605 | Rilgamon-205066 | addon['db']['profile']['sorting'] = addon['db']['profile']['sorting'] or 0 |
|
606 | Rilgamon-205066 | addon['db']['profile']['auras'] = addon['db']['profile']['auras'] or {} |
|
607 | Rilgamon-205066 | addon['db']['profile']['auras'][L['Defaults']] = addon['db']['profile']['auras'][L['Defaults']] or { |
|
608 | Rilgamon-205066 | ['warningOnly'] = false, |
|
609 | Rilgamon-205066 | ['warning'] = 1, |
|
610 | Rilgamon-205066 | ['charges'] = true, |
|
611 | Rilgamon-205066 | ['static'] = false, |
|
612 | Rilgamon-205066 | ['ignoreMeOmniCC'] = false, |
|
613 | Rilgamon-205066 | ['priority'] = 1, |
|
614 | Rilgamon-205066 | ['playSound'] = false, |
|
615 | Rilgamon-205066 | ['soundEffect'] = LSM:GetDefault('sound') or nil, |
|
616 | Rilgamon-205066 | ['showTextTimer'] = false |
|
617 | Rilgamon-205066 | } |
|
618 | Rilgamon-205066 | end |
|
619 | Rilgamon-205066 | ||
620 | Rilgamon-205066 | function addon:OnUpdate(elapsed) |
|
621 | Rilgamon-205066 | -- timeElapsed = timeElapsed + elapsed |
|
622 | Rilgamon-205066 | -- addon['db']['profile']['update'] = addon['db']['profile']['update'] or 1 |
|
623 | Rilgamon-205066 | if(addon['nextUpdate'] < GetTime()) then |
|
624 | Rilgamon-205066 | if(addon['db']:GetCurrentProfile() ~= addon.lastProfile) then |
|
625 | Rilgamon-205066 | addon:checkDBDefault() |
|
626 | Rilgamon-205066 | addon:buildConfig() |
|
627 | Rilgamon-205066 | addon:destroyButtons() |
|
628 | Rilgamon-205066 | end |
|
629 | Rilgamon-205066 | addon:scanAll() |
|
630 | Rilgamon-205066 | -- timeElapsed = 0 |
|
631 | Rilgamon-205066 | end |
|
632 | Rilgamon-205066 | end |
|
633 | Rilgamon-205066 | ||
634 | Rilgamon-205066 | function addon:getListIndex(index,typ,list,def) |
|
635 | Rilgamon-205066 | for k,v in pairs(list) do |
|
636 | Rilgamon-205066 | if(LSM:Fetch(typ,v) == addon['db']['global'][index]) then |
|
637 | Rilgamon-205066 | return k |
|
638 | Rilgamon-205066 | end |
|
639 | Rilgamon-205066 | end |
|
640 | Rilgamon-205066 | return def or 1 |
|
641 | Rilgamon-205066 | end |
|
642 | Rilgamon-205066 | ||
643 | Rilgamon-205066 | function addon:getListIndex2(index,list,def) |
|
644 | Rilgamon-205066 | for k,v in pairs(list) do |
|
645 | Rilgamon-205066 | if(list[k] == addon['db']['global'][index]) then |
|
646 | Rilgamon-205066 | return k |
|
647 | Rilgamon-205066 | end |
|
648 | Rilgamon-205066 | end |
|
649 | Rilgamon-205066 | return def or 1 |
|
650 | Rilgamon-205066 | end |
|
651 | Rilgamon-205066 | ||
652 | Rilgamon-205066 | function addon:getPref5(info) |
|
653 | Rilgamon-205066 | if(info[#info] == 'chargesFont' or info[#info] == 'timerFont') then |
|
654 | Rilgamon-205066 | return addon:getListIndex(info[#info],"font",addon:buildFontlist(),1) |
|
655 | Rilgamon-205066 | elseif(info[#info] == 'chargesAnchor' or info[#info] == 'timerAnchor') then |
|
656 | Rilgamon-205066 | return addon:getListIndex2(info[#info],addon:buildAnchor(),1) |
|
657 | Rilgamon-205066 | end |
|
658 | Rilgamon-205066 | return addon['db']['global'][info[#info]] |
|
659 | Rilgamon-205066 | end |
|
660 | Rilgamon-205066 | ||
661 | Rilgamon-205066 | function addon:setListIndex(index,typ,list,value) |
|
662 | Rilgamon-205066 | for k,v in pairs(list) do |
|
663 | Rilgamon-205066 | if(k == value) then |
|
664 | Rilgamon-205066 | addon['db']['global'][index] = LSM:Fetch(typ,v) |
|
665 | Rilgamon-205066 | break |
|
666 | Rilgamon-205066 | end |
|
667 | Rilgamon-205066 | end |
|
668 | Rilgamon-205066 | end |
|
669 | Rilgamon-205066 | ||
670 | Rilgamon-205066 | function addon:setListIndex2(index,list,value) |
|
671 | Rilgamon-205066 | for k,v in pairs(list) do |
|
672 | Rilgamon-205066 | if(k == value) then |
|
673 | Rilgamon-205066 | addon['db']['global'][index] = list[value] |
|
674 | Rilgamon-205066 | break |
|
675 | Rilgamon-205066 | end |
|
676 | Rilgamon-205066 | end |
|
677 | Rilgamon-205066 | end |
|
678 | Rilgamon-205066 | ||
679 | Rilgamon-205066 | function addon:setPref5(info,value) |
|
680 | Rilgamon-205066 | if(UnitAffectingCombat("player") ~= 1) then |
|
681 | Rilgamon-205066 | if(info[#info] == 'chargesFont' or info[#info] == 'timerFont') then |
|
682 | Rilgamon-205066 | addon:setListIndex(info[#info],"font",addon:buildFontlist(),value) |
|
683 | Rilgamon-205066 | elseif(info[#info] == 'chargesAnchor' or info[#info] == 'timerAnchor') then |
|
684 | Rilgamon-205066 | addon:setListIndex2(info[#info],addon:buildAnchor(),value) |
|
685 | Rilgamon-205066 | else |
|
686 | Rilgamon-205066 | addon['db']['global'][info[#info]] = value |
|
687 | Rilgamon-205066 | end |
|
688 | Rilgamon-205066 | addon:destroyButtons() |
|
689 | Rilgamon-205066 | else |
|
690 | Rilgamon-205066 | addon:Print(L['You cant do this in combat']) |
|
691 | Rilgamon-205066 | end |
|
692 | Rilgamon-205066 | end |
|
693 | Rilgamon-205066 | ||
694 | Rilgamon-205066 | function addon:getPref4(info) |
|
695 | Rilgamon-205066 | return addon['db']['global'][info[#info]] |
|
696 | Rilgamon-205066 | end |
|
697 | Rilgamon-205066 | ||
698 | Rilgamon-205066 | function addon:setPref4(info,value) |
|
699 | Rilgamon-205066 | addon['db']['global'][info[#info]] = value |
|
700 | Rilgamon-205066 | addon:buildSpellList() |
|
701 | Rilgamon-205066 | end |
|
702 | Rilgamon-205066 | ||
703 | Rilgamon-205066 | function addon:getPref3(info) |
|
704 | Rilgamon-205066 | if(info[#info] == 'soundEffect') then |
|
705 | Rilgamon-205066 | for k,v in pairs(addon:buildSoundlist()) do |
|
706 | Rilgamon-205066 | if(LSM:Fetch("sound",v) == addon['db']['profile']['auras'][info[#info-1]]['soundEffect']) then |
|
707 | Rilgamon-205066 | return k |
|
708 | Rilgamon-205066 | end |
|
709 | Rilgamon-205066 | end |
|
710 | Rilgamon-205066 | return 1 |
|
711 | Rilgamon-205066 | end |
|
712 | Rilgamon-205066 | return addon['db']['profile']['auras'][info[#info-1]][info[#info]] |
|
713 | Rilgamon-205066 | end |
|
714 | Rilgamon-205066 | ||
715 | Rilgamon-205066 | function addon:setPref3(info,value) |
|
716 | Rilgamon-205066 | -- print("set2",info[#info],value) |
|
717 | Rilgamon-205066 | if(UnitAffectingCombat("player") ~= 1) then |
|
718 | Rilgamon-205066 | if(info[#info] == 'soundEffect') then |
|
719 | Rilgamon-205066 | for k,v in pairs(addon:buildSoundlist()) do |
|
720 | Rilgamon-205066 | if(k == value) then |
|
721 | Rilgamon-205066 | addon['db']['profile']['auras'][info[#info-1]]['soundEffect'] = LSM:Fetch("sound",v) |
|
722 | Rilgamon-205066 | break |
|
723 | Rilgamon-205066 | end |
|
724 | Rilgamon-205066 | end |
|
725 | Rilgamon-205066 | else |
|
726 | Rilgamon-205066 | addon['db']['profile']['auras'][info[#info-1]][info[#info]] = value |
|
727 | Rilgamon-205066 | if(info[#info] == "warning") then |
|
728 | Rilgamon-205066 | addon['db']['profile']['auras'][info[#info-1]]["warningIcon"] = nil |
|
729 | Rilgamon-205066 | end |
|
730 | Rilgamon-205066 | end |
|
731 | Rilgamon-205066 | addon:destroyButtons() |
|
732 | Rilgamon-205066 | addon:buildSpellList() |
|
733 | Rilgamon-205066 | addon:SPELL_UPDATE_COOLDOWN() |
|
734 | Rilgamon-205066 | else |
|
735 | Rilgamon-205066 | addon:Print(L['You cant do this in combat']) |
|
736 | Rilgamon-205066 | end |
|
737 | Rilgamon-205066 | end |
|
738 | Rilgamon-205066 | ||
739 | Rilgamon-205066 | function addon:getPref2(info) |
|
740 | Rilgamon-205066 | addon:buildSpellList() |
|
741 | Rilgamon-205066 | if(addon['db']['profile']['auras'][info[#info]]) then |
|
742 | Rilgamon-205066 | if(addon['db']['profile']['auras'][info[#info]]['whitelist'] == 1) then |
|
743 | Rilgamon-205066 | return true |
|
744 | Rilgamon-205066 | else |
|
745 | Rilgamon-205066 | return false |
|
746 | Rilgamon-205066 | end |
|
747 | Rilgamon-205066 | else |
|
748 | Rilgamon-205066 | return false |
|
749 | Rilgamon-205066 | end |
|
750 | Rilgamon-205066 | end |
|
751 | Rilgamon-205066 | ||
752 | Rilgamon-205066 | function addon:setPref2(info,value) |
|
753 | Rilgamon-205066 | if(UnitAffectingCombat("player") ~= 1) then |
|
754 | Rilgamon-205066 | if(addon['db']['profile']['auras'][info[#info]]) then |
|
755 | Rilgamon-205066 | if(value) then |
|
756 | Rilgamon-205066 | addon['db']['profile']['auras'][info[#info]]['whitelist'] = 1 |
|
757 | Rilgamon-205066 | else |
|
758 | Rilgamon-205066 | addon['db']['profile']['auras'][info[#info]]['whitelist'] = 0 |
|
759 | Rilgamon-205066 | end |
|
760 | Rilgamon-205066 | end |
|
761 | Rilgamon-205066 | addon:destroyButtons() |
|
762 | Rilgamon-205066 | addon:buildSpellList() |
|
763 | Rilgamon-205066 | addon:SPELL_UPDATE_COOLDOWN() |
|
764 | Rilgamon-205066 | else |
|
765 | Rilgamon-205066 | addon:Print(L['You cant do this in combat']) |
|
766 | Rilgamon-205066 | end |
|
767 | Rilgamon-205066 | end |
|
768 | Rilgamon-205066 | ||
769 | Rilgamon-205066 | ||
770 | Rilgamon-205066 | ||
771 | Rilgamon-205066 | function addon:buildSpellList() |
|
772 | Rilgamon-205066 | if(not addon.whitelist or not addon.blacklist or not addon.spelllist) then |
|
773 | Rilgamon-205066 | addon:buildConfig() |
|
774 | Rilgamon-205066 | end |
|
775 | Rilgamon-205066 | addon['whitelist']['args'] = {} |
|
776 | Rilgamon-205066 | addon['blacklist']['args'] = {} |
|
777 | Rilgamon-205066 | addon['spelllist']['args'] = {} |
|
778 | Rilgamon-205066 | addon['spellprefs'] = {} |
|
779 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras']) do |
|
780 | Rilgamon-205066 | if(k ~= L['Defaults']) then |
|
781 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]) then |
|
782 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['whitelist'] == 1) then |
|
783 | Rilgamon-205066 | addon:AddConfigEntry("toggle",k,k,nil,1,nil,nil,nil,nil,addon['whitelist']) |
|
784 | Rilgamon-205066 | addon['spellprefs'][k] = addon:AddConfigMenu({ |
|
785 | Rilgamon-205066 | ['name'] = k, |
|
786 | Rilgamon-205066 | ['order'] = addon['db']['profile']['auras'][k]['priority'] or addon['db']['profile']['auras'][L['Defaults']]['priority'], |
|
787 | Rilgamon-205066 | ['menuHandler'] = addon, |
|
788 | Rilgamon-205066 | ['menuGet'] = "getPref3", |
|
789 | Rilgamon-205066 | ['menuSet'] = "setPref3" |
|
790 | Rilgamon-205066 | },addon['spelllist']) |
|
791 | Rilgamon-205066 | addon:AddConfigEntry("toggle","charges",L['Charges'],L['Show charges'],1,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
792 | Rilgamon-205066 | addon:AddConfigEntry("toggle","static",L['Static'],L['Show spell when inactive'],2,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
793 | Rilgamon-205066 | -- if(not addon['db']['profile']['auras'][k]['spellCD']) then |
|
794 | Rilgamon-205066 | addon:AddConfigEntry("toggle","playSound",L['Play Sound'],L['Play a sound when this spell is active'],5,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
795 | Rilgamon-205066 | addon:AddConfigEntry("select","soundEffect",L['Sound'],nil,6,"buildSoundlist",nil,nil,nil,addon['spellprefs'][k]) |
|
796 | Rilgamon-205066 | -- end |
|
797 | Rilgamon-205066 | addon:AddConfigEntry("range","priority",L['Order'],L['Defines the priority on the spellbar.'],4,1,100,1,false,addon['spellprefs'][k]) |
|
798 | Rilgamon-205066 | addon:AddConfigEntry("toggle","showTextTimer",L['Timer'],L['Show Text Timer'],3,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
799 | Rilgamon-205066 | addon:AddConfigEntry("toggle","ignoreMeOmniCC",L['Disable OmniCC'],L['Disable OmniCC for this spell'],7,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
800 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][k]['spellCD']) then |
|
801 | Rilgamon-205066 | addon:AddConfigEntry("select","warning",L['Warning'],L['Show a warning when missing'],8,"buildWarning",nil,nil,nil,addon['spellprefs'][k]) |
|
802 | Rilgamon-205066 | addon:AddConfigEntry("toggle","warningOnly",L['Warning only'],L['Hide spell until warning'],9,nil,nil,nil,nil,addon['spellprefs'][k]) |
|
803 | Rilgamon-205066 | end |
|
804 | Rilgamon-205066 | else |
|
805 | Rilgamon-205066 | addon:AddConfigEntry("toggle",k,k,nil,1,nil,nil,nil,nil,addon['blacklist']) |
|
806 | Rilgamon-205066 | end |
|
807 | Rilgamon-205066 | end |
|
808 | Rilgamon-205066 | end |
|
809 | Rilgamon-205066 | end |
|
810 | Rilgamon-205066 | end |
|
811 | Rilgamon-205066 | ||
812 | Rilgamon-205066 | function addon:buildSort() |
|
813 | Rilgamon-205066 | return { [0] = L['Time'], [1] = L['Priority']} |
|
814 | Rilgamon-205066 | end |
|
815 | Rilgamon-205066 | function addon:buildSelect() |
|
816 | Rilgamon-205066 | return { [0] = L['Blacklist'],[1] = L['Whitelist']} |
|
817 | Rilgamon-205066 | end |
|
818 | Rilgamon-205066 | ||
819 | Rilgamon-205066 | local function skullReset(self) |
|
820 | Rilgamon-205066 | -- print("reset",self:GetName()) |
|
821 | Rilgamon-205066 | self['elapsed'] = 0 |
|
822 | Rilgamon-205066 | self['animSpeed'] = .1 |
|
823 | Rilgamon-205066 | self['animStep'] = -0.2 |
|
824 | Rilgamon-205066 | self:SetAlpha(.5) |
|
825 | Rilgamon-205066 | end |
|
826 | Rilgamon-205066 | ||
827 | Rilgamon-205066 | ||
828 | Rilgamon-205066 | ||
829 | Rilgamon-205066 | function addon:scanAll() |
|
830 | Rilgamon-205066 | if scanning then return end |
|
831 | Rilgamon-205066 | scanning = true |
|
832 | Rilgamon-205066 | scannedUnits = { ['HELPFUL'] = {}, ['HARMFUL'] = {}} |
|
833 | Rilgamon-205066 | -- print("update", addon['nextUpdate'],addon['db']['profile']['update']) |
|
834 | Rilgamon-205066 | addon['nextUpdate'] = GetTime() + addon['db']['profile']['update'] |
|
835 | Rilgamon-205066 | auras = addon:joinTable(addon:joinTable(addon:joinTable(addon:scanBuffs("player","HELPFUL"),addon:scanBuffs("player","HARMFUL")),addon:joinTable(addon:scanBuffs("target","HELPFUL"),addon:scanBuffs("target","HARMFUL"))),addon:joinTable(addon:scanBuffs("focus","HELPFUL"),addon:scanBuffs("focus","HARMFUL"))) |
|
836 | 9 | Rilgamon-205066 | hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges, hasThrownEnchant, thrownExpiration, thrownCharges = GetWeaponEnchantInfo() |
837 | 7 | Rilgamon-205066 | if(hasMainHandEnchant) then |
838 | Rilgamon-205066 | addon:addWeaponEnchant(L['mainhand'], GetInventoryItemTexture("player", 16), GetTime() + mainHandExpiration/1000, mainHandCharges) |
|
839 | Rilgamon-205066 | auras[#auras+1] = L['mainhand'] |
|
840 | Rilgamon-205066 | else |
|
841 | Rilgamon-205066 | if(addon['db']['profile']['auras'][L['mainhand']]) then |
|
842 | Rilgamon-205066 | addon['db']['profile']['auras'][L['mainhand']]['expirationTime'] = GetTime() - 1 |
|
843 | Rilgamon-205066 | addon['db']['profile']['auras'][L['mainhand']]['lastexpirationTime'] = addon['db']['profile']['auras'][L['mainhand']]['expirationTime'] |
|
844 | Rilgamon-205066 | addon['db']['profile']['auras'][L['mainhand']]['count'] = 0 |
|
845 | Rilgamon-205066 | end |
|
846 | Rilgamon-205066 | end |
|
847 | Rilgamon-205066 | if(hasOffHandEnchant) then |
|
848 | Rilgamon-205066 | addon:addWeaponEnchant(L['offhand'], GetInventoryItemTexture("player", 17), GetTime() + offHandExpiration/1000, offHandCharges) |
|
849 | Rilgamon-205066 | auras[#auras+1] = L['offhand'] |
|
850 | Rilgamon-205066 | else |
|
851 | Rilgamon-205066 | if(addon['db']['profile']['auras'][L['offhand']]) then |
|
852 | Rilgamon-205066 | addon['db']['profile']['auras'][L['offhand']]['expirationTime'] = GetTime() - 1 |
|
853 | Rilgamon-205066 | addon['db']['profile']['auras'][L['offhand']]['lastexpirationTime'] = addon['db']['profile']['auras'][L['offhand']]['expirationTime'] |
|
854 | Rilgamon-205066 | addon['db']['profile']['auras'][L['offhand']]['count'] = 0 |
|
855 | Rilgamon-205066 | end |
|
856 | Rilgamon-205066 | end |
|
857 | 9 | Rilgamon-205066 | if(hasThrownEnchant) then |
858 | Rilgamon-205066 | addon:addWeaponEnchant(L['thrown'], GetInventoryItemTexture("player", 18), GetTime() + thrownExpiration/1000, thrownCharges) |
|
859 | Rilgamon-205066 | auras[#auras+1] = L['thrown'] |
|
860 | Rilgamon-205066 | else |
|
861 | Rilgamon-205066 | if(addon['db']['profile']['auras'][L['thrown']]) then |
|
862 | Rilgamon-205066 | addon['db']['profile']['auras'][L['thrown']]['expirationTime'] = GetTime() - 1 |
|
863 | Rilgamon-205066 | addon['db']['profile']['auras'][L['thrown']]['lastexpirationTime'] = addon['db']['profile']['auras'][L['thrown']]['expirationTime'] |
|
864 | Rilgamon-205066 | addon['db']['profile']['auras'][L['thrown']]['count'] = 0 |
|
865 | Rilgamon-205066 | end |
|
866 | Rilgamon-205066 | end |
|
867 | 7 | Rilgamon-205066 | for k,v in pairs(spellBook) do |
868 | Rilgamon-205066 | spellName = "SpellCD_"..k |
|
869 | Rilgamon-205066 | if((addon['db']['profile']['auras'][spellName]) and (addon['db']['profile']['auras'][spellName]['expirationTime'] > GetTime() or addon['db']['profile']['auras'][spellName]['static'])) then |
|
870 | Rilgamon-205066 | auras[#auras+1] = spellName |
|
871 | Rilgamon-205066 | else |
|
872 | Rilgamon-205066 | if(addon['db']['profile']['auras'][spellName]) then |
|
873 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName]['lastTime'] = checkTime |
|
874 | Rilgamon-205066 | end |
|
875 | Rilgamon-205066 | end |
|
876 | Rilgamon-205066 | end |
|
877 | Rilgamon-205066 | ||
878 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras']) do |
|
879 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['warningIcon'] = nil |
|
880 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['warning'] and addon['db']['profile']['auras'][k]['warning'] > 1) then |
|
881 | Rilgamon-205066 | ex = true |
|
882 | Rilgamon-205066 | for r,s in pairs(auras) do |
|
883 | Rilgamon-205066 | if(s == k) then |
|
884 | Rilgamon-205066 | ex = false |
|
885 | Rilgamon-205066 | break |
|
886 | Rilgamon-205066 | end |
|
887 | Rilgamon-205066 | end |
|
888 | Rilgamon-205066 | -- print("+",k,v['warning'],ex) |
|
889 | Rilgamon-205066 | if(ex and (v['warning']==4 or (UnitAffectingCombat("player") and v['warning'] == 2) or (not UnitAffectingCombat("player") and v['warning'] == 3))) then |
|
890 | Rilgamon-205066 | auras[#auras+1] = k |
|
891 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['expirationTime'] = 0 |
|
892 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['count'] = 0 |
|
893 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['warningIcon'] = true |
|
894 | Rilgamon-205066 | end |
|
895 | Rilgamon-205066 | end |
|
896 | Rilgamon-205066 | if(addon['db']['profile']['whitelist'] == 1) then |
|
897 | Rilgamon-205066 | if(k ~= 'Defaults') then |
|
898 | Rilgamon-205066 | ex = true |
|
899 | Rilgamon-205066 | for r,s in pairs(auras) do |
|
900 | Rilgamon-205066 | if(s == k) then |
|
901 | Rilgamon-205066 | ex = false |
|
902 | Rilgamon-205066 | break |
|
903 | Rilgamon-205066 | end |
|
904 | Rilgamon-205066 | end |
|
905 | Rilgamon-205066 | if(ex and ((addon['db']['profile']['auras'][k]['static'] and addon['db']['profile']['auras'][k]['whitelist']==1))) then |
|
906 | Rilgamon-205066 | auras[#auras+1] = k |
|
907 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['expirationTime'] = GetTime() - 1 |
|
908 | Rilgamon-205066 | addon['db']['profile']['auras'][k]['count'] = 0 |
|
909 | Rilgamon-205066 | end |
|
910 | Rilgamon-205066 | end |
|
911 | Rilgamon-205066 | end |
|
912 | Rilgamon-205066 | -- [1] = L['Dont warn'], |
|
913 | Rilgamon-205066 | -- [2] = L['Only in Combat'], |
|
914 | Rilgamon-205066 | -- [3] = L['Only out of Combat'], |
|
915 | Rilgamon-205066 | -- [4] = L['Always'], |
|
916 | Rilgamon-205066 | ||
917 | Rilgamon-205066 | end |
|
918 | Rilgamon-205066 | if(UnitIsDeadOrGhost("player")) then |
|
919 | Rilgamon-205066 | auras = {} |
|
920 | Rilgamon-205066 | addon:updateBar(true) |
|
921 | Rilgamon-205066 | else |
|
922 | Rilgamon-205066 | addon:updateBar() |
|
923 | Rilgamon-205066 | end |
|
924 | Rilgamon-205066 | scanning = nil |
|
925 | Rilgamon-205066 | end |
|
926 | Rilgamon-205066 | ||
927 | Rilgamon-205066 | function addon:addWeaponEnchant(nameWeaponEnchant,iconWeaponEnchant,expirationTimeWeaponEnchant,countWeaponEnchant) |
|
928 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][nameWeaponEnchant]) then |
|
929 | Rilgamon-205066 | addon['db']['profile']['auras'][nameWeaponEnchant] = {} |
|
930 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras'][L['Defaults']]) do |
|
931 | Rilgamon-205066 | addon['db']['profile']['auras'][nameWeaponEnchant][k] = v |
|
932 | Rilgamon-205066 | end |
|
933 | Rilgamon-205066 | end |
|
934 | Rilgamon-205066 | enchantDuration = addon['db']['profile']['auras'][nameWeaponEnchant]['duration'] or 1 |
|
935 | Rilgamon-205066 | if(expirationTimeWeaponEnchant - GetTime() > enchantDuration) then |
|
936 | Rilgamon-205066 | enchantDuration = addon:round(expirationTimeWeaponEnchant - GetTime()) |
|
937 | Rilgamon-205066 | end |
|
938 | Rilgamon-205066 | addon['db']['profile']['auras'][nameWeaponEnchant] = { |
|
939 | Rilgamon-205066 | ['icon'] = iconWeaponEnchant, |
|
940 | Rilgamon-205066 | ['count'] = countWeaponEnchant, |
|
941 | Rilgamon-205066 | ['duration'] = enchantDuration, |
|
942 | Rilgamon-205066 | ['expirationTime'] = addon:round(expirationTimeWeaponEnchant,2), |
|
943 | Rilgamon-205066 | ['unitCaster'] = "player", |
|
944 | Rilgamon-205066 | ['filter'] = "HELPFUL", |
|
945 | Rilgamon-205066 | ['target'] = "player", |
|
946 | Rilgamon-205066 | ['weaponEnchant'] = true, |
|
947 | Rilgamon-205066 | ['priority'] = addon['db']['profile']['auras'][nameWeaponEnchant]['priority'] or addon['db']['profile']['priority'], |
|
948 | Rilgamon-205066 | ['whitelist'] = addon['db']['profile']['auras'][nameWeaponEnchant]['whitelist'] or addon['db']['profile']['whitelist'], |
|
949 | Rilgamon-205066 | ['lastTime'] = addon['db']['profile']['auras'][nameWeaponEnchant]['lastTime'], |
|
950 | Rilgamon-205066 | ['lastexpirationTime'] = addon['db']['profile']['auras'][nameWeaponEnchant]['lastexpirationTime'], |
|
951 | Rilgamon-205066 | ['soundEffect'] = addon['db']['profile']['auras'][nameWeaponEnchant]['soundEffect'], |
|
952 | Rilgamon-205066 | ['playSound'] = addon['db']['profile']['auras'][nameWeaponEnchant]['playSound'], |
|
953 | Rilgamon-205066 | ['ignoreMeOmniCC'] = addon['db']['profile']['auras'][nameWeaponEnchant]['ignoreMeOmniCC'], |
|
954 | Rilgamon-205066 | ['warning'] = addon['db']['profile']['auras'][nameWeaponEnchant]['warning'], |
|
955 | Rilgamon-205066 | ['warningOnly'] = addon['db']['profile']['auras'][nameWeaponEnchant]['warningOnly'], |
|
956 | Rilgamon-205066 | ['showTextTimer'] = addon['db']['profile']['auras'][nameWeaponEnchant]['showTextTimer'], |
|
957 | Rilgamon-205066 | ['spellcounter'] = addon['db']['profile']['auras'][nameWeaponEnchant]['spellcounter'] or 0, |
|
958 | Rilgamon-205066 | ['spellcount'] = addon['db']['profile']['auras'][nameWeaponEnchant]['spellcount'] or 0, |
|
959 | Rilgamon-205066 | } |
|
960 | Rilgamon-205066 | ||
961 | Rilgamon-205066 | -- print(addon['db']['profile']['auras'][nameWeaponEnchant]['lastexpirationTime'],addon['db']['profile']['auras'][nameWeaponEnchant]['expirationTime']) |
|
962 | Rilgamon-205066 | end |
|
963 | Rilgamon-205066 | ||
964 | Rilgamon-205066 | local function sortByTime(a,b) |
|
965 | Rilgamon-205066 | if(addon['db']['profile']['auras'][a] and addon['db']['profile']['auras'][b]) then |
|
966 | Rilgamon-205066 | if(addon['db']['profile']['reverse']) then |
|
967 | Rilgamon-205066 | return addon['db']['profile']['auras'][a]['expirationTime'] < addon['db']['profile']['auras'][b]['expirationTime'] |
|
968 | Rilgamon-205066 | else |
|
969 | Rilgamon-205066 | return addon['db']['profile']['auras'][a]['expirationTime'] > addon['db']['profile']['auras'][b]['expirationTime'] |
|
970 | Rilgamon-205066 | end |
|
971 | Rilgamon-205066 | else |
|
972 | Rilgamon-205066 | return false |
|
973 | Rilgamon-205066 | end |
|
974 | Rilgamon-205066 | end |
|
975 | Rilgamon-205066 | ||
976 | Rilgamon-205066 | local function sortByPrio(a,b) |
|
977 | Rilgamon-205066 | if(addon['db']['profile']['auras'][a] and addon['db']['profile']['auras'][b]) then |
|
978 | Rilgamon-205066 | if(addon['db']['profile']['reverse']) then |
|
979 | Rilgamon-205066 | return addon['db']['profile']['auras'][a]['priority'] < addon['db']['profile']['auras'][b]['priority'] |
|
980 | Rilgamon-205066 | else |
|
981 | Rilgamon-205066 | return addon['db']['profile']['auras'][a]['priority'] > addon['db']['profile']['auras'][b]['priority'] |
|
982 | Rilgamon-205066 | end |
|
983 | Rilgamon-205066 | else |
|
984 | Rilgamon-205066 | return false |
|
985 | Rilgamon-205066 | end |
|
986 | Rilgamon-205066 | end |
|
987 | Rilgamon-205066 | ||
988 | Rilgamon-205066 | function addon:updateBar(reset) |
|
989 | Rilgamon-205066 | addon:checkButtonSpellCD() |
|
990 | Rilgamon-205066 | buttonCount = 0 |
|
991 | Rilgamon-205066 | for k,v in pairs(button) do |
|
992 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]) then |
|
993 | Rilgamon-205066 | if((addon['db']['profile']['auras'][k]['spellCD'] and not addon['db']['profile']['auras'][k]['static']) or (not addon['db']['profile']['auras'][k]['spellCD'])) then |
|
994 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][k]['static']) then |
|
995 | Rilgamon-205066 | addon:removeButton(k, reset) |
|
996 | Rilgamon-205066 | else |
|
997 | Rilgamon-205066 | buttonCount = buttonCount + 1 |
|
998 | Rilgamon-205066 | end |
|
999 | Rilgamon-205066 | else |
|
1000 | Rilgamon-205066 | buttonCount = buttonCount + 1 |
|
1001 | Rilgamon-205066 | end |
|
1002 | Rilgamon-205066 | end |
|
1003 | Rilgamon-205066 | end |
|
1004 | Rilgamon-205066 | lastTime = checkTime |
|
1005 | Rilgamon-205066 | checkTime = GetTime() |
|
1006 | Rilgamon-205066 | if(auras) then |
|
1007 | Rilgamon-205066 | if(addon['db']['profile']['sorting'] == 1) then |
|
1008 | Rilgamon-205066 | lsort = sortByPrio |
|
1009 | Rilgamon-205066 | else |
|
1010 | Rilgamon-205066 | lsort = sortByTime |
|
1011 | Rilgamon-205066 | end |
|
1012 | Rilgamon-205066 | table.sort(auras,function(a,b) return sortByPrio(a,b) end) |
|
1013 | Rilgamon-205066 | for k,v in pairs(auras) do |
|
1014 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v] and addon['db']['profile']['auras'][v]['whitelist'] == 1 and (addon['db']['profile']['auras'][v]['expirationTime'] > checkTime or (addon['db']['profile']['auras'][v]['static']))) then |
|
1015 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['lastTime'] ~= lastTime) then |
|
1016 | Rilgamon-205066 | addon:auraAdded(v) |
|
1017 | Rilgamon-205066 | elseif(addon['db']['profile']['auras'][v]['lastexpirationTime'] and addon['db']['profile']['auras'][v]['expirationTime'] > addon['db']['profile']['auras'][v]['lastexpirationTime'] and addon['db']['profile']['auras'][v]['expirationTime'] > GetTime()) then |
|
1018 | Rilgamon-205066 | addon:auraAdded(v,true) |
|
1019 | Rilgamon-205066 | end |
|
1020 | Rilgamon-205066 | -- addon['db']['profile']['auras'][v]['lastexpirationTime'] = addon['db']['profile']['auras'][v]['expirationTime'] |
|
1021 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['warningIcon']) then |
|
1022 | Rilgamon-205066 | addon['db']['profile']['auras'][v]['lastTime'] = checkTime |
|
1023 | Rilgamon-205066 | end |
|
1024 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['spellCD'] and addon['db']['profile']['auras'][v]['static']) then |
|
1025 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['whitelist']==1) then |
|
1026 | Rilgamon-205066 | if(not button[v]) then |
|
1027 | Rilgamon-205066 | buttonCount = buttonCount + 1 |
|
1028 | Rilgamon-205066 | addon:getButton(v) |
|
1029 | Rilgamon-205066 | button[v]['nr'] = buttonCount |
|
1030 | Rilgamon-205066 | button[v]['Icon']:SetTexture(addon['db']['profile']['auras'][v]['icon'] or "Interface\\Icons\\Ability_Warrior_PunishingBlow") |
|
1031 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['static']) then |
|
1032 | Rilgamon-205066 | button[v]:Show() |
|
1033 | Rilgamon-205066 | end |
|
1034 | Rilgamon-205066 | end |
|
1035 | Rilgamon-205066 | if(button[v]['Cooldown']) then |
|
1036 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['expirationTime'] > GetTime() and addon['db']['profile']['auras'][v]['duration'] > 0) then |
|
1037 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['showTextTimer']) then |
|
1038 | Rilgamon-205066 | button[v]['TextTimer']:ClearAllPoints() |
|
1039 | Rilgamon-205066 | button[v]['TextTimer']:SetPoint(addon['db']['global']['timerAnchor'] or "TOPLEFT",button[v],addon['db']['global']['timerAnchor'] or "TOPLEFT",addon['db']['global']['timerxOffset'],addon['db']['global']['timeryOffset']) |
|
1040 | Rilgamon-205066 | button[v]['TextTimer']:SetJustifyH(addon['db']['global']['timerfontAnchorX'] or "TOP") |
|
1041 | Rilgamon-205066 | button[v]['TextTimer']:SetJustifyV(addon['db']['global']['timerfontAnchorY'] or "LEFT") |
|
1042 | Rilgamon-205066 | button[v]['TextTimer']:Show() |
|
1043 | Rilgamon-205066 | button[v]['TextTimer']:SetTextColor(addon['db']['global']['timerColor'][1],addon['db']['global']['timerColor'][2],addon['db']['global']['timerColor'][3],addon['db']['global']['timerColor'][4]) |
|
1044 | Rilgamon-205066 | button[v]['TextTimer']:SetText(addon:formatTextTimer(addon:round(addon['db']['profile']['auras'][v]['expirationTime'] - GetTime()))) |
|
1045 | Rilgamon-205066 | end |
|
1046 | Rilgamon-205066 | CooldownFrame_SetTimer(button[v]['Cooldown'], addon['db']['profile']['auras'][v]['expirationTime'] - addon['db']['profile']['auras'][v]['duration'], addon['db']['profile']['auras'][v]['duration'], 1) |
|
1047 | Rilgamon-205066 | elseif(addon['db']['profile']['auras'][v]['static']) then |
|
1048 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['spellCD']) then |
|
1049 | Rilgamon-205066 | CooldownFrame_SetTimer(button[v]['Cooldown'], 360, 360, 1) |
|
1050 | Rilgamon-205066 | end |
|
1051 | Rilgamon-205066 | button[v]['TextTimer']:Hide() |
|
1052 | Rilgamon-205066 | end |
|
1053 | Rilgamon-205066 | end |
|
1054 | Rilgamon-205066 | if(IsUsableSpell(string.sub(v,9)) and IsSpellInRange(addon['db']['profile']['auras'][v]['spellCDId'],"spell", UnitExists("target") and "target" or "player") == 1) then |
|
1055 | Rilgamon-205066 | button[v]['Icon']:SetVertexColor(1, 1, 1, 1) |
|
1056 | Rilgamon-205066 | else |
|
1057 | Rilgamon-205066 | if(not IsUsableSpell(string.sub(v,9))) then |
|
1058 | Rilgamon-205066 | button[v]['Icon']:SetVertexColor(1, 1, 1, .25) |
|
1059 | Rilgamon-205066 | else |
|
1060 | Rilgamon-205066 | button[v]['Icon']:SetVertexColor(1, 0, 0, 1) |
|
1061 | Rilgamon-205066 | end |
|
1062 | Rilgamon-205066 | end |
|
1063 | Rilgamon-205066 | end |
|
1064 | Rilgamon-205066 | end |
|
1065 | Rilgamon-205066 | end |
|
1066 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]) then |
|
1067 | Rilgamon-205066 | addon['db']['profile']['auras'][v]['lastexpirationTime'] = addon['db']['profile']['auras'][v]['expirationTime'] |
|
1068 | Rilgamon-205066 | end |
|
1069 | Rilgamon-205066 | end |
|
1070 | Rilgamon-205066 | addon:resetSpellCDLastTime() |
|
1071 | Rilgamon-205066 | table.sort(auras,function(a,b) return lsort(a,b) end) |
|
1072 | Rilgamon-205066 | for k,v in pairs(auras) do |
|
1073 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]) then |
|
1074 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['whitelist']==1) then |
|
1075 | Rilgamon-205066 | if((addon['db']['profile']['auras'][v]['spellCD'] and not addon['db']['profile']['auras'][v]['static']) or (not addon['db']['profile']['auras'][v]['spellCD']) or addon['db']['profile']['auras'][v]['warningIcon']) then |
|
1076 | Rilgamon-205066 | -- print(v,addon['db']['profile']['auras'][v]['warningOnly']) |
|
1077 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['warningOnly']) then |
|
1078 | Rilgamon-205066 | buttonCount = buttonCount + 1 |
|
1079 | Rilgamon-205066 | addon:getButton(v) |
|
1080 | Rilgamon-205066 | button[v]['nr'] = buttonCount |
|
1081 | Rilgamon-205066 | button[v]['Icon']:SetTexture(addon['db']['profile']['auras'][v]['icon'] or "Interface\\Icons\\Ability_Warrior_PunishingBlow") |
|
1082 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['static']) then |
|
1083 | Rilgamon-205066 | button[v]:Show() |
|
1084 | Rilgamon-205066 | end |
|
1085 | Rilgamon-205066 | txt = addon['db']['profile']['auras'][v]['count'] or 0 |
|
1086 | Rilgamon-205066 | -- txt = 15 |
|
1087 | Rilgamon-205066 | if(txt < 2) then |
|
1088 | Rilgamon-205066 | txt = "" |
|
1089 | Rilgamon-205066 | end |
|
1090 | Rilgamon-205066 | ||
1091 | Rilgamon-205066 | if(button[v]['Count']) then |
|
1092 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['charges']) then |
|
1093 | Rilgamon-205066 | button[v]['Count']:Hide() |
|
1094 | Rilgamon-205066 | else |
|
1095 | Rilgamon-205066 | button[v]['Count']:ClearAllPoints() |
|
1096 | Rilgamon-205066 | button[v]['Count']:SetPoint(addon['db']['global']['chargesAnchor'] or "BOTTOMRIGHT",button[v],addon['db']['global']['chargesAnchor'] or "BOTTOMRIGHT",addon['db']['global']['xOffset'],addon['db']['global']['yOffset']) |
|
1097 | Rilgamon-205066 | button[v]['Count']:SetJustifyH(addon['db']['global']['fontAnchorX'] or "BOTTOM") |
|
1098 | Rilgamon-205066 | button[v]['Count']:SetJustifyV(addon['db']['global']['fontAnchorY'] or "RIGHT") |
|
1099 | Rilgamon-205066 | button[v]['Count']:Show() |
|
1100 | Rilgamon-205066 | button[v]['Count']:SetTextColor(addon['db']['global']['chargesColor'][1],addon['db']['global']['chargesColor'][2],addon['db']['global']['chargesColor'][3],addon['db']['global']['chargesColor'][4]) |
|
1101 | Rilgamon-205066 | button[v]['Count']:SetText(txt) |
|
1102 | Rilgamon-205066 | end |
|
1103 | Rilgamon-205066 | end |
|
1104 | Rilgamon-205066 | if(button[v]['Cooldown']) then |
|
1105 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['expirationTime'] > GetTime()) then |
|
1106 | Rilgamon-205066 | if(addon['db']['profile']['auras'][v]['showTextTimer']) then |
|
1107 | Rilgamon-205066 | button[v]['TextTimer']:ClearAllPoints() |
|
1108 | Rilgamon-205066 | button[v]['TextTimer']:SetPoint(addon['db']['global']['timerAnchor'] or "TOPLEFT",button[v],addon['db']['global']['timerAnchor'] or "TOPLEFT",addon['db']['global']['timerxOffset'],addon['db']['global']['timeryOffset']) |
|
1109 | Rilgamon-205066 | button[v]['TextTimer']:SetJustifyH(addon['db']['global']['timerfontAnchorX'] or "TOP") |
|
1110 | Rilgamon-205066 | button[v]['TextTimer']:SetJustifyV(addon['db']['global']['timerfontAnchorY'] or "LEFT") |
|
1111 | Rilgamon-205066 | button[v]['TextTimer']:Show() |
|
1112 | Rilgamon-205066 | button[v]['TextTimer']:SetTextColor(addon['db']['global']['timerColor'][1],addon['db']['global']['timerColor'][2],addon['db']['global']['timerColor'][3],addon['db']['global']['timerColor'][4]) |
|
1113 | Rilgamon-205066 | button[v]['TextTimer']:SetText(addon:formatTextTimer(addon:round(addon['db']['profile']['auras'][v]['expirationTime'] - GetTime()))) |
|
1114 | Rilgamon-205066 | end |
|
1115 | Rilgamon-205066 | -- print(v,addon['db']['profile']['auras'][v]['expirationTime'],addon['db']['profile']['auras'][v]['duration']) |
|
1116 | Rilgamon-205066 | CooldownFrame_SetTimer(button[v]['Cooldown'], addon['db']['profile']['auras'][v]['expirationTime'] - addon['db']['profile']['auras'][v]['duration'], addon['db']['profile']['auras'][v]['duration'], 1) |
|
1117 | Rilgamon-205066 | elseif(addon['db']['profile']['auras'][v]['static'] or addon['db']['profile']['auras'][v]['warning']) then |
|
1118 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][v]['spellCD']) then |
|
1119 | Rilgamon-205066 | CooldownFrame_SetTimer(button[v]['Cooldown'], 360, 360, 1) |
|
1120 | Rilgamon-205066 | end |
|
1121 | Rilgamon-205066 | button[v]['TextTimer']:Hide() |
|
1122 | Rilgamon-205066 | end |
|
1123 | Rilgamon-205066 | end |
|
1124 | Rilgamon-205066 | elseif(addon['db']['profile']['auras'][v]['warningIcon']) then |
|
1125 | Rilgamon-205066 | buttonCount = buttonCount + 1 |
|
1126 | Rilgamon-205066 | addon:getButton(v) |
|
1127 | Rilgamon-205066 | button[v]['nr'] = buttonCount |
|
1128 | Rilgamon-205066 | button[v]['Icon']:SetTexture(addon['db']['profile']['auras'][v]['icon'] or "Interface\\Icons\\Ability_Warrior_PunishingBlow") |
|
1129 | Rilgamon-205066 | button[v]:Show() |
|
1130 | Rilgamon-205066 | end |
|
1131 | Rilgamon-205066 | end |
|
1132 | Rilgamon-205066 | end |
|
1133 | Rilgamon-205066 | -- print(v,addon['db']['profile']['auras'][v]['warning'],addon['db']['profile']['auras'][v]['warningIcon']) |
|
1134 | Rilgamon-205066 | if(button[v] and addon['db']['profile']['auras'][v]['warningIcon']) then |
|
1135 | Rilgamon-205066 | button[v]['Warning']:Show() |
|
1136 | Rilgamon-205066 | end |
|
1137 | Rilgamon-205066 | end |
|
1138 | Rilgamon-205066 | end |
|
1139 | Rilgamon-205066 | end |
|
1140 | Rilgamon-205066 | end |
|
1141 | Rilgamon-205066 | ||
1142 | Rilgamon-205066 | function addon:formatTextTimer(text) |
|
1143 | Rilgamon-205066 | if(text == 0 or not text) then return "" end |
|
1144 | Rilgamon-205066 | if(addon['db']['global']['displayMode'] == 1) then |
|
1145 | Rilgamon-205066 | if(text>60) then |
|
1146 | Rilgamon-205066 | text = tostring(addon:round(text/60).."m") |
|
1147 | Rilgamon-205066 | end |
|
1148 | Rilgamon-205066 | end |
|
1149 | Rilgamon-205066 | return text |
|
1150 | Rilgamon-205066 | end |
|
1151 | Rilgamon-205066 | ||
1152 | Rilgamon-205066 | function addon:auraAdded(name,refreshed,spell) |
|
1153 | Rilgamon-205066 | if(not spell) then |
|
1154 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['spellCD']) then return end |
|
1155 | Rilgamon-205066 | end |
|
1156 | Rilgamon-205066 | if(not addon['configDone']) then return end |
|
1157 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['soundPlayed']) then return end |
|
1158 | Rilgamon-205066 | addon['db']['profile']['auras'][name]['soundPlayed'] = true |
|
1159 | Rilgamon-205066 | if(refreshed) then |
|
1160 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['lastTime'] == lastTime) then |
|
1161 | Rilgamon-205066 | addon['db']['profile']['auras'][name]['spellcounter'] = addon['db']['profile']['auras'][name]['spellcounter'] or 0 |
|
1162 | Rilgamon-205066 | addon['db']['profile']['auras'][name]['spellcounter'] = addon['db']['profile']['auras'][name]['spellcounter'] + 1 |
|
1163 | Rilgamon-205066 | end |
|
1164 | Rilgamon-205066 | else |
|
1165 | Rilgamon-205066 | if(button[name])then |
|
1166 | Rilgamon-205066 | skullReset(button[name]['Warning']) |
|
1167 | Rilgamon-205066 | button[name]['Warning']:Hide() |
|
1168 | Rilgamon-205066 | end |
|
1169 | Rilgamon-205066 | addon['db']['profile']['auras'][name]['spellcount'] = addon['db']['profile']['auras'][name]['spellcount'] or 0 |
|
1170 | Rilgamon-205066 | addon['db']['profile']['auras'][name]['spellcount'] = addon['db']['profile']['auras'][name]['spellcount'] + 1 |
|
1171 | Rilgamon-205066 | end |
|
1172 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['playSound'] and addon['db']['profile']['auras'][name]['soundEffect']) then |
|
1173 | Rilgamon-205066 | if(LSM) then |
|
1174 | Rilgamon-205066 | PlaySoundFile(addon['db']['profile']['auras'][name]['soundEffect']) |
|
1175 | Rilgamon-205066 | -- addon:pdebug(tostring(name).." "..tostring(refreshed).." "..tostring(spell).."-"..tostring(addon['db']['profile']['auras'][name]['soundPlayed'])) |
|
1176 | Rilgamon-205066 | -- addon:pdebug(tostring(checkTime).."/"..tostring(GetTime()).."-"..tostring(addon['db']['profile']['auras'][name]['expirationTime']).."/"..tostring(addon['db']['profile']['auras'][name]['lastexpirationTime'])) |
|
1177 | Rilgamon-205066 | else |
|
1178 | Rilgamon-205066 | PlaySound("FriendJoinGame") |
|
1179 | Rilgamon-205066 | end |
|
1180 | Rilgamon-205066 | end |
|
1181 | Rilgamon-205066 | addon:resetSpellCDLastTime() |
|
1182 | Rilgamon-205066 | end |
|
1183 | Rilgamon-205066 | ||
1184 | Rilgamon-205066 | function addon:resetSpellCDLastTime() |
|
1185 | Rilgamon-205066 | for k,v in pairs(spellBook) do |
|
1186 | Rilgamon-205066 | spellName = "SpellCD_"..k |
|
1187 | Rilgamon-205066 | if(addon['db']['profile']['auras'][spellName]) then |
|
1188 | Rilgamon-205066 | addon['db']['profile']['auras'][spellName]['lastTime'] = checkTime |
|
1189 | Rilgamon-205066 | end |
|
1190 | Rilgamon-205066 | end |
|
1191 | Rilgamon-205066 | end |
|
1192 | Rilgamon-205066 | ||
1193 | Rilgamon-205066 | function addon:joinTable(t1,t2) |
|
1194 | Rilgamon-205066 | if(type(t1) == 'table' and type(t2) ~= 'table') then return t1 end |
|
1195 | Rilgamon-205066 | if(type(t2) == 'table' and type(t1) ~= 'table') then return t2 end |
|
1196 | Rilgamon-205066 | if(type(t1) ~= 'table' and type(t2) ~= 'table') then return {} end |
|
1197 | Rilgamon-205066 | tbl = t1 |
|
1198 | Rilgamon-205066 | for k,v in pairs(t2) do |
|
1199 | Rilgamon-205066 | ex = true |
|
1200 | Rilgamon-205066 | for r,s in pairs(t1) do |
|
1201 | Rilgamon-205066 | if(v == s) then |
|
1202 | Rilgamon-205066 | ex = false |
|
1203 | Rilgamon-205066 | break |
|
1204 | Rilgamon-205066 | end |
|
1205 | Rilgamon-205066 | end |
|
1206 | Rilgamon-205066 | if(ex) then |
|
1207 | Rilgamon-205066 | tbl[#tbl+1] = v |
|
1208 | Rilgamon-205066 | end |
|
1209 | Rilgamon-205066 | end |
|
1210 | Rilgamon-205066 | return tbl |
|
1211 | Rilgamon-205066 | end |
|
1212 | Rilgamon-205066 | ||
1213 | Rilgamon-205066 | function addon:scanBuffs(target, filter) |
|
1214 | Rilgamon-205066 | if(UnitIsDeadOrGhost(target)) then return {} end |
|
1215 | Rilgamon-205066 | if(not UnitExists(target)) then return {} end |
|
1216 | Rilgamon-205066 | buffs = {} |
|
1217 | Rilgamon-205066 | if(scannedUnits[filter][UnitGUID(target)] == true) then |
|
1218 | Rilgamon-205066 | return {} |
|
1219 | Rilgamon-205066 | end |
|
1220 | Rilgamon-205066 | scannedUnits[filter][UnitGUID(target)] = true |
|
1221 | Rilgamon-205066 | target = target or "player" |
|
1222 | Rilgamon-205066 | filter = filter or "HELPFUL" |
|
1223 | Rilgamon-205066 | for i = 1,40 do |
|
1224 | Rilgamon-205066 | buffs[#buffs+1] = addon:storeBuff(target, filter, UnitAura(target, i, filter)) |
|
1225 | Rilgamon-205066 | end |
|
1226 | Rilgamon-205066 | return buffs |
|
1227 | Rilgamon-205066 | end |
|
1228 | Rilgamon-205066 | ||
1229 | Rilgamon-205066 | function addon:storeBuff(target, filter, name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId) |
|
1230 | Rilgamon-205066 | if(name and unitCaster == 'player') then |
|
1231 | Rilgamon-205066 | ex = false |
|
1232 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][name]) then |
|
1233 | Rilgamon-205066 | addon['db']['profile']['auras'][name] = {} |
|
1234 | Rilgamon-205066 | for k,v in pairs(addon['db']['profile']['auras'][L['Defaults']]) do |
|
1235 | Rilgamon-205066 | addon['db']['profile']['auras'][name][k] = v |
|
1236 | Rilgamon-205066 | end |
|
1237 | Rilgamon-205066 | ex = true |
|
1238 | Rilgamon-205066 | end |
|
1239 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][name]['spellCD']) then |
|
1240 | Rilgamon-205066 | if(duration == 0 or not duration) then |
|
1241 | Rilgamon-205066 | duration = 9999 |
|
1242 | Rilgamon-205066 | expirationTime = GetTime() + duration |
|
1243 | Rilgamon-205066 | end |
|
1244 | Rilgamon-205066 | end |
|
1245 | Rilgamon-205066 | addon['db']['profile']['auras'][name] = { |
|
1246 | Rilgamon-205066 | ['rank'] = rank, |
|
1247 | Rilgamon-205066 | ['icon'] = icon, |
|
1248 | Rilgamon-205066 | ['count'] = count, |
|
1249 | Rilgamon-205066 | ['debuffType'] = debuffType, |
|
1250 | Rilgamon-205066 | ['duration'] = duration, |
|
1251 | Rilgamon-205066 | ['expirationTime'] = expirationTime, |
|
1252 | Rilgamon-205066 | ['unitCaster'] = unitCaster, |
|
1253 | Rilgamon-205066 | ['isStealable'] = isStealable, |
|
1254 | Rilgamon-205066 | ['shouldConsolidate'] = shouldConsolidate, |
|
1255 | Rilgamon-205066 | ['spellId'] = spellId, |
|
1256 | Rilgamon-205066 | ['filter'] = filter, |
|
1257 | Rilgamon-205066 | ['target'] = target, |
|
1258 | Rilgamon-205066 | ['priority'] = addon['db']['profile']['auras'][name]['priority'], |
|
1259 | Rilgamon-205066 | ['charges'] = addon['db']['profile']['auras'][name]['charges'], |
|
1260 | Rilgamon-205066 | ['static'] = addon['db']['profile']['auras'][name]['static'], |
|
1261 | Rilgamon-205066 | ['whitelist'] = addon['db']['profile']['auras'][name]['whitelist'] or txt, |
|
1262 | Rilgamon-205066 | ['lastTime'] = addon['db']['profile']['auras'][name]['lastTime'], |
|
1263 | Rilgamon-205066 | ['lastexpirationTime'] = addon['db']['profile']['auras'][name]['lastexpirationTime'], |
|
1264 | Rilgamon-205066 | ['soundEffect'] = addon['db']['profile']['auras'][name]['soundEffect'], |
|
1265 | Rilgamon-205066 | ['playSound'] = addon['db']['profile']['auras'][name]['playSound'], |
|
1266 | Rilgamon-205066 | ['ignoreMeOmniCC'] = addon['db']['profile']['auras'][name]['ignoreMeOmniCC'], |
|
1267 | Rilgamon-205066 | ['warning'] = addon['db']['profile']['auras'][name]['warning'], |
|
1268 | Rilgamon-205066 | ['warningOnly'] = addon['db']['profile']['auras'][name]['warningOnly'], |
|
1269 | Rilgamon-205066 | ['showTextTimer'] = addon['db']['profile']['auras'][name]['showTextTimer'], |
|
1270 | Rilgamon-205066 | ['spellcounter'] = addon['db']['profile']['auras'][name]['spellcounter'] or 0, |
|
1271 | Rilgamon-205066 | ['spellcount'] = addon['db']['profile']['auras'][name]['spellcount'] or 0, |
|
1272 | Rilgamon-205066 | } |
|
1273 | Rilgamon-205066 | if(ex) then |
|
1274 | Rilgamon-205066 | addon:buildSpellList() |
|
1275 | Rilgamon-205066 | end |
|
1276 | Rilgamon-205066 | return name |
|
1277 | Rilgamon-205066 | end |
|
1278 | Rilgamon-205066 | return nil |
|
1279 | Rilgamon-205066 | end |
|
1280 | Rilgamon-205066 | ||
1281 | Rilgamon-205066 | function addon:positionButton(bt) |
|
1282 | Rilgamon-205066 | bt:ClearAllPoints() |
|
1283 | Rilgamon-205066 | if(addon['db']['global']['vertical']) then |
|
1284 | Rilgamon-205066 | buttonSpacing = 0 |
|
1285 | Rilgamon-205066 | buttonSpacing2 = addon['db']['global']['spacing'] or 8 |
|
1286 | Rilgamon-205066 | if(addon['db']['global']['growth']) then |
|
1287 | Rilgamon-205066 | buttonAnchor = "BOTTOMLEFT" |
|
1288 | Rilgamon-205066 | buttonParentanchor = "TOPLEFT" |
|
1289 | Rilgamon-205066 | else |
|
1290 | Rilgamon-205066 | buttonSpacing2 = buttonSpacing2 * -1 |
|
1291 | Rilgamon-205066 | buttonAnchor = "TOPLEFT" |
|
1292 | Rilgamon-205066 | buttonParentanchor = "BOTTOMLEFT" |
|
1293 | Rilgamon-205066 | end |
|
1294 | Rilgamon-205066 | else |
|
1295 | Rilgamon-205066 | buttonSpacing = addon['db']['global']['spacing'] or 8 |
|
1296 | Rilgamon-205066 | buttonSpacing2 = 0 |
|
1297 | Rilgamon-205066 | if(addon['db']['global']['growth']) then |
|
1298 | Rilgamon-205066 | buttonAnchor = "TOPRIGHT" |
|
1299 | Rilgamon-205066 | buttonParentanchor = "TOPLEFT" |
|
1300 | Rilgamon-205066 | buttonSpacing = buttonSpacing * -1 |
|
1301 | Rilgamon-205066 | else |
|
1302 | Rilgamon-205066 | buttonAnchor = "TOPLEFT" |
|
1303 | Rilgamon-205066 | buttonParentanchor = "TOPRIGHT" |
|
1304 | Rilgamon-205066 | end |
|
1305 | Rilgamon-205066 | end |
|
1306 | Rilgamon-205066 | pb = addon:getButtonByNumber(buttonCount-1) |
|
1307 | Rilgamon-205066 | while(pb == bt) do |
|
1308 | Rilgamon-205066 | buttonCount = buttonCount - 1 |
|
1309 | Rilgamon-205066 | pb = addon:getButtonByNumber(buttonCount-1) |
|
1310 | Rilgamon-205066 | end |
|
1311 | Rilgamon-205066 | bt:SetPoint(buttonAnchor,pb,buttonParentanchor,buttonSpacing,buttonSpacing2) |
|
1312 | Rilgamon-205066 | end |
|
1313 | Rilgamon-205066 | ||
1314 | Rilgamon-205066 | function addon:getButton(name) |
|
1315 | Rilgamon-205066 | if(button[name]) then |
|
1316 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][name]['static']) then |
|
1317 | Rilgamon-205066 | addon:positionButton(button[name]) |
|
1318 | Rilgamon-205066 | end |
|
1319 | Rilgamon-205066 | return button[name] |
|
1320 | Rilgamon-205066 | else |
|
1321 | Rilgamon-205066 | return addon:createButton(name) |
|
1322 | Rilgamon-205066 | end |
|
1323 | Rilgamon-205066 | end |
|
1324 | Rilgamon-205066 | ||
1325 | Rilgamon-205066 | local function buttonRightClick(self, buttonClick, down) |
|
1326 | Rilgamon-205066 | if(buttonClick == 'RightButton' and addon['db']['profile']['removeAura']) then |
|
1327 | Rilgamon-205066 | if(addon['db']['profile']['auras'][self['name']]['target'] == 'player') then |
|
1328 | Rilgamon-205066 | if(self['name'] == L['mainhand']) then |
|
1329 | Rilgamon-205066 | CancelItemTempEnchantment(1) |
|
1330 | Rilgamon-205066 | elseif(self['name'] == L['offhand']) then |
|
1331 | Rilgamon-205066 | CancelItemTempEnchantment(2) |
|
1332 | Rilgamon-205066 | else |
|
1333 | Rilgamon-205066 | CancelUnitBuff('player',self['name']) |
|
1334 | Rilgamon-205066 | end |
|
1335 | Rilgamon-205066 | end |
|
1336 | Rilgamon-205066 | end |
|
1337 | Rilgamon-205066 | end |
|
1338 | Rilgamon-205066 | ||
1339 | Rilgamon-205066 | local function skullFade(self,elapsed) |
|
1340 | Rilgamon-205066 | self['elapsed'] = self['elapsed'] + elapsed |
|
1341 | Rilgamon-205066 | if self['elapsed'] < self['animSpeed'] then return end |
|
1342 | Rilgamon-205066 | alpha = self:GetAlpha() |
|
1343 | Rilgamon-205066 | alpha = alpha + self['animStep'] |
|
1344 | Rilgamon-205066 | if(alpha > 1) then |
|
1345 | Rilgamon-205066 | alpha = 1 |
|
1346 | Rilgamon-205066 | self['animStep'] = -self['animStep'] |
|
1347 | Rilgamon-205066 | elseif(alpha < 0) then |
|
1348 | Rilgamon-205066 | alpha = 0 |
|
1349 | Rilgamon-205066 | self['animStep'] = -self['animStep'] |
|
1350 | Rilgamon-205066 | end |
|
1351 | Rilgamon-205066 | self['elapsed'] = 0 |
|
1352 | Rilgamon-205066 | ||
1353 | Rilgamon-205066 | self:SetAlpha(alpha) |
|
1354 | Rilgamon-205066 | end |
|
1355 | Rilgamon-205066 | ||
1356 | Rilgamon-205066 | local function gametooltiphide() |
|
1357 | Rilgamon-205066 | GameTooltip:Hide() |
|
1358 | Rilgamon-205066 | end |
|
1359 | Rilgamon-205066 | ||
1360 | Rilgamon-205066 | local function gametooltipshow(self) |
|
1361 | Rilgamon-205066 | name = self['name'] |
|
1362 | Rilgamon-205066 | if(not addon['db']['profile']['showTooltip']) then return end |
|
1363 | Rilgamon-205066 | if(name and addon['db']['profile']['auras'][name]) then |
|
1364 | Rilgamon-205066 | GameTooltip:SetOwner(button[name],"ANCHOR_TOPRIGHT") |
|
1365 | Rilgamon-205066 | GameTooltip:ClearLines() |
|
1366 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['spellCD']) then |
|
1367 | Rilgamon-205066 | GameTooltip:SetSpellBookItem(addon['db']['profile']['auras'][name]['spellCDId'], BOOKTYPE_SPELL) |
|
1368 | Rilgamon-205066 | else |
|
1369 | Rilgamon-205066 | index = nil |
|
1370 | Rilgamon-205066 | for i=1,40 do |
|
1371 | Rilgamon-205066 | if(select(1,UnitAura(addon['db']['profile']['auras'][name]['target'],i,addon['db']['profile']['auras'][name]['filter'])) == name) then |
|
1372 | Rilgamon-205066 | index = i |
|
1373 | Rilgamon-205066 | break |
|
1374 | Rilgamon-205066 | end |
|
1375 | Rilgamon-205066 | end |
|
1376 | Rilgamon-205066 | ||
1377 | Rilgamon-205066 | if(index) then |
|
1378 | Rilgamon-205066 | GameTooltip:SetUnitAura(addon['db']['profile']['auras'][name]['target'],index,addon['db']['profile']['auras'][name]['filter']) |
|
1379 | Rilgamon-205066 | elseif(name==L['mainhand'] or name==L['offhand']) then |
|
1380 | Rilgamon-205066 | if(name==L['mainhand']) then |
|
1381 | Rilgamon-205066 | invSlot = 16 |
|
1382 | Rilgamon-205066 | else |
|
1383 | Rilgamon-205066 | invSlot = 17 |
|
1384 | Rilgamon-205066 | end |
|
1385 | Rilgamon-205066 | GameTooltip:SetInventoryItem("player", invSlot) |
|
1386 | Rilgamon-205066 | else |
|
1387 | Rilgamon-205066 | GameTooltip:AddLine(name) |
|
1388 | Rilgamon-205066 | end |
|
1389 | Rilgamon-205066 | end |
|
1390 | Rilgamon-205066 | GameTooltip:Show() |
|
1391 | Rilgamon-205066 | end |
|
1392 | Rilgamon-205066 | end |
|
1393 | Rilgamon-205066 | ||
1394 | Rilgamon-205066 | function addon:createButton(name) |
|
1395 | Rilgamon-205066 | if(addon['db']['profile']['auras'][name]['spellCD'] and addon['db']['profile']['auras'][name]['static']) then |
|
1396 | Rilgamon-205066 | button[name] = CreateFrame("Button","PWB_"..name, addon['mainframe'],"ActionButtonTemplate SecureActionButtonTemplate") |
|
1397 | Rilgamon-205066 | button[name]:SetAttribute("type", "spell") |
|
1398 | Rilgamon-205066 | button[name]:SetAttribute("checkselfcast", true) |
|
1399 | Rilgamon-205066 | button[name]:SetAttribute("spell", string.sub(name,9)) |
|
1400 | Rilgamon-205066 | elseif(addon['db']['profile']['auras'][name]['static']) then |
|
1401 | Rilgamon-205066 | button[name] = CreateFrame("Button","PWB_"..name, addon['mainframe'],"ActionButtonTemplate SecureActionButtonTemplate") |
|
1402 | Rilgamon-205066 | button[name]:SetAttribute("type", "cancelaura") |
|
1403 | Rilgamon-205066 | button[name]:SetAttribute("spell", name) |
|
1404 | Rilgamon-205066 | button[name]:SetAttribute("unit", "player") |
|
1405 | Rilgamon-205066 | button[name]:RegisterForClicks("RightButtonUp") |
|
1406 | Rilgamon-205066 | else |
|
1407 | Rilgamon-205066 | button[name] = CreateFrame("Button","PWB_"..name, addon['mainframe'],"ActionButtonTemplate") |
|
1408 | Rilgamon-205066 | button[name]:EnableMouse(true) |
|
1409 | Rilgamon-205066 | button[name]:SetScript("OnMouseDown", buttonRightClick) |
|
1410 | Rilgamon-205066 | end |
|
1411 | Rilgamon-205066 | button[name]['name'] = name |
|
1412 | Rilgamon-205066 | button[name]:SetWidth(64) |
|
1413 | Rilgamon-205066 | button[name]:SetHeight(64) |
|
1414 | Rilgamon-205066 | ||
1415 | Rilgamon-205066 | button[name]:SetScript("OnEnter", gametooltipshow) |
|
1416 | Rilgamon-205066 | button[name]:SetScript("OnLeave", gametooltiphide) |
|
1417 | Rilgamon-205066 | addon:positionButton(button[name]) |
|
1418 | Rilgamon-205066 | button[name]['Warning'] = CreateFrame("Frame","$PARENTWarning",button[name]) |
|
1419 | Rilgamon-205066 | button[name]['Warning']:SetWidth(96) |
|
1420 | Rilgamon-205066 | button[name]['Warning']:SetHeight(96) |
|
1421 | Rilgamon-205066 | button[name]['Warning']:SetPoint("CENTER",button[name],"CENTER",0,0) |
|
1422 | Rilgamon-205066 | button[name]['Warning']:SetFrameStrata("HIGH") |
|
1423 | Rilgamon-205066 | button[name]['Warning']:SetScript("OnUpdate", skullFade) |
|
1424 | Rilgamon-205066 | -- button[name]['Warning']:SetScript("OnHide", skullReset) |
|
1425 | Rilgamon-205066 | skullReset(button[name]['Warning']) |
|
1426 | Rilgamon-205066 | button[name]['Warning']:Hide() |
|
1427 | Rilgamon-205066 | button[name]['WarningTexture'] = button[name]['Warning']:CreateTexture() |
|
1428 | Rilgamon-205066 | button[name]['WarningTexture']:SetAllPoints(button[name]['Warning']) |
|
1429 | Rilgamon-205066 | button[name]['WarningTexture']:SetTexture("Interface\\AddOns\\zz_ProcWatch\\skull.tga") |
|
1430 | Rilgamon-205066 | ||
1431 | Rilgamon-205066 | button[name]['Icon'] = _G["PWB_"..name.."Icon"] |
|
1432 | Rilgamon-205066 | button[name]['Icon']:SetTexture(addon['db']['profile']['auras'][name]['icon'] or "Interface\\Icons\\Ability_Warrior_PunishingBlow") |
|
1433 | Rilgamon-205066 | ||
1434 | Rilgamon-205066 | button[name]['Cooldown'] = _G["PWB_"..name.."Cooldown"] |
|
1435 | Rilgamon-205066 | if(not addon['db']['profile']['auras'][name]['spellCD']) then |
|
1436 | Rilgamon-205066 | button[name]['Cooldown']:SetReverse(true) |
|
1437 | Rilgamon-205066 | else |
|
1438 | Rilgamon-205066 | button[name]['Cooldown']:SetReverse(false) |
|
1439 | Rilgamon-205066 | end |
|
1440 | Rilgamon-205066 | button[name]['Cooldown']['noCooldownCount'] = addon['db']['profile']['auras'][name]['ignoreMeOmniCC'] |
|
1441 | Rilgamon-205066 | button[name]['Count'] = _G["PWB_"..name.."Count"] |
|
1442 | Rilgamon-205066 | button[name]['Count']:SetFont(addon['db']['global']['chargesFont'], addon['db']['global']['chargesSize'], addon['db']['global']['chargesMode']) |
|
1443 | Rilgamon-205066 | if(LBF and LBFGroup) then |
|
1444 | Rilgamon-205066 | LBFGroup:AddButton(button[name]) |
|
1445 | Rilgamon-205066 | end |
|
1446 | Rilgamon-205066 | button[name]['TextTimer'] = button[name]:CreateFontString("PWB_"..name.."TextTimer","OVERLAY") |
|
1447 | Rilgamon-205066 | button[name]['TextTimer']:SetFont(addon['db']['global']['timerFont'], addon['db']['global']['timerSize'], addon['db']['global']['timerMode']) |
|
1448 | Rilgamon-205066 | button[name]['TextTimer']:SetPoint("TOPLEFT",button[name],"TOPLEFT",0,0) |
|
1449 | Rilgamon-205066 | return button[name] |
|
1450 | Rilgamon-205066 | end |
|
1451 | Rilgamon-205066 | ||
1452 | Rilgamon-205066 | ||
1453 | Rilgamon-205066 | ||
1454 | Rilgamon-205066 | function addon:removeButton(name,reset) |
|
1455 | Rilgamon-205066 | if(button[name]) then |
|
1456 | Rilgamon-205066 | button[name]:Hide() |
|
1457 | Rilgamon-205066 | button[name]['nr'] = nil |
|
1458 | Rilgamon-205066 | if(reset) then |
|
1459 | Rilgamon-205066 | if(LBF and LBFGroup) then |
|
1460 | Rilgamon-205066 | LBFGroup:RemoveButton(button[name]) |
|
1461 | Rilgamon-205066 | end |
|
1462 | Rilgamon-205066 | button[name]:SetParent(nil) |
|
1463 | Rilgamon-205066 | button[name] = nil |
|
1464 | Rilgamon-205066 | _G["PWB_"..name.."Icon"] = nil |
|
1465 | Rilgamon-205066 | _G["PWB_"..name.."Cooldown"] = nil |
|
1466 | Rilgamon-205066 | _G["PWB_"..name.."Count"] = nil |
|
1467 | Rilgamon-205066 | _G["PWB_"..name.."TextTimer"] = nil |
|
1468 | Rilgamon-205066 | end |
|
1469 | Rilgamon-205066 | end |
|
1470 | Rilgamon-205066 | end |
|
1471 | Rilgamon-205066 | ||
1472 | Rilgamon-205066 | function addon:getButtonByNumber(nr) |
|
1473 | Rilgamon-205066 | if(nr == 0) then |
|
1474 | Rilgamon-205066 | return addon['mainframe'] |
|
1475 | Rilgamon-205066 | end |
|
1476 | Rilgamon-205066 | for k,v in pairs(button) do |
|
1477 | Rilgamon-205066 | if(button[k]['nr'] == nr) then |
|
1478 | Rilgamon-205066 | return button[k] |
|
1479 | Rilgamon-205066 | end |
|
1480 | Rilgamon-205066 | end |
|
1481 | Rilgamon-205066 | return false |
|
1482 | Rilgamon-205066 | end |
|
1483 | Rilgamon-205066 | ||
1484 | Rilgamon-205066 | function addon:getMainframe() |
|
1485 | Rilgamon-205066 | local mainframe |
|
1486 | Rilgamon-205066 | mainframe = CreateFrame("Frame", "Layout"..addon:get('title'),UIParent) |
|
1487 | Rilgamon-205066 | mainframe:SetWidth(64) |
|
1488 | Rilgamon-205066 | mainframe:SetHeight(64) |
|
1489 | Rilgamon-205066 | mainframe:SetPoint("CENTER",UIParent,"CENTER",0,0) |
|
1490 | Rilgamon-205066 | mainframe['tab'] = addon['db']['profile'] |
|
1491 | Rilgamon-205066 | local tab = { |
|
1492 | Rilgamon-205066 | ['width'] = 64, |
|
1493 | Rilgamon-205066 | ['height'] = 64, |
|
1494 | Rilgamon-205066 | ['anchor'] = "TOPLEFT", |
|
1495 | Rilgamon-205066 | ['parentanchor'] = "TOPLEFT", |
|
1496 | Rilgamon-205066 | } |
|
1497 | Rilgamon-205066 | addontable['addDrag'](mainframe,"BOX",tab) |
|
1498 | Rilgamon-205066 | mainframe['nr'] = 0 |
|
1499 | Rilgamon-205066 | mainframe:SetScale(addon['db']['profile']['scale'] or 1) |
|
1500 | Rilgamon-205066 | addontable['loadFrame'](mainframe) |
|
1501 | Rilgamon-205066 | return mainframe |
|
1502 | Rilgamon-205066 | end |
|
1503 | Rilgamon-205066 | ||
1504 | Rilgamon-205066 | local function tooltipSort(a,b) |
|
1505 | Rilgamon-205066 | if(not a or not b) then return false end |
|
1506 | Rilgamon-205066 | tooltipSort1 = addon['db']['profile']['auras'][a]['spellcount'] or 0 |
|
1507 | Rilgamon-205066 | tooltipSort2 = addon['db']['profile']['auras'][b]['spellcount'] or 0 |
|
1508 | Rilgamon-205066 | return tooltipSort1 > tooltipSort2 |
|
1509 | Rilgamon-205066 | end |
|
1510 | Rilgamon-205066 | ||
1511 | Rilgamon-205066 | function addon:OnTooltip() |
|
1512 | Rilgamon-205066 | GameTooltip:ClearLines() |
|
1513 | Rilgamon-205066 | GameTooltip:AddDoubleLine(addon:get('title'), L['Proc'].."("..L['Refresh']..")") |
|
1514 | Rilgamon-205066 | ||
1515 | Rilgamon-205066 | whitelistAura = {} |
|
1516 | Rilgamon-205066 | for k in pairs(addon['db']['profile']['auras']) do |
|
1517 | Rilgamon-205066 | if(k~=L['Defaults']) then |
|
1518 | Rilgamon-205066 | if(addon['db']['profile']['auras'][k]['whitelist'] and addon['db']['profile']['auras'][k]['spellcount'] and addon['db']['profile']['auras'][k]['spellcount'] > 0 and not addon['db']['profile']['auras'][k]['spellCD']) then |
|
1519 | Rilgamon-205066 | whitelistAura[#whitelistAura + 1] = k |
|
1520 | Rilgamon-205066 | end |
|
1521 | Rilgamon-205066 | end |
|
1522 | Rilgamon-205066 | end |
|
1523 | Rilgamon-205066 | sort(whitelistAura, tooltipSort) |
|
1524 | Rilgamon-205066 | tooltipCount = 0 |
|
1525 | Rilgamon-205066 | for _,k in pairs(whitelistAura) do |
|
1526 | Rilgamon-205066 | GameTooltip:AddDoubleLine(k,(addon['db']['profile']['auras'][k]['spellcount'] or 0) .."("..(addon['db']['profile']['auras'][k]['spellcounter'] or 0)..")") |
|
1527 | Rilgamon-205066 | tooltipCount = tooltipCount + 1 |
|
1528 | Rilgamon-205066 | if(tooltipCount > 20) then |
|
1529 | Rilgamon-205066 | break |
|
1530 | Rilgamon-205066 | end |
|
1531 | Rilgamon-205066 | end |
|
1532 | Rilgamon-205066 | end |
|
1533 | Rilgamon-205066 | ||
1534 | Rilgamon-205066 | local map_global_local = { |
|
1535 | Rilgamon-205066 | ['spacing'] = true, |
|
1536 | Rilgamon-205066 | ['vertical'] = true, |
|
1537 | Rilgamon-205066 | ['growth'] = true, |
|
1538 | Rilgamon-205066 | } |
|
1539 | Rilgamon-205066 | ||
1540 | Rilgamon-205066 | function addon:Updated_Pref(value) |
|
1541 | Rilgamon-205066 | if(map_global_local[value]) then |
|
1542 | Rilgamon-205066 | addon['db']['global'][value] = addon['db']['profile'][value] |
|
1543 | Rilgamon-205066 | addon:destroyButtons() |
|
1544 | Rilgamon-205066 | elseif(value=='scale') then |
|
1545 | Rilgamon-205066 | addon.mainframe:SetScale(addon['db']['profile']['scale'] or 1) |
|
1546 | Rilgamon-205066 | end |
|
1547 | Rilgamon-205066 | end |
|
1548 | Rilgamon-205066 | ||
1549 | Rilgamon-205066 | function addon:round(num, idp) |
|
1550 | Rilgamon-205066 | return math.floor(num * (10^(idp or 0)) + 0.5) / (10^(idp or 0)) |
|
1551 | Rilgamon-205066 | end |