Skip to content

Commit

Permalink
add hunter beast training notification to broker
Browse files Browse the repository at this point in the history
  • Loading branch information
fusionpit committed Nov 30, 2024
1 parent a41ad40 commit 5bff807
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
27 changes: 25 additions & 2 deletions Broker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ local plugin = ldb:NewDataObject(addonName, {
type = "data source",
text = addonTitle,
icon = "Interface\\Icons\\INV_Misc_QuestionMark",
OnClick = function(_,button) wt.Open() end
OnClick = function(_,button)
local openBeastTraining = wt.needsBeastTraining() and IsShiftKeyDown()
if InCombatLockdown() then
print(openBeastTraining and wt.L.OPEN_BEAST_IN_COMBAT or wt.L.BROKER_OPEN_IN_COMBAT)
return
end
if openBeastTraining then
wt.openBeastTraining()
else
wt.Open()
end
end
})
local function formatGreen(text)
return '|cff19ff19'..text..'|r'
Expand All @@ -19,7 +30,8 @@ local function formatBlue(text)
end

local ttShown = false
local OPEN_HINT = formatGreen(wt.L.BROKEN_CLICK_OPEN)
local OPEN_HINT = formatGreen(wt.L.BROKER_CLICK_OPEN)
local OPEN_BEAST_TRAINING_HINT = formatGreen(wt.L.BROKER_CLICK_BEAST_TRAIN)
function plugin.OnTooltipShow(tt)
if ttShown == false then
wt:RebuildData()
Expand All @@ -29,9 +41,17 @@ function plugin.OnTooltipShow(tt)
tt:AddLine(wt.L.TAB_TEXT)
tt:AddLine(" ")

if wt.needsBeastTraining() then
tt:AddLine(wt.L.OPEN_BEAST_TRAINING)
tt:AddLine(" ")
end

if #wt.brokerData == 0 then
tt:AddLine(wt.L.BROKER_NOTHING)
tt:AddLine(" ")
if wt.needsBeastTraining() then
tt:AddLine(OPEN_BEAST_TRAINING_HINT)
end
tt:AddLine(OPEN_HINT)
return
end
Expand All @@ -57,6 +77,9 @@ function plugin.OnTooltipShow(tt)
if i ~= #wt.brokerData then tt:AddLine(" ") end
end
tt:AddLine(" ")
if wt.needsBeastTraining() then
tt:AddLine(OPEN_BEAST_TRAINING_HINT)
end
tt:AddLine(OPEN_HINT)
end

Expand Down
3 changes: 2 additions & 1 deletion Localization.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ local localeText = {
BROKER_HEADER_HIDDEN_FORMAT = "%s shown (%s total)",
BROKER_HIDDEN_FORMAT = "And another %d that cost %s",
BROKER_NOTHING = "Nothing left to learn!",
BROKEN_CLICK_OPEN = "Hint: Click to open spellbook.",
BROKER_CLICK_BEAST_TRAIN = "Hint: Shift-Click to open the Beast Training UI",
BROKER_CLICK_OPEN = "Hint: Click to open spellbook.",
LEVEL_FORMAT = "Level %s",
TAB_TEXT = "What can I train?",
OPEN_BEAST_TRAINING = "Please open the Beast Training UI",
Expand Down
11 changes: 11 additions & 0 deletions Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ function wt.formatSpellCost(spellInfo, fontHeight)

return HIGHLIGHT_FONT_COLOR_CODE .. format(formatString, coloredCoinString) .. FONT_COLOR_CODE_CLOSE
end

local BEAST_TRAINING_SPELL = 5149
function wt.needsBeastTraining()
return WT_NeedsToOpenBeastTraining == true and wt.hasBeastTraining()
end
function wt.hasBeastTraining()
return IsPlayerSpell(BEAST_TRAINING_SPELL)
end
function wt.openBeastTraining()
CastSpellByID(BEAST_TRAINING_SPELL)
end
10 changes: 8 additions & 2 deletions WhatsTraining.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,20 @@ local function rebuildData(playerLevel, isLevelUpEvent)
tinsert(wt.data, category)
categorySort(category)
local totalCost = 0
if (category.key == PET_KEY and WT_NeedsToOpenBeastTraining == true) then
if (category.key == PET_KEY and wt.needsBeastTraining()) then
tinsert(wt.data, {
formattedName = ORANGE_FONT_COLOR_CODE ..
wt.L.OPEN_BEAST_TRAINING .. FONT_COLOR_CODE_CLOSE,
isHeader = true,
cost = 0,
tooltip = wt.L.CLICK_TO_OPEN,
click = function() CastSpellByID(5149) end
click = function()
if InCombatLockdown() then
print(wt.L.OPEN_BEAST_IN_COMBAT)
else
wt.openBeastTraining()
end
end
})
end
if (WT_ShowLearnedNotice == true and category.key == PET_KEY and wt.currentClass == "WARLOCK") then
Expand Down

0 comments on commit 5bff807

Please sign in to comment.