diff --git a/SousChef.lua b/SousChef.lua
index 9f7bb31..5ebae02 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -10,6 +10,7 @@ local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")
local BACKPACK = ZO_PlayerInventoryBackpack
local BANK = ZO_PlayerBankBackpack
local GUILD_BANK = ZO_GuildBankBackpack
+local GUILD_SHOP = ZO_TradingHouse
local COOKING_RANK_1 = [[SousChef\media\One.dds]]
local COOKING_RANK_2 = [[SousChef\media\Two.dds]]
@@ -27,11 +28,16 @@ local ReverseCookbook = {}
local settings = nil
local slotLines = {}
local hookedFunctions = {}
+local hookedDataFunction
local function GetItemID(link)
return tonumber(string.match(string.match(link, "%d+:"), "%d+"))
end
+function EndsWith(String,End)
+ return End=='' or string.sub(String,-string.len(End))==End
+end
+
local function MatchInCookbook(bag, slot)
return Cookbook[GetItemName(bag, slot):lower():gsub(" ","")]
end
@@ -60,19 +66,26 @@ local function AddDetails(row)
return false
end
+local function getIcon(row)
+ local rankIcon = slotLines[row:GetName()]
+ if(not rankIcon) then
+ rankIcon = WINDOW_MANAGER:CreateControl(row:GetName() .. "SousChef", row, CT_TEXTURE)
+ slotLines[row:GetName()] = rankIcon
+ if row:GetOwningWindow():GetName() ~= "ZO_TradingHouse" then
+ ZO_PreHookHandler(row, "OnMouseDown", AddDetails)
+ ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked[self] = nil end )
+ end
+ end
+ return rankIcon
+end
+
local rowHandler = {}
local function AddRankToSlot(row)
local bagId = row.dataEntry.data.bagId
local slotIndex = row.dataEntry.data.slotIndex
- local rankIcon = slotLines[row:GetName()]
- if(not rankIcon) then
- rankIcon = WINDOW_MANAGER:CreateControl(row:GetName() .. "SousChef", row, CT_TEXTURE)
- slotLines[row:GetName()] = rankIcon
- ZO_PreHookHandler(row, "OnMouseDown", AddDetails)
- ZO_PreHookHandler(row, "OnMouseExit", function(self) rowClicked[self] = nil end )
- end
+ local rankIcon = getIcon(row)
-- Allow for ingeniousclown's Inventory Grid View
if row:GetWidth() - row:GetHeight() < 5 then -- if we're mostly square
@@ -102,7 +115,7 @@ local function AddRankToSlot(row)
if (match and settings.checkKnown == "known") or
(not match and settings.checkKnown == "unknown")then
rankIcon:SetTexture(CANLEARN)
- rankIcon:SetHidden(false)
+ rankIcon:SetHidden(false)
if not match and gmatch and settings.checkKnown == "unknown" and settings.markAlt then
rankIcon:SetColor(1,1,1,0.2)
else
@@ -114,6 +127,29 @@ local function AddRankToSlot(row)
end
end
+local function AddTradingSlot(row, result)
+ local rankIcon = getIcon(row)
+
+ rankIcon:SetHidden(true)
+
+ if EndsWith(result.name, GetString(SI_ITEMTYPE29)) then
+ local match = Cookbook[result.name:lower():gsub(" ","")]
+ local gmatch = settings.Cookbook[result.name:lower():gsub(" ","")]
+ if (match and settings.checkKnown == "known") or
+ (not match and settings.checkKnown == "unknown")then
+ rankIcon:SetDimensions(30, 30)
+ rankIcon:SetAnchor(CENTER, row, CENTER, 230)
+ rankIcon:SetTexture(CANLEARN)
+ rankIcon:SetHidden(false)
+ if not match and gmatch and settings.checkKnown == "unknown" and settings.markAlt then
+ rankIcon:SetColor(1,1,1,0.2)
+ else
+ rankIcon:SetColor(1,1,1,1)
+ end
+ end
+ end
+end
+
local function AddRecipe(Cookbook, link)
for _,v in pairs(Cookbook) do
if v == link then return end
@@ -173,6 +209,15 @@ local function SousChefCreateSettings()
end
+local function HookTrading(...)
+ if hookedDataFunction then return end
+ hookedDataFunction = ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback
+ ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback = function(...)
+ local row, data = ...
+ hookedDataFunction(...)
+ AddTradingSlot(row, data)
+ end
+end
local function SousChef_Loaded(eventCode, addOnName)
if(addOnName ~= "SousChef") then
@@ -192,21 +237,7 @@ local function SousChef_Loaded(eventCode, addOnName)
settings = ZO_SavedVars:NewAccountWide("SousChef_Settings", 5, nil, defaults)
- SLASH_COMMANDS["/SousChef"] = function()
- settings.watching = not settings.watching
- if settings.watching then
- d("Sous Chef is now ON")
- CheckNow(BACKPACK)
- CheckNow(BANK)
- CheckNow(GUILD_BANK)
- else
- d("Sous Chef is now OFF")
- for _,v in pairs(slotLines) do
- v:SetHidden(true)
- end
- end
- end
- SLASH_COMMANDS["/SCDebug"] = function()
+ SLASH_COMMANDS["/SCDebug"] = function()
d("Debug mode on")
SCCookbook = Cookbook
SCRCookbook = ReverseCookbook
@@ -214,12 +245,22 @@ local function SousChef_Loaded(eventCode, addOnName)
SCslotList = slotLines
SCsettings = settings
end
-
+ local function tablelength(T)
+ local count = 0
+ for _ in pairs(T) do count = count + 1 end
+ return count
+ end
+
+ SLASH_COMMANDS['/scstats'] = function()
+ d("Number of recipes known: ".. tablelength(settings.Cookbook))
+ d("Number of ingredients tracked: "..tablelength(settings.Pantry))
+ end
+
SousChefCreateSettings()
ParseRecipes()
- SLASH_COMMANDS["/sc"] = SLASH_COMMANDS["/SousChef"]
+
-- Now we want to hook into the function that sets the details on the inventory slot
for _,v in pairs(PLAYER_INVENTORY.inventories) do
@@ -237,6 +278,9 @@ local function SousChef_Loaded(eventCode, addOnName)
ZO_ScrollList_RefreshVisible(BACKPACK)
ZO_ScrollList_RefreshVisible(BANK)
ZO_ScrollList_RefreshVisible(GUILD_BANK)
+
+ EVENT_MANAGER:RegisterForEvent("SousChefTRading", EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, HookTrading)
+
end
local function SousChef_Initialized()