@@ -15,58 +15,58 @@ local profile, char
1515
1616function KIT :OnInitialize ()
1717 self .db = LibStub (" AceDB-3.0" ):New (" KethoInstanceTimerDB" , S .defaults , true )
18-
18+
1919 self .db .RegisterCallback (self , " OnProfileChanged" , " RefreshDB" )
2020 self .db .RegisterCallback (self , " OnProfileCopied" , " RefreshDB" )
2121 self .db .RegisterCallback (self , " OnProfileReset" , " RefreshDB" )
2222 self :RefreshDB ()
23-
23+
2424 self .db .global .version = S .VERSION
2525 self .db .global .build = S .BUILD
26-
26+
2727 options .args .libsink = self :GetSinkAce3OptionsDataTable ()
2828 options .args .libsink .order = 2
29-
29+
3030 options .args .profiles = LibStub (" AceDBOptions-3.0" ):GetOptionsTable (self .db )
3131 options .args .profiles .order = 4
3232 options .args .profiles .name = " |TInterface\\ Icons\\ INV_Misc_Note_01:16:16:-2:-1" .. S .crop .. " |t " .. options .args .profiles .name
33-
33+
3434 ACR :RegisterOptionsTable (NAME , S .options )
3535 ACD :AddToBlizOptions (NAME , NAME )
3636 ACD :SetDefaultSize (NAME , 550 , 430 )
37-
37+
3838 ---- -----------------
3939 --- Dungeon Names ---
4040 ---- -----------------
41-
41+
4242 if S .isRetail then
4343 -- grab the localized names from the dungeon finder
4444 for i = 1 , GetNumRFDungeons () do
4545 local id , name = GetRFDungeonInfo (i )
4646 S .DungeonName [id ] = name
4747 end
48-
48+
4949 for k , v in pairs (S .SpecialDungeon ) do
5050 S .DungeonName [k ] = GetLFGDungeonInfo (k )
5151 end
5252 end
53-
53+
5454 S .RemapDungeon ()
55-
55+
5656 ---- ------------------
5757 --- Slash Commands ---
5858 ---- ------------------
59-
59+
6060 for _ , v in ipairs ({" kit" , " kethoinstance" , " kethoinstancetimer" }) do
6161 self :RegisterChatCommand (v , " SlashCommand" )
6262 end
63-
63+
6464 ---- -------------------------
6565 --- Custom SavedVariables ---
6666 ---- -------------------------
67-
67+
6868 char .TimeInstanceList = char .TimeInstanceList or {}
69-
69+
7070 -- time data should be preserved between every /reload
7171 char .timeInstance = char .timeInstance or 0
7272 char .startDate = char .startDate or " "
@@ -77,17 +77,17 @@ function KIT:OnEnable()
7777 for _ , v in ipairs (S .isRetail and S .Events or S .ClassicEvents ) do
7878 self :RegisterEvent (v )
7979 end
80-
80+
8181 -- support [Class Colors] by Phanx
8282 if CUSTOM_CLASS_COLORS then
8383 CUSTOM_CLASS_COLORS :RegisterCallback (" WipeCache" , self )
8484 end
85-
85+
8686 -- player is not in a group (anymore) -> reset timer
8787 if not IsInGroup () then
8888 self :ResetTime (true )
8989 end
90-
90+
9191 -- initialize stopwatch while in an instance
9292 if S .IsStopwatch () then
9393 S .instance = select (2 , IsInInstance ())
9797
9898function KIT :OnDisable ()
9999 self :UnregisterAllEvents ()
100-
100+
101101 if CUSTOM_CLASS_COLORS then
102102 CUSTOM_CLASS_COLORS :UnregisterCallback (" WipeCache" , self )
103103 end
104-
104+
105105 if S .IsStopwatch () then
106106 S .StopwatchEnd ()
107107 end
110110function KIT :RefreshDB ()
111111 profile = self .db .profile
112112 char = self .db .char
113-
113+
114114 self :SetSinkStorage (profile ) -- LibSink
115-
115+
116116 -- update table references in other files
117117 for i = 1 , 2 do
118118 self [" RefreshDB" .. i ](self )
@@ -153,18 +153,18 @@ end
153153
154154function KIT :PLAYER_ENTERING_WORLD (event )
155155 S .instance = select (2 , IsInInstance ())
156-
156+
157157 local prevInstance = S .mapinstance
158158 S .mapinstance = select (8 , GetInstanceInfo ())
159-
159+
160160 if S .pve [S .instance ] and not S .IsGarrison () then
161161 -- zoned from an instance to a different instance
162162 local changedInstances = prevInstance and prevInstance ~= S .mapinstance
163163 -- entered instance
164164 if char .timeInstance == 0 or changedInstances then
165165 self :StartData ()
166166 end
167-
167+
168168 if S .IsStopwatch () then
169169 S .StopwatchStart ()
170170 end
@@ -174,7 +174,7 @@ function KIT:PLAYER_ENTERING_WORLD(event)
174174 elseif (S .instance == " none" or S .IsGarrison ()) and not IsInGroup (LE_PARTY_CATEGORY_INSTANCE ) then
175175 -- left instance
176176 self :ResetTime (true )
177-
177+
178178 if profile .Stopwatch then
179179 S .StopwatchEnd ()
180180 end
@@ -187,33 +187,33 @@ end
187187
188188function KIT :COMBAT_LOG_EVENT_UNFILTERED (event )
189189 local timestamp , subevent , hideCaster , sourceGUID , sourceName , sourceFlags , sourceRaidFlags , destGUID , destName , destFlags , destRaidFlags = CombatLogGetCurrentEventInfo ()
190-
190+
191191 if subevent ~= " UNIT_DIED" then return end
192-
192+
193193 local unitType , _ , _ , _ , _ , npcId = strsplit (" -" , destGUID )
194194 npcId = tonumber (npcId )
195-
195+
196196 local hasBossID = S .isRetail and S .BossIDs [npcId ] or S .ClassicBossIDs [npcId ]
197197 -- dont report raid finder in normal/heroic/mythic raids
198198 -- note that we still want to report in dungeons like maraudon and seasonal
199199 local name = not S .IsNormalRaid () and S .DungeonIDs [npcId ] or hasBossID
200-
200+
201201 if S .npc [unitType ] and name and char .timeInstance > 0 then
202-
202+
203203 -- boss fights with multiple npcs
204204 if S .Multiple [npcId ] and not S .CheckMultiple (npcId ) then return end
205-
205+
206206 -- if its raid finder/seasonal, get specific name, otherwise fall back to zone
207207 local name = (type (name ) == " string" ) and name
208-
208+
209209 -- Record
210210 self :Record (name )
211-
211+
212212 -- Report
213213 if profile [S .instance ] then
214214 self :Pour (self :InstanceText (nil , name ))
215215 end
216-
216+
217217 self :Finalize ()
218218 end
219219end
@@ -229,7 +229,7 @@ function KIT:CHAT_MSG_SYSTEM(event, msg)
229229 -- left or kicked from group; or reset through ResetInstances()
230230 if msg == ERR_LEFT_GROUP_YOU or msg == ERR_UNINVITE_YOU or strfind (msg , INSTANCE_RESET_SUCCESS ) then
231231 self :ResetTime (true )
232-
232+
233233 if profile .Stopwatch then
234234 S .StopwatchEnd ()
235235 end
@@ -244,7 +244,7 @@ function KIT:LFG_PROPOSAL_SUCCEEDED(event)
244244 C_Timer .After (20 , function ()
245245 if char .timeInstance == 0 then
246246 self :StartData ()
247-
247+
248248 if S .IsStopwatch () then
249249 S .StopwatchStart ()
250250 end
@@ -261,11 +261,11 @@ function KIT:SecondaryCompletion()
261261 C_Timer .After (1 , function ()
262262 if char .timeInstance > 0 then
263263 self :Record ()
264-
264+
265265 if profile [S .instance ] then
266266 self :Pour (self :InstanceText ())
267267 end
268-
268+
269269 self :Finalize ()
270270 end
271271 end )
0 commit comments