Mercurial > wow > mailopener
comparison Modules/Collected.lua @ 68:eadff31e61e8
Localization of all files. Testing packager settings (especially automatic locale exports), localization is not yet finished.
| author | Zerotorescue |
|---|---|
| date | Wed, 15 Sep 2010 13:10:56 +0200 |
| parents | 8d1a34cec258 |
| children | f01e0184a275 |
comparison
equal
deleted
inserted
replaced
| 67:4166a335ca81 | 68:eadff31e61e8 |
|---|---|
| 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); | 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); |
| 2 local mod = MailOpener:NewModule("Collected", "AceEvent-3.0", "AceTimer-3.0"); | 2 local mod = MailOpener:NewModule("Collected", "AceEvent-3.0", "AceTimer-3.0"); |
| 3 | 3 |
| 4 mod.moduleDescription = "Shows a simple summary of what has been collected at the mailbox."; | 4 mod.moduleDescription = L["Shows a simple summary of what has been collected at the mailbox."]; |
| 5 mod.moduleRequired = false; | 5 mod.moduleRequired = false; |
| 6 | 6 |
| 7 -- Gold | 7 -- Gold |
| 8 local previousGold, earned, sessionEarned; | 8 local previousGold, earned, sessionEarned; |
| 9 -- Items | 9 -- Items |
| 237 -- Time Spent | 237 -- Time Spent |
| 238 if timeSpent and timeSpent > 0 then | 238 if timeSpent and timeSpent > 0 then |
| 239 local timeSpentMinutes = floor( timeSpent / 60 ); | 239 local timeSpentMinutes = floor( timeSpent / 60 ); |
| 240 local timeSpentSeconds = ( timeSpent % 60 ); | 240 local timeSpentSeconds = ( timeSpent % 60 ); |
| 241 if timeSpentMinutes ~= 0 then | 241 if timeSpentMinutes ~= 0 then |
| 242 printMessage = printMessage .. format("Collected a total of %d mail within %d minutes and %d seconds. ", mailOpened, timeSpentMinutes, timeSpentSeconds); | 242 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 243 else | 243 else |
| 244 printMessage = printMessage .. format("Collected a total of %d mail within %d seconds. ", mailOpened, timeSpentSeconds); | 244 printMessage = printMessage .. format("Collected a total of %d mail within %d seconds.", mailOpened, timeSpentSeconds) .. " "; |
| 245 end | 245 end |
| 246 else | 246 else |
| 247 printMessage = printMessage .. format("Collected a total of %d mail. ", mailOpened); | 247 printMessage = printMessage .. format(L["Collected a total of %d mail."], mailOpened) .. " "; |
| 248 end | 248 end |
| 249 elseif timeSpent and timeSpent > 0 then | 249 elseif timeSpent and timeSpent > 0 then |
| 250 local timeSpentMinutes = floor( timeSpent / 60 ); | 250 local timeSpentMinutes = floor( timeSpent / 60 ); |
| 251 local timeSpentSeconds = ( timeSpent % 60 ); | 251 local timeSpentSeconds = ( timeSpent % 60 ); |
| 252 if timeSpentMinutes ~= 0 then | 252 if timeSpentMinutes ~= 0 then |
| 253 printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail. ", mailOpened, timeSpentMinutes, timeSpentSeconds); | 253 printMessage = printMessage .. format(L["Spent %d minutes and %d seconds collecting mail."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 254 else | 254 else |
| 255 printMessage = printMessage .. format("Spent %d seconds collecting mail. ", mailOpened, timeSpentSeconds); | 255 printMessage = printMessage .. format(L["Spent %d seconds collecting mail."], mailOpened, timeSpentSeconds) .. " "; |
| 256 end | 256 end |
| 257 end | 257 end |
| 258 | 258 |
| 259 -- Did we record any items or gold being looted? | 259 -- Did we record any items or gold being looted? |
| 260 if (itemsGained and itemsGained > 0) and (earned and earned > 0) then | 260 if (itemsGained and itemsGained > 0) and (earned and earned > 0) then |
| 261 printMessage = printMessage .. format("You gained %d items and %s from this.", itemsGained, MailOpener:FormatMoney(earned)); | 261 printMessage = printMessage .. format(L["You gained %d items and %s from this."], itemsGained, MailOpener:FormatMoney(earned)); |
| 262 elseif itemsGained and itemsGained > 0 then | 262 elseif itemsGained and itemsGained > 0 then |
| 263 printMessage = printMessage .. format("You gained %d items from this.", itemsGained); | 263 printMessage = printMessage .. format(L["You gained %d items from this."], itemsGained); |
| 264 elseif earned and earned > 0 then | 264 elseif earned and earned > 0 then |
| 265 printMessage = printMessage .. format("You gained %s from this.", MailOpener:FormatMoney(earned)); | 265 printMessage = printMessage .. format(L["You gained %s from this."], MailOpener:FormatMoney(earned)); |
| 266 end | 266 end |
| 267 | 267 |
| 268 -- Did we record anything? print that! | 268 -- Did we record anything? print that! |
| 269 if printMessage ~= "" then | 269 if printMessage ~= "" then |
| 270 print("|cff15ff00Mail Opener|r: " .. printMessage); | 270 MailOpener:Print(printMessage); |
| 271 end | 271 end |
| 272 | 272 |
| 273 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 | 273 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 |
| 274 -- Message buffer, append details we have data for | 274 -- Message buffer, append details we have data for |
| 275 printMessage = "|cff15ff00Mail Opener|r: (Session summary) "; | 275 printMessage = "(Session summary)" .. " "; |
| 276 | 276 |
| 277 -- Did we record any mail being opened? | 277 -- Did we record any mail being opened? |
| 278 if sessionMailOpened and sessionMailOpened > 0 then | 278 if sessionMailOpened and sessionMailOpened > 0 then |
| 279 -- Time Spent | 279 -- Time Spent |
| 280 if sessionTimeSpent and sessionTimeSpent > 0 then | 280 if sessionTimeSpent and sessionTimeSpent > 0 then |
| 281 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); | 281 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); |
| 282 local timeSpentSeconds = ( sessionTimeSpent % 60 ); | 282 local timeSpentSeconds = ( sessionTimeSpent % 60 ); |
| 283 if timeSpentMinutes ~= 0 then | 283 if timeSpentMinutes ~= 0 then |
| 284 printMessage = printMessage .. format("Collected a total of %d mail within %d minutes and %d seconds this session. ", mailOpened, timeSpentMinutes, timeSpentSeconds); | 284 printMessage = printMessage .. format(L["Collected a total of %d mail within %d minutes and %d seconds this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 285 else | 285 else |
| 286 printMessage = printMessage .. format("Collected a total of %d mail within %d seconds this session. ", mailOpened, timeSpentSeconds); | 286 printMessage = printMessage .. format(L["Collected a total of %d mail within %d seconds this session."], mailOpened, timeSpentSeconds) .. " "; |
| 287 end | 287 end |
| 288 else | 288 else |
| 289 printMessage = printMessage .. format("Collected a total of %d mail this session. ", sessionMailOpened); | 289 printMessage = printMessage .. format(L["Collected a total of %d mail this session."], sessionMailOpened) .. " "; |
| 290 end | 290 end |
| 291 elseif sessionTimeSpent then | 291 elseif sessionTimeSpent then |
| 292 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); | 292 local timeSpentMinutes = floor( sessionTimeSpent / 60 ); |
| 293 local timeSpentSeconds = ( sessionTimeSpent % 60 ); | 293 local timeSpentSeconds = ( sessionTimeSpent % 60 ); |
| 294 if timeSpentMinutes ~= 0 then | 294 if timeSpentMinutes ~= 0 then |
| 295 printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail this session. ", mailOpened, timeSpentMinutes, timeSpentSeconds); | 295 printMessage = printMessage .. format(L["Spent %d minutes and %d seconds collecting mail this session."], mailOpened, timeSpentMinutes, timeSpentSeconds) .. " "; |
| 296 else | 296 else |
| 297 printMessage = printMessage .. format("Spent %d seconds collecting mail this session. ", mailOpened, timeSpentSeconds); | 297 printMessage = printMessage .. format(L["Spent %d seconds collecting mail this session."], mailOpened, timeSpentSeconds) .. " "; |
| 298 end | 298 end |
| 299 end | 299 end |
| 300 | 300 |
| 301 -- Did we record any items or gold being looted? | 301 -- Did we record any items or gold being looted? |
| 302 if (sessionItemsgained and sessionItemsgained > 0) and (sessionEarned and sessionEarned > 0) then | 302 if (sessionItemsgained and sessionItemsgained > 0) and (sessionEarned and sessionEarned > 0) then |
| 303 printMessage = printMessage .. format("You gained %d items and %s from this.", sessionItemsgained, MailOpener:FormatMoney(sessionEarned)); | 303 printMessage = printMessage .. format(L["You gained %d items and %s from this."], sessionItemsgained, MailOpener:FormatMoney(sessionEarned)); |
| 304 elseif sessionItemsgained and sessionItemsgained > 0 then | 304 elseif sessionItemsgained and sessionItemsgained > 0 then |
| 305 printMessage = printMessage .. format("You gained %d items from this.", sessionItemsgained); | 305 printMessage = printMessage .. format(L["You gained %d items from this."], sessionItemsgained); |
| 306 elseif sessionEarned and sessionEarned > 0 then | 306 elseif sessionEarned and sessionEarned > 0 then |
| 307 printMessage = printMessage .. format("You gained %s from this.", MailOpener:FormatMoney(sessionEarned)); | 307 printMessage = printMessage .. format(L["You gained %s from this."], MailOpener:FormatMoney(sessionEarned)); |
| 308 end | 308 end |
| 309 | 309 |
| 310 -- Did we record anything? print that! | 310 -- Did we record anything? print that! |
| 311 if printMessage ~= "" then | 311 if printMessage ~= "" then |
| 312 print(printMessage); | 312 MailOpener:Print(printMessage); |
| 313 end | 313 end |
| 314 end | 314 end |
| 315 end | 315 end |
| 316 | 316 |
| 317 function mod:GetNumFreeSlots() | 317 function mod:GetNumFreeSlots() |
| 325 | 325 |
| 326 function mod:GetOptionsGroup() | 326 function mod:GetOptionsGroup() |
| 327 local configGroup = { | 327 local configGroup = { |
| 328 order = 0, | 328 order = 0, |
| 329 type = "modulesSubGroup", | 329 type = "modulesSubGroup", |
| 330 name = "Collected", | 330 name = L["Collected"], |
| 331 desc = "Change settings for the collected module.", | 331 desc = L["Change settings for the collected module."], |
| 332 args = { | 332 args = { |
| 333 General = { | 333 General = { |
| 334 order = 10, | 334 order = 10, |
| 335 type = "group", | 335 type = "group", |
| 336 inline = true, | 336 inline = true, |
| 337 name = "General", | 337 name = L["General"], |
| 338 args = { | 338 args = { |
| 339 description = { | 339 description = { |
| 340 order = 10, | 340 order = 10, |
| 341 type = "description", | 341 type = "description", |
| 342 name = function() | 342 name = function() |
| 343 local descText = "With this button you can completely toggle this module |cff00ff00on|r or |cffff0000off|r. This setting will be remembered and the module will be automatically toggled |cff00ff00on|r or |cffff0000off|r upon logon as it was last set.\n\n"; | 343 local descText = L["With this button you can completely toggle this module |cff00ff00on|r or |cffff0000off|r. This setting will be remembered and the module will be automatically toggled |cff00ff00on|r or |cffff0000off|r upon logon as it was last set."] .. "\n\n"; |
| 344 | 344 |
| 345 if self:IsEnabled() then | 345 if self:IsEnabled() then |
| 346 descText = descText .. "Status: |cff00ff00Enabled|r"; | 346 descText = descText .. L["Status: %s"]:format(L["|cff00ff00Enabled|r"]); |
| 347 else | 347 else |
| 348 descText = descText .. "Status: |cffff0000Disabled|r"; | 348 descText = descText .. L["Status: %s"]:format(L["|cffff0000Disabled|r"]); |
| 349 end | 349 end |
| 350 | 350 |
| 351 return descText; | 351 return descText; |
| 352 end, | 352 end, |
| 353 }, | 353 }, |
| 354 disable = { | 354 disable = { |
| 355 order = 20, | 355 order = 20, |
| 356 type = "execute", | 356 type = "execute", |
| 357 name = function() | 357 name = function() |
| 358 if self:IsEnabled() then | 358 if self:IsEnabled() then |
| 359 return "Disable Module"; | 359 return L["Disable Module"]; |
| 360 else | 360 else |
| 361 return "Enable Module"; | 361 return L["Enable Module"]; |
| 362 end | 362 end |
| 363 end, | 363 end, |
| 364 desc = "Click here to completely toggle this module on or off.", | 364 desc = L["Click here to completely toggle this module on or off."], |
| 365 width = "double", | 365 width = "double", |
| 366 func = function() | 366 func = function() |
| 367 if self:IsEnabled() then | 367 if self:IsEnabled() then |
| 368 self:Disable(); | 368 self:Disable(); |
| 369 | 369 |
| 379 }, | 379 }, |
| 380 TrackStats = { | 380 TrackStats = { |
| 381 order = 20, | 381 order = 20, |
| 382 type = "group", | 382 type = "group", |
| 383 inline = true, | 383 inline = true, |
| 384 name = "Track Stats", | 384 name = L["Track Stats"], |
| 385 args = { | 385 args = { |
| 386 description = { | 386 description = { |
| 387 order = 10, | 387 order = 10, |
| 388 type = "description", | 388 type = "description", |
| 389 name = "You can select what things to track. Toggling something off will stop tracking of it completely and reduce the resources used by Mail Opener (although you shouldn't notice a difference).", | 389 name = L["You can select what things to track. Toggling something off will stop tracking of it completely and reduce the resources used by Mail Opener (although you shouldn't notice a difference)."], |
| 390 }, | 390 }, |
| 391 AHHeader = { | 391 AHHeader = { |
| 392 order = 15, | 392 order = 15, |
| 393 type = "header", | 393 type = "header", |
| 394 name = "", | 394 name = "", |
| 395 }, | 395 }, |
| 396 trackGold = { | 396 trackGold = { |
| 397 order = 20, | 397 order = 20, |
| 398 type = "toggle", | 398 type = "toggle", |
| 399 name = "Track |cfffed000gold gained|r", | 399 name = L["Track |cfffed000gold gained|r"], |
| 400 desc = "Track the amount of gold gained and display it when closing the mailbox.", | 400 desc = L["Track the amount of gold gained and display it when closing the mailbox."], |
| 401 set = function(i, v) | 401 set = function(i, v) |
| 402 self.db.profile.trackGold = v; | 402 self.db.profile.trackGold = v; |
| 403 | 403 |
| 404 if MailFrame:IsVisible() then | 404 if MailFrame:IsVisible() then |
| 405 self:MAIL_SHOW(); | 405 self:MAIL_SHOW(); |
| 408 get = function() return self.db.profile.trackGold; end, | 408 get = function() return self.db.profile.trackGold; end, |
| 409 }, | 409 }, |
| 410 trackItems = { | 410 trackItems = { |
| 411 order = 30, | 411 order = 30, |
| 412 type = "toggle", | 412 type = "toggle", |
| 413 name = "Track |cfffed000items gained|r", | 413 name = L["Track |cfffed000items gained|r"], |
| 414 desc = "Track the amount of items gained and display it when closing the mailbox.", | 414 desc = L["Track the amount of items gained and display it when closing the mailbox."], |
| 415 set = function(i, v) | 415 set = function(i, v) |
| 416 self.db.profile.trackItems = v; | 416 self.db.profile.trackItems = v; |
| 417 | 417 |
| 418 if MailFrame:IsVisible() then | 418 if MailFrame:IsVisible() then |
| 419 self:MAIL_SHOW(); | 419 self:MAIL_SHOW(); |
| 422 get = function() return self.db.profile.trackItems; end, | 422 get = function() return self.db.profile.trackItems; end, |
| 423 }, | 423 }, |
| 424 trackMail = { | 424 trackMail = { |
| 425 order = 40, | 425 order = 40, |
| 426 type = "toggle", | 426 type = "toggle", |
| 427 name = "Track |cfffed000mail opened|r", | 427 name = L["Track |cfffed000mail opened|r"], |
| 428 desc = "Track the amount of mail received and display it when closing the mailbox.", | 428 desc = L["Track the amount of mail received and display it when closing the mailbox."], |
| 429 set = function(i, v) | 429 set = function(i, v) |
| 430 self.db.profile.trackMail = v; | 430 self.db.profile.trackMail = v; |
| 431 | 431 |
| 432 if MailFrame:IsVisible() then | 432 if MailFrame:IsVisible() then |
| 433 self:MAIL_SHOW(); | 433 self:MAIL_SHOW(); |
| 436 get = function() return self.db.profile.trackMail; end, | 436 get = function() return self.db.profile.trackMail; end, |
| 437 }, | 437 }, |
| 438 trackTimeSpent = { | 438 trackTimeSpent = { |
| 439 order = 50, | 439 order = 50, |
| 440 type = "toggle", | 440 type = "toggle", |
| 441 name = "Track |cfffed000time spent|r", | 441 name = L["Track |cfffed000time spent|r"], |
| 442 desc = "Track the amount of time spent at the mailbox.", | 442 desc = L["Track the amount of time spent at the mailbox."], |
| 443 set = function(i, v) | 443 set = function(i, v) |
| 444 self.db.profile.trackTimeSpent = v; | 444 self.db.profile.trackTimeSpent = v; |
| 445 | 445 |
| 446 if MailFrame:IsVisible() then | 446 if MailFrame:IsVisible() then |
| 447 self:MAIL_SHOW(); | 447 self:MAIL_SHOW(); |
| 453 }, | 453 }, |
| 454 Summarize = { | 454 Summarize = { |
| 455 order = 30, | 455 order = 30, |
| 456 type = "group", | 456 type = "group", |
| 457 inline = true, | 457 inline = true, |
| 458 name = "Summarize", | 458 name = L["Summarize"], |
| 459 args = { | 459 args = { |
| 460 sessionSummary = { | 460 sessionSummary = { |
| 461 order = 20, | 461 order = 20, |
| 462 type = "toggle", | 462 type = "toggle", |
| 463 name = "Also show a summary of the recorded stats within the entire session", | 463 name = L["Also show a summary of the recorded stats within the entire session"], |
| 464 desc = "Also show a summary of the recorded stats within the entire session (since your last login or /reload).", | 464 desc = L["Also show a summary of the recorded stats within the entire session (since your last login or /reload)."], |
| 465 set = function(i, v) | 465 set = function(i, v) |
| 466 self.db.profile.sessionSummary = v; | 466 self.db.profile.sessionSummary = v; |
| 467 | 467 |
| 468 if MailFrame:IsVisible() then | 468 if MailFrame:IsVisible() then |
| 469 self:MAIL_SHOW(); | 469 self:MAIL_SHOW(); |
| 473 width = "full", | 473 width = "full", |
| 474 }, | 474 }, |
| 475 batchSummary = { | 475 batchSummary = { |
| 476 order = 30, | 476 order = 30, |
| 477 type = "toggle", | 477 type = "toggle", |
| 478 name = "Show a summary of the recorded stats whenever it updated after opening the current batch has finished", | 478 name = L["Show a summary of the recorded stats whenever it updated after opening the current batch has finished"], |
| 479 desc = "Show a summary of the recorded stats whenever it has been updated after opening the current batch of mails has finished.", | 479 desc = L["Show a summary of the recorded stats whenever it has been updated after opening the current batch of mails has finished."], |
| 480 set = function(i, v) | 480 set = function(i, v) |
| 481 self.db.profile.batchSummary = v; | 481 self.db.profile.batchSummary = v; |
| 482 | 482 |
| 483 if MailFrame:IsVisible() then | 483 if MailFrame:IsVisible() then |
| 484 self:MAIL_SHOW(); | 484 self:MAIL_SHOW(); |
