-
Notifications
You must be signed in to change notification settings - Fork 4
/
Options.lua
176 lines (143 loc) · 7.37 KB
/
Options.lua
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
local _, Peddler = ...
local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
frame.name = "Peddler"
frame:Hide()
frame:SetScript("OnShow", function(self)
self:CreateOptions()
self:SetScript("OnShow", nil)
end)
local function createCheckBox(parent, anchor, number, property, label, tooltip)
local checkbox = CreateFrame("CheckButton", "PeddlerCheckBox" .. number, parent, "ChatConfigCheckButtonTemplate")
checkbox:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 16, number * -26)
local checkboxLabel = _G[checkbox:GetName() .. "Text"]
checkboxLabel:SetText(label)
checkboxLabel:SetPoint("TOPLEFT", checkbox, "RIGHT", 5, 7)
checkbox.tooltip = tooltip
checkbox:SetChecked(property)
return checkbox
end
local function changeModifierKey(self)
UIDropDownMenu_SetSelectedID(ModifierKeyDropDown, self:GetID())
ModifierKey = self.value
end
local function initModifierKeys(self, level)
local modifierKeys = {"CTRL", "ALT", "SHIFT", "CTRL-SHIFT", "CTRL-ALT", "ALT-SHIFT"}
for index, modifierKey in pairs(modifierKeys) do
local modifierKeyOption = UIDropDownMenu_CreateInfo()
modifierKeyOption.text = modifierKey
modifierKeyOption.value = modifierKey
modifierKeyOption.func = changeModifierKey
UIDropDownMenu_AddButton(modifierKeyOption)
if modifierKey == ModifierKey then
UIDropDownMenu_SetSelectedID(ModifierKeyDropDown, index)
end
end
end
local function changeIconPlacement(self)
UIDropDownMenu_SetSelectedID(IconPlacementDropDown, self:GetID())
IconPlacement = self.value
end
local function initIconPlacement(self, level)
local iconPlacements = {"TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT"}
for index, iconPlacement in pairs(iconPlacements) do
local iconPlacementOption = UIDropDownMenu_CreateInfo()
iconPlacementOption.text = iconPlacement
iconPlacementOption.value = iconPlacement
iconPlacementOption.func = changeIconPlacement
UIDropDownMenu_AddButton(iconPlacementOption)
if iconPlacement == IconPlacement then
UIDropDownMenu_SetSelectedID(IconPlacementDropDown, index)
end
end
end
function frame:CreateOptions()
local title = self:CreateFontString(nil, nil, "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("Peddler v5.0")
local sellLimit = createCheckBox(self, title, 1, SellLimit, "Sell Limit", "Limits the amount of items sold in one go, so you may buy all items back.")
sellLimit:SetScript("PostClick", function(self, button, down)
SellLimit = self:GetChecked()
end)
local silentMode = createCheckBox(self, title, 2, Silent, "Silent Mode", "Silence chat output about prices and sold item information.")
silentMode:SetScript("PostClick", function(self, button, down)
Silent = self:GetChecked()
end)
local silenceSaleSummary = createCheckBox(self, title, 3, SilenceSaleSummary, "Silence Sale Summary", "Silence the sale summary.")
silenceSaleSummary:SetScript("PostClick", function(self, button, down)
SilenceSaleSummary = self:GetChecked()
end)
silenceSaleSummary:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 190, 2 * -26)
local modifierKeyLabel = self:CreateFontString(nil, nil, "GameFontNormal")
modifierKeyLabel:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -90)
modifierKeyLabel:SetText("Modifier Key (used with right-click to mark/unmark items):")
local modifierKey = CreateFrame("Button", "ModifierKeyDropDown", self, "UIDropDownMenuTemplate")
modifierKey:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -107)
UIDropDownMenu_Initialize(ModifierKeyDropDown, initModifierKeys)
UIDropDownMenu_SetWidth(ModifierKeyDropDown, 90);
UIDropDownMenu_SetButtonWidth(ModifierKeyDropDown, 90)
local iconPlacementLabel = self:CreateFontString(nil, nil, "GameFontNormal")
iconPlacementLabel:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -150)
iconPlacementLabel:SetText("Icon Placement (the corner the coins icon should appear in - please reload to apply changes):")
local iconPlacement = CreateFrame("Button", "IconPlacementDropDown", self, "UIDropDownMenuTemplate")
iconPlacement:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -167)
UIDropDownMenu_Initialize(IconPlacementDropDown, initIconPlacement)
UIDropDownMenu_SetWidth(IconPlacementDropDown, 110);
UIDropDownMenu_SetButtonWidth(IconPlacementDropDown, 110);
local autoSellLabel = self:CreateFontString(nil, nil, "GameFontNormal")
autoSellLabel:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -210)
autoSellLabel:SetText("Automatically sell...")
local autoSellSoulboundOnly = createCheckBox(self, title, 8, SoulboundOnly, "Restrict to Soulbound Items", "Only allow Peddler to automatically mark soulbound items for sale (does not restrict grey items, naturally).")
autoSellSoulboundOnly:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 120, -205)
autoSellSoulboundOnly:SetScript("PostClick", function(self, button, down)
SoulboundOnly = self:GetChecked()
Peddler.markWares()
end)
local autoSellGreyItems = createCheckBox(self, title, 9, AutoSellGreyItems, "Poor Items", "Automatically sells all grey/junk items.")
autoSellGreyItems:SetScript("PostClick", function(self, button, down)
AutoSellGreyItems = self:GetChecked()
Peddler.markWares()
end)
local autoSellWhiteItems = createCheckBox(self, title, 10, AutoSellWhiteItems, "Common Items", "Automatically sells all white/common items.")
autoSellWhiteItems:SetScript("PostClick", function(self, button, down)
AutoSellWhiteItems = self:GetChecked()
Peddler.markWares()
end)
local autoSellGreenItems = createCheckBox(self, title, 11, AutoSellGreenItems, "Uncommon Items", "Automatically sells all green/uncommon items.")
autoSellGreenItems:SetScript("PostClick", function(self, button, down)
AutoSellGreenItems = self:GetChecked()
Peddler.markWares()
end)
local autoSellBlueItems = createCheckBox(self, title, 12, AutoSellBlueItems, "Rare Items", "Automatically sells all blue/rare items.")
autoSellBlueItems:SetScript("PostClick", function(self, button, down)
AutoSellBlueItems = self:GetChecked()
Peddler.markWares()
end)
local autoSellPurpleItems = createCheckBox(self, title, 13, AutoSellPurpleItems, "Epic Items", "Automatically sells all purple/epic items.")
autoSellPurpleItems:SetScript("PostClick", function(self, button, down)
AutoSellPurpleItems = self:GetChecked()
Peddler.markWares()
end)
local autoSellUnwantedItems = createCheckBox(self, title, 14, AutoSellUnwantedItems, "Unwanted Items", "Automatically sell all items which are unwanted for your current class (e.g. Priests don't want plate gear, so all plate gear will be marked).")
autoSellUnwantedItems:SetScript("PostClick", function(self, button, down)
AutoSellUnwantedItems = self:GetChecked()
Peddler.markWares()
end)
local clearWaresList = CreateFrame("Button", nil, self, "UIPanelButtonTemplate")
clearWaresList:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 16, -420)
clearWaresList:SetWidth(110)
clearWaresList:SetText("Clear Items List")
clearWaresList:SetScript("PostClick", function(self, button, down)
ItemsToSell = {}
Peddler.markWares()
end)
local clearWaresLabel = self:CreateFontString(nil, nil, "GameFontHighlightSmall")
clearWaresLabel:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 19, -450)
clearWaresLabel:SetText("Clears the list of items you've manually marked for sale, for this character.")
if self.refresh ~=nil then self:refresh() end
end
InterfaceOptions_AddCategory(frame)
-- Handling Peddler's options.
SLASH_PEDDLER_COMMAND1 = '/peddler'
SlashCmdList['PEDDLER_COMMAND'] = function(command)
InterfaceOptionsFrame_OpenToCategory('Peddler')
end