-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSchematicForm.lua
More file actions
81 lines (69 loc) · 2.46 KB
/
Copy pathSchematicForm.lua
File metadata and controls
81 lines (69 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---@class BFC
local BFC = select(2, ...)
local L = BFC.L
---@type AbstractFramework
local AF = _G.AbstractFramework
local GetCraftingReagentCount = ItemUtil.GetCraftingReagentCount
local GetCraftingReagentCountUnlocked = function() return 999 end
local forms
local currentForm
local function SetCurrentForm(frame)
currentForm = frame
end
---------------------------------------------------------------------
-- unlock button
---------------------------------------------------------------------
local unlockButton
local function UpdateUnlockState(trigger)
if trigger == unlockButton then
unlockButton._unlocked = not unlockButton._unlocked
else
unlockButton._unlocked = nil
end
if unlockButton._unlocked then
AF.RainbowText_Start(unlockButton.text)
ItemUtil.GetCraftingReagentCount = GetCraftingReagentCountUnlocked
else
AF.RainbowText_Stop(unlockButton.text)
ItemUtil.GetCraftingReagentCount = GetCraftingReagentCount
end
if currentForm and currentForm:IsVisible() then
currentForm:UpdateAllSlots()
end
end
local function UpdateUnlockButton(frame)
if not unlockButton then
unlockButton = AF.CreateButton(BFCMainFrame, L["Unlock All Reagents (For Simulation)"], "accent_hover", 200, 18)
unlockButton:SetOnClick(UpdateUnlockState)
end
local label = frame.Label
if label and label:IsVisible() then
unlockButton:SetParent(frame)
AF.ClearPoints(unlockButton)
AF.SetPoint(unlockButton, "LEFT", label, label:GetWrappedWidth() + 10, 0)
unlockButton:Show()
AF.ResizeToFitText(unlockButton, unlockButton.text, 5)
else
unlockButton:Hide()
end
end
---------------------------------------------------------------------
-- setup schematic simulation
---------------------------------------------------------------------
function BFC.SetupSchematicSimulation()
forms = {
_G.ProfessionsFrame.CraftingPage.SchematicForm,
_G.ProfessionsFrame.OrdersPage.OrderView.OrderDetails.SchematicForm
}
_G.ProfessionsFrame:HookScript("OnHide", UpdateUnlockState)
for _, form in next, forms do
if not form._BFCHooked then
form._BFCHooked = true
form:HookScript("OnShow", SetCurrentForm)
-- form:HookScript("OnHide", UpdateUnlockState)
if form.Reagents then
form.Reagents:HookScript("OnShow", UpdateUnlockButton)
end
end
end
end