-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
99 lines (87 loc) · 4.16 KB
/
Options.lua
File metadata and controls
99 lines (87 loc) · 4.16 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
if (select(2, UnitClass("player"))) ~= "ROGUE" then return end
local addOnName = ...
-- main frame
frame = CreateFrame("Frame","HemlockOptions")
frame.name = addOnName
InterfaceOptions_AddCategory(frame)
frame:Hide()
frame:SetScript("OnShow", function(frame)
local options = {}
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText(addOnName)
local description = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
description:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
description:SetText("Minimalistic addon to automate poison buying and creation")
local function newCheckbox(name, label, description, onClick)
local check = CreateFrame("CheckButton", "HemlockCheckBox" .. name, frame, "InterfaceOptionsCheckButtonTemplate")
check:SetScript("OnClick", function(self)
local tick = self:GetChecked()
onClick(self, tick and true or false)
if tick then
PlaySound(856)
else
PlaySound(857)
end
end)
check.label = _G[check:GetName() .. "Text"]
check.label:SetText(label)
check.tooltipText = label
check.tooltipRequirement = description
return check
end
smartPoisonCount = newCheckbox(
"SmartPoisonCount",
Hemlock:L("option_smartPoisonCount"),
Hemlock:L("option_smartPoisonCount_desc"),
function(self, value) Hemlock.db.profile.options.smartPoisonCount = value; Hemlock:InitFrames() end)
smartPoisonCount:SetChecked(Hemlock.db.profile.options.smartPoisonCount)
smartPoisonCount:SetPoint("TOPLEFT", description, "BOTTOMLEFT", -2, -16)
chatMessages = newCheckbox(
"ChatMessages",
Hemlock:L("option_chatMessages"),
Hemlock:L("option_chatMessages_desc"),
function(self, value) Hemlock.db.profile.options.chatMessages = value end)
chatMessages:SetChecked(Hemlock.db.profile.options.chatMessages)
chatMessages:SetPoint("TOPLEFT", smartPoisonCount, "BOTTOMLEFT", 0, -8)
alternativeWoundPoisonIcon = newCheckbox(
"AlternativeWoundPoisonIcon",
Hemlock:L("option_alternativeWoundPoisonIcon"),
Hemlock:L("option_alternativeWoundPoisonIcon_desc"),
function(self, value) Hemlock.db.profile.options.alternativeWoundPoisonIcon = value; Hemlock:InitFrames() end)
alternativeWoundPoisonIcon:SetChecked(Hemlock.db.profile.options.alternativeWoundPoisonIcon)
alternativeWoundPoisonIcon:SetPoint("TOPLEFT", chatMessages, "BOTTOMLEFT", 0, -8)
alternativeCripplingPoisonIcon = newCheckbox(
"AlternativeCripplingPoisonIcon",
Hemlock:L("option_alternativeCripplingPoisonIcon"),
Hemlock:L("option_alternativeCripplingPoisonIcon_desc"),
function(self, value) Hemlock.db.profile.options.alternativeCripplingPoisonIcon = value; Hemlock:InitFrames() end)
alternativeCripplingPoisonIcon:SetChecked(Hemlock.db.profile.options.alternativeCripplingPoisonIcon)
alternativeCripplingPoisonIcon:SetPoint("TOPLEFT", alternativeWoundPoisonIcon, "BOTTOMLEFT", 0, -8)
buyConfirmation = newCheckbox(
"BuyConfirmation",
Hemlock:L("option_buyConfirmation"),
Hemlock:L("option_buyConfirmation_desc"),
function(self, value) Hemlock.db.profile.options.buyConfirmation = value; Hemlock:InitFrames() end)
buyConfirmation:SetChecked(Hemlock.db.profile.options.buyConfirmation)
buyConfirmation:SetPoint("TOPLEFT", alternativeCripplingPoisonIcon, "BOTTOMLEFT", 0, -8)
ignoreLowerRankPoisons = newCheckbox(
"IgnoreLowerRankPoisons",
Hemlock:L("option_ignoreLowerRankPoisons"),
Hemlock:L("option_ignoreLowerRankPoisons_desc"),
function(self, value) Hemlock.db.profile.options.ignoreLowerRankPoisons = value; Hemlock:InitFrames() end)
ignoreLowerRankPoisons:SetChecked(Hemlock.db.profile.options.ignoreLowerRankPoisons)
ignoreLowerRankPoisons:SetPoint("TOPLEFT", buyConfirmation, "BOTTOMLEFT", 0, -8)
local reset = CreateFrame("Button", "HemlockResetButton", frame, "UIPanelButtonTemplate")
reset:SetText(Hemlock:L("option_reset_button"))
reset:SetWidth(177)
reset:SetHeight(24)
reset:SetPoint("TOPLEFT", ignoreLowerRankPoisons, "BOTTOMLEFT", 17, -15)
reset:SetScript("OnClick", function()
Hemlock:Reset();
PlaySound(856);
end)
reset.tooltipText = Hemlock:L("option_reset_tooltip_title")
reset.newbieText = Hemlock:L("option_reset_tooltip_desc")
frame:SetScript("OnShow", nil)
end)