Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 61.80 KB | None | 0 0
  1. local TableInsert = table.insert;
  2. local TableRemove = table.remove;
  3. local StringFormat = string.format;
  4. local ToString = tostring;
  5. local BitBand = bit.band
  6.  
  7. local qcL = qcLocalize
  8.  
  9. local qcPins = {}
  10. local qcPinFrames = {}
  11. local qcSparePinFrames = {}
  12.  
  13. local qcCurrentCategoryID = 0
  14. local qcCurrentCategoryQuestCount = 0
  15. local qcCategoryQuests = {}
  16.  
  17. --[[ Vars ]]--
  18. local qcCurrentScrollPosition = 1
  19. local qcMapTooltip = nil
  20. local qcQuestReputationTooltip = nil
  21. local qcQuestInformationTooltip = nil
  22. local qcToastTooltip = nil
  23. local qcNewDataAlertTooltip = nil
  24. local qcMutuallyExclusiveAlertTooltip = nil
  25.  
  26.  
  27. --[[ Constants ]]--
  28. local QCADDON_VERSION = 109.7
  29. local QCADDON_PURGE = true
  30. local QCDEBUG_MODE = false
  31. local QCADDON_CHAT_TITLE = "|CFF9482C9Quest Completist:|r "
  32.  
  33.  
  34. local COLOUR_DEATHKNIGHT = "|cFFC41F3B"
  35. local COLOUR_DEMONHUNTER = "|cFFA330C9"
  36. local COLOUR_DRUID = "|cFFFF7D0A"
  37. local COLOUR_HUNTER = "|cFFABD473"
  38. local COLOUR_MAGE = "|cFF69CCF0"
  39. local COLOUR_PALADIN = "|cFFF58CBA"
  40. local COLOUR_PRIEST = "|cFFFFFFFF"
  41. local COLOUR_ROGUE = "|cFFFFF569"
  42. local COLOUR_SHAMAN = "|cFF0070DE"
  43. local COLOUR_WARLOCK = "|cFF9482C9"
  44. local COLOUR_WARRIOR = "|cFFC79C6E"
  45.  
  46. local QC_ICON_COORDS_NORMAL = {0,0.125,0,0.25}
  47. local QC_ICON_COORDS_REPEATABLE = {0.125,0.25,0.25,0.50}
  48. local QC_ICON_COORDS_DAILY = {0,0.125,0.25,0.50}
  49. local QC_ICON_COORDS_SPECIAL = {0,0.125,0,0.25}
  50. local QC_ICON_COORDS_WEEKLY = {0,0.125,0,0.25}
  51. local QC_ICON_COORDS_SEASONAL = {0,0.125,0.5,0.75}
  52. local QC_ICON_COORDS_PROFESSION = {0.625,0.75,0,0.25}
  53. local QC_ICON_COORDS_PROGRESS = {0.25,0.375,0.25,0.5}
  54. local QC_ICON_COORDS_READY = {0.125,0.25,0,0.25}
  55. local QC_ICON_COORDS_COMPLETE = {0.125,0.25,0.5,0.75}
  56. local QC_ICON_COORDS_UNATTAINABLE = {0.25,0.375,0.5,0.75}
  57. local QC_ICON_COORDS_ITEMDROPSTANDARD = {0.375,0.5,0,0.25}
  58. local QC_ICON_COORDS_ITEMDROPREPEATABLE = {0.375,0.5,0.25,0.5}
  59. local QC_ICON_COORDS_CLASS = {0.5,0.625,0,0.25}
  60. local QC_ICON_COORDS_KILL = {0.25,0.375,0,0.25}
  61.  
  62. local qcCategoryDropDownMenu = CreateFrame("Frame", "qcCategoryDropDownMenu")
  63.  
  64. --[[ Bitwise Values ]]--
  65. qcFactionBits = {
  66. ["ALLIANCE"]=1,["HORDE"]=2,["NEUTRAL"]=4,
  67. }
  68. qcRaceBits = {
  69. ["HUMAN"]=1,["ORC"]=2,["DWARF"]=4,["NIGHTELF"]=8,
  70. ["SCOURGE"]=16,["TAUREN"]=32,["GNOME"]=64,["TROLL"]=128,
  71. ["GOBLIN"]=256,["BLOODELF"]=512,["DRAENEI"]=1024,["WORGEN"]=2048,
  72. ["PANDAREN"]=4096,["VOIDELF"]=8192,["NIGHTBORNE"]=16384,
  73. ["HIGHMOUNTAINTAUREN"]=32768,["LIGHTFORGEDDRAENEI"]=65536
  74. }
  75. qcClassBits = {
  76. ["WARRIOR"]=1,["PALADIN"]=2,["HUNTER"]=4,["ROGUE"]=8,["PRIEST"]=16,
  77. ["DEATHKNIGHT"]=32,["SHAMAN"]=64,["MAGE"]=128,["WARLOCK"]=256,["DRUID"]=512,
  78. ["MONK"]=1024,["DEMONHUNTER"]=2048
  79. }
  80. qcProfessionBits = {
  81. [171]=1, -- Alchemy
  82. [164]=2, -- Blacksmithing
  83. [333]=4, -- Enchanting
  84. [202]=8, -- Engineering
  85. [773]=16, -- Inscription
  86. [755]=32, -- Jewelcrafting
  87. [165]=64, -- Leatherworking
  88. [197]=128, -- Tailoring
  89. [182]=256, -- Herbalism
  90. [186]=512, -- Mining
  91. [393]=1024, -- Skinning
  92. [794]=2048, -- Archaeology
  93. [129]=4096, -- First Aid
  94. [185]=8192, -- Cooking
  95. [356]=16384, -- Fishing
  96. }
  97. local qcHolidayDates = {
  98. [1]={"180920","111006"}, -- Brewfest 2018
  99. [2]={"180425","180502"}, -- Children's Week 2018
  100. [4]={"181101","181103"}, -- Day of the Dead 2018
  101. [8]={"181216","190102"}, -- Feast of Winter Veil 2018-2019
  102. [16]={"181018","181101"}, -- Hallow's End 2018
  103. [32]={"180918","180925"}, -- Harvest Festival 2018
  104. [64]={"190205","190219"}, -- Love is in the Air 2019
  105. [128]={"190128","190211"}, -- Lunar Festival 2019
  106. [256]={"180621","180705"}, -- Midsummer Fire Festival 2018
  107. [512]={"180402","180409"}, -- Noblegarden 2018
  108. [1024]={"181119","181126"}, -- Pilgrim's Bounty 2018
  109. [2048]={"180919","180920"}, -- Pirates' Day 2018
  110. }
  111.  
  112. --[[ Constants for the Key Bindings & Slash Commands ]]--
  113. BINDING_HEADER_QCQUESTCOMPLETIST = "Quest Completist";
  114. BINDING_NAME_QCTOGGLEFRAME = "Toggle Frame";
  115. SLASH_QUESTCOMPLETIST1 = "/qc"
  116. SLASH_QUESTCOMPLETIST2 = "/questc"
  117.  
  118. SlashCmdList["QUESTCOMPLETIST"] = function(msg, editbox)
  119. ShowUIPanel(qcQuestCompletistUI)
  120. end
  121.  
  122. function qcCopyTable(qcTable)
  123. if not (qcTable) then return nil end
  124. if not (type(qcTable) == "table") then return nil end
  125. local qcNewTable = {}
  126. for qcKey, qcValue in pairs(qcTable) do
  127. if (type(qcValue) == "table") then
  128. qcNewTable[qcKey] = qcCopyTable(qcValue)
  129. else
  130. qcNewTable[qcKey] = qcValue
  131. end
  132. end
  133. return qcNewTable
  134. end
  135.  
  136. function qcUpdateCurrentCategoryText(categoryId)
  137. qcQuestCompletistUI.qcSelectedCategory:SetText("#")
  138. for i, e in pairs(qcQuestCategories) do
  139. if (e[1] == categoryId) then
  140. qcQuestCompletistUI.qcSelectedCategory:SetText(e[2])
  141. break
  142. end
  143. end
  144. end
  145.  
  146. local function qcUpdateMutuallyExclusiveCompletedQuest(qcQuestID)
  147. if (qcMutuallyExclusive[qcQuestID]) then
  148. for qcMutuallyExclusiveIndex, qcMutuallyExclusiveEntry in pairs(qcMutuallyExclusive[qcQuestID]) do
  149. if (qcQuestDatabase[qcMutuallyExclusiveEntry]) then
  150. qcCompletedQuests[qcMutuallyExclusiveEntry] = {["C"]=1}
  151. end
  152. end
  153. end
  154. end
  155.  
  156. local function qcUpdateSkippedBreadcrumbQuest(qcQuestID)
  157. if (qcBreadcrumbQuests[qcQuestID]) then
  158. for qcBreadcrumbIndex, qcBreadcrumbEntry in pairs(qcBreadcrumbQuests[qcQuestID]) do
  159. if (qcQuestDatabase[qcBreadcrumbEntry]) then
  160. qcCompletedQuests[qcBreadcrumbEntry] = {["C"]=1}
  161. end
  162. end
  163. end
  164. end
  165.  
  166. local function qcGetSearchQuests(searchText)
  167. local tableInsert = table.insert
  168. local stringUpper = string.upper
  169. local stringFind = string.find
  170. wipe(qcSearchQuests) -- TODO: Where is this table, and we dont seem to be returning it correctly.
  171. local holdingTable = {}
  172. for qcIndex, qcEntry in pairs(qcQuestDatabase) do
  173. if (stringFind(stringUpper(qcEntry[2]),searchText,1,true)) then
  174. tableInsert(holdingTable,qcEntry)
  175. end
  176. end
  177. qcSearchQuests = qcCopyTable(holdingTable)
  178. end
  179.  
  180. local function qcGetCategoryQuests(categoryId, searchText) -- *
  181. local tableInsert = table.insert
  182. local stringUpper = string.upper
  183. local tableSort = table.sort
  184. local holdingTable = {}
  185. wipe(qcCategoryQuests)
  186. if (searchText) then
  187. local stringfind = string.find
  188. for i, e in pairs(qcQuestDatabase) do
  189. if (stringfind(stringUpper(e[2]),searchText,1,true)) then
  190. tableInsert(holdingTable,e)
  191. end
  192. end
  193. qcCategoryQuests = qcCopyTable(holdingTable)
  194. return nil
  195. end
  196. local tableRemove = table.remove
  197. local BitBand = bit.band
  198. for i, e in pairs(qcQuestDatabase) do
  199. if (e[5] == categoryId) then
  200. tableInsert(holdingTable,e)
  201. end
  202. end
  203. qcCategoryQuests = qcCopyTable(holdingTable)
  204. if (qcSettings.QC_L_HIDE_COMPLETED == 1) then
  205. for i = #qcCategoryQuests, 1, -1 do
  206. if (qcCompletedQuests[qcCategoryQuests[i][1]]) then
  207. if (qcCompletedQuests[qcCategoryQuests[i][1]]["C"] == 1) or (qcCompletedQuests[qcCategoryQuests[i][1]]["C"] == 2) then
  208. tableRemove(qcCategoryQuests,i)
  209. end
  210. end
  211. end
  212. end
  213. if (qcSettings.QC_ML_HIDE_FACTION == 1) then
  214. local playerFaction, _ = UnitFactionGroup("player")
  215. local factionFlag = qcFactionBits[stringUpper(playerFaction)]
  216. for i = #qcCategoryQuests, 1, -1 do
  217. if (BitBand(qcCategoryQuests[i][7], factionFlag) == 0) then
  218. tableRemove(qcCategoryQuests,i)
  219. end
  220. end
  221. end
  222. if (qcSettings.QC_ML_HIDE_RACECLASS == 1) then
  223. local _, playerRace = UnitRace("player")
  224. local raceFlag = qcRaceBits[stringUpper(playerRace)]
  225. local _, playerClass = UnitClass("player")
  226. local classFlag = qcClassBits[stringUpper(playerClass)]
  227. for i = #qcCategoryQuests, 1, -1 do
  228. if ((BitBand(qcCategoryQuests[i][8], raceFlag) == 0) or (BitBand(qcCategoryQuests[i][9], classFlag) == 0)) then
  229. tableRemove(qcCategoryQuests,i)
  230. end
  231. end
  232. end
  233. if (qcSettings.SORT == 1) then
  234. tableSort(qcCategoryQuests,function(a,b) return (a[3]<b[3] or (a[3] == b[3] and a[2]<b[2])) end)
  235. elseif (qcSettings.SORT == 2) then
  236. tableSort(qcCategoryQuests,function(a,b) return a[2]<b[2] end)
  237. else
  238. tableSort(qcCategoryQuests,function(a,b) return (a[3]<b[3] or (a[3] == b[3] and a[2]<b[2])) end)
  239. end
  240. end
  241.  
  242. function qcUpdateQuestList(categoryId, startIndex, searchText) -- *
  243. if not (qcQuestCompletistUI:IsVisible()) then return nil end
  244. local stringFormat = string.format
  245. if (categoryId) then
  246. qcQuestCompletistUI.qcSearchBox:SetText("")
  247. qcCurrentCategoryID = categoryId
  248. qcUpdateCurrentCategoryText(categoryId)
  249. qcGetCategoryQuests(categoryId)
  250. qcCurrentCategoryQuestCount = (#qcCategoryQuests)
  251. if (qcCurrentCategoryQuestCount < 16) then
  252. qcMenuSlider:SetMinMaxValues(1, 1)
  253. else
  254. qcMenuSlider:SetMinMaxValues(1, qcCurrentCategoryQuestCount - 15)
  255. end
  256. qcMenuSlider:SetValue(startIndex)
  257. else
  258. if (searchText) then
  259. qcGetCategoryQuests(nil, searchText)
  260. qcCurrentCategoryQuestCount = (#qcCategoryQuests)
  261. qcQuestCompletistUI.qcSelectedCategory:SetText("Search Results")
  262. if (qcCurrentCategoryQuestCount < 16) then
  263. qcMenuSlider:SetMinMaxValues(1, 1)
  264. else
  265. qcMenuSlider:SetMinMaxValues(1, qcCurrentCategoryQuestCount - 15)
  266. end
  267. qcMenuSlider:SetValue(startIndex)
  268. end
  269. end
  270. qcQuestCompletistUI.qcCurrentCategoryQuestCount:SetText(stringFormat("%d Quests Found",qcCurrentCategoryQuestCount))
  271. for i = 1, 16 do
  272. local offset = ((i + startIndex) - 1)
  273. local questRecord = _G["qcMenuButton" .. i]
  274. if (qcCurrentCategoryQuestCount >= offset) then
  275. local e = qcCategoryQuests[offset]
  276. local questId = e[1]
  277. local questType = e[6]
  278. local questFaction = e[7]
  279. questRecord.QuestName:SetText(stringFormat("[%d] %s",e[3],e[2]))
  280. questRecord.QuestID = questId
  281. -- TODO: Possible to reduce code with call to _G[]?
  282. if (questType == 1) then
  283. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  284. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  285. elseif (questType == 2) then
  286. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_REPEATABLE))
  287. questRecord.QuestName:SetTextColor(0.0941176470588235, 0.6274509803921569, 0.9411764705882353, 1.0)
  288. elseif (questType == 3) then
  289. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_DAILY))
  290. questRecord.QuestName:SetTextColor(0.0941176470588235, 0.6274509803921569, 0.9411764705882353, 1.0)
  291. elseif (questType == 4) then
  292. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_SPECIAL))
  293. questRecord.QuestName:SetTextColor(1.0, 0.6156862745098039, 0.0862745098039216, 1.0)
  294. elseif (questType == 5) then
  295. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  296. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  297. elseif (questType == 6) then
  298. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_PROFESSION))
  299. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  300. elseif (questType == 7) then
  301. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_SEASONAL))
  302. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  303. elseif (questType == 11) then
  304. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_WORLDQUEST))
  305. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  306. else
  307. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  308. questRecord.QuestName:SetTextColor(1.0, 1.0, 1.0, 1.0)
  309. end
  310. questRecord.QuestIcon:Show()
  311. if ((questFaction == 0) or (questFaction == 3)) then
  312. questRecord.FactionIcon:Hide()
  313. elseif (questFaction == 1) then
  314. questRecord.FactionIcon:SetTexture("Interface\\Addons\\QuestCompletist\\Images\\AllianceIcon")
  315. questRecord.FactionIcon:Show()
  316. elseif(questFaction == 2) then
  317. questRecord.FactionIcon:SetTexture("Interface\\Addons\\QuestCompletist\\Images\\HordeIcon")
  318. questRecord.FactionIcon:Show()
  319. else
  320. questRecord.FactionIcon:Hide()
  321. end
  322. if not (GetQuestLogIndexByID(questId) == 0) then
  323. local isComplete
  324. _, _, _, _, _, isComplete, _, _, _ = GetQuestLogTitle(GetQuestLogIndexByID(questId)) -- TODO: Still same return?
  325. if (isComplete == nil) then
  326. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_PROGRESS))
  327. questRecord.QuestName:SetTextColor(0.5803921568627451, 0.5882352941176471, 0.5803921568627451, 1.0)
  328. elseif (isComplete == 1) then
  329. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_READY))
  330. questRecord.QuestName:SetTextColor(1.0, 0.8196078431372549, 0.0, 1.0)
  331. elseif (isComplete == -1) then
  332. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  333. questRecord.QuestName:SetTextColor(0.9372549019607843, 0.1490196078431373, 0.0627450980392157, 1.0)
  334. end
  335. end
  336. if (qcCompletedQuests[questId]) then
  337. if not ((questType == 2) or (questType == 3)) then
  338. if (qcCompletedQuests[questId]["C"] == 1) then
  339. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_COMPLETE))
  340. questRecord.QuestName:SetTextColor(0.0, 1.0, 0.0, 1.0)
  341. elseif (qcCompletedQuests[questId]["C"] == 2) then
  342. questRecord.QuestIcon:SetTexCoord(unpack(QC_ICON_COORDS_UNATTAINABLE))
  343. questRecord.QuestName:SetTextColor(0.77, 0.12, 0.23, 1.0)
  344. end
  345. end
  346. end
  347. questRecord:Show()
  348. questRecord:Enable()
  349. else
  350. questRecord.QuestName:SetText("#")
  351. questRecord:Hide()
  352. questRecord:Disable()
  353. end
  354. end
  355. end
  356.  
  357. function qcSearchBox_OnEditFocusLost(self) -- *
  358. searchText = string.upper(self:GetText())
  359. if not (searchText == "") then
  360. qcUpdateQuestList(nil, 1, searchText)
  361. else
  362. qcUpdateQuestList(qcCurrentCategoryID, 1)
  363. end
  364. end
  365.  
  366. function qcSearchBox_OnTextChanged(self, userInput) -- *
  367. if (userInput == true) then
  368. searchText = string.upper(self:GetText())
  369. if not (searchText == "") then
  370. qcUpdateQuestList(nil, 1, searchText)
  371. else
  372. qcUpdateQuestList(qcCurrentCategoryID, 1)
  373. end
  374. end
  375. end
  376.  
  377. function qcScrollUpdate(value) -- *
  378. if not (qcCurrentScrollPosition == value) then
  379. qcCurrentScrollPosition = value
  380. qcUpdateQuestList(nil, value)
  381. end
  382. end
  383.  
  384. function qcQueryQuestFlaggedComplete()
  385.  
  386. local qcChecked = 0
  387. local qcNewFlagged = 0
  388.  
  389. for qcIndex, qcEntry in pairs(qcQuestDatabase) do
  390. qcChecked = (qcChecked + 1)
  391. if (IsQuestFlaggedCompleted(qcIndex)) then
  392. if not (qcQuestDatabase[qcIndex][6] == 2) or (qcQuestDatabase[qcIndex][6] == 3) then
  393. if (qcCompletedQuests[qcIndex] == nil) then
  394. qcNewFlagged = (qcNewFlagged + 1)
  395. end
  396. qcCompletedQuests[qcIndex] = {["C"]=1}
  397. qcUpdateMutuallyExclusiveCompletedQuest(qcIndex)
  398. qcUpdateSkippedBreadcrumbQuest(qcIndex)
  399. end
  400. end
  401. end
  402.  
  403. if (qcNewFlagged > 0) then
  404. print(string.format("%s%d quests where checked, and %d previously completed quest(s) have now been updated as such.",QCADDON_CHAT_TITLE,qcChecked,qcNewFlagged))
  405. qcUpdateQuestList(nil,qcMenuSlider:GetValue())
  406. end
  407.  
  408. end
  409.  
  410. local function qcQuestQueryCompleted()
  411.  
  412. local qcCountReturned = 0
  413. local qcNewFlagged = 0
  414. local qcCompletedTable = {}
  415.  
  416. GetQuestsCompleted(qcCompletedTable)
  417.  
  418. for qcIndex, qcEntry in pairs(qcCompletedTable) do
  419. qcCountReturned = (qcCountReturned + 1)
  420. if not (qcQuestDatabase[qcIndex] == nil) then
  421. if not (qcQuestDatabase[qcIndex][6] == 2) or (qcQuestDatabase[qcIndex][6] == 3) then
  422. if (qcCompletedQuests[qcIndex] == nil) then
  423. qcNewFlagged = (qcNewFlagged + 1)
  424. end
  425. qcCompletedQuests[qcIndex] = {["C"]=1}
  426. qcUpdateMutuallyExclusiveCompletedQuest(qcIndex)
  427. qcUpdateSkippedBreadcrumbQuest(qcIndex)
  428. end
  429. end
  430. end
  431.  
  432. if (qcCountReturned == 0) then
  433. print(string.format("%sNo quests were returned from the server query. Attempting to check each quest individually...",QCADDON_CHAT_TITLE))
  434. qcQueryQuestFlaggedComplete()
  435. end
  436. if (qcNewFlagged > 0) then
  437. print(string.format("%s%d previously completed quest(s) have now been updated as such.",QCADDON_CHAT_TITLE,qcNewFlagged))
  438. qcUpdateQuestList(nil,qcMenuSlider:GetValue())
  439. end
  440.  
  441. print(string.format("%sQuery completed.",QCADDON_CHAT_TITLE))
  442.  
  443. end
  444.  
  445. local function qcClearUpdateCache()
  446. wipe(qcCompletedQuests)
  447. print(string.format("%sCache Cleared.",QCADDON_CHAT_TITLE))
  448. end
  449.  
  450. local function qcPurgeCollectedCache()
  451. if (qcCollectedQuests == nil) then qcCollectedQuests = {} end
  452. if (qcProgressComplete == nil) then qcProgressComplete = {} end
  453. wipe(qcCollectedQuests)
  454. wipe(qcProgressComplete)
  455. print(string.format("%sCollected Cache Purged.",QCADDON_CHAT_TITLE))
  456. end
  457.  
  458. function qcMenuMouseWheel(self, delta) -- *
  459. local position = qcMenuSlider:GetValue()
  460. if (delta < 0) and (position < qcCurrentCategoryQuestCount) then
  461. qcMenuSlider:SetValue(position + 2)
  462. elseif (delta > 0) and (position > 1) then
  463. qcMenuSlider:SetValue(position - 2)
  464. end
  465. end
  466.  
  467. function qcProcessMenuAction(button, arg1)
  468.  
  469. if (arg1 == "PERFORMSERVERQUERY") then
  470. print(string.format("%s%s",QCADDON_CHAT_TITLE,qcL.QUERYREQUESTED))
  471. qcQuestQueryCompleted()
  472. CloseDropDownMenus()
  473. elseif (arg1 == "CLEARUPDATECACHE") then
  474. print(string.format("%s%s",QCADDON_CHAT_TITLE,"Clearing your update Cache..."))
  475. qcClearUpdateCache()
  476. CloseDropDownMenus()
  477. elseif (arg1 == "SORTLEVEL") then
  478. qcSettings.SORT = 1
  479. qcQuestCompletistUI.qcSearchBox:SetText("")
  480. qcUpdateQuestList(qcCurrentCategoryID, qcMenuSlider:GetValue())
  481. CloseDropDownMenus()
  482. elseif (arg1 == "SORTALPHA") then
  483. qcSettings.SORT = 2
  484. qcQuestCompletistUI.qcSearchBox:SetText("")
  485. qcUpdateQuestList(qcCurrentCategoryID, qcMenuSlider:GetValue())
  486. CloseDropDownMenus()
  487. end
  488.  
  489. end
  490.  
  491. function qcProcessMenuSelection(self, arg1)
  492. qcQuestCompletistUI.qcSearchBox:SetText("");
  493. qcUpdateQuestList(arg1,1);
  494. CloseDropDownMenus();
  495. end
  496.  
  497. function qcCategoryDropdown_Initialize(self, level, menuList)
  498.  
  499. local stringformat = string.format
  500. local qcMenuData = {}
  501.  
  502. if (level == 1) then
  503. for qcMenuIndex, qcMenuEntry in ipairs(qcCategoryMenu) do
  504. if (qcMenuEntry[3]) then
  505. qcMenuData = {text=stringformat(" %s",qcMenuEntry[2]),isTitle=false,notCheckable=true,hasArrow=true,value=qcMenuEntry[1]}
  506. else
  507. qcMenuData = {text=qcMenuEntry[2],isTitle=true,notCheckable=true,hasArrow=false}
  508. end
  509. UIDropDownMenu_AddButton(qcMenuData, level)
  510. end
  511. elseif (level == 2) then
  512. local qcParentValue = UIDROPDOWNMENU_MENU_VALUE
  513. for qcMenuIndex, qcMenuEntry in ipairs(qcCategoryMenu) do
  514. if (qcMenuEntry[1] == qcParentValue) then
  515. for qcSubmenuIndex, qcSubmenuEntry in ipairs(qcMenuEntry[3]) do
  516. if (qcSubmenuEntry[3]) then
  517. qcMenuData = {text=stringformat(" %s",qcSubmenuEntry[2]),isTitle=false,notCheckable=true,hasArrow=true,value=qcSubmenuEntry[1]}
  518. else
  519. if (tonumber(qcSubmenuEntry[1])) then
  520. qcMenuData = {text=qcSubmenuEntry[2],isTitle=false,notCheckable=false,hasArrow=false,value=qcSubmenuEntry[1],arg1=qcSubmenuEntry[1],func=function(button,arg1) qcQuestCompletistUI.qcSearchBox:SetText("");qcUpdateQuestList(arg1,1);CloseDropDownMenus();end}
  521. else
  522. qcMenuData = {text=qcSubmenuEntry[2],isTitle=false,notCheckable=false,hasArrow=false,value=qcSubmenuEntry[1],arg1=qcSubmenuEntry[1],func=function(button,arg1) qcProcessMenuAction(button,arg1);end}
  523. end
  524. end
  525. UIDropDownMenu_AddButton(qcMenuData, level)
  526. end
  527. break
  528. end
  529. end
  530. elseif (level == 3) then
  531. local qcParentValue = UIDROPDOWNMENU_MENU_VALUE
  532. for qcMenuIndex, qcMenuEntry in ipairs(qcCategoryMenu) do
  533. if (qcMenuEntry[3]) then
  534. for qcSubmenuIndex, qcSubmenuEntry in ipairs(qcMenuEntry[3]) do
  535. if (qcSubmenuEntry[1] == qcParentValue) then
  536. if (tonumber(qcSubmenuEntry[1])) then
  537. qcMenuData = {text=qcSubmenuEntry[2],isTitle=false,notCheckable=false,hasArrow=false,value=qcSubmenuEntry[1],arg1=qcSubmenuEntry[1],func=function(button,arg1) qcQuestCompletistUI.qcSearchBox:SetText("");qcUpdateQuestList(arg1,1);CloseDropDownMenus();end}
  538. else
  539. qcMenuData = {text=qcSubmenuEntry[2],isTitle=false,notCheckable=false,hasArrow=false,value=qcSubmenuEntry[1],arg1=qcSubmenuEntry[1],func=function(button,arg1) qcProcessMenuAction(button,arg1);end}
  540. end
  541. UIDropDownMenu_AddButton(qcMenuData, level)
  542. end
  543. break
  544. end
  545. else
  546. qcMenuData = {text=qcMenuEntry[2],isTitle=true,notCheckable=true,hasArrow=false}
  547. end
  548. end
  549. end
  550.  
  551. end
  552.  
  553. function qcCategoryDropdownButton_OnClick(self, button, down) -- *
  554. EasyMenu(qcMenu, qcCategoryDropDownMenu, self:GetName(), 0, 0, nil)
  555. end
  556.  
  557. function qcCategoryDropdown_OnLoad(self) -- TODO: Is this even needed anymore?
  558. UIDropDownMenu_Initialize(self, qcCategoryDropdown_Initialize)
  559. end
  560.  
  561. local function qcZoneChangedNewArea() -- *
  562. -- SetMapToCurrentZone()
  563. local id = C_Map.GetBestMapForUnit("player")
  564. if (qcAreaIDToCategoryID[id]) then
  565. qcCurrentCategoryID = qcAreaIDToCategoryID[id]
  566. qcUpdateQuestList(qcCurrentCategoryID,1)
  567. end
  568. end
  569.  
  570. function qcUpdateTooltip(index)
  571. local stringFormat = string.format
  572. local questId = _G["qcMenuButton" .. index].QuestID
  573.  
  574. if not (questId == nil) then
  575. qcQuestInformationTooltip:SetOwner(qcQuestCompletistUI,"ANCHOR_BOTTOMRIGHT",-30,500)
  576. qcQuestInformationTooltip:ClearLines()
  577. qcQuestInformationTooltip:SetHyperlink(stringFormat("quest:%d",questId))
  578. qcQuestInformationTooltip:AddLine(" ")
  579. qcQuestInformationTooltip:AddDoubleLine("Quest ID:", stringFormat("|cFF69CCF0%d|r",questId))
  580. if not (qcQuestDatabase[questId][13] == nil) then
  581. for qcInitiatorIndex, qcInitiatorEntry in pairs(qcQuestDatabase[questId][13]) do
  582. local qcInitiatorID = qcInitiatorEntry[1]
  583. local qcInitiatorName = qcInitiatorEntry[2]
  584. local qcInitiatorMapID = qcInitiatorEntry[3]
  585. local qcInitiatorMapLevel = qcInitiatorEntry[4]
  586. local qcInitiatorX = qcInitiatorEntry[5]
  587. local qcInitiatorY = qcInitiatorEntry[6]
  588. if not (qcInitiatorID == 0) then
  589. if not (qcInitiatorName == nil) then
  590. qcQuestInformationTooltip:AddDoubleLine("Quest Giver:", stringFormat("%s%s [%d]",COLOUR_HUNTER,qcInitiatorName,qcInitiatorID))
  591. else
  592. qcQuestInformationTooltip:AddDoubleLine("Quest Giver:", stringFormat("%s%s [%d]",COLOUR_HUNTER,"Self-provided Quest",qcInitiatorID))
  593. end
  594. else
  595. if not (qcInitiatorName == nil) then
  596. qcQuestInformationTooltip:AddDoubleLine("Quest Giver:", stringFormat("%s%s",COLOUR_HUNTER,qcInitiatorName))
  597. else
  598. qcQuestInformationTooltip:AddDoubleLine("Quest Giver:", stringFormat("%s%s",COLOUR_HUNTER,"Self-provided Quest"))
  599. end
  600. end
  601. if not (qcInitiatorMapLevel == 0) then
  602. qcQuestInformationTooltip:AddDoubleLine(" - Location:", stringFormat("%s%s, Floor %d @ %.1f,%.1f",COLOUR_HUNTER,tostring(C_Map.GetMapInfo(qcInitiatorMapID) or nil),qcInitiatorMapLevel,qcInitiatorX,qcInitiatorY),nil,nil,nil,true)
  603. else
  604. qcQuestInformationTooltip:AddDoubleLine(" - Location:", stringFormat("%s%s @ %.1f,%.1f",COLOUR_HUNTER,tostring(C_Map.GetMapInfo(qcInitiatorMapID) or nil),qcInitiatorX,qcInitiatorY),nil,nil,nil,true)
  605. end
  606. end
  607. end
  608. qcQuestInformationTooltip:Show()
  609. qcQuestReputationTooltip:SetOwner(qcQuestInformationTooltip,"ANCHOR_BOTTOMRIGHT",-qcQuestInformationTooltip:GetWidth())
  610. qcQuestReputationTooltip:ClearLines()
  611. if not (qcQuestDatabase[questId][12] == nil) then
  612. qcReputationCount = 0
  613. qcQuestReputationTooltip:AddLine(GetText("COMBAT_TEXT_SHOW_REPUTATION_TEXT"))
  614. qcQuestReputationTooltip:AddLine(" ")
  615. for qcReputationIndex, qcReputationEntry in pairs(qcQuestDatabase[questId][12]) do
  616. qcReputationCount = (qcReputationCount+1)
  617. qcQuestReputationTooltip:AddDoubleLine(tostring(qcFactions[qcReputationIndex] or qcReputationIndex), stringFormat("%s%d rep",COLOUR_DRUID,qcReputationEntry))
  618. end
  619. if (qcReputationCount > 0) then
  620. qcQuestReputationTooltip:Show()
  621. else
  622. qcQuestReputationTooltip:Hide()
  623. end
  624. end
  625. else
  626. qcQuestReputationTooltip:Hide()
  627. end
  628.  
  629. end
  630.  
  631. function qcQuestClick(qcButtonIndex)
  632. local qcQuestID = _G["qcMenuButton" .. qcButtonIndex].QuestID
  633. if (IsLeftShiftKeyDown()) then --[[ User wants to toggle the completed status of a quest ]]--
  634. --print(string.format("%sLeft shift key is down",QCADDON_CHAT_TITLE))
  635. if (qcCompletedQuests[qcQuestID] == nil) then
  636. qcCompletedQuests[qcQuestID] = {["C"] = 1}
  637. else
  638. if (qcCompletedQuests[qcQuestID]["C"] == nil) then
  639. qcCompletedQuests[qcQuestID]["C"] = 1
  640. else
  641. if (qcCompletedQuests[qcQuestID]["C"] == 1) then
  642. qcCompletedQuests[qcQuestID]["C"] = 0
  643. elseif (qcCompletedQuests[qcQuestID]["C"] == 0) then
  644. qcCompletedQuests[qcQuestID]["C"] = 1
  645. elseif (qcCompletedQuests[qcQuestID]["C"] == 2) then
  646. qcCompletedQuests[qcQuestID]["C"] = 1
  647. end
  648. end
  649. end
  650. elseif (IsLeftAltKeyDown()) then --[[ User wants to toggle the unattainable status of a quest ]]--
  651. --print(string.format("%sLeft alt key is down",QCADDON_CHAT_TITLE))
  652. if (qcCompletedQuests[qcQuestID] == nil) then
  653. qcCompletedQuests[qcQuestID] = {["C"] = 2}
  654. else
  655. if (qcCompletedQuests[qcQuestID]["C"] == nil) then
  656. qcCompletedQuests[qcQuestID]["C"] = 2
  657. else
  658. if (qcCompletedQuests[qcQuestID]["C"] == 2) then
  659. qcCompletedQuests[qcQuestID]["C"] = 0
  660. elseif (qcCompletedQuests[qcQuestID]["C"] == 0) then
  661. qcCompletedQuests[qcQuestID]["C"] = 2
  662. elseif (qcCompletedQuests[qcQuestID]["C"] == 1) then
  663. qcCompletedQuests[qcQuestID]["C"] = 2
  664. end
  665. end
  666. end
  667. else
  668. --print(string.format("%sLooking for Tom Tom.",QCADDON_CHAT_TITLE))
  669. if (IsAddOnLoaded('TomTom')) then
  670. --print(string.format("%sLooking for quest in db.",QCADDON_CHAT_TITLE))
  671. for qcMapIndex, qcMapEntry in pairs(qcPinDB) do
  672. for qcInitiatorIndex, qcInitiatorEntry in pairs(qcPinDB[qcMapIndex]) do
  673. for qcInitiatorQuestIndex, qcInitiatorQuestEntry in pairs(qcPinDB[qcMapIndex][qcInitiatorIndex][7]) do
  674. if (qcInitiatorQuestEntry == qcQuestID) then
  675. --print(string.format("%sFound quest. Initiator: %s",QCADDON_CHAT_TITLE, qcInitiatorEntry[4]))
  676. TomTom:AddMFWaypoint(qcMapIndex, 0, qcInitiatorEntry[5]/100, qcInitiatorEntry[6]/100, {title=qcInitiatorEntry[4]})
  677. break
  678. end
  679. end
  680. end
  681. end
  682. TomTom:SetClosestWaypoint()
  683. end
  684. end
  685.  
  686. --print(string.format("%sUpdating quest list",QCADDON_CHAT_TITLE))
  687. qcUpdateQuestList(nil, qcMenuSlider:GetValue())
  688.  
  689. end
  690.  
  691. function qcFilterButton_OnClick(self, button, down) -- *
  692. InterfaceOptionsFrame_OpenToCategory(qcInterfaceOptions)
  693. InterfaceOptionsFrame_OpenToCategory(qcInterfaceOptions)
  694. end
  695.  
  696. function qcCloseTooltip()
  697. qcQuestInformationTooltip:Hide()
  698. qcQuestReputationTooltip:Hide()
  699. end
  700.  
  701. local function qcUpdateCompletedQuest(questId) -- *
  702. if (qcQuestDatabase[questId]) then
  703. if ((qcQuestDatabase[questId][6] == 2) or (qcQuestDatabase[questId][6] == 3)) then
  704. return nil
  705. end
  706. end
  707. if not (qcCompletedQuests[questId]) then qcCompletedQuests[questId] = {["C"]=1} end
  708. end
  709.  
  710. local function qcNewDataChecks(questId) -- *
  711. if ((questId == nil) or (questId == 0)) then return nil end
  712. if not (qcQuestDatabase[questId]) then
  713. qcNewDataAlert.New = true
  714. qcNewDataAlert.Faction = false
  715. qcNewDataAlert.Race = false
  716. qcNewDataAlert.Class = false
  717. qcNewDataAlert:Show()
  718. else
  719. qcNewDataAlert:Hide()
  720. qcNewDataAlert.New = false
  721. qcNewDataAlert.Faction = false
  722. qcNewDataAlert.Race = false
  723. qcNewDataAlert.Class = false
  724. local factionFlag, raceFlag, classFlag = 0, 0, 0
  725. local playerFaction, _ = UnitFactionGroup("player")
  726. local _, playerRace = UnitRace("player")
  727. local _, playerClass = UnitClass("player")
  728. factionFlag = qcFactionBits[string.upper(playerFaction)]
  729. if (bit.band(factionFlag,qcQuestDatabase[questId][7]) == 0) then
  730. qcNewDataAlert.Faction = true
  731. end
  732. raceFlag = qcRaceBits[string.upper(playerRace)]
  733. if (bit.band(raceFlag,qcQuestDatabase[questId][8]) == 0) then
  734. qcNewDataAlert.Race = true
  735. end
  736. classFlag = qcClassBits[string.upper(playerClass)]
  737. if (bit.band(classFlag,qcQuestDatabase[questId][9]) == 0) then
  738. qcNewDataAlert.Class = true
  739. end
  740. if ((qcNewDataAlert.Faction) or (qcNewDataAlert.Race) or (qcNewDataAlert.Class)) then
  741. qcNewDataAlert:Show()
  742. end
  743. end
  744. end
  745.  
  746. function qcNewDataAlert_OnEnter(self) -- *
  747. qcNewDataAlertTooltip:SetOwner(qcNewDataAlert, "ANCHOR_CURSOR")
  748. qcNewDataAlertTooltip:ClearLines()
  749. qcNewDataAlertTooltip:AddLine("Quest Completist")
  750. qcNewDataAlertTooltip:AddLine(COLOUR_HUNTER .. "Quest Completist was not aware of the following information. Please help improve the accuracy of the addon by contributing with the Community Editor! (Link on Curse)", nil, nil, nil, true)
  751. if (qcNewDataAlert.New) then
  752. qcNewDataAlertTooltip:AddLine(COLOUR_MAGE .. " - Quest does not exist in the database.", nil, nil, nil, true)
  753. qcNewDataAlertTooltip:Show()
  754. end
  755. if (qcNewDataAlert.Faction) then
  756. qcNewDataAlertTooltip:AddLine(COLOUR_MAGE .. " - QC was not aware your FACTION could complete this quest.", nil, nil, nil, true)
  757. end
  758. if (qcNewDataAlert.Race) then
  759. qcNewDataAlertTooltip:AddLine(COLOUR_MAGE .. " - QC was not aware your RACE could complete this quest.", nil, nil, nil, true)
  760. end
  761. if (qcNewDataAlert.Class) then
  762. qcNewDataAlertTooltip:AddLine(COLOUR_MAGE .. " - QC was not aware your CLASS could complete this quest.", nil, nil, nil, true)
  763. end
  764. if ((qcNewDataAlert.New) or (qcNewDataAlert.Faction) or (qcNewDataAlert.Race) or (qcNewDataAlert.Class)) then
  765. qcNewDataAlertTooltip:Show()
  766. end
  767. end
  768.  
  769. function qcNewDataAlert_OnLeave(self) -- *
  770. qcNewDataAlertTooltip:Hide()
  771. end
  772.  
  773. local function qcBreadcrumbChecks(qcQuestID)
  774.  
  775. if (qcQuestID == nil) or (qcQuestID == 0) then return nil end
  776.  
  777. if (qcBreadcrumbQuests[qcQuestID] == nil) then
  778. qcToast.QuestID = nil
  779. qcToast:Hide()
  780. else
  781. qcToast.QuestID = qcQuestID
  782. local qcCount = 0
  783. for qcBreadcrumbIndex, qcBreadcrumbEntry in pairs(qcBreadcrumbQuests[qcQuestID]) do
  784. if (qcCompletedQuests[qcBreadcrumbEntry] == nil) then
  785. qcCount = (qcCount + 1)
  786. else
  787. if not (qcCompletedQuests[qcBreadcrumbEntry]["C"] == 1) then
  788. qcCount = (qcCount + 1)
  789. end
  790. end
  791. end
  792. if (qcCount == 0) then
  793. qcToast.QuestID = nil
  794. qcToast:Hide()
  795. else
  796. if (qcCount == 1) then
  797. qcToastText:SetText("1 Breadcrumb Available!")
  798. else
  799. qcToastText:SetText(string.format("%d Breadcrumbs Available!",qcCount))
  800. end
  801. qcToast:Show()
  802. end
  803. end
  804.  
  805. end
  806.  
  807. local function qcMutuallyExclusiveChecks(qcQuestID)
  808.  
  809. if (qcQuestID == nil) or (qcQuestID == 0) then return nil end
  810.  
  811. if (qcMutuallyExclusive[qcQuestID] == nil) then
  812. qcMutuallyExclusiveAlert.QuestID = nil
  813. qcMutuallyExclusiveAlert:Hide()
  814. else
  815. qcMutuallyExclusiveAlert.QuestID = qcQuestID
  816. qcMutuallyExclusiveAlert:Show()
  817. end
  818.  
  819. end
  820.  
  821. function qcMapTooltipSetup() -- *
  822. qcMapTooltip = CreateFrame("GameTooltip", "qcMapTooltip", UIParent, "GameTooltipTemplate")
  823. qcMapTooltip:SetFrameStrata("TOOLTIP")
  824. WorldMapFrame:HookScript("OnSizeChanged",
  825. function(self)
  826. qcMapTooltip:SetScale(1/self:GetScale())
  827. end
  828. )
  829. end
  830.  
  831. function qcQuestReputationTooltipSetup() -- *
  832. qcQuestReputationTooltip = CreateFrame("GameTooltip", "qcQuestReputationTooltip", qcQuestCompletistUI, "GameTooltipTemplate")
  833. qcQuestReputationTooltip:SetFrameStrata("TOOLTIP")
  834. end
  835.  
  836. function qcQuestInformationTooltipSetup() -- *
  837. qcQuestInformationTooltip = CreateFrame("GameTooltip", "qcQuestInformationTooltip", qcQuestCompletistUI, "GameTooltipTemplate")
  838. qcQuestInformationTooltip:SetFrameStrata("TOOLTIP")
  839. end
  840.  
  841. function qcToastTooltipSetup() -- *
  842. qcToastTooltip = CreateFrame("GameTooltip", "qcToastTooltip", qcToast, "GameTooltipTemplate")
  843. qcToastTooltip:SetFrameStrata("TOOLTIP")
  844. end
  845.  
  846. function qcNewDataAlertTooltipSetup() -- *
  847. qcNewDataAlertTooltip = CreateFrame("GameTooltip", "qcNewDataAlertTooltip", qcNewDataAlert, "GameTooltipTemplate")
  848. qcNewDataAlertTooltip:SetFrameStrata("TOOLTIP")
  849. end
  850.  
  851. function qcMutuallyExclusiveAlertTooltipSetup() -- *
  852. qcMutuallyExclusiveAlertTooltip = CreateFrame("GameTooltip", "qcMutuallyExclusiveAlertTooltip", qcMutuallyExclusiveAlert, "GameTooltipTemplate")
  853. qcMutuallyExclusiveAlertTooltip:SetFrameStrata("TOOLTIP")
  854. end
  855.  
  856. function qcGetToastQuestInformation(questId) -- *
  857. if (questId) then
  858. if (qcQuestDatabase[questId]) then
  859. return tostring(qcQuestDatabase[questId][2] or nil)
  860. end
  861. end
  862. end
  863.  
  864. function qcToast_OnEnter(self)
  865.  
  866. if (self.QuestID == nil) then
  867. qcToastTooltip:Hide()
  868. else
  869. qcToastTooltip:SetOwner(qcToast, "ANCHOR_CURSOR")
  870. qcToastTooltip:ClearLines()
  871. qcToastTooltip:AddLine("Breadcrumb Quests")
  872. for qcBreadcrumbIndex, qcBreadcrumbEntry in pairs(qcBreadcrumbQuests[self.QuestID]) do
  873. if (qcCompletedQuests[qcBreadcrumbEntry] == nil) then
  874. local qcQuestName = qcGetToastQuestInformation(qcBreadcrumbEntry)
  875. if (qcQuestName and qcBreadcrumbEntry) then qcToastTooltip:AddLine(tostring(COLOUR_DRUID .. qcQuestName .. COLOUR_MAGE .. " [" .. qcBreadcrumbEntry .. "]")) end
  876. else
  877. if not (qcCompletedQuests[qcBreadcrumbEntry]["C"] == 1) then
  878. local qcQuestName = qcGetToastQuestInformation(qcBreadcrumbEntry)
  879. if (qcQuestName and qcBreadcrumbEntry) then qcToastTooltip:AddLine(tostring(COLOUR_DRUID .. qcQuestName .. " [" .. qcBreadcrumbEntry .. "]")) end
  880. end
  881. end
  882. end
  883. qcToastTooltip:Show()
  884. end
  885.  
  886. end
  887.  
  888. function qcToast_OnLeave(self) -- *
  889. qcToastTooltip:Hide()
  890. end
  891.  
  892. function qcMutuallyExclusiveQuestInformation(qcQuestID)
  893.  
  894. if (qcQuestID) then
  895. if (qcQuestDatabase[qcQuestID]) then
  896. local qcQuestName = tostring(qcQuestDatabase[qcQuestID][2] or nil)
  897. return qcQuestName
  898. end
  899. end
  900.  
  901. return nil
  902.  
  903. end
  904.  
  905. function qcMutuallyExclusiveAlert_OnEnter(self)
  906.  
  907. if (self.QuestID == nil) then
  908. qcMutuallyExclusiveAlertTooltip:Hide()
  909. else
  910. qcMutuallyExclusiveAlertTooltip:SetOwner(qcMutuallyExclusiveAlert, "ANCHOR_BOTTOMRIGHT")
  911. qcMutuallyExclusiveAlertTooltip:ClearLines()
  912. qcMutuallyExclusiveAlertTooltip:AddLine("Quest Completist")
  913. qcMutuallyExclusiveAlertTooltip:AddLine(COLOUR_MAGE .. "This quest is mutually exclusive with others, meaning you can only complete one of them. The other quests are:", nil, nil, nil, true)
  914. for qcMutuallyExclusiveIndex, qcMutuallyExclusiveEntry in pairs(qcMutuallyExclusive[self.QuestID]) do
  915. if (qcQuestDatabase[qcMutuallyExclusiveEntry] == nil) then
  916. qcMutuallyExclusiveAlertTooltip:AddLine(string.format("%s<Quest Not Found In DB> [%d]|r",COLOUR_DRUID,qcMutuallyExclusiveEntry))
  917. else
  918. local qcQuestName = qcMutuallyExclusiveQuestInformation(qcMutuallyExclusiveEntry)
  919. if (qcQuestName and qcMutuallyExclusiveEntry) then qcMutuallyExclusiveAlertTooltip:AddLine(string.format("%s%s [%d]|r",COLOUR_DRUID,qcQuestName,qcMutuallyExclusiveEntry)) end
  920. end
  921. end
  922. qcMutuallyExclusiveAlertTooltip:Show()
  923. end
  924. end
  925.  
  926. function qcMutuallyExclusiveAlert_OnLeave(self)
  927.  
  928. qcMutuallyExclusiveAlertTooltip:Hide()
  929.  
  930. end
  931.  
  932. --[[ ##### MAP PINS START ##### ]]--
  933.  
  934. local function qcColouredQuestName(questId)
  935. if not (questId) then return nil end
  936. if not (qcQuestDatabase[questId]) then return nil end
  937. if ((qcQuestDatabase[questId][6] == 3) or (qcQuestDatabase[questId][6] == 2)) then
  938. return string.format("|cff178ed5%s|r",qcQuestDatabase[questId][2])
  939. elseif (qcCompletedQuests[questId] == nil) then
  940. return string.format("|cffffffff%s|r",qcQuestDatabase[questId][2])
  941. elseif ((qcCompletedQuests[questId]["C"] == 1) or (qcCompletedQuests[questId]["C"] == 2)) then
  942. return string.format("|cff00ff00%s|r",qcQuestDatabase[questId][2])
  943. else
  944. return string.format("|cffffffff%s [U]|r",qcQuestDatabase[questId][2])
  945. end
  946. end
  947.  
  948. local function qcHideAllPins() -- *
  949. for i = #qcPinFrames, 1, -1 do
  950. qcPinFrames[i]:Hide()
  951. TableInsert(qcSparePinFrames, qcPinFrames[i])
  952. TableRemove(qcPinFrames,i)
  953. end
  954. end
  955.  
  956. local function qcGetPin()
  957. local pin = nil
  958. if (#qcSparePinFrames > 0) then
  959. pin = qcSparePinFrames[1]
  960. TableRemove(qcSparePinFrames, 1)
  961. end
  962. if not (pin) then
  963. pin = CreateFrame("Frame", "qcPin", WorldMapDetailFrame)
  964. pin:SetWidth(16)
  965. pin:SetHeight(16)
  966. pin.Texture = pin:CreateTexture()
  967. pin.Texture:SetTexture("Interface\\Addons\\QuestCompletist\\Images\\QCIcons")
  968. pin.Texture:SetAllPoints()
  969. pin:EnableMouse(true)
  970. pin:SetFrameStrata(WorldMapDetailFrame:GetFrameStrata()) -- ****
  971. pin:SetFrameLevel(WorldMapPOIFrame:GetFrameLevel() + 1)
  972. pin:HookScript("OnEnter",
  973. function(self, motion)
  974. local frames = {}
  975. local frame = EnumerateFrames()
  976. while (frame) do
  977. if (frame:IsVisible() and MouseIsOver(frame) and (frame:GetName() == "qcPin")) then
  978. TableInsert(frames, frame)
  979. end
  980. frame = EnumerateFrames(frame)
  981. end
  982. qcMapTooltip:SetParent(self)
  983. qcMapTooltip:SetOwner(self, "ANCHOR_RIGHT")
  984. qcMapTooltip:ClearLines()
  985. for i, e in pairs(frames) do -- TODO: Possible ipairs?
  986. local initiatorsIndex = e.PinIndex
  987. if (qcPins[initiatorsIndex][3] == 0) then
  988. qcMapTooltip:AddLine(qcPins[initiatorsIndex][4] or StringFormat("%s %s",UnitName("player"),"|cff69ccf0<Yourself>|r"))
  989. else
  990. qcMapTooltip:AddDoubleLine(qcPins[initiatorsIndex][4] or StringFormat("%s %s",UnitName("player"),"|cff69ccf0<Yourself>|r"), StringFormat("|cffff7d0a[%d]|r",qcPins[initiatorsIndex][3]))
  991. end
  992. for qcIndex, qcEntry in ipairs(qcPins[initiatorsIndex][7]) do
  993. qcMapTooltip:AddDoubleLine(tostring(qcColouredQuestName(qcEntry)), StringFormat("|cffff7d0a[%d]|r",tostring(qcEntry)))
  994. if (#qcPins[initiatorsIndex][7] <= 10) then
  995. --[[ Order by most likely first, always leaving completed until the end ]]--
  996. --[[ TODO: Create a texture object and use in-game texture with SetTexCoord ]]--
  997. if (qcQuestDatabase[qcEntry]) then
  998. if (qcQuestDatabase[qcEntry][6] == 3) then
  999. qcMapTooltip:AddTexture("Interface\\Addons\\QuestCompletist\\Images\\DailyQuestIcon")
  1000. elseif (qcQuestDatabase[qcEntry][6] == 2) then
  1001. qcMapTooltip:AddTexture("Interface\\Addons\\QuestCompletist\\Images\\DailyActiveQuestIcon")
  1002. elseif (qcCompletedQuests[qcEntry] ~= nil) and (qcCompletedQuests[qcEntry]["C"] == 1 or qcCompletedQuests[qcEntry]["C"] == 2) then
  1003. qcMapTooltip:AddTexture("Interface\\Addons\\QuestCompletist\\Images\\QuestCompleteIcon")
  1004. else
  1005. qcMapTooltip:AddTexture("Interface\\Addons\\QuestCompletist\\Images\\AvailableQuestIcon")
  1006. end
  1007. end
  1008. end
  1009. end
  1010. if (qcPins[initiatorsIndex][8]) then
  1011. qcMapTooltip:AddLine(StringFormat("|cffabd473%s|r",qcPins[initiatorsIndex][8]),nil,nil,nil,true)
  1012. end
  1013. end
  1014. qcMapTooltip:Show()
  1015. end
  1016. )
  1017. pin:HookScript("OnLeave",
  1018. function(self)
  1019. qcMapTooltip:Hide()
  1020. end
  1021. )
  1022. end
  1023. TableInsert(qcPinFrames, pin)
  1024. return pin
  1025. end
  1026.  
  1027. local function qcShowPin(index, icon) -- *
  1028. local pin = qcGetPin()
  1029. pin:SetPoint("CENTER", WorldMapDetailFrame, "TOPLEFT", (qcPins[index][5] / 100) * WorldMapDetailFrame:GetWidth(), (-qcPins[index][6] / 100) * WorldMapDetailFrame:GetHeight())
  1030. pin.PinIndex = index
  1031. if (icon == 1) then
  1032. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  1033. elseif (icon == 3) then
  1034. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_DAILY))
  1035. elseif (icon == 2) then
  1036. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_REPEATABLE))
  1037. elseif (icon == 5) then
  1038. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_SEASONAL))
  1039. elseif (icon == 4) then
  1040. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_SPECIAL))
  1041. elseif (icon == 6) then
  1042. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_PROFESSION))
  1043. elseif (icon == 7) then
  1044. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_ITEMDROPSTANDARD))
  1045. elseif (icon == 8) then
  1046. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_ITEMDROPREPEATABLE))
  1047. elseif (icon == 9) then
  1048. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_CLASS))
  1049. elseif (icon == 10) then
  1050. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_KILL))
  1051. elseif (icon == 11) then
  1052. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_WORLDQUEST))
  1053. else
  1054. pin.Texture:SetTexCoord(unpack(QC_ICON_COORDS_NORMAL))
  1055. end
  1056. pin:Show()
  1057. end
  1058.  
  1059. local function qcRefreshPins(mapId, mapLevel)
  1060. if not (WorldMapFrame:IsVisible()) then return nil end
  1061. qcHideAllPins()
  1062. wipe(qcPins)
  1063. if (qcSettings.QC_M_SHOW_ICONS == 0) or (qcPinDB[mapId] == nil) then
  1064. wipe(qcPins)
  1065. return nil
  1066. end
  1067. qcPins = qcCopyTable(qcPinDB[mapId])
  1068. for i = #qcPins, 1, -1 do
  1069. if not (qcPins[i][1] == mapLevel) then
  1070. TableRemove(qcPins,i)
  1071. end
  1072. end
  1073. if (qcSettings.QC_M_HIDE_LOWLEVEL == 1) then
  1074. for i = #qcPins, 1, -1 do
  1075. for questIndex = #qcPins[i][7], 1, -1 do
  1076. local questId = qcPins[i][7][questIndex]
  1077. if (qcQuestDatabase[questId]) then
  1078. local questLevel = qcQuestDatabase[questId][3] or 0
  1079. local greenCutoff = (UnitLevel("player") - GetQuestGreenRange())
  1080. if (questLevel < greenCutoff) then
  1081. TableRemove(qcPins[i][7],questIndex)
  1082. end
  1083. else
  1084. TableRemove(qcPins[i][7],questIndex)
  1085. end
  1086. end
  1087. if (#qcPins[i][7] == 0) then
  1088. TableRemove(qcPins, i)
  1089. end
  1090. end
  1091. end
  1092. if (qcSettings["QC_M_HIDE_COMPLETED"] == 1) then
  1093. for i = #qcPins, 1, -1 do
  1094. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1095. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1096. if (qcCompletedQuests[qcQuestID]) and ((qcCompletedQuests[qcQuestID]["C"] == 1) or (qcCompletedQuests[qcQuestID]["C"] == 2)) then
  1097. TableRemove(qcPins[i][7], qcQuestIndex)
  1098. end
  1099. end
  1100. if (#qcPins[i][7] == 0) then
  1101. TableRemove(qcPins, i)
  1102. end
  1103. end
  1104. end
  1105.  
  1106. --[[ Faction ]]--
  1107. if (qcSettings["QC_ML_HIDE_FACTION"] == 1) then
  1108. for i = #qcPins, 1, -1 do
  1109. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1110. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1111. local qcCurrentPlayerFaction, _S = UnitFactionGroup("player")
  1112. local qcCurrentFaction = qcFactionBits[string.upper(qcCurrentPlayerFaction)]
  1113. if (qcQuestDatabase[qcQuestID]) and (BitBand(qcQuestDatabase[qcQuestID][7], qcCurrentFaction) == 0) then
  1114. TableRemove(qcPins[i][7], qcQuestIndex)
  1115. end
  1116. end
  1117. if (#qcPins[i][7] == 0) then
  1118. TableRemove(qcPins, i)
  1119. end
  1120. end
  1121. end
  1122.  
  1123. --[[ Race\Class ]]--
  1124. if (qcSettings["QC_ML_HIDE_RACECLASS"] == 1) then
  1125. for i = #qcPins, 1, -1 do
  1126. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1127. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1128. local _S, qcCurrentPlayerRace = UnitRace("player")
  1129. local qcCurrentRace = qcRaceBits[string.upper(qcCurrentPlayerRace)]
  1130. local _S, qcCurrentPlayerClass = UnitClass("player")
  1131. local qcCurrentClass = qcClassBits[string.upper(qcCurrentPlayerClass)]
  1132. if (qcQuestDatabase[qcQuestID]) and (BitBand(qcQuestDatabase[qcQuestID][8], qcCurrentRace) == 0) then
  1133. TableRemove(qcPins[i][7], qcQuestIndex)
  1134. elseif (qcQuestDatabase[qcQuestID]) and (BitBand(qcQuestDatabase[qcQuestID][9], qcCurrentClass) == 0) then
  1135. TableRemove(qcPins[i][7], qcQuestIndex)
  1136. end
  1137. end
  1138. if (#qcPins[i][7] == 0) then
  1139. TableRemove(qcPins, i)
  1140. end
  1141. end
  1142. end
  1143.  
  1144. --[[ Seasonal ]]--
  1145. if (qcSettings["QC_M_HIDE_SEASONAL"] == 1) then
  1146. local qcToday = date("%y%m%d")
  1147. for i = #qcPins, 1, -1 do
  1148. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1149. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1150. if (qcQuestDatabase[qcQuestID]) and (qcQuestDatabase[qcQuestID][11] > 0) then
  1151. if not ((qcToday >= qcHolidayDates[qcQuestDatabase[qcQuestID][11]][1]) and (qcToday <= qcHolidayDates[qcQuestDatabase[qcQuestID][11]][2])) then
  1152. TableRemove(qcPins[i][7], qcQuestIndex)
  1153. end
  1154. end
  1155. end
  1156. if (#qcPins[i][7] == 0) then
  1157. TableRemove(qcPins, i)
  1158. end
  1159. end
  1160. end
  1161.  
  1162. --[[ Professions ]]--
  1163. if (qcSettings["QC_M_HIDE_PROFESSION"] == 1) then
  1164. local qcProfessionBitwise = 0
  1165. local qcProfessions = {GetProfessions()}
  1166. for qcIndex, qcEntry in pairs(qcProfessions) do
  1167. local qcName, qcTexture, _S, _S, _S, _S, qcProfessionID, _S = GetProfessionInfo(qcEntry)
  1168. qcProfessionBitwise = (qcProfessionBitwise + qcProfessionBits[qcProfessionID])
  1169. end
  1170. for i = #qcPins, 1, -1 do
  1171. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1172. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1173. if (qcQuestDatabase[qcQuestID]) and (qcQuestDatabase[qcQuestID][10] > 0) then
  1174. if (BitBand(qcQuestDatabase[qcQuestID][10], qcProfessionBitwise) == 0) then
  1175. TableRemove(qcPins[i][7], qcQuestIndex)
  1176. end
  1177. end
  1178. end
  1179. if (#qcPins[i][7] == 0) then
  1180. TableRemove(qcPins, i)
  1181. end
  1182. end
  1183. end
  1184.  
  1185. --[[WORLDQUEST ]]--
  1186. -- if (qcSettings["QC_ML_HIDE_WORLDQUEST"] == 1) then
  1187. -- for i = #qcPins, 1, -1 do
  1188. -- for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1189. -- local qcQuestID = qcPins[i][7][qcQuestIndex]
  1190. -- local _S, qcCurrentPlayerRace = UnitRace("player")
  1191. -- local qcCurrentRace = qcRaceBits[string.upper(qcCurrentPlayerRace)]
  1192. -- local _S, qcCurrentPlayerClass = UnitClass("player")
  1193. -- local qcCurrentClass = qcClassBits[string.upper(qcCurrentPlayerClass)]
  1194. -- if (qcQuestDatabase[qcQuestID]) and (BitBand(qcQuestDatabase[qcQuestID][8], qcCurrentRace) == 0) then
  1195. -- TableRemove(qcPins[i][7], qcQuestIndex)
  1196. -- elseif (qcQuestDatabase[qcQuestID]) and (BitBand(qcQuestDatabase[qcQuestID][9], qcCurrentClass) == 0) then
  1197. -- TableRemove(qcPins[i][7], qcQuestIndex)
  1198. -- end
  1199. -- end
  1200. -- if (#qcPins[i][7] == 0) then
  1201. -- TableRemove(qcPins, i)
  1202. -- end
  1203. -- end
  1204. -- end
  1205.  
  1206. --[[ In progress ]]--
  1207. if (qcSettings["QC_M_HIDE_INPROGRESS"] == 1) then
  1208. for i = #qcPins, 1, -1 do
  1209. for qcQuestIndex = #qcPins[i][7], 1, -1 do
  1210. local qcQuestID = qcPins[i][7][qcQuestIndex]
  1211. if (GetQuestLogIndexByID(qcQuestID) ~= 0) then
  1212. TableRemove(qcPins[i][7], qcQuestIndex)
  1213. end
  1214. end
  1215. if (#qcPins[i][7] == 0) then
  1216. TableRemove(qcPins, i)
  1217. end
  1218. end
  1219. end
  1220.  
  1221. --[[ Empty quest sub-tables ]]--
  1222. for i = #qcPins, 1, -1 do
  1223. if (#qcPins[i][7] == 0) then
  1224. TableRemove(qcPins, i)
  1225. end
  1226. end
  1227.  
  1228. --[[ Check if only 1 quest remains for each initiator, and customize icon for that final quest ]]--
  1229. for i = #qcPins, 1, -1 do
  1230. local qcIconType = qcPins[i][2]
  1231. if (#qcPins[i][7] == 1) then
  1232. local qcQuestID = qcPins[i][7][1]
  1233. if ((qcQuestDatabase[qcQuestID]) and (qcIconType == 1)) then
  1234. if (qcQuestDatabase[qcQuestID][6] == 1) then
  1235. qcIconType = 1
  1236. elseif (qcQuestDatabase[qcQuestID][6] == 3) then
  1237. qcIconType = 3
  1238. elseif (qcQuestDatabase[qcQuestID][6] == 2) then
  1239. qcIconType = 2
  1240. elseif (qcQuestDatabase[qcQuestID][6] == 4) then
  1241. qcIconType = 4
  1242. end
  1243. end
  1244. end
  1245. qcShowPin(i, qcIconType)
  1246. end
  1247.  
  1248. end
  1249.  
  1250. --[[ ##### MAP PINS END ##### ]]--
  1251.  
  1252. --[[ ##### INTERFACE OPTIONS START ##### ]]--
  1253.  
  1254. function qcInterfaceOptions_Okay(self) -- *
  1255. qcUpdateQuestList(qcCurrentCategoryID, 1)
  1256. qcRefreshPins(C_Map.GetBestMapForUnit("player"))
  1257. end
  1258.  
  1259. function qcInterfaceOptions_Cancel(self) -- *
  1260. end
  1261.  
  1262. function qcInterfaceOptions_OnShow(self)
  1263. local qcL = qcLocalize
  1264.  
  1265. qcConfigTitle = self:CreateFontString("qcConfigTitle", "ARTWORK", "GameFontNormalLarge")
  1266. qcConfigTitle:SetPoint("TOPLEFT", 16, -16)
  1267. qcConfigTitle:SetText(qcL.CONFIGTITLE)
  1268.  
  1269. qcConfigSubtitle = self:CreateFontString("qcConfigSubtitle", "ARTWORK", "GameFontHighlightSmall")
  1270. qcConfigSubtitle:SetHeight(22)
  1271. qcConfigSubtitle:SetPoint("TOPLEFT", qcConfigTitle, "BOTTOMLEFT", 0, -8)
  1272. qcConfigSubtitle:SetPoint("RIGHT", self, -32, 0)
  1273. qcConfigSubtitle:SetNonSpaceWrap(true)
  1274. qcConfigSubtitle:SetJustifyH("LEFT")
  1275. qcConfigSubtitle:SetJustifyV("TOP")
  1276. qcConfigSubtitle:SetText(qcL.CONFIGSUBTITLE)
  1277.  
  1278. qcMapFiltersTitle = self:CreateFontString("qcMapFiltersTitle", "ARTWORK", "GameFontNormal")
  1279. qcMapFiltersTitle:SetPoint("TOPLEFT", qcConfigSubtitle, "BOTTOMLEFT", 16, -4)
  1280. qcMapFiltersTitle:SetText(qcL.MAPFILTERS)
  1281.  
  1282. qcIO_M_SHOW_ICONS = CreateFrame("CheckButton", "qcIO_M_SHOW_ICONS", self, "InterfaceOptionsCheckButtonTemplate")
  1283. qcIO_M_SHOW_ICONS:SetPoint("TOPLEFT", qcMapFiltersTitle, "BOTTOMLEFT", 16, -6)
  1284. _G[qcIO_M_SHOW_ICONS:GetName().."Text"]:SetText(qcL.SHOWMAPICONS)
  1285. qcIO_M_SHOW_ICONS:SetScript("OnClick", function(self)
  1286. if (qcIO_M_SHOW_ICONS:GetChecked() == false) then
  1287. qcSettings.QC_M_SHOW_ICONS = 0
  1288. else
  1289. qcSettings.QC_M_SHOW_ICONS = 1
  1290. end
  1291. end)
  1292.  
  1293. qcIO_M_HIDE_COMPLETED = CreateFrame("CheckButton", "qcIO_M_HIDE_COMPLETED", self, "InterfaceOptionsCheckButtonTemplate")
  1294. qcIO_M_HIDE_COMPLETED:SetPoint("TOPLEFT", qcIO_M_SHOW_ICONS, "BOTTOMLEFT", 0, 0)
  1295. _G[qcIO_M_HIDE_COMPLETED:GetName().."Text"]:SetText(qcL.HIDECOMPLETEDQUESTS)
  1296. qcIO_M_HIDE_COMPLETED:SetScript("OnClick", function(self)
  1297. if (qcIO_M_HIDE_COMPLETED:GetChecked() == false) then
  1298. qcSettings.QC_M_HIDE_COMPLETED = 0
  1299. else
  1300. qcSettings.QC_M_HIDE_COMPLETED = 1
  1301. end
  1302. end)
  1303.  
  1304. qcIO_M_HIDE_LOWLEVEL = CreateFrame("CheckButton", "qcIO_M_HIDE_LOWLEVEL", self, "InterfaceOptionsCheckButtonTemplate")
  1305. qcIO_M_HIDE_LOWLEVEL:SetPoint("TOPLEFT", qcIO_M_HIDE_COMPLETED, "BOTTOMLEFT", 0, 0)
  1306. _G[qcIO_M_HIDE_LOWLEVEL:GetName().."Text"]:SetText(qcL.HIDELOWLEVELQUESTS)
  1307. qcIO_M_HIDE_LOWLEVEL:SetScript("OnClick", function(self)
  1308. if (qcIO_M_HIDE_LOWLEVEL:GetChecked() == false) then
  1309. qcSettings.QC_M_HIDE_LOWLEVEL = 0
  1310. else
  1311. qcSettings.QC_M_HIDE_LOWLEVEL = 1
  1312. end
  1313. end)
  1314.  
  1315. qcIO_M_HIDE_PROFESSION = CreateFrame("CheckButton", "qcIO_M_HIDE_PROFESSION", self, "InterfaceOptionsCheckButtonTemplate")
  1316. qcIO_M_HIDE_PROFESSION:SetPoint("TOPLEFT", qcIO_M_HIDE_LOWLEVEL, "BOTTOMLEFT", 0, 0)
  1317. _G[qcIO_M_HIDE_PROFESSION:GetName().."Text"]:SetText(qcL.HIDEOTHERPROFESSIONQUESTS)
  1318. qcIO_M_HIDE_PROFESSION:SetScript("OnClick", function(self)
  1319. if (qcIO_M_HIDE_PROFESSION:GetChecked() == false) then
  1320. qcSettings.QC_M_HIDE_PROFESSION = 0
  1321. else
  1322. qcSettings.QC_M_HIDE_PROFESSION = 1
  1323. end
  1324. end)
  1325.  
  1326. qcIO_M_HIDE_SEASONAL = CreateFrame("CheckButton", "qcIO_M_HIDE_SEASONAL", self, "InterfaceOptionsCheckButtonTemplate")
  1327. qcIO_M_HIDE_SEASONAL:SetPoint("TOPLEFT", qcIO_M_HIDE_PROFESSION, "BOTTOMLEFT", 0, 0)
  1328. _G[qcIO_M_HIDE_SEASONAL:GetName().."Text"]:SetText(qcL.HIDENONACTIVESEASONALQUESTS)
  1329. qcIO_M_HIDE_SEASONAL:SetScript("OnClick", function(self)
  1330. if (qcIO_M_HIDE_SEASONAL:GetChecked() == false) then
  1331. qcSettings.QC_M_HIDE_SEASONAL = 0
  1332. else
  1333. qcSettings.QC_M_HIDE_SEASONAL = 1
  1334. end
  1335. end)
  1336.  
  1337. qcIO_M_HIDE_INPROGRESS = CreateFrame("CheckButton", "qcIO_M_HIDE_INPROGRESS", self, "InterfaceOptionsCheckButtonTemplate")
  1338. qcIO_M_HIDE_INPROGRESS:SetPoint("TOPLEFT", qcIO_M_HIDE_SEASONAL, "BOTTOMLEFT", 0, 0)
  1339. _G[qcIO_M_HIDE_INPROGRESS:GetName().."Text"]:SetText(qcL.HIDEINPROGRESSQUESTS)
  1340. qcIO_M_HIDE_INPROGRESS:SetScript("OnClick", function(self)
  1341. if (qcIO_M_HIDE_INPROGRESS:GetChecked() == false) then
  1342. qcSettings.QC_M_HIDE_INPROGRESS = 0
  1343. else
  1344. qcSettings.QC_M_HIDE_INPROGRESS = 1
  1345. end
  1346. end)
  1347.  
  1348. --- Quest List Filters Start ---
  1349. qcListFiltersTitle = self:CreateFontString("qcListFiltersTitle", "ARTWORK", "GameFontNormal")
  1350. qcListFiltersTitle:SetPoint("TOPLEFT", qcConfigSubtitle, "BOTTOMLEFT", 16, -185)
  1351. qcListFiltersTitle:SetText(qcL.QUESTLISTFILTERS)
  1352.  
  1353. qcIO_L_HIDE_COMPLETED = CreateFrame("CheckButton", "qcIO_L_HIDE_COMPLETED", self, "InterfaceOptionsCheckButtonTemplate")
  1354. qcIO_L_HIDE_COMPLETED:SetPoint("TOPLEFT", qcListFiltersTitle, "BOTTOMLEFT", 16, -6)
  1355. _G[qcIO_L_HIDE_COMPLETED:GetName().."Text"]:SetText(qcL.HIDECOMPLETEDQUESTS)
  1356. qcIO_L_HIDE_COMPLETED:SetScript("OnClick", function(self)
  1357. if (qcIO_L_HIDE_COMPLETED:GetChecked() == false) then
  1358. qcSettings.QC_L_HIDE_COMPLETED = 0
  1359. else
  1360. qcSettings.QC_L_HIDE_COMPLETED = 1
  1361. end
  1362. end)
  1363.  
  1364. qcIO_L_HIDE_LOWLEVEL = CreateFrame("CheckButton", "qcIO_L_HIDE_LOWLEVEL", self, "InterfaceOptionsCheckButtonTemplate")
  1365. qcIO_L_HIDE_LOWLEVEL:SetPoint("TOPLEFT", qcIO_L_HIDE_COMPLETED, "BOTTOMLEFT", 0, 0)
  1366. _G[qcIO_L_HIDE_LOWLEVEL:GetName().."Text"]:SetText(qcL.HIDELOWLEVELQUESTS .. COLOUR_DEATHKNIGHT .. " (Not Yet Implemented)")
  1367. qcIO_L_HIDE_LOWLEVEL:SetScript("OnClick", function(self)
  1368. if (qcIO_L_HIDE_LOWLEVEL:GetChecked() == false) then
  1369. qcSettings.QC_L_HIDE_LOWLEVEL = 0
  1370. else
  1371. qcSettings.QC_L_HIDE_LOWLEVEL = 1
  1372. end
  1373. end)
  1374.  
  1375. qcIO_L_HIDE_PROFESSION = CreateFrame("CheckButton", "qcIO_L_HIDE_PROFESSION", self, "InterfaceOptionsCheckButtonTemplate")
  1376. qcIO_L_HIDE_PROFESSION:SetPoint("TOPLEFT", qcIO_L_HIDE_LOWLEVEL, "BOTTOMLEFT", 0, 0)
  1377. _G[qcIO_L_HIDE_PROFESSION:GetName().."Text"]:SetText(qcL.HIDEOTHERPROFESSIONQUESTS .. COLOUR_DEATHKNIGHT .. " (Not Yet Implemented)")
  1378. qcIO_L_HIDE_PROFESSION:SetScript("OnClick", function(self)
  1379. if (qcIO_L_HIDE_PROFESSION:GetChecked() == false) then
  1380. qcSettings.QC_L_HIDE_PROFESSION = 0
  1381. else
  1382. qcSettings.QC_L_HIDE_PROFESSION = 1
  1383. end
  1384. end)
  1385.  
  1386. --- qcIO_L_HIDE_WORLDQUEST = CreateFrame("CheckButton", "qcIO_L_HIDE_WORLDQUEST", self, "InterfaceOptionsCheckButtonTemplate")
  1387. --- qcIO_L_HIDE_WORLDQUEST:SetPoint("TOPLEFT", qcIO_L_HIDE_WORLDQUEST, "BOTTOMLEFT", 0, 0)
  1388. --- _G[qcIO_L_HIDE_WORLDQUEST:GetName().."Text"]:SetText(qcL.HIDEWORLDQUEST .. COLOUR_DEATHKNIGHT .. " (Not Yet Implemented)")
  1389. --- qcIO_L_HIDE_WORLDQUEST:SetScript("OnClick", function(self)
  1390. --- if (qcIO_L_HIDE_WORLDQUEST:GetChecked() == false) then
  1391. --- qcSettings.QC_L_HIDE_WORLDQUEST = 0
  1392. --- else
  1393. --- qcSettings.QC_L_HIDE_WORLDQUEST = 1
  1394. --- end
  1395. --- end)
  1396.  
  1397. --- Combined Map and Quest FILTERS
  1398. qcCombinedFiltersTitle = self:CreateFontString("qcCombinedFiltersTitle", "ARTWORK", "GameFontNormal")
  1399. qcCombinedFiltersTitle:SetPoint("TOPLEFT", qcConfigSubtitle, "BOTTOMLEFT", 16, -290)
  1400. qcCombinedFiltersTitle:SetText(qcL.COMBINEDMAPANDQUESTFILTERS)
  1401.  
  1402. qcIO_ML_HIDE_FACTION = CreateFrame("CheckButton", "qcIO_ML_HIDE_FACTION", self, "InterfaceOptionsCheckButtonTemplate")
  1403. qcIO_ML_HIDE_FACTION:SetPoint("TOPLEFT", qcCombinedFiltersTitle, "BOTTOMLEFT", 16, -6)
  1404. _G[qcIO_ML_HIDE_FACTION:GetName().."Text"]:SetText(qcL.HIDEOTHERFACTIONQUESTS)
  1405. qcIO_ML_HIDE_FACTION:SetScript("OnClick", function(self)
  1406. if (qcIO_ML_HIDE_FACTION:GetChecked() == false) then
  1407. qcSettings.QC_ML_HIDE_FACTION = 0
  1408. else
  1409. qcSettings.QC_ML_HIDE_FACTION = 1
  1410. end
  1411. end)
  1412.  
  1413. qcIO_ML_HIDE_RACECLASS = CreateFrame("CheckButton", "qcIO_ML_HIDE_RACECLASS", self, "InterfaceOptionsCheckButtonTemplate")
  1414. qcIO_ML_HIDE_RACECLASS:SetPoint("TOPLEFT", qcIO_ML_HIDE_FACTION, "BOTTOMLEFT", 0, 0)
  1415. _G[qcIO_ML_HIDE_RACECLASS:GetName().."Text"]:SetText(qcL.HIDEOTHERRACEANDCLASSQUESTS)
  1416. qcIO_ML_HIDE_RACECLASS:SetScript("OnClick", function(self)
  1417. if (qcIO_ML_HIDE_RACECLASS:GetChecked() == false) then
  1418. qcSettings.QC_ML_HIDE_RACECLASS = 0
  1419. else
  1420. qcSettings.QC_ML_HIDE_RACECLASS = 1
  1421. end
  1422. end)
  1423.  
  1424. self:SetScript("OnShow", qcConfigRefresh)
  1425. qcConfigRefresh(self)
  1426.  
  1427. end
  1428.  
  1429. function qcConfigRefresh(self)
  1430. if not (self:IsVisible()) then return end
  1431. --[[ Set control values here ]]--
  1432. end
  1433.  
  1434. function qcInterfaceOptions_OnLoad(self)
  1435.  
  1436. self.name = "Quest Completist"
  1437. self.okay = function(self) qcInterfaceOptions_Okay(self) end
  1438. self.cancel = function(self) qcInterfaceOptions_Cancel(self) end
  1439. InterfaceOptions_AddCategory(self)
  1440.  
  1441. end
  1442.  
  1443. --[[ ##### INTERFACE OPTIONS END ##### ]]--
  1444.  
  1445. local function qcWelcomeMessage()
  1446. print(string.format("%sThanks for using Quest Completist. Spot a quest innaccuracy? Please report it on curse",QCADDON_CHAT_TITLE))
  1447. end
  1448.  
  1449. local function qcCheckSettings()
  1450.  
  1451. if (qcSettings == nil) then
  1452. qcSettings = {}
  1453. end
  1454.  
  1455. if (qcSettings.SORT == nil) then --[[ 1:Level, 2:Alpha, 3:Quest Giver ]]--
  1456. qcSettings.SORT = 1
  1457. end
  1458. if (qcSettings.PURGED == nil) then
  1459. qcSettings.PURGED = 0
  1460. end
  1461.  
  1462. --[[ Interface Options ]]--
  1463.  
  1464. if (qcSettings.QC_M_SHOW_ICONS == nil) then --[[ 0:No, 1:Yes ]]--
  1465. qcSettings.QC_M_SHOW_ICONS = 1
  1466. end
  1467. if (qcSettings.QC_M_HIDE_COMPLETED == nil) then --[[ 0:No, 1:Yes ]]--
  1468. qcSettings.QC_M_HIDE_COMPLETED = 0
  1469. end
  1470. if (qcSettings.QC_M_HIDE_LOWLEVEL == nil) then --[[ 0:No, 1:Yes ]]--
  1471. qcSettings.QC_M_HIDE_LOWLEVEL = 0
  1472. end
  1473. if (qcSettings.QC_M_HIDE_PROFESSION == nil) then --[[ 0:No, 1:Yes ]]--
  1474. qcSettings.QC_M_HIDE_PROFESSION = 1
  1475. end
  1476. if (qcSettings.QC_M_HIDE_SEASONAL == nil) then --[[ 0:No, 1:Yes ]]--
  1477. qcSettings.QC_M_HIDE_SEASONAL = 1
  1478. end
  1479. if (qcSettings.QC_M_HIDE_INPROGRESS == nil) then --[[ 0:No, 1:Yes ]]--
  1480. qcSettings.QC_M_HIDE_INPROGRESS = 0
  1481. end
  1482. if (qcSettings.QC_L_HIDE_COMPLETED == nil) then --[[ 0:No, 1:Yes ]]--
  1483. qcSettings.QC_L_HIDE_COMPLETED = 0
  1484. end
  1485. if (qcSettings.QC_L_HIDE_LOWLEVEL == nil) then --[[ 0:No, 1:Yes ]]--
  1486. qcSettings.QC_L_HIDE_LOWLEVEL = 0
  1487. end
  1488. if (qcSettings.QC_L_HIDE_PROFESSION == nil) then --[[ 0:No, 1:Yes ]]--
  1489. qcSettings.QC_L_HIDE_PROFESSION = 1
  1490. end
  1491. if (qcSettings.QC_L_HIDE_WORLDQUEST == nil) then --[[ 0:No, 1:Yes ]]--
  1492. qcSettings.QC_L_HIDE_WORLDQUEST = 1
  1493. end
  1494. if (qcSettings.QC_ML_HIDE_FACTION == nil) then --[[ 0:No, 1:Yes ]]--
  1495. qcSettings.QC_ML_HIDE_FACTION = 1
  1496. end
  1497. if (qcSettings.QC_ML_HIDE_RACECLASS == nil) then --[[ 0:No, 1:Yes ]]--
  1498. qcSettings.QC_ML_HIDE_RACECLASS = 1
  1499. end
  1500. if (qcSettings.QC_SERVER_QUERY_COMPLETE == nil) then --[[ 0:No, 1:Yes ]]--
  1501. qcSettings.QC_SERVER_QUERY_COMPLETE = 0
  1502. end
  1503. if (qcSettings.QCIO_M_HIDE_DAILYREPEATABLE == nil) then
  1504. qcSettings.QCIO_M_HIDE_DAILYREPEATABLE = 0
  1505. end
  1506.  
  1507. end
  1508.  
  1509. local function qcApplySettings()
  1510.  
  1511. if (qcSettings.QC_M_SHOW_ICONS == 0) then
  1512. qcIO_M_SHOW_ICONS:SetChecked(false)
  1513. else
  1514. qcIO_M_SHOW_ICONS:SetChecked(true)
  1515. end
  1516. if (qcSettings.QC_M_HIDE_COMPLETED == 0) then
  1517. qcIO_M_HIDE_COMPLETED:SetChecked(false)
  1518. else
  1519. qcIO_M_HIDE_COMPLETED:SetChecked(true)
  1520. end
  1521. if (qcSettings.QC_M_HIDE_LOWLEVEL == 0) then
  1522. qcIO_M_HIDE_LOWLEVEL:SetChecked(false)
  1523. else
  1524. qcIO_M_HIDE_LOWLEVEL:SetChecked(true)
  1525. end
  1526. if (qcSettings.QC_M_HIDE_PROFESSION == 0) then
  1527. qcIO_M_HIDE_PROFESSION:SetChecked(false)
  1528. else
  1529. qcIO_M_HIDE_PROFESSION:SetChecked(true)
  1530. end
  1531. if (qcSettings.QC_M_HIDE_SEASONAL == 0) then
  1532. qcIO_M_HIDE_SEASONAL:SetChecked(false)
  1533. else
  1534. qcIO_M_HIDE_SEASONAL:SetChecked(true)
  1535. end
  1536. if (qcSettings.QC_M_HIDE_INPROGRESS == 0) then
  1537. qcIO_M_HIDE_INPROGRESS:SetChecked(false)
  1538. else
  1539. qcIO_M_HIDE_INPROGRESS:SetChecked(true)
  1540. end
  1541. if (qcSettings.QC_L_HIDE_COMPLETED == 0) then
  1542. qcIO_L_HIDE_COMPLETED:SetChecked(false)
  1543. else
  1544. qcIO_L_HIDE_COMPLETED:SetChecked(true)
  1545. end
  1546. if (qcSettings.QC_L_HIDE_LOWLEVEL == 0) then
  1547. qcIO_L_HIDE_LOWLEVEL:SetChecked(false)
  1548. else
  1549. qcIO_L_HIDE_LOWLEVEL:SetChecked(true)
  1550. end
  1551. if (qcSettings.QC_L_HIDE_PROFESSION == 0) then
  1552. qcIO_L_HIDE_PROFESSION:SetChecked(false)
  1553. else
  1554. qcIO_L_HIDE_PROFESSION:SetChecked(true)
  1555. end
  1556. -- if (qcSettings.QC_L_HIDE_WORLDQUEST == 0) then
  1557. -- qcIO_L_HIDE_WORLDQUEST:SetChecked(false)
  1558. -- else
  1559. -- qcIO_L_HIDE_WORLDQUEST:SetChecked(true)
  1560. -- end
  1561. if (qcSettings.QC_ML_HIDE_FACTION == 0) then
  1562. qcIO_ML_HIDE_FACTION:SetChecked(false)
  1563. else
  1564. qcIO_ML_HIDE_FACTION:SetChecked(true)
  1565. end
  1566. if (qcSettings.QC_ML_HIDE_RACECLASS == 0) then
  1567. qcIO_ML_HIDE_RACECLASS:SetChecked(false)
  1568. else
  1569. qcIO_ML_HIDE_RACECLASS:SetChecked(true)
  1570. end
  1571.  
  1572. if (QCADDON_PURGE == true) then
  1573. if not (qcSettings.PURGED == QCADDON_VERSION) then
  1574. qcPurgeCollectedCache()
  1575. qcSettings.PURGED = QCADDON_VERSION
  1576. end
  1577. end
  1578.  
  1579. if (qcSettings.QC_SERVER_QUERY_COMPLETE == 1) then
  1580. print(string.format("%s%s",QCADDON_CHAT_TITLE,qcL.QUERYREQUESTED))
  1581. qcQuestCompletistUI:RegisterEvent("QUEST_QUERY_COMPLETE")
  1582. QueryQuestsCompleted()
  1583. end
  1584.  
  1585. end
  1586.  
  1587. local function qcEventHandler(self, event, ...)
  1588. if (event == "ADVENTURE_MAP_OPEN") then
  1589. qcRefreshPins(C_Map.GetBestMapForUnit("player"))
  1590. elseif (event == "UNIT_QUEST_LOG_CHANGED") then
  1591. if (... == "player") then qcUpdateQuestList(nil, qcMenuSlider:GetValue()) end
  1592. elseif (event == "ZONE_CHANGED_NEW_AREA") then
  1593. qcZoneChangedNewArea()
  1594. elseif (event == "QUEST_ITEM_UPDATE") then
  1595. if (QuestFrame:IsShown()) then QuestFrameNpcNameText:SetText(string.format("%s [%d]",UnitName("questnpc") or "nil",GetQuestID())) end
  1596. elseif (event == "QUEST_DETAIL") then
  1597. local qcQuestID = GetQuestID()
  1598. if (QuestFrame:IsShown()) then QuestFrameNpcNameText:SetText(string.format("%s [%d]",UnitName("questnpc") or "nil",GetQuestID())) end
  1599. qcBreadcrumbChecks(qcQuestID)
  1600. qcNewDataChecks(qcQuestID)
  1601. qcMutuallyExclusiveChecks(qcQuestID)
  1602. if (QCDEBUG_MODE) then qcVerifyMapDataExists() end
  1603. elseif (event == "QUEST_ACCEPTED") then
  1604. qcUpdateQuestList(nil, qcMenuSlider:GetValue())
  1605. elseif (event == "QUEST_PROGRESS") then
  1606. local qcQuestID = GetQuestID()
  1607. if (QuestFrame:IsShown()) then QuestFrameNpcNameText:SetText(string.format("%s [%d]",UnitName("questnpc") or "nil",GetQuestID())) end
  1608. if not (qcQuestID == 0) then
  1609. qcBreadcrumbChecks(qcQuestID)
  1610. qcNewDataChecks(qcQuestID)
  1611. qcMutuallyExclusiveChecks(qcQuestID)
  1612. end
  1613. elseif (event == "QUEST_COMPLETE") then
  1614. local qcQuestID = GetQuestID()
  1615. if (QuestFrame:IsShown()) then QuestFrameNpcNameText:SetText(string.format("%s [%d]",UnitName("questnpc") or "nil",GetQuestID())) end
  1616. if not (qcQuestID == 0) then
  1617. qcBreadcrumbChecks(qcQuestID)
  1618. qcNewDataChecks(qcQuestID)
  1619. qcMutuallyExclusiveChecks(qcQuestID)
  1620. qcUpdateCompletedQuest(qcQuestID)
  1621. qcUpdateMutuallyExclusiveCompletedQuest(qcQuestID)
  1622. qcUpdateSkippedBreadcrumbQuest(qcQuestID)
  1623. qcUpdateQuestList(nil, qcMenuSlider:GetValue())
  1624. end
  1625. elseif (event == "PLAYER_ENTERING_WORLD") then
  1626. qcQuestQueryCompleted()
  1627. qcZoneChangedNewArea()
  1628. elseif (event == "ADDON_LOADED") then
  1629. if (... == "QuestCompletist") then
  1630. if not (qcCompletedQuests) then qcCompletedQuests = {} end
  1631. if not (qcWorkingDB) then qcWorkingDB = {} end
  1632. if not (qcWorkingLog) then qcWorkingLog = {} end
  1633. qcCheckSettings()
  1634. qcApplySettings()
  1635. qcWelcomeMessage()
  1636. qcZoneChangedNewArea()
  1637. qcMenuSlider:SetValueStep(1);
  1638. qcMenuSlider:SetObeyStepOnDrag(true);
  1639. end
  1640. end
  1641.  
  1642. end
  1643.  
  1644. function qcQuestCompletistUI_OnShow(self)
  1645. if (qcSettings) then
  1646. qcUpdateQuestList(qcCurrentCategoryID,qcMenuSlider:GetValue())
  1647. end
  1648. end
  1649.  
  1650. function qcQuestCompletistUI_OnLoad(self)
  1651. SetPortraitToTexture(self.qcPortrait, "Interface\\ICONS\\TRADE_ARCHAEOLOGY_DRAENEI_TOME")
  1652. self.qcTitleText:SetText(string.format("Quest Completist v%s", QCADDON_VERSION))
  1653. self.qcCategoryDropdownButton:SetText(GetText("CATEGORIES"))
  1654. self.qcOptionsButton:SetText(GetText("FILTERS"))
  1655. self:RegisterForDrag("LeftButton")
  1656. self:RegisterEvent("QUEST_COMPLETE")
  1657. self:RegisterEvent("QUEST_DETAIL")
  1658. self:RegisterEvent("QUEST_PROGRESS")
  1659. self:RegisterEvent("QUEST_ACCEPTED")
  1660. self:RegisterEvent("QUEST_ITEM_UPDATE")
  1661. self:RegisterEvent("UNIT_QUEST_LOG_CHANGED")
  1662. self:RegisterEvent("PLAYER_ENTERING_WORLD")
  1663. self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  1664. self:RegisterEvent("ADDON_LOADED")
  1665. self:RegisterEvent("ADVENTURE_MAP_OPEN")
  1666. self:SetScript("OnEvent", qcEventHandler)
  1667. qcQuestInformationTooltipSetup()
  1668. qcQuestReputationTooltipSetup()
  1669. qcMapTooltipSetup()
  1670. qcToastTooltipSetup()
  1671. qcNewDataAlertTooltipSetup()
  1672. qcMutuallyExclusiveAlertTooltipSetup()
  1673. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement