Guest User

SorhaQuestLog 1.5.1.1 BonusObjective Fix Modules/Quests.lua

a guest
May 17th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 205.33 KB | None | 0 0
  1. local SorhaQuestLog = LibStub("AceAddon-3.0"):GetAddon("SorhaQuestLog")
  2. local L = LibStub("AceLocale-3.0"):GetLocale("SorhaQuestLog")
  3. local MODNAME = "QuestTracker"
  4. local QuestTracker = SorhaQuestLog:NewModule(MODNAME, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0", "LibSink-2.0")
  5. SorhaQuestLog.QuestTracker = QuestTracker
  6.  
  7. local LibToast = LibStub("LibToast-1.0", true)
  8. LibToast:Embed(SorhaQuestLog)
  9.  
  10.  
  11. local AceConfigDialog = LibStub("AceConfigDialog-3.0")
  12. local LSM = LibStub("LibSharedMedia-3.0")
  13. local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
  14. local MSQ = LibStub("Masque", true)
  15.  
  16. local fraMinionAnchor = nil
  17. local blnMinionInitialized = false
  18. local blnMinionUpdating = false
  19.  
  20. local strButtonPrefix = MODNAME .. "Button"
  21. local strItemButtonPrefix = MODNAME .. "ItemButton"
  22. local intNumberUsedButtons = 0
  23. local intNumberOfItemButtons = 0
  24.  
  25. local tblButtonCache = {}
  26. local tblItemButtonCache = {}
  27. local tblUsingButtons = {}
  28. local tblUsedItemButtons = {}
  29.  
  30. local strMinionTitleColour = "|cffffffff"
  31. local strInfoColour = "|cffffffff"
  32. local strHeaderColour = "|cffffffff"
  33. local strQuestTitleColour = "|cffffffff"
  34. local strObjectiveTitleColour = "|cffffffff"
  35. local strObjectiveDescriptionColour = "|cffffffff"
  36. local strQuestStatusFailed = "|cffffffff"
  37. local strQuestStatusDone = "|cffffffff"
  38. local strQuestStatusGoto = "|cffffffff"
  39. local strQuestLevelColour = "|cffffffff"
  40. local strObjectiveStatusColour = "|cffffffff"
  41. local strObjective00Colour = "|cffffffff"
  42. local strObjective01to24Colour = "|cffffffff"
  43. local strObjective25to49Colour = "|cffffffff"
  44. local strObjective50to74Colour = "|cffffffff"
  45. local strObjective75to99Colour = "|cffffffff"
  46. local strObjective100Colour = "|cffffffff"
  47. local strUndoneColour = "|cffffffff"
  48. local strDoneColour = "|cffffffff"
  49. local strObjectiveTooltipTextColour = "|cffffffff"
  50.  
  51. local intItemButtonSize = 26
  52. local bonusObjectivesZoneTitle = L['Bonus Objectives'];
  53. local bonusObjectivesZoneID = 'Bonus Objectives';
  54. local worldQuestsZoneTitle = TRACKER_HEADER_WORLD_QUESTS;
  55. local worldQuestsZoneID = 'World Quests';
  56. local campaignZoneID = 'Campaign Objectives';
  57.  
  58. --player info
  59. local playerMoney = 0;
  60. local tblPOIs = {};
  61.  
  62. -- Tables
  63. local tblBagsToCheck = {}
  64. local tblHaveQuestItems = {}
  65.  
  66. local blnWasAClick = false -- Was QUEST_LOG_UPDATE called by a click on a header etc
  67. local blnIgnoreUpdateEvents = false -- Ignores QLU events, used when making large scale collapse/expands to log
  68. local blnFirstUpdate = true -- Was first update of quest log, no old data will be on store yet
  69. local blnFirstBagCheck = true
  70.  
  71. local blnBagCheckUpdating = false
  72. local blnHaveRegisteredBagUpdate = false
  73.  
  74.  
  75. -- Strings used to store current location for auto collapse/expand
  76. local strZone = ""
  77. local strSubZone = ""
  78.  
  79. local curQuestInfo = nil -- Questlog data stores
  80. local intTimeOfLastSound = 0 -- Time last sound played
  81. local timeOfProximityCheck = 0
  82. local timeOfFirstQuestUpdate = 0;
  83.  
  84. local LEFT_CLICK = "LEFT_CLICK";
  85. local LEFT_ALT_CLICK = "LEFT_ALT_CLICK";
  86. local LEFT_ALT_CTRL_CLICK = "LEFT_ALT_CTRL_CLICK";
  87. local LEFT_ALT_SHIFT_CLICK = "LEFT_ALT_SHIFT_CLICK";
  88. local LEFT_CTRL_CLICK = "LEFT_CTRL_CLICK";
  89. local LEFT_CTRL_SHIFT_CLICK = "LEFT_CTRL_SHIFT_CLICK";
  90. local LEFT_SHIFT_CLICK = "LEFT_SHIFT_CLICK";
  91. local RIGHT_CLICK = "RIGHT_CLICK";
  92. local RIGHT_ALT_CLICK = "RIGHT_ALT_CLICK";
  93. local RIGHT_ALT_CTRL_CLICK = "RIGHT_ALT_CTRL_CLICK";
  94. local RIGHT_ALT_SHIFT_CLICK = "RIGHT_ALT_SHIFT_CLICK";
  95. local RIGHT_CTRL_CLICK = "RIGHT_CTRL_CLICK";
  96. local RIGHT_CTRL_SHIFT_CLICK = "RIGHT_CTRL_SHIFT_CLICK";
  97. local RIGHT_SHIFT_CLICK = "RIGHT_SHIFT_CLICK";
  98. local HEADER_BUTTON = "HEADER_BUTTON";
  99. local QUEST_BUTTON = "QUEST_BUTTON";
  100.  
  101.  
  102. local tmpQuest = nil;
  103. local btnSearchQuestsClick = 1;
  104. local btnSearchQuests = nil;
  105.  
  106. -- Matching quest completion outputs
  107. local function getPattern(strPattern)
  108.     strPattern = string.gsub(strPattern, "%(", "%%%1")
  109.     strPattern = string.gsub(strPattern, "%)", "%%%1")
  110.     strPattern = string.gsub(strPattern, "%%%d?$?.", "(.+)")
  111.     return format("^%s$", strPattern)
  112. end
  113.  
  114. local tblQuestMatchs = {
  115.     ["Found"] = getPattern(ERR_QUEST_ADD_FOUND_SII),
  116.     ["Item"] = getPattern(ERR_QUEST_ADD_ITEM_SII),
  117.     ["Kill"] = getPattern(ERR_QUEST_ADD_KILL_SII),
  118.     ["PKill"] = getPattern(ERR_QUEST_ADD_PLAYER_KILL_SII),
  119.     ["ObjectiveComplete"] = getPattern(ERR_QUEST_OBJECTIVE_COMPLETE_S),
  120.     ["QuestComplete"] = getPattern(ERR_QUEST_COMPLETE_S),
  121.     ["QuestFailed"] = getPattern(ERR_QUEST_FAILED_S),
  122. }
  123.  
  124. local tblZoneClickBindings = {
  125.     ["LEFT_CLICK"] = nil,
  126.     ["LEFT_ALT_CLICK"] = nil,
  127.     ["LEFT_ALT_CTRL_CLICK"] = nil,
  128.     ["LEFT_CTRL_CLICK"] = nil,
  129.     ["LEFT_SHIFT_CLICK"] = nil,
  130.     ["RIGHT_CLICK"] = nil, 
  131. }
  132.  
  133. local tblQuestClickBindings = {
  134.     ["LEFT_CLICK"] = nil,
  135.     ["LEFT_ALT_CLICK"] = nil,
  136.     ["LEFT_ALT_CTRL_CLICK"] = nil,
  137.     ["LEFT_CTRL_CLICK"] = nil,
  138.     ["LEFT_SHIFT_CLICK"] = nil,
  139.     ["RIGHT_CLICK"] = nil, 
  140.     ["RIGHT_SHIFT_CLICK"] = nil,
  141. }
  142.  
  143. -- Tables used for quest tags (Group, Elite etc)
  144. local dicQuestTags = {
  145.     [ELITE] = "+",
  146.     [Enum.QuestTag.Group] = "g",
  147.     [Enum.QuestTag.Pvp] = "p",
  148.     [Enum.QuestTag.Raid] = "r",
  149.     [Enum.QuestTag.Raid10] = "r",
  150.     [Enum.QuestTag.Raid25] = "r",
  151.     [Enum.QuestTag.Dungeon] = "d",
  152.     [Enum.QuestTag.Heroic] = "d+",
  153.     [Enum.QuestTag.Scenario] = "s",
  154.     [Enum.QuestTag.Account] = "a",
  155.     ["Daily"] = "*",
  156.     ["Weekly"] = "**",
  157. }
  158.  
  159. local dicLongQuestTags = {
  160.     [ELITE] = ELITE,
  161.     [Enum.QuestTag.Group] = GROUP,
  162.     [Enum.QuestTag.Pvp] = PVP,
  163.     [Enum.QuestTag.Raid] = RAID,
  164.     [Enum.QuestTag.Raid10] = RAID,
  165.     [Enum.QuestTag.Raid25] = RAID,
  166.     [Enum.QuestTag.Dungeon] = LFG_TYPE_DUNGEON,
  167.     [Enum.QuestTag.Heroic] = PLAYER_DIFFICULTY2,
  168.     [Enum.QuestTag.Scenario] = TRACKER_HEADER_SCENARIO,
  169.     [Enum.QuestTag.Account] = L["Account"],
  170.     ["Daily"] = DAILY,
  171.     ["Weekly"] = WEEKLY,
  172. }
  173.  
  174. local dicRepLevels = {
  175.     ["Hated"] = {["MTitle"] = FACTION_STANDING_LABEL1, ["FTitle"] = FACTION_STANDING_LABEL1_FEMALE, ["Value"] = 1.00},
  176.     ["Hostile"] = {["MTitle"] = FACTION_STANDING_LABEL2, ["FTitle"] = FACTION_STANDING_LABEL2_FEMALE, ["Value"] = 1.30},
  177.     ["Unfriendly"] = {["MTitle"] = FACTION_STANDING_LABEL3, ["FTitle"] = FACTION_STANDING_LABEL3_FEMALE, ["Value"] = 1.70},
  178.     ["Neutral"] = {["MTitle"] = FACTION_STANDING_LABEL4, ["FTitle"] = FACTION_STANDING_LABEL4_FEMALE, ["Value"] = 2.20},
  179.     ["Friendly"] = {["MTitle"] = FACTION_STANDING_LABEL5, ["FTitle"] = FACTION_STANDING_LABEL5_FEMALE, ["Value"] = 2.85},
  180.     ["Honored"] = {["MTitle"] = FACTION_STANDING_LABEL6, ["FTitle"] = FACTION_STANDING_LABEL6_FEMALE, ["Value"] = 3.71},
  181.     ["Revered"] = {["MTitle"] = FACTION_STANDING_LABEL7, ["FTitle"] = FACTION_STANDING_LABEL7_FEMALE, ["Value"] = 4.82},
  182.     ["Exalted"] = {["MTitle"] = FACTION_STANDING_LABEL8, ["FTitle"] = FACTION_STANDING_LABEL8_FEMALE, ["Value"] = 6.27},
  183. }
  184.  
  185. --options table helpers
  186. local dicQuestSortOrder = {
  187.     ["Default"] = DEFAULT,
  188.     ["Title"] = L["Title"],
  189.     ["Level"] = LEVEL,
  190.     ["POI"] = MINIMAP_TRACKING_POI,
  191.     ["Proximity"] = TRACKER_SORT_PROXIMITY,
  192.     ["Completion"] = TUTORIAL_TITLE34,
  193. }
  194.  
  195. local dicOutlines = {
  196.     [""] = NONE,
  197.     ["OUTLINE"] = L["Outline"],
  198.     ["THICKOUTLINE"] = L["Thick Outline"],
  199.     ["MONOCHROMEOUTLINE"] = L["Monochrome Outline"],
  200. }
  201.  
  202. local dicQuestTitleColourOptions = {
  203.     ["Custom"] = CUSTOM,
  204.     ["Level"] = LEVEL,
  205.     ["Completion"] = TUTORIAL_TITLE34,
  206.     ["Done/Undone"] = L["Done/Undone"],
  207. }
  208.  
  209. local dicObjectiveColourOptions = {
  210.     ["Custom"] = CUSTOM,
  211.     ["Done/Undone"] = L["Done/Undone"],
  212.     ["Completion"] = TUTORIAL_TITLE34,
  213. }
  214.  
  215. local dicNotificationColourOptions = {
  216.     ["Custom"] = CUSTOM,
  217.     ["Completion"] = TUTORIAL_TITLE34,
  218. }
  219.  
  220. local dicKeybinds = {
  221.     ["LEFT_CLICK"] = L["Left Click"],
  222.     ["LEFT_ALT_CLICK"] = L["Left Alt Click"],
  223.     ["LEFT_ALT_CTRL_CLICK"] = L["Left Alt+Ctrl Click"],
  224.     --["LEFT_ALT_SHIFT_CLICK"] = L["Left Alt+Shift Click"],
  225.     ["LEFT_CTRL_CLICK"] = L["Left Ctrl Click"],
  226.     --["LEFT_CTRL_SHIFT_CLICK"] = L["Left Ctrl+Shift Click"],
  227.     ["LEFT_SHIFT_CLICK"] = L["Left Shift Click"],
  228.     ["RIGHT_CLICK"] = L["Right Click"],
  229.     --["RIGHT_ALT_CLICK"] = L["Right Alt Click"],
  230.     --["RIGHT_ALT_CTRL_CLICK"] = L["Right Alt+Ctrl Click"],
  231.     --["RIGHT_ALT_SHIFT_CLICK"] = L["Right Alt+Shift Click"],
  232.     --["RIGHT_CTRL_CLICK"] = L["Right Ctrl Click"],
  233.     --["RIGHT_CTRL_SHIFT_CLICK"] = L["Right Ctrl+Shift Click"],
  234.     ["RIGHT_SHIFT_CLICK"] = L["Right Shift Click"],
  235. }
  236.  
  237. local dicQuestTagsLength = {
  238.     ["None"] = NONE,
  239.     ["Short"] = SHORT,
  240.     ["Full"] = L["Full"],
  241. }
  242.  
  243. local dicZoneLevels = {
  244.     [650] = 110, -- Highmountain
  245.     [634] = 110, -- Stormheim
  246.     [680] = 110, -- Suramar
  247.     [630] = 110, -- Azsuna
  248.     [641] = 110, -- Val'sharah
  249.     [627] = 110, -- Dalaran
  250.     [790] = 110, -- Eye of Azshara
  251.     [646] = 110, -- Broken Shore
  252.     [882] = 110, -- Mac'Aree
  253.     [830] = 110, -- Krokun
  254.     [885] = 110, -- Antoran Wastes
  255.     [942] = 120, -- Stormsong Valley
  256.     [895] = 120, -- Tiragarde Sound
  257.     [1161] = 120, -- Boralus
  258.     [896] = 120, -- Drustvar
  259.     [864] = 120, -- Vol'dun
  260.     [863] = 120, -- Nazmir
  261.     [862] = 120, -- Zuldazar
  262.     [1165] = 120, -- Dazar'alor
  263. }
  264.  
  265. --Defaults
  266. local db
  267. local dbCore;
  268. local dbChar;
  269. local defaults = {
  270.     profile = {
  271.         MinionLocation = {X = 0, Y = 0, Point = "CENTER", RelativePoint = "CENTER"},
  272.         MinionScale = 1,
  273.         MinionLocked = false,
  274.         MinionWidth = 220,
  275.         AutoHideTitle = false,
  276.         MinionCollapseToLeft = false,
  277.         MoveTooltipsRight = false,     
  278.         GrowUpwards = false,
  279.         ConfirmQuestAbandons = true,
  280.         ShowNumberOfQuests = true,
  281.         ShowNumberOfDailyQuests = false,       
  282.         ShowItemButtons = true,
  283.         IndentItemButtons = false,
  284.         IndentItemButtonQuestsOnly = false,        
  285.         ItemButtonScale = 0.8,
  286.         HideItemButtonsForCompletedQuests = true,  
  287.         UseStatusBars = true,
  288.         UseQuestCountMaxText = true,
  289.         ShowCurrentSmartQuestItem = false,
  290.         ZonesAndQuests = {
  291.             QuestLevelColouringSetting = "Level",
  292.             QuestTitleColouringSetting = "Level",
  293.             ObjectiveTitleColouringSetting = "Custom",
  294.             ObjectiveStatusColouringSetting = "Completion",
  295.             QuestTagsLength = "Short",
  296.             ShowQuestLevels = true,
  297.             HideCompletedObjectives = true,
  298.             HideCompletedQuests = false,
  299.             ShowDescWhenNoObjectives = false,
  300.             AllowHiddenQuests = true,
  301.             CollapseOnLeave = false,
  302.             ExpandOnEnter = false,
  303.             HideZoneHeaders = false,
  304.             QuestHeadersHideWhenEmpty = true,
  305.             ShowHiddenCountOnZones = false,
  306.             QuestTitleIndent = 5,
  307.             ObjectivesIndent = 0,
  308.             QuestAfterPadding = 0,
  309.             ObjectiveTextLast= false,
  310.             DisplayPOITag = false,
  311.             QuestSortOrder = "Default",
  312.             DisplayQuestIDInTooltip = false,
  313.         },     
  314.         Sounds = {
  315.             UseQuestDoneSound = false,
  316.             UseObjectiveDoneSound = false,
  317.         },
  318.         Fonts = {
  319.             -- Scenario minion title font
  320.             MinionTitleFontSize = 11,
  321.             MinionTitleFont = "framd",
  322.             MinionTitleFontOutline = "",
  323.             MinionTitleFontShadowed = true,
  324.             MinionTitleFontLineSpacing = 0,
  325.            
  326.             -- Zone header font
  327.             HeaderFontSize = 11,
  328.             HeaderFont = "framd",
  329.             HeaderFontOutline = "",
  330.             HeaderFontShadowed = true,
  331.             HeaderFontLineSpacing = 0,
  332.                
  333.             -- Quest title font
  334.             QuestFontSize = 11,
  335.             QuestFont = "framd",
  336.             QuestFontOutline = "",
  337.             QuestFontShadowed = true,
  338.             QuestFontLineSpacing = 0,
  339.            
  340.             -- Objective text font
  341.             ObjectiveFontSize = 11,
  342.             ObjectiveFont = "framd",
  343.             ObjectiveFontOutline = "",
  344.             ObjectiveFontShadowed = true,
  345.             ObjectiveFontLineSpacing = 0,
  346.         },
  347.         Colours = {
  348.             MinionTitleColour = {r = 0, g = 1, b = 0, a = 1},
  349.             HeaderColour = {r = 0, g = 0.6, b = 1, a = 1},
  350.             QuestTitleColour = {r = 1, g = 1, b = 1, a = 1},
  351.             ObjectiveDescColour = {r = 0.5, g = 0.5, b = 0.5, a = 0.5},
  352.             ObjectiveTitleColour = {r = 1, g = 1, b = 1, a = 1},           
  353.             QuestStatusFailedColour = {r = 1, g = 1, b = 1, a = 1},
  354.             QuestStatusDoneColour = {r = 1, g = 1, b = 1, a = 1},
  355.             QuestStatusGotoColour = {r = 1, g = 1, b = 1, a = 1},
  356.             QuestLevelColour = {r = 1, g = 1, b = 1, a = 1},
  357.             ObjectiveStatusColour = {r = 1, g = 1, b = 1, a = 1},
  358.             Objective00Colour = {r = 1, g = 0, b = 0, a = 1},
  359.             Objective00PlusColour = {r = 1, g = 0, b = 0, a = 1},
  360.             Objective25PlusColour = {r = 1, g = 0.3, b = 0, a = 1},
  361.             Objective50PlusColour  = {r = 1, g = 0.6, b = 0, a = 1},
  362.             Objective75PlusColour = {r = 1, g = 0.95, b = 0, a = 1},
  363.             ObjectiveDoneColour = {r = 0, g = 1, b = 0, a = 1},        
  364.             UndoneColour = {r = 1, g = 0, b = 0, a = 1},           
  365.             DoneColour = {r = 0, g = 1, b = 0, a = 1},         
  366.             MinionBackGroundColour = {r = 0.5, g = 0.5, b = 0.5, a = 0},
  367.             MinionBorderColour = {r = 0.5, g = 0.5, b = 0.5, a = 0},
  368.             InfoColour = {r = 0, g = 1, b = 0.5, a = 1},
  369.             NotificationsColour = {r = 0, g = 1, b = 0, a = 1},
  370.             ObjectiveTooltipTextColour = {r = 0.5, g = 0.5, b = 0.5, a = 1},
  371.             StatusBarFillColour = {r = 0, g = 1, b = 0, a = 1},
  372.             StatusBarBackColour = {r = 0, g = 0, b = 0, a = 1},
  373.             ShowHideButtonColour = {r = 0.3, g = 0.3, b = 0.3, a = 0.65},
  374.             ShowHideButtonActiveColour = {r = 0.2, g = 0.3, b = 1, a = 0.75},
  375.             ShowHideButtonBorderColour = {r = 0, g = 0, b = 0, a = 1},
  376.         },
  377.         Notifications = {
  378.             SuppressBlizzardNotifications = false,
  379.             LibSinkColourSetting = "Custom",
  380.             LibSinkObjectiveNotifications = false,
  381.             DisplayQuestOnObjectiveNotifications = true,
  382.             ShowQuestCompletesAndFails = false,
  383.             QuestDoneSound = "None",
  384.             ObjectiveDoneSound = "None",
  385.             ObjectiveChangedSound = "None",
  386.             QuestItemFoundSound = "None",
  387.             ShowMessageOnPickingUpQuestItem = false,
  388.             DisableToasts = false,
  389.         },
  390.         ClickBinds = {
  391.             OpenLog = "LEFT_CLICK",
  392.             OpenFullLog = "LEFT_ALT_CLICK",
  393.             AbandonQuest = "LEFT_ALT_CTRL_CLICK",
  394.             TrackQuest = "LEFT_CTRL_CLICK",
  395.             LinkQuest = "LEFT_SHIFT_CLICK",
  396.             HideShowQuest = "RIGHT_CLICK",
  397.             FindGroup = "RIGHT_SHIFT_CLICK",
  398.         },
  399.     },
  400.     char = {
  401.         ZoneIsAllHiddenQuests = {},
  402.         ZoneIsCollapsed = {},
  403.         ZonesAndQuests = {
  404.             ShowAllQuests = false,
  405.         }
  406.     },
  407. }
  408.  
  409. --Options
  410. local options
  411. local function getOptions()
  412.     if not options then
  413.         options = {
  414.             name = L["Quest Tracker Settings"],
  415.             type = "group",
  416.             childGroups = "tab",
  417.             order = 1,
  418.             arg = MODNAME,
  419.             args = {
  420.                 Main = {
  421.                     name = L["Main"],
  422.                     type = "group",
  423.                     order = 1,
  424.                     args = {
  425.                         enabled = {
  426.                             order = 1,
  427.                             type = "toggle",
  428.                             name = L["Enable Minion"],
  429.                             get = function() return SorhaQuestLog:GetModuleEnabled(MODNAME) end,
  430.                             set = function(info, value)
  431.                                 SorhaQuestLog:SetModuleEnabled(MODNAME, value)
  432.                                 QuestTracker:MinionAnchorUpdate(false)
  433.                             end,
  434.                         },             
  435.                         MinionLockedToggle = {
  436.                             name = L["Lock Minion"],
  437.                             type = "toggle",
  438.                             get = function() return db.MinionLocked end,
  439.                             set = function()
  440.                                 db.MinionLocked = not db.MinionLocked
  441.                                 QuestTracker:MinionAnchorUpdate(false)
  442.                             end,
  443.                             order = 2,
  444.                         },
  445.                         AutoHideTitleToggle = {
  446.                             name = L["Auto Hide Minion Title"],
  447.                             desc = L["Hide the title when there is nothing to display"],
  448.                             type = "toggle",
  449.                             get = function() return db.AutoHideTitle end,
  450.                             set = function()
  451.                                 db.AutoHideTitle = not db.AutoHideTitle
  452.                                 QuestTracker:UpdateMinion()
  453.                             end,
  454.                             order = 5,
  455.                         },
  456.                         GrowUpwardsToggle = {
  457.                             name = L["Grow Upwards"],
  458.                             desc = L["Minions grows upwards from the anchor"],
  459.                             type = "toggle",
  460.                             get = function() return db.GrowUpwards end,
  461.                             set = function()
  462.                                 db.GrowUpwards = not db.GrowUpwards
  463.                                 QuestTracker:UpdateMinion()
  464.                             end,
  465.                             order = 7,
  466.                         },                     
  467.                         CollapseToLeftToggle = {
  468.                             name = L["Autoshrink to left"],
  469.                             desc = L["Shrinks the width down when the length of current achievements is less then the max width\nNote: Doesn't work well with achievements that word wrap"],
  470.                             type = "toggle",
  471.                             get = function() return db.MinionCollapseToLeft end,
  472.                             set = function()
  473.                                 db.MinionCollapseToLeft = not db.MinionCollapseToLeft
  474.                                 QuestTracker:UpdateMinion()
  475.                             end,
  476.                             order = 8,
  477.                         },
  478.                         MoveTooltipsRightToggle = {
  479.                             name = L["Tooltips on right"],
  480.                             desc = L["Moves the tooltips to the right"],
  481.                             type = "toggle",
  482.                             get = function() return db.MoveTooltipsRight end,
  483.                             set = function()
  484.                                 db.MoveTooltipsRight = not db.MoveTooltipsRight
  485.                                 QuestTracker:UpdateMinion()
  486.                             end,
  487.                             order = 9,
  488.                         },
  489.                         MinionScaler = {
  490.                             order = 10,
  491.                             name = L["Minion Scale"],
  492.                             desc = L["Adjust the scale of the minion"],
  493.                             type = "range",
  494.                             min = 0.5, max = 2, step = 0.05,
  495.                             isPercent = false,
  496.                             get = function() return db.MinionScale end,
  497.                             set = function(info, value)
  498.                                 db.MinionScale = value
  499.                                 QuestTracker:MinionAnchorUpdate(true)
  500.                             end,
  501.                         },
  502.                         MinionWidth = {
  503.                             order = 11,
  504.                             name = L["Width"],
  505.                             desc = L["Adjust the width of the minion"],
  506.                             type = "range",
  507.                             min = 150, max = 600, step = 1,
  508.                             isPercent = false,
  509.                             get = function() return db.MinionWidth end,
  510.                             set = function(info, value)
  511.                                 db.MinionWidth = value
  512.                                 QuestTracker:UpdateMinion()
  513.                             end,
  514.                         },
  515.                         Reset = {
  516.                             order = 12,
  517.                             type = "execute",
  518.                             name = L["Reset Main Frame"],
  519.                             desc = L["Resets Main Frame position"],
  520.                             func = function()
  521.                                 db.MinionLocation.Point = "CENTER"
  522.                                 db.MinionLocation.RelativePoint =  "CENTER"
  523.                                 db.MinionLocation.X = 0
  524.                                 db.MinionLocation.Y = 0
  525.                                 QuestTracker:MinionAnchorUpdate(true)
  526.                             end,
  527.                         },
  528.                         HeaderMiscSettingsSpacer = {
  529.                             name = "",
  530.                             width = "full",
  531.                             type = "description",
  532.                             order = 30,
  533.                         },
  534.                         HeaderMiscSettings = {
  535.                             name = L["Misc. Settings"],
  536.                             type = "header",
  537.                             order = 31,
  538.                         },
  539.                         ShowNumberQuestsToggle = {
  540.                             name = L["Show number of quests"],
  541.                             desc = L["Shows/Hides the number of quests"],
  542.                             type = "toggle",
  543.                             get = function() return db.ShowNumberOfQuests end,
  544.                             set = function()
  545.                                 db.ShowNumberOfQuests = not db.ShowNumberOfQuests
  546.                                 QuestTracker:UpdateMinion()
  547.                             end,
  548.                             order = 32,
  549.                         },
  550.                         ShowNumberOfDailyQuestsToggle = {
  551.                             name = L["Show # of Dailies"],
  552.                             desc = L["Shows/Hides the number of daily quests completed"],
  553.                             type = "toggle",
  554.                             get = function() return db.ShowNumberOfDailyQuests end,
  555.                             set = function()
  556.                                 db.ShowNumberOfDailyQuests = not db.ShowNumberOfDailyQuests
  557.                                 QuestTracker:UpdateMinion()
  558.                             end,
  559.                             order = 33,
  560.                         },
  561.                         UseQuestCountMaxTextToggle = {
  562.                             name = L["Count/Max Header"],
  563.                             desc = L["Sets the LDB and minion header counts to questcount/max instead of count/completed"],
  564.                             type = "toggle",
  565.                             get = function() return db.UseQuestCountMaxText end,
  566.                             set = function()
  567.                                 db.UseQuestCountMaxText = not db.UseQuestCountMaxText
  568.                                 QuestTracker:UpdateMinion()
  569.                             end,
  570.                             order = 34,
  571.                         },
  572.                         ConfirmQuestAbandonsToggle = {
  573.                             name = L["Require confirmation when abandoning a Quest"],
  574.                             desc = L["Shows the confirm box when you try to abandon a quest"],
  575.                             type = "toggle",
  576.                             width = "full",
  577.                             get = function() return db.ConfirmQuestAbandons end,
  578.                             set = function()
  579.                                 db.ConfirmQuestAbandons = not db.ConfirmQuestAbandons
  580.                                 QuestTracker:UpdateMinion()
  581.                             end,
  582.                             order = 36,
  583.                         }, 
  584.                         AutoTrackQuests = {
  585.                             name = L["Automatically track quests"],
  586.                             desc = L["Same as blizzard setting. Tracked quests are shown quests when the ability to hide quests is on."],
  587.                             width = "full",
  588.                             type = "toggle",
  589.                             get = function()
  590.                                 if (GetCVar("autoQuestWatch") ==  "1") then
  591.                                     return true
  592.                                 else
  593.                                     return false
  594.                                 end
  595.                             end,
  596.                             set = function()
  597.                                 if (GetCVar("autoQuestWatch") ==  "1") then
  598.                                     SetCVar("autoQuestWatch", "0", AUTO_QUEST_WATCH_TEXT)
  599.                                 else
  600.                                     SetCVar("autoQuestWatch", "1", AUTO_QUEST_WATCH_TEXT)
  601.                                 end
  602.                             end,
  603.                             order = 37,
  604.                         },
  605.                         AutoTrackQuestsWhenObjectiveupdate = {
  606.                             name = L["Automatically track quests when objectives update"],
  607.                             desc = L["Same as blizzard setting. Tracked quests are shown quests when the ability to hide quests is on."],
  608.                             width = "full",
  609.                             type = "toggle",
  610.                             get = function()
  611.                                 if (GetCVar("autoQuestProgress") ==  "1") then
  612.                                     return true
  613.                                 else
  614.                                     return false
  615.                                 end
  616.                             end,
  617.                             set = function()
  618.                                 if (GetCVar("autoQuestProgress") ==  "1") then
  619.                                     SetCVar("autoQuestProgress", "0", AUTO_QUEST_PROGRESS_TEXT)
  620.                                 else
  621.                                     SetCVar("autoQuestProgress", "1", AUTO_QUEST_PROGRESS_TEXT)
  622.                                 end
  623.                             end,
  624.                             order = 38,
  625.                         },
  626.                         StatusBarSpacerHeader = {
  627.                             name = L["Status Bar Settings"],
  628.                             type = "header",
  629.                             order = 50,
  630.                         },
  631.                         UseStatusBarsToggle = {
  632.                             name = L["Use Bars"],
  633.                             desc = L["Uses status bars for progress bar type objectives"],
  634.                             type = "toggle",
  635.                             get = function() return db.UseStatusBars end,
  636.                             set = function()
  637.                                 db.UseStatusBars = not db.UseStatusBars
  638.                                 QuestTracker:UpdateMinion()
  639.                             end,
  640.                             order = 51,
  641.                         },             
  642.                         MouseBindsSpacerHeader = {
  643.                             name = L["Mouse Click Bindings"],
  644.                             type = "header",
  645.                             order = 60,
  646.                         },
  647.                         OpenQuestLogClick = {
  648.                             name = L["Open Quest Log:"],
  649.                             desc = L["Mouse click to open the quest details pane"],
  650.                             type = "select",
  651.                             order = 61,
  652.                             values = dicKeybinds,
  653.                             get = function() return db.ClickBinds.OpenLog end,
  654.                             set = function(info, value)
  655.                                 db.ClickBinds.OpenLog = value
  656.                                 QuestTracker:UpdateClickBindings();
  657.                                 QuestTracker:UpdateMinion()
  658.                             end,
  659.                         }, 
  660.                         OpenFullQuestLogClick = {
  661.                             name = L["Open Full Quest Log:"],
  662.                             desc = L["Mouse click to open the full quest log pane"],
  663.                             type = "select",
  664.                             order = 62,
  665.                             values = dicKeybinds,
  666.                             get = function() return db.ClickBinds.OpenFullLog end,
  667.                             set = function(info, value)
  668.                                 db.ClickBinds.OpenFullLog = value
  669.                                 QuestTracker:UpdateClickBindings();
  670.                                 QuestTracker:UpdateMinion()
  671.                             end,
  672.                         },
  673.                         AbandonQuestClick = {
  674.                             name = ABANDON_QUEST,
  675.                             desc = L["Mouse click to abandon quest"],
  676.                             type = "select",
  677.                             order = 63,
  678.                             values = dicKeybinds,
  679.                             get = function() return db.ClickBinds.AbandonQuest end,
  680.                             set = function(info, value)
  681.                                 db.ClickBinds.AbandonQuest = value
  682.                                 QuestTracker:UpdateClickBindings();
  683.                                 QuestTracker:UpdateMinion()
  684.                             end,
  685.                         },
  686.                         TrackQuestClick = {
  687.                             name = TRACK_QUEST,
  688.                             desc = L["Mouse click to track quest"],
  689.                             type = "select",
  690.                             order = 64,
  691.                             values = dicKeybinds,
  692.                             get = function() return db.ClickBinds.TrackQuest end,
  693.                             set = function(info, value)
  694.                                 db.ClickBinds.TrackQuest = value
  695.                                 QuestTracker:UpdateClickBindings();
  696.                                 QuestTracker:UpdateMinion()
  697.                             end,
  698.                         },
  699.                         LinkQuestClick = {
  700.                             name = L["Link Quest:"],
  701.                             desc = L["Mouse click to link quest in chat"],
  702.                             type = "select",
  703.                             order = 65,
  704.                             values = dicKeybinds,
  705.                             get = function() return db.ClickBinds.LinkQuest end,
  706.                             set = function(info, value)
  707.                                 db.ClickBinds.LinkQuest = value
  708.                                 QuestTracker:UpdateClickBindings();
  709.                                 QuestTracker:UpdateMinion()
  710.                             end,
  711.                         },
  712.                         HideShowQuestClick = {
  713.                             name = L["Hide/Show Quest:"],
  714.                             desc = L["Mouse click to show/hide quest"],
  715.                             type = "select",
  716.                             order = 66,
  717.                             values = dicKeybinds,
  718.                             get = function() return db.ClickBinds.HideShowQuest end,
  719.                             set = function(info, value)
  720.                                 db.ClickBinds.HideShowQuest = value
  721.                                 QuestTracker:UpdateClickBindings();
  722.                                 QuestTracker:UpdateMinion()
  723.                             end,
  724.                         },
  725.                         FindGroupClick = {
  726.                             name = L["Find/Start Quest Group:"],
  727.                             desc = L["Mouse click to find or start a group for the quest"],
  728.                             type = "select",
  729.                             order = 67,
  730.                             values = dicKeybinds,
  731.                             get = function() return db.ClickBinds.FindGroup end,
  732.                             set = function(info, value)
  733.                                 db.ClickBinds.FindGroup = value
  734.                                 QuestTracker:UpdateClickBindings();
  735.                                 QuestTracker:UpdateMinion()
  736.                             end,
  737.                         },
  738.                     },                     
  739.                 },
  740.                 Zones = {
  741.                     name = L["Zones"],
  742.                     type = "group",
  743.                     order = 2,
  744.                     args = {
  745.                         AllowHiddenQuestsToggle = {
  746.                             name = L["Allow quests to be hidden"],
  747.                             desc = L["Allows quests to be hidden and enables the show/hide button"],
  748.                             type = "toggle",
  749.                             width = "full",
  750.                             get = function() return db.ZonesAndQuests.AllowHiddenQuests end,
  751.                             set = function()
  752.                                 db.ZonesAndQuests.AllowHiddenQuests = not db.ZonesAndQuests.AllowHiddenQuests
  753.                                 QuestTracker:doHiddenQuestsUpdate()
  754.                                 QuestTracker:UpdateMinion()
  755.                             end,
  756.                             order = 3,
  757.                         },
  758.                         AllowHiddenHeadersToggle = {
  759.                             name = L["Zone headers hide when all contained quests are hidden"],
  760.                             desc = L["Makes zone headers hide when all contained quests are hidden"],
  761.                             type = "toggle",
  762.                             disabled = function() return not db.ZonesAndQuests.AllowHiddenQuests end,
  763.                             width = "full",
  764.                             get = function() return db.ZonesAndQuests.QuestHeadersHideWhenEmpty end,
  765.                             set = function()
  766.                                 db.ZonesAndQuests.QuestHeadersHideWhenEmpty = not db.ZonesAndQuests.QuestHeadersHideWhenEmpty
  767.                                 QuestTracker:UpdateMinion()
  768.                             end,
  769.                             order = 4,
  770.                         },     
  771.                         AllowHiddenCountOnZonesToggle = {
  772.                             name = L["Display count of hidden quest in each zone"],
  773.                             desc = L["Displays a count of the hidden quests in each zone on the zone header"],
  774.                             type = "toggle",
  775.                             disabled = function() return not db.ZonesAndQuests.AllowHiddenQuests end,
  776.                             width = "full",
  777.                             get = function() return db.ZonesAndQuests.ShowHiddenCountOnZones end,
  778.                             set = function()
  779.                                 db.ZonesAndQuests.ShowHiddenCountOnZones = not db.ZonesAndQuests.ShowHiddenCountOnZones
  780.                                 QuestTracker:UpdateMinion()
  781.                             end,
  782.                             order = 5,
  783.                         },
  784.                         ExpandOnEnterToggle = {
  785.                             name = L["Auto expand zones on enter"],
  786.                             desc = L["Automatically expands zone headers when you enter the zone"],
  787.                             type = "toggle",
  788.                             get = function() return db.ZonesAndQuests.ExpandOnEnter end,
  789.                             set = function()
  790.                                 db.ZonesAndQuests.ExpandOnEnter = not db.ZonesAndQuests.ExpandOnEnter
  791.                                 QuestTracker:doHandleZoneChange()
  792.                             end,
  793.                             order = 22,
  794.                         }, 
  795.                         CollapseOnLeaveToggle = {
  796.                             name = L["Auto collapse zones on exit"],
  797.                             desc = L["Automatically collapses zone headers when you exit the zone"],
  798.                             type = "toggle",
  799.                             get = function() return db.ZonesAndQuests.CollapseOnLeave end,
  800.                             set = function()
  801.                                 db.ZonesAndQuests.CollapseOnLeave = not db.ZonesAndQuests.CollapseOnLeave
  802.                                 QuestTracker:doHandleZoneChange()
  803.                             end,
  804.                             order = 23,
  805.                         }, 
  806.                         HideZoneHeadersToggle = {
  807.                             name = L["Hide Zone Headers"],
  808.                             desc = L["Hides all zone headers and just displays quests. Note: Does not expand zone headers for you"],
  809.                             type = "toggle",
  810.                             get = function() return db.ZonesAndQuests.HideZoneHeaders end,
  811.                             set = function()
  812.                                 db.ZonesAndQuests.HideZoneHeaders = not db.ZonesAndQuests.HideZoneHeaders
  813.                                 QuestTracker:UpdateMinion()
  814.                             end,
  815.                             order = 28,
  816.                         },
  817.                        
  818.                     }
  819.                 },
  820.                 Quests = {
  821.                     name = QUESTS_LABEL,
  822.                     type = "group",
  823.                     order = 3,
  824.                     args = {
  825.                         ShowQuestLevelsToggle = {
  826.                             name = L["Display level in Quest Title"],
  827.                             desc = L["Displays the level of the quest in the title"],
  828.                             type = "toggle",
  829.                             get = function() return db.ZonesAndQuests.ShowQuestLevels end,
  830.                             set = function()
  831.                                 db.ZonesAndQuests.ShowQuestLevels = not db.ZonesAndQuests.ShowQuestLevels
  832.                                 QuestTracker:UpdateMinion()
  833.                             end,
  834.                             order = 6,
  835.                         },
  836.                         ShowQuestPOIsToggle = {
  837.                             name = L["Display POI Tag in Quest Title"],
  838.                             desc = L["Displays the POI Tag used on the world map for in the title"],
  839.                             type = "toggle",
  840.                             get = function() return db.ZonesAndQuests.DisplayPOITag end,
  841.                             set = function()
  842.                                 db.ZonesAndQuests.DisplayPOITag = not db.ZonesAndQuests.DisplayPOITag
  843.                                 QuestTracker:UpdateMinion()
  844.                             end,
  845.                             order = 7,
  846.                         },
  847.                         DisplayQuestIDInTooltipToggle = {
  848.                             name = L["Show Quest Ids in Tooltip"],
  849.                             desc = L["Displays the Id of the quest in the tooltip"],
  850.                             type = "toggle",
  851.                             width = "full",
  852.                             get = function() return db.ZonesAndQuests.DisplayQuestIDInTooltip end,
  853.                             set = function()
  854.                                 db.ZonesAndQuests.DisplayQuestIDInTooltip = not db.ZonesAndQuests.DisplayQuestIDInTooltip
  855.                                 QuestTracker:UpdateMinion()
  856.                             end,
  857.                             order = 8,
  858.                         },
  859.                         QuestTagsLengthSelect = {
  860.                             name = L["Quest Tag Length:"],
  861.                             desc = L["The length of the quest tags (d, p, g5, ELITE etc)"],
  862.                             type = "select",
  863.                             order = 9,
  864.                             values = dicQuestTagsLength,
  865.                             get = function() return db.ZonesAndQuests.QuestTagsLength end,
  866.                             set = function(info, value)
  867.                                 db.ZonesAndQuests.QuestTagsLength = value
  868.                                 QuestTracker:UpdateMinion()
  869.                             end,
  870.                         },
  871.                         QuestSortOrderSelect = {
  872.                             name = L["Quest Sort Order:"],
  873.                             desc = L["The sort order of quests, within each zone"],
  874.                             type = "select",
  875.                             order = 10,
  876.                             values = dicQuestSortOrder,
  877.                             get = function() return db.ZonesAndQuests.QuestSortOrder end,
  878.                             set = function(info, value)
  879.                                 db.ZonesAndQuests.QuestSortOrder = value
  880.                                 QuestTracker:UpdateMinion()
  881.                             end,
  882.                         },
  883.  
  884.                         HeaderQuestsSpacer = {
  885.                             name = "",
  886.                             width = "full",
  887.                             type = "description",
  888.                             order = 40,
  889.                         },
  890.                         HeaderQuests = {
  891.                             name = L["Quest Settings"],
  892.                             type = "header",
  893.                             order = 41,
  894.                         },
  895.  
  896.                         HideCompletedQuestsToggle = {
  897.                             name = L["Hide Completed quests/goto Quests"],
  898.                             desc = L["Automatically hides completed quests on completion. Also hides goto quests"],
  899.                             width = "full",
  900.                             type = "toggle",
  901.                             get = function() return db.ZonesAndQuests.HideCompletedQuests end,
  902.                             set = function()
  903.                                 db.ZonesAndQuests.HideCompletedQuests = not db.ZonesAndQuests.HideCompletedQuests
  904.                                 QuestTracker:UpdateMinion()
  905.                             end,
  906.                             order = 43,
  907.                         },
  908.                         QuestTitleIndent = {
  909.                             order = 48,
  910.                             name = L["Quest Text Indent"],
  911.                             desc = L["Controls the level of indentation for the quest text"],
  912.                             type = "range",
  913.                             min = 0, max = 20, step = 1,
  914.                             isPercent = false,
  915.                             get = function() return db.ZonesAndQuests.QuestTitleIndent end,
  916.                             set = function(info, value)
  917.                                 db.ZonesAndQuests.QuestTitleIndent = value
  918.                                 QuestTracker:UpdateMinion()
  919.                             end,
  920.                         },
  921.                         QuestAfterPadding = {
  922.                             order = 49,
  923.                             name = L["Padding After Quest"],
  924.                             desc = L["The amount of extra padding after a quest before the next text."],
  925.                             type = "range",
  926.                             min = 0, max = 20, step = 1,
  927.                             isPercent = false,
  928.                             get = function() return db.ZonesAndQuests.QuestAfterPadding end,
  929.                             set = function(info, value)
  930.                                 db.ZonesAndQuests.QuestAfterPadding = value
  931.                                 QuestTracker:UpdateMinion()
  932.                             end,
  933.                         },                 
  934.                        
  935.                         HeaderObjectivesSpacer = {
  936.                             name = "",
  937.                             width = "full",
  938.                             type = "description",
  939.                             order = 80,
  940.                         },
  941.                         HeaderObjectives = {
  942.                             name = L["Objective Settings"],
  943.                             type = "header",
  944.                             order = 81,
  945.                         },
  946.                         HideCompletedObjectivesToggle = {
  947.                             name = L["Hide completed objectives"],
  948.                             desc = L["Shows/Hides completed objectives"],
  949.                             type = "toggle",
  950.                             width = "full",
  951.                             get = function() return db.ZonesAndQuests.HideCompletedObjectives end,
  952.                             set = function()
  953.                                 db.ZonesAndQuests.HideCompletedObjectives = not db.ZonesAndQuests.HideCompletedObjectives
  954.                                 QuestTracker:UpdateMinion()
  955.                             end,
  956.                             order = 82,
  957.                         },
  958.                         ShowDescWhenNoObjectivesToggle = {
  959.                             name = L["Display quest description if not objectives"],
  960.                             desc = L["Displays a quests description if there are no objectives available"],
  961.                             type = "toggle",
  962.                             width = "full",
  963.                             get = function() return db.ZonesAndQuests.ShowDescWhenNoObjectives end,
  964.                             set = function()
  965.                                 db.ZonesAndQuests.ShowDescWhenNoObjectives = not db.ZonesAndQuests.ShowDescWhenNoObjectives
  966.                                 QuestTracker:UpdateMinion()
  967.                             end,
  968.                             order = 83,
  969.                         }, 
  970.                         ObjectivesIndent = {
  971.                             order = 88,
  972.                             name = L["Objective Text Indent"],
  973.                             desc = L["Controls the level of indentation for the Objective text"],
  974.                             type = "range",
  975.                             min = 0, max = 20, step = 1,
  976.                             isPercent = false,
  977.                             get = function() return db.ZonesAndQuests.ObjectivesIndent end,
  978.                             set = function(info, value)
  979.                                 db.ZonesAndQuests.ObjectivesIndent = value
  980.                                 QuestTracker:UpdateMinion()
  981.                             end,
  982.                         }, 
  983.                         ObjectivesTextLast = {
  984.                             order = 89,
  985.                             name = L["Objective Text Last"],
  986.                             desc = L["Display the text of an objective after numbers"],
  987.                             type = "toggle",
  988.                             width = "full",
  989.                             get = function() return db.ZonesAndQuests.ObjectiveTextLast end,
  990.                             set = function()
  991.                                 db.ZonesAndQuests.ObjectiveTextLast = not db.ZonesAndQuests.ObjectiveTextLast
  992.                                 QuestTracker:UpdateMinion()
  993.                             end,
  994.                         },     
  995.  
  996.                     }
  997.                 },
  998.                 QuestItems = {
  999.                     name = L["Quest Items"],
  1000.                     type = "group",
  1001.                     order = 4,
  1002.                     args = {
  1003.                         HeaderItemButtons = {
  1004.                             name = L["Item Button Settings"],
  1005.                             type = "header",
  1006.                             order = 71,
  1007.                         },
  1008.                         ShowItemButtonsToggle = {
  1009.                             name = L["Show quest item buttons"],
  1010.                             desc = L["Shows/Hides the quest item buttons"],
  1011.                             type = "toggle",
  1012.                             get = function() return db.ShowItemButtons end,
  1013.                             set = function()
  1014.                                 db.ShowItemButtons = not db.ShowItemButtons
  1015.                                 QuestTracker:UpdateMinion()
  1016.                             end,
  1017.                             order = 72,
  1018.                         },
  1019.                         ItemsAndTooltipsRightToggle = {
  1020.                             name = L["Display items and tooltips on right"],
  1021.                             desc = L["Moves items and tooltips to the right"],
  1022.                             type = "toggle",
  1023.                             get = function() return db.MoveTooltipsRight end,
  1024.                             set = function()
  1025.                                 db.MoveTooltipsRight = not db.MoveTooltipsRight
  1026.                                 QuestTracker:UpdateMinion()
  1027.                             end,
  1028.                             order = 73,
  1029.                         },
  1030.                         IndentItemButtonsToggle = {
  1031.                             name = L["Indent item buttons inside tracker"],
  1032.                             desc = L["Indents the item buttons into the quest tracker so they are flush with zone headers"],
  1033.                             type = "toggle",
  1034.                             width = "full",
  1035.                             disabled = function() return (db.MoveTooltipsRight == true or db.ShowItemButtons == false) end,
  1036.                             get = function() return db.IndentItemButtons end,
  1037.                             set = function()
  1038.                                 db.IndentItemButtons = not db.IndentItemButtons
  1039.                                 QuestTracker:UpdateMinion()
  1040.                             end,
  1041.                             order = 74,
  1042.                         },
  1043.                         IndentItemButtonQuestsOnlyToggle = {
  1044.                             name = L["Indent only quests with item buttons"],
  1045.                             desc = L["Only indents a quest if the quest has an item button"],
  1046.                             type = "toggle",
  1047.                             width = "full",
  1048.                             disabled = function() return (db.MoveTooltipsRight == true or db.IndentItemButtons == false or db.ShowItemButtons == false) end,
  1049.                             get = function() return db.IndentItemButtonQuestsOnly end,
  1050.                             set = function()
  1051.                                 db.IndentItemButtonQuestsOnly = not db.IndentItemButtonQuestsOnly
  1052.                                 QuestTracker:UpdateMinion()
  1053.                             end,
  1054.                             order = 75,
  1055.                         },
  1056.                         HideItemButtonsForCompletedQuestsToggle = {
  1057.                             name = L["Hide Item Buttons for completed quests"],
  1058.                             desc = L["Hides the quests item button once the quest is complete"],
  1059.                             type = "toggle",
  1060.                             width = "full",
  1061.                             disabled = function() return not(db.ShowItemButtons) end,
  1062.                             get = function() return db.HideItemButtonsForCompletedQuests end,
  1063.                             set = function()
  1064.                                 db.HideItemButtonsForCompletedQuests = not db.HideItemButtonsForCompletedQuests
  1065.                                 QuestTracker:UpdateMinion()
  1066.                             end,
  1067.                             order = 76,
  1068.                         },     
  1069.                         ShowCurrentSmartQuestItemToggle = {
  1070.                             name = L["Show Smart Item Button"],
  1071.                             desc = L["Shows the Smart Item Button. This isn't needed for the keybind"],
  1072.                             type = "toggle",
  1073.                             width = "full",
  1074.                             disabled = function() return not(db.ShowItemButtons) end,
  1075.                             get = function() return db.ShowCurrentSmartQuestItem end,
  1076.                             set = function()
  1077.                                 db.ShowCurrentSmartQuestItem = not db.ShowCurrentSmartQuestItem
  1078.                                 QuestTracker:UpdateMinion()
  1079.                             end,
  1080.                             order = 77,
  1081.                         }, 
  1082.                         ItemButtonsSizeSlider = {
  1083.                             order = 80,
  1084.                             name = L["Item Button Size"],
  1085.                             desc = L["Controls the size of the Item Buttons."],
  1086.                             type = "range",
  1087.                             disabled = function() return not(db.ShowItemButtons) end,
  1088.                             min = 0.5, max = 2, step = 0.05,
  1089.                             isPercent = false,
  1090.                             get = function() return db.ItemButtonScale end,
  1091.                             set = function(info, value)
  1092.                                 db.ItemButtonScale = value
  1093.                                 QuestTracker:UpdateMinion()
  1094.                             end,
  1095.                         },                                         
  1096.                     }
  1097.                 },
  1098.                 Fonts = {
  1099.                     name = L["Fonts"],
  1100.                     type = "group",
  1101.                     order = 5,
  1102.                     args = {
  1103.                         HeaderTitleFont = {
  1104.                             name = L["Info Text Font Settings"],
  1105.                             type = "header",
  1106.                             order = 41,
  1107.                         },
  1108.                         MinionTitleFontSelect = {
  1109.                             type = "select", dialogControl = 'LSM30_Font',
  1110.                             order = 42,
  1111.                             name = L["Font"],
  1112.                             desc = L["The font used for this element"],
  1113.                             values = AceGUIWidgetLSMlists.font,
  1114.                             get = function() return db.Fonts.MinionTitleFont end,
  1115.                             set = function(info, value)
  1116.                                 db.Fonts.MinionTitleFont = value
  1117.                                 QuestTracker:UpdateMinion()
  1118.                             end,
  1119.                         },
  1120.                         MinionTitleFontOutlineSelect = {
  1121.                             name = L["Font Outline"],
  1122.                             desc = L["The outline that this font will use"],
  1123.                             type = "select",
  1124.                             order = 43,
  1125.                             values = dicOutlines,
  1126.                             get = function() return db.Fonts.MinionTitleFontOutline end,
  1127.                             set = function(info, value)
  1128.                                 db.Fonts.MinionTitleFontOutline = value
  1129.                                 QuestTracker:UpdateMinion()
  1130.                             end,
  1131.                         },
  1132.                         MinionTitleFontShadowedToggle = {
  1133.                             name = L["Shadow Text"],
  1134.                             desc = L["Shows/Hides text shadowing"],
  1135.                             type = "toggle",
  1136.                             get = function() return db.Fonts.MinionTitleFontShadowed end,
  1137.                             set = function()
  1138.                                 db.Fonts.MinionTitleFontShadowed = not db.Fonts.MinionTitleFontShadowed
  1139.                                 QuestTracker:UpdateMinion()
  1140.                             end,
  1141.                             order = 44,
  1142.                         },
  1143.                         MinionTitleFontSizeSelect = {
  1144.                             order = 45,
  1145.                             name = FONT_SIZE,
  1146.                             desc = L["Controls the font size this font"],
  1147.                             type = "range",
  1148.                             min = 8, max = 20, step = 1,
  1149.                             isPercent = false,
  1150.                             get = function() return db.Fonts.MinionTitleFontSize end,
  1151.                             set = function(info, value)
  1152.                                 db.Fonts.MinionTitleFontSize = value
  1153.                                 QuestTracker:UpdateMinion()
  1154.                             end,
  1155.                         },
  1156.                         MinionTitleFontLineSpacing = {
  1157.                             order = 46,
  1158.                             name = L["Font Line Spacing"],
  1159.                             desc = L["Controls the spacing below each line of this font"],
  1160.                             type = "range",
  1161.                             min = 0, max = 20, step = 1,
  1162.                             isPercent = false,
  1163.                             get = function() return db.Fonts.MinionTitleFontLineSpacing end,
  1164.                             set = function(info, value)
  1165.                                 db.Fonts.MinionTitleFontLineSpacing = value
  1166.                                 QuestTracker:UpdateMinion()
  1167.                             end,
  1168.                         },
  1169.  
  1170.                         ZonesFontSpacer = {
  1171.                             name = "",
  1172.                             width = "full",
  1173.                             type = "description",
  1174.                             order = 50,
  1175.                         },
  1176.                         ZonesFontHeader = {
  1177.                             name = L["Zone Font Settings"],
  1178.                             type = "header",
  1179.                             order = 51,
  1180.                         },
  1181.                         ZonesFontSelect = {
  1182.                             type = "select", dialogControl = 'LSM30_Font',
  1183.                             order = 52,
  1184.                             name = L["Font"],
  1185.                             desc = L["The font used for this element"],
  1186.                             values = AceGUIWidgetLSMlists.font,
  1187.                             get = function() return db.Fonts.HeaderFont end,
  1188.                             set = function(info, value)
  1189.                                 db.Fonts.HeaderFont = value
  1190.                                 QuestTracker:UpdateMinion()
  1191.                             end,
  1192.                         },
  1193.                         ZonesFontOutlineSelect = {
  1194.                             name = L["Font Outline"],
  1195.                             desc = L["The outline that this font will use"],
  1196.                             type = "select",
  1197.                             order = 53,
  1198.                             values = dicOutlines,
  1199.                             get = function() return db.Fonts.HeaderFontOutline end,
  1200.                             set = function(info, value)
  1201.                                 db.Fonts.HeaderFontOutline = value
  1202.                                 QuestTracker:UpdateMinion()
  1203.                             end,
  1204.                         },
  1205.                         ZonesFontShadowedToggle = {
  1206.                             name = L["Shadow Text"],
  1207.                             desc = L["Shows/Hides text shadowing"],
  1208.                             type = "toggle",
  1209.                             get = function() return db.Fonts.HeaderFontShadowed end,
  1210.                             set = function()
  1211.                                 db.Fonts.HeaderFontShadowed = not db.Fonts.HeaderFontShadowed
  1212.                                 QuestTracker:UpdateMinion()
  1213.                             end,
  1214.                             order = 54,
  1215.                         },
  1216.                         ZonesFontSize = {
  1217.                             order = 55,
  1218.                             name = FONT_SIZE,
  1219.                             desc = L["Controls the font size this font"],
  1220.                             type = "range",
  1221.                             min = 8, max = 20, step = 1,
  1222.                             isPercent = false,
  1223.                             get = function() return db.Fonts.HeaderFontSize end,
  1224.                             set = function(info, value)
  1225.                                 db.Fonts.HeaderFontSize = value
  1226.                                 QuestTracker:UpdateMinion()
  1227.                             end,
  1228.                         },
  1229.                         ZonesFontLineSpacing = {
  1230.                             order = 56,
  1231.                             name = L["Font Line Spacing"],
  1232.                             desc = L["Controls the spacing below each line of this font"],
  1233.                             type = "range",
  1234.                             min = 0, max = 20, step = 1,
  1235.                             isPercent = false,
  1236.                             get = function() return db.Fonts.HeaderFontLineSpacing end,
  1237.                             set = function(info, value)
  1238.                                 db.Fonts.HeaderFontLineSpacing = value
  1239.                                 QuestTracker:UpdateMinion()
  1240.                             end,
  1241.                         },
  1242.                         QuestFontSpacer = {
  1243.                             name = "",
  1244.                             width = "full",
  1245.                             type = "description",
  1246.                             order = 60,
  1247.                         },
  1248.                         QuestFontHeader = {
  1249.                             name = L["Quest Font Settings"],
  1250.                             type = "header",
  1251.                             order = 61,
  1252.                         },
  1253.                         QuestFontSelect = {
  1254.                             type = "select", dialogControl = 'LSM30_Font',
  1255.                             order = 62,
  1256.                             name = L["Font"],
  1257.                             desc = L["The font used for this element"],
  1258.                             values = AceGUIWidgetLSMlists.font,
  1259.                             get = function() return db.Fonts.QuestFont end,
  1260.                             set = function(info, value)
  1261.                                 db.Fonts.QuestFont = value
  1262.                                 QuestTracker:UpdateMinion()
  1263.                             end,
  1264.                         },
  1265.                         QuestFontOutlineSelect = {
  1266.                             name = L["Font Outline"],
  1267.                             desc = L["The outline that this font will use"],
  1268.                             type = "select",
  1269.                             order = 63,
  1270.                             values = dicOutlines,
  1271.                             get = function() return db.Fonts.QuestFontOutline end,
  1272.                             set = function(info, value)
  1273.                                 db.Fonts.QuestFontOutline = value
  1274.                                 QuestTracker:UpdateMinion()
  1275.                             end,
  1276.                         },
  1277.                         QuestFontShadowedToggle = {
  1278.                             name = L["Shadow Text"],
  1279.                             desc = L["Shows/Hides text shadowing"],
  1280.                             type = "toggle",
  1281.                             get = function() return db.Fonts.QuestFontShadowed end,
  1282.                             set = function()
  1283.                                 db.Fonts.QuestFontShadowed = not db.Fonts.QuestFontShadowed
  1284.                                 QuestTracker:UpdateMinion()
  1285.                             end,
  1286.                             order = 64,
  1287.                         },
  1288.                         QuestFontSize = {
  1289.                             order = 65,
  1290.                             name = FONT_SIZE,
  1291.                             desc = L["Controls the font size this font"],
  1292.                             type = "range",
  1293.                             min = 8, max = 20, step = 1,
  1294.                             isPercent = false,
  1295.                             get = function() return db.Fonts.QuestFontSize end,
  1296.                             set = function(info, value)
  1297.                                 db.Fonts.QuestFontSize = value
  1298.                                 QuestTracker:UpdateMinion()
  1299.                             end,
  1300.                         },
  1301.                         QuestFontLineSpacing = {
  1302.                             order = 66,
  1303.                             name = L["Font Line Spacing"],
  1304.                             desc = L["Controls the spacing below each line of this font"],
  1305.                             type = "range",
  1306.                             min = 0, max = 20, step = 1,
  1307.                             isPercent = false,
  1308.                             get = function() return db.Fonts.QuestFontLineSpacing end,
  1309.                             set = function(info, value)
  1310.                                 db.Fonts.QuestFontLineSpacing = value
  1311.                                 QuestTracker:UpdateMinion()
  1312.                             end,
  1313.                         },
  1314.                        
  1315.                         ObjectiveFontSpacer = {
  1316.                             name = "",
  1317.                             width = "full",
  1318.                             type = "description",
  1319.                             order = 70,
  1320.                         },
  1321.                         ObjectiveFontHeader = {
  1322.                             name = L["Objective Font Settings"],
  1323.                             type = "header",
  1324.                             order = 71,
  1325.                         },
  1326.                         ObjectiveFontSelect = {
  1327.                             type = "select", dialogControl = 'LSM30_Font',
  1328.                             order = 72,
  1329.                             name = L["Font"],
  1330.                             desc = L["The font used for this element"],
  1331.                             values = AceGUIWidgetLSMlists.font,
  1332.                             get = function() return db.Fonts.ObjectiveFont end,
  1333.                             set = function(info, value)
  1334.                                 db.Fonts.ObjectiveFont = value
  1335.                                 QuestTracker:UpdateMinion()
  1336.                             end,
  1337.                         },
  1338.                         ObjectiveFontOutlineSelect = {
  1339.                             name = L["Font Outline"],
  1340.                             desc = L["The outline that this font will use"],
  1341.                             type = "select",
  1342.                             order = 73,
  1343.                             values = dicOutlines,
  1344.                             get = function() return db.Fonts.ObjectiveFontOutline end,
  1345.                             set = function(info, value)
  1346.                                 db.Fonts.ObjectiveFontOutline = value
  1347.                                 QuestTracker:UpdateMinion()
  1348.                             end,
  1349.                         },
  1350.                         ObjectiveFontShadowedToggle = {
  1351.                             name = L["Shadow Text"],
  1352.                             desc = L["Shows/Hides text shadowing"],
  1353.                             type = "toggle",
  1354.                             get = function() return db.Fonts.ObjectiveFontShadowed end,
  1355.                             set = function()
  1356.                                 db.Fonts.ObjectiveFontShadowed = not db.Fonts.ObjectiveFontShadowed
  1357.                                 QuestTracker:UpdateMinion()
  1358.                             end,
  1359.                             order = 74,
  1360.                         }, 
  1361.                         ObjectiveFontSize = {
  1362.                             order = 75,
  1363.                             name = FONT_SIZE,
  1364.                             desc = L["Controls the font size this font"],
  1365.                             type = "range",
  1366.                             min = 8, max = 20, step = 1,
  1367.                             isPercent = false,
  1368.                             get = function() return db.Fonts.ObjectiveFontSize end,
  1369.                             set = function(info, value)
  1370.                                 db.Fonts.ObjectiveFontSize = value
  1371.                                 QuestTracker:UpdateMinion()
  1372.                             end,
  1373.                         },
  1374.                         ObjectiveFontLineSpacing = {
  1375.                             order = 76,
  1376.                             name = L["Font Line Spacing"],
  1377.                             desc = L["Controls the spacing below each line of this font"],
  1378.                             type = "range",
  1379.                             min = 0, max = 20, step = 1,
  1380.                             isPercent = false,
  1381.                             get = function() return db.Fonts.ObjectiveFontLineSpacing end,
  1382.                             set = function(info, value)
  1383.                                 db.Fonts.ObjectiveFontLineSpacing = value
  1384.                                 QuestTracker:UpdateMinion()
  1385.                             end,
  1386.                         },
  1387.                     }
  1388.                 },
  1389.                 Colours = {
  1390.                     name = L["Colours"],
  1391.                     type = "group",
  1392.                     order = 6,
  1393.                     args = {
  1394.                         InfoTextColour = {
  1395.                             name = L["Info Text"],
  1396.                             desc = L["Sets the color of the info text (Title bar, # of quests hidden etc)"],
  1397.                             type = "color",
  1398.                             hasAlpha = true,
  1399.                             get = function() return db.Colours.InfoColour.r, db.Colours.InfoColour.g, db.Colours.InfoColour.b, db.Colours.InfoColour.a end,
  1400.                             set = function(_,r,g,b,a)
  1401.                                     db.Colours.InfoColour.r = r
  1402.                                     db.Colours.InfoColour.g = g
  1403.                                     db.Colours.InfoColour.b = b
  1404.                                     db.Colours.InfoColour.a = a
  1405.                                     QuestTracker:HandleColourChanges()
  1406.                                 end,
  1407.                             order = 2,
  1408.                         },
  1409.                         MinionBackGroundColour = {
  1410.                             name = L["Background Colour"],
  1411.                             desc = L["Sets the color of the minions background"],
  1412.                             type = "color",
  1413.                             hasAlpha = true,
  1414.                             get = function() return db.Colours.MinionBackGroundColour.r, db.Colours.MinionBackGroundColour.g, db.Colours.MinionBackGroundColour.b, db.Colours.MinionBackGroundColour.a end,
  1415.                             set = function(_,r,g,b,a)
  1416.                                     db.Colours.MinionBackGroundColour.r = r
  1417.                                     db.Colours.MinionBackGroundColour.g = g
  1418.                                     db.Colours.MinionBackGroundColour.b = b
  1419.                                     db.Colours.MinionBackGroundColour.a = a
  1420.                                     QuestTracker:HandleColourChanges()
  1421.                                 end,
  1422.                             order = 4,
  1423.                         },
  1424.                         MinionBorderColour = {
  1425.                             name = L["Border Colour"],
  1426.                             desc = L["Sets the color of the minions border"],
  1427.                             type = "color",
  1428.                             hasAlpha = true,
  1429.                             get = function() return db.Colours.MinionBorderColour.r, db.Colours.MinionBorderColour.g, db.Colours.MinionBorderColour.b, db.Colours.MinionBorderColour.a end,
  1430.                             set = function(_,r,g,b,a)
  1431.                                     db.Colours.MinionBorderColour.r = r
  1432.                                     db.Colours.MinionBorderColour.g = g
  1433.                                     db.Colours.MinionBorderColour.b = b
  1434.                                     db.Colours.MinionBorderColour.a = a
  1435.                                     QuestTracker:HandleColourChanges()
  1436.                                 end,
  1437.                             order = 5,
  1438.                         },
  1439.                         ShowHideButtonColourSelect = {
  1440.                             name = L["Toggle Hidden Colour"],
  1441.                             desc = L["Sets the color of the 'Toggle Hidden Quests' buttons inactive state"],
  1442.                             type = "color",
  1443.                             hasAlpha = true,
  1444.                             get = function() return db.Colours.ShowHideButtonColour.r, db.Colours.ShowHideButtonColour.g, db.Colours.ShowHideButtonColour.b, db.Colours.ShowHideButtonColour.a end,
  1445.                             set = function(_,r,g,b,a)
  1446.                                     db.Colours.ShowHideButtonColour.r = r
  1447.                                     db.Colours.ShowHideButtonColour.g = g
  1448.                                     db.Colours.ShowHideButtonColour.b = b
  1449.                                     db.Colours.ShowHideButtonColour.a = a
  1450.                                     QuestTracker:HandleColourChanges()
  1451.                                 end,
  1452.                             order = 6,
  1453.                         },
  1454.                         ShowHideButtonBorderColourSelect = {
  1455.                             name = L["Toggle Hidden Border Colour"],
  1456.                             desc = L["Sets the color of the 'Toggle Hidden Quests' buttons border"],
  1457.                             type = "color",
  1458.                             hasAlpha = true,
  1459.                             get = function() return db.Colours.ShowHideButtonBorderColour.r, db.Colours.ShowHideButtonBorderColour.g, db.Colours.ShowHideButtonBorderColour.b, db.Colours.ShowHideButtonBorderColour.a end,
  1460.                             set = function(_,r,g,b,a)
  1461.                                     db.Colours.ShowHideButtonBorderColour.r = r
  1462.                                     db.Colours.ShowHideButtonBorderColour.g = g
  1463.                                     db.Colours.ShowHideButtonBorderColour.b = b
  1464.                                     db.Colours.ShowHideButtonBorderColour.a = a
  1465.                                     QuestTracker:HandleColourChanges()
  1466.                                 end,
  1467.                             order = 7,
  1468.                         },         
  1469.                         ShowHideButtonActiveColourSelect = {
  1470.                             name = L["Toggle Hidden Colour (Active)"],
  1471.                             desc = L["Sets the color of the 'Toggle Hidden Quests' buttons active state"],
  1472.                             type = "color",
  1473.                             hasAlpha = true,
  1474.                             get = function() return db.Colours.ShowHideButtonActiveColour.r, db.Colours.ShowHideButtonActiveColour.g, db.Colours.ShowHideButtonActiveColour.b, db.Colours.ShowHideButtonActiveColour.a end,
  1475.                             set = function(_,r,g,b,a)
  1476.                                     db.Colours.ShowHideButtonActiveColour.r = r
  1477.                                     db.Colours.ShowHideButtonActiveColour.g = g
  1478.                                     db.Colours.ShowHideButtonActiveColour.b = b
  1479.                                     db.Colours.ShowHideButtonActiveColour.a = a
  1480.                                     QuestTracker:HandleColourChanges()
  1481.                                 end,
  1482.                             order = 8,
  1483.                         },         
  1484.                         HeaderColourSettings = {
  1485.                             name = L["Colour Settings"],
  1486.                             type = "header",
  1487.                             order = 10,
  1488.                         },
  1489.                         QuestLevelColouringSelect = {
  1490.                             name = L["Colour quest levels by:"],
  1491.                             desc = L["The setting by which the colour of quest levels are determined"],
  1492.                             type = "select",
  1493.                             order = 11,
  1494.                             values = dicQuestTitleColourOptions,
  1495.                             get = function() return db.ZonesAndQuests.QuestLevelColouringSetting end,
  1496.                             set = function(info, value)
  1497.                                 db.ZonesAndQuests.QuestLevelColouringSetting = value
  1498.                                 QuestTracker:UpdateMinion()
  1499.                             end,
  1500.                         },
  1501.                         QuestTitleColouringSelect = {
  1502.                             name = L["Colour quest titles by:"],
  1503.                             desc = L["The setting by which the colour of quest titles is determined"],
  1504.                             type = "select",
  1505.                             order = 12,
  1506.                             values = dicQuestTitleColourOptions,
  1507.                             get = function() return db.ZonesAndQuests.QuestTitleColouringSetting end,
  1508.                             set = function(info, value)
  1509.                                 db.ZonesAndQuests.QuestTitleColouringSetting = value
  1510.                                 QuestTracker:UpdateMinion()
  1511.                             end,
  1512.                         },
  1513.                         ObjectiveTitleColouringSelect = {
  1514.                             name = L["Colour objective title text by:"],
  1515.                             desc = L["The setting by which the colour of objective title is determined"],
  1516.                             type = "select",
  1517.                             order = 13,
  1518.                             values = dicObjectiveColourOptions,
  1519.                             get = function() return db.ZonesAndQuests.ObjectiveTitleColouringSetting end,
  1520.                             set = function(info, value)
  1521.                                 db.ZonesAndQuests.ObjectiveTitleColouringSetting = value
  1522.                                 QuestTracker:UpdateMinion()
  1523.                             end,
  1524.                         },
  1525.                         ObjectiveStatusColouringSelect = {
  1526.                             name = L["Colour objective status text by:"],
  1527.                             desc = L["The setting by which the colour of objective statuses is determined"],
  1528.                             type = "select",
  1529.                             order = 14,
  1530.                             values = dicObjectiveColourOptions,
  1531.                             get = function() return db.ZonesAndQuests.ObjectiveStatusColouringSetting end,
  1532.                             set = function(info, value)
  1533.                                 db.ZonesAndQuests.ObjectiveStatusColouringSetting = value
  1534.                                 QuestTracker:UpdateMinion()
  1535.                             end,
  1536.                         },
  1537.                         HeaderMainColoursSpacer = {
  1538.                             name = "",
  1539.                             width = "full",
  1540.                             type = "description",
  1541.                             order = 20,
  1542.                         },
  1543.                         HeaderMainColours = {
  1544.                             name = L["Main Colours"],
  1545.                             type = "header",
  1546.                             order = 21,
  1547.                         },
  1548.                         HeaderColour = {
  1549.                             name = L["Zone Header Colour"],
  1550.                             desc = L["Sets the color for the header of each zone"],
  1551.                             type = "color",
  1552.                             hasAlpha = true,
  1553.                             get = function() return db.Colours.HeaderColour.r, db.Colours.HeaderColour.g, db.Colours.HeaderColour.b, db.Colours.HeaderColour.a end,
  1554.                             set = function(_,r,g,b,a)
  1555.                                     db.Colours.HeaderColour.r = r
  1556.                                     db.Colours.HeaderColour.g = g
  1557.                                     db.Colours.HeaderColour.b = b
  1558.                                     db.Colours.HeaderColour.a = a
  1559.                                     QuestTracker:HandleColourChanges()
  1560.                                 end,
  1561.                             order = 24,
  1562.                         },
  1563.                         QuestLevelColour = {
  1564.                             name = L["Quest levels"],
  1565.                             desc = L["Sets the color for the quest levels if custom colouring is on"],
  1566.                             type = "color",
  1567.                             disabled = function() return not(db.ZonesAndQuests.QuestLevelColouringSetting == "Custom") end,
  1568.                             hasAlpha = true,
  1569.                             get = function() return db.Colours.QuestLevelColour.r, db.Colours.QuestLevelColour.g, db.Colours.QuestLevelColour.b, db.Colours.QuestLevelColour.a end,
  1570.                             set = function(_,r,g,b,a)
  1571.                                     db.Colours.QuestLevelColour.r = r
  1572.                                     db.Colours.QuestLevelColour.g = g
  1573.                                     db.Colours.QuestLevelColour.b = b
  1574.                                     db.Colours.QuestLevelColour.a = a
  1575.                                     QuestTracker:HandleColourChanges()
  1576.                                 end,
  1577.                             order = 25,
  1578.                         },
  1579.                         QuestTitleColour = {
  1580.                             name = L["Quest titles"],
  1581.                             desc = L["Sets the color for the quest titles if colouring by level is off"],
  1582.                             type = "color",
  1583.                             disabled = function() return not(db.ZonesAndQuests.QuestTitleColouringSetting == "Custom") end,
  1584.                             hasAlpha = true,
  1585.                             get = function() return db.Colours.QuestTitleColour.r, db.Colours.QuestTitleColour.g, db.Colours.QuestTitleColour.b, db.Colours.QuestTitleColour.a end,
  1586.                             set = function(_,r,g,b,a)
  1587.                                     db.Colours.QuestTitleColour.r = r
  1588.                                     db.Colours.QuestTitleColour.g = g
  1589.                                     db.Colours.QuestTitleColour.b = b
  1590.                                     db.Colours.QuestTitleColour.a = a
  1591.                                     QuestTracker:HandleColourChanges()
  1592.                                 end,
  1593.                             order = 26,
  1594.                         },
  1595.                         NoObjectivesColour = {
  1596.                             name = L["No objectives description colour"],
  1597.                             desc = L["Sets the color for the description displayed when there is no quest objectives"],
  1598.                             type = "color",
  1599.                             hasAlpha = true,
  1600.                             get = function() return db.Colours.ObjectiveDescColour.r, db.Colours.ObjectiveDescColour.g, db.Colours.ObjectiveDescColour.b, db.Colours.ObjectiveDescColour.a end,
  1601.                             set = function(_,r,g,b,a)
  1602.                                     db.Colours.ObjectiveDescColour.r = r
  1603.                                     db.Colours.ObjectiveDescColour.g = g
  1604.                                     db.Colours.ObjectiveDescColour.b = b
  1605.                                     db.Colours.ObjectiveDescColour.a = a
  1606.                                     QuestTracker:HandleColourChanges()
  1607.                                 end,
  1608.                             order = 27,
  1609.                         },
  1610.                         ObjectiveTitleColourPicker = {
  1611.                             name = L["Objective title colour"],
  1612.                             desc = L["Sets the custom color for objectives titles"],
  1613.                             type = "color",
  1614.                             disabled = function() return not(db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Custom") end,
  1615.                             hasAlpha = true,
  1616.                             get = function() return db.Colours.ObjectiveTitleColour.r, db.Colours.ObjectiveTitleColour.g, db.Colours.ObjectiveTitleColour.b, db.Colours.ObjectiveTitleColour.a end,
  1617.                             set = function(_,r,g,b,a)
  1618.                                     db.Colours.ObjectiveTitleColour.r = r
  1619.                                     db.Colours.ObjectiveTitleColour.g = g
  1620.                                     db.Colours.ObjectiveTitleColour.b = b
  1621.                                     db.Colours.ObjectiveTitleColour.a = a
  1622.                                     QuestTracker:HandleColourChanges()
  1623.                                 end,
  1624.                             order = 28,
  1625.                         },
  1626.                         ObjectiveStatusColourPicker = {
  1627.                             name = L["Objective status colour"],
  1628.                             desc = L["Sets the custom color for objectives statuses"],
  1629.                             type = "color",
  1630.                             disabled = function() return not(db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Custom") end,
  1631.                             hasAlpha = true,
  1632.                             get = function() return db.Colours.ObjectiveStatusColour.r, db.Colours.ObjectiveStatusColour.g, db.Colours.ObjectiveStatusColour.b, db.Colours.ObjectiveStatusColour.a end,
  1633.                             set = function(_,r,g,b,a)
  1634.                                     db.Colours.ObjectiveStatusColour.r = r
  1635.                                     db.Colours.ObjectiveStatusColour.g = g
  1636.                                     db.Colours.ObjectiveStatusColour.b = b
  1637.                                     db.Colours.ObjectiveStatusColour.a = a
  1638.                                     QuestTracker:HandleColourChanges()
  1639.                                 end,
  1640.                             order = 29,
  1641.                         },
  1642.                         QuestStatusFailedColourPicker = {
  1643.                             name = L["Quest failed tag"],
  1644.                             desc = L["Sets the color for the quest failed tag"],
  1645.                             type = "color",
  1646.                             hasAlpha = true,
  1647.                             get = function() return db.Colours.QuestStatusFailedColour.r, db.Colours.QuestStatusFailedColour.g, db.Colours.QuestStatusFailedColour.b, db.Colours.QuestStatusFailedColour.a end,
  1648.                             set = function(_,r,g,b,a)
  1649.                                     db.Colours.QuestStatusFailedColour.r = r
  1650.                                     db.Colours.QuestStatusFailedColour.g = g
  1651.                                     db.Colours.QuestStatusFailedColour.b = b
  1652.                                     db.Colours.QuestStatusFailedColour.a = a
  1653.                                     QuestTracker:HandleColourChanges()
  1654.                                 end,
  1655.                             order = 30,
  1656.                         },                             
  1657.                         QuestStatusDoneColourPicker = {
  1658.                             name = L["Quest done tag"],
  1659.                             desc = L["Sets the color for the quest done tag"],
  1660.                             type = "color",
  1661.                             hasAlpha = true,
  1662.                             get = function() return db.Colours.QuestStatusDoneColour.r, db.Colours.QuestStatusDoneColour.g, db.Colours.QuestStatusDoneColour.b, db.Colours.QuestStatusDoneColour.a end,
  1663.                             set = function(_,r,g,b,a)
  1664.                                     db.Colours.QuestStatusDoneColour.r = r
  1665.                                     db.Colours.QuestStatusDoneColour.g = g
  1666.                                     db.Colours.QuestStatusDoneColour.b = b
  1667.                                     db.Colours.QuestStatusDoneColour.a = a
  1668.                                     QuestTracker:HandleColourChanges()
  1669.                                 end,
  1670.                             order = 31,
  1671.                         },                                 
  1672.                         QuestStatusGotoColourPicker = {
  1673.                             name = L["Quest goto Tag"],
  1674.                             desc = L["Sets the color for the quest goto tag"],
  1675.                             type = "color",
  1676.                             hasAlpha = true,
  1677.                             get = function() return db.Colours.QuestStatusGotoColour.r, db.Colours.QuestStatusGotoColour.g, db.Colours.QuestStatusGotoColour.b, db.Colours.QuestStatusGotoColour.a end,
  1678.                             set = function(_,r,g,b,a)
  1679.                                     db.Colours.QuestStatusGotoColour.r = r
  1680.                                     db.Colours.QuestStatusGotoColour.g = g
  1681.                                     db.Colours.QuestStatusGotoColour.b = b
  1682.                                     db.Colours.QuestStatusGotoColour.a = a
  1683.                                     QuestTracker:HandleColourChanges()
  1684.                                 end,
  1685.                             order = 32,
  1686.                         },     
  1687.                         ObjectiveTooltipTextColourColourPicker = {
  1688.                             name = L["Objective Tooltip Text"],
  1689.                             desc = L["Sets the color for the objective text in the quests tooltip"],
  1690.                             type = "color",
  1691.                             hasAlpha = true,
  1692.                             get = function() return db.Colours.ObjectiveTooltipTextColour.r, db.Colours.ObjectiveTooltipTextColour.g, db.Colours.ObjectiveTooltipTextColour.b, db.Colours.ObjectiveTooltipTextColour.a end,
  1693.                             set = function(_,r,g,b,a)
  1694.                                     db.Colours.ObjectiveTooltipTextColour.r = r
  1695.                                     db.Colours.ObjectiveTooltipTextColour.g = g
  1696.                                     db.Colours.ObjectiveTooltipTextColour.b = b
  1697.                                     db.Colours.ObjectiveTooltipTextColour.a = a
  1698.                                     QuestTracker:HandleColourChanges()
  1699.                                 end,
  1700.                             order = 33,
  1701.                         },     
  1702.                         HeaderGradualColoursSpacer = {
  1703.                             name = "",
  1704.                             width = "full",
  1705.                             type = "description",
  1706.                             order = 50,
  1707.                         },
  1708.                         HeaderGradualColours = {
  1709.                             name = L["Gradual objective Colours"],
  1710.                             type = "header",
  1711.                             order = 51,
  1712.                         },
  1713.                         Objective00Colour = {
  1714.                             name = L["Unstarted(0%) objective colour"],
  1715.                             desc = L["Sets the color for objectives that are 0% complete"],
  1716.                             type = "color",
  1717.                             hasAlpha = true,
  1718.                             get = function() return db.Colours.Objective00Colour.r, db.Colours.Objective00Colour.g, db.Colours.Objective00Colour.b, db.Colours.Objective00Colour.a end,
  1719.                             set = function(_,r,g,b,a)
  1720.                                     db.Colours.Objective00Colour.r = r
  1721.                                     db.Colours.Objective00Colour.g = g
  1722.                                     db.Colours.Objective00Colour.b = b
  1723.                                     db.Colours.Objective00Colour.a = a
  1724.                                     QuestTracker:HandleColourChanges()
  1725.                                 end,
  1726.                             order = 52,
  1727.                         },
  1728.                         Objective00PlusColour = {
  1729.                             name = L["1-25% Complete objective colour"],
  1730.                             desc = L["Sets the color for objectives that are above 0% complete"],
  1731.                             type = "color",
  1732.                             hasAlpha = true,
  1733.                             get = function() return db.Colours.Objective00PlusColour.r, db.Colours.Objective00PlusColour.g, db.Colours.Objective00PlusColour.b, db.Colours.Objective00PlusColour.a end,
  1734.                             set = function(_,r,g,b,a)
  1735.                                     db.Colours.Objective00PlusColour.r = r
  1736.                                     db.Colours.Objective00PlusColour.g = g
  1737.                                     db.Colours.Objective00PlusColour.b = b
  1738.                                     db.Colours.Objective00PlusColour.a = a
  1739.                                     QuestTracker:HandleColourChanges()
  1740.                                 end,
  1741.                             order = 53,
  1742.                         },
  1743.                         Objective25PlusColour = {
  1744.                             name = L["25% Complete objective colour"],
  1745.                             desc = L["Sets the color for objectives that are above 25% complete"],
  1746.                             type = "color",
  1747.                             disabled = function() return not(db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Completion" or db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Completion" or db.ZonesAndQuests.QuestLevelColouringSetting == "Completion" or db.ZonesAndQuests.QuestTitleColouringSetting == "Completion") end,
  1748.                             hasAlpha = true,
  1749.                             get = function() return db.Colours.Objective25PlusColour.r, db.Colours.Objective25PlusColour.g, db.Colours.Objective25PlusColour.b, db.Colours.Objective25PlusColour.a end,
  1750.                             set = function(_,r,g,b,a)
  1751.                                     db.Colours.Objective25PlusColour.r = r
  1752.                                     db.Colours.Objective25PlusColour.g = g
  1753.                                     db.Colours.Objective25PlusColour.b = b
  1754.                                     db.Colours.Objective25PlusColour.a = a
  1755.                                     QuestTracker:HandleColourChanges()
  1756.                                 end,
  1757.                             order = 54,
  1758.                         },
  1759.                         Objective50PlusColour = {
  1760.                             name = L["50% Complete objective colour"],
  1761.                             desc = L["Sets the color for objectives that are above 50% complete"],
  1762.                             type = "color",
  1763.                             disabled = function() return not(db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Completion" or db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Completion" or db.ZonesAndQuests.QuestLevelColouringSetting == "Completion" or db.ZonesAndQuests.QuestTitleColouringSetting == "Completion") end,
  1764.                             hasAlpha = false,
  1765.                             get = function() return db.Colours.Objective50PlusColour.r, db.Colours.Objective50PlusColour.g, db.Colours.Objective50PlusColour.b, db.Colours.Objective50PlusColour.a end,
  1766.                             set = function(_,r,g,b,a)
  1767.                                     db.Colours.Objective50PlusColour.r = r
  1768.                                     db.Colours.Objective50PlusColour.g = g
  1769.                                     db.Colours.Objective50PlusColour.b = b
  1770.                                     db.Colours.Objective50PlusColour.a = a
  1771.                                     QuestTracker:HandleColourChanges()
  1772.                                 end,
  1773.                             order = 55,
  1774.                         },
  1775.                         Objective75PlusColour = {
  1776.                             name = L["75% Complete objective colour"],
  1777.                             desc = L["Sets the color for objectives that are above 75% complete"],
  1778.                             type = "color",
  1779.                             disabled = function() return not(db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Completion" or db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Completion" or db.ZonesAndQuests.QuestLevelColouringSetting == "Completion" or db.ZonesAndQuests.QuestTitleColouringSetting == "Completion") end,
  1780.                             hasAlpha = true,
  1781.                             get = function() return db.Colours.Objective75PlusColour.r, db.Colours.Objective75PlusColour.g, db.Colours.Objective75PlusColour.b, db.Colours.Objective75PlusColour.a end,
  1782.                             set = function(_,r,g,b,a)
  1783.                                     db.Colours.Objective75PlusColour.r = r
  1784.                                     db.Colours.Objective75PlusColour.g = g
  1785.                                     db.Colours.Objective75PlusColour.b = b
  1786.                                     db.Colours.Objective75PlusColour.a = a
  1787.                                     QuestTracker:HandleColourChanges()
  1788.                                 end,
  1789.                             order = 56,
  1790.                         },
  1791.                         DoneObjectiveColour = {
  1792.                             name = L["Complete objective colour"],
  1793.                             desc = L["Sets the color for the complete objectives"],
  1794.                             type = "color",
  1795.                             hasAlpha = true,
  1796.                             get = function() return db.Colours.ObjectiveDoneColour.r, db.Colours.ObjectiveDoneColour.g, db.Colours.ObjectiveDoneColour.b, db.Colours.ObjectiveDoneColour.a end,
  1797.                             set = function(_,r,g,b,a)
  1798.                                     db.Colours.ObjectiveDoneColour.r = r
  1799.                                     db.Colours.ObjectiveDoneColour.g = g
  1800.                                     db.Colours.ObjectiveDoneColour.b = b
  1801.                                     db.Colours.ObjectiveDoneColour.a = a
  1802.                                     QuestTracker:HandleColourChanges()
  1803.                                 end,
  1804.                             order = 57,
  1805.                         },
  1806.                         spacerdoneundone1 = {
  1807.                             name = "",
  1808.                             type = "description",
  1809.                             order = 58,
  1810.                         },
  1811.                         UndoneColour = {
  1812.                             name = L["Undone colour"],
  1813.                             desc = L["Sets the colour for undone items"],
  1814.                             type = "color",
  1815.                             hasAlpha = true,
  1816.                             get = function() return db.Colours.UndoneColour.r, db.Colours.UndoneColour.g, db.Colours.UndoneColour.b, db.Colours.UndoneColour.a end,
  1817.                             set = function(_,r,g,b,a)
  1818.                                     db.Colours.UndoneColour.r = r
  1819.                                     db.Colours.UndoneColour.g = g
  1820.                                     db.Colours.UndoneColour.b = b
  1821.                                     db.Colours.UndoneColour.a = a
  1822.                                     QuestTracker:HandleColourChanges()
  1823.                                 end,
  1824.                             order = 59,
  1825.                         },
  1826.                         DoneColour = {
  1827.                             name = L["Done colour"],
  1828.                             desc = L["Sets the colour for done items"],
  1829.                             type = "color",
  1830.                             hasAlpha = true,
  1831.                             get = function() return db.Colours.DoneColour.r, db.Colours.DoneColour.g, db.Colours.DoneColour.b, db.Colours.DoneColour.a end,
  1832.                             set = function(_,r,g,b,a)
  1833.                                     db.Colours.DoneColour.r = r
  1834.                                     db.Colours.DoneColour.g = g
  1835.                                     db.Colours.DoneColour.b = b
  1836.                                     db.Colours.DoneColour.a = a
  1837.                                     QuestTracker:HandleColourChanges()
  1838.                                 end,
  1839.                             order = 60,
  1840.                         },
  1841.  
  1842.                         StatusBarSpacerHeader = {
  1843.                             name = L["Status Bar Settings"],
  1844.                             type = "header",
  1845.                             order = 70,
  1846.                         },                     
  1847.                         StatusBarFillColour = {
  1848.                             name = L["Bar Fill Colour"],
  1849.                             desc = L["Sets the color for the completed part status bars"],
  1850.                             type = "color",
  1851.                             hasAlpha = true,
  1852.                             get = function() return db.Colours.StatusBarFillColour.r, db.Colours.StatusBarFillColour.g, db.Colours.StatusBarFillColour.b, db.Colours.StatusBarFillColour.a end,
  1853.                             set = function(_,r,g,b,a)
  1854.                                     db.Colours.StatusBarFillColour.r = r
  1855.                                     db.Colours.StatusBarFillColour.g = g
  1856.                                     db.Colours.StatusBarFillColour.b = b
  1857.                                     db.Colours.StatusBarFillColour.a = a
  1858.                                     QuestTracker:UpdateMinion()
  1859.                                 end,
  1860.                             order = 71,
  1861.                         },
  1862.                         StatusBarBackColour = {
  1863.                             name = L["Bar Back Colour"],
  1864.                             desc = L["Sets the color for the un-completed part of status bars"],
  1865.                             type = "color",
  1866.                             hasAlpha = true,
  1867.                             get = function() return db.Colours.StatusBarBackColour.r, db.Colours.StatusBarBackColour.g, db.Colours.StatusBarBackColour.b, db.Colours.StatusBarBackColour.a end,
  1868.                             set = function(_,r,g,b,a)
  1869.                                     db.Colours.StatusBarBackColour.r = r
  1870.                                     db.Colours.StatusBarBackColour.g = g
  1871.                                     db.Colours.StatusBarBackColour.b = b
  1872.                                     db.Colours.StatusBarBackColour.a = a
  1873.                                     QuestTracker:UpdateMinion()
  1874.                                 end,
  1875.                             order = 72,
  1876.                         },
  1877.                     }
  1878.                 },
  1879.                 Notifications = {
  1880.                     name = L["Notifications"],
  1881.                     type = "group",
  1882.                     childGroups = "tab",
  1883.                     order = 7,
  1884.                     args = {
  1885.                         Notifications2 = {
  1886.                             name = L["Notifications"],
  1887.                             type = "group",
  1888.                             order = 7,
  1889.                             args = {
  1890.                                 NotificationSettingsHeader = {
  1891.                                     name = L["Text Notification Settings"],
  1892.                                     type = "header",
  1893.                                     order = 1,
  1894.                                 },
  1895.                                 SuppressBlizzardNotificationsToggle = {
  1896.                                     name = L["Suppress blizzard notification messages"],
  1897.                                     desc = L["Suppresses the notification messages sent by blizzard to the UIErrors Frame for progress updates"],
  1898.                                     type = "toggle",
  1899.                                     width = "full",
  1900.                                     get = function() return db.Notifications.SuppressBlizzardNotifications end,
  1901.                                     set = function()
  1902.                                         db.Notifications.SuppressBlizzardNotifications = not db.Notifications.SuppressBlizzardNotifications
  1903.                                     end,
  1904.                                     order = 2,
  1905.                                 },
  1906.                                 LibSinkHeaderSpacer = {
  1907.                                     name = "",
  1908.                                     width = "full",
  1909.                                     type = "description",
  1910.                                     order = 20,
  1911.                                 },
  1912.                                 LibSinkHeader = {
  1913.                                     name = L["LibSink Options"],
  1914.                                     type = "header",
  1915.                                     order = 21,
  1916.                                 },
  1917.                                 LibSinkObjectivesSmallHeader = {
  1918.                                     name = "|cff00ff00" .. L["Objective Notifications"] .. "|r",
  1919.                                     width = "full",
  1920.                                     type = "description",
  1921.                                     order = 22,
  1922.                                 },
  1923.                                 LibSinkObjectiveNotificationsToggle = {
  1924.                                     name = L["Use for Objective notification messages"],
  1925.                                     desc = L["Displays objective notification messages using LibSink"],
  1926.                                     type = "toggle",
  1927.                                     get = function() return db.Notifications.LibSinkObjectiveNotifications end,
  1928.                                     set = function()
  1929.                                         db.Notifications.LibSinkObjectiveNotifications = not db.Notifications.LibSinkObjectiveNotifications
  1930.                                     end,
  1931.                                     order = 23,
  1932.                                 },
  1933.                                 DisplayQuestOnObjectiveNotificationsToggle = {
  1934.                                     name = L["Display Quest Name"],
  1935.                                     desc = L["Adds the quest name to objective notification messages"],
  1936.                                     type = "toggle",
  1937.                                     disabled = function() return not(db.Notifications.LibSinkObjectiveNotifications) end,
  1938.                                     get = function() return db.Notifications.DisplayQuestOnObjectiveNotifications end,
  1939.                                     set = function()
  1940.                                         db.Notifications.DisplayQuestOnObjectiveNotifications = not db.Notifications.DisplayQuestOnObjectiveNotifications
  1941.                                     end,
  1942.                                     order = 24,
  1943.                                 },
  1944.                                 LibSinkQuestsSmallHeader = {
  1945.                                     name = "|cff00ff00" .. L["Quest Notifications"] .. "|r",
  1946.                                     width = "full",
  1947.                                     type = "description",
  1948.                                     order = 26,
  1949.                                 },
  1950.                                 ShowQuestCompletesAndFailsToggle = {
  1951.                                     name = L["Output Complete and Failed messages for quests"],
  1952.                                     desc = L["Displays '<Quest Title> (Complete)' etc messages once you finish all objectives"],
  1953.                                     type = "toggle",
  1954.                                     width = "full",
  1955.                                     get = function() return db.Notifications.ShowQuestCompletesAndFails end,
  1956.                                     set = function()
  1957.                                         db.Notifications.ShowQuestCompletesAndFails = not db.Notifications.ShowQuestCompletesAndFails
  1958.                                     end,
  1959.                                     order = 27,
  1960.                                 },
  1961.                                 ShowMessageOnPickingUpQuestItemToggle = {
  1962.                                     name = L["Show message when picking up an item that starts a quest"],
  1963.                                     desc = L["Displays a message through LibSink when you pick up an item that starts a quest"],
  1964.                                     type = "toggle",
  1965.                                     width = "full",
  1966.                                     get = function() return db.Notifications.ShowMessageOnPickingUpQuestItem end,
  1967.                                     set = function()
  1968.                                         db.Notifications.ShowMessageOnPickingUpQuestItem = not db.Notifications.ShowMessageOnPickingUpQuestItem
  1969.                                     end,
  1970.                                     order = 28,
  1971.                                 },
  1972.                                 DisableToastsToggle = {
  1973.                                     name = L["Disable Toast popups on completing bonus objectives"],
  1974.                                     desc = L["Disables the Toasts which appear upon completing a bonus objective"],
  1975.                                     type = "toggle",
  1976.                                     width = "full",
  1977.                                     get = function() return db.Notifications.DisableToasts end,
  1978.                                     set = function()
  1979.                                         db.Notifications.DisableToasts = not db.Notifications.DisableToasts
  1980.                                     end,
  1981.                                     order = 29,
  1982.                                 },
  1983.  
  1984.                                 LibSinkColourSmallHeaderSpacer = {
  1985.                                     name = "",
  1986.                                     width = "full",
  1987.                                     type = "description",
  1988.                                     order = 50,
  1989.                                 },
  1990.                                 LibSinkColourSmallHeader = {
  1991.                                     name = "|cff00ff00" .. L["Colour Settings"] .. "|r",
  1992.                                     width = "full",
  1993.                                     type = "description",
  1994.                                     order = 51,
  1995.                                 },
  1996.                                 NotificationsColourSelect = {
  1997.                                     name = L["Lib Sink Colour by:"],
  1998.                                     desc = L["The setting by which the colour of notification messages are determined"],
  1999.                                     type = "select",
  2000.                                     order = 52,
  2001.                                     values = dicNotificationColourOptions,
  2002.                                     get = function() return db.Notifications.LibSinkColourSetting end,
  2003.                                     set = function(info, value)
  2004.                                         db.Notifications.LibSinkColourSetting = value
  2005.                                     end,
  2006.                                 },
  2007.                                 NotificationsColour = {
  2008.                                     name = L["Notifications"],
  2009.                                     desc = L["Sets the color for notifications"],
  2010.                                     type = "color",
  2011.                                     hasAlpha = true,
  2012.                                     get = function() return db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b, db.Colours.NotificationsColour.a end,
  2013.                                     set = function(_,r,g,b,a)
  2014.                                             db.Colours.NotificationsColour.r = r
  2015.                                             db.Colours.NotificationsColour.g = g
  2016.                                             db.Colours.NotificationsColour.b = b
  2017.                                             db.Colours.NotificationsColour.a = a
  2018.                                         end,
  2019.                                     order = 53,
  2020.                                 },
  2021.                                 SoundSettingsHeaderSpacer = {
  2022.                                     name = "",
  2023.                                     width = "full",
  2024.                                     type = "description",
  2025.                                     order = 80,
  2026.                                 },
  2027.                                 SoundSettingsHeader = {
  2028.                                     name = SOUND_OPTIONS,
  2029.                                     type = "header",
  2030.                                     order = 81,
  2031.                                 },
  2032.                                 ObjectiveDoneSoundSelect = {
  2033.                                     name = L["Objective Completion Sound"],
  2034.                                     desc = L["The sound played when you complete a quests objective"],
  2035.                                     type = "select",
  2036.                                     dialogControl = "LSM30_Sound",
  2037.                                     values = AceGUIWidgetLSMlists.sound,
  2038.                                     get = function() return db.Notifications.ObjectiveDoneSound end,
  2039.                                     set = function(info, value)
  2040.                                         db.Notifications.ObjectiveDoneSound = value
  2041.                                     end,
  2042.                                     order = 82
  2043.                                 },
  2044.                                 ObjectiveChangedSoundSelect = {
  2045.                                     name = L["Objective Changed Sound"],
  2046.                                     desc = L["The sound played when a quests objective changes"],
  2047.                                     type = "select",
  2048.                                     dialogControl = "LSM30_Sound",
  2049.                                     values = AceGUIWidgetLSMlists.sound,
  2050.                                     get = function() return db.Notifications.ObjectiveChangedSound end,
  2051.                                     set = function(info, value)
  2052.                                         db.Notifications.ObjectiveChangedSound = value
  2053.                                     end,
  2054.                                     order = 83
  2055.                                 },
  2056.                                 QuestDoneSoundSelect = {
  2057.                                     name = L["Quest Completion Sound"],
  2058.                                     desc = L["The sound played when you complete a quest (Finish all objectives)"],
  2059.                                     type = "select",
  2060.                                     dialogControl = "LSM30_Sound",
  2061.                                     values = AceGUIWidgetLSMlists.sound,
  2062.                                     get = function() return db.Notifications.QuestDoneSound end,
  2063.                                     set = function(info, value)
  2064.                                         db.Notifications.QuestDoneSound = value
  2065.                                     end,
  2066.                                     order = 84
  2067.                                 },
  2068.                                 QuestItemFoundSoundSelect = {
  2069.                                     name = L["Quest Starting Item Picked Up"],
  2070.                                     desc = L["The sound played when you pickup an item that starts a quest"],
  2071.                                     type = "select",
  2072.                                     dialogControl = "LSM30_Sound",
  2073.                                     values = AceGUIWidgetLSMlists.sound,
  2074.                                     get = function() return db.Notifications.QuestItemFoundSound end,
  2075.                                     set = function(info, value)
  2076.                                         db.Notifications.QuestItemFoundSound = value
  2077.                                     end,
  2078.                                     order = 85
  2079.                                 },
  2080.                             }
  2081.                         },
  2082.                         NotificationsOptions = QuestTracker:GetSinkAce3OptionsDataTable(),
  2083.                     }
  2084.                 },
  2085.             }
  2086.         }
  2087.     end
  2088.  
  2089.     return options
  2090. end
  2091.  
  2092.  
  2093.  
  2094. --Sorting
  2095. local function spairs(t, order)
  2096.     -- collect the keys
  2097.     local keys = {}
  2098.     for k in pairs(t) do keys[#keys+1] = k end
  2099.  
  2100.     -- if order function given, sort by it by passing the table and keys a, b,
  2101.     -- otherwise just sort the keys
  2102.     if order then
  2103.         table.sort(keys, function(a,b) return order(t, a, b) end)
  2104.     else
  2105.         table.sort(keys)
  2106.     end
  2107.  
  2108.     -- return the iterator function
  2109.     local i = 0
  2110.     return function()
  2111.         i = i + 1
  2112.         if keys[i] then
  2113.             return keys[i], t[keys[i]]
  2114.         end
  2115.     end
  2116. end
  2117.  
  2118. local function zoneSortChooser(t)
  2119.     return spairs(t, function(t,a,b)
  2120.         if (a and b) then
  2121.             if (t[a].ID and t[a].ID == campaignZoneID) then
  2122.                 return true
  2123.             end
  2124.             if (t[b].ID and t[b].ID == campaignZoneID) then
  2125.                 return false
  2126.             end
  2127.             if (t[a].IsFakeZone == true or t[b].IsFakeZone == true) then
  2128.                 return tostring(t[b].IsFakeZone) > tostring(t[a].IsFakeZone)           
  2129.             else
  2130.                 return b > a
  2131.             end
  2132.         end
  2133.     end);
  2134. end
  2135.  
  2136. local function questSortChooser(t)
  2137.     if (db.ZonesAndQuests.QuestSortOrder == "Default") then
  2138.         return pairs(t);
  2139.     end
  2140.     if (db.ZonesAndQuests.QuestSortOrder == "Title") then
  2141.         return spairs(t, function(t,a,b)
  2142.             return t[b].Title > t[a].Title
  2143.         end);
  2144.     end
  2145.     if (db.ZonesAndQuests.QuestSortOrder == "Level") then
  2146.         return spairs(t, function(t,a,b)
  2147.             return t[b].Level > t[a].Level
  2148.         end);
  2149.     end
  2150.     if (db.ZonesAndQuests.QuestSortOrder == "POI") then
  2151.         return spairs(t, function(t,a,b)
  2152.             return t[b].POIText > t[a].POIText
  2153.         end);
  2154.     end
  2155.     if (db.ZonesAndQuests.QuestSortOrder == "Proximity") then
  2156.         if (InCombatLockdown()) then
  2157.             return spairs(t, function(t,a,b)
  2158.                 return t[b].LastSortIndex > t[a].LastSortIndex
  2159.             end);
  2160.         end
  2161.         return spairs(t, function(t,a,b)
  2162.             return t[b].Distance > t[a].Distance
  2163.         end);
  2164.     end
  2165.     if (db.ZonesAndQuests.QuestSortOrder == "Completion") then
  2166.         return spairs(t, function(t,a,b)
  2167.             if (t[b].IsComplete == false and t[a].IsComplete == false) then
  2168.                 return t[b].ObjectiveCount < t[a].ObjectiveCount;
  2169.             end
  2170.             return tostring(t[b].IsComplete) > tostring(t[a].IsComplete);
  2171.             --return tostring(t[b].IsComplete) > tostring(t[a].IsComplete)
  2172.         end);
  2173.     end
  2174.     return pairs(t);
  2175. end
  2176.  
  2177.  
  2178. --Classes
  2179. local SQLQuestTimer = {};
  2180. SQLQuestTimer.__index = SQLQuestTimer;
  2181.  
  2182. function SQLQuestTimer:new(duration, elasped)
  2183.     local self = {};
  2184.     setmetatable(self, SQLQuestTimer);
  2185.  
  2186.     self.Duration = duration;
  2187.     self.Elasped = elasped;
  2188.     self.TimeLeft = 0;
  2189.     self.Running = false;
  2190.  
  2191.     self:Start();
  2192.     return self;
  2193. end
  2194.  
  2195. function SQLQuestTimer:Start()
  2196.     self.Running = false;
  2197.     self.TimeLeft = self.Duration;
  2198.     if (self.Duration > self.Elasped) then
  2199.         self.Running = true;
  2200.     end
  2201. end
  2202.  
  2203. function SQLQuestTimer:Stop()
  2204.     self.Duration = 0;
  2205.     self.Elasped = 0;
  2206.     self.Running = false;
  2207.     self.TimeLeft = 0;
  2208. end
  2209.  
  2210. function SQLQuestTimer:Refresh(elasped)
  2211.     self.Elasped = elasped;
  2212.     self.TimeLeft = self.Duration - self.Elasped;
  2213.  
  2214.     if (self.TimeLeft > 0) then
  2215.         self.Running = true;
  2216.     else
  2217.         self.Duration = 0;
  2218.         self.Elasped = 0;
  2219.         self.Running = false;
  2220.         self.TimeLeft = 0;
  2221.     end
  2222. end
  2223.  
  2224. function SQLQuestTimer:Update(elasped)
  2225.     self.Elasped = self.Elasped + elasped;
  2226.     self.TimeLeft = self.Duration - self.Elasped;
  2227.  
  2228.     if (self.TimeLeft > 0) then
  2229.         self.Running = true;
  2230.     else
  2231.         self.Duration = 0;
  2232.         self.Elasped = 0;
  2233.         self.Running = false;
  2234.         self.TimeLeft = 0;
  2235.     end
  2236. end
  2237.  
  2238.  
  2239.  
  2240. local SQLObjective = {};
  2241. SQLObjective.__index = SQLObjective;
  2242.  
  2243. function SQLObjective:new(objectiveIndex, questIndex, questID)
  2244.     local self = {};
  2245.     setmetatable(self, SQLObjective);
  2246.  
  2247.     self.Index = objectiveIndex;
  2248.     self.QuestIndex = questIndex
  2249.     self.QuestID = questID;
  2250.     self.Text = nil;
  2251.     self.Have = nil;
  2252.     self.Need = nil;
  2253.     self.CompletionLevel = 0;
  2254.     self.Type = nil;
  2255.     self.IsComplete = false;
  2256.  
  2257.     self.Changed = false;
  2258.     self._Valid = false;
  2259.  
  2260.     if (self.Index ~= nil and self.QuestIndex ~= nil) then
  2261.         self:Update();
  2262.     end
  2263.  
  2264.     if (self._Valid == true) then
  2265.         self.Changed = false;
  2266.         return self;
  2267.     else
  2268.         return nil;
  2269.     end
  2270. end
  2271.  
  2272. function SQLObjective:Update()
  2273.     self.Changed = false;
  2274.     local text, objectiveType, finished, have, need = GetQuestObjectiveInfo(self.QuestID, self.Index, false);
  2275.    
  2276.  
  2277.    
  2278.     self.Type = objectiveType; 
  2279.  
  2280.     if (finished == true) then
  2281.         if (self.IsComplete == false) then
  2282.             self.Changed = true;   
  2283.         end
  2284.         self.IsComplete = true;
  2285.     else
  2286.         if (self.IsComplete == true) then
  2287.             self.Changed = true;   
  2288.         end
  2289.         self.IsComplete = false;
  2290.     end
  2291.  
  2292.     if (text ~= nil) then
  2293.         self.Text = text;
  2294.         local completionLevel = 0;
  2295.         local intGot = 0;
  2296.         local intNeed = 1;
  2297.        
  2298.         if (self.Type == "reputation") then
  2299.             local y, z, repuationHave, reputationNeed,objectiveDescription  = string.find(self.Text, "(.*)%s*/%s*(%S*)%s*(.*)");
  2300.  
  2301.             if (objectiveDescription == "") then
  2302.                 y, z, objectiveDescription, repuationHave, reputationNeed = string.find(self.Text, "(.*):%s*([-%d]+)/([-%d]+)$");
  2303.             end
  2304.  
  2305.             if (objectiveDescription ~= nil) then
  2306.                 self.Text = objectiveDescription
  2307.             end
  2308.  
  2309.             if (repuationHave == nil) then
  2310.                 have = ""
  2311.             else
  2312.                 have = strtrim(repuationHave)
  2313.             end
  2314.  
  2315.             if (reputationNeed == nil) then
  2316.                 need = ""
  2317.             else
  2318.                 need = strtrim(reputationNeed)
  2319.             end
  2320.  
  2321.             for k, RepInstance in pairs(dicRepLevels) do
  2322.                 if (have == RepInstance["MTitle"] or have == RepInstance["FTitle"]) then
  2323.                     intGot = RepInstance["Value"]
  2324.                 end
  2325.                 if (need == RepInstance["MTitle"] or need == RepInstance["FTitle"]) then
  2326.                     intNeed = RepInstance["Value"]
  2327.                 end
  2328.             end
  2329.             intGot = tonumber(intGot);
  2330.             intNeed = tonumber(intNeed);
  2331.             if not(intGot) then
  2332.                 intGot = 0;
  2333.             end
  2334.             if not(intNeed) then
  2335.                 intNeed = 1;
  2336.             end
  2337.             completionLevel = intGot / intNeed;
  2338.         else
  2339.             local y, z, intGot, intNeeded, objectiveDescription = string.find(self.Text, "([-%d]+)/([-%d]+)%s*(.*)$");
  2340.             if (objectiveDescription == "") then
  2341.                 y, z, objectiveDescription, intGot, intNeeded = string.find(self.Text, "(.*):%s*([-%d]+)/([-%d]+)$");
  2342.             end
  2343.  
  2344.             if (objectiveDescription ~= nil) then
  2345.                 self.Text = objectiveDescription
  2346.             end
  2347.  
  2348.             completionLevel = have / need;
  2349.         end
  2350.  
  2351.         if (self.IsComplete == true) then
  2352.             completionLevel = 1;
  2353.         end
  2354.  
  2355.         if (self.Have ~= have) then
  2356.             local canChange = true;
  2357.             if (self.Have and need) then
  2358.                 if ((tonumber(self.Have) and tonumber(need)) and (tonumber(self.Have) >= tonumber(need))) then
  2359.                     canChange = false; 
  2360.                 end
  2361.             end    
  2362.             if (canChange) then
  2363.                 self.Changed = true;
  2364.             end
  2365.             self.Have = have;
  2366.         end
  2367.  
  2368.         if (self.Need ~= need) then
  2369.             self.Need = need;
  2370.             self.Changed = true;
  2371.         end
  2372.  
  2373.         if (self.CompletionLevel ~= completionLevel) then
  2374.             self.CompletionLevel = completionLevel;
  2375.             self.Changed = true;
  2376.         end
  2377.  
  2378.         self._Valid = true;
  2379.     end
  2380. end
  2381.  
  2382. function SQLObjective:Render()
  2383.     local strObjectiveGradualColour = "|cffffffff"
  2384.     local strObjectiveTitleColourOutput = strObjectiveTitleColour
  2385.     local strObjectiveStatusColourOutput = strObjectiveStatusColour
  2386.     local strOutput ="";
  2387.  
  2388.     -- If somethings uses gradual colours get colour
  2389.     if (db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Completion" or db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Completion") then
  2390.         strObjectiveGradualColour = QuestTracker:GetCompletionColourString(self.CompletionLevel)
  2391.     end
  2392.    
  2393.     -- Decide on quest title colour
  2394.     if (db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Completion") then
  2395.         strObjectiveTitleColourOutput = strObjectiveGradualColour
  2396.     elseif (db.ZonesAndQuests.ObjectiveTitleColouringSetting == "Done/Undone") then
  2397.         if (self.IsComplete == false) then
  2398.             strObjectiveTitleColourOutput = strUndoneColour
  2399.         else
  2400.             strObjectiveTitleColourOutput = strDoneColour
  2401.         end
  2402.     end
  2403.  
  2404.     -- Decide on quest status (0/1 etc) colour
  2405.     if (db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Completion") then
  2406.         strObjectiveStatusColourOutput = strObjectiveGradualColour
  2407.     elseif (db.ZonesAndQuests.ObjectiveStatusColouringSetting == "Done/Undone") then
  2408.         if (self.IsComplete == false) then
  2409.             strObjectiveStatusColourOutput = strUndoneColour
  2410.         else
  2411.             strObjectiveStatusColourOutput = strDoneColour
  2412.         end
  2413.     end            
  2414.    
  2415.    
  2416.     -- Depending on quest type display it in a certain way
  2417.     if (self.Type == nil) then
  2418.         strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r"    
  2419.        
  2420.     elseif (self.Type == "event") then
  2421.         if (self.IsComplete == false) then
  2422.             strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r"
  2423.         else
  2424.             strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r" .. strObjective100Colour .. " (Done)|r"
  2425.         end
  2426.        
  2427.     elseif (self.Type == "log" or self.Type == "progressbar") then
  2428.         strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r"
  2429.        
  2430.     elseif (self.Type == "reputation") then
  2431.         if ((self.Have == 0 and self.Need == 0) or (self.Have == '' and self.Need == '') or (self.Have == nil and self.Need == nil)) then
  2432.             if (self.IsComplete == false) then
  2433.                 strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r"
  2434.             else
  2435.                 strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r" .. strObjective100Colour .. " (Done)|r"
  2436.             end
  2437.         else
  2438.             if (db.ZonesAndQuests.ObjectiveTextLast == true) then
  2439.                 strOutput = strObjectiveStatusColourOutput .. " - "..  self.Have .. " / " .. self.Need .. "|r" .. " " .. strObjectiveTitleColourOutput  .. self.Text .. "|r"
  2440.             else
  2441.                 strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. ": |r" .. strObjectiveStatusColourOutput .. self.Have .. " / " .. self.Need .. "|r"
  2442.             end
  2443.         end                
  2444.     elseif (self.IsComplete == false and self.Have == self.Need) then
  2445.         strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. "|r"
  2446.    
  2447.     else
  2448.         if (db.ZonesAndQuests.ObjectiveTextLast == true) then
  2449.             strOutput = strObjectiveStatusColourOutput .. " - " .. self.Have .. "/" .. self.Need .. "|r" .. strObjectiveTitleColourOutput .. " " .. self.Text .. "|r";
  2450.         else
  2451.             strOutput = strObjectiveTitleColourOutput .. " - " .. self.Text .. ": |r" .. strObjectiveStatusColourOutput .. self.Have .. "/" .. self.Need .. "|r"
  2452.         end
  2453.     end
  2454.    
  2455.     return strOutput;
  2456. end
  2457.  
  2458.  
  2459. local SQLItem = {};
  2460. SQLItem.__index = SQLItem;
  2461.  
  2462. function SQLItem:new(questIndex)
  2463.     local self = {};
  2464.     setmetatable(self, SQLItem);
  2465.  
  2466.     self.QuestIndex = questIndex;
  2467.  
  2468.     self.Link = nil;
  2469.     self.Item = nil;
  2470.     self.Charges = 0;
  2471.     self.ItemID = nil;
  2472.     self.ShowWhenComplete = false;
  2473.     self.Changed = false;
  2474.     self.Valid = false;
  2475.     self.StillValid = true;
  2476.  
  2477.     self:Update();
  2478.  
  2479.     if (self.Valid == true) then
  2480.         self.Changed = true;
  2481.         return self;
  2482.     else
  2483.         return nil;
  2484.     end
  2485. end
  2486.  
  2487. function SQLItem:Update(newIndex)
  2488.     self.Changed = false;
  2489.  
  2490.     if (newIndex) then
  2491.         self.QuestIndex = newIndex;
  2492.     end
  2493.  
  2494.     local link, icon, charges, showItemWhenComplete = GetQuestLogSpecialItemInfo(self.QuestIndex)
  2495.    
  2496.     if (icon ~= nil) then
  2497.         local itemID = link:match("Hitem:(%d+):");
  2498.         if (self.ItemID ~= itemID) then
  2499.             self.ItemID = itemID;
  2500.             self.Changed = true;
  2501.         end
  2502.  
  2503.         if (self.Charges ~= charges) then
  2504.             self.Charges = charges;
  2505.             self.Changed = true;
  2506.         end
  2507.  
  2508.         self.ShowWhenComplete = showItemWhenComplete;
  2509.         self.Link = link;
  2510.         self.Item = icon
  2511.         self.Valid = true;
  2512.     else
  2513.         self.Valid = false;
  2514.     end
  2515. end
  2516.  
  2517.  
  2518. local SQLQuest = {};
  2519. SQLQuest.__index = SQLQuest;
  2520.  
  2521. function SQLQuest:new(questIndex, questID, isWorldQuest)
  2522.     local self = {};
  2523.     setmetatable(self, SQLQuest);
  2524.  
  2525.     self.Index = questIndex;
  2526.     self.ID = questID;
  2527.     self.Title = nil;
  2528.     self.Level = nil;
  2529.     self.SuggestedGroup = nil;
  2530.     self.Frequency = nil;
  2531.    
  2532.     self.HaveLocalPOI = false;
  2533.     self.DisplayQuestID = false;
  2534.     self.IsComplete = false;
  2535.     self.IsFailed = false;
  2536.     self.IsOnMap = false;
  2537.     self.IsTask = false;
  2538.     self.IsWorldQuest = isWorldQuest;
  2539.     self.IsStory = false;
  2540.     self.StartsEvent = false;
  2541.     self.IsHidden = false;
  2542.     self.IsBreadcrumb = false;
  2543.     self.RequiredMoney = 0;
  2544.     self.LastSortIndex = 0;
  2545.  
  2546.     self.Timer = nil;
  2547.  
  2548.     self.TagID = nil;
  2549.     self.TagName = nil;
  2550.     self.QuestItem = nil;
  2551.     self.ObjectiveCount = 0;
  2552.     self.ObjectiveList = {};
  2553.     self.ObjectiveDescription = "";
  2554.     self.CompletionText = "";
  2555.     self.POIText = "";
  2556.     self.Distance = 0;
  2557.     self.ProgressBarPercent = 0;
  2558.     self.HasProgressBar = false;
  2559.     self.DataChanged = true;
  2560.     self.Changed = true;
  2561.     self.Keep = true;
  2562.     self._Valid = false;
  2563.    
  2564.     self._ChangedValid = false;
  2565.     self._CompletionLevel = 0;
  2566.     self._CompletionLevelValid = false;
  2567.     self._FirstUpdate = true;
  2568.  
  2569.  
  2570.     if (self.Index ~= nil) then
  2571.         self:Update();
  2572.     end
  2573.  
  2574.     if (self._Valid == true) then
  2575.         self.Changed = false;
  2576.         self.DataChanged = false;      
  2577.         return self;
  2578.     else
  2579.         return nil;
  2580.     end
  2581. end
  2582.  
  2583. function SQLQuest:Update(newIndex)
  2584.     self.Changed = false;
  2585.     self.DataChanged = false;
  2586.     self.Keep = true;
  2587.     self._CompletionLevelValid = false;
  2588.  
  2589.     if (newIndex) then
  2590.         self.Index = newIndex;
  2591.         for i, objective in ipairs(self.ObjectiveList) do
  2592.             objective.QuestIndex = self.Index;
  2593.         end
  2594.     end
  2595.  
  2596.     if (self.IsWorldQuest) then
  2597.        
  2598.         local isInArea, isOnMap, numObjectives, taskName, displayAsObjective = GetTaskInfo(self.ID);
  2599.         local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(self.ID);
  2600.         self.TagID = tagID;
  2601.         if (isElite) then
  2602.             self.TagID = ELITE
  2603.         end
  2604.         self.TagName = tagName;    
  2605.         self.Index = GetQuestLogIndexByID(self.ID);
  2606.        
  2607.         self.Title = taskName;
  2608.         if (self.Title == nil) then
  2609.             self.Title = UNKNOWN
  2610.         end
  2611.  
  2612.         if (self._FirstUpdate) then
  2613.             self.RequiredMoney = 0;
  2614.             self.ObjectiveDescription = "";
  2615.            
  2616.             self.Level = dicZoneLevels[zoneID] or 120;
  2617.             self.SuggestedGroup = 0;
  2618.             self.Frequency = frequency;
  2619.  
  2620.             if (isOnMap) then
  2621.                 self.IsOnMap = true;
  2622.             end
  2623.            
  2624.             self.IsTask = true;
  2625.         end
  2626.  
  2627.         if not(self.QuestItem) then
  2628.             self.QuestItem = SQLItem:new(self.Index);
  2629.             if (self.QuestItem) then
  2630.                 self.Changed = true;
  2631.                 self.DataChanged = true;
  2632.             end
  2633.         else
  2634.             self.QuestItem:Update(self.Index);
  2635.             if (self.QuestItem.Valid == false) then
  2636.                 self.QuestItem = nil;
  2637.                 self.Changed = true;
  2638.                 self.DataChanged = true;
  2639.             else
  2640.                 if (self.QuestItem.Changed == true) then
  2641.                     self.Changed = true;
  2642.                     self.DataChanged = true;
  2643.                 end
  2644.             end
  2645.         end
  2646.        
  2647.         if (isComplete == nil) then
  2648.             if (self.IsComplete == true or self.IsFailed == true) then
  2649.                 self.Changed = true;
  2650.                 self.DataChanged = true;
  2651.             end
  2652.             self.IsComplete = false;
  2653.             self.IsFailed = false;
  2654.        
  2655.         elseif (isComplete == 1) then
  2656.             if (self.IsComplete == false or self.IsFailed == true) then
  2657.                 self.Changed = true;
  2658.                 self.DataChanged = true;
  2659.  
  2660.                 if (db.ZonesAndQuests.HideCompletedQuests == true and self._FirstUpdate == false) then
  2661.                     self:Hide();
  2662.                 end
  2663.             end
  2664.             self.IsComplete = true;
  2665.             self.IsFailed = false;
  2666.         else
  2667.             if (self.IsComplete == true or self.IsFailed == false) then
  2668.                 self.Changed = true;
  2669.                 self.DataChanged = true;
  2670.             end
  2671.             self.IsComplete = false;
  2672.             self.IsFailed = true;
  2673.         end
  2674.  
  2675.         self.HasProgressBar = false;
  2676.         local tmpObjectives = {}
  2677.         if (numObjectives and (self.ObjectiveCount == 0 or numObjectives ~= self.ObjectiveCount)) then
  2678.             for objectiveIndex = 1, numObjectives, 1 do
  2679.                 local objective = SQLObjective:new(objectiveIndex, self.Index, self.ID);
  2680.                 if (objective) then
  2681.                     tinsert(tmpObjectives, objective);
  2682.                 end
  2683.             end
  2684.         end
  2685.         if (self.ObjectiveCount ~= #tmpObjectives and #tmpObjectives > 0) then
  2686.             self:ClearObjectives();
  2687.             for objectiveIndex = 1, #tmpObjectives, 1 do
  2688.                 local objective = tmpObjectives[objectiveIndex]
  2689.                 self:AddObjective(objective);
  2690.                 if (objective.Type == "progressbar") then
  2691.                     self.HasProgressBar = true;
  2692.                 end
  2693.                 self.Changed = true;
  2694.                 self.DataChanged = true;
  2695.             end
  2696.         else       
  2697.             for i, objective in ipairs(self.ObjectiveList) do
  2698.                 objective:Update();
  2699.                 if (objective.Type == "progressbar") then
  2700.                     self.HasProgressBar = true;
  2701.                 end
  2702.                 if (objective.Changed == true) then
  2703.                     self.Changed = true;
  2704.                     self.DataChanged = true;
  2705.                 end
  2706.             end
  2707.         end
  2708.        
  2709.        
  2710.         if (self.HasProgressBar == true) then
  2711.             self.ProgressBarPercent = GetQuestProgressBarPercent(self.ID);
  2712.         end
  2713.  
  2714.  
  2715.         if (self.ObjectiveCount == 0) then
  2716.             if (db.ZonesAndQuests.HideCompletedQuests == true and self._FirstUpdate == true) then
  2717.                 self:Hide();
  2718.             end
  2719.         end
  2720.  
  2721.         self.POIText = "";
  2722.         for i=0, #tblPOIs, 1 do
  2723.             if (tblPOIs[i] == self.ID) then
  2724.                 if ( self.IsComplete == true or self.ObjectiveCount == 0) then
  2725.                     self.POIText = "?";
  2726.                 else
  2727.                     self.POIText = tostring(i);
  2728.                 end
  2729.             end
  2730.         end
  2731.  
  2732.         self.Distance = 0;
  2733.         self._FirstUpdate = false;
  2734.         self._Valid = true;
  2735.  
  2736.    
  2737.     else   
  2738.         local title, level, suggestedGroup, isHeader, _, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(self.Index); 
  2739.         local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID);
  2740.         self.TagID = tagID;
  2741.         self.TagName = tagName;    
  2742.        
  2743.         self.Title = title;
  2744.         if (self.Title == nil) then
  2745.             self.Title = UNKNOWN
  2746.         end
  2747.  
  2748.         if (self._FirstUpdate) then
  2749.             SelectQuestLogEntry(self.Index);           
  2750.             local _, questObjectives = GetQuestLogQuestText();
  2751.             self.RequiredMoney = GetQuestLogRequiredMoney(self.Index);
  2752.  
  2753.             self.ObjectiveDescription = questObjectives;
  2754.            
  2755.  
  2756.  
  2757.             self.Level = level;
  2758.             self.SuggestedGroup = suggestedGroup;
  2759.             self.Frequency = frequency;
  2760.  
  2761.  
  2762.             if (startEvent) then
  2763.                 self.StartsEvent = true;
  2764.             end
  2765.  
  2766.             if (displayQuestID) then
  2767.                 self.DisplayQuestID = true;
  2768.             end
  2769.  
  2770.             if (isOnMap) then
  2771.                 self.IsOnMap = true;
  2772.             end
  2773.  
  2774.             if (hasLocalPOI) then
  2775.                 self.HaveLocalPOI = true;
  2776.             end
  2777.  
  2778.             if (isTask) then
  2779.                 self.IsTask = true;
  2780.             end
  2781.  
  2782.             if (isStory) then
  2783.                 self.IsStory = true;
  2784.             end
  2785.         end
  2786.         local numObjectives = GetNumQuestLeaderBoards(self.Index);
  2787.  
  2788.  
  2789.         if not(self.QuestItem) then
  2790.             self.QuestItem = SQLItem:new(self.Index);
  2791.             if (self.QuestItem) then
  2792.                 self.Changed = true;
  2793.                 self.DataChanged = true;
  2794.             end
  2795.         else
  2796.             self.QuestItem:Update(self.Index);
  2797.             if (self.QuestItem.Valid == false) then
  2798.                 self.QuestItem = nil;
  2799.                 self.Changed = true;
  2800.                 self.DataChanged = true;
  2801.             else
  2802.                 if (self.QuestItem.Changed == true) then
  2803.                     self.Changed = true;
  2804.                     self.DataChanged = true;
  2805.                 end
  2806.             end
  2807.         end
  2808.        
  2809.         if (self.IsTask ~= true) then
  2810.             local isWatched = IsQuestWatched(self.Index);      
  2811.             if (isWatched == nil) then
  2812.                 if (self.IsHidden == false) then
  2813.                     self:Hide();
  2814.                 end
  2815.             else
  2816.                 if (self.IsHidden == true) then
  2817.                     self:Show();
  2818.                 end
  2819.             end
  2820.         end
  2821.  
  2822.  
  2823.         self.IsBreadcrumb = false;
  2824.         if (not( isComplete and isComplete < 0 )) then
  2825.             if ( numObjectives == 0 and playerMoney >= self.RequiredMoney and not self.StartsEvent) then
  2826.                 if ( self.RequiredMoney == 0 ) then
  2827.                     self.IsBreadcrumb = true;
  2828.                     self.CompletionText = GetQuestLogCompletionText(self.Index);
  2829.                 end
  2830.             end
  2831.         end
  2832.  
  2833.         if (isComplete == nil) then
  2834.             if (self.IsComplete == true or self.IsFailed == true) then
  2835.                 self.Changed = true;
  2836.                 self.DataChanged = true;
  2837.             end
  2838.             self.IsComplete = false;
  2839.             self.IsFailed = false;
  2840.        
  2841.         elseif (isComplete == 1) then
  2842.             if (self.IsComplete == false or self.IsFailed == true) then
  2843.                 self.Changed = true;
  2844.                 self.DataChanged = true;
  2845.  
  2846.                 if (db.ZonesAndQuests.HideCompletedQuests == true and self._FirstUpdate == false) then
  2847.                     self:Hide();
  2848.                 end
  2849.             end
  2850.             self.IsComplete = true;
  2851.             self.IsFailed = false;
  2852.         else
  2853.             if (self.IsComplete == true or self.IsFailed == false) then
  2854.                 self.Changed = true;
  2855.                 self.DataChanged = true;
  2856.             end
  2857.             self.IsComplete = false;
  2858.             self.IsFailed = true;
  2859.         end
  2860.  
  2861.  
  2862.         self.HasProgressBar = false;
  2863.         local tmpObjectives = {}
  2864.         if (self.ObjectiveCount == 0 or numObjectives ~= self.ObjectiveCount) then
  2865.             for objectiveIndex = 1, numObjectives, 1 do
  2866.                 local objective = SQLObjective:new(objectiveIndex, self.Index, self.ID);
  2867.                 if (objective) then
  2868.                     tinsert(tmpObjectives, objective);
  2869.                 end
  2870.             end
  2871.         end
  2872.         if (self.ObjectiveCount ~= #tmpObjectives and #tmpObjectives > 0) then
  2873.             self:ClearObjectives();
  2874.             for objectiveIndex = 1, #tmpObjectives, 1 do
  2875.                 local objective = tmpObjectives[objectiveIndex]
  2876.                 self:AddObjective(objective);
  2877.                 if (objective.Type == "progressbar") then
  2878.                     self.HasProgressBar = true;
  2879.                 end
  2880.             end
  2881.         else       
  2882.             for i, objective in ipairs(self.ObjectiveList) do
  2883.                 objective:Update();
  2884.                 if (objective.Type == "progressbar") then
  2885.                     self.HasProgressBar = true;
  2886.                 end
  2887.                 if (objective.Changed == true) then
  2888.                     self.Changed = true;
  2889.                     self.DataChanged = true;
  2890.                 end
  2891.             end
  2892.         end
  2893.        
  2894.                                        
  2895.         if (self.HasProgressBar == true) then
  2896.             self.ProgressBarPercent = GetQuestProgressBarPercent(self.ID);
  2897.         end
  2898.  
  2899.  
  2900.         if (self.ObjectiveCount == 0) then
  2901.             if (db.ZonesAndQuests.HideCompletedQuests == true and self._FirstUpdate == true) then
  2902.                 self:Hide();
  2903.             end
  2904.         end
  2905.  
  2906.         self.POIText = "";
  2907.         for i=0, #tblPOIs, 1 do
  2908.             if (tblPOIs[i] == self.ID) then
  2909.                 if ( self.IsComplete == true or self.ObjectiveCount == 0) then
  2910.                     self.POIText = "?";
  2911.                 else
  2912.                     self.POIText = tostring(i);
  2913.                 end
  2914.             end
  2915.         end
  2916.  
  2917.         self.Distance = 0;
  2918.         if (db.ZonesAndQuests.QuestSortOrder == "Proximity") then
  2919.             local distanceSq, onContinent = GetDistanceSqToQuest(self.Index)
  2920.             if(onContinent) then
  2921.                 self.Distance =  distanceSq;
  2922.             end
  2923.         end
  2924.  
  2925.         self._FirstUpdate = false;
  2926.         self._Valid = true;
  2927.        
  2928.     end
  2929.  
  2930.  
  2931.  
  2932.     return self;
  2933. end
  2934.  
  2935. function SQLQuest:Render()
  2936.     local strLevelColor = ""
  2937.     local strTitleColor = ""
  2938.    
  2939.  
  2940.     -- Get quest level colour
  2941.     if (db.ZonesAndQuests.QuestLevelColouringSetting == "Level") then
  2942.         local objColour = GetQuestDifficultyColor(self.Level); 
  2943.         strLevelColor = format("|c%02X%02X%02X%02X", 255, objColour.r * 255, objColour.g * 255, objColour.b * 255);
  2944.    
  2945.     elseif (db.ZonesAndQuests.QuestLevelColouringSetting == "Completion") then
  2946.         strLevelColor = QuestTracker:GetCompletionColourString(self:CompletionLevel())
  2947.    
  2948.     elseif (db.ZonesAndQuests.QuestLevelColouringSetting == "Done/Undone") then
  2949.         if (self.IsComplete == true) then
  2950.             strLevelColor = strDoneColour
  2951.         else
  2952.  
  2953.             strLevelColor = strUndoneColour
  2954.         end
  2955.    
  2956.     else
  2957.         strLevelColor = strQuestLevelColour
  2958.     end
  2959.    
  2960.     -- Get quest title colour
  2961.     if (db.ZonesAndQuests.QuestTitleColouringSetting == "Level") then
  2962.         local objColour = GetQuestDifficultyColor(self.Level); 
  2963.         strTitleColor = format("|c%02X%02X%02X%02X", 255, objColour.r * 255, objColour.g * 255, objColour.b * 255);
  2964.    
  2965.     elseif (db.ZonesAndQuests.QuestTitleColouringSetting == "Completion") then
  2966.         strTitleColor = QuestTracker:GetCompletionColourString(self:CompletionLevel())
  2967.    
  2968.     elseif (db.ZonesAndQuests.QuestTitleColouringSetting == "Done/Undone") then
  2969.         if (self.IsComplete == true) then
  2970.             strTitleColor = strDoneColour
  2971.         else
  2972.             strTitleColor = strUndoneColour
  2973.         end
  2974.    
  2975.     else
  2976.         strTitleColor = strQuestTitleColour
  2977.     end
  2978.        
  2979.     local strQuestReturnText = ""
  2980.     local blnShowBrackets = false
  2981.     local blnFirstThing = true
  2982.  
  2983.  
  2984.  
  2985.     if (db.ZonesAndQuests.DisplayPOITag == true) then
  2986.         if (self.POIText ~= nil and self.POIText ~= "") then
  2987.             strQuestReturnText = strQuestReturnText .. self.POIText .. " "
  2988.         end
  2989.     end
  2990.  
  2991.     -- Quest level
  2992.     if (db.ZonesAndQuests.ShowQuestLevels == true) then
  2993.         strQuestReturnText = strQuestReturnText .. self.Level
  2994.         blnShowBrackets = true
  2995.         blnFirstThing = false
  2996.     end
  2997.  
  2998.  
  2999.  
  3000.  
  3001.    
  3002.  
  3003.     --PVP, RAID, Group, etc tags
  3004.     if (self.TagID) then
  3005.         if (db.ZonesAndQuests.QuestTagsLength == "Full" and dicLongQuestTags[self.TagID] ~= nil) then
  3006.             if (blnFirstThing == true) then
  3007.                 strQuestReturnText = strQuestReturnText .. dicLongQuestTags[self.TagID]
  3008.             else
  3009.                 strQuestReturnText = strQuestReturnText .. " " .. dicLongQuestTags[self.TagID]
  3010.             end
  3011.            
  3012.             blnShowBrackets = true
  3013.             blnFirstThing = false
  3014.         elseif (db.ZonesAndQuests.QuestTagsLength == "Short" and dicQuestTags[self.TagID] ~= nil) then
  3015.             strQuestReturnText = strQuestReturnText .. dicQuestTags[self.TagID]
  3016.             blnShowBrackets = true
  3017.             blnFirstThing = false
  3018.         end    
  3019.     end
  3020.    
  3021.     if (self.SuggestedGroup > 0 and db.ZonesAndQuests.QuestTagsLength ~= "None") then
  3022.         strQuestReturnText = strQuestReturnText .. self.SuggestedGroup
  3023.         blnShowBrackets = true
  3024.         blnFirstThing = false
  3025.     end
  3026.  
  3027.     if (self:IsDaily() == true) then
  3028.         if (db.ZonesAndQuests.QuestTagsLength == "Full") then
  3029.             if (blnFirstThing == true) then
  3030.                 strQuestReturnText = strQuestReturnText .. dicLongQuestTags["Daily"]
  3031.             else
  3032.                 strQuestReturnText = strQuestReturnText .. " " .. dicLongQuestTags["Daily"]
  3033.             end
  3034.             blnShowBrackets = true
  3035.         elseif (db.ZonesAndQuests.QuestTagsLength == "Short") then
  3036.             strQuestReturnText = strQuestReturnText .. dicQuestTags["Daily"]
  3037.             blnShowBrackets = true
  3038.         end
  3039.     end
  3040.    
  3041.     if (self:IsWeekly() == true) then
  3042.         if (db.ZonesAndQuests.QuestTagsLength == "Full") then
  3043.             if (blnFirstThing == true) then
  3044.                 strQuestReturnText = strQuestReturnText .. dicLongQuestTags["Weekly"]
  3045.             else
  3046.                 strQuestReturnText = strQuestReturnText .. " " .. dicLongQuestTags["Weekly"]
  3047.             end
  3048.             blnShowBrackets = true
  3049.         elseif (db.ZonesAndQuests.QuestTagsLength == "Short") then
  3050.             strQuestReturnText = strQuestReturnText .. dicQuestTags["Weekly"]
  3051.             blnShowBrackets = true
  3052.         end
  3053.     end
  3054.  
  3055.     if (db.ZonesAndQuests.ShowQuestLevels == true or db.ZonesAndQuests.QuestTagsLength ~= "None" and blnShowBrackets == true) then
  3056.         strQuestReturnText = strLevelColor .. "[" .. strQuestReturnText
  3057.        
  3058.         strQuestReturnText = strQuestReturnText .. "]|r "
  3059.     end
  3060.    
  3061.     strQuestReturnText = strQuestReturnText .. strTitleColor .. self.Title .. "|r"
  3062.  
  3063.     -- Completion/failed etc tag
  3064.     if (self.IsFailed == true) then
  3065.         strQuestReturnText = strQuestReturnText .. strQuestStatusFailed .. L[" (Failed)"] .. "|r"
  3066.     elseif (self.IsComplete == true) then
  3067.         strQuestReturnText = strQuestReturnText .. strQuestStatusDone .. L[" (Done)"] .. "|r"
  3068.     elseif (self.ObjectiveCount == 0) then
  3069.         strQuestReturnText = strQuestReturnText .. strQuestStatusGoto .. L[" (goto)"] .. "|r"
  3070.     end
  3071.    
  3072.     -- Hidden tag
  3073.     if (self.IsHidden == true and db.ZonesAndQuests.AllowHiddenQuests == true) then
  3074.         strQuestReturnText = strQuestReturnText .. strHeaderColour .. L[" (Hidden)"] .. "|r"
  3075.     end
  3076.    
  3077.     local strObjectivesReturnText = ""
  3078.    
  3079.     -- Objectives
  3080.     if (self.ObjectiveCount == 0) then
  3081.         -- If no objective and show descriptions on display quest description
  3082.         local renderText = self.ObjectiveDescription;
  3083.         if (self.IsBreadcrumb == true) then
  3084.             renderText = self.CompletionText;
  3085.         end
  3086.         if (renderText == nill) then
  3087.             renderText = "";
  3088.         end
  3089.         if (db.ZonesAndQuests.ShowDescWhenNoObjectives == true) then
  3090.             if (not(self.IsComplete == true)) then
  3091.                 strObjectivesReturnText = strObjectivesReturnText .. strObjectiveDescriptionColour .. " - " .. renderText .. "|r\n"
  3092.             else
  3093.                 if (db.ZonesAndQuests.HideCompletedObjectives == false) then
  3094.                     strObjectivesReturnText = strObjectivesReturnText .. strObjectiveDescriptionColour .. " - " .. renderText .. "|r\n"
  3095.                 end
  3096.             end
  3097.         end
  3098.     else
  3099.         if (self.IsComplete == false) then
  3100.             -- For each objective in quest
  3101.             for k, ObjectiveInstance in pairs(self.ObjectiveList) do
  3102.                 if not(db.ZonesAndQuests.HideCompletedObjectives == true and ObjectiveInstance.IsComplete == true) then
  3103.                     strObjectivesReturnText = strObjectivesReturnText .. ObjectiveInstance:Render() .. "\n";   
  3104.                 end
  3105.             end
  3106.         end
  3107.     end
  3108.  
  3109.    
  3110.     strQuestReturnText = strtrim(strQuestReturnText)
  3111.     strObjectivesReturnText = strtrim(strObjectivesReturnText)
  3112.     return strQuestReturnText, strObjectivesReturnText
  3113. end
  3114.  
  3115. function SQLQuest:Hide()
  3116.     self.IsHidden = true;
  3117.     self.Changed = true;
  3118.     RemoveQuestWatch(self.Index)
  3119. end
  3120.  
  3121. function SQLQuest:Show()
  3122.     self.IsHidden = false;
  3123.     self.Changed = true;
  3124.     AddQuestWatch(self.Index)
  3125. end
  3126.  
  3127. function SQLQuest:IsDaily()
  3128.     if (self.Frequency == 2) then
  3129.         return true;
  3130.     end
  3131.     return false;
  3132. end
  3133.  
  3134. function SQLQuest:IsWeekly()
  3135.     if (self.Frequency == 3) then
  3136.         return true;
  3137.     end
  3138.     return false;
  3139. end
  3140.  
  3141. function SQLQuest:AddObjective(objective)
  3142.     self.Changed = true;
  3143.     self.DataChanged = true;
  3144.     self.ObjectiveCount = self.ObjectiveCount + 1;
  3145.     tinsert(self.ObjectiveList, objective);
  3146.     self._CompletionLevelValid = false;
  3147. end
  3148.  
  3149. function SQLQuest:ClearObjectives()
  3150.     self.Changed = true;
  3151.     self.DataChanged = true;
  3152.     self.ObjectiveCount = 0;
  3153.     self.ObjectiveList = {};
  3154.     self._CompletionLevelValid = false;
  3155. end
  3156.  
  3157. function SQLQuest:CompletionLevel()
  3158.     if (self._CompletionLevelValid == false) then
  3159.         if (self.ObjectiveCount == 0) then
  3160.             self._CompletionLevel = 1;
  3161.         else
  3162.             local totalCompletion = 0;
  3163.             local usedObjectives = 0;
  3164.             for i, objective in ipairs(self.ObjectiveList) do
  3165.                 totalCompletion = totalCompletion + objective.CompletionLevel;
  3166.                 usedObjectives = usedObjectives + 1;
  3167.             end
  3168.             self._CompletionLevel = totalCompletion / usedObjectives;
  3169.         end
  3170.         self._CompletionLevelValid = true;
  3171.     end
  3172.     return self._CompletionLevel;
  3173. end
  3174.  
  3175.  
  3176. local SQLZone = {};
  3177. SQLZone.__index = SQLZone;
  3178.  
  3179.  
  3180. function SQLZone:new(zoneIndex, fakeZone, id, title)
  3181.     local self = {};
  3182.     setmetatable(self, SQLZone);
  3183.  
  3184.     self.Index = zoneIndex;
  3185.     self.IsFakeZone = false;
  3186.     self.ID = nil;
  3187.     self.Title = nil;
  3188.     self.IsCollapsed = false;
  3189.  
  3190.     self.QuestCount = 0;
  3191.     self._CompletedQuestCount = 0;
  3192.     self.QuestList = {};
  3193.  
  3194.     self._HiddenQuestCount = 0;
  3195.     self._Changed = true;
  3196.     self._Valid = false;
  3197.  
  3198.  
  3199.     if (fakeZone) then
  3200.         self.IsFakeZone = true;
  3201.         self.ID = id;
  3202.         self.Title = title;
  3203.     end
  3204.  
  3205.     if (self.Index ~= nil) then
  3206.         self:Update();
  3207.     end
  3208.  
  3209.     if (self._Valid == true) then
  3210.         self._Changed = true;
  3211.         return self;
  3212.     else
  3213.         return nil;
  3214.     end
  3215. end
  3216.  
  3217. function SQLZone:Update(newIndex)
  3218.     self._Changed = false;
  3219.  
  3220.     if (self.IsFakeZone == true) then
  3221.         self._Valid = true;
  3222.         return;
  3223.     end
  3224.  
  3225.     if (newIndex ~= nil) then
  3226.         self.Index = newIndex;
  3227.     end
  3228.  
  3229.     local title, _, _, isHeader, isCollapsed, _, _, questID = GetQuestLogTitle(self.Index);
  3230.    
  3231.     if (isHeader) then
  3232.         self.Title = title;
  3233.         self.ID = title;
  3234.         if (self.Title == nil) then
  3235.             self.Title = UNKNOWN;
  3236.         end    
  3237.  
  3238.         self._Valid = true;
  3239.     end
  3240. end
  3241.  
  3242. function SQLZone:AddQuest(quest)
  3243.     if (self.QuestList[quest.ID] == nil) then
  3244.         self.QuestCount = self.QuestCount + 1;
  3245.         self.QuestList[quest.ID] = quest
  3246.         self._HiddenQuestCountValid = false;
  3247.         self._ChangedValid = false;
  3248.     end
  3249.  
  3250. end
  3251.  
  3252. function SQLZone:RemoveQuest(quest)
  3253.     if (self.QuestList[quest.ID] ~= nil) then
  3254.         self.QuestCount = self.QuestCount - 1;
  3255.         self.QuestList[quest.ID] = nil;
  3256.         self._HiddenQuestCountValid = false;
  3257.         self._ChangedValid = false;
  3258.     end
  3259. end
  3260.  
  3261. function SQLZone:ClearQuests()
  3262.     self.QuestCount = 0;
  3263.     self.HiddenQuestCount = 0;
  3264.     self.QuestList = {};   
  3265.     self._HiddenQuestCountValid = false;
  3266.     self._ChangedValid = false;
  3267. end
  3268.  
  3269. function SQLZone:Changed()
  3270.     for i, quest in pairs(self.QuestList) do
  3271.         if (quest.Changed == true) then
  3272.             self._Changed = true;
  3273.         end
  3274.     end
  3275.     return self._Changed;
  3276. end
  3277.  
  3278. function SQLZone:Collapse()
  3279.     dbChar.ZoneIsCollapsed[self.ID] = true;
  3280.     self._Changed = true;
  3281. end
  3282.  
  3283. function SQLZone:Expand()
  3284.     dbChar.ZoneIsCollapsed[self.ID] = false;
  3285.     self._Changed = true;
  3286. end
  3287.  
  3288. function SQLZone:CompletedQuestCount()
  3289.     self._CompletedQuestCount = 0;
  3290.     for i, quest in pairs(self.QuestList) do
  3291.         if (quest.IsComplete == true) then
  3292.             self._CompletedQuestCount = self._CompletedQuestCount + 1;
  3293.         end
  3294.     end
  3295.  
  3296.     return self._CompletedQuestCount;
  3297. end
  3298.  
  3299. function SQLZone:HiddenQuestCount()
  3300.     self._HiddenQuestCount = 0;
  3301.     for i, quest in pairs(self.QuestList) do
  3302.         if (quest.IsHidden == true or (quest.IsTask == true and self.IsFakeZone == false)) then
  3303.             self._HiddenQuestCount = self._HiddenQuestCount + 1;
  3304.         end
  3305.     end
  3306.  
  3307.     return self._HiddenQuestCount;
  3308. end
  3309.  
  3310. function SQLZone:HaveVisibleQuests()
  3311.     if (self:HiddenQuestCount() >= self.QuestCount) then
  3312.         return false;
  3313.     end
  3314.     return true;
  3315. end
  3316.  
  3317. local SQLQuestLogData = {};
  3318. SQLQuestLogData.__index = SQLQuestLogData;
  3319.  
  3320.  
  3321. function SQLQuestLogData:new()
  3322.     local self = {};
  3323.     setmetatable(self, SQLQuestLogData);
  3324.  
  3325.     self.FirstUpdate = true;
  3326.     self.EntryCount = 0;
  3327.     self.HaveTrackedQuests = false;
  3328.  
  3329.     self.ZoneCount = 0;
  3330.     self.ZoneList = {};
  3331.    
  3332.     self.QuestCount = 0;
  3333.     self.QuestList = {};
  3334.     self.CompletedQuestCount = 0;
  3335.  
  3336.     self.CollapsedZoneCount = 0;
  3337.     self.HiddenQuestCount = 0;
  3338.  
  3339.     self.ZoneList[campaignZoneID] = SQLZone:new(1, true, campaignZoneID, "");
  3340.     self.ZoneList[bonusObjectivesZoneID] = SQLZone:new(0, true, bonusObjectivesZoneID, bonusObjectivesZoneTitle);
  3341.     self.ZoneList[worldQuestsZoneID] = SQLZone:new(100, true, worldQuestsZoneID, worldQuestsZoneTitle);
  3342.  
  3343.     self.Changed = false;
  3344.     self:Update();
  3345.  
  3346.     return self;
  3347. end
  3348.  
  3349. function SQLQuestLogData:Update()
  3350.     self.Changed = false;
  3351.    
  3352.     if (timeOfFirstQuestUpdate == 0) then
  3353.         timeOfFirstQuestUpdate = GetTime();
  3354.     end
  3355.  
  3356.     playerMoney = GetMoney();
  3357.     local POIs = GetQuestPOIs();
  3358.     tblPOIs = {};
  3359.     for i=0, #POIs, 1 do
  3360.         if (POIs[i]) then
  3361.             tblPOIs[i] = POIs[i];
  3362.         end
  3363.     end
  3364.  
  3365.  
  3366.  
  3367.     for i, quest in pairs(self.QuestList) do
  3368.         quest.Keep = false;
  3369.     end
  3370.  
  3371.     local timers = {GetQuestTimers()};
  3372.     local tblTimers = {};
  3373.     local trackedTimerCount = 0;
  3374.  
  3375.     if (#timers > 0) then
  3376.         for i = 1, GetNumQuestWatches() do
  3377.             local timerQuestID, _, _, _, _, _, _, _, failureTime, timeElapsed = GetQuestWatchInfo(i);
  3378.             if ( not timerQuestID ) then
  3379.                 break;
  3380.             end
  3381.             if (failureTime ~= nil and failureTime > 0) then
  3382.                 if (timeElapsed == nil) then
  3383.                     timeElapsed = 0;
  3384.                 end
  3385.                 tblTimers[timerQuestID] = {['Elapsed'] = timeElapsed, ['Duration'] = failureTime, ['Tracked'] = true}
  3386.                 trackedTimerCount = trackedTimerCount + 1;
  3387.             end
  3388.         end
  3389.         if (trackedTimerCount < #timers) then
  3390.             for i=1,#timers, 1 do
  3391.                 local index = GetQuestIndexForTimer(i);
  3392.                 local _, _, _, _, _, _, _, timerQuestID = GetQuestLogTitle(index); 
  3393.                 tblTimers[timerQuestID] = {['Elapsed'] = 0, ['Duration'] = timers[i], ['Tracked'] = false}
  3394.             end
  3395.         end
  3396.     end
  3397.  
  3398.        
  3399.        
  3400.     local campaignId = C_CampaignInfo.GetCurrentCampaignID();
  3401.     if (campaignId) then
  3402.         local campaignInfo = C_CampaignInfo.GetCampaignInfo(campaignId);
  3403.         self.ZoneList[campaignZoneID].Title = campaignInfo.name or "";
  3404.     end
  3405.    
  3406.    
  3407.    
  3408.     local numEntries, numQuests = GetNumQuestLogEntries();
  3409.     local zoneID = nil;
  3410.     for i = 1, numEntries, 1 do
  3411.         local title, _, _, isHeader, _, _, _, questID, _, _, isOnMap, _, isTask, isBounty, _, isHidden = GetQuestLogTitle(i);
  3412.         local tagID, tagName, worldQuestType, rarity, isElite, tradeskillLineIndex = GetQuestTagInfo(questID);
  3413.  
  3414.         if (isHeader) then
  3415.             zoneID = title;
  3416.             if (self.ZoneList[zoneID] == nil) then
  3417.                 self.ZoneList[zoneID] = SQLZone:new(i);
  3418.                 self.ZoneCount = self.ZoneCount + 1;
  3419.             else
  3420.                 self.ZoneList[zoneID]:Update(i);
  3421.             end
  3422.             if (dbChar.ZoneIsCollapsed[zoneID] == true) then
  3423.                 self.ZoneList[zoneID].IsCollapsed = true;
  3424.             else
  3425.                 self.ZoneList[zoneID].IsCollapsed = false;
  3426.             end
  3427.         else
  3428.             if (not QuestUtils_IsQuestWorldQuest(questID) and (not isHidden and not isBounty) or (isTask and not worldQuestType)) then
  3429.                 if (self.QuestList[questID] == nil) then
  3430.                     self.QuestList[questID] = SQLQuest:new(i, questID, false);
  3431.                     self.QuestCount = self.QuestCount + 1;
  3432.                 else
  3433.                     self.QuestList[questID]:Update(i);
  3434.                 end
  3435.  
  3436.                 if (tblTimers[questID] == nil) then
  3437.                     self.QuestList[questID].Timer = nil;
  3438.                 else
  3439.                     if (self.QuestList[questID].Timer == nil) then
  3440.                         self.QuestList[questID].Timer = SQLQuestTimer:new(tblTimers[questID].Duration, tblTimers[questID].Elapsed)
  3441.                     else
  3442.                         if (tblTimers[questID].Duration > self.QuestList[questID].Timer.Duration) then
  3443.                             self.QuestList[questID].Timer.Duration = tblTimers[questID].Duration;
  3444.                         end
  3445.  
  3446.                         if (tblTimers[questID].Tracked == false) then
  3447.                             local elapsed = self.QuestList[questID].Timer.Duration - tblTimers[questID].Duration;
  3448.                             self.QuestList[questID].Timer:Refresh(elapsed);
  3449.                         else
  3450.                             self.QuestList[questID].Timer:Refresh(tblTimers[questID].Elapsed);
  3451.                         end
  3452.                     end
  3453.                 end
  3454.  
  3455.                 if (self.QuestList[questID].IsTask == true) then
  3456.                     self.ZoneList[bonusObjectivesZoneID]:AddQuest(self.QuestList[questID]);
  3457.                 else
  3458.                     if (self.ZoneList[zoneID] ~= nil) then
  3459.                         self.ZoneList[zoneID]:AddQuest(self.QuestList[questID]);
  3460.                     end
  3461.                 end
  3462.                
  3463.                 if (C_CampaignInfo.IsCampaignQuest(questID)) then
  3464.                     self.ZoneList[campaignZoneID]:AddQuest(self.QuestList[questID]);
  3465.                 end
  3466.            
  3467.             end
  3468.         end
  3469.     end
  3470.  
  3471.  
  3472.    
  3473.    
  3474.     local worldQuestIDs = {}
  3475.     local tasksTable = GetTasksTable();
  3476.     for i = 1, #tasksTable do
  3477.         local questID = tasksTable[i];
  3478.         if (QuestUtils_IsQuestWorldQuest(questID) and not IsWorldQuestWatched(questID) ) then
  3479.             local isInArea = GetTaskInfo(questID);
  3480.             if (isInArea) then
  3481.                 table.insert(worldQuestIDs, questID);
  3482.             end
  3483.         end
  3484.     end
  3485.    
  3486.     for i = 1, GetNumWorldQuestWatches() do
  3487.         local watchedWorldQuestID = GetWorldQuestWatchInfo(i);
  3488.         if ( watchedWorldQuestID ) then
  3489.             table.insert(worldQuestIDs, watchedWorldQuestID)
  3490.         end
  3491.     end
  3492.    
  3493.     for i = 1, #worldQuestIDs do
  3494.         local questID = worldQuestIDs[i];
  3495.         if (self.QuestList[questID] == nil) then
  3496.             self.QuestList[questID] = SQLQuest:new(i, questID, true);
  3497.             self.QuestCount = self.QuestCount + 1;
  3498.         else
  3499.             self.QuestList[questID]:Update(i);
  3500.         end
  3501.         self.ZoneList[worldQuestsZoneID]:AddQuest(self.QuestList[questID]);
  3502.     end
  3503.  
  3504.    
  3505.    
  3506.     if (dbChar.ZoneIsCollapsed[bonusObjectivesZoneID] == true) then
  3507.         self.ZoneList[bonusObjectivesZoneID].IsCollapsed = true;
  3508.     else
  3509.         self.ZoneList[bonusObjectivesZoneID].IsCollapsed = false;
  3510.     end
  3511.     if (dbChar.ZoneIsCollapsed[worldQuestsZoneID] == true) then
  3512.         self.ZoneList[worldQuestsZoneID].IsCollapsed = true;
  3513.     else
  3514.         self.ZoneList[worldQuestsZoneID].IsCollapsed = false;
  3515.     end
  3516.     if (dbChar.ZoneIsCollapsed[campaignZoneID] == true) then
  3517.         self.ZoneList[campaignZoneID].IsCollapsed = true;
  3518.     else
  3519.         self.ZoneList[campaignZoneID].IsCollapsed = false;
  3520.     end
  3521.  
  3522.     self.HiddenQuestCount = 0;
  3523.     self.CompletedQuestCount = 0;
  3524.     for questKey, quest in pairs(self.QuestList) do
  3525.         if (quest.Keep == false) then
  3526.             for zoneKey, zone in pairs(self.ZoneList) do
  3527.                 zone:RemoveQuest(quest);
  3528.             end
  3529.             self.QuestList[quest.ID] = nil;
  3530.             self.QuestCount = self.QuestCount - 1;
  3531.             self.Changed = true;
  3532.         else
  3533.             if (quest.IsComplete == true) then
  3534.                 self.CompletedQuestCount = self.CompletedQuestCount + 1;
  3535.             end
  3536.             if(quest.IsHidden == true) then
  3537.                 self.HiddenQuestCount = self.HiddenQuestCount + 1;
  3538.             end
  3539.         end
  3540.     end
  3541.  
  3542.  
  3543.     if (self.QuestCount > 0 and GetTime() - timeOfFirstQuestUpdate > 20) then
  3544.         dbChar.ZoneIsCollapsed = {};
  3545.     end
  3546.     self.CollapsedZoneCount = 0;
  3547.     for zoneKey, zone in pairs(self.ZoneList) do
  3548.         if (zone.QuestCount > 0 or zone.IsFakeZone == true) then
  3549.             if (zone.IsCollapsed == true) then
  3550.                 self.CollapsedZoneCount = self.CollapsedZoneCount + 1;
  3551.                 dbChar.ZoneIsCollapsed[zoneKey] = true;
  3552.             else
  3553.                 dbChar.ZoneIsCollapsed[zoneKey] = false;
  3554.             end
  3555.  
  3556.             if (zone:Changed() == true) then
  3557.                 self.Changed = true;
  3558.             end
  3559.        
  3560.         else
  3561.             self.ZoneList[zone.ID] = nil;
  3562.             self.ZoneCount = self.ZoneCount - 1;
  3563.             self.Changed = true;
  3564.         end
  3565.     end
  3566.  
  3567.     self.HaveTrackedQuests = true;
  3568.     if (self.HiddenQuestCount >= self.QuestCount) then
  3569.         self.HaveTrackedQuests = false;
  3570.     end
  3571.  
  3572.  
  3573.     self.FirstUpdate = false;
  3574. end
  3575.  
  3576. function SQLQuestLogData:CompleteCheck()
  3577.     local questComplete = false;
  3578.     local questFailed = false;
  3579.     local objectiveChanged = false;
  3580.     local objectiveComplete = false;
  3581.     local messages = {};
  3582.  
  3583.     for questKey, quest in pairs(self.QuestList) do
  3584.         if (quest.DataChanged == true) then        
  3585.             for objectiveKey, objective in pairs(quest.ObjectiveList) do
  3586.                 if (objective.Changed == true) then
  3587.                     objectiveChanged = true;
  3588.  
  3589.                     local strMessage = "";
  3590.                     if (objective.IsComplete == true) then
  3591.                         objectiveComplete = true;
  3592.  
  3593.                         if (db.Notifications.LibSinkObjectiveNotifications == true) then
  3594.                             if (db.Notifications.DisplayQuestOnObjectiveNotifications == true) then
  3595.                                 strMessage = format("(%s) %s ", quest.Title, objective.Text) .. L["(Complete)"];
  3596.                             else
  3597.                                 strMessage = format("%s ", objective.Text) .. L["(Complete)"];
  3598.                             end
  3599.  
  3600.                             if (db.Notifications.LibSinkColourSetting == "Custom") then
  3601.                                 QuestTracker:Pour(strMessage, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b);
  3602.                             else
  3603.                                 QuestTracker:Pour(strMessage, db.Colours.ObjectiveDoneColour.r, db.Colours.ObjectiveDoneColour.g, db.Colours.ObjectiveDoneColour.b);
  3604.                             end
  3605.                         end
  3606.                     else
  3607.                         if (db.Notifications.LibSinkObjectiveNotifications == true) then
  3608.                             if (db.Notifications.DisplayQuestOnObjectiveNotifications == true) then
  3609.                                 if (quest.Title == nil or objective.Text == nil or objective.Have == nil or objective.Need == nil) then
  3610.                                     print(quest.Title);print(objective.Text);print(objective.Have);print(objective.Need);
  3611.                                 end
  3612.                                 strMessage = format("(%s) %s : %s / %s", quest.Title, objective.Text, objective.Have, objective.Need);
  3613.                             else
  3614.                                 strMessage = format("%s : %s / %s", objective.Text, objective.Have, objective.Need);
  3615.                             end
  3616.                                
  3617.                             if (db.Notifications.LibSinkColourSetting == "Custom") then
  3618.                                 QuestTracker:Pour(strMessage, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b);
  3619.                             else
  3620.                                 r, g, b = QuestTracker:GetCompletionColourRGB(objective.CompletionLevel / 1.0);
  3621.                                 QuestTracker:Pour(strMessage, r, g, b);
  3622.                             end
  3623.                         end
  3624.                     end
  3625.                 end
  3626.             end
  3627.            
  3628.  
  3629.             if (quest.IsComplete == true) then
  3630.                 questComplete = true;
  3631.                 if (db.Notifications.ShowQuestCompletesAndFails) then
  3632.                     QuestTracker:Pour(QUEST_COMPLETE .. ": " .. quest.Title, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b);
  3633.                 end
  3634.             elseif (quest.IsFailed == true) then
  3635.                 questFailed = true;
  3636.                 if (db.Notifications.ShowQuestCompletesAndFails) then
  3637.                     QuestTracker:Pour(L["Quest failed: "] .. quest.Title, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b);
  3638.                 end
  3639.             end
  3640.         end
  3641.     end
  3642.    
  3643.  
  3644.     if (questComplete == true) then
  3645.         if ((GetTime() - intTimeOfLastSound) > 1 and db.Notifications.QuestDoneSound ~= "None") then
  3646.             PlaySoundFile(LSM:Fetch("sound", db.Notifications.QuestDoneSound))
  3647.             intTimeOfLastSound = GetTime()
  3648.         end
  3649.     elseif (objectiveComplete == true) then
  3650.         if ((GetTime() - intTimeOfLastSound) > 1 and db.Notifications.ObjectiveDoneSound ~= "None") then
  3651.             PlaySoundFile(LSM:Fetch("sound", db.Notifications.ObjectiveDoneSound))
  3652.             intTimeOfLastSound = GetTime()
  3653.         end
  3654.     elseif (objectiveChanged == true) then
  3655.         if ((GetTime() - intTimeOfLastSound) > 1 and db.Notifications.ObjectiveChangedSound ~= "None") then
  3656.             PlaySoundFile(LSM:Fetch("sound", db.Notifications.ObjectiveChangedSound))
  3657.             intTimeOfLastSound = GetTime()
  3658.         end
  3659.     end
  3660. end
  3661.  
  3662. --Inits
  3663. function QuestTracker:OnInitialize()
  3664.     self.db = SorhaQuestLog.db:RegisterNamespace(MODNAME, defaults)
  3665.     db = self.db.profile
  3666.     dbChar = self.db.char  
  3667.     dbCore = SorhaQuestLog.db.profile
  3668.     self:SetSinkStorage(db)
  3669.    
  3670.     self:SetEnabledState(SorhaQuestLog:GetModuleEnabled(MODNAME))
  3671.     SorhaQuestLog:RegisterModuleOptions(MODNAME, getOptions, L["Quest Tracker"])
  3672.    
  3673.     self:UpdateColourStrings();
  3674.     self:UpdateClickBindings();
  3675.     self:MinionAnchorUpdate(true)
  3676.  
  3677.     SorhaQuestLog:RegisterToast("TaskCompleteToast", function(toast, rewards)
  3678.         toast:SetTitle(rewards.title)
  3679.  
  3680.         local text = "";
  3681.         local firstIcon = true;
  3682.         if (rewards["currencies"]) then
  3683.             if (firstIcon == true) then
  3684.                 toast:SetIconTexture(rewards["currencies"].texture);
  3685.             end
  3686.             text = text .. rewards["currencies"].text .. "\n";
  3687.             firstIcon = false;
  3688.         end
  3689.         if (rewards["items"]) then
  3690.             if (firstIcon == true) then
  3691.                 toast:SetIconTexture(rewards["items"].texture);
  3692.             end
  3693.             text = text .. rewards["items"].text .. "\n";
  3694.             firstIcon = false;
  3695.         end
  3696.         if (rewards["xp"]) then
  3697.             if (firstIcon == true) then
  3698.                 toast:SetIconTexture(rewards["xp"].texture);
  3699.  
  3700.             end
  3701.             text = text .. rewards["xp"].text .. " Experience\n";
  3702.             firstIcon = false;
  3703.         end
  3704.         if (rewards["money"]) then
  3705.             if (firstIcon == true) then
  3706.                 toast:SetIconTexture(rewards["money"].texture);
  3707.             end
  3708.             text = text .. rewards["money"].text .. "\n";
  3709.             firstIcon = false;
  3710.         end
  3711.  
  3712.         toast:SetText(text)
  3713.     end)
  3714. end
  3715.  
  3716. function QuestTracker:OnEnable()
  3717.    
  3718.     strZone = GetRealZoneText()
  3719.     strSubZone = GetSubZoneText()
  3720.     self:RegisterEvent("QUEST_LOG_UPDATE");
  3721.     self:RegisterEvent("QUEST_WATCH_LIST_CHANGED");
  3722.     self:RegisterEvent("QUEST_TURNED_IN");
  3723.     self:RegisterEvent('PLAYER_LEVEL_UP');
  3724.     self:RegisterEvent("ZONE_CHANGED")
  3725.     self:RegisterEvent("ZONE_CHANGED_INDOORS")
  3726.     self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  3727.     self:RegisterEvent("PLAYER_STOPPED_MOVING")
  3728.    
  3729.    
  3730.     -- Hook for moving quest progress messages
  3731.     self:RawHookScript(UIErrorsFrame, "OnEvent", function(self, event, msgType, msg, ...)
  3732.         QuestTracker:HandleUIErrorsFrame(self, event, msgType, msg, ...)
  3733.     end)
  3734.    
  3735.  
  3736.  
  3737.     intTimeOfLastSound = GetTime()
  3738.     self:MinionAnchorUpdate(false);
  3739.  
  3740.     self:UpdateMinionHandler()
  3741. end
  3742.  
  3743. function QuestTracker:OnDisable()
  3744.     self:UnregisterEvent("QUEST_LOG_UPDATE")   
  3745.     self:UnregisterEvent("QUEST_WATCH_LIST_CHANGED");
  3746.     self:UnregisterEvent("QUEST_TURNED_IN");
  3747.     self:UnregisterEvent('PLAYER_LEVEL_UP');
  3748.     self:UnregisterEvent("ZONE_CHANGED")
  3749.     self:UnregisterEvent("ZONE_CHANGED_INDOORS")
  3750.     self:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
  3751.     self:UnregisterEvent("PLAYER_STOPPED_MOVING")
  3752.  
  3753.     self:MinionAnchorUpdate(true);
  3754.     self:UpdateMinionHandler()
  3755. end
  3756.  
  3757. function QuestTracker:Refresh()
  3758.     db = self.db.profile
  3759.     dbCore = SorhaQuestLog.db.profile
  3760.     self:SetSinkStorage(db)
  3761.    
  3762.     self:HandleColourChanges()
  3763.     self:doHiddenQuestsUpdate()
  3764.     self:MinionAnchorUpdate(true)  
  3765. end
  3766.  
  3767.  
  3768. --Events/handlers
  3769. function QuestTracker:QUEST_LOG_UPDATE(...)
  3770.     if (blnHaveRegisteredBagUpdate == false) then
  3771.         blnHaveRegisteredBagUpdate = true
  3772.         self:RegisterEvent("BAG_UPDATE")
  3773.     end
  3774.  
  3775.     self:UpdateMinionHandler();
  3776. end
  3777.  
  3778. function QuestTracker:QUEST_WATCH_LIST_CHANGED(...)
  3779.     self:UpdateMinionHandler();
  3780. end
  3781.  
  3782. function QuestTracker:QUEST_TURNED_IN(...)
  3783.     local event, questID, xp, money = ...;
  3784.     if ( IsQuestTask(questID)) then
  3785.         rewards = { };
  3786.         local title = C_TaskQuest.GetQuestInfoByQuestID(questID);
  3787.         if (title == nil) then
  3788.             return
  3789.         end
  3790.         rewards.title = C_TaskQuest.GetQuestInfoByQuestID(questID) .. " Complete";
  3791.  
  3792.         -- xp
  3793.         if ( not xp ) then
  3794.             xp = GetQuestLogRewardXP(questID);
  3795.         end
  3796.         if ( xp > 0 and UnitLevel("player") < MAX_PLAYER_LEVEL ) then
  3797.             local t = { };
  3798.             t.text = xp;
  3799.             t.texture = "Interface\\Icons\\XP_Icon";
  3800.             rewards["xp"] = t;
  3801.         end
  3802.  
  3803.         -- currencies
  3804.         local numCurrencies = GetNumQuestLogRewardCurrencies(questID);
  3805.         for i = 1, numCurrencies do
  3806.             local name, texture, count = GetQuestLogRewardCurrencyInfo(i, questID);
  3807.             local t = { };
  3808.             t.text = tostring(count) .. " " .. name;
  3809.             t.texture = texture;
  3810.             rewards["currencies"] = t;
  3811.             break;
  3812.         end
  3813.  
  3814.         -- items -- only the first
  3815.         local numItems = GetNumQuestLogRewards(questID);
  3816.         for i = 1, numItems do
  3817.             local name, texture, count, quality, isUsable = GetQuestLogRewardInfo(i, questID);
  3818.             local t = { };
  3819.             t.text = name;
  3820.             t.texture = texture;
  3821.             rewards["items"] = t;
  3822.             break;
  3823.         end
  3824.  
  3825.         -- money
  3826.         if ( not money ) then
  3827.             money = GetQuestLogRewardMoney(questID);
  3828.         end
  3829.         if ( money > 0 ) then
  3830.             local t = { };
  3831.             t.text = GetCoinText(money, ", ");
  3832.             t.texture = "Interface\\Icons\\inv_misc_coin_01";
  3833.             rewards["money"] = t;
  3834.         end
  3835.  
  3836.         if (db.Notifications.DisableToasts == false) then
  3837.             SorhaQuestLog:SpawnToast("TaskCompleteToast", rewards);
  3838.         end
  3839.     end
  3840. end
  3841.  
  3842. function QuestTracker:PLAYER_LEVEL_UP(...)
  3843.     self:UpdateMinionHandler();
  3844. end
  3845.  
  3846. function QuestTracker:PLAYER_REGEN_ENABLED(...)
  3847.     blnWasAClick = true;
  3848.     self:UpdateMinionHandler();
  3849.     self:UnregisterEvent("PLAYER_REGEN_ENABLED")
  3850. end
  3851.  
  3852. function QuestTracker:ZONE_CHANGED(...)
  3853.     self:doHandleZoneChange()
  3854. end
  3855.  
  3856. function QuestTracker:ZONE_CHANGED_INDOORS(...)
  3857.     self:doHandleZoneChange()
  3858. end
  3859.  
  3860. function QuestTracker:ZONE_CHANGED_NEW_AREA(...)
  3861.     if (strZone == nil) then
  3862.         strZone = GetRealZoneText()
  3863.         strSubZone = GetSubZoneText()
  3864.     end
  3865.     self:doHandleZoneChange()
  3866. end
  3867.  
  3868.  
  3869. function QuestTracker:PLAYER_STOPPED_MOVING(...)
  3870.     if (InCombatLockdown()) then
  3871.         return;
  3872.     end
  3873.  
  3874.     local currentTime = GetTime();
  3875.     if (timeOfProximityCheck + 5 < currentTime) then
  3876.         timeOfProximityCheck = currentTime;
  3877.        
  3878.         if (db.ZonesAndQuests.QuestSortOrder ~= "Proximity") then
  3879.             QuestTracker:UpdateMinionHandler();
  3880.         else
  3881.             QuestTracker:UpdateSmartItemButton();
  3882.         end    
  3883.     end
  3884. end
  3885.  
  3886. function QuestTracker:BAG_UPDATE(...)
  3887.     local intBag = select(2,...)
  3888.    
  3889.     if (db.Notifications.ShowMessageOnPickingUpQuestItem == true) then
  3890.         if (intBag < 5) then
  3891.             if (tContains(tblBagsToCheck, intBag) == nil) then
  3892.                 tinsert(tblBagsToCheck, intBag)
  3893.             end
  3894.             if (blnBagCheckUpdating == false) then
  3895.                 blnBagCheckUpdating = true
  3896.                 self:ScheduleTimer("CheckBags", 1)
  3897.             end
  3898.         end
  3899.     end
  3900. end
  3901.  
  3902. function QuestTracker:HandleUIErrorsFrame(frame, event, msgType, msg, ...)
  3903.     if (event == "UI_INFO_MESSAGE") then
  3904.         for k, strPattern in pairs(tblQuestMatchs) do
  3905.             if (msg:match(strPattern)) then
  3906.                 if (db.Notifications.SuppressBlizzardNotifications == true) then
  3907.                     return
  3908.                 end
  3909.                 break
  3910.             end
  3911.         end
  3912.     end
  3913.     QuestTracker.hooks[frame].OnEvent(frame, event, msgType, msg, ...)
  3914. end
  3915.  
  3916. --Buttons
  3917. function QuestTracker:GetMinionButton()
  3918.     local objButton = SorhaQuestLog:GetLogButton()
  3919.     objButton:SetParent(fraMinionAnchor)
  3920.     objButton.intOffset = 0;
  3921.  
  3922.     -- Create scripts
  3923.     objButton:RegisterForClicks("AnyUp")
  3924.     objButton:SetScript("OnLeave", function(self)
  3925.         GameTooltip:Hide()
  3926.     end)
  3927.     return objButton
  3928. end
  3929.  
  3930. function QuestTracker:GetMinionHeaderButton(zoneInstance)
  3931.     local objButton = QuestTracker:GetMinionButton()   
  3932.     objButton.ZoneInstance = zoneInstance;
  3933.  
  3934.     local strPrefix = strHeaderColour .. "- "
  3935.     if (objButton.ZoneInstance.IsCollapsed == true) then
  3936.         strPrefix = strHeaderColour .. "+ "
  3937.     end
  3938.  
  3939.     objButton.objFontString1:SetPoint("TOPLEFT", objButton, "TOPLEFT", 0, 0);
  3940.     objButton.objFontString1:SetFont(LSM:Fetch("font", db.Fonts.HeaderFont), db.Fonts.HeaderFontSize, db.Fonts.HeaderFontOutline)
  3941.     objButton.objFontString1:SetSpacing(db.Fonts.HeaderFontLineSpacing)
  3942.     if (db.Fonts.HeaderFontShadowed == true) then
  3943.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  3944.     else
  3945.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  3946.     end
  3947.    
  3948.     if (db.ZonesAndQuests.ShowHiddenCountOnZones == true and db.ZonesAndQuests.AllowHiddenQuests == true) then
  3949.         if (objButton.ZoneInstance:HiddenQuestCount() > 0) then
  3950.             objButton.objFontString1:SetText(strPrefix .. objButton.ZoneInstance.Title .. "|r " .. strInfoColour .. "(" .. objButton.ZoneInstance:HiddenQuestCount() .. "/" .. objButton.ZoneInstance.QuestCount .." Hidden)|r");  
  3951.         else
  3952.             objButton.objFontString1:SetText(strPrefix .. objButton.ZoneInstance.Title .. "|r");
  3953.         end
  3954.     else
  3955.         objButton.objFontString1:SetText(strPrefix .. objButton.ZoneInstance.Title .. "|r");
  3956.     end
  3957.  
  3958.  
  3959.     -- Create scripts
  3960.     objButton:SetScript("OnClick", function(self, button)
  3961.         blnWasAClick = true
  3962.         if (button == "LeftButton") then
  3963.             if (self.ZoneInstance.IsCollapsed == true) then
  3964.                 dbChar.ZoneIsCollapsed[self.ZoneInstance.ID] = false;
  3965.             else
  3966.                 dbChar.ZoneIsCollapsed[self.ZoneInstance.ID] = true;
  3967.             end
  3968.             QuestTracker:UpdateMinionHandler();        
  3969.         else
  3970.             if (IsAltKeyDown()) then
  3971.                 QuestTracker:DisplayAltRightClickMenu(self)    
  3972.             else
  3973.                 if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  3974.                     QuestTracker:DisplayRightClickMenu(self)
  3975.                 end
  3976.             end
  3977.         end
  3978.     end)
  3979.     objButton:SetScript("OnEnter", function(self)      
  3980.         if (db.ShowHelpTooltips == true) then
  3981.             if (db.MoveTooltipsRight == true) then
  3982.                 GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, 0);
  3983.             else
  3984.                 GameTooltip:SetOwner(self, "ANCHOR_LEFT", 0, 0);
  3985.             end
  3986.            
  3987.             GameTooltip:SetText(L["Zone Header"], 0, 1, 0, 1);
  3988.             GameTooltip:AddLine(L["Click to collapse/expand zone"], 1, 1, 1, 1);
  3989.             if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  3990.                 GameTooltip:AddLine(L["Right-click to show hidden quests toggle dropdown menu"], 1, 1, 1, 1);
  3991.             end
  3992.             GameTooltip:AddLine(L["Alt Right-click to show zone collapse/expand dropdown menu"], 1, 1, 1, 1);
  3993.             GameTooltip:AddLine(L["You can disable help tooltips in general settings"], 0.5, 0.5, 0.5, 1);
  3994.            
  3995.             GameTooltip:Show();
  3996.         end
  3997.     end)
  3998.  
  3999.    
  4000.     return objButton
  4001. end
  4002.  
  4003. function QuestTracker:GetCampaignButton(zoneInstance)
  4004.  
  4005.  
  4006.     -- Create scripts
  4007.     local campaignId = C_CampaignInfo.GetCurrentCampaignID();
  4008.     local campaignInfo, campaignChapterInfo;
  4009.     if (campaignId) then
  4010.         campaignInfo = C_CampaignInfo.GetCampaignInfo(campaignId);
  4011.     end
  4012.    
  4013.     local campaignChapterId = C_CampaignInfo.GetCurrentCampaignChapterID();
  4014.     if (campaignChapterId) then
  4015.         campaignChapterInfo = C_CampaignInfo.GetCampaignChapterInfo(campaignChapterId)
  4016.     end
  4017.    
  4018.  
  4019.     local objButton = fraMinionAnchor.CampaignButton;
  4020.     objButton.ZoneInstance = zoneInstance
  4021.     objButton.CampaignTooltip.warCampaignID = campaignId;
  4022.  
  4023.     objButton.objFontString1:SetPoint("TOPLEFT", objButton, "TOPLEFT", 0, 0);
  4024.     objButton.objFontString1:SetFont(LSM:Fetch("font", db.Fonts.HeaderFont), db.Fonts.HeaderFontSize, db.Fonts.HeaderFontOutline)
  4025.     objButton.objFontString1:SetSpacing(db.Fonts.HeaderFontLineSpacing)
  4026.     if (db.Fonts.HeaderFontShadowed == true) then
  4027.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4028.     else
  4029.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4030.     end
  4031.    
  4032.     if (objButton.ZoneInstance.IsCollapsed == true) then
  4033.         objButton.objFontString1:SetText(strHeaderColour .. "+ " .. zoneInstance.Title .. "|r");   
  4034.     else
  4035.         objButton.objFontString1:SetText(strHeaderColour .. "- " ..zoneInstance.Title .. "|r");
  4036.     end
  4037.  
  4038.  
  4039.     objButton.objFontString2:SetPoint("TOPLEFT", objButton, "TOPLEFT", 0, 0);
  4040.     objButton.objFontString2:SetFont(LSM:Fetch("font", db.Fonts.QuestFont), db.Fonts.QuestFontSize, db.Fonts.QuestFontOutline)
  4041.     objButton.objFontString2:SetSpacing(db.Fonts.QuestFontLineSpacing)
  4042.     if (db.Fonts.HeaderFontShadowed == true) then
  4043.         objButton.objFontString2:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4044.     else
  4045.         objButton.objFontString2:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4046.     end
  4047.     if (campaignChapterInfo) then
  4048.         objButton.objFontString2:SetText(strQuestTitleColour .. campaignChapterInfo.name .. "|r");
  4049.     end
  4050.  
  4051.    
  4052.    
  4053.    
  4054.     objButton:SetScript("OnClick", function(self, button)
  4055.         blnWasAClick = true
  4056.  
  4057.         if (button == "LeftButton") then
  4058.             if (self.ZoneInstance.IsCollapsed == true) then
  4059.                 dbChar.ZoneIsCollapsed[self.ZoneInstance.ID] = false;
  4060.                 self.ZoneInstance:Expand();
  4061.             else
  4062.                 dbChar.ZoneIsCollapsed[self.ZoneInstance.ID] = true;
  4063.                 self.ZoneInstance:Collapse();
  4064.             end
  4065.             QuestTracker:UpdateMinionHandler();        
  4066.         else
  4067.             if (IsAltKeyDown()) then
  4068.                 QuestTracker:DisplayAltRightClickMenu(self)    
  4069.             else
  4070.                 if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  4071.                     QuestTracker:DisplayRightClickMenu(self)
  4072.                 end
  4073.             end
  4074.         end
  4075.     end)
  4076.  
  4077.     objButton:SetScript("OnEnter", function(self)      
  4078.         if (db.MoveTooltipsRight == true) then
  4079.             self.CampaignTooltip:SetPoint("TOPLEFT", self, "TOPRIGHT", 27, 0);
  4080.         else
  4081.             self.CampaignTooltip:SetPoint("TOPRIGHT", self, "TOPLEFT", -5, 0);
  4082.         end    
  4083.  
  4084.         if (campaignInfo) then
  4085.             self.CampaignTooltip.Title:SetText(campaignInfo.name);
  4086.         end
  4087.  
  4088.         if (campaignChapterId) then
  4089.             local campaignChapterInfo = C_CampaignInfo.GetCampaignChapterInfo(campaignChapterId);
  4090.             if (campaignChapterInfo) then
  4091.                 self.CampaignTooltip.ChapterTitle:SetText(campaignChapterInfo.name);
  4092.                 self.CampaignTooltip.Description:SetText(campaignChapterInfo.description);
  4093.                 self.CampaignTooltip.Description:SetTextColor(HIGHLIGHT_FONT_COLOR:GetRGB());
  4094.                 if ( GetNumQuestLogRewards(campaignChapterInfo.rewardQuestID) > 0 ) then
  4095.                     -- if (not EmbeddedItemTooltip_SetItemByQuestReward(self.ItemTooltip, 1, campaignChapterInfo.rewardQuestID)) then
  4096.                         -- self.CampaignTooltip.ItemTooltip:Hide();
  4097.                     -- end
  4098.                 elseif ( GetNumQuestLogRewardSpells(campaignChapterInfo.rewardQuestID) > 0 ) then
  4099.                     -- if (not EmbeddedItemTooltip_SetSpellByQuestReward(self.ItemTooltip, 1, campaignChapterInfo.rewardQuestID)) then
  4100.                         -- self.CampaignTooltip.ItemTooltip:Hide();
  4101.                     -- end
  4102.                 else
  4103.                     -- if (QuestUtils_AddQuestCurrencyRewardsToTooltip(campaignChapterInfo.rewardQuestID, nil, self.ItemTooltip) == 0 ) then
  4104.                         -- self.CampaignTooltip.ItemTooltip:Hide();
  4105.                     -- end
  4106.                     EmbeddedItemTooltip_UpdateSize(self.CampaignTooltip.ItemTooltip);
  4107.                 end
  4108.             else
  4109.                 self.CampaignTooltip.ChapterTitle:SetText(campaignInfo.name);
  4110.                 self.CampaignTooltip.Description:SetText(campaignInfo.playerConditionFailedReason);
  4111.                 self.CampaignTooltip.ItemTooltip:Hide();
  4112.                 self.CampaignTooltip.Description:SetTextColor(NORMAL_FONT_COLOR:GetRGB());
  4113.             end
  4114.         else
  4115.             if ( campaignInfo.complete ) then
  4116.                 self.CampaignTooltip.Description:SetText(WAR_CAMPAIGN_DONE_DESCRIPTION);
  4117.             else
  4118.                 self.CampaignTooltip.Description:SetText(campaignInfo.playerConditionFailedReason);
  4119.             end
  4120.             self.CampaignTooltip.ChapterTitle:SetText(nil);
  4121.             self.CampaignTooltip.ItemTooltip:Hide();
  4122.             self.CampaignTooltip.Description:SetTextColor(NORMAL_FONT_COLOR:GetRGB());
  4123.         end
  4124.  
  4125.         if (self.CampaignTooltip.ItemTooltip:IsShown()) then
  4126.             self.CampaignTooltip.CompleteRewardText:Show();
  4127.         else
  4128.             self.CampaignTooltip.CompleteRewardText:Hide();
  4129.         end
  4130.  
  4131.         self.CampaignTooltip:Layout();
  4132.         self.CampaignTooltip:Show();
  4133.    
  4134.     end)
  4135.    
  4136.     objButton:SetScript("OnLeave", function(self)      
  4137.         self.CampaignTooltip:Hide()
  4138.     end)
  4139.  
  4140.     objButton:Show();
  4141.     return objButton
  4142. end
  4143.  
  4144. function QuestTracker:GetMinionQuestButton(questInstance)
  4145.     local objButton = QuestTracker:GetMinionButton()
  4146.     objButton.QuestInstance = questInstance;
  4147.  
  4148.     -- Get quest text
  4149.     local strQuestTitle, strObjectiveText = objButton.QuestInstance:Render();
  4150.    
  4151.     -- Setup quest title string
  4152.     objButton.objFontString1:SetPoint("TOPLEFT", objButton, "TOPLEFT", 0, 0);
  4153.     objButton.objFontString1:SetFont(LSM:Fetch("font", db.Fonts.QuestFont), db.Fonts.QuestFontSize, db.Fonts.QuestFontOutline)
  4154.     objButton.objFontString1:SetSpacing(db.Fonts.QuestFontLineSpacing)
  4155.     if (db.Fonts.QuestFontShadowed == true) then
  4156.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4157.     else
  4158.         objButton.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4159.     end
  4160.    
  4161.     objButton.objFontString1:SetText(strQuestTitle);
  4162.  
  4163.     -- Setup quest objectives string
  4164.     objButton.objFontString2:SetFont(LSM:Fetch("font", db.Fonts.ObjectiveFont), db.Fonts.ObjectiveFontSize, db.Fonts.ObjectiveFontOutline)
  4165.     objButton.objFontString2:SetSpacing(db.Fonts.ObjectiveFontLineSpacing)
  4166.     if (db.Fonts.ObjectiveFontShadowed == true) then
  4167.         objButton.objFontString2:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4168.     else
  4169.         objButton.objFontString2:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4170.     end
  4171.    
  4172.     if (questInstance.IsWorldQuest) then
  4173.         local timeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes(questInstance.ID);
  4174.         if (timeLeftMinutes and timeLeftMinutes > 0 and timeLeftMinutes < WORLD_QUESTS_TIME_CRITICAL_MINUTES ) then
  4175.             strObjectiveText = strObjectiveText .. "\n" .. strQuestStatusFailed .. BONUS_OBJECTIVE_TIME_LEFT:format(SecondsToTime(timeLeftMinutes * 60)) .. "|r";
  4176.         end
  4177.     end
  4178.    
  4179.     objButton.objFontString2:SetText(strObjectiveText);    
  4180.  
  4181.     -- Create scripts
  4182.     objButton:SetScript("OnClick", function(self, button)
  4183.         blnWasAClick = true
  4184.  
  4185.         if (button == "LeftButton") then
  4186.             if (IsShiftKeyDown()) then
  4187.                 QuestTracker:HandleQuestClick(LEFT_SHIFT_CLICK, self.QuestInstance);
  4188.  
  4189.             elseif (IsControlKeyDown() and IsAltKeyDown()) then
  4190.                 QuestTracker:HandleQuestClick(LEFT_ALT_CTRL_CLICK, self.QuestInstance);
  4191.                
  4192.             elseif (IsAltKeyDown()) then
  4193.                 QuestTracker:HandleQuestClick(LEFT_ALT_CLICK, self.QuestInstance);
  4194.  
  4195.             elseif (IsControlKeyDown()) then
  4196.                 QuestTracker:HandleQuestClick(LEFT_CTRL_CLICK, self.QuestInstance);
  4197.  
  4198.             else
  4199.                 QuestTracker:HandleQuestClick(LEFT_CLICK, self.QuestInstance);
  4200.             end
  4201.         else
  4202.             if (IsShiftKeyDown()) then
  4203.                 QuestTracker:HandleQuestClick(RIGHT_SHIFT_CLICK, self.QuestInstance);
  4204.             else
  4205.                 QuestTracker:HandleQuestClick(RIGHT_CLICK, self.QuestInstance);
  4206.             end
  4207.         end
  4208.     end)
  4209.     objButton:SetScript("OnEnter", function(self)
  4210.         if (db.MoveTooltipsRight == true) then
  4211.             GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, -50);
  4212.         else
  4213.             GameTooltip:SetOwner(self, "ANCHOR_LEFT", 0, -50);
  4214.         end
  4215.  
  4216.         if (self.QuestInstance.IsTask == false) then
  4217.             GameTooltip:SetText(self.QuestInstance.Title, 0, 1, 0, 1);
  4218.             GameTooltip:AddLine(self.QuestInstance.ObjectiveDescription, db.Colours.ObjectiveTooltipTextColour.r, db.Colours.ObjectiveTooltipTextColour.g, db.Colours.ObjectiveTooltipTextColour.b, db.Colours.ObjectiveTooltipTextColour.a);
  4219.         else
  4220.             if (self.QuestInstance.IsWorldQuest) then      
  4221.                 local questID = self.QuestInstance.ID
  4222.                 local headerLine = 1;
  4223.                 local needsSpacer = false;
  4224.                
  4225.                 local mapID, zoneMapID = C_TaskQuest.GetQuestZoneID(questID)
  4226.                
  4227.                 if (mapID and zoneMapID) then
  4228.                     local name = C_MapCanvas.GetZoneInfoByID(mapID, zoneMapID);
  4229.                                
  4230.                     if (name) then
  4231.                         GameTooltip:SetText(name, 0.4, 0.733, 1.0);
  4232.                         needsSpacer = true;
  4233.                         headerLine = headerLine + 1;
  4234.                     end
  4235.                 end
  4236.                
  4237.                 local _, factionID, capped = C_TaskQuest.GetQuestInfoByQuestID(questID);               
  4238.                 if (factionID) then
  4239.                     local factionName = GetFactionInfoByID(factionID);
  4240.                     if ( factionName ) then
  4241.                         if (capped) then
  4242.                             GameTooltip:AddLine(factionName, GRAY_FONT_COLOR:GetRGB());
  4243.                         else
  4244.                             GameTooltip:AddLine(factionName, 0.4, 0.733, 1.0);
  4245.                         end
  4246.                         headerLine = headerLine + 1;
  4247.                        
  4248.                     end
  4249.                 end
  4250.                
  4251.                 local timeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes(questInstance.ID);
  4252.                 if (timeLeftMinutes and timeLeftMinutes > 0) then
  4253.                     GameTooltip:AddLine(BONUS_OBJECTIVE_TIME_LEFT:format(SecondsToTime(timeLeftMinutes * 60)), 1, 1, 1, 1);
  4254.                 end
  4255.                    
  4256.                 if (needsSpacer) then
  4257.                     GameTooltip:AddLine(" ");
  4258.                     headerLine = headerLine + 1;
  4259.                 end
  4260.                    
  4261.                 GameTooltip:AddLine(REWARDS, 1, 0.824, 0);
  4262.                 GameTooltip:AddLine(WORLD_QUEST_TOOLTIP_DESCRIPTION, 1, 1, 1, 1);
  4263.                 GameTooltip:AddLine(" ");
  4264.                 -- xp
  4265.                 local xp = GetQuestLogRewardXP(questID);
  4266.                 if ( xp > 0 ) then
  4267.                     GameTooltip:AddLine(string.format(BONUS_OBJECTIVE_EXPERIENCE_FORMAT, xp), 1, 1, 1);
  4268.                 end
  4269.                 local artifactXP = GetQuestLogRewardArtifactXP(questID);
  4270.                 if ( artifactXP > 0 ) then
  4271.                     GameTooltip:AddLine(string.format(BONUS_OBJECTIVE_ARTIFACT_XP_FORMAT, artifactXP), 1, 1, 1);
  4272.                 end
  4273.                 -- currency    
  4274.                 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(questID);
  4275.                 for i = 1, numQuestCurrencies do
  4276.                     local name, texture, numItems = GetQuestLogRewardCurrencyInfo(i, questID);
  4277.                     local text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, numItems, name);
  4278.                     GameTooltip:AddLine(text, 1, 1, 1);        
  4279.                 end
  4280.                 -- items
  4281.                 local numQuestRewards = GetNumQuestLogRewards(questID);
  4282.                 for i = 1, numQuestRewards do
  4283.                     local name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(i, questID);
  4284.                     local text;
  4285.                     if ( numItems > 1 ) then
  4286.                         text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, numItems, name);
  4287.                     elseif( texture and name ) then
  4288.                         text = string.format(BONUS_OBJECTIVE_REWARD_FORMAT, texture, name);        
  4289.                     end
  4290.                     if( text ) then
  4291.                         local color = ITEM_QUALITY_COLORS[quality];
  4292.                         GameTooltip:AddLine(text, color.r, color.g, color.b);
  4293.                     end
  4294.                 end
  4295.                 -- money
  4296.                 local money = GetQuestLogRewardMoney(questID);
  4297.                 if ( money > 0 ) then
  4298.                     SetTooltipMoney(GameTooltip, money, nil);
  4299.                 end
  4300.             else
  4301.                 GameTooltip:AddLine(BONUS_OBJECTIVE_TOOLTIP_DESCRIPTION, 1, 1, 1, 1);
  4302.                 GameTooltip:AddLine(" ");
  4303.                 -- xp
  4304.                 local xp = GetQuestLogRewardXP(self.QuestInstance.ID);
  4305.                 if ( xp > 0 ) then
  4306.                     GameTooltip:AddLine(string.format(BONUS_OBJECTIVE_EXPERIENCE_FORMAT, xp), 1, 1, 1);
  4307.                 end
  4308.                 -- currency    
  4309.                 local numQuestCurrencies = GetNumQuestLogRewardCurrencies(self.QuestInstance.ID);
  4310.                 for i = 1, numQuestCurrencies do
  4311.                     local name, texture, numItems = GetQuestLogRewardCurrencyInfo(i, self.QuestInstance.ID);
  4312.                     local text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, numItems, name);
  4313.                     GameTooltip:AddLine(text, 1, 1, 1);        
  4314.                 end
  4315.                 -- items
  4316.                 local numQuestRewards = GetNumQuestLogRewards(self.QuestInstance.ID);
  4317.                 for i = 1, numQuestRewards do
  4318.                     local name, texture, numItems, quality, isUsable = GetQuestLogRewardInfo(i, self.QuestInstance.ID);
  4319.                     local text;
  4320.                     if ( numItems > 1 ) then
  4321.                         text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, numItems, name);
  4322.                     elseif( texture and name ) then
  4323.                         text = string.format(BONUS_OBJECTIVE_REWARD_FORMAT, texture, name);        
  4324.                     end
  4325.                     if( text ) then
  4326.                         local color = ITEM_QUALITY_COLORS[quality];
  4327.                         GameTooltip:AddLine(text, color.r, color.g, color.b);
  4328.                     end
  4329.                 end
  4330.                 -- money
  4331.                 local money = GetQuestLogRewardMoney(self.QuestInstance.ID);
  4332.                 if ( money > 0 ) then
  4333.                     SetTooltipMoney(GameTooltip, money, nil);
  4334.                 end
  4335.  
  4336.             end
  4337.         end
  4338.        
  4339.         local strQuestTag = ""
  4340.         if (self.QuestInstance.Frequency == 2) then
  4341.             strQuestTag = strQuestTag .. DAILY .. " "          
  4342.         elseif (self.QuestInstance.Frequency == 3) then
  4343.             strQuestTag = strQuestTag .. CALENDAR_REPEAT_WEEKLY .. " "
  4344.         end            
  4345.  
  4346.         if (self.QuestInstance.SuggestedGroup > 0) then
  4347.             strQuestTag = strQuestTag .. " (" .. self.QuestInstance.SuggestedGroup .. ")"
  4348.         end
  4349.         GameTooltip:AddLine(strQuestTag, 1, 0, 0, 1);
  4350.  
  4351.         if (db.ZonesAndQuests.DisplayQuestIDInTooltip) then
  4352.             GameTooltip:AddLine(self.QuestInstance.ID, 1, 1, 1, 1);
  4353.         end
  4354.        
  4355.         local intPartyMembers = GetNumGroupMembers();
  4356.         if (intPartyMembers > 0) then
  4357.             GameTooltip:AddLine(PARTY_QUEST_STATUS_ON, 0, 1, 0, 1);
  4358.             for k = 1, intPartyMembers do
  4359.                 if (IsUnitOnQuest(self.QuestInstance.Index, "party" .. k)) then
  4360.                     GameTooltip:AddLine(UnitName("party" .. k), 1, 1, 1, 1);
  4361.                 end
  4362.             end            
  4363.         end
  4364.  
  4365.         GameTooltip:Show();
  4366.     end)
  4367.    
  4368.     return objButton
  4369. end
  4370.  
  4371. function QuestTracker:GetStatusBar()
  4372.     return SorhaQuestLog:GetStatusBar()
  4373. end
  4374.  
  4375. function QuestTracker:GetTimerStatusBar(timerInstance)
  4376.     local objStatusBar = SorhaQuestLog:GetStatusBar();
  4377.     objStatusBar.TimerInstance = timerInstance
  4378.  
  4379.     -- Setup colours and texture
  4380.     objStatusBar:SetStatusBarTexture(LSM:Fetch("statusbar", dbCore.StatusBarTexture))
  4381.     objStatusBar:SetStatusBarColor(db.Colours.StatusBarFillColour.r, db.Colours.StatusBarFillColour.g, db.Colours.StatusBarFillColour.b, db.Colours.StatusBarFillColour.a)
  4382.    
  4383.     objStatusBar.Background:SetTexture(LSM:Fetch("statusbar", dbCore.StatusBarTexture))        
  4384.     objStatusBar.Background:SetVertexColor(db.Colours.StatusBarBackColour.r, db.Colours.StatusBarBackColour.g, db.Colours.StatusBarBackColour.b, db.Colours.StatusBarBackColour.a)
  4385.    
  4386.     objStatusBar:SetBackdropColor(db.Colours.StatusBarBackColour.r, db.Colours.StatusBarBackColour.g, db.Colours.StatusBarBackColour.b, db.Colours.StatusBarBackColour.a)
  4387.  
  4388.    
  4389.     objStatusBar.objFontString:SetFont(LSM:Fetch("font", db.Fonts.ObjectiveFont), db.Fonts.ObjectiveFontSize, db.Fonts.ObjectiveFontOutline)
  4390.     if (db.Fonts.ObjectiveFontShadowed == true) then
  4391.         objStatusBar.objFontString:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4392.     else
  4393.         objStatusBar.objFontString:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4394.     end
  4395.  
  4396.     local r,g,b = SorhaQuestLog:GetTimerTextColor(objStatusBar.TimerInstance.Duration, objStatusBar.TimerInstance.Elasped);
  4397.     local colour = format("|c%02X%02X%02X%02X", 255, r * 255, g * 255, b * 255);
  4398.  
  4399.     objStatusBar.objFontString:SetText( colour .. SorhaQuestLog:SecondsToFormatedTime(objStatusBar.TimerInstance.TimeLeft) .. "|r")
  4400.  
  4401.     objStatusBar.Width = objStatusBar.objFontString:GetWidth();
  4402.    
  4403.     objStatusBar.objFontString:SetHeight(math.floor(objStatusBar.objFontString:GetHeight() + 3));
  4404.     objStatusBar:SetHeight(math.floor(objStatusBar.objFontString:GetHeight())) 
  4405.  
  4406.     objStatusBar:SetMinMaxValues(0, objStatusBar.TimerInstance.Duration);
  4407.     objStatusBar:SetValue(objStatusBar.TimerInstance.TimeLeft);
  4408.  
  4409.     objStatusBar:Show()
  4410.  
  4411.     objStatusBar.updateTimer = 0;
  4412.  
  4413.     objStatusBar:SetScript('OnUpdate', function(self, elapsed)
  4414.         self.updateTimer = self.updateTimer + elapsed
  4415.  
  4416.         if(self.updateTimer > 0.05) then
  4417.             self.TimerInstance:Update(self.updateTimer);
  4418.             objStatusBar:SetValue(self.TimerInstance.TimeLeft);
  4419.  
  4420.             local r,g,b = SorhaQuestLog:GetTimerTextColor(self.TimerInstance.Duration, self.TimerInstance.Elasped);
  4421.             local colour = format("|c%02X%02X%02X%02X", 255, r * 255, g * 255, b * 255);
  4422.  
  4423.             objStatusBar.objFontString:SetText( colour .. SorhaQuestLog:SecondsToFormatedTime(self.TimerInstance.TimeLeft) .. "|r")
  4424.             self.updateTimer = 0;
  4425.         end
  4426.     end)
  4427.  
  4428.     objStatusBar:SetWidth(math.floor(db.MinionWidth - db.ZonesAndQuests.QuestTitleIndent));
  4429.     objStatusBar.objFontString:SetWidth(math.floor(db.MinionWidth - db.ZonesAndQuests.QuestTitleIndent))
  4430.     return objStatusBar;
  4431. end
  4432.  
  4433. function QuestTracker:RecycleStatusBar(objStatusBar)
  4434.     objStatusBar:SetScript("OnUpdate", nil);
  4435.     SorhaQuestLog:RecycleStatusBar(objStatusBar)
  4436. end
  4437.  
  4438. function QuestTracker:RecycleMinionButton(objButton)
  4439.     if (objButton.StatusBar ~= nil) then
  4440.         self:RecycleStatusBar(objButton.StatusBar)
  4441.         objButton.StatusBar = nil
  4442.     end
  4443.     if (objButton.TimerBar ~= nil) then
  4444.         self:RecycleStatusBar(objButton.TimerBar)
  4445.         objButton.TimerBar = nil
  4446.     end
  4447.     SorhaQuestLog:RecycleLogButton(objButton)
  4448. end
  4449.  
  4450. function QuestTracker:GetItemButton(objItem, yOffset)
  4451.     local objButton = tremove(tblItemButtonCache)
  4452.     if (objButton == nil) then
  4453.         intNumberOfItemButtons = intNumberOfItemButtons + 1
  4454.         objButton = CreateFrame('Button', strItemButtonPrefix .. intNumberOfItemButtons, UIParent, 'SorhaQuestLogItemButtonTemplate')
  4455.         objButton.rangeTimer = -1
  4456.  
  4457.         if (MSQ) then
  4458.             local group = MSQ:Group("SorhaQuestLog", "Item Buttons")
  4459.             group:AddButton(objButton,{ Icon = objButton.icon })
  4460.         end
  4461.        
  4462.        
  4463.         objButton:SetScript('OnEvent', function(self, event)
  4464.             if (event == "PLAYER_TARGET_CHANGED") then
  4465.                 self.rangeTimer = TOOLTIP_UPDATE_TIME;
  4466.  
  4467.             elseif(event == 'BAG_UPDATE_COOLDOWN') then
  4468.                 QuestObjectiveItem_UpdateCooldown(self)
  4469.  
  4470.             elseif(event == 'PLAYER_REGEN_ENABLED') then
  4471.                 self:SetAttribute('item', self.setItem)
  4472.                 if (self.setItem == nil) then
  4473.                     QuestTracker:TearDownItemButton(objButton);
  4474.                 else               
  4475.                     QuestTracker:SetupItemButton(objButton);
  4476.                 end
  4477.                 self:UnregisterEvent(event)
  4478.             end
  4479.         end)
  4480.     end
  4481.  
  4482.     objButton:SetID(objItem.QuestIndex)
  4483.     objButton.questLogIndex = objItem.QuestIndex;          
  4484.     objButton.yOffset = yOffset;
  4485.     if(objItem.Link) then
  4486.         if(objItem.Link == objButton.itemLink and objButton:IsShown()) then
  4487.             return
  4488.         end
  4489.         objButton.charges = objItem.Charges;
  4490.         objButton.link = objItem.Link
  4491.         objButton.item = objItem.Item      
  4492.         SetItemButtonTexture(objButton, objItem.Item)
  4493.         SetItemButtonCount(objButton, objItem.Charges)
  4494.         objButton.HotKey:Hide()
  4495.     end
  4496.        
  4497.     if(InCombatLockdown()) then
  4498.         objButton.setItem = objButton.link
  4499.         objButton:RegisterEvent('PLAYER_REGEN_ENABLED')
  4500.     else
  4501.         objButton:SetAttribute('item', objButton.link)
  4502.         QuestTracker:SetupItemButton(objButton);
  4503.     end
  4504.    
  4505.     return objButton
  4506. end
  4507.  
  4508. function QuestTracker:RecycleItemButton(objButton)
  4509.     if(InCombatLockdown()) then
  4510.         objButton.setItem = nil
  4511.         objButton:RegisterEvent('PLAYER_REGEN_ENABLED')
  4512.     else
  4513.         objButton:SetAttribute('item', nil)
  4514.         objButton:SetScript('OnUpdate', nil);
  4515.         QuestTracker:TearDownItemButton(objButton);
  4516.     end
  4517. end
  4518.  
  4519. function QuestTracker:SetupItemButton(objButton)   
  4520.     objButton:SetScale(db.ItemButtonScale);
  4521.  
  4522.     objButton:RegisterEvent('BAG_UPDATE_COOLDOWN')
  4523.     objButton:RegisterEvent("PLAYER_TARGET_CHANGED")
  4524.    
  4525.     objButton:SetScript('OnUpdate', function(self, elapsed)
  4526.         self.rangeTimer = self.rangeTimer + elapsed;
  4527.  
  4528.         if(self.rangeTimer >= TOOLTIP_UPDATE_TIME) then
  4529.             if (IsQuestLogSpecialItemInRange(self.questLogIndex) == 0) then
  4530.                 SetItemButtonTextureVertexColor(self, 0.8, 0.1, 0.1)
  4531.             else
  4532.                 SetItemButtonTextureVertexColor(self, 1.0, 1.0, 1.0)
  4533.             end
  4534.             self.rangeTimer = 0
  4535.         end
  4536.     end)
  4537.  
  4538.     objButton:SetParent(fraMinionAnchor);
  4539.     objButton:Show();
  4540.     QuestObjectiveItem_UpdateCooldown(objButton)
  4541.     objButton.Cooldown:SetFrameStrata("DIALOG")
  4542.     if (db.MoveTooltipsRight == true) then
  4543.         objButton:SetPoint("TOPLEFT", fraMinionAnchor, "TOPRIGHT", (8 * (1 / objButton:GetScale())), objButton.yOffset * (1 / objButton:GetScale()))
  4544.     else
  4545.         if (db.IndentItemButtons == true) then
  4546.             objButton:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", (1 * (1 / objButton:GetScale())), objButton.yOffset * (1 / objButton:GetScale()))
  4547.         else
  4548.             objButton:SetPoint("TOPRIGHT", fraMinionAnchor, "TOPLEFT", -(1 * (1 / objButton:GetScale())), objButton.yOffset * (1 / objButton:GetScale()))
  4549.         end
  4550.     end
  4551.     tinsert(tblUsedItemButtons, objButton);
  4552. end
  4553.  
  4554. function QuestTracker:TearDownItemButton(objButton)
  4555.     objButton:SetParent(UIParent)
  4556.     objButton:ClearAllPoints()
  4557.     objButton:Hide()
  4558.     objButton:UnregisterEvent("BAG_UPDATE_COOLDOWN")
  4559.     objButton:UnregisterEvent("PLAYER_TARGET_CHANGED")
  4560.     objButton:SetScript("OnUpdate", nil)
  4561.  
  4562.     tinsert(tblItemButtonCache, objButton);
  4563. end
  4564.  
  4565. --Minion
  4566. function QuestTracker:CreateMinionLayout()
  4567.     fraMinionAnchor = SorhaQuestLog:doCreateFrame("FRAME","SQLQuestMinionAnchor",UIParent,db.MinionWidth,20,1,"BACKGROUND",1, db.MinionLocation.Point, UIParent, db.MinionLocation.RelativePoint, db.MinionLocation.X, db.MinionLocation.Y, 1)
  4568.    
  4569.     fraMinionAnchor:SetMovable(true)
  4570.     fraMinionAnchor:SetClampedToScreen(true)
  4571.     fraMinionAnchor:RegisterForDrag("LeftButton")
  4572.     fraMinionAnchor:SetScript("OnDragStart", fraMinionAnchor.StartMoving)
  4573.     fraMinionAnchor:SetScript("OnDragStop",  function(self)
  4574.         fraMinionAnchor:StopMovingOrSizing()
  4575.         local strPoint, tempB, strRelativePoint, intPosX, intPosY = fraMinionAnchor:GetPoint()
  4576.         db.MinionLocation.Point = strPoint
  4577.         db.MinionLocation.RelativePoint = strRelativePoint
  4578.         db.MinionLocation.X = intPosX
  4579.         db.MinionLocation.Y = intPosY
  4580.     end)
  4581.     fraMinionAnchor:SetScript("OnEnter", function(self)
  4582.         if (db.ShowHelpTooltips == true) then
  4583.             if (db.MoveTooltipsRight == true) then
  4584.                 GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, 0);
  4585.             else
  4586.                 GameTooltip:SetOwner(self, "ANCHOR_LEFT", 0, 0);
  4587.             end
  4588.            
  4589.             GameTooltip:SetText(L["Quest Minion Anchor"], 0, 1, 0, 1);
  4590.             GameTooltip:AddLine(L["Drag this to move the Quest minion when it is unlocked."], 1, 1, 1, 1);
  4591.             local strOutput = ""
  4592.             if (db.ShowNumberOfQuests == true) then
  4593.                 strOutput = strOutput .. L["Displays # of quests you have in your log and the max limit"]
  4594.             end
  4595.             if (db.ShowNumberOfDailyQuests == true) then
  4596.                 strOutput = strOutput .. L["Displays # of daily quests you have done today of the max limit"]
  4597.             end        
  4598.             GameTooltip:AddLine(strOutput, 1, 1, 1, 1);
  4599.             GameTooltip:AddLine(L["You can disable help tooltips in general settings"], 0.5, 0.5, 0.5, 1);
  4600.            
  4601.             GameTooltip:Show();
  4602.         end
  4603.     end)
  4604.     fraMinionAnchor:SetScript("OnLeave", function(self)
  4605.         GameTooltip:Hide()
  4606.     end)
  4607.    
  4608.     fraMinionAnchor:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = false, tileSize = 16,    edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, insets = {left = 5, right = 3, top = 3, bottom = 5}})
  4609.     fraMinionAnchor:SetBackdropColor(0, 1, 0, 0)
  4610.     fraMinionAnchor:SetBackdropBorderColor(0.5, 0.5, 0, 0)
  4611.    
  4612.     -- Quests Anchor
  4613.     fraMinionAnchor.fraQuestsAnchor = SorhaQuestLog:doCreateLooseFrame("FRAME","SQLQuestsAnchor",fraMinionAnchor, fraMinionAnchor:GetWidth(),1,1,"LOW",1,1)
  4614.     fraMinionAnchor.fraQuestsAnchor:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, 0);
  4615.     fraMinionAnchor.fraQuestsAnchor:SetBackdropColor(0, 0, 0, 0)
  4616.     fraMinionAnchor.fraQuestsAnchor:SetBackdropBorderColor(0,0,0,0)
  4617.     fraMinionAnchor.fraQuestsAnchor:SetAlpha(0)
  4618.    
  4619.     -- Number of quests fontstring/title fontstring
  4620.     fraMinionAnchor.objFontString = fraMinionAnchor:CreateFontString(nil, "OVERLAY");
  4621.     fraMinionAnchor.objFontString:SetFont(LSM:Fetch("font", db.Fonts.MinionTitleFont), db.Fonts.MinionTitleFontSize, db.Fonts.MinionTitleFontOutline)
  4622.     fraMinionAnchor.objFontString:SetJustifyH("LEFT")
  4623.     fraMinionAnchor.objFontString:SetJustifyV("TOP")
  4624.     fraMinionAnchor.objFontString:SetText("");
  4625.     if (db.Fonts.MinionTitleFontShadowed == true) then
  4626.         fraMinionAnchor.objFontString:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4627.     else
  4628.         fraMinionAnchor.objFontString:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4629.     end
  4630.     fraMinionAnchor.objFontString:SetShadowOffset(1, -1)
  4631.  
  4632.     fraMinionAnchor.buttonShowHidden = SorhaQuestLog:doCreateLooseFrame("BUTTON","SQLShowHiddenButton",fraMinionAnchor,10,10,1,"LOW",1,1)
  4633.     fraMinionAnchor.buttonShowHidden:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 3, -1);
  4634.     fraMinionAnchor.buttonShowHidden:SetBackdrop({bgFile="Interface\\BUTTONS\\WHITE8X8", edgeFile="Interface\\BUTTONS\\WHITE8X8", tile=false, tileSize=0, edgeSize=1, insets={left=0, right=0, top=0, bottom=0}})
  4635.     fraMinionAnchor.buttonShowHidden:SetBackdropColor(db.Colours.ShowHideButtonColour.r, db.Colours.ShowHideButtonColour.g, db.Colours.ShowHideButtonColour.b, db.Colours.ShowHideButtonColour.a)
  4636.     fraMinionAnchor.buttonShowHidden:SetBackdropBorderColor(db.Colours.ShowHideButtonBorderColour.r, db.Colours.ShowHideButtonBorderColour.g, db.Colours.ShowHideButtonBorderColour.b, db.Colours.ShowHideButtonBorderColour.a)
  4637.  
  4638.  
  4639.     fraMinionAnchor.buttonShowHidden.Update = function(self)
  4640.         if (dbChar.ZonesAndQuests.ShowAllQuests == true) then
  4641.             fraMinionAnchor.buttonShowHidden:SetBackdropColor(db.Colours.ShowHideButtonActiveColour.r, db.Colours.ShowHideButtonActiveColour.g, db.Colours.ShowHideButtonActiveColour.b, db.Colours.ShowHideButtonActiveColour.a)
  4642.         else
  4643.             fraMinionAnchor.buttonShowHidden:SetBackdropColor(db.Colours.ShowHideButtonColour.r, db.Colours.ShowHideButtonColour.g, db.Colours.ShowHideButtonColour.b, db.Colours.ShowHideButtonColour.a)
  4644.         end
  4645.         fraMinionAnchor.buttonShowHidden:SetBackdropBorderColor(db.Colours.ShowHideButtonBorderColour.r, db.Colours.ShowHideButtonBorderColour.g, db.Colours.ShowHideButtonBorderColour.b, db.Colours.ShowHideButtonBorderColour.a)
  4646.     end
  4647.    
  4648.     -- Show/Hide hidden quest button events
  4649.     fraMinionAnchor.buttonShowHidden:RegisterForClicks("AnyUp")
  4650.     fraMinionAnchor.buttonShowHidden:SetScript("OnEnter", function(self)
  4651.         fraMinionAnchor.buttonShowHidden:SetBackdropBorderColor(0, 0, 1, 1)
  4652.         if (db.ShowHelpTooltips == true) then
  4653.             if (db.MoveTooltipsRight == true) then
  4654.                 GameTooltip:SetOwner(self, "ANCHOR_RIGHT", 0, 0);
  4655.             else
  4656.                 GameTooltip:SetOwner(self, "ANCHOR_LEFT", 0, 0);
  4657.             end
  4658.            
  4659.             GameTooltip:SetText(L["Show all quests button"], 0, 1, 0, 1);
  4660.             GameTooltip:AddLine(L["Enable to show all hidden quests"], 1, 1, 1, 1);
  4661.             GameTooltip:AddLine(L["You can disable help tooltips in general settings"], 0.5, 0.5, 0.5, 1);
  4662.            
  4663.             GameTooltip:Show();
  4664.         end
  4665.     end)
  4666.     fraMinionAnchor.buttonShowHidden:SetScript("OnLeave", function(self)
  4667.         fraMinionAnchor.buttonShowHidden:SetBackdropBorderColor(0, 0, 0, 1)
  4668.         GameTooltip:Hide()
  4669.     end)   
  4670.     fraMinionAnchor.buttonShowHidden:SetScript("OnClick", function()
  4671.         if (IsControlKeyDown()) then
  4672.             local hidingZones = false;
  4673.             for k, ZoneInstance in pairs(curQuestInfo.ZoneList) do
  4674.                 if (ZoneInstance.IsCollapsed == false) then
  4675.                     hidingZones = true;
  4676.                     break;
  4677.                 end
  4678.             end
  4679.  
  4680.             for k, ZoneInstance in pairs(curQuestInfo.ZoneList) do
  4681.                 dbChar.ZoneIsCollapsed[ZoneInstance.ID] =hidingZones;
  4682.             end
  4683.         else               
  4684.             dbChar.ZonesAndQuests.ShowAllQuests = not dbChar.ZonesAndQuests.ShowAllQuests
  4685.             fraMinionAnchor.buttonShowHidden.Update();
  4686.         end
  4687.         self:UpdateMinionHandler()
  4688.     end)
  4689.    
  4690.  
  4691.    
  4692.     fraMinionAnchor.BorderFrame = SorhaQuestLog:doCreateFrame("FRAME","SQLQuestMinionBorder", fraMinionAnchor, db.MinionWidth,40,1,"BACKGROUND",1, "TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, 0, 1)
  4693.     fraMinionAnchor.BorderFrame:SetBackdrop({bgFile = LSM:Fetch("background", dbCore.BackgroundTexture), tile = false, tileSize = 16,   edgeFile = LSM:Fetch("border", dbCore.BorderTexture), edgeSize = 16,    insets = {left = 5, right = 3, top = 3, bottom = 3}})
  4694.     fraMinionAnchor.BorderFrame:SetBackdropColor(db.Colours.MinionBackGroundColour.r, db.Colours.MinionBackGroundColour.g, db.Colours.MinionBackGroundColour.b, db.Colours.MinionBackGroundColour.a)
  4695.     fraMinionAnchor.BorderFrame:SetBackdropBorderColor(db.Colours.MinionBorderColour.r, db.Colours.MinionBorderColour.g, db.Colours.MinionBorderColour.b, db.Colours.MinionBorderColour.a)
  4696.     fraMinionAnchor.BorderFrame:Show()
  4697.    
  4698.     fraMinionAnchor.BottomFrame = SorhaQuestLog:doCreateFrame("FRAME","SQLQuestMinionBottom", fraMinionAnchor, db.MinionWidth,40,1,"BACKGROUND",1, "TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, 0, 1)
  4699.  
  4700.    
  4701.        
  4702.     btnSearchQuests = CreateFrame('Button', "SQLSearchQuestsButton", UIParent, 'SecureActionButtonTemplate')
  4703.     btnSearchQuests:SetPoint("TOPRIGHT", fraMinionAnchor, "TOPRIGHT", 0, 2);
  4704.     btnSearchQuests:SetHeight(24)
  4705.     btnSearchQuests:SetWidth(100)
  4706.     btnSearchQuests:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = false, tileSize = 16,edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, insets = {left = 5, right = 3, top = 3, bottom = 5}})
  4707.     btnSearchQuests:SetBackdropColor(0, 0, 0, 0.9)
  4708.     btnSearchQuests:SetBackdropBorderColor(1, 1, 1, 0)
  4709.     btnSearchQuests:SetFrameStrata("DIALOG")
  4710.     btnSearchQuests:SetFrameLevel(2)
  4711.     btnSearchQuests:Hide()
  4712.     btnSearchQuests:SetAttribute("type", "myFunction")
  4713.     btnSearchQuests.myFunction = function(self)
  4714.         local activityID, categoryID, filters, questName = LFGListUtil_GetQuestCategoryData(tmpQuest.ID);
  4715.         if not activityID then
  4716.             self:Hide();           
  4717.             return;
  4718.         end    
  4719.  
  4720.         if (LFGListFrame.CategorySelection.selectedCategory == categoryID and LFGListFrame.activePanel == LFGListFrame.SearchPanel and LFGListFrame:IsVisible()) then
  4721.             self:Hide();           
  4722.  
  4723.             LFGListFrame.SearchPanel.SearchBox:SetText(questName or "");
  4724.             local languages = C_LFGList.GetLanguageSearchFilter();
  4725.             C_LFGList.Search(categoryID, LFGListSearchPanel_ParseSearchTerms(questName), filters, 4, languages)
  4726.         else           
  4727.             if C_LFGList.GetActiveEntryInfo() then
  4728.                 if LFGListUtil_CanListGroup() then
  4729.                     C_LFGList.RemoveListing();
  4730.                     LFGListFrame_SetPendingQuestIDSearch(LFGListFrame, questID);
  4731.                 end
  4732.                 return;
  4733.             end
  4734.            
  4735.             PVEFrame_ShowFrame("GroupFinderFrame", LFGListPVEStub);
  4736.            
  4737.             local panel = LFGListFrame.CategorySelection;
  4738.             LFGListCategorySelection_SelectCategory(panel, categoryID, filters);
  4739.             LFGListEntryCreation_SetAutoCreateMode(panel:GetParent().EntryCreation, "quest", activityID, questID);
  4740.              
  4741.             local searchPanel = panel:GetParent().SearchPanel;
  4742.             LFGListSearchPanel_Clear(searchPanel);
  4743.             searchPanel.SearchBox:SetText(questName or "");
  4744.             LFGListSearchPanel_SetCategory(searchPanel, panel.selectedCategory, panel.selectedFilters, baseFilters);
  4745.             LFGListFrame_SetActivePanel(panel:GetParent(), searchPanel);
  4746.            
  4747.         end
  4748.     end
  4749.     btnSearchQuests.TextFrame = SorhaQuestLog:doCreateLooseFrame("FRAME","SQLSearchQuestsButtonText",SQLSearchQuestsButton, SQLSearchQuestsButton:GetWidth(),1,1,"DIALOG",3,1)
  4750.     btnSearchQuests.TextFrame:SetPoint("TOPRIGHT", SQLSearchQuestsButton, "TOPRIGHT", -5, -4);
  4751.     btnSearchQuests.TextFrame.objFontString1 = btnSearchQuests.TextFrame:CreateFontString(nil, "OVERLAY");
  4752.     btnSearchQuests.TextFrame.objFontString1:SetPoint("TOPRIGHT", btnSearchQuests.TextFrame, "TOPRIGHT", 0, 0);
  4753.     btnSearchQuests.TextFrame.objFontString1:SetFont(LSM:Fetch("font", db.Fonts.HeaderFont), db.Fonts.HeaderFontSize, db.Fonts.HeaderFontOutline)
  4754.     btnSearchQuests.TextFrame.objFontString1:SetSpacing(db.Fonts.HeaderFontLineSpacing)
  4755.     btnSearchQuests.TextFrame.objFontString1:SetJustifyH("RIGHT")
  4756.     btnSearchQuests.TextFrame.objFontString1:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4757.     btnSearchQuests.TextFrame.objFontString1:SetText(strHeaderColour .. L["Click Until Gone"] .. "|r")
  4758.    
  4759.     fraMinionAnchor.CampaignButton = QuestTracker:GetMinionButton();
  4760.     fraMinionAnchor.CampaignButton.CampaignTooltip = CreateFrame("FRAME","CampaignItemTooltip",UIParent,"WarCampaignTooltipTemplate")
  4761.  
  4762.     self:CreateSmartItemButton()
  4763.    
  4764.     blnMinionInitialized = true
  4765.     self:MinionAnchorUpdate(false)
  4766.     self:doHiddenQuestsUpdate() -- Update show/hide hidden quests button position/visibility etc
  4767. end
  4768.  
  4769. function QuestTracker:CreateSmartItemButton()
  4770.  
  4771.     fraMinionAnchor.SmartItemButton = CreateFrame('Button', 'SQLSmartItemButton', UIParent, 'SorhaQuestLogItemButtonTemplate')
  4772.     local objButton = fraMinionAnchor.SmartItemButton;
  4773.    
  4774.     objButton.rangeTimer = -1
  4775.  
  4776.     if (MSQ) then
  4777.         local group = MSQ:Group("SorhaQuestLog", "Item Buttons")
  4778.         group:AddButton(objButton,{ Icon = objButton.icon })
  4779.     end
  4780.    
  4781.     objButton:SetScript('OnEvent', function(self, event)
  4782.         if (event == "PLAYER_TARGET_CHANGED") then
  4783.             self.rangeTimer = TOOLTIP_UPDATE_TIME;
  4784.  
  4785.         elseif(event == 'BAG_UPDATE_COOLDOWN') then
  4786.             if (self.questLogIndex) then
  4787.                 QuestObjectiveItem_UpdateCooldown(self)
  4788.             end
  4789.  
  4790.         elseif(event == 'PLAYER_REGEN_ENABLED') then
  4791.             self:SetParent(fraMinionAnchor);
  4792.             self:SetPoint("TOPRIGHT", fraMinionAnchor, "TOPRIGHT", -2, -2);
  4793.             self:UnregisterEvent(event)
  4794.         end
  4795.     end)
  4796.  
  4797.     if(InCombatLockdown()) then
  4798.         objButton:RegisterEvent('PLAYER_REGEN_ENABLED')
  4799.     else
  4800.         objButton:SetParent(fraMinionAnchor);
  4801.         objButton:SetPoint("TOPRIGHT", fraMinionAnchor, "TOPRIGHT", -2, -2);
  4802.     end
  4803.  
  4804.     objButton:SetID(0)
  4805.     objButton.questLogIndex = nil;
  4806.     objButton:RegisterEvent('BAG_UPDATE_COOLDOWN')
  4807.     objButton:RegisterEvent("PLAYER_TARGET_CHANGED")
  4808.     objButton:SetScale(0.9);
  4809.     objButton:SetScript('OnUpdate', function(self, elapsed)
  4810.         self.rangeTimer = self.rangeTimer + elapsed;
  4811.        
  4812.         if(self.rangeTimer >= TOOLTIP_UPDATE_TIME) then
  4813.             if (not self.questLogIndex or IsQuestLogSpecialItemInRange(self.questLogIndex) == 0) then
  4814.                 SetItemButtonTextureVertexColor(self, 0.8, 0.1, 0.1)
  4815.             else
  4816.                 SetItemButtonTextureVertexColor(self, 1.0, 1.0, 1.0)
  4817.             end
  4818.             self.rangeTimer = 0
  4819.         end
  4820.     end)
  4821.  
  4822.     objButton:Hide();
  4823.  
  4824.  
  4825.        
  4826. end
  4827.  
  4828. function QuestTracker:UpdateMinionHandler()
  4829.     if (blnWasAClick == true) then -- Was the event called from a click (Skips the delay on header collapses etc)
  4830.         blnMinionUpdating = true
  4831.         self:UpdateMinion()
  4832.     elseif (blnMinionUpdating == false) then --If not updating then update, forces a 0.5 second delay between system called updates
  4833.         if (blnIgnoreUpdateEvents == false) then
  4834.             blnMinionUpdating = true
  4835.             self:ScheduleTimer("UpdateMinion", 0.3)
  4836.         end
  4837.     end
  4838. end
  4839.  
  4840. function QuestTracker:UpdateMinion()
  4841.     blnMinionUpdating = true
  4842.     blnWasAClick = false
  4843.  
  4844.     --Build minion
  4845.     if (blnMinionInitialized == false) then
  4846.         self:CreateMinionLayout()
  4847.     end
  4848.  
  4849.     --Get Quest Info, Compare quest data
  4850.     self:GetQuestLogInformation();
  4851.     curQuestInfo:CompleteCheck();
  4852.    
  4853.     -- Update LDB
  4854.     if (LDB) then
  4855.         if (SorhaQuestLog.SQLBroker ~= nil) then
  4856.             if (db.UseQuestCountMaxText == true) then
  4857.                 SorhaQuestLog.SQLBroker.text = strInfoColour .. curQuestInfo.QuestCount .. "/25|r"
  4858.             else
  4859.                 SorhaQuestLog.SQLBroker.text = strInfoColour .. curQuestInfo.QuestCount .. "/"..  curQuestInfo.CompletedQuestCount  .. "|r"
  4860.             end
  4861.         end
  4862.     end
  4863.  
  4864.     --Do nothing if hidden
  4865.     if (self:IsVisible() == false) then
  4866.         blnMinionUpdating = false
  4867.         return ""
  4868.     end
  4869.  
  4870.     -- Release all used buttons
  4871.     fraMinionAnchor.CampaignButton:Hide();
  4872.     for k, objButton in pairs(tblUsingButtons) do
  4873.         self:RecycleMinionButton(objButton)
  4874.     end
  4875.     wipe(tblUsingButtons)
  4876.  
  4877.     local createItemButtons = true;
  4878.     if(InCombatLockdown()) then
  4879.         createItemButtons = false;
  4880.         self:RegisterEvent('PLAYER_REGEN_ENABLED')
  4881.     end
  4882.  
  4883.     if (not InCombatLockdown()) then
  4884.         self:UpdateSmartItemButton();
  4885.         -- Release all used Item buttons
  4886.         for k, objItemButton in pairs(tblUsedItemButtons) do
  4887.             self:RecycleItemButton(objItemButton)
  4888.         end
  4889.         wipe(tblUsedItemButtons)
  4890.     end
  4891.    
  4892.     -- Setup variables
  4893.     local isVisible = false;
  4894.     local intSpacingIncrease = 0
  4895.     local intLargestWidth = 20
  4896.     local blnLargestWidthIsHeader = false
  4897.     local intHeaderOutlineOffset = 0
  4898.     local intQuestOutlineOffset = 0
  4899.     local intObjectiveOutlineOffset = 0
  4900.     local intYPosition = 0
  4901.     local intInitialYOffset = 0
  4902.     local intButtonSize = intItemButtonSize * db.ItemButtonScale
  4903.     local intQuestOffset =  db.ZonesAndQuests.QuestTitleIndent
  4904.     local intObjectiveOffset =  db.ZonesAndQuests.ObjectivesIndent
  4905.     local intQuestWithItemButtonOffset = intQuestOffset + intButtonSize
  4906.    
  4907.  
  4908.  
  4909.    
  4910.     --Add in slight offsets for outlined text to try stop overlap
  4911.     if (db.Fonts.HeaderFontOutline == "THICKOUTLINE") then
  4912.         intHeaderOutlineOffset = 2
  4913.     elseif (db.Fonts.HeaderFontOutline == "OUTLINE" or db.Fonts.HeaderFontOutline == "MONOCHROMEOUTLINE") then
  4914.         intHeaderOutlineOffset = 1
  4915.     end
  4916.     if (db.Fonts.QuestFontOutline == "THICKOUTLINE") then
  4917.         intQuestOutlineOffset = 1.5
  4918.     elseif (db.Fonts.QuestFontOutline == "OUTLINE" or db.Fonts.QuestFontOutline == "MONOCHROMEOUTLINE") then
  4919.         intQuestOutlineOffset = 0.5
  4920.     end
  4921.     if (db.Fonts.ObjectiveFontOutline == "THICKOUTLINE") then
  4922.         intObjectiveOutlineOffset = 1.5
  4923.     elseif (db.Fonts.ObjectiveFontOutline == "OUTLINE" or db.Fonts.ObjectiveFontOutline == "MONOCHROMEOUTLINE") then
  4924.         intObjectiveOutlineOffset = 0.5
  4925.     end
  4926.        
  4927.     -- Number of quests title display
  4928.     if (curQuestInfo.HaveTrackedQuests == false and db.AutoHideTitle == true) then
  4929.         fraMinionAnchor.objFontString:SetText("");
  4930.         fraMinionAnchor.buttonShowHidden:Hide()
  4931.     else
  4932.         isVisible = true;
  4933.        
  4934.         if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  4935.             fraMinionAnchor.buttonShowHidden:Show()
  4936.         else
  4937.             fraMinionAnchor.buttonShowHidden:Hide()
  4938.         end
  4939.        
  4940.         if (db.ShowNumberOfQuests == true or db.ShowNumberOfDailyQuests == true or db.ZonesAndQuests.AllowHiddenQuests == true) then
  4941.             intYPosition = -db.Fonts.MinionTitleFontSize - db.Fonts.MinionTitleFontLineSpacing;
  4942.         else
  4943.             intYPosition = -2 - db.Fonts.MinionTitleFontLineSpacing;
  4944.         end
  4945.        
  4946.         if (db.ShowNumberOfQuests == true or db.ShowNumberOfDailyQuests == true) then
  4947.             fraMinionAnchor.objFontString:SetFont(LSM:Fetch("font", db.Fonts.MinionTitleFont), db.Fonts.MinionTitleFontSize, db.Fonts.MinionTitleFontOutline)
  4948.             fraMinionAnchor.objFontString:SetSpacing(db.Fonts.MinionTitleFontLineSpacing)
  4949.             if (db.Fonts.MinionTitleFontShadowed == true) then
  4950.                 fraMinionAnchor.objFontString:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  4951.             else
  4952.                 fraMinionAnchor.objFontString:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  4953.             end
  4954.            
  4955.             local strText = ""
  4956.             if (db.ShowNumberOfQuests == true) then
  4957.                 if (db.UseQuestCountMaxText == true) then
  4958.                     strText = strText .. strInfoColour .. curQuestInfo.QuestCount .. "/25 |r"
  4959.                 else
  4960.                     strText = strText .. strInfoColour .. curQuestInfo.QuestCount .. "/"..  curQuestInfo.CompletedQuestCount  .. " |r"
  4961.                 end
  4962.  
  4963.             end
  4964.             if (db.ShowNumberOfDailyQuests == true) then
  4965.                 strText = strText ..  strInfoColour .. "(" .. GetDailyQuestsCompleted() .. ")|r"
  4966.             end
  4967.            
  4968.            
  4969.             fraMinionAnchor.objFontString:SetText(strText);
  4970.             if (fraMinionAnchor.objFontString:GetWidth() > intLargestWidth) then
  4971.                 if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  4972.                     intLargestWidth = fraMinionAnchor.objFontString:GetWidth() + 20 -- Offset for the show/hide button pushing the fontstring accross
  4973.                 else
  4974.                     intLargestWidth = fraMinionAnchor.objFontString:GetWidth()
  4975.                 end
  4976.             end
  4977.         else
  4978.             fraMinionAnchor.objFontString:SetText("");
  4979.         end
  4980.     end
  4981.  
  4982.    
  4983.     intInitialYOffset = intYPosition;
  4984.     --local tblTasks = {};
  4985.     local tblItemButtons = {};
  4986.  
  4987.     -- Zone/Quest buttons
  4988.     local campaignId = C_CampaignInfo.GetCurrentCampaignID();
  4989.     local objButton = nil
  4990.     for k, ZoneInstance in zoneSortChooser(curQuestInfo.ZoneList) do
  4991.         if (curQuestInfo.HaveTrackedQuests == false and db.AutoHideTitle == true and ZoneInstance.ID ~= campaignZoneID) then
  4992.             break
  4993.         end
  4994.        
  4995.         if (dbChar.ZonesAndQuests.ShowAllQuests == true or not(db.ZonesAndQuests.AllowHiddenQuests == true and db.ZonesAndQuests.QuestHeadersHideWhenEmpty == true and ZoneInstance:HaveVisibleQuests() == false) or ZoneInstance.ID == campaignZoneID) then
  4996.             if (db.ZonesAndQuests.HideZoneHeaders == false and not (ZoneInstance.IsFakeZone == true and ZoneInstance:HaveVisibleQuests() == false) or (ZoneInstance.ID == campaignZoneID and campaignId ~= nil)) then
  4997.                
  4998.                 if (ZoneInstance.ID and ZoneInstance.ID == campaignZoneID) then
  4999.                     objButton = self:GetCampaignButton(ZoneInstance)
  5000.                
  5001.                     objButton:SetWidth(db.MinionWidth)
  5002.                     --
  5003.                     if (objButton.objFontString1:GetWidth() > intLargestWidth) then
  5004.                         intLargestWidth = objButton.objFontString1:GetWidth()
  5005.                         blnLargestWidthIsHeader = true
  5006.                     end
  5007.                     --
  5008.                     objButton.objFontString1:SetWidth(db.MinionWidth)
  5009.                     intSpacingIncrease = objButton.objFontString1:GetHeight() + intHeaderOutlineOffset + db.Fonts.HeaderFontLineSpacing
  5010.                    
  5011.                     local nextOffset = objButton.objFontString1:GetHeight() + intHeaderOutlineOffset + db.Fonts.HeaderFontLineSpacing;
  5012.                     objButton.objFontString2:SetPoint("TOPLEFT", objButton, "TOPLEFT", intObjectiveOffset, -nextOffset);
  5013.                     objButton.objFontString2:SetWidth(db.MinionWidth)
  5014.                    
  5015.                    
  5016.                     nextOffset = objButton.objFontString2:GetHeight() + intQuestOutlineOffset + db.Fonts.QuestFontLineSpacing;
  5017.                     intSpacingIncrease = intSpacingIncrease + nextOffset
  5018.                    
  5019.                    
  5020.                     objButton:SetHeight(intSpacingIncrease)
  5021.  
  5022.                     objButton:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", 0, intYPosition - intHeaderOutlineOffset)
  5023.                     intYPosition = intYPosition - intSpacingIncrease
  5024.                 else
  5025.                     objButton = self:GetMinionHeaderButton(ZoneInstance)
  5026.                                        
  5027.                     objButton:SetWidth(db.MinionWidth)
  5028.                     --
  5029.                     if (objButton.objFontString1:GetWidth() > intLargestWidth) then
  5030.                         intLargestWidth = objButton.objFontString1:GetWidth()
  5031.                         blnLargestWidthIsHeader = true
  5032.                     end
  5033.                     --
  5034.                     objButton.objFontString1:SetWidth(db.MinionWidth)
  5035.                    
  5036.                     intSpacingIncrease = objButton.objFontString1:GetHeight() + intHeaderOutlineOffset + db.Fonts.HeaderFontLineSpacing
  5037.                     objButton:SetHeight(intSpacingIncrease)
  5038.                     tinsert(tblUsingButtons, objButton)
  5039.  
  5040.                     objButton:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", 0, intYPosition - intHeaderOutlineOffset)
  5041.                     intYPosition = intYPosition - intSpacingIncrease
  5042.                 end
  5043.             end
  5044.            
  5045.             if (ZoneInstance.IsCollapsed == false) then
  5046.                 -- Create each quest in zone
  5047.  
  5048.                 local questSortIndex = 0;
  5049.                 for k2, QuestInstance in questSortChooser(ZoneInstance.QuestList) do
  5050.                     questSortIndex = questSortIndex + 1;
  5051.                     QuestInstance.LastSortIndex = questSortIndex;
  5052.  
  5053.                     if ((QuestInstance.IsHidden == false or QuestInstance.IsTask == true) or db.ZonesAndQuests.AllowHiddenQuests == false or dbChar.ZonesAndQuests.ShowAllQuests == true) then
  5054.                         if (not (QuestInstance.IsTask == true and ZoneInstance.IsFakeZone == false)) then
  5055.                            
  5056.                             local blnHasShownButton = false
  5057.                             local intThisQuestsOffset = intQuestOffset
  5058.                             if (db.ShowItemButtons == true and QuestInstance.QuestItem) then -- Item Buttons on and has a button
  5059.                                 if (db.HideItemButtonsForCompletedQuests == false or (db.HideItemButtonsForCompletedQuests and QuestInstance.IsComplete == false and QuestInstance.IsFailed == false) or (QuestInstance.QuestItem.ShowWhenComplete and QuestInstance.IsComplete)) then -- Button not hidden because of completion
  5060.                                     blnHasShownButton = true
  5061.        
  5062.                                     if (db.IndentItemButtons == true and db.MoveTooltipsRight == false) then
  5063.                                         intThisQuestsOffset = intQuestWithItemButtonOffset
  5064.                                     end
  5065.                                 end
  5066.                             end
  5067.                             if (db.IndentItemButtonQuestsOnly == false and db.IndentItemButtons == true and db.MoveTooltipsRight == false) then
  5068.                                 intThisQuestsOffset = intQuestWithItemButtonOffset             
  5069.                             end
  5070.  
  5071.                             objButton = self:GetMinionQuestButton(QuestInstance)
  5072.                             objButton.intOffset = intThisQuestsOffset
  5073.                             objButton:SetWidth(db.MinionWidth - intThisQuestsOffset)
  5074.  
  5075.                             -- Find out if either string is larger then the current largest string
  5076.                             if (objButton.objFontString1:GetWidth() + intThisQuestsOffset > intLargestWidth) then
  5077.                                 intLargestWidth = objButton.objFontString1:GetWidth() + intThisQuestsOffset*2
  5078.                                 blnLargestWidthIsHeader = false
  5079.                             end
  5080.                             if (objButton.objFontString2:GetWidth() + (intThisQuestsOffset + intObjectiveOffset) > intLargestWidth) then
  5081.                                 intLargestWidth = objButton.objFontString2:GetWidth() + intThisQuestsOffset + intObjectiveOffset
  5082.                                 blnLargestWidthIsHeader = false
  5083.                             end
  5084.  
  5085.                             objButton.objFontString1:SetWidth(db.MinionWidth - intThisQuestsOffset)
  5086.  
  5087.                             -- Set second fontstring of the buttons position
  5088.                             local nextOffset = objButton.objFontString1:GetHeight() + intQuestOutlineOffset + db.Fonts.QuestFontLineSpacing;
  5089.  
  5090.                             if (QuestInstance.Timer ~= nil and not QuestInstance.IsComplete) then
  5091.                                 objButton.TimerBar = QuestTracker:GetTimerStatusBar(QuestInstance.Timer);
  5092.                                 objButton.TimerBar:SetParent(objButton)
  5093.                                 objButton.TimerBar:SetPoint("TOPLEFT", objButton, "TOPLEFT", 0, -nextOffset-3);
  5094.                                 nextOffset = nextOffset + objButton.TimerBar:GetHeight() + 5;
  5095.                                
  5096.                                 objButton.TimerBar.Offsets = intThisQuestsOffset;
  5097.  
  5098.                                 if (intLargestWidth < objButton.TimerBar.Width) then
  5099.                                     intLargestWidth = objButton.TimerBar.Width
  5100.                                 end
  5101.                             end
  5102.  
  5103.                             objButton.objFontString2:SetPoint("TOPLEFT", objButton, "TOPLEFT", intObjectiveOffset, -nextOffset);
  5104.                             objButton.objFontString2:SetWidth(db.MinionWidth - intThisQuestsOffset - intObjectiveOffset)
  5105.                            
  5106.                            
  5107.                             --Progress bars
  5108.                             if (QuestInstance.HasProgressBar == false or (QuestInstance.HasProgressBar == true and QuestInstance.IsComplete == true)) then
  5109.                                 -- Find spacing needed for next button
  5110.                                 nextOffset = objButton.objFontString2:GetHeight() + intObjectiveOutlineOffset + nextOffset                             
  5111.                                 intSpacingIncrease = nextOffset
  5112.                             else
  5113.                                 local percentText = format("%d", QuestInstance.ProgressBarPercent);
  5114.                                 local tmpText = objButton.objFontString2:GetText();
  5115.                                 if (tmpText == nil) then
  5116.                                     tmpText = " - " .. QUEST_COMPLETE .. ": ";
  5117.                                 end
  5118.  
  5119.                                 objButton.objFontString2:SetText(tmpText);
  5120.                                 nextOffset = objButton.objFontString2:GetHeight() + intObjectiveOutlineOffset + nextOffset                             
  5121.  
  5122.  
  5123.                                 if (db.UseStatusBars == false) then
  5124.                                     objButton.objFontString2:SetText(objButton.objFontString2:GetText() .. percentText .. "%");
  5125.                                     intSpacingIncrease = nextOffset
  5126.  
  5127.                                 else
  5128.                                     nextOffset = nextOffset + 4
  5129.                                     intSpacingIncrease = nextOffset
  5130.  
  5131.                                     if (objButton.StatusBar == nil) then
  5132.                                         objButton.StatusBar = self:GetStatusBar()
  5133.                                     end
  5134.                                
  5135.                                     objButton.StatusBar:Show()
  5136.                                     objButton.StatusBar:SetParent(objButton)
  5137.                                     objButton.StatusBar:SetPoint("TOPLEFT", objButton, "TOPLEFT", intObjectiveOffset, -nextOffset);
  5138.                                    
  5139.                                     -- Setup colours and texture
  5140.                                     objButton.StatusBar:SetStatusBarTexture(LSM:Fetch("statusbar", dbCore.StatusBarTexture))
  5141.                                     objButton.StatusBar:SetStatusBarColor(db.Colours.StatusBarFillColour.r, db.Colours.StatusBarFillColour.g, db.Colours.StatusBarFillColour.b, db.Colours.StatusBarFillColour.a)                                  
  5142.                                     objButton.StatusBar.Background:SetTexture(LSM:Fetch("statusbar", dbCore.StatusBarTexture))         
  5143.                                     objButton.StatusBar.Background:SetVertexColor(db.Colours.StatusBarBackColour.r, db.Colours.StatusBarBackColour.g, db.Colours.StatusBarBackColour.b, db.Colours.StatusBarBackColour.a)                                  
  5144.                                     objButton.StatusBar:SetBackdropColor(db.Colours.StatusBarBackColour.r, db.Colours.StatusBarBackColour.g, db.Colours.StatusBarBackColour.b, db.Colours.StatusBarBackColour.a)
  5145.  
  5146.                                
  5147.                                     objButton.StatusBar.objFontString:SetFont(LSM:Fetch("font", db.Fonts.ObjectiveFont), db.Fonts.ObjectiveFontSize, db.Fonts.ObjectiveFontOutline)
  5148.                                     if (db.Fonts.ObjectiveFontShadowed == true) then
  5149.                                         objButton.StatusBar.objFontString:SetShadowColor(0.0, 0.0, 0.0, 1.0)
  5150.                                     else
  5151.                                         objButton.StatusBar.objFontString:SetShadowColor(0.0, 0.0, 0.0, 0.0)
  5152.                                     end
  5153.                                    
  5154.                                     objButton.StatusBar.objFontString:SetText(percentText .. "%")
  5155.                                    
  5156.                                     -- Find out if string is larger then the current largest string
  5157.                                     if (objButton.StatusBar.objFontString:GetWidth() > intLargestWidth) then
  5158.                                         intLargestWidth = objButton.StatusBar.objFontString:GetWidth()
  5159.                                     end
  5160.                                     objButton.StatusBar.objFontString:SetWidth(db.MinionWidth)
  5161.                                     objButton.StatusBar:SetWidth(db.MinionWidth - intThisQuestsOffset - intObjectiveOffset)
  5162.                                     objButton.StatusBar.Offsets = intThisQuestsOffset + intObjectiveOffset;
  5163.                                    
  5164.                                     objButton.StatusBar.objFontString:SetHeight(objButton.StatusBar.objFontString:GetHeight() + 1.5);
  5165.                                     objButton.StatusBar:SetHeight(objButton.StatusBar.objFontString:GetHeight())   
  5166.  
  5167.                                    
  5168.                                     objButton.StatusBar:SetMinMaxValues(0, 100);
  5169.                                     objButton.StatusBar:SetValue(tonumber(QuestInstance.ProgressBarPercent));
  5170.                                
  5171.                                     nextOffset = objButton.StatusBar:GetHeight() + 2                           
  5172.                                     intSpacingIncrease = intSpacingIncrease + nextOffset
  5173.                                 end
  5174.                             end
  5175.  
  5176.                        
  5177.                             -- If theres an item button to be shown add it
  5178.                             if (blnHasShownButton == true) then
  5179.                                
  5180.                                 if (createItemButtons == true) then
  5181.                                     local tmp = {['Item'] = QuestInstance.QuestItem, ['Offset'] = intYPosition};
  5182.                                     tinsert(tblItemButtons, tmp)
  5183.                                     --local objItemButton = self:GetItemButton(QuestInstance.QuestItem, intYPosition)
  5184.                                 end
  5185.                                
  5186.                                 -- If a button is heigher then its quest then expand the quest frame to stop overlapping buttons
  5187.                                 if (intButtonSize > intSpacingIncrease) then
  5188.                                     intSpacingIncrease = intButtonSize
  5189.                                     objButton.objFontString1:SetHeight(intButtonSize)
  5190.                                 end
  5191.                             end
  5192.  
  5193.  
  5194.  
  5195.                             objButton:SetHeight(intSpacingIncrease)
  5196.                             tinsert(tblUsingButtons, objButton)
  5197.  
  5198.                             objButton:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", intThisQuestsOffset, intYPosition)
  5199.                             intYPosition = intYPosition - intSpacingIncrease - db.Fonts.ObjectiveFontLineSpacing - db.ZonesAndQuests.QuestAfterPadding;
  5200.                         end
  5201.                     end
  5202.                 end
  5203.             end
  5204.         end
  5205.     end
  5206.  
  5207.  
  5208.     --Create Item buttons last for position data
  5209.     for key, ItemButtonInfo in pairs(tblItemButtons) do
  5210.         if (db.GrowUpwards == false) then
  5211.             local objItemButton = self:GetItemButton(ItemButtonInfo.Item, ItemButtonInfo.Offset)
  5212.         else
  5213.             local offset = ItemButtonInfo.Offset - intYPosition + 5;
  5214.             local objItemButton = self:GetItemButton(ItemButtonInfo.Item, offset)
  5215.         end    
  5216.     end
  5217.  
  5218.    
  5219.     -- Auto collapse
  5220.     if(InCombatLockdown()  == false) then      
  5221.         fraMinionAnchor:SetWidth(db.MinionWidth)   
  5222.     end
  5223.  
  5224.     local intBorderWidth = db.MinionWidth
  5225.     if (db.MinionCollapseToLeft == true) then
  5226.         if (intLargestWidth < db.MinionWidth) then
  5227.            
  5228.             if(InCombatLockdown() == false) then       
  5229.                 fraMinionAnchor:SetWidth(intLargestWidth)
  5230.             end
  5231.  
  5232.             intBorderWidth = intLargestWidth
  5233.            
  5234.             for k, objButton in pairs(tblUsingButtons) do
  5235.                 objButton.objFontString1:SetWidth(intLargestWidth - objButton.intOffset)
  5236.                 objButton:SetWidth(intLargestWidth - objButton.intOffset)
  5237.  
  5238.                 if (objButton.StatusBar ~= nil) then
  5239.                     objButton.StatusBar.objFontString:SetWidth(intLargestWidth - objButton.StatusBar.Offsets)
  5240.                     objButton.StatusBar:SetWidth(intLargestWidth - objButton.StatusBar.Offsets)
  5241.                 end
  5242.                 if (objButton.TimerBar ~= nil) then
  5243.                     local width = math.floor(intLargestWidth - objButton.TimerBar.Offsets);
  5244.                     objButton.TimerBar.objFontString:SetWidth(width)
  5245.                     objButton.TimerBar:SetWidth(width)
  5246.                 end
  5247.             end
  5248.         end
  5249.     end
  5250.    
  5251.     fraMinionAnchor.BottomFrame:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", 0, intYPosition);
  5252.     fraMinionAnchor.BottomFrame:SetWidth(fraMinionAnchor:GetWidth());
  5253.     fraMinionAnchor.BottomFrame:SetHeight(5);
  5254.    
  5255.    
  5256.     -- Show border if at least the title is shown
  5257.     if (isVisible == false) then
  5258.         fraMinionAnchor.BorderFrame:SetBackdropColor(db.Colours.MinionBackGroundColour.r, db.Colours.MinionBackGroundColour.g, db.Colours.MinionBackGroundColour.b, 0)
  5259.         fraMinionAnchor.BorderFrame:SetBackdropBorderColor(db.Colours.MinionBorderColour.r, db.Colours.MinionBorderColour.g, db.Colours.MinionBorderColour.b, 0)       
  5260.     else
  5261.         fraMinionAnchor.BorderFrame:SetBackdropColor(db.Colours.MinionBackGroundColour.r, db.Colours.MinionBackGroundColour.g, db.Colours.MinionBackGroundColour.b, db.Colours.MinionBackGroundColour.a)
  5262.         fraMinionAnchor.BorderFrame:SetBackdropBorderColor(db.Colours.MinionBorderColour.r, db.Colours.MinionBorderColour.g, db.Colours.MinionBorderColour.b, db.Colours.MinionBorderColour.a) 
  5263.         fraMinionAnchor.BorderFrame:SetWidth(intBorderWidth + 16)
  5264.     end
  5265.    
  5266.     -- Reposition/Resize the border and the Achievements Anchor based on grow upwards option
  5267.     fraMinionAnchor.BorderFrame:ClearAllPoints()
  5268.     if (db.GrowUpwards == false) then
  5269.         fraMinionAnchor.BorderFrame:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", -6, 6);
  5270.         fraMinionAnchor.BorderFrame:SetHeight((-intYPosition) + 6 + fraMinionAnchor:GetHeight()/2)
  5271.         fraMinionAnchor.fraQuestsAnchor:ClearAllPoints()
  5272.         fraMinionAnchor.fraQuestsAnchor:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, 0);
  5273.     else
  5274.         fraMinionAnchor.BorderFrame:SetPoint("TOPLEFT", fraMinionAnchor.fraQuestsAnchor, "TOPLEFT", -6,  6 + intInitialYOffset);
  5275.         fraMinionAnchor.BorderFrame:SetHeight((-intYPosition) + fraMinionAnchor:GetHeight() - 2)
  5276.         fraMinionAnchor.fraQuestsAnchor:ClearAllPoints()
  5277.         fraMinionAnchor.fraQuestsAnchor:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, -intYPosition+5);
  5278.     end
  5279.  
  5280.     blnMinionUpdating = false
  5281. end
  5282.  
  5283. function QuestTracker:UpdateSmartItemButton()
  5284.     local objButton = fraMinionAnchor.SmartItemButton;
  5285.     local questInstance = self:GetClosestItemQuest()
  5286.     if (questInstance)  then
  5287.         objButton:SetID(questInstance.Index)
  5288.         objButton.questLogIndex = questInstance.Index;         
  5289.  
  5290.         local objItem = questInstance.QuestItem;
  5291.         if(objItem.Link) then
  5292.             if(objItem.Link == objButton.itemLink and objButton:IsShown()) then
  5293.                 return
  5294.             end
  5295.             objButton.charges = objItem.Charges;
  5296.             objButton.link = objItem.Link
  5297.             objButton.item = objItem.Item      
  5298.             SetItemButtonTexture(objButton, objItem.Item)
  5299.             SetItemButtonCount(objButton, objItem.Charges)
  5300.             objButton.HotKey:Hide()
  5301.         end
  5302.        
  5303.         --update function
  5304.         QuestObjectiveItem_UpdateCooldown(objButton)
  5305.         objButton.Cooldown:SetFrameStrata("DIALOG")
  5306.         objButton:SetAttribute('item', objButton.link)
  5307.         if (db.ShowCurrentSmartQuestItem) then
  5308.             objButton:Show();
  5309.         end
  5310.     else
  5311.         objButton:SetID(0)
  5312.         objButton.questLogIndex = nil;
  5313.         objButton.itemLink = nil;
  5314.         objButton:Hide();
  5315.     end
  5316. end
  5317.  
  5318.  
  5319. --Quest minion
  5320. function QuestTracker:GetQuestLogInformation()
  5321.     if (curQuestInfo == nil) then
  5322.         curQuestInfo = SQLQuestLogData:new();
  5323.     else
  5324.         curQuestInfo:Update();
  5325.     end
  5326. end
  5327.  
  5328. function QuestTracker:GetCompletionColourString(dblPercent)
  5329.     if (dblPercent == 0.00) then
  5330.         return strObjective00Colour
  5331.     elseif (dblPercent < 0.25) then
  5332.         return strObjective01to24Colour
  5333.     elseif (dblPercent >= 0.25 and dblPercent < 0.50) then
  5334.         return strObjective25to49Colour
  5335.     elseif (dblPercent >= 0.50 and dblPercent < 0.75) then
  5336.         return strObjective50to74Colour
  5337.     elseif (dblPercent >= 0.75 and dblPercent < 1) then
  5338.         return strObjective75to99Colour
  5339.     else
  5340.         return strObjective100Colour
  5341.     end
  5342. end
  5343.  
  5344. function QuestTracker:GetCompletionColourRGB(dblPercent)
  5345.     if (dblPercent < 0.25) then
  5346.         return db.Colours.Objective00PlusColour.r, db.Colours.Objective00PlusColour.g, db.Colours.Objective00PlusColour.b
  5347.     elseif (dblPercent >= 0.25 and dblPercent < 0.50) then
  5348.         return db.Colours.Objective25PlusColour.r, db.Colours.Objective25PlusColour.g, db.Colours.Objective25PlusColour.b
  5349.     elseif (dblPercent >= 0.50 and dblPercent < 0.75) then
  5350.         return db.Colours.Objective50PlusColour.r, db.Colours.Objective50PlusColour.g, db.Colours.Objective50PlusColour.b
  5351.     elseif (dblPercent >= 0.75 and dblPercent < 1) then
  5352.         return db.Colours.Objective75PlusColour.r, db.Colours.Objective75PlusColour.g, db.Colours.Objective75PlusColour.b
  5353.     else
  5354.         return db.Colours.ObjectiveDoneColour.r, db.Colours.ObjectiveDoneColour.g, db.Colours.ObjectiveDoneColour.b
  5355.     end
  5356. end
  5357.  
  5358. function QuestTracker:doHiddenQuestsUpdate()
  5359.     -- Show/Hide hidden quests button and move quest count text accordingly
  5360.     if (blnMinionInitialized == true) then
  5361.         if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  5362.             fraMinionAnchor.objFontString:ClearAllPoints()
  5363.             fraMinionAnchor.objFontString:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 16, 0);
  5364.         else
  5365.             fraMinionAnchor.objFontString:ClearAllPoints()
  5366.             fraMinionAnchor.objFontString:SetPoint("TOPLEFT", fraMinionAnchor, "TOPLEFT", 0, 0);
  5367.         end    
  5368.         fraMinionAnchor.buttonShowHidden.Update();
  5369.     end
  5370. end
  5371.  
  5372. function QuestTracker:DisplayRightClickMenu(objButton)
  5373.     local objMenu = CreateFrame("Frame", "SorhaQuestLogMenuThing")
  5374.     local intLevel = 1
  5375.     local info = {}
  5376.    
  5377.     objMenu.displayMode = "MENU"
  5378.     objMenu.initialize = function(self, intLevel)
  5379.         if not intLevel then return end
  5380.         wipe(info)
  5381.         if intLevel == 1 then
  5382.             -- Create the title of the menu
  5383.             info.isTitle = 1
  5384.             info.text = L["Show/Hide Quests"]
  5385.             info.notCheckable = 1
  5386.             UIDropDownMenu_AddButton(info, intLevel)
  5387.            
  5388.             local intCurrentButton = 0
  5389.             local curZone = curQuestInfo.ZoneList[objButton.ZoneInstance.ID];
  5390.                
  5391.             -- Show/Hide buttons for each quest
  5392.             for k2, QuestInstance in pairs(curZone.QuestList) do
  5393.                 info.disabled = nil
  5394.                 info.isTitle = nil
  5395.                 info.notCheckable = nil
  5396.                 info.text = QuestInstance.Title;
  5397.                 info.func = function()
  5398.                     if (QuestInstance.IsHidden == true) then
  5399.                         if (GetNumQuestWatches() >= 25) then
  5400.                             UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, 25), 1.0, 0.1, 0.1, 1.0);
  5401.                         else
  5402.                             AddQuestWatch(QuestInstance.Index)
  5403.                         end
  5404.                     else
  5405.                         RemoveQuestWatch(QuestInstance.Index)
  5406.                     end
  5407.                     QuestTracker:UpdateMinionHandler()
  5408.                 end
  5409.                 info.checked = not(QuestInstance.IsHidden);
  5410.                 UIDropDownMenu_AddButton(info, intLevel)
  5411.             end
  5412.    
  5413.             -- Hide all button if not all hidden
  5414.             if (curZone.HaveVisibleQuests == true)then
  5415.                 info.text = L["Hide All"]
  5416.                 info.disabled = nil
  5417.                 info.isTitle = nil
  5418.                 info.notCheckable = 1
  5419.                 info.func = function()
  5420.                     for k2, QuestInstance in pairs(curZone.QuestList) do
  5421.                         RemoveQuestWatch(QuestInstance.Index);
  5422.                     end
  5423.                     QuestTracker:UpdateMinionHandler()
  5424.                 end
  5425.                 UIDropDownMenu_AddButton(info, intLevel)
  5426.             end
  5427.            
  5428.             -- Show all button if not all hidden
  5429.             if (curZone.HaveVisibleQuests == true and curZone.HiddenQuestCount > 0)then
  5430.                 info.text = L["Show All"]
  5431.                 info.disabled = nil
  5432.                 info.isTitle = nil
  5433.                 info.notCheckable = 1
  5434.                 info.func = function()
  5435.                     for k2, QuestInstance in pairs(curZone.QuestList) do
  5436.                         if (GetNumQuestWatches() >= 25) then
  5437.                             UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, 25), 1.0, 0.1, 0.1, 1.0);
  5438.                             break
  5439.                         else
  5440.                             AddQuestWatch(QuestInstance.Index)
  5441.                         end
  5442.                     end
  5443.                     QuestTracker:UpdateMinionHandler()
  5444.                 end
  5445.                 UIDropDownMenu_AddButton(info, intLevel)
  5446.             end
  5447.  
  5448.             -- Close menu item
  5449.             info.text = CLOSE
  5450.             info.disabled = nil
  5451.             info.isTitle = nil
  5452.             info.notCheckable = 1
  5453.             info.func = function() CloseDropDownMenus() end
  5454.             UIDropDownMenu_AddButton(info, intLevel)
  5455.         end
  5456.     end
  5457.  
  5458.     ToggleDropDownMenu(1, nil, objMenu, objButton, 0, 0)
  5459. end
  5460.  
  5461. function QuestTracker:DisplayAltRightClickMenu(objButton)
  5462.     local objMenu = CreateFrame("Frame", "SorhaQuestLogMenuThing")
  5463.     local intLevel = 1
  5464.     local info = {}
  5465.    
  5466.     objMenu.displayMode = "MENU"
  5467.     objMenu.initialize = function(self, intLevel)
  5468.         if not intLevel then return end
  5469.         wipe(info)
  5470.         if intLevel == 1 then
  5471.             -- Create the title of the menu
  5472.             info.isTitle = 1
  5473.             info.text = L["Expand/Collapse Zones"]
  5474.             info.notCheckable = 1
  5475.             UIDropDownMenu_AddButton(info, intLevel)
  5476.            
  5477.             -- Collapse/Expand button for each zone
  5478.             for k, ZoneInstance in pairs(curQuestInfo.ZoneList) do
  5479.                 info.disabled = nil
  5480.                 info.isTitle = nil
  5481.                 info.notCheckable = nil
  5482.                 info.text = ZoneInstance.Title;
  5483.                 info.func = function()
  5484.                     if (ZoneInstance.IsCollapsed == true) then
  5485.                         dbChar.ZoneIsCollapsed[ZoneInstance.ID] = false;
  5486.                     else
  5487.                         dbChar.ZoneIsCollapsed[ZoneInstance.ID] = true;
  5488.                     end
  5489.                     QuestTracker:UpdateMinionHandler();
  5490.                 end
  5491.                 info.checked = not(ZoneInstance.IsCollapsed)
  5492.                 UIDropDownMenu_AddButton(info, intLevel)
  5493.             end
  5494.  
  5495.             -- Collapse all button if not all hidden
  5496.             if (curQuestInfo.CollapsedZoneCount < curQuestInfo.ZoneCount)then
  5497.                 info.text = L["Collapse All"]
  5498.                 info.disabled = nil
  5499.                 info.isTitle = nil
  5500.                 info.notCheckable = 1
  5501.                 info.func = function()
  5502.                     for k, ZoneInstance in pairs(curQuestInfo.ZoneList) do
  5503.                         dbChar.ZoneIsCollapsed[ZoneInstance.ID] = true;
  5504.                     end
  5505.                     QuestTracker:UpdateMinionHandler();
  5506.                 end
  5507.                 UIDropDownMenu_AddButton(info, intLevel)
  5508.             end
  5509.            
  5510.             -- Expand all button if not all hidden
  5511.             if (curQuestInfo.CollapsedZoneCount > 0)then
  5512.                 info.text = L["Expand All"]
  5513.                 info.disabled = nil
  5514.                 info.isTitle = nil
  5515.                 info.notCheckable = 1
  5516.                 info.func = function()
  5517.                     for k, ZoneInstance in pairs(curQuestInfo.ZoneList) do
  5518.                         dbChar.ZoneIsCollapsed[ZoneInstance.ID] = false;
  5519.                     end
  5520.                     QuestTracker:UpdateMinionHandler();
  5521.                 end
  5522.                 UIDropDownMenu_AddButton(info, intLevel)
  5523.             end
  5524.  
  5525.             -- Close menu item
  5526.             info.text = CLOSE
  5527.             info.disabled = nil
  5528.             info.isTitle = nil
  5529.             info.notCheckable = 1
  5530.             info.func = function() CloseDropDownMenus() end
  5531.             UIDropDownMenu_AddButton(info, intLevel)
  5532.         end
  5533.     end
  5534.  
  5535.     ToggleDropDownMenu(1, nil, objMenu, objButton, 0, 0)
  5536. end
  5537.  
  5538. function QuestTracker:CheckBags()
  5539.     for k, intBag in pairs(tblBagsToCheck) do
  5540.         for intSlot = 1, GetContainerNumSlots(intBag), 1 do
  5541.             local isQuestItem, questId, isActive = GetContainerItemQuestInfo(intBag, intSlot);
  5542.             if (questId ~= nil and isActive == false) then
  5543.                 local intID = GetContainerItemID(intBag, intSlot)
  5544.                 if (blnFirstBagCheck == true) then
  5545.                     tinsert(tblHaveQuestItems, intID)
  5546.                 else
  5547.                     if not(tContains(tblHaveQuestItems, intID)) then
  5548.                         tinsert(tblHaveQuestItems, intID)
  5549.                         local itemName, itemLink, itemRarity , _, _, _, _, _,_, itemTexture, _ = GetItemInfo(intID)
  5550.                         local _, _, _, hex = GetItemQualityColor(itemRarity)
  5551.                        
  5552.                         hex = "|c" .. hex
  5553.                        
  5554.                         local strOutput = nil
  5555.                         if (db.sink20OutputSink == "Channel") then
  5556.                             strOutput = UnitName("player") .. " " .. L["picked up a quest starting item: "] .. hex .. itemName .. "|r"
  5557.                             self:Pour(strOutput, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b,_,_,_,_,_,itemTexture)
  5558.                         else
  5559.                             local strItem = ""
  5560.                             if (db.sink20OutputSink == "ChatFrame") then
  5561.                                 strItem = "|T" .. itemTexture .. ":15|t"
  5562.                             else
  5563.                                 strItem = "|T" .. itemTexture .. ":20:20:-5|t"
  5564.                             end
  5565.                            
  5566.                             strOutput = L["You picked up a quest starting item: "] .. " " .. strItem .. hex .. itemLink .. "|r"
  5567.                             self:Pour(strOutput, db.Colours.NotificationsColour.r, db.Colours.NotificationsColour.g, db.Colours.NotificationsColour.b)
  5568.                         end
  5569.                        
  5570.                         -- Play sound if enabled
  5571.                         if ((GetTime() - intTimeOfLastSound) > 1 and db.Notifications.QuestItemFoundSound ~= "None") then
  5572.                             PlaySoundFile(LSM:Fetch("sound", db.Notifications.QuestItemFoundSound))
  5573.                             intTimeOfLastSound = GetTime()
  5574.                         end
  5575.                     end
  5576.                 end
  5577.             end
  5578.         end
  5579.     end
  5580.     wipe(tblBagsToCheck)
  5581.  
  5582.     if (blnFirstBagCheck == true) then
  5583.         blnFirstBagCheck = false
  5584.     end
  5585.     blnBagCheckUpdating = false
  5586. end
  5587.  
  5588. function QuestTracker:doHandleZoneChange()
  5589.     blnIgnoreUpdateEvents = true
  5590.    
  5591.     local blnNewZone = not(strZone == GetRealZoneText())
  5592.     strZone = GetRealZoneText()
  5593.     strSubZone = GetSubZoneText()
  5594.     local blnChanged = false
  5595.    
  5596.     if (db.ZonesAndQuests.CollapseOnLeave == true or db.ZonesAndQuests.ExpandOnEnter == true) then
  5597.         if (curQuestInfo == nil) then
  5598.             self:GetQuestLogInformation()
  5599.         end
  5600.  
  5601.         local numEntries, numQuests = GetNumQuestLogEntries(); 
  5602.         for i = numEntries, 1, -1 do
  5603.             local zoneKey = GetQuestLogTitle(i);
  5604.             local zone = curQuestInfo.ZoneList[zoneKey];
  5605.  
  5606.             if (zone) then
  5607.                 if (zone.Title == strZone or zone.Title == strSubZone) then
  5608.                     if (db.ZonesAndQuests.ExpandOnEnter == true and zone.IsCollapsed == true) then
  5609.                         zone:Expand();
  5610.                         blnChanged = true
  5611.                     end
  5612.                 else       
  5613.                     if (db.ZonesAndQuests.CollapseOnLeave == true and zone.IsCollapsed == false and blnNewZone) then               
  5614.                         zone:Collapse();
  5615.                         blnChanged = true
  5616.                     end            
  5617.                 end
  5618.             end
  5619.         end
  5620.     end
  5621.    
  5622.     blnIgnoreUpdateEvents = false
  5623.     if (blnMinionInitialized == true and blnChanged == true) then
  5624.         self:UpdateMinionHandler()
  5625.     end
  5626. end
  5627.  
  5628. function QuestTracker:GetClosestItemQuest()
  5629.     local itemQuests = {}
  5630.     for k, QuestInstance in pairs(curQuestInfo.QuestList) do
  5631.         if (db.ShowItemButtons == true and QuestInstance.QuestItem) then
  5632.             if (db.HideItemButtonsForCompletedQuests == false or (db.HideItemButtonsForCompletedQuests and QuestInstance.IsComplete == false and QuestInstance.IsFailed == false) or (QuestInstance.QuestItem.ShowWhenComplete and QuestInstance.IsComplete)) then
  5633.        
  5634.                 QuestInstance.Distance = 0;
  5635.                 local distanceSq, onContinent = GetDistanceSqToQuest(QuestInstance.Index)
  5636.                 if(onContinent) then
  5637.                     QuestInstance.Distance =  distanceSq;
  5638.                 end
  5639.                 tinsert(itemQuests, QuestInstance)
  5640.             end
  5641.         end
  5642.     end
  5643.     if (#itemQuests < 1) then
  5644.         return nil 
  5645.     end
  5646.     for k, QuestInstance in spairs(itemQuests, function(itemQuests,a,b) return itemQuests[b].Distance > itemQuests[a].Distance end) do
  5647.         return QuestInstance;
  5648.     end
  5649. end
  5650.  
  5651.  
  5652.  
  5653. --Click Bindings
  5654. function QuestTracker:UpdateClickBindings()
  5655.     tblQuestClickBindings = {};
  5656.     tblQuestClickBindings[db.ClickBinds.OpenLog] = function(questInstance) QuestTracker:OpenQuestLog(questInstance); end;
  5657.     tblQuestClickBindings[db.ClickBinds.OpenFullLog] = function(questInstance) QuestTracker:OpenFullQuestLog(questInstance); end;
  5658.     tblQuestClickBindings[db.ClickBinds.AbandonQuest] = function(questInstance) QuestTracker:AbandonQuest(questInstance); end;
  5659.     tblQuestClickBindings[db.ClickBinds.TrackQuest] = function(questInstance) QuestTracker:TrackQuest(questInstance); end;
  5660.     tblQuestClickBindings[db.ClickBinds.LinkQuest] = function(questInstance) QuestTracker:LinkQuest(questInstance); end;   
  5661.     tblQuestClickBindings[db.ClickBinds.HideShowQuest] = function(questInstance) QuestTracker:HideShowQuest(questInstance); end;
  5662.     tblQuestClickBindings[db.ClickBinds.FindGroup] = function(questInstance) QuestTracker:FindQuestGroup(questInstance); end;
  5663.    
  5664. end
  5665.  
  5666. function QuestTracker:HandleQuestClick(binding, questInstance)
  5667.     if (tblQuestClickBindings[binding]) then
  5668.         tblQuestClickBindings[binding](questInstance);
  5669.     end
  5670. end
  5671.  
  5672. function QuestTracker:OpenQuestLog(questInstance)
  5673.     if (questInstance.IsWorldQuest) then
  5674.         if(WorldMapFrame:IsShown() ~= true) then
  5675.             ToggleWorldMap()
  5676.         end
  5677.         local mapID, zoneMapID = C_TaskQuest.GetQuestZoneID(questInstance.ID)
  5678.         if mapID then
  5679.             OpenQuestLog(mapID);
  5680.             WorldMapPing_StartPingQuest(questInstance.ID);
  5681.         end
  5682.        
  5683.        
  5684.         SetSuperTrackedQuestID(questInstance.ID)
  5685.        
  5686.         return
  5687.     end
  5688.     if ( IsQuestComplete(questInstance.ID) and GetQuestLogIsAutoComplete(questInstance.Index) ) then
  5689.         AutoQuestPopupTracker_RemovePopUp(questInstance.ID);
  5690.         ShowQuestComplete(questInstance.Index);
  5691.     else
  5692.         QuestLogPopupDetailFrame_Show(questInstance.Index);
  5693.     end
  5694. end
  5695.  
  5696. function QuestTracker:OpenFullQuestLog(questInstance)
  5697.     if (questInstance.IsWorldQuest) then
  5698.         if IsAddOnLoaded("WorldQuestGroupFinder") then
  5699.             WorldQuestGroupFinder.HandleBlockClick(questInstance.ID)
  5700.         else
  5701.             LFGListUtil_FindQuestGroup(questInstance.ID);
  5702.         end;
  5703.         return
  5704.     end
  5705.     if (QuestLogFrame and QuestLog_SetSelection) then --Legacy quest support
  5706.         QuestLog_SetSelection(questInstance.Index);
  5707.         if (QuestLogFrame:IsVisible() == false) then
  5708.             if (ToggleQuestLog) then
  5709.                 ToggleQuestLog();
  5710.             end
  5711.         end
  5712.     else
  5713.         QuestMapFrame_OpenToQuestDetails(questInstance.ID);
  5714.     end
  5715. end
  5716.  
  5717. function QuestTracker:FindQuestGroup(questInstance)
  5718.     if (questInstance.IsWorldQuest and IsAddOnLoaded("WorldQuestGroupFinder")) then
  5719.         WorldQuestGroupFinder.HandleBlockClick(questInstance.ID)
  5720.     else       
  5721.         if (C_LFGList.CanCreateQuestGroup(questInstance.ID)) then
  5722.             LFGListUtil_FindQuestGroup(questInstance.ID)
  5723.         else
  5724.             print(L["The LFG tool does not work with Quest: "] .. questInstance.Title);
  5725.         end
  5726.     end
  5727. end
  5728.  
  5729. function QuestTracker:TrackQuest(questInstance)
  5730.     SetSuperTrackedQuestID(questInstance.ID)
  5731.    
  5732.     if (DugisGuideViewer and DugisGuideViewer.DugisArrow) then
  5733.         DugisGuideViewer.DugisArrow:QuestPOIWaypoint({questID=questInstance.ID,worldQuest=questInstance.IsWorldQuest},true)
  5734.     end
  5735. end
  5736.  
  5737. function QuestTracker:LinkQuest(questInstance)
  5738.     if (questInstance.IsWorldQuest) then       
  5739.         local zone = "";
  5740.  
  5741.         local mapID, zoneMapID = C_TaskQuest.GetQuestZoneID(questInstance.ID)
  5742.         if (mapID and zoneMapID) then
  5743.             zone = C_MapCanvas.GetZoneInfoByID(mapID, zoneMapID);
  5744.         end            
  5745.                
  5746.         local rewards = {};    
  5747.         local xp = GetQuestLogRewardXP(questInstance.ID);
  5748.         if ( xp > 0 ) then
  5749.             tinsert(rewards,string.format(BONUS_OBJECTIVE_EXPERIENCE_FORMAT, xp))
  5750.         end
  5751.         local artifactXP = GetQuestLogRewardArtifactXP(questInstance.ID);
  5752.         if ( artifactXP > 0 ) then
  5753.             tinsert(rewards,string.format(BONUS_OBJECTIVE_ARTIFACT_XP_FORMAT, artifactXP))
  5754.         end
  5755.        
  5756.         -- currency    
  5757.         for i = 1, GetNumQuestLogRewardCurrencies(questInstance.ID) do
  5758.             local name, _, numItems = GetQuestLogRewardCurrencyInfo(i, questInstance.ID);
  5759.             tinsert(rewards, numItems .. " " .. name);
  5760.         end
  5761.        
  5762.         -- items
  5763.         for i = 1, GetNumQuestLogRewards(questInstance.ID) do
  5764.             local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questInstance.ID);
  5765.             local _, link = GetItemInfo(itemID);
  5766.             tinsert(rewards, link);
  5767.            
  5768.             local text;
  5769.             if ( numItems > 1 ) then
  5770.                 text = string.format(BONUS_OBJECTIVE_REWARD_WITH_COUNT_FORMAT, texture, numItems, name);
  5771.             elseif( texture and name ) then
  5772.                 text = string.format(BONUS_OBJECTIVE_REWARD_FORMAT, texture, name);        
  5773.             end
  5774.             if( text ) then
  5775.                 local color = ITEM_QUALITY_COLORS[quality];
  5776.             end
  5777.            
  5778.  
  5779.         end
  5780.         -- money
  5781.         local money = GetQuestLogRewardMoney(questInstance.ID);
  5782.         if (money > 0) then
  5783.             tinsert(rewards, floor(money / (COPPER_PER_SILVER * SILVER_PER_GOLD)) .. "g");
  5784.         end
  5785.        
  5786.         local rewardText = "";
  5787.         for i=1, #rewards do
  5788.             if (rewardText ~= "") then
  5789.                 rewardText = rewardText .. ", ";
  5790.             end
  5791.             rewardText = rewardText .. rewards[i];
  5792.         end
  5793.        
  5794.         local link = GetQuestLink(questInstance.ID);
  5795.         if (zone and zone ~= "") then
  5796.             link = link .. " - " .. zone;
  5797.         end
  5798.         link = link .. " - " .. REWARDS .. ": " .. rewardText
  5799.        
  5800.    
  5801.        
  5802.         ChatEdit_InsertLink(link)
  5803.         return
  5804.     end
  5805.     if ChatEdit_GetActiveWindow() then -- Link in chat
  5806.         ChatEdit_InsertLink(GetQuestLink(questInstance.ID))
  5807.     else -- Track/untrack quest
  5808.         if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  5809.             if (IsQuestWatched(questInstance.Index) == nil) then
  5810.                 if (GetNumQuestWatches() >= 25) then
  5811.                     UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, 25), 1.0, 0.1, 0.1, 1.0);
  5812.                 else
  5813.                     AddQuestWatch(questInstance.Index)
  5814.                 end
  5815.             else
  5816.                 RemoveQuestWatch(questInstance.Index)
  5817.             end
  5818.             QuestTracker:UpdateMinionHandler()
  5819.         end
  5820.     end
  5821. end
  5822.  
  5823. function QuestTracker:AbandonQuest(questInstance)
  5824.     local intCurrentSelectedIndex = GetQuestLogSelection()
  5825.     SelectQuestLogEntry(questInstance.Index)
  5826.     SetAbandonQuest()
  5827.    
  5828.     if (db.ConfirmQuestAbandons == true) then
  5829.         local items = GetAbandonQuestItems();
  5830.         if ( items ) then
  5831.             StaticPopup_Hide("ABANDON_QUEST");
  5832.             StaticPopup_Show("ABANDON_QUEST_WITH_ITEMS", GetAbandonQuestName(), items);
  5833.         else
  5834.             StaticPopup_Hide("ABANDON_QUEST_WITH_ITEMS");
  5835.             StaticPopup_Show("ABANDON_QUEST", GetAbandonQuestName());
  5836.         end
  5837.     else
  5838.         DEFAULT_CHAT_FRAME:AddMessage("|cFFDF4444" .. L["Quest abandoned: "] .. questInstance.Title .. "|r")
  5839.         PlaySound(SOUNDKIT.IG_QUEST_LOG_ABANDON_QUEST)
  5840.         AbandonQuest()
  5841.     end
  5842.  
  5843.     SelectQuestLogEntry(intCurrentSelectedIndex);
  5844. end
  5845.  
  5846. function QuestTracker:HideShowQuest(questInstance)
  5847.     if (questInstance.IsWorldQuest) then
  5848.         RemoveWorldQuestWatch(questInstance.ID)
  5849.     else
  5850.         if (db.ZonesAndQuests.AllowHiddenQuests == true) then
  5851.             if (IsQuestWatched(questInstance.Index) == nil) then
  5852.                 if (GetNumQuestWatches() >= 25) then
  5853.                     UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY, 25), 1.0, 0.1, 0.1, 1.0);
  5854.                 else
  5855.                     AddQuestWatch(questInstance.Index)
  5856.                 end
  5857.             else
  5858.                 RemoveQuestWatch(questInstance.Index)
  5859.             end
  5860.             QuestTracker:UpdateMinionHandler()
  5861.         end
  5862.     end
  5863. end
  5864.  
  5865.  
  5866.  
  5867. --Uniform
  5868. function QuestTracker:MinionAnchorUpdate(blnMoveAnchors)
  5869.     if (blnMinionInitialized == false) then
  5870.         if (self:IsVisible() == true) then
  5871.             self:CreateMinionLayout()
  5872.         end
  5873.     end
  5874.    
  5875.     if (blnMinionInitialized == true) then
  5876.         -- Enable/Disable movement 
  5877.         if (db.MinionLocked == false) then
  5878.             fraMinionAnchor:EnableMouse(true)
  5879.         else
  5880.             fraMinionAnchor:EnableMouse(false)
  5881.         end
  5882.        
  5883.         -- Show/Hide Minion
  5884.         if (self:IsVisible() == true) then
  5885.             fraMinionAnchor:Show()
  5886.             if (dbCore.Main.ShowAnchors == true and db.MinionLocked == false) then
  5887.                 fraMinionAnchor:SetBackdropColor(0, 1, 0, 1)
  5888.             else
  5889.                 fraMinionAnchor:SetBackdropColor(0, 1, 0, 0)
  5890.             end
  5891.            
  5892.             if (blnMinionUpdating == false) then
  5893.                 self:UpdateMinionHandler()
  5894.             end
  5895.         else
  5896.             fraMinionAnchor:Hide()
  5897.         end
  5898.        
  5899.         fraMinionAnchor.BorderFrame:SetBackdrop({bgFile = LSM:Fetch("background", dbCore.BackgroundTexture), tile = false, tileSize = 16,   edgeFile = LSM:Fetch("border", dbCore.BorderTexture), edgeSize = 16,    insets = {left = 5, right = 3, top = 3, bottom = 3}})
  5900.  
  5901.         -- Set position to stored position
  5902.         if (blnMoveAnchors == true) then
  5903.             fraMinionAnchor:ClearAllPoints()
  5904.             fraMinionAnchor:SetPoint(db.MinionLocation.Point, UIParent, db.MinionLocation.RelativePoint, db.MinionLocation.X, db.MinionLocation.Y);
  5905.             fraMinionAnchor:SetScale(db.MinionScale);
  5906.         end
  5907.     end
  5908. end
  5909.  
  5910. function QuestTracker:UpdateColourStrings()
  5911.     strMinionTitleColour = format("|c%02X%02X%02X%02X", 255, db.Colours.MinionTitleColour.r * 255, db.Colours.MinionTitleColour.g * 255, db.Colours.MinionTitleColour.b * 255);
  5912.     strInfoColour = format("|c%02X%02X%02X%02X", 255, db.Colours.InfoColour.r * 255, db.Colours.InfoColour.g * 255, db.Colours.InfoColour.b * 255);
  5913.     strHeaderColour = format("|c%02X%02X%02X%02X", 255, db.Colours.HeaderColour.r * 255, db.Colours.HeaderColour.g * 255, db.Colours.HeaderColour.b * 255);
  5914.     strQuestStatusFailed = format("|c%02X%02X%02X%02X", 255, db.Colours.QuestStatusFailedColour.r * 255, db.Colours.QuestStatusFailedColour.g * 255, db.Colours.QuestStatusFailedColour.b * 255);
  5915.     strQuestStatusDone = format("|c%02X%02X%02X%02X", 255, db.Colours.QuestStatusDoneColour.r * 255, db.Colours.QuestStatusDoneColour.g * 255, db.Colours.QuestStatusDoneColour.b * 255);
  5916.     strQuestStatusGoto = format("|c%02X%02X%02X%02X", 255, db.Colours.QuestStatusGotoColour.r * 255, db.Colours.QuestStatusGotoColour.g * 255, db.Colours.QuestStatusGotoColour.b * 255);
  5917.     strQuestLevelColour = format("|c%02X%02X%02X%02X", 255, db.Colours.QuestLevelColour.r * 255, db.Colours.QuestLevelColour.g * 255, db.Colours.QuestLevelColour.b * 255);
  5918.     strQuestTitleColour = format("|c%02X%02X%02X%02X", 255, db.Colours.QuestTitleColour.r * 255, db.Colours.QuestTitleColour.g * 255, db.Colours.QuestTitleColour.b * 255);
  5919.     strObjectiveTitleColour = format("|c%02X%02X%02X%02X", 255, db.Colours.ObjectiveTitleColour.r * 255, db.Colours.ObjectiveTitleColour.g * 255, db.Colours.ObjectiveTitleColour.b * 255);
  5920.     strObjectiveStatusColour = format("|c%02X%02X%02X%02X", 255, db.Colours.ObjectiveStatusColour.r * 255, db.Colours.ObjectiveStatusColour.g * 255, db.Colours.ObjectiveStatusColour.b * 255);
  5921.     strObjective00Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.Objective00Colour.r * 255, db.Colours.Objective00Colour.g * 255, db.Colours.Objective00Colour.b * 255);
  5922.     strObjective01to24Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.Objective00PlusColour.r * 255, db.Colours.Objective00PlusColour.g * 255, db.Colours.Objective00PlusColour.b * 255);
  5923.     strObjective25to49Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.Objective25PlusColour.r * 255, db.Colours.Objective25PlusColour.g * 255, db.Colours.Objective25PlusColour.b * 255);
  5924.     strObjective50to74Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.Objective50PlusColour.r * 255, db.Colours.Objective50PlusColour.g * 255, db.Colours.Objective50PlusColour.b * 255);
  5925.     strObjective75to99Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.Objective75PlusColour.r * 255, db.Colours.Objective75PlusColour.g * 255, db.Colours.Objective75PlusColour.b * 255);
  5926.     strObjective100Colour = format("|c%02X%02X%02X%02X", 255, db.Colours.ObjectiveDoneColour.r * 255, db.Colours.ObjectiveDoneColour.g * 255, db.Colours.ObjectiveDoneColour.b * 255);
  5927.     strUndoneColour = format("|c%02X%02X%02X%02X", 255, db.Colours.UndoneColour.r * 255, db.Colours.UndoneColour.g * 255, db.Colours.UndoneColour.b * 255);
  5928.     strDoneColour = format("|c%02X%02X%02X%02X", 255, db.Colours.DoneColour.r * 255, db.Colours.DoneColour.g * 255, db.Colours.DoneColour.b * 255);
  5929.     strObjectiveDescriptionColour = format("|c%02X%02X%02X%02X", 255, db.Colours.ObjectiveDescColour.r * 255, db.Colours.ObjectiveDescColour.g * 255, db.Colours.ObjectiveDescColour.b * 255); 
  5930.     strObjectiveTooltipTextColour = format("|c%02X%02X%02X%02X", 255, db.Colours.ObjectiveTooltipTextColour.r * 255, db.Colours.ObjectiveTooltipTextColour.g * 255, db.Colours.ObjectiveTooltipTextColour.b * 255);
  5931. end
  5932.  
  5933. function QuestTracker:HandleColourChanges()
  5934.     self:UpdateColourStrings()
  5935.  
  5936.     if (blnMinionInitialized) then
  5937.         fraMinionAnchor.buttonShowHidden.Update();
  5938.     end
  5939.     if (self:IsVisible() == true) then
  5940.    
  5941.         if (blnMinionUpdating == false) then
  5942.             blnMinionUpdating = true
  5943.             self:ScheduleTimer("UpdateMinion", 0.1)
  5944.         end
  5945.     end
  5946. end
  5947.  
  5948. function QuestTracker:ToggleLockState()
  5949.     db.MinionLocked = not db.MinionLocked
  5950. end
  5951.  
  5952. function QuestTracker:IsVisible()
  5953.     if (self:IsEnabled() == true and dbCore.Main.HideAll == false) then
  5954.         return true
  5955.     end
  5956.     return false   
  5957. end
Add Comment
Please, Sign In to add comment