ought

core/cps.lua

Feb 3rd, 2019
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vexpower.CPBar.handler(change) -- XXXXXXXXXXXXXXXXXXXXXXXXX
  2. vexpower.CPBar.setCurrent(change)
  3. if vexpower.CPBar.currentCP[1] > vexpower.CPBar.currentCP[2] then
  4. --CPs built
  5. for i=1, vexpower.CPBar.currentCP[1] do
  6. if vexpower.CPBar.aniGrps[i]~=nil then
  7. if vexpower.CPBar.aniGrps[i]:IsPlaying() then
  8. vexpower.CPBar.aniGrps[i]:Stop()
  9. end
  10. end
  11. if not(vexpower.CPBar.frames[i]:IsShown()) then vexpower.CPBar.frames[i]:Show() end
  12. vexpower.CPBar.setBGColors(i, true)
  13. end
  14. else
  15. --CPs used
  16. for i=1, vexpower.CPBar.maxCPs do
  17. vexpower.CPBar.setBGColors(i, true)
  18. end
  19.  
  20. local cpsLost = vexpower.CPBar.currentCP[2]-vexpower.CPBar.currentCP[1]
  21.  
  22. for i=1, cpsLost do
  23. local bar = vexpower.CPBar.currentCP[2]+1-i
  24. vexpower.CPBar.setBGColors(bar, false)
  25. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["usedEffect"]["activate"] then
  26. vexpower.CPBar.aniGrps[bar]:Play()
  27. else
  28. if vexpower.CPBar.frames[bar]:IsShown() then vexpower.CPBar.frames[bar]:Hide() end
  29. end
  30. end
  31. end
  32. vexpower.CPBar.playSound()
  33. end
  34.  
  35. function vexpower.CPBar.getCPToAdjust(CP)
  36. return CP
  37. end
  38.  
  39. function vexpower.CPBar.get(current)
  40. local returnvalue = 0
  41. if vexpower.vehicle.CP and vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["show"]["vehicleCPs"] then
  42. if current then
  43. returnvalue = GetComboPoints("vehicle")
  44. else
  45. returnvalue = 5
  46. end
  47. elseif vexpower.data.classString == "DRUID" then
  48. if current then
  49. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["druid"]["keepCPShown"] then
  50. returnvalue = UnitPower("player", 4)
  51. else
  52. returnvalue = GetComboPoints("player")
  53. end
  54. else
  55. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["druid"]["cps"] then
  56. returnvalue = 5
  57. else
  58. returnvalue = 0
  59. end
  60. end
  61. elseif vexpower.data.classString == "ROGUE" then
  62. -- if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["anticipation"] and select(2, GetTalentTierInfo(3))==19250 then
  63. -- if current then
  64. -- if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["keepCPShown"] then
  65. -- returnvalue = UnitPower("player", 4)
  66. -- else
  67. -- returnvalue = GetComboPoints("player")
  68. -- end
  69.  
  70. -- if returnvalue ~= 0 then
  71. -- returnvalue = returnvalue+vexpower.CPBar.getCurrentBuff()
  72. -- end
  73. -- else
  74. -- returnvalue = 10
  75. -- end
  76. -- else
  77. if current then
  78. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["keepCPShown"] then
  79. returnvalue = UnitPower("player", 4)
  80. else
  81. returnvalue = GetComboPoints("player")
  82. end
  83. else
  84. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["cps"] then
  85. -- returnvalue = UnitPowerMax("player", SPELL_POWER_COMBO_POINTS)
  86. if select(4, GetTalentInfo(3,2, GetActiveSpecGroup())) then
  87. returnvalue = 6
  88. else
  89. returnvalue = 5
  90. end
  91. else
  92. returnvalue = 0
  93. end
  94. end
  95. -- end
  96. elseif vexpower.data.classString == "PALADIN" then
  97. if current then
  98. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["paladin"]["cps"] then
  99. returnvalue = UnitPower("player", 9)
  100. else
  101. returnvalue = 0
  102. end
  103. else
  104. returnvalue = UnitPowerMax("player", 9)
  105. end
  106. elseif vexpower.data.classString == "DEMONHUNTER" then
  107. if vexpower.data.specID == 581 then -- Vengeance
  108. if current then
  109. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["dh"]["fragments"] then
  110. returnvalue = vexpower.CPBar.getCurrentBuff()
  111. else
  112. returnvalue = 0
  113. end
  114. else
  115. returnvalue = 5
  116. end
  117. --vexdebugs.print("returnvalue",returnvalue)
  118. end
  119. elseif vexpower.data.classString == "MONK" then
  120. if vexpower.data.specID == 270 then --Mistweaver
  121. returnvalue = 0
  122. elseif vexpower.data.specID == 268 then --Brewmaster
  123. if current then
  124. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["monk"]["GotO"] then
  125. returnvalue = vexpower.CPBar.getSpellCount()
  126. else
  127. returnvalue = 0
  128. end
  129. else
  130. returnvalue = 5
  131. end
  132. else
  133. if current then
  134. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["monk"]["cps"] then
  135. returnvalue = UnitPower("player", 12)
  136. else
  137. returnvalue = 0
  138. end
  139. else
  140. returnvalue = UnitPowerMax("player", 12)
  141. end
  142. end
  143. elseif vexpower.data.classString == "PRIEST" then
  144. if vexpower.data.specID == 258 then -- Shadow
  145. if current then
  146. returnvalue = 0
  147. else
  148. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["priest"]["mana"] then
  149. returnvalue = 1
  150. else
  151. returnvalue = 0
  152. end
  153. end
  154. end
  155. elseif vexpower.data.classString == "SHAMAN" then
  156. if vexpower.data.specID == 263 then -- Enhancer (263)
  157. if current then
  158. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["shaman"]["enhancerMana"] then
  159. returnvalue = 0
  160. elseif vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["shaman"]["enhancerStormstrikes"] then
  161. returnvalue = 0
  162. local start, duration = GetSpellCooldown(17364)
  163. if start > 0 and duration > 1.5 then
  164. returnvalue = 0
  165. else
  166. returnvalue = 1 + vexpower.CPBar.getCurrentBuff()
  167. end
  168. else
  169. returnvalue = 0
  170. end
  171. else
  172. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["shaman"]["enhancerMana"] then
  173. returnvalue = 1
  174. elseif vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["shaman"]["enhancerStormstrikes"] then
  175. if select(4, GetTalentInfo(5,1, GetActiveSpecGroup())) then
  176. returnvalue = 3
  177. else
  178. returnvalue = 2
  179. end
  180. else
  181. returnvalue = 0
  182. end
  183. end
  184. elseif vexpower.data.specID == 262 then -- Ele (262)
  185. if current then
  186. returnvalue = 0
  187. else
  188. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["shaman"]["eleMana"] then
  189. returnvalue = 1
  190. else
  191. returnvalue = 0
  192. end
  193. end
  194. end
  195. elseif vexpower.data.classString == "WARLOCK" then
  196. if current then
  197. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["warlock"]["cps"] then
  198. returnvalue = UnitPower("player", 7)
  199. else
  200. returnvalue = 0
  201. end
  202. else
  203. returnvalue = UnitPowerMax("player", 7)
  204. end
  205. elseif vexpower.data.classString == "MAGE" then
  206. if vexpower.data.specID == 62 then -- Arcane
  207. if current then
  208. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["mage"]["cps"] then
  209. returnvalue = UnitPower("player", 16)
  210. else
  211. returnvalue = 0
  212. end
  213. else
  214. returnvalue = UnitPowerMax("player", 16)
  215. end
  216. end
  217. elseif vexpower.data.classString == "WARRIOR" then
  218. if vexpower.data.specID == 73 then -- Protection
  219. if current then
  220. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["warrior"]["focuesdrage"] then
  221. returnvalue = vexpower.CPBar.getCurrentBuff()
  222. else
  223. returnvalue = 0
  224. end
  225. else
  226. returnvalue = 3
  227. end
  228.  
  229. elseif vexpower.data.specID == 71 then -- Arms
  230. if current then
  231. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["warrior"]["focuesdrageArms"] then
  232. returnvalue = vexpower.CPBar.getCurrentBuff()
  233. else
  234. returnvalue = 0
  235. end
  236. else
  237. returnvalue = 3
  238. end
  239. end
  240. end
  241. if current then
  242. if returnvalue > vexpower.CPBar.maxCPs then
  243. returnvalue = vexpower.CPBar.maxCPs
  244. end
  245. end
  246. return returnvalue
  247. end
  248.  
  249. function vexpower.CPBar.getSpellCount()
  250. local returnvalue = 0
  251. if vexpower.data.specID == 268 then -- Brewmaster
  252. returnvalue = GetSpellCount(115072) --Expel Harm
  253. end
  254. return returnvalue
  255. end
  256.  
  257. function vexpower.CPBar.getCurrent(change)
  258. local new = 0
  259.  
  260. if change ~= nil then
  261. new = vexpower.CPBar.currentCP[1]+change
  262. else
  263. new = vexpower.CPBar.get(true)
  264. end
  265.  
  266. return new
  267. end
  268.  
  269. function vexpower.CPBar.setCurrent(change)
  270. local new = vexpower.CPBar.getCurrent(change)
  271.  
  272. if change ~= nil then new = vexpower.CPBar.currentCP[1]+change end
  273.  
  274. if new ~= vexpower.CPBar.currentCP[1] then
  275. vexpower.CPBar.currentCP[2] = vexpower.CPBar.currentCP[1]
  276. vexpower.CPBar.currentCP[1] = new
  277. end
  278. end
  279.  
  280. function vexpower.CPBar.getSpecAuraID()
  281. local returnvalue = 0
  282.  
  283. if vexpower.data.specID == 581 then -- Vengeance DH
  284. returnvalue = 203981
  285. elseif vexpower.data.specID == 263 then -- Enhancer
  286. returnvalue = 201846
  287. elseif vexpower.data.specID == 73 then -- Protection
  288. returnvalue = 204488
  289. elseif vexpower.data.specID == 71 then -- Arms Warri
  290. returnvalue = 207982
  291. -- if vexpower.data.specID == 254 then -- Marksman
  292. -- returnvalue =
  293. -- elseif vexpower.data.specID == 253 then -- Beast Master
  294. -- returnvalue = 19615
  295. -- elseif vexpower.data.specID == 72 then -- Fury
  296. -- returnvalue = 131116
  297. -- elseif vexpower.data.classString == "ROGUE" then -- Anticipation for all rogues
  298. -- returnvalue = 115189
  299. end
  300.  
  301. return returnvalue
  302. end
  303.  
  304. function vexpower.CPBar.getCurrentDebuff()
  305. local count = 0
  306. local continue = true
  307. local i = 1
  308. local auraid = vexpower.CPBar.getSpecAuraID()
  309.  
  310. if auraid ~= 0 then
  311. while continue do
  312. if UnitDebuff("player", i) == nil then
  313. continue = false
  314. elseif select(10, UnitDebuff("player", i)) == auraid then
  315. count = select(3, UnitDebuff("player", i))
  316. continue = false
  317. end
  318. i = i + 1
  319. end
  320. end
  321. return count
  322. end
  323.  
  324. function vexpower.CPBar.getCurrentBuff()
  325. local count = 0
  326. local continue = true
  327. local i = 1
  328. local auraid = vexpower.CPBar.getSpecAuraID()
  329.  
  330. if auraid ~= 0 then
  331. while continue do
  332. if UnitBuff("player", i) == nil then
  333. continue = false
  334. elseif select(10, UnitBuff("player", i)) == auraid then
  335. count = select(3, UnitBuff("player", i))
  336. continue = false
  337. end
  338. i = i + 1
  339. end
  340. end
  341.  
  342. -- Marksman Override for "Fire!"
  343. -- if vexpower.data.specID == 254 then -- Marksman
  344. -- i = 1
  345. -- continue = true
  346. -- while continue do
  347. -- if UnitBuff("player", i, nil, "PLAYER") == nil then
  348. -- continue = false
  349. -- elseif select(10, UnitBuff("player", i)) == 82926 then
  350. -- count = vexpower.CPBar.maxCPs
  351. -- continue = false
  352. -- end
  353. -- i = i + 1
  354. -- end
  355. -- end
  356.  
  357. return count
  358. end
  359.  
  360. function vexpower.CPBar.getMax()
  361. return vexpower.CPBar.get(false)
  362. end
  363.  
  364. function vexpower.CPBar.setMax()
  365. vexpower.CPBar.maxCPs = vexpower.CPBar.getMax()
  366. end
  367.  
  368. function vexpower.CPBar.calcDownCP(cp)
  369. while cp>10 do
  370. cp = cp -10
  371. end
  372. return cp
  373. end
  374.  
  375. function vexpower.CPBar.setBGColors(cp, standard) -- XXXXXXXXXXXXXXXXXXXXXXXXX
  376. cp = vexpower.CPBar.getCPToAdjust(cp)
  377. if vexpower.CPBar.frames[cp] ~=nil then
  378. local color = tostring(vexpower.CPBar.calcDownCP(cp))
  379. -- local color = tostring(cp)
  380. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["activateRecoloring"] then
  381. local changeOnMax = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["changeOnMax"]
  382. local absentCombopoints = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["absentCombopoints"]
  383. local treshold
  384. if absentCombopoints then
  385. treshold = vexpower.CPBar.getMax() - tonumber(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["threshold"])
  386. else
  387. treshold = tonumber(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["threshold"])
  388. end
  389. if (not changeOnMax) and (vexpower.CPBar.currentCP[1] >= treshold) then
  390. if (vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["changeThresholdOnly"] and cp <= treshold) then
  391. color = "change"
  392. elseif not(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["changeThresholdOnly"]) then
  393. color = "change"
  394. end
  395. elseif vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["changeOnMax"] and vexpower.CPBar.currentCP[1]==vexpower.CPBar.maxCPs then
  396. color = "change"
  397. end
  398. end
  399. if not(standard) then
  400. color = "used"
  401. end
  402. vexpower.CPBar.frames[cp]:SetBackdropColor(
  403. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["colors"][color]["r"],
  404. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["colors"][color]["g"],
  405. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["colors"][color]["b"],
  406. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["colors"][color]["a"])
  407. end
  408. end
  409.  
  410. function vexpower.CPBar.setBars()
  411. if not(vexpower.testmode.activated) then
  412. if vexpower.CPBar.frames ~= nil then
  413. for i=1, #vexpower.CPBar.frames do
  414. if vexpower.CPBar.frames[i] ~= nil then vexpower.CPBar.frames[i]:Hide() end
  415. end
  416. end
  417. end
  418.  
  419. --Setup CPs
  420. for i=1, vexpower.CPBar.maxCPs do
  421. if not(vexpower.testmode.activated) then
  422. vexpower.CPBar.frames[i] = CreateFrame("Frame", nil, vexpower.CPBar.mainframe)
  423. end
  424. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["texture"]["usePack"] == 1 then
  425. vexpower.CPBar.frames[i]:SetBackdrop({
  426. bgFile=vexpower.LSM:Fetch("background", vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["texture"]["pack1"]),
  427. edgeFile=vexpower.LSM:Fetch("border", vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["texture"]), tile=false,
  428. edgeSize=vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["size"],
  429. insets = {
  430. left = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["left"],
  431. right = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["right"],
  432. top = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["top"],
  433. bottom = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["bottom"]
  434. }
  435. })
  436. else
  437. vexpower.CPBar.frames[i]:SetBackdrop({
  438. bgFile=vexpower.LSM:Fetch("statusbar", vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["texture"]["pack2"]),
  439. edgeFile=vexpower.LSM:Fetch("border", vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["texture"]), tile=false,
  440. edgeSize=vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["size"],
  441. insets = {
  442. left = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["left"],
  443. right = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["right"],
  444. top = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["top"],
  445. bottom = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["insets"]["bottom"]
  446. }
  447. })
  448. end
  449. vexpower.CPBar.setBGColors(i, true)
  450. vexpower.CPBar.frames[i]:SetBackdropBorderColor(
  451. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["color"]["r"],
  452. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["color"]["g"],
  453. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["color"]["b"],
  454. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["border"]["color"]["a"])
  455.  
  456. if not(vexpower.testmode.activated) then
  457. if vexpower.CPBar.currentCP[1] > 0 then
  458. if not(vexpower.CPBar.frames[i]:IsShown()) then vexpower.CPBar.frames[i]:Show() end
  459. else
  460. if vexpower.CPBar.frames[i]:IsShown() then vexpower.CPBar.frames[i]:Hide() end
  461. end
  462. end
  463.  
  464. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["activate"] then
  465. vexpower.CPBar.frames[i]:ClearAllPoints()
  466. vexpower.CPBar.frames[i]:SetFrameStrata(vexpower.options.strata.convertValues(vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["strata"]["cps"]))
  467. -- if vexpower.data.classString == "ROGUE" and vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["anticipation"] and vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["anti2ndRow"] then
  468. -- local width = 0
  469. -- if vexpower.CPBar.maxCPs ~= 0 then
  470. -- width = (vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["size"]["width"] - (vexpower.CPBar.maxCPs-6)*vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["gap"] - vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["offset"]*2)/(vexpower.CPBar.maxCPs-5)
  471. -- else
  472. -- vexpower.CPBar.frames[i]:Hide()
  473. -- end
  474. -- vexpower.CPBar.frames[i]:SetWidth(width)
  475. -- if i>5 then
  476. -- local start = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["offset"]+(width*(i-6))+(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["gap"]*(i-6))
  477. -- vexpower.CPBar.frames[i]:SetHeight(vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["antiRowHeight"])
  478. -- vexpower.CPBar.frames[i]:SetPoint("TOPLEFT", vexpower.CPBar.mainframe, "TOPLEFT", start, vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["antiRowHeight"]+vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["classSpec"]["rogue"]["antiRowYDistance"])
  479. -- else
  480. -- vexpower.CPBar.frames[i]:SetHeight(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["height"])
  481. -- local start = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["offset"]+(width*(i-1))+(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["gap"]*(i-1))
  482. -- vexpower.CPBar.frames[i]:SetPoint("TOPLEFT", vexpower.CPBar.mainframe, "TOPLEFT", start, 0)
  483. -- end
  484. -- else
  485. vexpower.CPBar.frames[i]:SetHeight(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["height"])
  486. local width = 0
  487. if vexpower.CPBar.maxCPs ~= 0 then
  488. width = (vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["size"]["width"] - (vexpower.CPBar.maxCPs-1)*vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["gap"] - vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["offset"]*2)/vexpower.CPBar.maxCPs
  489. else
  490. if vexpower.CPBar.frames[i]:IsShown() then vexpower.CPBar.frames[i]:Hide() end
  491. end
  492. vexpower.CPBar.frames[i]:SetWidth(width)
  493. local start = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["offset"]+(width*(i-1))+(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["intMode"]["gap"]*(i-1))
  494. vexpower.CPBar.frames[i]:SetPoint("TOPLEFT", vexpower.CPBar.mainframe, "TOPLEFT", start, 0)
  495. -- end
  496. else
  497. local usage = vexpower.CPBar.getAltPos()
  498. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage] ~= nil then
  499. vexpower.CPBar.frames[i]:SetHeight(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage]["height"])
  500. vexpower.CPBar.frames[i]:SetWidth(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage]["width"])
  501. vexpower.CPBar.frames[i]:SetFrameStrata(vexpower.options.strata.convertValues(vexpower_SV_profiles[vexpower_SV_data["profile"]]["data"]["strata"]["cps"]))
  502. vexpower.CPBar.frames[i]:ClearAllPoints()
  503. vexpower.CPBar.frames[i]:SetPoint(
  504. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage][tostring(i)]["anchor"],
  505. vexpower.CPBar.mainframe,
  506. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage][tostring(i)]["anchorFrame"],
  507. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage][tostring(i)]["x"],
  508. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][usage][tostring(i)]["y"])
  509. else
  510. if vexpower.CPBar.frames[i]:IsShown() then vexpower.CPBar.frames[i]:Hide() end
  511. end
  512. end
  513.  
  514. vexpower.CPBar.aniGrps[i] = vexpower.CPBar.frames[i]:CreateAnimationGroup("vexpower.CPBar.aniGrps["..i.."]")
  515. vexpower.CPBar.aniGrps[i]:SetLooping("NONE")
  516. vexpower.CPBar.aniGrps[i]:SetScript("OnPlay", function () if not(vexpower.CPBar.frames[i]:IsShown()) then vexpower.CPBar.frames[i]:Show() end end)
  517. vexpower.CPBar.aniGrps[i]:SetScript("OnFinished", function () if vexpower.CPBar.frames[i]:IsShown() then vexpower.CPBar.frames[i]:Hide() end end)
  518. vexpower.CPBar.anis[i] = vexpower.CPBar.aniGrps[i]:CreateAnimation("Alpha")
  519. vexpower.CPBar.anis[i]:SetDuration(0.3)
  520. vexpower.CPBar.anis[i]:SetOrder(1)
  521. vexpower.CPBar.anis[i]:SetFromAlpha(vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["colors"]["colors"]["used"]["a"])
  522. vexpower.CPBar.anis[i]:SetToAlpha(0)
  523.  
  524. end
  525. end
  526.  
  527. function vexpower.CPBar.getAltPos()
  528. if vexpower.CPBar.maxCPs == 10 then
  529. return "10"
  530. else
  531. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][tostring(vexpower.CPBar.maxCPs)] ~= nil then
  532. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["altPositioning"][tostring(vexpower.CPBar.maxCPs)]["change"] then
  533. return tostring(vexpower.CPBar.maxCPs)
  534. else
  535. return "10"
  536. end
  537. end
  538. end
  539. end
  540.  
  541. function vexpower.CPBar.setMovable(movable)
  542. if movable ~= nil then
  543. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["clipToPower"] then
  544. vexpower_MainFrame:SetMovable(movable)
  545. else
  546. vexpower.CPBar.mainframe:SetMovable(movable)
  547. end
  548. vexpower.CPBar.mainframe:EnableMouse(movable)
  549. end
  550. end
  551.  
  552. function vexpower.CPBar.savePosition()
  553. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchor"] = select(1, vexpower.CPBar.mainframe:GetPoint())
  554. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchorFrame"] = select(3, vexpower.CPBar.mainframe:GetPoint())
  555. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["x"] = select(4, vexpower.CPBar.mainframe:GetPoint())
  556. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["y"] = select(5, vexpower.CPBar.mainframe:GetPoint())
  557. end
  558.  
  559. function vexpower.CPBar.toggleBGColor()
  560. if vexpower.testmode.activated then
  561. vexpower.CPBar.mainframe:SetBackdropColor(1,1,1,0.3)
  562. else
  563. vexpower.CPBar.mainframe:SetBackdropColor(0,0,0,0)
  564. end
  565. end
  566.  
  567. function vexpower.CPBar.setMainframe()
  568. vexpower.CPBar.mainframe:ClearAllPoints()
  569. vexpower.CPBar.mainframe:SetWidth(vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["size"]["width"])
  570. vexpower.CPBar.mainframe:SetHeight(vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["size"]["height"])
  571. vexpower.CPBar.mainframe:SetBackdrop({
  572. bgFile="Interface\\Buttons\\WHITE8X8", edgeFile=vexpower.LSM:Fetch("border", vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["border"]["texture"]), tile=false,
  573. edgeSize=vexpower_SV_profiles[vexpower_SV_data["profile"]]["powerbar"]["design"]["border"]["size"]})
  574.  
  575. if not(vexpower.testmode.activated) then
  576. vexpower.CPBar.mainframe:SetBackdropColor(0,0,0,0)
  577. else
  578. vexpower.CPBar.mainframe:SetBackdropColor(1,1,1,0.3)
  579. end
  580.  
  581. vexpower.CPBar.mainframe:SetBackdropBorderColor(0,0,0,0)
  582.  
  583. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["clipToPower"] then
  584. vexpower.CPBar.mainframe:SetPoint(
  585. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchor"],
  586. vexpower_MainFrame,
  587. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchorFrame"],
  588. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["x"],
  589. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["y"])
  590. else
  591. vexpower.CPBar.mainframe:SetPoint(
  592. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchor"],
  593. UIparent,
  594. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["anchorFrame"],
  595. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["x"],
  596. vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["y"])
  597. end
  598.  
  599. vexpower.CPBar.mainframe:RegisterForDrag("LeftButton")
  600. vexpower.CPBar.mainframe:SetScript("OnDragStart", function ()
  601. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["clipToPower"] then
  602. vexpower_MainFrame:StartMoving()
  603. else
  604. vexpower.CPBar.mainframe:StartMoving()
  605. end end)
  606. vexpower.CPBar.mainframe:SetScript("OnDragStop", function ()
  607. if vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["design"]["position"]["clipToPower"] then
  608. vexpower_MainFrame:StopMovingOrSizing()
  609. vexpower.mainframe.savePositon()
  610. else
  611. vexpower.CPBar.mainframe:StopMovingOrSizing()
  612. vexpower.CPBar.savePosition()
  613. end end)
  614. vexpower.CPBar.mainframe:SetMovable(vexpower.testmode.activated)
  615. vexpower.CPBar.mainframe:EnableMouse(vexpower.testmode.activated)
  616. end
  617.  
  618. function vexpower.CPBar.showHandler() -- XXXXXXXXXXXXXXXXXXXXXXXXX
  619. for i=1, #vexpower.CPBar.frames do
  620. if vexpower.CPBar.frames[i] ~=nil then
  621. if i <= vexpower.CPBar.currentCP[1] then
  622. if not(vexpower.CPBar.frames[i]:IsShown()) then vexpower.CPBar.frames[i]:Show() end
  623. else
  624. if vexpower.CPBar.frames[i]:IsShown() then vexpower.CPBar.frames[i]:Hide() end
  625. end
  626. end
  627. end
  628. end
  629.  
  630. function vexpower.CPBar.playSound()
  631. local x = vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["sound"]["threshold"]
  632. if vexpower.CPBar.currentCP[2] < x and vexpower.CPBar.currentCP[1] >= x and vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["sound"]["activate"] then
  633. PlaySoundFile(vexpower.LSM:Fetch("sound", vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["sound"]["file"]), vexpower_SV_profiles[vexpower_SV_data["profile"]]["CPBar"]["sound"]["channel"])
  634. end
  635. end
RAW Paste Data