Skip to content

Commit

Permalink
Updated Usable Bag Items to now also Combine Gems
Browse files Browse the repository at this point in the history
  • Loading branch information
Larsj02 committed May 22, 2024
1 parent e988cf2 commit b8d445e
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 36 deletions.
71 changes: 71 additions & 0 deletions Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,77 @@ constants.CLOAK_BUFF = {
ACHIEVEMENT_ID_START = 20527,
ACHIEVEMENT_ID_END = 20538,
}
constants.USABLE_BAG_ITEMS = {
-- Prismatic Gems for Combining
[210715] = "GEM", -- Chipped Masterful Amethyst
[216640] = "GEM", -- Flawed Masterful Amethyst
[211106] = "GEM", -- Masterful Amethyst
[211108] = "GEM", -- Perfect Masterful Amethyst
[210714] = "GEM", -- Chipped Deadly Sapphire
[216644] = "GEM", -- Flawed Deadly Sapphire
[211123] = "GEM", -- Deadly Sapphire
[211102] = "GEM", -- Perfect Deadly Sapphire
[210681] = "GEM", -- Chipped Quick Topaz
[216643] = "GEM", -- Flawed Quick Topaz
[211107] = "GEM", -- Quick Topaz
[211110] = "GEM", -- Perfect Quick Topaz
[220371] = "GEM", -- Chipped Versatile Diamond
[220372] = "GEM", -- Flawed Versatile Diamond
[220374] = "GEM", -- Versatile Diamond
[220373] = "GEM", -- Perfect Versatile Diamond
[220367] = "GEM", -- Chipped Stalwart Pearl
[220368] = "GEM", -- Flawed Stalwart Pearl
[220370] = "GEM", -- Stalwart Pearl
[220369] = "GEM", -- Perfect Stalwart Pearl
[210717] = "GEM", -- Chipped Hungering Ruby
[216641] = "GEM", -- Flawed Hungering Ruby
[210718] = "GEM", -- Hungering Ruby
[211103] = "GEM", -- Perfect Hungering Ruby
[210716] = "GEM", -- Chipped Swift Opal
[216639] = "GEM", -- Flawed Swift Opal
[211124] = "GEM", -- Swift Opal
[211101] = "GEM", -- Perfect Swift Opal

-- Random Gem Items
[223907] = "RANDOM_GEM", -- Asynchronized Prismatic Gem
[223906] = "RANDOM_GEM", -- Asynchronized Tinker Gem
[223904] = "RANDOM_GEM", -- Asynchronized Cogwheel Gem
[223905] = "RANDOM_GEM", -- Asynchronized Meta Gem

-- Threads
[226144] = "THREAD", -- Lesser Spool of Eternal Thread
[226145] = "THREAD", -- Minor Spool of Eternal Thread
[226143] = "THREAD", -- Spool of Eternal Thread
[226142] = "THREAD", -- Greater Spool of Eternal Thread
[217722] = "THREAD", -- Thread of Experience
[219262] = "THREAD", -- Temporal Thread of Mastery
[219258] = "THREAD", -- Temporal Thread of Critical Strike
[219261] = "THREAD", -- Temporal Thread of Leech
[219260] = "THREAD", -- Temporal Thread of Speed
[219263] = "THREAD", -- Temporal Thread of Versatility
[219259] = "THREAD", -- Temporal Thread of Haste
[219256] = "THREAD", -- Temporal Thread of Power
[219257] = "THREAD", -- Temporal Thread of Stamina
[219264] = "THREAD", -- Temporal Thread of Experience
[219270] = "THREAD", -- Perpetual Thread of Leech
[219272] = "THREAD", -- Perpetual Thread of Versatility
[219267] = "THREAD", -- Perpetual Thread of Critical Strike
[219268] = "THREAD", -- Perpetual Thread of Haste
[219269] = "THREAD", -- Perpetual Thread of Speed
[219265] = "THREAD", -- Perpetual Thread of Power
[219271] = "THREAD", -- Perpetual Thread of Mastery
[219266] = "THREAD", -- Perpetual Thread of Stamina
[219273] = "THREAD", -- Perpetual Thread of Experience
[219279] = "THREAD", -- Infinite Thread of Leech
[219278] = "THREAD", -- Infinite Thread of Speed
[219276] = "THREAD", -- Infinite Thread of Critical Strike
[219277] = "THREAD", -- Infinite Thread of Haste
[219281] = "THREAD", -- Infinite Thread of Versatility
[219282] = "THREAD", -- Infinite Thread of Experience
[219280] = "THREAD", -- Infinite Thread of Mastery
[219274] = "THREAD", -- Infinite Thread of Power
[219275] = "THREAD", -- Infinite Thread of Stamina
}

constants.COLORS = {
POSITIVE = CreateColorFromHexString("FF2ecc71"),
Expand Down
101 changes: 68 additions & 33 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ local function itemListInitializer(frame, data)
frame.Stripe:SetShown(data.index % 2 == 1)
end

local function bagItemInitiliazer(frame, data)
if not frame.initialized then
local clickable = uiElements:CreateIcon(frame, {
points = {
{ "TOPLEFT" },
{ "BOTTOMRIGHT" }
},
})
frame.clickable = clickable
frame.initialized = true
end
frame.clickable:UpdateClickable(true, "ITEM", data.itemID, true)
end

local function createFrame()
local gems = uiElements:CreateBaseFrame(CharacterFrame, {
title = const.ADDON_NAME,
Expand Down Expand Up @@ -181,12 +195,13 @@ local function createFrame()
local castButton = resocketButtons[gemIndex]
if castButton then
castButton:UpdateClickable(true, "ITEM", gemID)
castButton:SetPoint("LEFT", self, "CENTER", gemsStart + (gemIndex - 1 ) * 50, 5)
castButton:SetPoint("LEFT", self, "CENTER", gemsStart + (gemIndex - 1) * 50, 5)
castButton:Show()
end
end
self:Show()
end

resocketPopup:Hide()

local frameToggle = CreateFrame("Frame", nil, CharacterFrame)
Expand Down Expand Up @@ -269,32 +284,52 @@ local function createFrame()
end
})

local openLootbox = uiElements:CreateIcon(gems, {
points = {
{ "TOPLEFT", gems, "BOTTOMLEFT", 5, -5 }
},
isClickable = true,
actionType = "ITEM",
actionID = 211279
})

local openRandomGemP = uiElements:CreateIcon(gems, {
local openBagItems = uiElements:CreateBaseFrame(gems, {
frameStyle = "Flat",
height = 150,
title = "Open, Use and Combine",
points = {
{ "LEFT", openLootbox, "RIGHT", 5, 0 }
},
isClickable = true,
actionType = "ITEM",
actionID = 223907
{ "TOPLEFT", gems, "BOTTOMLEFT", 0, -2 },
{ "TOPRIGHT", gems, "BOTTOMRIGHT", 0, -2 },
}
})

local openRandomGemT = uiElements:CreateIcon(gems, {
points = {
{ "LEFT", openRandomGemP, "RIGHT", 5, 0 }
},
isClickable = true,
actionType = "ITEM",
actionID = 223906
local openBagText = openBagItems:CreateFontString()
openBagText:SetFontObject(const.FONT_OBJECTS.HEADING)
openBagText:SetText("NOTHING TO USE")
openBagText:SetPoint("CENTER", 0, -10)
openBagText:Hide()
local allPointsAnchorPoints = {
CreateAnchor("TOPLEFT", openBagItems, "TOPLEFT", 25, -35),
CreateAnchor("BOTTOMRIGHT", openBagItems, "BOTTOMRIGHT", -25, 15)
}
local bagItemScrollBox, bagItemScrollView = uiElements:CreateScrollable(openBagItems, {
element_height = 45,
type = "GRID",
initializer = bagItemInitiliazer,
element_padding = 5,
elements_per_row = math.floor((gems:GetWidth() - 50) / 50),
anchors = {
with_scroll_bar = allPointsAnchorPoints,
without_scroll_bar = allPointsAnchorPoints,
}
})
local function updateBagItems()
if not bagItemScrollBox:IsVisible() then return end
bagItemScrollView:UpdateContentData({})
local added = 0
for itemID, itemType in pairs(const.USABLE_BAG_ITEMS) do
local count = C_Item.GetItemCount(itemID)
local threshold = itemType == "GEM" and 3 or 1
if count >= threshold then
bagItemScrollView:UpdateContentData({ { itemID = itemID } }, true)
end
end
openBagItems:SetHeight(added > 0 and 150 or 75)
openBagText:SetShown(added < 1)
end
bagItemScrollBox:RegisterEvent("BAG_UPDATE_DELAYED")
bagItemScrollBox:SetScript("OnEvent", updateBagItems)
bagItemScrollBox:SetScript("OnShow", updateBagItems)

local openRandomGemC = uiElements:CreateIcon(gems, {
points = {
Expand Down Expand Up @@ -461,17 +496,17 @@ eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
eventFrame:RegisterEvent("SCRAPPING_MACHINE_ITEM_ADDED")
eventFrame:SetScript("OnEvent", function(_, event)
if event == "SCRAPPING_MACHINE_ITEM_ADDED" then
RunNextFrame(function()
local mun = ScrappingMachineFrame
for f in pairs(mun.ItemSlots.scrapButtons.activeObjects) do
if f.itemLink then
local gemsList = gemUtil:GetItemGems(f.itemLink)
if #gemsList > 0 then
Private.Frames.ResocketPopup:FillPopup(gemsList)
RunNextFrame(function()
local mun = ScrappingMachineFrame
for f in pairs(mun.ItemSlots.scrapButtons.activeObjects) do
if f.itemLink then
local gemsList = gemUtil:GetItemGems(f.itemLink)
if #gemsList > 0 then
Private.Frames.ResocketPopup:FillPopup(gemsList)
end
end
end
end
end)
end)
end
if event ~= "PLAYER_ENTERING_WORLD" then return end

Expand Down
9 changes: 6 additions & 3 deletions UIElements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function uiElements:CreateIcon(parent, data)
button.icon = icon
button.lastUpdate = 0

function button:UpdateClickable(isClickable, actionType, actionID)
function button:UpdateClickable(isClickable, actionType, actionID, noExtract)
self:UnregisterAllEvents()
self:SetScript("OnEvent", nil)
self:SetScript("PreClick", nil)
Expand Down Expand Up @@ -362,9 +362,12 @@ function uiElements:CreateIcon(parent, data)
self:RegisterEvent("ITEM_COUNT_CHANGED")
self:RegisterEvent("BAG_UPDATE_DELAYED")
self:SetScript("OnEvent", updateItemCountOrSlot)
self:SetScript("PreClick", extractPreClick)
self:SetScript("PostClick", extractPostClick)
if not noExtract then
self:SetScript("PreClick", extractPreClick)
self:SetScript("PostClick", extractPostClick)
end
updateItemCountOrSlot(self)
updateItemCountOrSlot(self, "BAG_UPDATE_DELAYED")
end
end

Expand Down

0 comments on commit b8d445e

Please sign in to comment.