Mercurial > wow > spotlight-hidden-artifact-skin-tracking
comparison Spotlight.lua @ 5:59c355620405 v0.7.1.2
Added Slash Handler for /spotlight
Updated LDB display formatting.
Added verification to initialization
| author | Vynn <mischivin@gmail.com> |
|---|---|
| date | Sun, 29 Jan 2017 10:18:10 -0500 |
| parents | c5024af04845 |
| children | a30c29933ebc |
comparison
equal
deleted
inserted
replaced
| 4:61a64da6caec | 5:59c355620405 |
|---|---|
| 5 OnClick = function(clickedframe, button) | 5 OnClick = function(clickedframe, button) |
| 6 Spotlight.ShowPercent = not Spotlight.ShowPercent; | 6 Spotlight.ShowPercent = not Spotlight.ShowPercent; |
| 7 Spotlight.Update(); | 7 Spotlight.Update(); |
| 8 end, | 8 end, |
| 9 }) | 9 }) |
| 10 | |
| 11 SLASH_SPOTLIGHT1, SLASH_SPOTLIGHT2 = "/spotlight", "/Spotlight"; | |
| 12 | |
| 13 local function SlashHandler(msg) | |
| 14 print("|T" .. dataobj.icon .. ":0|t |cffe5cc80Spotlight|r - Artifact Hidden Skin Progress:"); | |
| 15 if Spotlight.IDs then | |
| 16 for key, value in pairs(Spotlight.IDs) do | |
| 17 print(" |cffe5cc80" .. key .. " - " .. Spotlight.Format(key, false) .. " (" .. Spotlight.Format(key, true) .. ")|r"); | |
| 18 end | |
| 19 end | |
| 20 end | |
| 21 | |
| 22 function SlashCmdList.SPOTLIGHT(msg, editbox) | |
| 23 SlashHandler(msg); | |
| 24 end | |
| 10 | 25 |
| 11 local function Initialize () | 26 local function Initialize () |
| 12 if not Spotlight.Status then | 27 if not Spotlight.Status then |
| 13 Spotlight.Status = { | 28 Spotlight.Status = { |
| 14 Dungeons = { | 29 Dungeons = { |
| 59 b = string.format("%i", b * 255); | 74 b = string.format("%i", b * 255); |
| 60 | 75 |
| 61 return "ff" .. string.format("%02x", r) .. string.format("%02x", g) .. string.format("%02x", b); | 76 return "ff" .. string.format("%02x", r) .. string.format("%02x", g) .. string.format("%02x", b); |
| 62 end | 77 end |
| 63 | 78 |
| 64 Spotlight.Format = function (key) | 79 Spotlight.Format = function (key, showPercent) |
| 65 local value = Spotlight.Status[key].Progress / Spotlight.Status[key].Max; | 80 local value = Spotlight.Status[key].Progress / Spotlight.Status[key].Max; |
| 66 if Spotlight.ShowPercent then | 81 if showPercent then |
| 67 value = string.format("|c" .. Spotlight.GetColor(value) .. "%.1f|cffffffff%%|r", value * 100); | 82 value = string.format("|c" .. Spotlight.GetColor(value) .. "%.1f|cffffffff%%|r", value * 100); |
| 68 else | 83 else |
| 69 value = "|c" .. Spotlight.GetColor(value) .. Spotlight.Status[key].Progress .. "|cffffffff/" .. Spotlight.Status[key].Max .. "|r"; | 84 value = "|c" .. Spotlight.GetColor(value) .. Spotlight.Status[key].Progress .. "|cffffffff/" .. Spotlight.Status[key].Max .. "|r"; |
| 70 end | 85 end |
| 71 return value; | 86 return value; |
| 75 local output = ""; | 90 local output = ""; |
| 76 for key, value in pairs(Spotlight.IDs) do | 91 for key, value in pairs(Spotlight.IDs) do |
| 77 Spotlight.Status[key].Completed = select(3, GetAchievementCriteriaInfo(value,1)); | 92 Spotlight.Status[key].Completed = select(3, GetAchievementCriteriaInfo(value,1)); |
| 78 if not Spotlight.Status[key].Completed then | 93 if not Spotlight.Status[key].Completed then |
| 79 Spotlight.Status[key].Progress = Spotlight.Calculate(key); | 94 Spotlight.Status[key].Progress = Spotlight.Calculate(key); |
| 95 if output == "" then | |
| 96 else | |
| 97 output = output .. " ||"; | |
| 98 end | |
| 80 if Spotlight.Status[key].Progress > 0 then | 99 if Spotlight.Status[key].Progress > 0 then |
| 81 output = output .. string.format(" %.1s", key) .. ":" .. Spotlight.Format(key); | 100 output = output .. string.format("|cffe5cc80 %.1s", key) .. ":|r " .. Spotlight.Format(key, Spotlight.ShowPercent); |
| 82 end | 101 end |
| 83 end | 102 end |
| 84 end | 103 end |
| 85 dataobj.icon = GetInventoryItemTexture("player", 16); | 104 dataobj.icon = GetInventoryItemTexture("player", 16); |
| 86 dataobj.text = output; | 105 dataobj.text = output; |
| 87 end | 106 end |
| 88 | 107 |
| 89 Spotlight.Update(); | 108 Spotlight.Update(); |
| 109 | |
| 110 return true | |
| 90 end | 111 end |
| 91 | 112 |
| 92 function dataobj:OnTooltipShow() | 113 function dataobj:OnTooltipShow() |
| 93 self:AddLine("Spotlight - Hidden Artifact Tracker|n|n"); | 114 self:AddLine("|cffe5cc80Spotlight - Hidden Artifact Skins|r|n|n"); |
| 94 for k, v in pairs(Spotlight.IDs) do | 115 for k, v in pairs(Spotlight.IDs) do |
| 95 self:AddDoubleLine(k .. ":", Spotlight.Format(k)); | 116 self:AddDoubleLine(k .. ":", Spotlight.Format(k, false) .. " (" .. Spotlight.Format(k, true) .. ")"); |
| 96 end | 117 end |
| 97 self:AddLine("|nClick to toggle display method"); | 118 self:AddLine("|nClick to toggle display method"); |
| 98 end | 119 end |
| 99 | 120 |
| 100 function dataobj:OnEnter() | 121 function dataobj:OnEnter() |
| 109 GameTooltip:Hide() | 130 GameTooltip:Hide() |
| 110 end | 131 end |
| 111 | 132 |
| 112 local function EventHandler(self, event, ...) | 133 local function EventHandler(self, event, ...) |
| 113 if event == "VARIABLES_LOADED" then | 134 if event == "VARIABLES_LOADED" then |
| 114 Initialize(); | 135 if Initialize() then |
| 136 print("|T" .. dataobj.icon .. ":0|t |cffe5cc80Spotlight v" .. GetAddOnMetadata("Spotlight", "Version") .. " Loaded!|r") | |
| 137 end | |
| 115 end | 138 end |
| 116 if event == "CRITERIA_UPDATE" or "PLAYER_ENTERING_WORLD" then | 139 if event == "CRITERIA_UPDATE" or "PLAYER_ENTERING_WORLD" then |
| 117 Spotlight.Update(); | 140 Spotlight.Update(); |
| 118 end | 141 end |
| 119 end | 142 end |