LS: Toasts

LS: Toasts

807k Downloads

Include transmog notifications

Eiltherune opened this issue ยท 5 comments

commented

Transmogs don't currently toggle a toast when you learn an appearance, but I was able to use your code to create a toast for them. The majority of the additions are just copying and adapting the existing Achievement coding.

ls_toasts.lua:43

transmog = false, -- transmog appearances

ls_toasts.lua:52

  transmog_enabled = true,

ls_toasts.lua:951-1008

--------------
-- TRANSMOG --
--------------

local function TransmogToast_SetUp(vID)
local toast = GetToast("misc")
--This if/end is used only for the test scenario.
--A vID will not be passed to the main function during regular use.
local visualID
if vID then visualID = vID else
  visualID = C_TransmogCollection.GetLatestAppearance()
end
if visualID then
  local sources
  sources = C_TransmogCollection.GetAppearanceSources(visualID)
  for i=1,#sources do
-- Many appearances have multiple sources, so we need to match those with possible items
    sID = sources[i].sourceID
    _,_,_,_,_,sLink,aLink = C_TransmogCollection.GetAppearanceSourceInfo(sID)
-- We assume the item is in the player's inventory, since it was just added to the collection
    if GetItemCount(sLink) == 1 then
      break
    end
  end
  _,_,_,_,_,_,_,_,_,icon = GetItemInfo(sLink)

  toast.Title:SetText("Appearance Added!")
  toast.Text:SetText(sLink)

  toast.Border:SetVertexColor(1, 1, 1)
  toast.IconBorder:SetVertexColor(1, 1, 1)
  toast.Icon:SetTexture(icon)
  toast.link = aLink
else
--Currently, there is no way to know what appearance was removed
--unless we cache the player's inventory. The only way for appearances
--to be removed is by trading raid loot or returning alternate-currency
--items to a vendor, both within the 2 hour time limit.
  toast.Title:SetText("Appearance Removed!")
  toast.Text:SetText("Check recent sales/trades")

  toast.Border:SetVertexColor(1, 1, 1)
  toast.IconBorder:SetVertexColor(1, 1, 1)
  toast.Icon:SetTexture(134400)
end

SpawnToast(toast, CFG.dnd.transmog)
end

function dispatcher:TRANSMOG_COLLECTION_UPDATED(...)
--vID is only used here for the testing function later.  
  vID = ...
  TransmogToast_SetUp(vID)

end

local function EnableTransmogToasts()

  if CFG.transmog_enabled then
    dispatcher:RegisterEvent("TRANSMOG_COLLECTION_UPDATED")
  end
end

local function DisableTransmogToasts()
  dispatcher:UnregisterEvent("TRANSMOG_COLLECTION_UPDATED")
end

ls_toasts.lua:1865-1869

local function SpawnTestTransmogToast()
--This event doesn't actually send an appearanceID, but we are faking it for this test.
--Note that the first time the player runs this test, the toast will be empty
--because the item has not been cached yet.
--This wouldn't happen in normal operations because the item
--is already in our bags when we create the toast.
  dispatcher:TRANSMOG_COLLECTION_UPDATED(24799)
end

ls_toasts.lua:2131-2136

  elseif value == "transmog_enabled" then
    if state then
      EnableTransmogToasts()
    else
      DisableTransmogToasts()
    end

ls_toasts.lua:2536
Change height of panel to accomodate the addition of the Appearances line

  toastSettings:SetSize(441, 191)

ls_toasts.lua:2562-2565
Add Appearances to the config window, change for statement to include an 8th option

  [8] = {name = "Appearances", point = {"TOPLEFT", toastSettings, "TOPLEFT", 2, -173}, enabled = "transmog_enabled", dnd = "dnd.transmog", testFunc = SpawnTestTransmogToast},
}

for i = 1, 8 do
[...]

ls_toasts.lua:2628

  EnableTransmogToasts()

I would like to have the toast show the Collections window when clicked, but I couldn't figure out how to make that happen. I'd also like to have the toast use a different image for the background, possibly incorporating the EtherealLines.blp that is in the 'BlizzardInterfaceArt\Interface\Transmogrify' folder.

commented

Hi!

I may implement it a bit differently, nevertheless, that's a cool idea ๐Ÿ‘

I'll look into it a bit later, cuz I have more than one addon, and I work on them in turn.

commented

Here's a preview for anyone who reads it. BG texture is still WIP.

image

commented

Thank you so much! I'm glad I was able to help get this feature implemented! Is there a download for it yet?

commented

Well, you can download it from GH. I haven't added BG texture yet, need to finish it first.

commented

Sup!

I started working on transmog toast today (see 62d10cf), code-wise it's pretty much done. Instead of using TRANSMOG_COLLECTION_UPDATED, I'm monitoring CHAT_MSG_SYSTEM event to get info on what was added/removed.

Now I need to draw background texture and debug it.

Once again, thanks for the idea ๐Ÿ˜