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