-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.lua
215 lines (167 loc) · 6.36 KB
/
config.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
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
local _NAME, _NS = ...
local Butsu = _G[_NAME]
local LoadSettings
do
LoadSettings = function(self)
-- We only need this once.
self:SetScript('OnShow', nil)
if(_NS.db) then return _NS.db end
local db = ButsuDB or {}
_NS.db = setmetatable(db,
{
__index = {
iconSize = 22;
-- Attempt to set sane defaults.
fontSizeTitle = math.floor(select(2, GameTooltipHeaderText:GetFont()) + .5);
fontSizeItem = math.floor(select(2, GameFontWhite:GetFont()) + .5);
fontSizeCount = math.floor(select(2, NumberFontNormalSmall:GetFont()) + .5);
frameScale = 1;
framePosition = 'TOPLEFT\031UIParent\0310\031-104';
}
})
if(not ButsuDB) then
ButsuDB = db
end
self.title:SetFont(GameTooltipHeaderText:GetFont(), _NS.db.fontSizeTitle, 'OUTLINE')
self:SetScale(_NS.db.frameScale)
self:LoadPosition()
end
-- Used to setup our DB and such.
Butsu:SetScript('OnShow', LoadSettings)
end
local OPTION_CATEGORY
do
local opt = CreateFrame("Frame")
opt:Hide()
opt.name = _NAME
opt:SetScript("OnShow", function(self)
LoadSettings(Butsu)
local db = _NS.db
local createFontString = function(parent, text, template, ...)
local label = parent:CreateFontString(nil, nil, template or 'GameFontHighlight')
label:SetPoint(...)
label:SetText(text)
return label
end
local createSlider
do
local sliderBackdrop = {
bgFile = [[Interface\Buttons\UI-SliderBar-Background]], tile = true, tileSize = 8,
edgeFile = [[Interface\Buttons\UI-SliderBar-Border]], edgeSize = 8,
insets = {left = 3, right = 3, top = 6, bottom = 6},
}
createSlider = function(parent, name, min, max, cur, ...)
local slider = CreateFrame('Slider', nil, parent, 'BackdropTemplate')
slider:SetOrientation'HORIZONTAL'
slider:SetPoint(...)
slider:SetSize(144, 17)
slider:SetHitRectInsets(0, 0, -10, -10)
slider:SetBackdrop(sliderBackdrop)
slider:SetThumbTexture[[Interface\Buttons\UI-SliderBar-Button-Horizontal]]
slider:SetMinMaxValues(min, max)
slider:SetValue(cur)
slider.label = createFontString(parent, name, 'GameFontHighlightCenter', 'BOTTOM', slider, 'TOP')
slider.min = createFontString(parent, min, 'GameFontHighlightSmall', 'TOPLEFT', slider, 'BOTTOMLEFT', 2, 2)
slider.max = createFontString(parent, max, 'GameFontHighlightSmall', 'TOPRIGHT', slider, 'BOTTOMRIGHT', -2, 2)
slider.current = createFontString(parent, cur, 'GameFontHighlightSmall', 'TOP', slider, 'BOTTOM')
return slider
end
end
local boxBackdrop = {
bgFile = [[Interface\ChatFrame\ChatFrameBackground]], tile = true, tileSize = 16,
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4},
}
local title = createFontString(self, _NAME, 'GameFontNormalLarge', 'TOPLEFT', 16, -16)
title:SetPoint('TOPRIGHT', -16, -16)
title:SetJustifyH'LEFT'
local fontBox = CreateFrame('Frame', nil, self, 'BackdropTemplate')
fontBox:SetBackdrop(boxBackdrop)
fontBox:SetBackdropBorderColor(.3, .3, .3)
fontBox:SetBackdropColor(.1, .1, .1, .5)
fontBox:SetHeight(64)
fontBox:SetPoint('LEFT', 12, 0)
fontBox:SetPoint('RIGHT', -12, 0)
fontBox:SetPoint('TOP', title, 'BOTTOM', 0, -32)
local L = _NS.L
local fontBoxTitle = createFontString(fontBox, L.uiFontSizeTitle, nil, 'BOTTOMLEFT', fontBox, 'TOPLEFT', 6, 0)
local fontSizeTitle = createSlider(fontBox, L.uiTitleSize, 7, 40, db.fontSizeTitle, 'LEFT', fontBox, 12, 0)
fontSizeTitle:SetScript('OnValueChanged', function(self, value)
value = math.floor(value + .5)
db.fontSizeTitle = value
self.current:SetText(value)
local font, size, outline = Butsu.title:GetFont()
Butsu.title:SetFont(font, value, outline)
end)
local fontSizeItem = createSlider(fontBox, L.uiItemSize, 7, 40, db.fontSizeItem, 'CENTER')
fontSizeItem:SetScript('OnValueChanged', function(self, value)
value = math.floor(value + .5)
db.fontSizeItem = value
self.current:SetText(value)
for _, slot in next, _NS.slots do
local font, size, outline = slot.name:GetFont()
slot.name:SetFont(font, value, outline)
end
Butsu:UpdateWidth()
Butsu:AnchorSlots()
end)
local fontSizeCount = createSlider(fontBox, L.uiCountSize, 7, 40, db.fontSizeCount, 'RIGHT', -12, 0)
fontSizeCount:SetScript('OnValueChanged', function(self, value)
value = math.floor(value + .5)
db.fontSizeCount = value
self.current:SetText(value)
for _, slot in next, _NS.slots do
local font, size, outline = slot.count:GetFont()
slot.count:SetFont(font, value, outline)
end
end)
local settBox = CreateFrame('Frame', nil, self, 'BackdropTemplate')
settBox:SetBackdrop(boxBackdrop)
settBox:SetBackdropBorderColor(.3, .3, .3)
settBox:SetBackdropColor(.1, .1, .1, .5)
settBox:SetHeight(64)
settBox:SetPoint('LEFT', 12, 0)
settBox:SetPoint('RIGHT', -12, 0)
settBox:SetPoint('TOP', fontBox, 'BOTTOM', 0, -32)
local settBoxTitle = createFontString(settBox, L.uiScaleSizeTitle, nil, 'BOTTOMLEFT', settBox, 'TOPLEFT', 6, 0)
local iconSize = createSlider(settBox, L.uiIconSize, 14, 80, db.iconSize, 'LEFT', 12, 0)
iconSize:SetScript('OnValueChanged', function(self, value)
value = math.floor(value + .5)
db.iconSize = value
self.current:SetText(value)
for _, slot in next, _NS.slots do
slot:SetHeight(value)
slot.iconFrame:SetSize(value, value)
slot.quest:SetSize(value * .8, value * .8)
slot.quest:ClearAllPoints()
slot.quest:SetPoint('BOTTOMLEFT', -value * .15, 0)
end
Butsu:UpdateWidth()
Butsu:AnchorSlots()
end)
local frameScale = createSlider(settBox, L.uiFrameScale, .4, 3, db.frameScale, 'CENTER')
frameScale:SetValueStep(.05)
frameScale:SetScript('OnValueChanged', function(self, value)
value = math.floor(value * 10^2 + .5) / 10^2
db.frameScale = value
self.current:SetFormattedText('%.02f', value)
Butsu:SetScale(value)
end)
local UpdateSettings = function(self)
fontSizeTitle:SetValue(db.fontSizeTitle)
fontSizeItem:SetValue(db.fontSizeItem)
fontSizeCount:SetValue(db.fontSizeCount)
iconSize:SetValue(db.iconSize)
frameScale:SetValue(db.frameScale)
end
self:SetScript('OnShow', UpdateSettings)
end)
OPTION_CATEGORY = Settings.RegisterCanvasLayoutCategory(opt, _TITLE)
Settings.RegisterAddOnCategory(OPTION_CATEGORY)
end
do
SLASH_BUTSU1 = '/butsu'
SlashCmdList['BUTSU'] = function(inp)
Settings.OpenToCategory(OPTION_CATEGORY:GetID())
end
end