-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWelcome.lua
More file actions
141 lines (124 loc) · 5.4 KB
/
Copy pathWelcome.lua
File metadata and controls
141 lines (124 loc) · 5.4 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
local ADDON, AF = ...
-- First-login welcome window. Explains AutoFeed and lets the player create only
-- the macros they want - each costs one per-character macro slot, so we no longer
-- auto-create them. Reopen any time with /autofeed welcome.
local function MacroExists(name)
local idx = name and GetMacroIndexByName(name)
return idx and idx > 0
end
function AF:ShowWelcome()
if AF.welcomeFrame then
if AF.welcomeFrame.Refresh then AF.welcomeFrame:Refresh() end
AF.welcomeFrame:Show()
return
end
local w = CreateFrame("Frame", "AutoFeedWelcome", UIParent, "BackdropTemplate")
w:SetSize(440, 120) -- height set after rows lay out
w:SetPoint("CENTER", 0, 140)
w:SetFrameStrata("DIALOG")
w:SetClampedToScreen(true)
w:EnableMouse(true)
w:SetMovable(true)
w:RegisterForDrag("LeftButton")
w:SetScript("OnDragStart", function(self) self:StartMoving() end)
w:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
w:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 },
})
w:SetBackdropColor(0, 0, 0, 0.92)
w:SetBackdropBorderColor(0.3, 0.5, 0.85, 1)
tinsert(UISpecialFrames, "AutoFeedWelcome") -- Escape closes
AF.welcomeFrame = w
local icon = w:CreateTexture(nil, "ARTWORK")
icon:SetSize(28, 28)
icon:SetPoint("TOPLEFT", 14, -12)
icon:SetTexture("Interface\\Icons\\INV_Misc_Food_15")
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
local title = w:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("LEFT", icon, "RIGHT", 10, 0)
title:SetText("|cff66ccffWelcome to AutoFeed|r")
local close = CreateFrame("Button", nil, w, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", 2, 2)
close:SetScript("OnClick", function() w:Hide() end)
local body = w:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
body:SetPoint("TOPLEFT", 16, -50)
body:SetWidth(408); body:SetJustifyH("LEFT"); body:SetSpacing(3)
body:SetText("Self-updating macros that always point at the best consumable in your "
.. "bags - eat, drink, pot, and buff from one button each.\n\n"
.. "Each macro uses |cffffd100one character macro slot|r, so create only the ones "
.. "you'll use. Click Create, then drag the macro from |cffffd100Esc > Macros|r onto "
.. "your action bars (one time).")
local DESC = {
food = "Eat the best food",
drink = "Drink the best water",
heal = "Best healing potion (combat-safe)",
mana = "Best mana potion (combat-safe)",
scroll = "Next scroll buff you're missing",
bandage = "Use your best bandage",
}
local hasMana = (UnitPowerMax("player", 0) or 0) > 0
local bodyH = body:GetStringHeight() or 80
local y = -50 - bodyH - 14
local rows = {}
for _, m in ipairs(AF.MACROS) do
if not (m.need == "mana" and not hasMana) then
local name = AF.db[m.slot]
local label = w:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
label:SetPoint("TOPLEFT", 22, y)
label:SetWidth(300); label:SetJustifyH("LEFT")
label:SetText("|cffffd100" .. name .. "|r - " .. (DESC[m.key] or m.short))
local btn = CreateFrame("Button", nil, w, "UIPanelButtonTemplate")
btn:SetSize(96, 22)
btn:SetPoint("TOPRIGHT", -16, y + 4)
btn._name = name
btn._key = m.key
btn:SetScript("OnClick", function(self)
AF:CreateMacroByKey(self._key)
if w.Refresh then w:Refresh() end
end)
rows[#rows + 1] = btn
y = y - 28
end
end
local note = w:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
note:SetPoint("TOPLEFT", 18, y - 4)
note:SetWidth(404); note:SetJustifyH("LEFT")
note:SetText("|cff999999AutoFeed is still in active development - if anything doesn't work as "
.. "intended, please report it on the CurseForge or GitHub page. Thanks for testing!|r")
local noteH = note:GetStringHeight() or 28
local settingsBtn = CreateFrame("Button", nil, w, "UIPanelButtonTemplate")
settingsBtn:SetSize(110, 22)
settingsBtn:SetPoint("BOTTOMLEFT", 16, 14)
settingsBtn:SetText("Open Settings")
settingsBtn:SetScript("OnClick", function()
w:Hide()
if AF.OpenOptions then AF:OpenOptions() end
end)
local allBtn = CreateFrame("Button", nil, w, "UIPanelButtonTemplate")
allBtn:SetSize(90, 22)
allBtn:SetPoint("BOTTOM", 0, 14)
allBtn:SetText("Create all")
allBtn:SetScript("OnClick", function()
if AF.CreateAllMacros then AF:CreateAllMacros() end
if w.Refresh then w:Refresh() end
end)
local okBtn = CreateFrame("Button", nil, w, "UIPanelButtonTemplate")
okBtn:SetSize(90, 22)
okBtn:SetPoint("BOTTOMRIGHT", -16, 14)
okBtn:SetText("Got it")
okBtn:SetScript("OnClick", function() w:Hide() end)
function w:Refresh()
for _, btn in ipairs(rows) do
if MacroExists(btn._name) then
btn:SetText("Created"); btn:Disable()
else
btn:SetText("Create"); btn:Enable()
end
end
end
w:SetHeight(-(y - 4) + noteH + 48)
w:Refresh()
end