Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. -- ------------------------------------------------------------------------------ --
  2. -- TradeSkillMaster_Mailing --
  3. -- http://www.curse.com/addons/wow/tradeskillmaster_mailing --
  4. -- --
  5. -- A TradeSkillMaster Addon (http://tradeskillmaster.com) --
  6. -- All Rights Reserved* - Detailed license information included with addon. --
  7. -- ------------------------------------------------------------------------------ --
  8.  
  9. -- register this file with Ace Libraries
  10. local TSM = select(2, ...)
  11. TSM = LibStub("AceAddon-3.0"):NewAddon(TSM, "TSM_Mailing", "AceEvent-3.0", "AceConsole-3.0")
  12. local AceGUI = LibStub("AceGUI-3.0") -- load the AceGUI libraries
  13. local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Mailing") -- loads the localization table
  14.  
  15. TSM.SPELLING_WARNING = "|cffff0000"..L["BE SURE TO SPELL THE NAME CORRECTLY!"].."|r"
  16. local private = {lootIndex=1, recheckTime=1, allowTimerStart=true}
  17.  
  18. local settingsInfo = {
  19. version = 1,
  20. global = {
  21. defaultMailTab = { type = "boolean", default = true, lastModifiedVersion = 1 },
  22. autoCheck = { type = "boolean", default = true, lastModifiedVersion = 1 },
  23. displayMoneyCollected = { type = "boolean", default = true, lastModifiedVersion = 1 },
  24. sendItemsIndividually = { type = "boolean", default = false, lastModifiedVersion = 1 },
  25. deleteEmptyNPCMail = { type = "boolean", default = false, lastModifiedVersion = 1 },
  26. inboxMessages = { type = "boolean", default = true, lastModifiedVersion = 1 },
  27. sendMessages = { type = "boolean", default = true, lastModifiedVersion = 1 },
  28. showReloadBtn = { type = "boolean", default = true, lastModifiedVersion = 1 },
  29. resendDelay = { type = "number", default = 1, lastModifiedVersion = 1 },
  30. sendDelay = { type = "number", default = 0.5, lastModifiedVersion = 1 },
  31. defaultPage = { type = "number", default = 1, lastModifiedVersion = 1 },
  32. keepMailSpace = { type = "number", default = 0, lastModifiedVersion = 1 },
  33. deMaxQuality = { type = "number", default = 2, lastModifiedVersion = 1 },
  34. openMailSound = { type = "string", default = TSMAPI:GetNoSoundKey(), lastModifiedVersion = 1 },
  35. helpPlatesShown = { type = "table", default = { inbox = nil, groups = nil, quickSend = nil, other = nil }, lastModifiedVersion = 1 },
  36. },
  37. factionrealm = {
  38. deMailTarget = { type = "string", default = "", lastModifiedVersion = 1 },
  39. },
  40. char = {
  41. goldMailTarget = { type = "string", default = "", lastModifiedVersion = 1 },
  42. goldKeepAmount = { type = "number", default = 1000000, lastModifiedVersion = 1 },
  43. },
  44. }
  45. local operationDefaults = {
  46. maxQtyEnabled = nil,
  47. maxQty = 10,
  48. target = "",
  49. restock = nil, -- take into account how many the target already has
  50. restockSources = {guild=nil, bank=nil},
  51. keepQty = 0,
  52. }
  53.  
  54. function TSM:OnEnable()
  55. if TradeSkillMasterModulesDB then
  56. TradeSkillMasterModulesDB.Mailing = TradeSkillMaster_MailingDB
  57. end
  58.  
  59. -- load settings
  60. TSM.db = TSMAPI.Settings:Init("TradeSkillMaster_MailingDB", settingsInfo)
  61.  
  62. for moduleName, module in pairs(TSM.modules) do
  63. TSM[moduleName] = module
  64. end
  65.  
  66. -- register this module with TSM
  67. TSM:RegisterModule()
  68.  
  69. -- TSM3 conversions
  70. for _ in TSMAPI:GetTSMProfileIterator() do
  71. for _, operation in pairs(TSM.operations) do
  72. if not operation.restockSources then
  73. operation.restockSources = {guild=operation.restockGBank}
  74. operation.restockGBank = nil
  75. end
  76. end
  77. end
  78.  
  79. -- fix patch 7.3 sound changes
  80. local sounds = TSMAPI:GetSounds()
  81. if not sounds[TSM.db.global.openMailSound] then
  82. TSM.db.global.openMailSound = TSM.NO_SOUND_KEY
  83. end
  84. end
  85.  
  86. -- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule().
  87. function TSM:RegisterModule()
  88. TSM.operations = { maxOperations = 30, callbackOptions = "Options:GetOperationOptionsInfo", callbackInfo = "GetOperationInfo", defaults = operationDefaults }
  89. TSM.moduleOptions = {callback="Options:ShowOptions"}
  90. TSM.moduleAPIs = {
  91. {key="mailItems", callback="AutoMail:SendItems"},
  92. }
  93. TSM.bankUiButton = { callback = "BankUI:createTab" }
  94.  
  95. TSMAPI:NewModule(TSM)
  96. end
  97.  
  98. function TSM:GetOperationInfo(operationName)
  99. local operation = TSM.operations[operationName]
  100. if not operation then return end
  101. if operation.target == "" then return end
  102.  
  103. if operation.maxQtyEnabled then
  104. return format(L["Mailing up to %d to %s."], operation.maxQty, operation.target)
  105. else
  106. return format(L["Mailing all to %s."], operation.target)
  107. end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement