mischivin@14
|
1 local initizlized = false;
|
mischivin@14
|
2
|
mischivin@0
|
3 local dataobj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Spotlight", {
|
mischivin@0
|
4 type = "data source",
|
mischivin@3
|
5 text = "Nothing to track!",
|
mischivin@0
|
6 icon = GetInventoryItemTexture("player", 16),
|
mischivin@0
|
7 OnClick = function(clickedframe, button)
|
mischivin@23
|
8 if button == "LeftButton" then
|
mischivin@23
|
9 Spotlight.ShowPercent = not Spotlight.ShowPercent;
|
mischivin@23
|
10 elseif button == "RightButton" then
|
mischivin@23
|
11 Spotlight.ShowIcon = not Spotlight.ShowIcon;
|
mischivin@23
|
12 end
|
mischivin@0
|
13 Spotlight.Update();
|
mischivin@0
|
14 end,
|
mischivin@0
|
15 })
|
mischivin@0
|
16
|
mischivin@5
|
17 SLASH_SPOTLIGHT1, SLASH_SPOTLIGHT2 = "/spotlight", "/Spotlight";
|
mischivin@5
|
18
|
mischivin@23
|
19 local ICONS = {
|
mischivin@23
|
20 PvP = "|T1339312:12:12:0:0:512:128:416:432:42:58|t",
|
mischivin@23
|
21 Dungeons = "|T1339312:12:12:0:0:512:128:416:432:24:40|t",
|
mischivin@23
|
22 WorldQuests = "|T1339312:12:12:0:0:512:128:428:444:87:103|t",
|
mischivin@23
|
23 }
|
mischivin@23
|
24
|
mischivin@5
|
25 local function SlashHandler(msg)
|
mischivin@9
|
26 print("|T" .. Spotlight.Icon .. ":0|t |cffe5cc80Spotlight|r - Artifact Hidden Skin Progress:");
|
mischivin@5
|
27 if Spotlight.IDs then
|
mischivin@5
|
28 for key, value in pairs(Spotlight.IDs) do
|
mischivin@23
|
29 print(" " .. ICONS[tostring(key)] .. " |cffe5cc80" .. key .. " - " .. Spotlight.Format(key, false) .. " (" .. Spotlight.Format(key, true) .. ")|r");
|
mischivin@5
|
30 end
|
mischivin@5
|
31 end
|
mischivin@5
|
32 end
|
mischivin@5
|
33
|
mischivin@5
|
34 function SlashCmdList.SPOTLIGHT(msg, editbox)
|
mischivin@5
|
35 SlashHandler(msg);
|
mischivin@5
|
36 end
|
mischivin@5
|
37
|
mischivin@14
|
38 local function Initialize()
|
mischivin@0
|
39 if not Spotlight.Status then
|
mischivin@0
|
40 Spotlight.Status = {
|
mischivin@0
|
41 Dungeons = {
|
mischivin@0
|
42 Completed = false,
|
mischivin@0
|
43 Progress = 0,
|
mischivin@0
|
44 Max = 100,
|
mischivin@0
|
45 },
|
mischivin@0
|
46 WorldQuests = {
|
mischivin@0
|
47 Completed = false,
|
mischivin@0
|
48 Progress = 0,
|
mischivin@0
|
49 Max = 200,
|
mischivin@0
|
50 },
|
mischivin@0
|
51 PvP = {
|
mischivin@0
|
52 Completed = false,
|
mischivin@0
|
53 Progress = 0,
|
mischivin@0
|
54 Max = 1000,
|
mischivin@0
|
55 },
|
mischivin@0
|
56 };
|
mischivin@0
|
57 Spotlight.ShowPercent = true;
|
mischivin@23
|
58 Spotlight.ShowIcon = false;
|
mischivin@0
|
59 end
|
mischivin@0
|
60
|
mischivin@0
|
61 Spotlight.IDs = {
|
mischivin@0
|
62 Dungeons = 11152,
|
mischivin@0
|
63 WorldQuests = 11153,
|
mischivin@0
|
64 PvP = 11154,
|
mischivin@0
|
65 };
|
mischivin@0
|
66
|
mischivin@0
|
67 Spotlight.Calculate = function (key)
|
mischivin@0
|
68 local value = 0;
|
mischivin@0
|
69 for index = 1, GetAchievementNumCriteria(Spotlight.IDs[key]) do
|
mischivin@0
|
70 value = value + select(4, GetAchievementCriteriaInfo(Spotlight.IDs[key], index));
|
mischivin@0
|
71 end
|
mischivin@0
|
72 return value;
|
mischivin@0
|
73 end
|
mischivin@0
|
74
|
mischivin@0
|
75 Spotlight.GetColor = function (value)
|
mischivin@0
|
76 value = value * 2;
|
mischivin@0
|
77 local r = (2 - value);
|
mischivin@0
|
78 local g = value;
|
mischivin@0
|
79 local b = 0;
|
mischivin@0
|
80
|
mischivin@0
|
81 if r > 1 then r = 1 end
|
mischivin@0
|
82 if g > 1 then g = 1 end
|
mischivin@0
|
83 if b > 1 then b = 1 end
|
mischivin@0
|
84
|
mischivin@0
|
85 r = string.format("%i", r * 255);
|
mischivin@0
|
86 g = string.format("%i", g * 255);
|
mischivin@0
|
87 b = string.format("%i", b * 255);
|
mischivin@0
|
88
|
mischivin@0
|
89 return "ff" .. string.format("%02x", r) .. string.format("%02x", g) .. string.format("%02x", b);
|
mischivin@0
|
90 end
|
mischivin@0
|
91
|
mischivin@5
|
92 Spotlight.Format = function (key, showPercent)
|
mischivin@0
|
93 local value = Spotlight.Status[key].Progress / Spotlight.Status[key].Max;
|
mischivin@5
|
94 if showPercent then
|
mischivin@0
|
95 value = string.format("|c" .. Spotlight.GetColor(value) .. "%.1f|cffffffff%%|r", value * 100);
|
mischivin@0
|
96 else
|
mischivin@0
|
97 value = "|c" .. Spotlight.GetColor(value) .. Spotlight.Status[key].Progress .. "|cffffffff/" .. Spotlight.Status[key].Max .. "|r";
|
mischivin@0
|
98 end
|
mischivin@0
|
99 return value;
|
mischivin@0
|
100 end
|
mischivin@0
|
101
|
mischivin@0
|
102 Spotlight.Update = function (self)
|
mischivin@9
|
103 Spotlight.Icon = GetInventoryItemTexture("player", 16);
|
mischivin@9
|
104
|
mischivin@0
|
105 local output = "";
|
mischivin@0
|
106 for key, value in pairs(Spotlight.IDs) do
|
mischivin@0
|
107 Spotlight.Status[key].Completed = select(3, GetAchievementCriteriaInfo(value,1));
|
mischivin@0
|
108 if not Spotlight.Status[key].Completed then
|
mischivin@0
|
109 Spotlight.Status[key].Progress = Spotlight.Calculate(key);
|
mischivin@23
|
110 if output == "" then
|
mischivin@23
|
111 output = " ";
|
mischivin@5
|
112 else
|
mischivin@23
|
113 output = output .. " || ";
|
mischivin@5
|
114 end
|
mischivin@3
|
115 if Spotlight.Status[key].Progress > 0 then
|
mischivin@23
|
116 if Spotlight.ShowIcon then
|
mischivin@23
|
117 output = output .. ICONS[tostring(key)] .. Spotlight.Format(key, Spotlight.ShowPercent);
|
mischivin@23
|
118 else
|
mischivin@23
|
119 output = output .. string.format("|cffe5cc80%.1s", key) .. ":|r " .. Spotlight.Format(key, Spotlight.ShowPercent);
|
mischivin@23
|
120 end
|
mischivin@3
|
121 end
|
mischivin@0
|
122 end
|
mischivin@0
|
123 end
|
mischivin@23
|
124 if output == "" then
|
mischivin@23
|
125 output = " Everything Unlocked!";
|
mischivin@23
|
126 end
|
mischivin@9
|
127
|
mischivin@9
|
128 dataobj.icon = Spotlight.Icon
|
mischivin@0
|
129 dataobj.text = output;
|
mischivin@0
|
130 end
|
mischivin@0
|
131
|
mischivin@0
|
132 Spotlight.Update();
|
mischivin@5
|
133
|
mischivin@5
|
134 return true
|
mischivin@0
|
135 end
|
mischivin@0
|
136
|
mischivin@0
|
137 function dataobj:OnTooltipShow()
|
mischivin@5
|
138 self:AddLine("|cffe5cc80Spotlight - Hidden Artifact Skins|r|n|n");
|
mischivin@0
|
139 for k, v in pairs(Spotlight.IDs) do
|
mischivin@19
|
140 if not Spotlight.Status[k].Completed then
|
mischivin@23
|
141 self:AddDoubleLine(ICONS[tostring(k)] .. " " .. k .. ":", Spotlight.Format(k, false) .. " (" .. Spotlight.Format(k, true) .. ")");
|
mischivin@19
|
142 end
|
mischivin@0
|
143 end
|
mischivin@23
|
144 self:AddLine("|nLeft Click to toggle Percentage or Fractional Display");
|
mischivin@23
|
145 self:AddLine("|nRight Click to toggle Icon or Text Labels")
|
mischivin@0
|
146 end
|
mischivin@0
|
147
|
mischivin@0
|
148 function dataobj:OnEnter()
|
mischivin@0
|
149 GameTooltip:SetOwner(self, "ANCHOR_NONE");
|
mischivin@0
|
150 GameTooltip:SetPoint("TOP", self, "BOTTOM");
|
mischivin@0
|
151 GameTooltip:ClearLines();
|
mischivin@0
|
152 dataobj.OnTooltipShow(GameTooltip);
|
mischivin@0
|
153 GameTooltip:Show();
|
mischivin@0
|
154 end
|
mischivin@0
|
155
|
mischivin@0
|
156 function dataobj:OnLeave()
|
mischivin@0
|
157 GameTooltip:Hide()
|
mischivin@0
|
158 end
|
mischivin@0
|
159
|
mischivin@0
|
160 local function EventHandler(self, event, ...)
|
mischivin@0
|
161 if event == "VARIABLES_LOADED" then
|
mischivin@5
|
162 if Initialize() then
|
mischivin@14
|
163 initialized = true;
|
mischivin@14
|
164 print("|T" .. (Spotlight.Icon or 1355359) .. ":0|t |cffe5cc80Spotlight v" .. GetAddOnMetadata("Spotlight", "Version") .. " Loaded!|r");
|
mischivin@5
|
165 end
|
mischivin@0
|
166 end
|
mischivin@14
|
167 if event == "CRITERIA_UPDATE" or "PLAYER_ENTERING_WORLD" and initialized then
|
mischivin@0
|
168 Spotlight.Update();
|
mischivin@0
|
169 end
|
mischivin@0
|
170 end
|
mischivin@0
|
171
|
mischivin@0
|
172 local EventListener = CreateFrame("FRAME", "Spotlight");
|
mischivin@0
|
173 EventListener:RegisterEvent("VARIABLES_LOADED");
|
mischivin@0
|
174 EventListener:RegisterEvent("CRITERIA_UPDATE");
|
mischivin@3
|
175 EventListener:RegisterEvent("PLAYER_ENTERING_WORLD");
|
mischivin@0
|
176 EventListener:SetScript("OnEvent", EventHandler);
|
mischivin@0
|
177
|