Advertisement
Guest User

Ouf_Drk core.lua

a guest
Aug 29th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.34 KB | None | 0 0
  1. local addon, ns = ...
  2.  
  3. local cfg = ns.cfg
  4. local lib = ns.lib
  5.  
  6. -----------------------------
  7. -- STYLE FUNCTIONS
  8. -----------------------------
  9.  
  10. local bgMulti = 0.4
  11.  
  12. -- Hide Blizzard stuff
  13. if cfg.hideRaidFrame then
  14. CompactRaidFrameManager:UnregisterAllEvents()
  15. CompactRaidFrameManager:Hide()
  16. end
  17.  
  18. if cfg.hideRaidFrameContainer then
  19. CompactRaidFrameContainer:UnregisterAllEvents()
  20. CompactRaidFrameContainer:Hide()
  21. end
  22.  
  23. if cfg.hideBuffFrame then
  24. BuffFrame:Hide()
  25. end
  26.  
  27. if cfg.hideWeaponEnchants then
  28. TemporaryEnchantFrame:Hide()
  29. end
  30.  
  31. -- Menus
  32. local dropdown = CreateFrame("Frame", "MyAddOnUnitDropDownMenu", UIParent, "UIDropDownMenuTemplate")
  33.  
  34. UIDropDownMenu_Initialize(dropdown, function(self)
  35. local unit = self:GetParent().unit
  36. if not unit then return end
  37.  
  38. local menu, name, id
  39. if UnitIsUnit(unit, "player") then
  40. menu = "SELF"
  41. elseif UnitIsUnit(unit, "vehicle") then
  42. menu = "VEHICLE"
  43. elseif UnitIsUnit(unit, "pet") then
  44. menu = "PET"
  45. elseif UnitIsPlayer(unit) then
  46. id = UnitInRaid(unit)
  47. if id then
  48. menu = "RAID_PLAYER"
  49. name = GetRaidRosterInfo(id)
  50. elseif UnitInParty(unit) then
  51. menu = "PARTY"
  52. else
  53. menu = "PLAYER"
  54. end
  55. else
  56. menu = "TARGET"
  57. name = RAID_TARGET_ICON
  58. end
  59. if menu then
  60. UnitPopup_ShowMenu(self, menu, unit, name, id)
  61. end
  62. end, "MENU")
  63.  
  64. local menu = function(self)
  65. dropdown:SetParent(self)
  66. ToggleDropDownMenu(1, nil, dropdown, "cursor", 0, 0)
  67. end
  68.  
  69. UnitSpecific = {
  70. player = function(self)
  71. -- unit specifics
  72. self.mystyle = "player"
  73. lib.addHealthBar(self)
  74. lib.addPowerBar(self)
  75. lib.addPortrait(self)
  76.  
  77. -- Set frame size
  78. self:SetScale(cfg.frameScale)
  79. self:SetWidth(250)
  80. self:SetHeight(53)
  81.  
  82. -- Set statusbars specifics
  83. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  84. self.Health:SetSize(250, 33)
  85. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  86. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  87.  
  88. self.Power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 0)
  89. self.Power:SetSize(250, 15)
  90. self.Power.colorTapping = true
  91. self.Power.colorDisconnected = true
  92. self.Power.colorClass = true
  93. self.Power.bg.multiplier = 0.3
  94. self.Power.frequentUpdates = true
  95.  
  96. lib.addTextTags(self, 17)
  97. lib.ThreatBar(self)
  98. lib.AltPowerBar(self)
  99.  
  100. lib.addIcons(self)
  101.  
  102. lib.addClassBar(self)
  103.  
  104. -- Buffs and Debuffs
  105. if cfg.showPlayerBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.player) end
  106. if cfg.showPlayerDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.player) end
  107.  
  108. lib.addCastBar(self, true)
  109.  
  110. -- Plugins
  111. lib.addCombatFeedback(self)
  112. end,
  113.  
  114. target = function(self)
  115. -- unit specifics
  116. self.mystyle = "target"
  117. lib.addHealthBar(self)
  118. lib.addPowerBar(self)
  119. lib.addPortrait(self)
  120.  
  121. -- Set frame size
  122. self:SetScale(cfg.frameScale)
  123. self:SetWidth(250)
  124. self:SetHeight(53)
  125.  
  126. -- Set statusbars specifics
  127. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  128. self.Health:SetSize(250, 33)
  129. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  130. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  131.  
  132. self.Power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 0)
  133. self.Power:SetSize(250, 15)
  134. self.Power.colorTapping = true
  135. self.Power.colorDisconnected = true
  136. self.Power.colorHappiness = false
  137. self.Power.colorReaction = true
  138. self.Power.colorClass = true
  139. self.Power.bg.multiplier = 0.3
  140.  
  141. lib.addTextTags(self, 17)
  142.  
  143. lib.addIcons(self)
  144.  
  145. -- Buffs and Debuffs
  146. if cfg.showTargetBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.target) end
  147. if cfg.showTargetDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.target) end
  148.  
  149. lib.addCastBar(self, true)
  150.  
  151. -- Plugins
  152. lib.addCombatFeedback(self)
  153. end,
  154.  
  155. pet = function(self)
  156. -- unit specifics
  157. self.mystyle = "pet"
  158. lib.addHealthBar(self)
  159. lib.addPowerBar(self)
  160.  
  161. -- Set frame size
  162. self:SetScale(cfg.frameScale)
  163. self:SetWidth(120)
  164. self:SetHeight(21)
  165.  
  166. -- Set statusbars specifics
  167. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  168. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  169. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  170. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  171.  
  172. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  173. self.Power:SetSize(self:GetWidth()-7, 2)
  174. self.Power:SetStatusBarColor(1, 1, 1)
  175. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  176.  
  177. lib.addTextTags(self, 12)
  178.  
  179. lib.addIcons(self)
  180.  
  181. -- Buffs and Debuffs
  182. if cfg.showPetBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.pet) end
  183. if cfg.showPetDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.pet) end
  184.  
  185. lib.addCastBar(self, true)
  186.  
  187. end,
  188.  
  189. pettarget = function(self)
  190. -- unit specifics
  191. self.mystyle = "pettarget"
  192. lib.addHealthBar(self)
  193. lib.addPowerBar(self)
  194.  
  195. -- Set frame size
  196. self:SetScale(cfg.frameScale)
  197. self:SetWidth(120)
  198. self:SetHeight(21)
  199.  
  200. -- Set statusbars specifics
  201. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  202. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  203. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  204. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  205.  
  206. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  207. self.Power:SetSize(self:GetWidth()-7, 2)
  208. self.Power:SetStatusBarColor(1, 1, 1)
  209. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  210.  
  211. lib.addTextTags(self, 12)
  212.  
  213. lib.addIcons(self)
  214. end,
  215.  
  216. targettarget = function(self)
  217. -- unit specifics
  218. self.mystyle = "targettarget"
  219. lib.addHealthBar(self)
  220. lib.addPowerBar(self)
  221.  
  222. -- Set frame size
  223. self:SetScale(cfg.frameScale)
  224. self:SetWidth(120)
  225. self:SetHeight(21)
  226.  
  227. -- Set statusbars specifics
  228. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  229. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  230. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  231. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  232.  
  233. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  234. self.Power:SetSize(self:GetWidth()-7, 2)
  235. self.Power:SetStatusBarColor(1, 1, 1)
  236. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  237.  
  238. lib.addTextTags(self, 12)
  239.  
  240. lib.addIcons(self)
  241. end,
  242.  
  243. focus = function(self)
  244. -- unit specifics
  245. self.mystyle = "focus"
  246. lib.addHealthBar(self)
  247. lib.addPowerBar(self)
  248.  
  249. -- Set frame size
  250. self:SetScale(cfg.frameScale)
  251. self:SetWidth(250)
  252. self:SetHeight(21)
  253.  
  254. -- Set statusbars specifics
  255. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  256. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  257. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  258. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  259.  
  260. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  261. self.Power:SetSize(self:GetWidth()-7, 2)
  262. self.Power:SetStatusBarColor(1, 1, 1)
  263. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  264.  
  265. lib.addTextTags(self, 12)
  266.  
  267. lib.addIcons(self)
  268.  
  269. -- Buffs and Debuffs
  270. if cfg.showFocusBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.focus) end
  271. if cfg.showFocusDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.focus) end
  272.  
  273. lib.addCastBar(self, true)
  274. end,
  275.  
  276. focustarget = function(self)
  277. -- unit specifics
  278. self.mystyle = "focustarget"
  279. lib.addHealthBar(self)
  280. lib.addPowerBar(self)
  281.  
  282. -- Set frame size
  283. self:SetScale(cfg.frameScale)
  284. self:SetWidth(120)
  285. self:SetHeight(21)
  286.  
  287. -- Set statusbars specifics
  288. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  289. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  290. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  291. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  292.  
  293. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  294. self.Power:SetSize(self:GetWidth()-7, 2)
  295. self.Power:SetStatusBarColor(1, 1, 1)
  296. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  297.  
  298. lib.addTextTags(self, 12)
  299.  
  300. lib.addIcons(self)
  301. end,
  302. }
  303.  
  304. local Style = function(self, unit)
  305. -- Shared layout code
  306. self:RegisterForClicks('AnyUp')
  307. self.menu = menu
  308. self:SetAttribute("*type2", "menu")
  309.  
  310. if UnitSpecific[unit] then
  311. return UnitSpecific[unit](self)
  312. end
  313.  
  314. end
  315.  
  316. local raidStyle = function(self, unit)
  317. self:RegisterForClicks('AnyUp')
  318. self.menu = menu
  319. self:SetAttribute("*type2", "menu")
  320.  
  321. self.mystyle = "raid"
  322. lib.addHealthBar(self)
  323. lib.addPowerBar(self)
  324.  
  325. self.Range = {
  326. insideAlpha = 1,
  327. outsideAlpha = .3,
  328. }
  329.  
  330. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  331. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  332. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  333. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  334.  
  335. self.Health.frequentUpdates = true
  336.  
  337. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 2)
  338. self.Power:SetSize(self:GetWidth()-6, 2)
  339. self.Power:SetStatusBarColor(1, 1, 1)
  340. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  341.  
  342. lib.addTextTags(self, 12)
  343.  
  344. lib.addIcons(self)
  345. self.LFDRole:Hide()
  346. lib.addAuraWatch(self)
  347. lib.addDebuffHighlight(self)
  348. lib.raidDebuffs(self)
  349.  
  350. -- Event hooks
  351. self:RegisterEvent('PLAYER_TARGET_CHANGED', lib.changedTarget)
  352. self:RegisterEvent('RAID_ROSTER_UPDATE', lib.changedTarget)
  353. self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", lib.updateAggro)
  354. self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", lib.updateAggro)
  355. end
  356.  
  357. local bossStyle = function(self, unit, isSingle)
  358. self:RegisterForClicks('AnyUp')
  359. self.menu = menu
  360. self:SetAttribute("*type2", "menu")
  361.  
  362. self.mystyle = "boss"
  363. lib.addHealthBar(self)
  364. lib.addPowerBar(self)
  365. self:SetScale(cfg.frameScale)
  366. self:SetSize(250, 21)
  367.  
  368. self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
  369. self.Health:SetSize(self:GetWidth(), self:GetHeight())
  370. self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  371. self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))
  372.  
  373. self.Power:SetPoint('BOTTOM', self, 'BOTTOM', 0, 3)
  374. self.Power:SetSize(self:GetWidth()-7, 2)
  375. self.Power:SetStatusBarColor(1, 1, 1)
  376. self.Power.bg:SetVertexColor(1, 1, 1, 0.6)
  377.  
  378. lib.addTextTags(self, 12)
  379.  
  380. lib.addIcons(self)
  381.  
  382. -- Buffs and Debuffs
  383. if cfg.showBossBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.boss) end
  384.  
  385. lib.addCastBar(self, true)
  386.  
  387. end
  388.  
  389. -----------------------------
  390. -- SPAWN UNITS
  391. -----------------------------
  392.  
  393. oUF:RegisterStyle('drk', Style)
  394. oUF:RegisterStyle('drkRaid', raidStyle)
  395. oUF:RegisterStyle('drkBoss', bossStyle)
  396.  
  397. oUF:Factory(function(self)
  398. -- Single Frames
  399. self:SetActiveStyle('drk')
  400.  
  401. self:Spawn('player'):SetPoint("BOTTOMRIGHT", UIParent, cfg.playerRelativePoint, cfg.playerX, cfg.playerY)
  402. self:Spawn('target'):SetPoint("BOTTOMLEFT", UIParent, cfg.targetRelativePoint, cfg.targetX, cfg.targetY)
  403. if cfg.showTot then self:Spawn('targettarget'):SetPoint("BOTTOMRIGHT",oUF_drkTarget,"TOPRIGHT", 0, 8) end
  404. if cfg.showPet then self:Spawn('pet'):SetPoint("BOTTOMLEFT",oUF_drkPlayer,"TOPLEFT", 0, 8) end
  405. if cfg.showPetTarget then self:Spawn('pettarget'):SetPoint("BOTTOMRIGHT",oUF_drkPlayer,"TOPRIGHT", 0, 8) end
  406. if cfg.showFocus then self:Spawn('focus'):SetPoint("BOTTOMLEFT",oUF_drkTarget,"TOPLEFT", 0, 36) end
  407. if cfg.showFocusTarget then self:Spawn('focustarget'):SetPoint("BOTTOMLEFT",oUF_drkTarget,"TOPLEFT", 0, 8) end
  408.  
  409. -- Raid/Party Frames
  410. if cfg.showRaid then
  411. self:SetActiveStyle('drkRaid')
  412.  
  413. local raid = oUF:SpawnHeader("oUF_Raid", nil, "custom [@raid26,exists] hide;show",
  414. "showRaid", cfg.showRaid,
  415. "showPlayer", true,
  416. "showSolo", cfg.raidShowSolo,
  417. "showParty", cfg.showParty,
  418. "xoffset", 9,
  419. "yOffset", 5,
  420. "groupFilter", "1,2,3,4,5",
  421. "groupBy", "GROUP",
  422. "groupingOrder", "1,2,3,4,5",
  423. "sortMethod", "INDEX",
  424. "maxColumns", "5",
  425. "unitsPerColumn", 5,
  426. "columnSpacing", 7,
  427. "point", "LEFT",
  428. "columnAnchorPoint", cfg.raidAnchorPoint,
  429. "oUF-initialConfigFunction", ([[
  430. self:SetWidth(%d)
  431. self:SetHeight(%d)
  432. ]]):format(72, 28))
  433. raid:SetScale(cfg.raidScale)
  434. raid:SetPoint("BOTTOMLEFT", UIParent, cfg.raidRelativePoint, cfg.raidX, cfg.raidY)
  435. CompactRaidFrameContainer:Hide()
  436. CompactRaidFrameManager:SetAlpha(0)
  437. local raid40 = oUF:SpawnHeader("oUF_Raid40", nil, "custom [@raid26,exists] show;hide",
  438. "showRaid", cfg.showRaid,
  439. "showPlayer", true,
  440. "showSolo", cfg.raidShowSolo,
  441. "showParty", cfg.showParty,
  442. "xoffset", 9,
  443. "yOffset", 5,
  444. "groupFilter", "1,2,3,4,5",
  445. "groupBy", "GROUP",
  446. "groupingOrder", "1,2,3,4,5",
  447. "sortMethod", "INDEX",
  448. "maxColumns", "5",
  449. "unitsPerColumn", 5,
  450. "columnSpacing", 7,
  451. "point", "LEFT",
  452. "columnAnchorPoint", cfg.raid40AnchorPoint,
  453. "oUF-initialConfigFunction", ([[
  454. self:SetWidth(%d)
  455. self:SetHeight(%d)
  456. ]]):format(72, 28))
  457. raid40:SetScale(cfg.raidScale)
  458. raid40:SetPoint("TOPLEFT", UIParent, cfg.raid40RelativePoint, cfg.raid40X, cfg.raid40Y)
  459. end
  460.  
  461. -- Boss frames
  462. if cfg.showBossFrames then
  463. self:SetActiveStyle('drkBoss')
  464. local bossFrames = {}
  465. for i = 1, MAX_BOSS_FRAMES do
  466. local unit = self:Spawn('boss' .. i)
  467. if i > 1 then
  468. unit:SetPoint('BOTTOMLEFT', bossFrames[i - 1], 'TOPLEFT', 0, 8)
  469. else
  470. unit:SetPoint('BOTTOMLEFT', oUF_drkTarget, 'TOPLEFT', 0, 90)
  471. end
  472. bossFrames[i] = unit
  473. end
  474. end
  475. end)
  476. do
  477. UnitPopupMenus["SELF"] = { "LOOT_METHOD", "LOOT_THRESHOLD", "OPT_OUT_LOOT_TITLE", "LOOT_PROMOTE", "DUNGEON_DIFFICULTY", "RAID_DIFFICULTY", "RESET_INSTANCES", "RAID_TARGET_ICON", "SELECT_ROLE", "LEAVE", "CANCEL" };
  478. UnitPopupMenus["PET"] = { "PET_PAPERDOLL", "PET_RENAME", "PET_ABANDON", "PET_DISMISS", "CANCEL" };
  479. UnitPopupMenus["PARTY"] = { "MUTE", "UNMUTE", "PARTY_SILENCE", "PARTY_UNSILENCE", "RAID_SILENCE", "RAID_UNSILENCE", "BATTLEGROUND_SILENCE", "BATTLEGROUND_UNSILENCE", "WHISPER", "PROMOTE", "PROMOTE_GUIDE", "LOOT_PROMOTE", "VOTE_TO_KICK", "UNINVITE", "INSPECT", "ACHIEVEMENTS", "TRADE", "FOLLOW", "DUEL", "RAID_TARGET_ICON", "SELECT_ROLE", "PVP_REPORT_AFK", "RAF_SUMMON", "RAF_GRANT_LEVEL", "CANCEL" }
  480. UnitPopupMenus["PLAYER"] = { "WHISPER", "INSPECT", "INVITE", "ACHIEVEMENTS", "TRADE", "FOLLOW", "DUEL", "RAID_TARGET_ICON", "RAF_SUMMON", "RAF_GRANT_LEVEL", "CANCEL" }
  481. UnitPopupMenus["VEHICLE"] = { "RAID_TARGET_ICON", "VEHICLE_LEAVE", "CANCEL" }
  482. UnitPopupMenus["TARGET"] = { "RAID_TARGET_ICON", "CANCEL" }
  483. UnitPopupMenus["ARENAENEMY"] = { "CANCEL" }
  484. UnitPopupMenus["FOCUS"] = { "RAID_TARGET_ICON", "CANCEL" }
  485. UnitPopupMenus["BOSS"] = { "RAID_TARGET_ICON", "CANCEL" }
  486. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement