Mercurial > wow > mailopener
comparison Modules/Collected.lua @ 76:364791db5503
Hopefully fixed the session time spent tracker.
Forgot some localizations in the Collected module.
| author | Zerotorescue |
|---|---|
| date | Wed, 15 Sep 2010 23:51:43 +0200 |
| parents | f01e0184a275 |
| children | bd80e4b4042f |
comparison
equal
deleted
inserted
replaced
| 75:5dcc50650dd3 | 76:364791db5503 |
|---|---|
| 104 end | 104 end |
| 105 | 105 |
| 106 function mod:MAIL_CLOSED() | 106 function mod:MAIL_CLOSED() |
| 107 self:Debug("MAIL_CLOSED"); | 107 self:Debug("MAIL_CLOSED"); |
| 108 | 108 |
| 109 self:Summarize(); | 109 self:Summarize(true); |
| 110 | 110 |
| 111 self:Stop(); | 111 self:Stop(); |
| 112 end | 112 end |
| 113 | 113 |
| 114 function mod:PLAYER_MONEY() | 114 function mod:PLAYER_MONEY() |
| 185 end | 185 end |
| 186 | 186 |
| 187 function mod:MO_OPEN_COMPLETE() | 187 function mod:MO_OPEN_COMPLETE() |
| 188 -- Only summarize when changed | 188 -- Only summarize when changed |
| 189 if updated then | 189 if updated then |
| 190 self:Summarize(); | 190 self:Summarize(false); |
| 191 | 191 |
| 192 updated = false; | 192 updated = false; |
| 193 end | 193 end |
| 194 end | 194 end |
| 195 | 195 |
| 218 | 218 |
| 219 -- Time Spent | 219 -- Time Spent |
| 220 timeStarted = nil; | 220 timeStarted = nil; |
| 221 end | 221 end |
| 222 | 222 |
| 223 function mod:Summarize() | 223 function mod:Summarize(full) |
| 224 -- Message buffer, append details we have data for | 224 -- Message buffer, append details we have data for |
| 225 local printMessage = ""; | 225 local printMessage = ""; |
| 226 | 226 |
| 227 local timeSpent; | 227 local timeSpent, tempSessionTimeSpent; |
| 228 if timeStarted then | 228 if timeStarted then |
| 229 timeSpent = ( GetTime() - timeStarted ); | 229 timeSpent = ( GetTime() - timeStarted ); |
| 230 | |
| 231 if self.db.profile.sessionSummary and self.db.profile.trackTimeSpent then | |
| 232 tempSessionTimeSpent = ( sessionTimeSpent + timeSpent ); | |
| 230 | 233 |
| 231 if self.db.profile.sessionSummary and self.db.profile.trackTimeSpent then | 234 if full then |
| 232 sessionTimeSpent = ( sessionTimeSpent + timeSpent ); | 235 -- Only remember the timespent when the mailbox is closed |
| 236 sessionTimeSpent = tempSessionTimeSpent; | |
| 237 end | |
| 233 end | 238 end |
| 234 end | 239 end |
| 235 | 240 |
| 236 -- Did we record any mail being opened? | 241 -- Did we record any mail being opened? |
| 237 if mailOpened and mailOpened > 0 then | 242 if mailOpened and mailOpened > 0 then |
| 240 local timeSpentMinutes = floor( timeSpent / 60 ); | 245 local timeSpentMinutes = floor( timeSpent / 60 ); |
| 241 local timeSpentSeconds = ( timeSpent % 60 ); | 246 local timeSpentSeconds = ( timeSpent % 60 ); |
| 242 if timeSpentMinutes ~= 0 then | 247 if timeSpentMinutes ~= 0 then |
| 243 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; | 248 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 244 else | 249 else |
| 245 printMessage = printMessage .. format("Collected a total of %d mail within %d seconds.", mailOpened, timeSpentSeconds) .. " "; | 250 printMessage = printMessage .. format(L["Collected a total of %d mail within %d seconds."], mailOpened, timeSpentSeconds) .. " "; |
| 246 end | 251 end |
| 247 else | 252 else |
| 248 printMessage = printMessage .. format(L["Collected a total of %d mail."], mailOpened) .. " "; | 253 printMessage = printMessage .. format(L["Collected a total of %d mail."], mailOpened) .. " "; |
| 249 end | 254 end |
| 250 elseif timeSpent and timeSpent > 0 then | 255 elseif timeSpent and timeSpent > 0 then |
| 269 -- Did we record anything? print that! | 274 -- Did we record anything? print that! |
| 270 if printMessage ~= "" then | 275 if printMessage ~= "" then |
| 271 MailOpener:Print(printMessage); | 276 MailOpener:Print(printMessage); |
| 272 end | 277 end |
| 273 | 278 |
| 274 if self.db.profile.sessionSummary and ((sessionMailOpened and (not mailOpened or sessionMailOpened > mailOpened)) or (sessionTimeSpent and (not timeSpent or sessionTimeSpent > timeSpent)) or (sessionEarned and (not earned or sessionEarned > earned)) or (sessionItemsgained and (not itemsGained or sessionItemsgained > itemsGained))) then | 279 if self.db.profile.sessionSummary and ((sessionMailOpened and (not mailOpened or sessionMailOpened > mailOpened)) or (tempSessionTimeSpent and (not timeSpent or tempSessionTimeSpent > timeSpent)) or (sessionEarned and (not earned or sessionEarned > earned)) or (sessionItemsgained and (not itemsGained or sessionItemsgained > itemsGained))) then |
| 275 -- Message buffer, append details we have data for | 280 -- Message buffer, append details we have data for |
| 276 printMessage = "(Session summary)" .. " "; | 281 printMessage = L["(Session summary)"] .. " "; |
| 277 | 282 |
| 278 -- Did we record any mail being opened? | 283 -- Did we record any mail being opened? |
| 279 if sessionMailOpened and sessionMailOpened > 0 then | 284 if sessionMailOpened and sessionMailOpened > 0 then |
| 280 -- Time Spent | 285 -- Time Spent |
| 281 if sessionTimeSpent and sessionTimeSpent > 0 then | 286 if tempSessionTimeSpent and tempSessionTimeSpent > 0 then |
| 282 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); | 287 local timeSpentMinutes = floor( tempSessionTimeSpent / 60 ); |
| 283 local timeSpentSeconds = ( sessionTimeSpent % 60 ); | 288 local timeSpentSeconds = ( tempSessionTimeSpent % 60 ); |
| 284 if timeSpentMinutes ~= 0 then | 289 if timeSpentMinutes ~= 0 then |
| 285 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; | 290 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 286 else | 291 else |
| 287 printMessage = printMessage .. format(L["Collected a total of %d mail within %d seconds this session."], mailOpened, timeSpentSeconds) .. " "; | 292 printMessage = printMessage .. format(L["Collected a total of %d mail within %d seconds this session."], mailOpened, timeSpentSeconds) .. " "; |
| 288 end | 293 end |
| 289 else | 294 else |
| 290 printMessage = printMessage .. format(L["Collected a total of %d mail this session."], sessionMailOpened) .. " "; | 295 printMessage = printMessage .. format(L["Collected a total of %d mail this session."], sessionMailOpened) .. " "; |
| 291 end | 296 end |
| 292 elseif sessionTimeSpent then | 297 elseif tempSessionTimeSpent then |
| 293 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); | 298 local timeSpentMinutes = floor( tempSessionTimeSpent / 60 ); |
| 294 local timeSpentSeconds = ( sessionTimeSpent % 60 ); | 299 local timeSpentSeconds = ( tempSessionTimeSpent % 60 ); |
| 295 if timeSpentMinutes ~= 0 then | 300 if timeSpentMinutes ~= 0 then |
| 296 printMessage = printMessage .. format(L["Spent %d minutes and %d seconds collecting mail this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; | 301 printMessage = printMessage .. format(L["Spent %d minutes and %d seconds collecting mail this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 297 else | 302 else |
| 298 printMessage = printMessage .. format(L["Spent %d seconds collecting mail this session."], mailOpened, timeSpentSeconds) .. " "; | 303 printMessage = printMessage .. format(L["Spent %d seconds collecting mail this session."], mailOpened, timeSpentSeconds) .. " "; |
| 299 end | 304 end |
