Skip to content

Commit

Permalink
Merge pull request #17 from h2oboi89/develop
Browse files Browse the repository at this point in the history
v2.1
  • Loading branch information
h2oboi89 authored Oct 27, 2020
2 parents 8605ea6 + 6a4fe50 commit 49c714e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/TradeSkillReagents.toc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Interface: 90001
## Title: Trade Skill Reagents
## Author: Hotel2Oscar
## Version: 2.0
## Version: 2.1
## Notes: Shows which trade skills use the reagent in the tooltip
## X-Category: Tradeskill
## X-Embeds: Ace3
Expand All @@ -11,4 +11,4 @@

embeds.xml

Core.lua
TradeSkillReagentsCore.lua
36 changes: 33 additions & 3 deletions src/Core.lua → src/TradeSkillReagentsCore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ local defaults = {
options = {
debug = false,
tooltip = {
disable = false,
useSingleColor = true,
singleColor = {r = 0, g = 1, b = 1, a = 1},
tradeSkills = {}
Expand All @@ -28,17 +29,20 @@ local options = {
name = "Colors",
type = "group",
inline = true,
order = 0,
args = {
useSingleColor = {
name = "Use single color for trade skills in tooltips",
desc = "Uncheck to use different colors for each trade skill",
type = "toggle",
order = 0,
set = "SetOptionsSingleColorToggle",
get = "GetOptionsSingleColorToggle"
},
singleColor = {
name = "Single Color",
type = "color",
order = 1,
set = "SetOptionsSingleColor",
get = "GetOptionsSingleColor"
},
Expand All @@ -52,10 +56,17 @@ local options = {
}
}
},
disableTooltip = {
name = "Disable tooltip",
desc = "Check to disable tooltip if Trade Skill Reagents is being used by another addon",
type = "toggle",
order = 1,
set = "SetOptionsDisableTooltip",
get = "GetOptionsDisableTooltip"
},
debug = {
name = "Debug",
desc = "Enables debug print statements",
descStyle = "inline",
type = "toggle",
set = "SetOptionsDebug",
get = "GetOptionsDebug",
Expand Down Expand Up @@ -180,12 +191,23 @@ end

function TradeSkillReagents:OnEnable()
self:RegisterEvent("TRADE_SKILL_LIST_UPDATE")
self:RegisterMessage("TRADE_SKILL_REAGENTS_QUERY")

self:HookScript(GameTooltip, "OnToolTipSetItem", "AddTradeSkillTooltipInfo")
self:HookScript(ItemRefTooltip, "OnToolTipSetItem",
"AddTradeSkillTooltipInfo")
end

function TradeSkillReagents:TRADE_SKILL_REAGENTS_QUERY(messageName, itemName)
local response = {itemName = itemName}

local tradeSkills = self.db.reagents[itemName]

if tradeSkills then response.tradeSkills = deepCopy(tradeSkills) end

self:SendMessage("TRADE_SKILL_REAGENTS_QUERY_RESPONSE", response)
end

function TradeSkillReagents:TRADE_SKILL_LIST_UPDATE()
if self.ScanTimer then return end

Expand Down Expand Up @@ -287,7 +309,7 @@ function TradeSkillReagents:GetTooltipColor(tradeSkill)
end

function TradeSkillReagents:AddTradeSkillTooltipInfo(tooltip)
if IsShiftKeyDown() then return end
if IsShiftKeyDown() or self.db.options.tooltip.disable then return end

local itemName, itemLink = tooltip:GetItem()

Expand Down Expand Up @@ -318,6 +340,14 @@ end

function TradeSkillReagents:GetOptionsDebug(info) return self.db.options.debug end

function TradeSkillReagents:SetOptionsDisableTooltip(info, value)
self.db.options.tooltip.disable = value
end

function TradeSkillReagents:GetOptionsDisableTooltip(info)
return self.db.options.tooltip.disable
end

function TradeSkillReagents:SetOptionsSingleColorToggle(info, value)
self.db.options.tooltip.useSingleColor = value
end
Expand Down Expand Up @@ -349,4 +379,4 @@ function TradeSkillReagents:GetOptionsTradeSkillColor(info)
local tradeSkill = info[#info]
local color = self.db.options.tooltip.tradeSkills[tradeSkill]
return color.r, color.g, color.b, color.a
end
end
11 changes: 11 additions & 0 deletions test/CommTest/CommTest.toc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Interface: 90001
## Title: CommTest
## Author: Hotel2Oscar
## Version: 2.0
## Notes: Addon to test Trade Skills Reagents inter addon communications
## DefaultState: Enabled
## LoadOnDemand: 0

embeds.xml

CommTestCore.lua
31 changes: 31 additions & 0 deletions test/CommTest/CommTestCore.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CommTest = LibStub("AceAddon-3.0"):NewAddon("CommTest", "AceConsole-3.0",
"AceEvent-3.0")

function CommTest:OnInitialize()
self:RegisterChatCommand("commtest", "QueryItem")
end

function CommTest:OnEnable()
self:RegisterMessage("TRADE_SKILL_REAGENTS_QUERY_RESPONSE")
end

function CommTest:QueryItem(input)
self:Print("Sending " .. input)
self:SendMessage("TRADE_SKILL_REAGENTS_QUERY", input)
end

function CommTest:TRADE_SKILL_REAGENTS_QUERY_RESPONSE(messageName, response)
self:Print("Receiving " .. response.itemName)

if response.tradeSkills then
for tradeSkill, categories in pairs(response.tradeSkills) do
self:Print(" - " .. tradeSkill)

for _, category in ipairs(categories) do
self:Print(" - " .. category)
end
end
else
self:Print(" No trade skill info")
end
end
12 changes: 12 additions & 0 deletions test/CommTest/embeds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="Libs\LibStub\LibStub.lua"/>
<Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml"/>
<Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/>
<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
<Include file="Libs\AceEvent-3.0\AceEvent-3.0.xml"/>
<Include file="Libs\AceHook-3.0\AceHook-3.0.xml"/>
<Include file="Libs\AceTimer-3.0\AceTimer-3.0.xml" />
</Ui>

0 comments on commit 49c714e

Please sign in to comment.