Skip to content

Commit

Permalink
Replace EasyMenu calls
Browse files Browse the repository at this point in the history
  • Loading branch information
b-morgan committed Sep 16, 2024
1 parent 5d4a20d commit fb19e83
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 87 deletions.
59 changes: 35 additions & 24 deletions Skillet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ function Skillet:OnInitialize()
if not self.db.global.customPrice then
self.db.global.customPrice = {}
end
if not self.db.global.warbandData then
self.db.global.warbandData = {}
end
if not self.db.global.warbandDetails then
self.db.global.warbandDetails = {}
end
--
-- Initialize the Skill Levels data if any of the tables are missing
--
Expand Down Expand Up @@ -398,13 +404,6 @@ function Skillet:OnInitialize()
end
Skillet.FixBugs = Skillet.db.profile.FixBugs

--
-- Fix InterfaceOptionsFrame_OpenToCategory not actually opening the category (and not even scrolling to it)
--
if Skillet.FixBugs then
Skillet:FixOpenToCategory()
end

--
-- Create static popups for changing professions
--
Expand Down Expand Up @@ -456,6 +455,15 @@ StaticPopupDialogs["SKILLET_MANUAL_CHANGE"] = {
self:InitializeDatabase(UnitName("player"))
self:InitializePlugins()
self.NewsGUI:Initialize()

--
-- Some counters for high frequency events
--
if not Skillet.bagUpdateCounts then
Skillet.bagUpdateCounts = {}
Skillet.bagUpdateDelayedCount = 0
Skillet.bankUpdateCount = 0
end
end

--
Expand Down Expand Up @@ -553,6 +561,8 @@ function Skillet:FlushDetailData()
Skillet.db.realm.bagDetails = {}
Skillet.db.realm.bankData = {}
Skillet.db.realm.bankDetails = {}
Skillet.db.global.warbandData = {}
Skillet.db.global.warbandDetails = {}
Skillet.db.global.detailedGuildbank = {}
end

Expand Down Expand Up @@ -789,40 +799,41 @@ function Skillet:OnEnable()
self:RegisterEvent("NEW_RECIPE_LEARNED") -- arg1 = recipeID
-- self:RegisterEvent("ADDON_ACTION_BLOCKED")

if Skillet.db.profile.BlizzOR then
--
-- Dump the data passed to C_TradeSkillUI functions so we can learn how Blizzard handles the new stuff
--
-- C_TradeSkillUI.CraftRecipe(recipeSpellID [, numCasts, craftingReagents, recipeLevel, orderID])
--
hooksecurefunc(C_TradeSkillUI,"CraftRecipe",function(...)
local recipeSpellID, numCasts, craftingReagents, recipeLevel, orderID = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftRecipe: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", recipeLevel= "..tostring(recipeLevel)..", orderID= "..tostring(orderID))
end)
hooksecurefunc(C_TradeSkillUI,"CraftRecipe",function(...)
local recipeSpellID, numCasts, craftingReagents, recipeLevel, orderID = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftRecipe: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", recipeLevel= "..tostring(recipeLevel)..", orderID= "..tostring(orderID))
end)

--
-- C_TradeSkillUI.CraftSalvage(recipeSpellID [, numCasts, itemTarget])
--
hooksecurefunc(C_TradeSkillUI,"CraftSalvage",function(...)
local recipeSpellID, numCasts, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftSalvage: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", itemTarget= "..DA.DUMP(itemTarget))
end)
hooksecurefunc(C_TradeSkillUI,"CraftSalvage",function(...)
local recipeSpellID, numCasts, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftSalvage: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", itemTarget= "..DA.DUMP(itemTarget))
end)

--
-- C_TradeSkillUI.CraftEnchant(recipeSpellID [, numCasts, craftingReagents, itemTarget])
--
hooksecurefunc(C_TradeSkillUI,"CraftEnchant",function(...)
local recipeSpellID, numCasts, craftingReagents, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftEnchant: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", itemTarget= "..DA.DUMP(itemTarget))
end)
hooksecurefunc(C_TradeSkillUI,"CraftEnchant",function(...)
local recipeSpellID, numCasts, craftingReagents, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftEnchant: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", itemTarget= "..DA.DUMP(itemTarget))
end)

--
-- result = C_TradeSkillUI.RecraftRecipe(itemGUID [, craftingReagents])
--
hooksecurefunc(C_TradeSkillUI,"RecraftRecipe",function(...)
local itemGUID, craftingReagents = ...
DA.DEBUG(0, "C_TradeSkillUI.RecraftRecipe: itemGUID= "..tostring(itemGUID)..", craftingReagents= "..DA.DUMP(craftingReagents))
end)

hooksecurefunc(C_TradeSkillUI,"RecraftRecipe",function(...)
local itemGUID, craftingReagents = ...
DA.DEBUG(0, "C_TradeSkillUI.RecraftRecipe: itemGUID= "..tostring(itemGUID)..", craftingReagents= "..DA.DUMP(craftingReagents))
end)
end
--
-- Debugging cleanup if enabled
--
Expand Down
2 changes: 2 additions & 0 deletions Skillet.toc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Libs\LibPeriodicTable-3.1\LibPeriodicTable-3.1.lua
Libs\LibPeriodicTable-3.1\LibPeriodicTable-3.1-Tradeskill\LibPeriodicTable-3.1-Tradeskill.lua
Libs\LibPeriodicTable-3.1\LibPeriodicTable-3.1-TradeskillResultMats\LibPeriodicTable-3.1-TradeskillResultMats.lua
Libs\LibPeriodicTable-3.1\LibPeriodicTable-3.1-TradeskillLevels\LibPeriodicTable-3.1-TradeskillLevels.lua
Libs\EasySkillet\EasySkillet.lua
Libs\EasySkillet\UIDropDownSkillet.xml

#### Localization files
Locale\Locale-enUS.lua
Expand Down
14 changes: 14 additions & 0 deletions SkilletNewsData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ local isCata = WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC

Skillet.NewsName = "Skillet News"
Skillet.NewsData = {
{ version = "5.34",
data = {
{ name = "Changes",
data = {
{ header = "Warband Bank", body = "Keep track of Warband (Account) bank" },
},
},
{ name = "Fixes",
data = {
{ header = "EasyMenu", body = "Replace EasyMenu calls" },
},
},
},
},
{ version = "5.33",
data = {
{ name = "Changes",
Expand Down
117 changes: 64 additions & 53 deletions SkilletOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,20 @@ Skillet.options =
end,
order = 67
},
printshop = {
type = 'execute',
name = "printshop",
desc = "Print ShoppingList",
func = function()
if not (UnitAffectingCombat("player")) then
Skillet:PrintShoppingList()
else
DA.DEBUG(0,"|cff8888ffSkillet|r: Combat lockdown restriction." ..
" Leave combat and try again.")
end
end,
order = 68
},
--
-- commands to toggle Blizzard's frames (beats using "/run")
--
Expand All @@ -844,7 +858,7 @@ Skillet.options =
Skillet.BlizzardUIshowing = false
end
end,
order = 68
order = 69
},
bcui = {
type = "toggle",
Expand All @@ -861,7 +875,7 @@ Skillet.options =
HideUIPanel(CraftFrame)
end
end,
order = 69
order = 70
},
--
-- commands to update Skillet's main windows
Expand Down Expand Up @@ -1497,6 +1511,54 @@ Skillet.options =
end,
order = 109
},
--
-- Debug options to deal with bag update events slowing bag and bank sorting
--
bagevents = {
type = "toggle",
name = "bagevents",
desc = "Option for debugging",
get = function()
return Skillet.BagEvents
end,
set = function(self,value)
Skillet.BagEvents = value
if Skillet.BagEvents then
Skillet:UnregisterEvent("BAG_UPDATE") -- Fires for both bag and bank updates.
Skillet:UnregisterEvent("BAG_UPDATE_DELAYED") -- Fires after all applicable BAG_UPDATE events for a specific action have been fired.
Skillet:UnregisterEvent("UNIT_INVENTORY_CHANGED") -- BAG_UPDATE_DELAYED seems to have disappeared. Using this instead.
Skillet:Print(RED_FONT_COLOR_CODE.."BAG_UPDATE events are off"..FONT_COLOR_CODE_CLOSE)
else
Skillet:RegisterEvent("BAG_UPDATE") -- Fires for both bag and bank updates.
Skillet:RegisterEvent("BAG_UPDATE_DELAYED") -- Fires after all applicable BAG_UPDATE events for a specific action have been fired.
Skillet:RegisterEvent("UNIT_INVENTORY_CHANGED") -- BAG_UPDATE_DELAYED seems to have disappeared. Using this instead.
Skillet:Print(GREEN_FONT_COLOR_CODE.."BAG_UPDATE events are on"..FONT_COLOR_CODE_CLOSE)
end
end,
order = 120
},
bagcounts = {
type = 'execute',
name = "bagcounts",
desc = "Option for debugging",
func = function()
Skillet:Print("bagUpdateCounts= "..DA.DUMP1(Skillet.bagUpdateCounts))
Skillet:Print("bagUpdateDelayedCount= "..tostring(Skillet.bagUpdateDelayedCount))
Skillet:Print("bankUpdateCount= "..tostring(Skillet.bankUpdateCount))
end,
order = 121
},
bagclear = {
type = 'execute',
name = "bagclear",
desc = "Option for debugging",
func = function()
Skillet.bagUpdateCounts = {}
Skillet.bagUpdateDelayedCount = 0
Skillet.bankUpdateCount = 0
end,
order = 122
},
}
}

Expand Down Expand Up @@ -1541,54 +1603,3 @@ local function get_panel_name(panel)
end
end
end

local doNotRun
local function InterfaceOptionsFrame_OpenToCategory_Fix(panel)
if doNotRun or InCombatLockdown() then return end
local panelName = get_panel_name(panel)
if not panelName then return end -- if its not part of our list return early
local noncollapsedHeaders = {}
local shownpanels = 0
local mypanel
local t = {}
local cat = INTERFACEOPTIONS_ADDONCATEGORIES
for i = 1, #cat do
local panel = cat[i]
if not panel.parent or noncollapsedHeaders[panel.parent] then
if panel.name == panelName then
panel.collapsed = true
t.element = panel
InterfaceOptionsListButton_ToggleSubCategories(t)
noncollapsedHeaders[panel.name] = true
mypanel = shownpanels + 1
end
if not panel.collapsed then
noncollapsedHeaders[panel.name] = true
end
shownpanels = shownpanels + 1
end
end
local Smin, Smax = InterfaceOptionsFrameAddOnsListScrollBar:GetMinMaxValues()
if shownpanels > 15 and Smin < Smax then
local val = (Smax/(shownpanels-15))*(mypanel-2)
InterfaceOptionsFrameAddOnsListScrollBar:SetValue(val)
end
doNotRun = true
InterfaceOptionsFrame_OpenToCategory(panel)
doNotRun = false
end

--
-- Fix InterfaceOptionsFrame_OpenToCategory not actually opening the category (and not even scrolling to it)
--
function Skillet:FixOpenToCategory()
--[[
if (not IsAddOnLoaded("!BlizzBugsSuck")) then
DA.DEBUG(0,"FixOpenToCategory executed")
hooksecurefunc("InterfaceOptionsFrame_OpenToCategory", InterfaceOptionsFrame_OpenToCategory_Fix)
else
DA.DEBUG(0,"FixOpenToCategory skipped")
end
--]]
end

2 changes: 1 addition & 1 deletion UI/DetailFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ function Skillet:ReagentButtonOnClick(button, mouse, skillIndex, reagentIndex)
else
local x, y = GetCursorPosition()
local uiScale = UIParent:GetEffectiveScale()
EasyMenu(self.data.recipeMenuTable, self.recipeMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(self.data.recipeMenuTable, self.recipeMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
end
end
end
Expand Down
46 changes: 37 additions & 9 deletions UI/MainFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,8 @@ function Skillet:UpdateTradeSkillWindow()
self:RecipeDifficultyButton_OnShow()
SkilletUseHighestQuality:SetChecked(self.db.profile.best_quality)
SkilletUseHighestQuality:Show()
SkilletUseConcentration:SetChecked(self.db.profile.use_concentration)
SkilletUseConcentration:Show()
SkilletHideUncraftableRecipes:SetChecked(self:GetTradeSkillOption("hideuncraftable"))
C_TradeSkillUI.SetOnlyShowMakeableRecipes(self:GetTradeSkillOption("hideuncraftable"))
self:UpdateQueueWindow()
Expand Down Expand Up @@ -2624,19 +2626,28 @@ function Skillet:SkilletSkillMenu_Show(button)
local x, y = GetCursorPosition()
local uiScale = UIParent:GetEffectiveScale()
local locked = self:RecipeGroupIsLocked()
if not SkilletSkillMenu then
SkilletSkillMenu = CreateFrame("Frame", "SkilletSkillMenu", _G["UIParent"], "UIDropDownMenuTemplate")
SkilletSkillMenu:SetScale(uiScale)
if not SkilletSkillMenu.SetBackdrop then
Mixin(SkilletSkillMenu, BackdropTemplateMixin)
end
SkilletSkillMenu:SetBackdrop(FrameBackdrop)
SkilletSkillMenu:SetBackdropColor(0.1, 0.1, 0.1)
end
self.menuButton = button
if button.skill.subGroup then
if button.skill.mainGroup then
if locked then
EasyMenu(headerMenuListMainGroupLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(headerMenuListMainGroupLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
else
EasyMenu(headerMenuListMainGroup, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(headerMenuListMainGroup, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
end
else
if locked then
EasyMenu(headerMenuListLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(headerMenuListLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
else
EasyMenu(headerMenuList, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(headerMenuList, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
end
end
else
Expand All @@ -2650,9 +2661,9 @@ function Skillet:SkilletSkillMenu_Show(button)
favoriteMenu["text"] = L["Remove Favorite"]
end
if locked then
EasyMenu(skillMenuListLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(skillMenuListLocked, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
else
EasyMenu(skillMenuList, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
EasySkillet(skillMenuList, SkilletSkillMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
end
end
end
Expand Down Expand Up @@ -2773,13 +2784,23 @@ function Skillet:StartQueue_OnClick(button, mouse)
end

function Skillet:SkilletQueueMenu_Show(button)
--DA.DEBUG(0,"SkilletQueueMenu_Show("..tostring(button)..")")
local x, y = GetCursorPosition()
local uiScale = UIParent:GetEffectiveScale()
if not SkilletQueueMenu then
SkilletQueueMenu = CreateFrame("Frame", "SkilletQueueMenu", _G["UIParent"], "UIDropDownMenuTemplate")
-- SkilletQueueMenu = CreateFrame("Frame", "SkilletQueueMenu", _G["UIParent"], "WowStyle1DropdownTemplate")
--DA.DEBUG(0,"SkilletQueueMenu_Show: uiScale= "..tostring(uiScale))
SkilletQueueMenu:SetScale(uiScale)
end
local x, y = GetCursorPosition()
local uiScale = UIParent:GetEffectiveScale()
self.queueMenuButton = button
EasyMenu(queueMenuList, SkilletQueueMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
-- EasyMenu(queueMenuList, SkilletQueueMenu, _G["UIParent"], x/uiScale,y/uiScale, "MENU", 5)
MenuUtil.CreateButtonContextMenu(SkilletQueueMenu,
{L["Move to Top"], function() Skillet:QueueMoveToTop(Skillet.queueMenuButton:GetID()) end},
{L["Move Up"], function() Skillet:QueueMoveUp(Skillet.queueMenuButton:GetID()) end},
{L["Move Down"], function() Skillet:QueueMoveDown(Skillet.queueMenuButton:GetID()) end},
{L["Move to Bottom"], function() Skillet:QueueMoveToBottom(Skillet.queueMenuButton:GetID()) end}
);
end

function Skillet:QueueManagementToggle(showDetails)
Expand Down Expand Up @@ -3108,3 +3129,10 @@ function Skillet:AddButtonToTradeskillWindow(button)
end
return SkilletFrame
end

function Skillet:ToggleUseConcentration()
self.db.profile.use_concentration = not self.db.profile.use_concentration
--DA.DEBUG(0,"ToggleUseConcentration: use_concentration= "..tostring(self.db.profile.use_concentration))
SkilletUseConcentration:SetChecked(self.db.profile.use_concentration)
self:UpdateDetailWindow(self.selectedSkill)
end
Loading

0 comments on commit fb19e83

Please sign in to comment.