-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
264 lines (214 loc) · 8.95 KB
/
Copy pathOptions.lua
File metadata and controls
264 lines (214 loc) · 8.95 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
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
local addonName, addon = ...
local defaultsDB = {
CoinFormat = FT.ICON, --< Icon, Short, Long
NoDisplay = false,
NoSound = false,
Displacement = -1,
}
local category, layout = Settings.RegisterVerticalLayoutCategory(addonName)
-- Add Display On/Off
local function GetOptionDisplay()
return FleecingTipDB.NoDisplay or defaultsDB.NoDisplay
end
local function SetOptionDisplay(value)
FleecingTipDB.NoDisplay = value
end
local setting = Settings.RegisterProxySetting(category, "FleecingTipDB.NoDisplay", Settings.VarType.Boolean, FT.OPTION_DISPLAY_FLEECING_DESC_SHORT, defaultsDB.NoDisplay, GetOptionDisplay, SetOptionDisplay)
Settings.CreateCheckbox(category, setting, FT.OPTION_DISPLAY_FLEECING_DESC)
-- Add Sound On/Off
local function GetOptionSound()
return FleecingTipDB.NoSound or defaultsDB.NoSound
end
local function SetOptionSound(value)
FleecingTipDB.NoSound = value
end
local setting = Settings.RegisterProxySetting(category, "FleecingTipDB.NoSound", Settings.VarType.Boolean, FT.OPTION_SOUND_FLEECING_DESC_SHORT, defaultsDB.NoSound, GetOptionSound, SetOptionSound)
Settings.CreateCheckbox(category, setting, FT.OPTION_SOUND_FLEECING_DESC)
-- Money Format
local moneyRefresh = function() -- also needed else where!
MoneyIconOptions:SetText(FTUtils.GSC(999999));
end
-- Populate the options for the money format dropdown
local function GetMoneyFormatOptions()
local container = Settings.CreateControlTextContainer()
container:Add(FT.ICON, FT.ICON)
container:Add(FT.SHORT, FT.SHORT)
container:Add(FT.LONG, FT.LONG)
return container:GetData()
end
local function GetOptionMoneyFormat()
return FleecingTipDB.CoinFormat or defaultsDB.CoinFormat
end
local function SetOptionMoneyFormat(value)
FleecingTipDB.CoinFormat = value
end
local setting = Settings.RegisterProxySetting(category, "FleecingTipDB.CoinFormat", Settings.VarType.String, FT.OPTION_MONEY_FORMAT_FLEECING_DESC_SHORT, defaultsDB.CoinFormat, GetOptionMoneyFormat, SetOptionMoneyFormat)
Settings.CreateDropdown(category, setting, GetMoneyFormatOptions, FT.OPTION_MONEY_FORMAT_FLEECING_DESC)
--Settings.SetOnValueChangedCallback("FleecingTipDB.CoinFormat", OnSettingChanged)
--[[
-- Money Format Label
local MoneyLabel = self:CreateFontString("$parentMoneyLabelOptions", "ARTWORK", "GameFontNormal");
MoneyLabel:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", -1, -78);
MoneyLabel:SetText("Money Format");
-- Money Icon Display
local MoneyIconOptions = self:CreateFontString("$parentMoneyIconOptions", "ARTWORK", "GameFontNormal");
local moneyRefresh = function() -- also needed else where!
MoneyIconOptions:SetText(FTUtils.GSC(999999));
end;
]]
-- Add FleecingTip to the list of AddOns
Settings.RegisterAddOnCategory(category)
function addon:ShowOptions()
Settings.OpenToCategory(category)
end
--[[
local addon, private = ...
local version = GetAddOnMetadata(addon, "Version");
local classicOnly = select(4, GetBuildInfo()) < 20000;
local Options = CreateFrame("Frame", "FleecingTipUIOptions", InterfaceOptionsFramePanelContainer);
Options.name = addon;
InterfaceOptions_AddCategory(Options);
function private.ShowOptions()
InterfaceOptionsFrame_OpenToCategory(Options);
end;
Options:Hide();
Options:SetScript("OnShow", function(self)
local function makeSlider(name)
local Slider = CreateFrame("Slider", name, self, "OptionsSliderTemplate");
Slider:SetWidth(200);
Slider.low = _G[Slider:GetName().."Low"];
Slider.low:SetPoint("TOPLEFT", Slider, "BOTTOMLEFT", 0, 0);
Slider.low:SetFontObject(GameFontNormalSmall);
Slider.low:Hide();
Slider.high = _G[Slider:GetName().."High"];
Slider.high:SetPoint("TOPRIGHT", Slider, "BOTTOMRIGHT", 0, 0);
Slider.high:SetFontObject(GameFontNormalSmall);
Slider.high:Hide();
Slider.value = Slider:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
Slider.value:SetPoint("LEFT", Slider, "RIGHT", 4, 0);
Slider.text = _G[Slider:GetName().."Text"];
Slider.text:SetFontObject(GameFontNormal);
Slider.text:ClearAllPoints();
Slider.text:SetPoint("BOTTOMLEFT", Slider, "TOPLEFT", -4, 2);
Slider.text:SetPoint("BOTTOMRIGHT", Slider.value, "BOTTOMLEFT", -4, 0);
Slider.text:SetJustifyH("LEFT");
return Slider;
end;
local function makeCheckbox(label, description, onClick)
local check = CreateFrame("CheckButton", "FleecingTipCheckbox_"..label, self, "InterfaceOptionsCheckButtonTemplate");
check:SetScript("OnClick", function(self)
-- 856 = igMainMenuOptionCheckBoxOn
-- 857 = igMainMenuOptionCheckBoxOff
local click = self:GetChecked() and 856 or 857
PlaySound(click)
onClick(self, self:GetChecked() and true or false)
end);
check.label = _G[check:GetName().."Text"];
check.label:SetText(label);
check.tooltipText = label;
check.tooltipRequirement = description;
return check;
end;
-- version
local VersionOptions = self:CreateFontString("$parentTitleOptions", "ARTWORK", "GameFontNormalSmall");
VersionOptions:SetPoint("TOPRIGHT", -16, -17);
VersionOptions:SetJustifyH("RIGHT");
VersionOptions:SetText("|cff999999Version "..version.."|r");
if (classicOnly) then
-- Title
local TitleOptions = self:CreateFontString("$parentTitleOptions", "ARTWORK", "GameFontNormalLarge");
TitleOptions:SetPoint("TOPLEFT", 16, -16);
TitleOptions:SetText("|cff3399ff"..addon.." |cffa330c9(Classic Edition)|r");
-- Display On/Off
local DisplayLock = makeCheckbox(
"Enabled", -- label
"Display FleecingTip on items tooltip.", -- description
function(self, value)
FleecingTipDB.NoDisplay = not value
end); -- onClick
DisplayLock:SetChecked(not FleecingTipDB.NoDisplay);
DisplayLock:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", 0, -12);
-- Sound On/Off
local SoundLock = makeCheckbox(
"Sound On", -- label
"Give Fleecing Tip some sound.", -- description
function(self, value)
FleecingTipDB.NoSound = not value
end); -- onClick
SoundLock:SetChecked(not FleecingTipDB.NoSound);
SoundLock:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", 0, -40);
-- Money Format Label
local MoneyLabel = self:CreateFontString("$parentMoneyLabelOptions", "ARTWORK", "GameFontNormal");
MoneyLabel:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", -1, -78);
MoneyLabel:SetText("Money Format");
-- Money Icon Display
local MoneyIconOptions = self:CreateFontString("$parentMoneyIconOptions", "ARTWORK", "GameFontNormal");
local moneyRefresh = function() -- also needed else where!
MoneyIconOptions:SetText(FTUtils.GSC(999999));
end;
-- Scale Displacement
local ScaleDisplacement = makeSlider("$parentSliderOptions");
ScaleDisplacement:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", 2, -150);
ScaleDisplacement:SetMinMaxValues(-2, 2);
ScaleDisplacement:SetValueStep(1.0);
ScaleDisplacement.low:SetText("-2");
ScaleDisplacement.high:SetText("2");
ScaleDisplacement.text:SetText("Coin Displacement");
-- ScaleDisplacement.tooltipText = "Adjusts coin displacement.";
ScaleDisplacement:SetScript("OnValueChanged", function(self, value)
if (FleecingTipDB.CoinFormat ~= FT.ICON) then
ScaleDisplacement:SetValue(FleecingTipDB.Displacement);
return;
end;
value = floor(value);
self.value:SetText(value);
FleecingTipDB.Displacement = value;
moneyRefresh();
end);
-- Icon Format
local info = {};
local IconFormatDropdown = CreateFrame("Frame", addon.."Dropdown", self, "UIDropDownMenuTemplate");
IconFormatDropdown:SetPoint("TOPLEFT", TitleOptions, "BOTTOMLEFT", -15, -94);
IconFormatDropdown.initialize = function()
wipe(info);
local values = {FT.ICON, FT.SHORT, FT.LONG};
local names = {FT.ICON, FT.SHORT, FT.LONG};
for i, val in next, values do
info.text = names[i];
info.value = val;
info.func = function(self)
FleecingTipDB.CoinFormat = self.value;
FleecingTipDropdownText:SetText(self:GetText());
moneyRefresh();
if (FleecingTipDB.CoinFormat == FT.ICON) then
ScaleDisplacement:SetAlpha(1);
else
ScaleDisplacement:SetAlpha(.25);
end;
end;
info.checked = val == FleecingTipDB.CoinFormat;
UIDropDownMenu_AddButton(info);
end;
end;
FleecingTipDropdownText:SetText(FleecingTipDB.CoinFormat);
MoneyIconOptions:SetPoint("LEFT", IconFormatDropdown, "RIGHT", 118, 2);
moneyRefresh();
function self:refresh()
if (FleecingTipDB.CoinFormat == FT.ICON) then
ScaleDisplacement:SetAlpha(1);
else
ScaleDisplacement:SetAlpha(.25);
end;
ScaleDisplacement:SetValue(FleecingTipDB.Displacement);
end;
self:refresh();
else
-- Title
local TitleOptions = self:CreateFontString("$parentTitleOptions", "ARTWORK", "GameFontNormalLarge");
TitleOptions:SetPoint("TOPLEFT", 16, -16);
TitleOptions:SetText("|cff3399ff"..addon.." |cffff0000(Incompatible Version)|r");
end;
self:SetScript("OnShow", nil);
end);
]]
-- end