Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed May 17, 2024
1 parent 3cb7af0 commit e8ee088
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 61 deletions.
23 changes: 11 additions & 12 deletions EZTrade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ local addonName, EZT = ...
local f = CreateFrame("Frame")

local function isRelevantLoot(classID)

if EZTradeDB.debug then
return true
end

if (classID == 2 and EZTradeDB.trackWeapons) then
return true
elseif (classID == 4 and EZTradeDB.trackArmors) then
Expand All @@ -14,8 +19,6 @@ local function isRelevantLoot(classID)
return true
elseif (classID == 17 and EZTradeDB.trackPets) then
return true
--elseif (classID == 0 or classID == 15) then -- Temporary
-- return true
else
return false
end
Expand Down Expand Up @@ -53,20 +56,16 @@ function f:CHAT_MSG_LOOT(lootText)
local localizedLootString = LOOT_ITEM_SELF:gsub("%%s", ""):gsub("%.$", "")

local itemLinkTmp = string.match(lootText, "|c.-|h|r")
--local itemId = GetItemInfoFromHyperlink(itemLinkTmp)

if (itemLinkTmp) then
local itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType,
itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID,
subclassID, bindType, expansionID, setID, isCraftingReagent = C_Item.GetItemInfo(itemLinkTmp)

EZT.debugPrint(itemLink .. classID)
local _, _, _, _, _, _, _, _, _, _, _, classID = C_Item.GetItemInfo(itemLinkTmp)

if (isMyLoot(lootText, localizedLootString)) then -- Only add "my" loot to the list.
---@diagnostic disable-next-line: undefined-field
if (isRelevantLoot(classID)) then -- Only add relevant loot
EZT.AddLoot(itemLinkTmp)
--EZT.RedrawLootList()
if (isRelevantLoot(classID)) then -- Only add relevant loot
C_Timer.After(1, function()
EZT.AddLoot(itemLinkTmp)
end)
end
end
end
Expand All @@ -79,4 +78,4 @@ end)
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("CHAT_MSG_LOOT")
f:RegisterEvent("TRADE_SHOW")
f:RegisterEvent("TRADE_CLOSED")
f:RegisterEvent("TRADE_CLOSED")
6 changes: 4 additions & 2 deletions EZTrade.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
## Title: |cff45D388EZTrade|r
## Notes: EZ trade items you recently looted
## Author: Pinta365@Github
## Version: 0.0.1
## SavedVariables: EZTradeDB
## Version: 0.1.0
## SavedVariables: EZTradeDB
## X-Curse-Project-ID: 1016387
## X-Wago-ID: BKpqarGE
## IconTexture: Interface\AddOns\EZTrade\Textures\pinta

src\Config.lua
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## EZTrade
## EZTrade - World of Warcraft Addon

Your bags are a chaotic mess of reagents, grey vendor trash, and that epic trinket you just won. Your friends are green with envy, but you can't even find the darn thing to trade it to them. **EZTrade** to the rescue!

Expand Down
19 changes: 13 additions & 6 deletions src/DebugPanel.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
--DebugPanel.lua
-- Just a temporary panel with things for development

local addonName, EZT = ...



EZT.setUpDebugFrame = function()
---@class EZTDebugFrame: Frame
local EZTDebugFrame = CreateFrame("Frame", "EZTradeFrame", UIParent, "BasicFrameTemplateWithInset")
Expand All @@ -25,7 +24,9 @@ EZT.setUpDebugFrame = function()
button1:SetWidth(200)
EZT.setOrHookHandler(button1, "OnClick", function(self)
EZT.AddLoot("|cffa335ee|Hitem:193869::::::::4:1448:::::::::|h[Pattern: Toxic Thorn Footwraps]|h|r")
--EZT.RedrawLootList()
C_Timer.After(1, function()
EZT.RedrawLootList()
end)
end)

local button2 = CreateFrame("Button", "Dathea's Cyclonic Cage", EZTDebugFrame, "UIPanelButtonTemplate")
Expand All @@ -35,7 +36,9 @@ EZT.setUpDebugFrame = function()
button2:SetWidth(200)
EZT.setOrHookHandler(button2, "OnClick", function(self)
EZT.AddLoot("|cffa335ee|Hitem:195494::::::::4:1448:::::::::|h[Dathea's Cyclonic Cage]|h|r")
--EZT.RedrawLootList()
C_Timer.After(1, function()
EZT.RedrawLootList()
end)
end)

local button3 = CreateFrame("Button", "Sargha's Smasher", EZTDebugFrame, "UIPanelButtonTemplate")
Expand All @@ -45,7 +48,9 @@ EZT.setUpDebugFrame = function()
button3:SetWidth(200)
EZT.setOrHookHandler(button3, "OnClick", function(self)
EZT.AddLoot("|cff0070dd|Hitem:193779::::::::4:1448:::::::::|h[Sargha's Smasher]|h|r")
--EZT.RedrawLootList()
C_Timer.After(1, function()
EZT.RedrawLootList()
end)
end)

local button4 = CreateFrame("Button", "Eye of Allseeing", EZTDebugFrame, "UIPanelButtonTemplate")
Expand All @@ -55,7 +60,9 @@ EZT.setUpDebugFrame = function()
button4:SetWidth(200)
EZT.setOrHookHandler(button4, "OnClick", function(self)
EZT.AddLoot("|cff1eff00|Hitem:186554::::::::4:1448:::::::::|h[Eye of Allseeing]|h|r")
--EZT.RedrawLootList()
C_Timer.After(1, function()
EZT.RedrawLootList()
end)
end)

local button5 = CreateFrame("Button", "Redraw", EZTDebugFrame, "UIPanelButtonTemplate")
Expand Down
26 changes: 14 additions & 12 deletions src/OptionsPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,51 +44,53 @@ EZT.InitOptions = function()
optionsPanel.name = addonName

-- Create a toggle for the "Debug" option.
local debugCheckbox = createOptionCheckButton(optionsPanel, "Debug mode (developer mode)", "ToggleDebugCheckbox", 16, -16)
EZT.setOrHookHandler(debugCheckbox, "OnClick", function(self)
EZTradeDB.debug = self:GetChecked()
end)
debugCheckbox:SetChecked(EZTradeDB.debug)
--local debugCheckbox = createOptionCheckButton(optionsPanel, "Debug mode (developer mode)", "ToggleDebugCheckbox", 16, -16)
--EZT.setOrHookHandler(debugCheckbox, "OnClick", function(self)
-- EZTradeDB.debug = self:GetChecked()
--end)
--debugCheckbox:SetChecked(EZTradeDB.debug)

-- Loot options

optionsPanel.lootHeader = optionsPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlightMedium")
optionsPanel.lootHeader:SetPoint("TOPLEFT", 16, -100)
optionsPanel.lootHeader:SetPoint("TOPLEFT", 16, -10)
optionsPanel.lootHeader:SetText("Loot tracking")

local trackWeapons = createOptionCheckButton(optionsPanel, "Track weapons", "trackWeaponsButton", 16, -120)
local trackWeapons = createOptionCheckButton(optionsPanel, "Track weapons", "trackWeaponsButton", 16, -30)
EZT.setOrHookHandler(trackWeapons, "OnClick", function(self)
EZTradeDB.trackWeapons = self:GetChecked()
end)
trackWeapons:SetChecked(EZTradeDB.trackWeapons)

local trackArmors = createOptionCheckButton(optionsPanel, "Track armors", "trackArmorsButton", 16, -140)
local trackArmors = createOptionCheckButton(optionsPanel, "Track armors", "trackArmorsButton", 16, -50)
EZT.setOrHookHandler(trackArmors, "OnClick", function(self)
EZTradeDB.trackArmors = self:GetChecked()
end)
trackArmors:SetChecked(EZTradeDB.trackArmors)

local trackRecipe = createOptionCheckButton(optionsPanel, "Track recipies", "trackRecipeButton", 16, -160)
local trackRecipe = createOptionCheckButton(optionsPanel, "Track recipies", "trackRecipeButton", 16, -70)
EZT.setOrHookHandler(trackRecipe, "OnClick", function(self)
EZTradeDB.trackRecipe = self:GetChecked()
end)
trackRecipe:SetChecked(EZTradeDB.trackRecipe)

local trackPets = createOptionCheckButton(optionsPanel, "Track battle pets", "trackPetsButton", 16, -180)
local trackPets = createOptionCheckButton(optionsPanel, "Track battle pets", "trackPetsButton", 16, -90)
EZT.setOrHookHandler(trackPets, "OnClick", function(self)
EZTradeDB.trackPets = self:GetChecked()
end)
trackPets:SetChecked(EZTradeDB.trackPets)

-- Button for resetting to default settings.
local resetButton = createOptionButton(optionsPanel, "Reset settings", "resetButton", 16, -48, 100, 25)
local resetButton = createOptionButton(optionsPanel, "Reset to default settings", "resetButton", 16, -200, 200, 25)
EZT.setOrHookHandler(resetButton, "OnClick", function()
EZTradeDB = CopyTable(EZT.addonDefaults)
debugCheckbox:SetChecked(EZTradeDB.debug)
--debugCheckbox:SetChecked(EZTradeDB.debug)
trackWeapons:SetChecked(EZTradeDB.trackWeapons)
trackArmors:SetChecked(EZTradeDB.trackArmors)
trackRecipe:SetChecked(EZTradeDB.trackRecipe)
trackPets:SetChecked(EZTradeDB.trackPets)

print(WrapTextInColorCode(EZT.addon.title .. " is reset to default settings.", EZT.colors["PRIMARY"]))
end)

optionsPanel.versionInfo = optionsPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
Expand Down
9 changes: 9 additions & 0 deletions src/SlashCommand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ SlashCmdList["EZTrade_CMD"] = function(args)
--Reset to default settings.
EZTradeDB = CopyTable(EZT.addonDefaults)
ReloadUI()
elseif lowercaseArgs == "debug" then
-- toggle EZTradeDB.debug
EZTradeDB.debug = not EZTradeDB.debug
if EZTradeDB.debug then
print(WrapTextInColorCode(EZT.addon.title .. " debug mode enabled.", EZT.colors["PRIMARY"]))
else
print(WrapTextInColorCode(EZT.addon.title .. " debug mode disabled.", EZT.colors["PRIMARY"]))
end

else
InterfaceOptionsFrame_OpenToCategory("EZTrade")
end
Expand Down
Loading

0 comments on commit e8ee088

Please sign in to comment.