Advertisement
Guest User

Miscellaneous.lua

a guest
Apr 27th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.58 KB | None | 0 0
  1. local MODULE_NAME = "Miscellaneous"
  2. local ADDON_NAME = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
  3. local MODULE = ADDON_NAME:NewModule(MODULE_NAME, "AceEvent-3.0")
  4. local L = setmetatable({}, { __index = function(t,k)
  5. local v = tostring(k)
  6. rawset(t, k, v)
  7. return v
  8. end })
  9.  
  10. ------------------------------------------------------------------------
  11. -- Module Database
  12. ------------------------------------------------------------------------
  13.  
  14. local BASIC_BORDER = [[Interface\Tooltips\UI-Tooltip-Border]]
  15. local BASIC_STATUSBAR = [[Interface\TargetingFrame\UI-StatusBar]]
  16.  
  17. local db
  18. local defaults = {
  19. profile = {
  20. enable = true,
  21. flashgathernodes = true,
  22. cooldown = true,
  23. quicky = true,
  24. vellum = true,
  25. altbuy = true,
  26. quest = true,
  27.  
  28. autogreed = {
  29. enable = true, -- Auto Roll greed for green items.
  30. disenchant = true, -- Disenchant Green Item's on Roll
  31. },
  32.  
  33. merchant = {
  34. enable = true,
  35. autoSellGrey = true, -- autosell grey items at merchant.
  36. autoRepair = true, -- autorepair at merchant.
  37. guildPay = false, -- let your guild pay for your repairs if they allow.
  38. },
  39. quest = {
  40. enable = true, -- enable quest module.
  41. tekvendor = true, -- Tek's best quest item by vendor price.
  42. autocomplete = false, -- enable the autoaccept quest and autocomplete quest if no reward.
  43. },
  44. skin = {
  45. enable = true,
  46. border = BASIC_BORDER,
  47. statusbar = BASIC_STATUSBAR,
  48. DBM = true,
  49. Recount = true,
  50. RecountBackdrop = true,
  51. },
  52. }
  53. }
  54.  
  55. ------------------------------------------------------------------------
  56. -- Module Functions
  57. ------------------------------------------------------------------------
  58.  
  59. local classColor
  60.  
  61. function MODULE:OnInitialize()
  62. self.db = ADDON_NAME.db:RegisterNamespace(MODULE_NAME, defaults)
  63. db = self.db.profile
  64.  
  65. local _, class = UnitClass("player")
  66. classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  67.  
  68. self:SetEnabledState(ADDON_NAME:GetModuleEnabled(MODULE_NAME))
  69. end
  70.  
  71. function MODULE:FlashGatherNods()
  72. if (IsAddOnLoaded('Zygor Guides Viewer 4')) then return end
  73.  
  74.  
  75. function AssignButtonTexture(obj,tx,num,total)
  76. self.ChainCall(obj):SetNormalTexture(CreateTexWithCoordsNum(obj,tx,num,total,1,4))
  77. :SetPushedTexture(CreateTexWithCoordsNum(obj,tx,num,total,2,4))
  78. :SetHighlightTexture(CreateTexWithCoordsNum(obj,tx,num,total,3,4))
  79. :SetDisabledTexture(CreateTexWithCoordsNum(obj,tx,num,total,4,4))
  80. end
  81.  
  82. function self.ChainCall(obj) local T={} setmetatable(T,{__index=function(self,fun) if fun=="__END" then return obj end return function(self,...) assert(obj[fun],fun.." missing in object") obj[fun](obj,...) return self end end}) return T end
  83.  
  84. local flash_interval = 0.25
  85.  
  86. local flash = nil
  87. local MinimapNodeFlash = function(s)
  88. flash = not flash
  89. Minimap:SetBlipTexture("Interface\\AddOns\\BasicUI\\Media\\objecticons_"..(flash and "on" or "off"))
  90. end
  91.  
  92. local q = 0
  93. do
  94. local flashFrame = CreateFrame("FRAME","PointerExtraFrame")
  95. local ant_last=GetTime()
  96. local flash_last=GetTime()
  97. flashFrame:SetScript("OnUpdate",function(self,elapsed)
  98. local t=GetTime()
  99.  
  100. -- Flashing node dots. Prettier than the standard, too. And slightly bigger.
  101. if db.flashgathernodes then
  102. if t-flash_last>=flash_interval then
  103. MinimapNodeFlash()
  104. flash_last=t-(t-flash_last)%flash_interval
  105. end
  106. else
  107. Minimap:SetBlipTexture("Interface\\AddOns\\BasicUI\\Media\\objecticons_on")
  108. end
  109. end)
  110.  
  111. flashFrame:SetPoint("CENTER",UIParent)
  112. flashFrame:Show()
  113. self.ChainCall(flashFrame:CreateTexture("PointerDotOn","OVERLAY")) :SetTexture("Interface\\AddOns\\BasicUI\\Media\\objecticons_on") :SetSize(50,50) :SetPoint("CENTER") :SetNonBlocking(true) :Show()
  114. self.ChainCall(flashFrame:CreateTexture("PointerDotOff","OVERLAY")) :SetTexture("Interface\\AddOns\\BasicUI\\Media\\objecticons_off") :SetSize(50,50) :SetPoint("RIGHT") :SetNonBlocking(true) :Show()
  115. end
  116. end
  117.  
  118. function MODULE:Cooldown()
  119.  
  120. if db.cooldown ~= true then return end
  121.  
  122. OmniCC = true -- hack to work around detection from other addons for OmniCC
  123.  
  124. local FONT_COLOR = {1, 1, 1}
  125. local FONT_FACE, FONT_SIZE = ADDON_NAME.db.profile.media.fontNormal, 20
  126.  
  127. local MIN_DURATION = 2.5 -- the minimum duration to show cooldown text for
  128. local DECIMAL_THRESHOLD = 2 -- threshold in seconds to start showing decimals
  129.  
  130. local MIN_SCALE = 0.5 -- the minimum scale we want to show cooldown counts at, anything below this will be hidden
  131. local ICON_SIZE = 36
  132.  
  133. local DAY, HOUR, MINUTE = 86400, 3600, 60
  134. local DAYISH, HOURISH, MINUTEISH = 3600 * 23.5, 60 * 59.5, 59.5
  135. local HALFDAYISH, HALFHOURISH, HALFMINUTEISH = DAY/2 + 0.5, HOUR/2 + 0.5, MINUTE/2 + 0.5
  136.  
  137. local GetTime = GetTime
  138.  
  139. local min = math.min
  140. local floor = math.floor
  141. local format = string.format
  142.  
  143. local round = function(x)
  144. return floor(x + 0.5)
  145. end
  146.  
  147. local function getTimeText(s)
  148. if (s < DECIMAL_THRESHOLD + 0.5) then
  149. return format('|cffff0000%.1f|r', s), s - format('%.1f', s)
  150. elseif (s < MINUTEISH) then
  151. local seconds = round(s)
  152. return format('|cffffff00%d|r', seconds), s - (seconds - 0.51)
  153. elseif (s < HOURISH) then
  154. local minutes = round(s/MINUTE)
  155. return format('|cffffffff%dm|r', minutes), minutes > 1 and (s - (minutes*MINUTE - HALFMINUTEISH)) or (s - MINUTEISH)
  156. elseif (s < DAYISH) then
  157. local hours = round(s/HOUR)
  158. return format('|cffccccff%dh|r', hours), hours > 1 and (s - (hours*HOUR - HALFHOURISH)) or (s - HOURISH)
  159. else
  160. local days = round(s/DAY)
  161. return format('|cffcccccc%dd|r', days), days > 1 and (s - (days*DAY - HALFDAYISH)) or (s - DAYISH)
  162. end
  163. end
  164.  
  165. -- stops the timer
  166.  
  167. local function Timer_Stop(self)
  168. self.enabled = nil
  169. self:Hide()
  170. end
  171.  
  172. -- forces the given timer to update on the next frame
  173.  
  174. local function Timer_ForceUpdate(self)
  175. self.nextUpdate = 0
  176. self:Show()
  177. end
  178.  
  179. -- adjust font size whenever the timer's parent size changes, hide if it gets too tiny
  180.  
  181. local function Timer_OnSizeChanged(self, width, height)
  182. local fontScale = round(width) / ICON_SIZE
  183.  
  184. if (fontScale == self.fontScale) then
  185. return
  186. end
  187.  
  188. self.fontScale = fontScale
  189.  
  190. if (fontScale < MIN_SCALE) then
  191. self:Hide()
  192. else
  193. self.text:SetFont(FONT_FACE, fontScale * FONT_SIZE, 'OUTLINE')
  194. self.text:SetShadowColor(0, 0, 0, 0.5)
  195. self.text:SetShadowOffset(2, -2)
  196.  
  197. if (self.enabled) then
  198. Timer_ForceUpdate(self)
  199. end
  200. end
  201. end
  202.  
  203. -- update timer text, if it needs to be, hide the timer if done
  204.  
  205. local function Timer_OnUpdate(self, elapsed)
  206. if (self.nextUpdate > 0) then
  207. self.nextUpdate = self.nextUpdate - elapsed
  208. else
  209. local remain = self.duration - (GetTime() - self.start)
  210. if (round(remain) > 0) then
  211. local time, nextUpdate = getTimeText(remain)
  212. self.text:SetText(time)
  213. self.nextUpdate = nextUpdate
  214. else
  215. Timer_Stop(self)
  216. end
  217. end
  218. end
  219.  
  220. -- returns a new timer object
  221.  
  222. local function Timer_Create(self)
  223. local scaler = CreateFrame('Frame', nil, self)
  224. scaler:SetAllPoints(self)
  225.  
  226. local timer = CreateFrame('Frame', nil, scaler)
  227. timer:Hide()
  228. timer:SetAllPoints(scaler)
  229. timer:SetScript('OnUpdate', Timer_OnUpdate)
  230.  
  231. local text = timer:CreateFontString(nil, 'BACKGROUND ')
  232. text:SetPoint('CENTER', 0, 0)
  233. text:SetJustifyH("CENTER")
  234. timer.text = text
  235.  
  236. Timer_OnSizeChanged(timer, scaler:GetSize())
  237. scaler:SetScript('OnSizeChanged', function(self, ...)
  238. Timer_OnSizeChanged(timer, ...)
  239. end)
  240.  
  241. self.timer = timer
  242.  
  243. return timer
  244. end
  245.  
  246. -- hook the SetCooldown method of all cooldown frames
  247. -- ActionButton1Cooldown is used here since its likely to always exist
  248. -- and I'd rather not create my own cooldown frame to preserve a tiny bit of memory
  249.  
  250. hooksecurefunc(getmetatable(ActionButton1Cooldown).__index, 'SetCooldown', function(self, start, duration)
  251. if (self.noOCC) then
  252. return
  253. end
  254.  
  255. if (start > 0 and duration > MIN_DURATION) then
  256. local timer = self.timer or Timer_Create(self)
  257. timer.start = start
  258. timer.duration = duration
  259. timer.enabled = true
  260. timer.nextUpdate = 0
  261.  
  262. if (timer.fontScale >= MIN_SCALE) then
  263. timer:Show()
  264. end
  265. else
  266. local timer = self.timer
  267.  
  268. if (timer) then
  269. Timer_Stop(timer)
  270. end
  271. end
  272. end)
  273. end
  274.  
  275. function MODULE:Quicky()
  276.  
  277. if db.quicky ~= true then return end
  278.  
  279. local f = CreateFrame('Frame')
  280.  
  281. f.Head = CreateFrame('Button', nil, CharacterHeadSlot)
  282. f.Head:SetFrameStrata('HIGH')
  283. f.Head:SetSize(16, 32)
  284. f.Head:SetPoint('LEFT', CharacterHeadSlot, 'CENTER', 9, 0)
  285.  
  286. f.Head:SetScript('OnClick', function()
  287. ShowHelm(not ShowingHelm())
  288. end)
  289.  
  290. f.Head:SetScript('OnEnter', function(self)
  291. GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 13, -10)
  292. GameTooltip:AddLine(SHOW_HELM)
  293. GameTooltip:Show()
  294. end)
  295.  
  296. f.Head:SetScript('OnLeave', function()
  297. GameTooltip:Hide()
  298. end)
  299.  
  300. f.Head:SetNormalTexture([[Interface\AddOns\BasicUI\Media\textureNormal]])
  301. f.Head:SetHighlightTexture([[Interface\AddOns\BasicUI\Media\textureHighlight]])
  302. f.Head:SetPushedTexture([[Interface\AddOns\BasicUI\Media\texturePushed]])
  303.  
  304. CharacterHeadSlotPopoutButton:SetScript('OnShow', function()
  305. f.Head:ClearAllPoints()
  306. f.Head:SetPoint('RIGHT', CharacterHeadSlot, 'CENTER', -9, 0)
  307. end)
  308.  
  309. CharacterHeadSlotPopoutButton:SetScript('OnHide', function()
  310. f.Head:ClearAllPoints()
  311. f.Head:SetPoint('LEFT', CharacterHeadSlot, 'CENTER', 9, 0)
  312. end)
  313.  
  314. f.Cloak = CreateFrame('Button', nil, CharacterBackSlot)
  315. f.Cloak:SetFrameStrata('HIGH')
  316. f.Cloak:SetSize(16, 32)
  317. f.Cloak:SetPoint('LEFT', CharacterBackSlot, 'CENTER', 9, 0)
  318.  
  319. f.Cloak:SetScript('OnClick', function()
  320. ShowCloak(not ShowingCloak())
  321. end)
  322.  
  323. f.Cloak:SetScript('OnEnter', function(self)
  324. GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 13, -10)
  325. GameTooltip:AddLine(SHOW_CLOAK)
  326. GameTooltip:Show()
  327. end)
  328.  
  329. f.Cloak:SetScript('OnLeave', function()
  330. GameTooltip:Hide()
  331. end)
  332.  
  333. f.Cloak:SetNormalTexture([[Interface\AddOns\BasicUI\Media\textureNormal]])
  334. f.Cloak:SetHighlightTexture([[Interface\AddOns\BasicUI\Media\textureHighlight]])
  335. f.Cloak:SetPushedTexture([[Interface\AddOns\BasicUI\Media\texturePushed]])
  336.  
  337. CharacterBackSlotPopoutButton:SetScript('OnShow', function()
  338. f.Cloak:ClearAllPoints()
  339. f.Cloak:SetPoint('RIGHT', CharacterBackSlot, 'CENTER', -9, 0)
  340. end)
  341.  
  342. CharacterBackSlotPopoutButton:SetScript('OnHide', function()
  343. f.Cloak:ClearAllPoints()
  344. f.Cloak:SetPoint('LEFT', CharacterBackSlot, 'CENTER', 9, 0)
  345. end)
  346. end
  347.  
  348. function MODULE:Velluminous()
  349. if db.vellum ~= true then return end
  350.  
  351. if not TradeSkillFrame then
  352. print("What the fuck? Velluminous cannot initialize. BAIL! BAIL! BAIL!")
  353. return
  354. end
  355.  
  356.  
  357. local butt = CreateFrame("Button", nil, TradeSkillCreateButton, "SecureActionButtonTemplate")
  358. butt:SetAttribute("type", "macro")
  359. butt:SetAttribute("macrotext", "/click TradeSkillCreateButton\n/use item:38682")
  360.  
  361. butt:SetText("Vellum")
  362.  
  363. butt:SetPoint("RIGHT", TradeSkillCreateButton, "LEFT")
  364.  
  365. butt:SetWidth(80) butt:SetHeight(22)
  366.  
  367. -- Fonts --
  368. butt:SetDisabledFontObject(GameFontDisable)
  369. butt:SetHighlightFontObject(GameFontHighlight)
  370. butt:SetNormalFontObject(GameFontNormal)
  371.  
  372. -- Textures --
  373. butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
  374. butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
  375. butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
  376. butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
  377. butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  378. butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  379. butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  380. butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  381. butt:GetHighlightTexture():SetBlendMode("ADD")
  382.  
  383. local hider = CreateFrame("Frame", nil, TradeSkillCreateAllButton)
  384. hider:SetScript("OnShow", function() butt:Hide() end)
  385. hider:SetScript("OnHide", function() butt:Show() end)
  386. end
  387.  
  388. function MODULE:Merchant()
  389.  
  390. if db.merchant.enable ~= true then return end
  391.  
  392. -- Credit for Merchant goes to Tuks for his Tukui project.
  393. -- You can find his Addon at http://tukui.org/dl.php
  394. -- Editied by Cokedriver
  395.  
  396. local sg = CreateFrame("Frame")
  397. sg:SetScript("OnEvent", function()
  398. if db.merchant.autoSellGrey then
  399. local c = 0
  400. for b=0,4 do
  401. for s=1,GetContainerNumSlots(b) do
  402. local l,lid = GetContainerItemLink(b, s), GetContainerItemID(b, s)
  403. if l and lid then
  404. local p = 0
  405. local mult1, mult2 = select(11, GetItemInfo(l)), select(2, GetContainerItemInfo(b, s))
  406. if mult1 and mult2 then p = mult1 * mult2 end
  407. if db.merchant.autoSellGrey and select(3, GetItemInfo(l)) == 0 and p > 0 then
  408. UseContainerItem(b, s)
  409. PickupMerchantItem()
  410. c = c+p
  411. end
  412. end
  413. end
  414. end
  415. if c>0 then
  416. local g, s, c = math.floor(c/10000) or 0, math.floor((c%10000)/100) or 0, c%100
  417. DEFAULT_CHAT_FRAME:AddMessage("Your grey item's have been sold for".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r"..".",255,255,0)
  418. end
  419. end
  420. if not IsShiftKeyDown() then
  421. if CanMerchantRepair() and db.merchant.autoRepair then
  422. guildRepairFlag = 0
  423. local cost, possible = GetRepairAllCost()
  424. -- additional checks for guild repairs
  425. if (IsInGuild()) and (CanGuildBankRepair()) then
  426. if cost <= GetGuildBankWithdrawMoney() then
  427. guildRepairFlag = 1
  428. end
  429. end
  430. if cost>0 then
  431. if (possible or guildRepairFlag) then
  432. RepairAllItems(guildRepairFlag)
  433. local c = cost%100
  434. local s = math.floor((cost%10000)/100)
  435. local g = math.floor(cost/10000)
  436. if db.merchant.guildPay == "true" and guildRepairFlag == 1 then
  437. DEFAULT_CHAT_FRAME:AddMessage("Your guild payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
  438. else
  439. DEFAULT_CHAT_FRAME:AddMessage("You payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
  440. end
  441. else
  442. DEFAULT_CHAT_FRAME:AddMessage("You don't have enough money for repair!",255,0,0)
  443. end
  444. end
  445. end
  446. end
  447. end)
  448. sg:RegisterEvent("MERCHANT_SHOW")
  449.  
  450. end
  451.  
  452. function MODULE:Autogreed()
  453.  
  454. if db.autogreed.enable ~= true then return end
  455.  
  456. local skipList = {
  457. --['Stone Scarab'] = true,
  458. --['Silver Scarab'] = true,
  459. }
  460.  
  461. local ag = CreateFrame('Frame')
  462. ag:RegisterEvent('START_LOOT_ROLL')
  463. ag:SetScript('OnEvent', function(_, _, RollID)
  464. local texture, name, count, quality, bindOnPickUp , canNeed, canGreed, canDisenchant = GetLootRollItemInfo(RollID)
  465.  
  466. if db.autogreed.disenchant ~= true then
  467. if (quality == 2 and not bindOnPickUp) then
  468. RollOnLoot(RollID, canGreed and 3 or 2)
  469. end
  470. else
  471. if (quality == 2 and not bindOnPickUp) then
  472. RollOnLoot(RollID, canDisenchant and 3 or 2)
  473. end
  474. end
  475. end)
  476. end
  477.  
  478. function MODULE:AltBuy()
  479.  
  480. if db.altbuy ~= true then return end
  481.  
  482. local NEW_ITEM_VENDOR_STACK_BUY = ITEM_VENDOR_STACK_BUY
  483. ITEM_VENDOR_STACK_BUY = '|cffa9ff00'..NEW_ITEM_VENDOR_STACK_BUY..'|r'
  484.  
  485. -- alt-click to buy a stack
  486. local origMerchantItemButton_OnModifiedClick = _G.MerchantItemButton_OnModifiedClick
  487. local function MerchantItemButton_OnModifiedClickHook(self, ...)
  488. origMerchantItemButton_OnModifiedClick(self, ...)
  489.  
  490. if (IsAltKeyDown()) then
  491. local maxStack = select(8, GetItemInfo(GetMerchantItemLink(self:GetID())))
  492. local _, _, _, quantity = GetMerchantItemInfo(self:GetID())
  493.  
  494. if (maxStack and maxStack > 1) then
  495. BuyMerchantItem(self:GetID(), floor(maxStack / quantity))
  496. end
  497. end
  498. end
  499. MerchantItemButton_OnModifiedClick = MerchantItemButton_OnModifiedClickHook
  500.  
  501. -- Google translate ftw...NOT
  502. local function GetAltClickString()
  503. if (GetLocale() == 'enUS') then
  504. return '<Alt-click, to buy an stack>'
  505. elseif (GetLocale() == 'frFR') then
  506. return '<Alt-clic, d acheter une pile>'
  507. elseif (GetLocale() == 'esES') then
  508. return '<Alt-clic, para comprar una pila>'
  509. elseif (GetLocale() == 'deDE') then
  510. return '<Alt-klicken, um einen ganzen Stapel zu kaufen>'
  511. else
  512. return '<Alt-click, to buy an stack>'
  513. end
  514. end
  515.  
  516. -- add a hint to the tooltip
  517. local function IsMerchantButtonOver()
  518. return GetMouseFocus():GetName() and GetMouseFocus():GetName():find('MerchantItem%d')
  519. end
  520.  
  521. GameTooltip:HookScript('OnTooltipSetItem', function(self)
  522. if (MerchantFrame:IsShown() and IsMerchantButtonOver()) then
  523. for i = 2, GameTooltip:NumLines() do
  524. if (_G['GameTooltipTextLeft'..i]:GetText():find('<[sS]hift')) then
  525. GameTooltip:AddLine('|cff00ffcc'..GetAltClickString()..'|r')
  526. end
  527. end
  528. end
  529. end)
  530. end
  531.  
  532. function MODULE:Quest()
  533. if db.quest ~= true then return end
  534.  
  535. local f = CreateFrame("Frame")
  536.  
  537. local function MostValueable()
  538. local bestp, besti = 0
  539. for i=1,GetNumQuestChoices() do
  540. local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i)
  541. local price = link and select(11, GetItemInfo(link))
  542. if not price then
  543. return
  544. elseif (price * (qty or 1)) > bestp then
  545. bestp, besti = (price * (qty or 1)), i
  546. end
  547. end
  548. if besti then
  549. local btn = _G["QuestInfoItem"..besti]
  550. if (btn.type == "choice") then
  551. btn:GetScript("OnClick")(btn)
  552. end
  553. end
  554. end
  555.  
  556. f:RegisterEvent("QUEST_ITEM_UPDATE")
  557. f:RegisterEvent("GET_ITEM_INFO_RECEIVED")
  558. f:RegisterEvent("QUEST_ACCEPT_CONFIRM")
  559. f:RegisterEvent("QUEST_DETAIL")
  560. f:RegisterEvent("QUEST_COMPLETE")
  561. f:SetScript("OnEvent", function(self, event, ...)
  562. if db.quest.autocomplete ~= false then
  563. if (event == "QUEST_DETAIL") then
  564. AcceptQuest()
  565. CompleteQuest()
  566. elseif (event == "QUEST_COMPLETE") then
  567. if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
  568. GetQuestReward()
  569. else
  570. MostValueable()
  571. end
  572. elseif (event == "QUEST_ACCEPT_CONFIRM") then
  573. ConfirmAcceptQuest()
  574. end
  575. else
  576. if (event == "QUEST_COMPLETE") then
  577. if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
  578. GetQuestReward()
  579. else
  580. MostValueable()
  581. end
  582. end
  583. end
  584. end)
  585. end
  586.  
  587. function MODULE:SkinAddons()
  588. --[[
  589.  
  590. All Credit for Skinning.lua goes to Neal and ballagarba.
  591. Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
  592. Edited by Cokedriver.
  593.  
  594. ]]
  595.  
  596. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  597.  
  598. if db.skin.enable ~= true then return end
  599.  
  600. local f = CreateFrame('Frame')
  601. f:RegisterEvent('VARIABLES_LOADED')
  602. f:RegisterEvent('ADDON_LOADED')
  603. f:RegisterEvent('PLAYER_ENTERING_WORLD')
  604.  
  605.  
  606. f:SetScript('OnEvent', function(self, ...)
  607. ---------------
  608. -- DBM Skinning
  609. ---------------
  610.  
  611. if (db.skin.DBM == true and IsAddOnLoaded('DBM-Core')) then
  612. -- Normal Bars (Credit for DBM codeing goes to Elv from ElvUI)
  613. hooksecurefunc(DBT, 'CreateBar', function(self)
  614. for bar in self:GetBarIterator() do
  615. if not bar.injected then
  616. bar.ApplyStyle=function()
  617. local frame = bar.frame
  618. local tbar = _G[frame:GetName().."Bar"]
  619. local spark = _G[frame:GetName().."BarSpark"]
  620. local texture = _G[frame:GetName().."BarTexture"]
  621. local icon1 = _G[frame:GetName().."BarIcon1"]
  622. local icon2 = _G[frame:GetName().."BarIcon2"]
  623. local name = _G[frame:GetName().."BarName"]
  624. local timer = _G[frame:GetName().."BarTimer"]
  625.  
  626. if not (icon1.overlay) then
  627. icon1.overlay = CreateFrame("Frame", "$parentIcon1Overlay", tbar)
  628. icon1.overlay:SetSize(26, 26)
  629. icon1.overlay:SetFrameStrata("MEDIUM");
  630. icon1.overlay:SetPoint("BOTTOMRIGHT", tbar, "BOTTOMLEFT", -22/4, -4);
  631. icon1.overlay:SetBackdrop({
  632. edgeFile = db.skin.border,
  633. tile = true, tileSize = 16, edgeSize = 18,
  634. })
  635.  
  636. if db.misc.classcolor then
  637. icon1.overlay:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  638. end
  639.  
  640. icon1.overlay.styled=true
  641. end
  642.  
  643. if not (icon2.overlay) then
  644. icon2.overlay = CreateFrame("Frame", "$parentIcon2Overlay", tbar)
  645. icon2.overlay:SetSize(26, 26)
  646. icon2.overlay:SetFrameStrata("MEDIUM");
  647. icon2.overlay:SetPoint("BOTTOMLEFT", tbar, "BOTTOMRIGHT", 22/4, -4);
  648. icon2.overlay:SetBackdrop({
  649. edgeFile = db.skin.border,
  650. tile = true, tileSize = 16, edgeSize = 18,
  651. })
  652.  
  653. if db.misc.classcolor then
  654. icon2.overlay:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  655. end
  656.  
  657. icon2.overlay.styled=true
  658. end
  659.  
  660. if bar.color then
  661. tbar:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b)
  662. else
  663. tbar:SetStatusBarColor(bar.owner.options.StartColorR, bar.owner.options.StartColorG, bar.owner.options.StartColorB)
  664. end
  665.  
  666. if bar.enlarged then frame:SetWidth(bar.owner.options.HugeWidth) else frame:SetWidth(bar.owner.options.Width) end
  667. if bar.enlarged then tbar:SetWidth(bar.owner.options.HugeWidth) else tbar:SetWidth(bar.owner.options.Width) end
  668.  
  669. if not frame.styled then
  670. frame:SetScale(1)
  671. frame.SetScale=B.dummy
  672. frame:SetHeight(22)
  673. local border = CreateFrame("Frame", nil, frame);
  674. border:SetFrameStrata("MEDIUM");
  675. border:SetPoint("TOPLEFT", -2, 2);
  676. border:SetPoint("BOTTOMRIGHT", 2, -2);
  677. border:SetBackdrop({
  678. edgeFile = db.skin.border,
  679. tile = true, tileSize = 16, edgeSize = 18,
  680. })
  681.  
  682. if db.misc.classcolor then
  683. border:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  684. end
  685.  
  686. frame.styled=true
  687. end
  688.  
  689. if not spark.killed then
  690. spark:SetAlpha(0)
  691. spark:SetTexture(nil)
  692. spark.killed=true
  693. end
  694.  
  695. if not icon1.styled then
  696. icon1:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  697. icon1:ClearAllPoints()
  698. icon1:SetPoint("TOPLEFT", icon1.overlay, 2, -2)
  699. icon1:SetPoint("BOTTOMRIGHT", icon1.overlay, -2, 2)
  700. icon1.styled=true
  701. end
  702.  
  703. if not icon2.styled then
  704. icon2:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  705. icon2:ClearAllPoints()
  706. icon2:SetPoint("TOPLEFT", icon2.overlay, 2, -2)
  707. icon2:SetPoint("BOTTOMRIGHT", icon2.overlay, -2, 2)
  708. icon2.styled=true
  709. end
  710.  
  711. if not texture.styled then
  712. texture:SetTexture(db.skin.statusbar)
  713. texture.styled=true
  714. end
  715.  
  716. tbar:SetStatusBarTexture(db.skin.statusbar)
  717. if not tbar.styled then
  718. tbar:SetPoint("TOPLEFT", frame, "TOPLEFT", 2, -2)
  719. tbar:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 2)
  720.  
  721. tbar.styled=true
  722. end
  723.  
  724. if not name.styled then
  725. name:ClearAllPoints()
  726. name:SetPoint("LEFT", frame, "LEFT", 4, 0)
  727. name:SetWidth(165)
  728. name:SetHeight(8)
  729. name:SetFont(db.media.fontNormal, db.media.fontSize)
  730. name:SetJustifyH("LEFT")
  731. name:SetShadowColor(0, 0, 0, 0)
  732. name.SetFont = B.dummy
  733. name.styled=true
  734. end
  735.  
  736. if not timer.styled then
  737. timer:ClearAllPoints()
  738. timer:SetPoint("RIGHT", frame, "RIGHT", -4, 0)
  739. timer:SetFont(db.media.fontNormal, db.media.fontSize)
  740. timer:SetJustifyH("RIGHT")
  741. timer:SetShadowColor(0, 0, 0, 0)
  742. timer.SetFont = B.dummy
  743. timer.styled=true
  744. end
  745.  
  746. if bar.owner.options.IconLeft then icon1:Show() icon1.overlay:Show() else icon1:Hide() icon1.overlay:Hide() end
  747. if bar.owner.options.IconRight then icon2:Show() icon2.overlay:Show() else icon2:Hide() icon2.overlay:Hide() end
  748. tbar:SetAlpha(1)
  749. frame:SetAlpha(1)
  750. texture:SetAlpha(1)
  751. frame:Show()
  752. bar:Update(0)
  753. bar.injected=true
  754. end
  755. bar:ApplyStyle()
  756. end
  757.  
  758. end
  759. end)
  760.  
  761. -- DBM Boss Healthbars
  762. hooksecurefunc(DBM.BossHealth,"Show",function()
  763. local anchor=DBMBossHealthDropdown:GetParent()
  764. if not anchor.styled then
  765. local header={anchor:GetRegions()}
  766. if header[1]:IsObjectType("FontString") then
  767. header[1]:SetFont(db.media.fontNormal, db.media.fontSize)
  768. header[1]:SetTextColor(1,1,1,1)
  769. header[1]:SetShadowColor(0, 0, 0, 0)
  770. anchor.styled=true
  771. end
  772. header=nil
  773. end
  774. anchor=nil
  775. end)
  776.  
  777. hooksecurefunc(DBM.BossHealth, "AddBoss", function()
  778. local count = 1
  779. while (_G[format("DBM_BossHealth_Bar_%d", count)]) do
  780. local bar = _G[format("DBM_BossHealth_Bar_%d", count)]
  781. local background = _G[bar:GetName().."BarBorder"]
  782. local progress = _G[bar:GetName().."Bar"]
  783. local name = _G[bar:GetName().."BarName"]
  784. local timer = _G[bar:GetName().."BarTimer"]
  785. local prev = _G[format("DBM_BossHealth_Bar_%d", count-1)]
  786.  
  787. if (count == 1) then
  788. local _, anch, _ ,_, _ = bar:GetPoint()
  789. bar:ClearAllPoints()
  790. if DBM_SavedOptions.HealthFrameGrowUp then
  791. bar:SetPoint("BOTTOM", anch, "TOP" , 0 , 12)
  792. else
  793. bar:SetPoint("TOP", anch, "BOTTOM" , 0, -22)
  794. end
  795. else
  796. bar:ClearAllPoints()
  797. if DBM_SavedOptions.HealthFrameGrowUp then
  798. bar:SetPoint("TOPLEFT", prev, "TOPLEFT", 0, 26)
  799. else
  800. bar:SetPoint("TOPLEFT", prev, "TOPLEFT", 0, -26)
  801. end
  802. end
  803.  
  804. if not bar.styled then
  805. bar:SetHeight(22)
  806. background:SetNormalTexture(nil)
  807. local barb = CreateFrame("Frame", nil, bar);
  808. barb:SetFrameStrata("MEDIUM");
  809. barb:SetPoint("TOPLEFT", -2, 2);
  810. barb:SetPoint("BOTTOMRIGHT", 2, -2);
  811. barb:SetBackdrop({
  812. edgeFile = db.skin.border,
  813. tile = true, tileSize = 16, edgeSize = 18,
  814. })
  815.  
  816. if db.misc.classcolor then
  817. barb:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  818. end
  819.  
  820. bar.styled=true
  821. end
  822.  
  823. if not progress.styled then
  824. progress:SetStatusBarTexture(db.skin.statusbar)
  825. progress:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b)
  826. progress.styled=true
  827. end
  828. progress:ClearAllPoints()
  829. progress:SetPoint("TOPLEFT", bar, "TOPLEFT", 2, -2)
  830. progress:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", -2, 2)
  831.  
  832. if not name.styled then
  833. name:ClearAllPoints()
  834. name:SetPoint("LEFT", bar, "LEFT", 4, 0)
  835. name:SetFont(db.media.fontNormal, db.media.fontSize)
  836. name:SetJustifyH("LEFT")
  837. name:SetShadowColor(0, 0, 0, 0)
  838. name.styled=true
  839. end
  840.  
  841. if not timer.styled then
  842. timer:ClearAllPoints()
  843. timer:SetPoint("RIGHT", bar, "RIGHT", -4, 0)
  844. timer:SetFont(db.media.fontNormal, db.media.fontSize)
  845. timer:SetJustifyH("RIGHT")
  846. timer:SetShadowColor(0, 0, 0, 0)
  847. timer.styled=true
  848. end
  849. count = count + 1
  850. end
  851. end)
  852. end
  853.  
  854. -------------------
  855. -- Recount Skinning
  856. -------------------
  857.  
  858. if (db.skin.Recount == true and IsAddOnLoaded('Recount')) then
  859. local rm = Recount.MainWindow
  860. if db.skin.RecountBackdrop == false then
  861. rm:SetBackdrop(nil)
  862. end
  863. local bgs = CreateFrame("Frame", nil, rm);
  864. bgs:SetFrameStrata("MEDIUM");
  865. bgs:SetPoint("TOPLEFT", -3, -8);
  866. bgs:SetPoint("BOTTOMRIGHT", 1, 0);
  867. bgs:SetBackdrop({
  868. edgeFile = db.skin.border,
  869. tile = true, tileSize = 16, edgeSize = 18,
  870. })
  871.  
  872. if db.misc.classcolor then
  873. bgs:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  874. end
  875.  
  876. end
  877. end)
  878. end
  879.  
  880. function MODULE:OnEnable()
  881. self:Cooldown()
  882. self:FlashGatherNods()
  883. self:Velluminous()
  884. self:Quicky()
  885. self:Autogreed()
  886. self:Quest()
  887. self:AltBuy()
  888. self:Merchant()
  889. self:SkinAddons()
  890. end
  891.  
  892.  
  893. ------------------------------------------------------------------------
  894. -- Module options
  895. ------------------------------------------------------------------------
  896.  
  897. local options
  898. function MODULE:GetOptions()
  899. if options then
  900. return options
  901. end
  902.  
  903. local function isModuleDisabled()
  904. return not ADDON_NAME:GetModuleEnabled(MODULE_NAME)
  905. end
  906.  
  907. options = {
  908. type = "group",
  909. name = L[MODULE_NAME],
  910. get = function(info) return db[ info[#info] ] end,
  911. set = function(info, value) db[ info[#info] ] = value; end,
  912. disabled = isModuleDisabled(),
  913. args = {
  914. ---------------------------
  915. --Option Type Seperators
  916. sep1 = {
  917. type = "description",
  918. order = 2,
  919. name = " ",
  920. },
  921. sep2 = {
  922. type = "description",
  923. order = 3,
  924. name = " ",
  925. },
  926. sep3 = {
  927. type = "description",
  928. order = 4,
  929. name = " ",
  930. },
  931. sep4 = {
  932. type = "description",
  933. order = 5,
  934. name = " ",
  935. },
  936. ---------------------------
  937. reloadUI = {
  938. type = "execute",
  939. name = "Reload UI",
  940. desc = " ",
  941. order = 0,
  942. func = function()
  943. ReloadUI()
  944. end,
  945. },
  946. Text = {
  947. type = "description",
  948. order = 0,
  949. name = "When changes are made a reload of the UI is needed.",
  950. width = "full",
  951. },
  952. Text1 = {
  953. type = "description",
  954. order = 1,
  955. name = " ",
  956. width = "full",
  957. },
  958. enable = {
  959. type = "toggle",
  960. order = 1,
  961. name = L["Enable Miscellaneous Module"],
  962. width = "full",
  963. disabled = false,
  964. },
  965. Text2 = {
  966. type = "description",
  967. name = " ",
  968. width = "full",
  969. },
  970. vellum = {
  971. type = "toggle",
  972. order = 2,
  973. name = L["Vellum"],
  974. desc = L["Enables a vellum button for Enchanters to click."],
  975. disabled = function() return isModuleDisabled() or not db.enable end,
  976. },
  977. cooldown = {
  978. type = "toggle",
  979. order = 2,
  980. name = L["Cooldown"],
  981. desc = L["Enables a version of OmniCC."],
  982. disabled = function() return isModuleDisabled() or not db.enable end,
  983. },
  984. quicky = {
  985. type = "toggle",
  986. order = 2,
  987. name = L["Quicky"],
  988. desc = L["Enables a quick hide show for your helm and cloak on your character page."],
  989. disabled = function() return isModuleDisabled() or not db.enable end,
  990. },
  991. altbuy = {
  992. type = "toggle",
  993. order = 2,
  994. name = L["Auto Disenchant"],
  995. desc = L["If Checked when in a a group any green items will have Disenchant auto selected if a enchanter is in your group"],
  996. disabled = function() return isModuleDisabled() or not db.enable end,
  997. },
  998. flashgathernodes = {
  999. type = "toggle",
  1000. order = 3,
  1001. name = L["Flash Gathering Nodes"],
  1002. desc = L["Enables flashing map nodes for tracking herbs and ore."],
  1003. width = "full",
  1004. disabled = function() return isModuleDisabled() or not db.enable end,
  1005. },
  1006. autogreed = {
  1007. type = "group",
  1008. order = 4,
  1009. name = L["Auto Greed Roll"],
  1010. guiInline = true,
  1011. get = function(info) return db.autogreed[ info[#info] ] end,
  1012. set = function(info, value) db.autogreed[ info[#info] ] = value; end,
  1013. disabled = function() return isModuleDisabled() or not db.enable end,
  1014. args = {
  1015. enable = {
  1016. type = "toggle",
  1017. order = 1,
  1018. name = L["Enable"],
  1019. desc = L["Enables Auto Rolling Greed on Green item's when in a Instance or Raid"],
  1020. width = "full",
  1021. },
  1022. disenchant = {
  1023. type = "toggle",
  1024. order = 2,
  1025. name = L["Auto Disenchant"],
  1026. desc = L["If Checked when in a a group any green items will have Disenchant auto selected if a enchanter is in your group"],
  1027. disabled = function() return isModuleDisabled() or not db.enable or not db.autogreed.enable end,
  1028. },
  1029. },
  1030. },
  1031. merchant = {
  1032. type = "group",
  1033. order = 5,
  1034. name = L["Merchant"],
  1035. guiInline = true,
  1036. get = function(info) return db.merchant[ info[#info] ] end,
  1037. set = function(info, value) db.merchant[ info[#info] ] = value; end,
  1038. disabled = function() return isModuleDisabled() or not db.enable end,
  1039. args = {
  1040. ---------------------------
  1041. --Option Type Seperators
  1042. sep1 = {
  1043. type = "description",
  1044. order = 2,
  1045. name = " ",
  1046. },
  1047. sep2 = {
  1048. type = "description",
  1049. order = 3,
  1050. name = " ",
  1051. },
  1052. sep3 = {
  1053. type = "description",
  1054. order = 4,
  1055. name = " ",
  1056. },
  1057. sep4 = {
  1058. type = "description",
  1059. order = 5,
  1060. name = " ",
  1061. },
  1062. ---------------------------
  1063. enable = {
  1064. type = "toggle",
  1065. order = 1,
  1066. name = L["Enable"],
  1067. desc = L["Enable Merchant Settings"],
  1068. width = "full",
  1069. },
  1070. autoRepair = {
  1071. type = "toggle",
  1072. order = 2,
  1073. name = L["Auto Repair"],
  1074. desc = L["Automatically repair when visiting a vendor"],
  1075. disabled = function() return isModuleDisabled() or not db.enable or not db.merchant.enable end,
  1076. },
  1077. guildPay = {
  1078. type = "toggle",
  1079. order = 2,
  1080. name = L["Guild Repair"],
  1081. desc = L["If Checked your guild will pay for your repairs"],
  1082. disabled = function() return isModuleDisabled() or not db.enable or not db.merchant.enable end,
  1083. },
  1084. autoSellGrey = {
  1085. type = "toggle",
  1086. order = 2,
  1087. name = L["Sell Grays"],
  1088. desc = L["Automatically sell gray items when visiting a vendor"],
  1089. disabled = function() return isModuleDisabled() or not db.enable or not db.merchant.enable end,
  1090. },
  1091. },
  1092. },
  1093. quest = {
  1094. type = "group",
  1095. order = 6,
  1096. name = L["Quest"],
  1097. desc = L["Quest Module for BasicUI."],
  1098. guiInline = true,
  1099. get = function(info) return db.quest[ info[#info] ] end,
  1100. set = function(info, value) db.quest[ info[#info] ] = value; end,
  1101. disabled = function() return isModuleDisabled() or not db.enable end,
  1102. args = {
  1103. ---------------------------
  1104. --Option Type Seperators
  1105. sep1 = {
  1106. type = "description",
  1107. order = 2,
  1108. name = " ",
  1109. },
  1110. sep2 = {
  1111. type = "description",
  1112. order = 3,
  1113. name = " ",
  1114. },
  1115. sep3 = {
  1116. type = "description",
  1117. order = 4,
  1118. name = " ",
  1119. },
  1120. sep4 = {
  1121. type = "description",
  1122. order = 5,
  1123. name = " ",
  1124. },
  1125. ---------------------------
  1126. enable = {
  1127. type = "toggle",
  1128. order = 1,
  1129. name = L["Enable"],
  1130. desc = L["Enables Quest Module"],
  1131. },
  1132. autocomplete = {
  1133. type = "toggle",
  1134. order = 2,
  1135. name = L["Autocomplete"],
  1136. desc = L["Automatically complete your quest."],
  1137. disabled = function() return isModuleDisabled() or not db.enable or not db.quest.enable end,
  1138. },
  1139. tekvendor = {
  1140. type = "toggle",
  1141. order = 2,
  1142. name = L["Tek's Vendor"],
  1143. desc = L["Enables Tek's best quest item by vendor price."],
  1144. disabled = function() return isModuleDisabled() or not db.enable or not db.quest.enable end,
  1145. },
  1146. },
  1147. },
  1148. skin = {
  1149. type = "group",
  1150. order = 7,
  1151. name = L["Skin Addons"],
  1152. guiInline = true,
  1153. get = function(info) return db.skin[ info[#info] ] end,
  1154. set = function(info, value) db.skin[ info[#info] ] = value; end,
  1155. disabled = function() return isModuleDisabled() or not db.enable end,
  1156. args = {
  1157. ---------------------------
  1158. --Option Type Seperators
  1159. sep1 = {
  1160. type = "description",
  1161. order = 2,
  1162. name = " ",
  1163. },
  1164. sep2 = {
  1165. type = "description",
  1166. order = 3,
  1167. name = " ",
  1168. },
  1169. sep3 = {
  1170. type = "description",
  1171. order = 4,
  1172. name = " ",
  1173. },
  1174. sep4 = {
  1175. type = "description",
  1176. order = 5,
  1177. name = " ",
  1178. },
  1179. ---------------------------
  1180. enable = {
  1181. type = "toggle",
  1182. order = 1,
  1183. name = L["Enable Skinning Addon's to match BasicUI"],
  1184. width = "full",
  1185. },
  1186. DBM = {
  1187. type = "toggle",
  1188. order = 2,
  1189. name = L["DBM"],
  1190. desc = L["Skins Deadly Boss Mods to match BasicUI."],
  1191. disabled = function() return isModuleDisabled() or not db.enable or not db.skin.enable end,
  1192. },
  1193. Recount = {
  1194. type = "toggle",
  1195. order = 2,
  1196. name = L["Recount"],
  1197. desc = L["Skins Recount to match BasicUI."],
  1198. disabled = function() return isModuleDisabled() or not db.enable or not db.skin.enable end,
  1199. },
  1200. RecountBackdrop = {
  1201. type = "toggle",
  1202. order = 2,
  1203. name = L["Recount Backdrop"],
  1204. desc = L["Keep the backdrop in the Recount Window."],
  1205. disabled = function() return isModuleDisabled() or not db.enable or not db.skin.enable end,
  1206. },
  1207. },
  1208. },
  1209. },
  1210. }
  1211. return options
  1212. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement