-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathOptions.lua
More file actions
317 lines (294 loc) · 11.4 KB
/
Options.lua
File metadata and controls
317 lines (294 loc) · 11.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
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
--------------
-- 配置面板 --
--------------
local LibEvent = LibStub:GetLibrary("LibEvent.7000")
local VERSION = 2.7
local addon, ns = ...
ns.IsMidnight = select(4, GetBuildInfo()) >= 120001
local L = ns.L or {}
setmetatable(L, { __index = function(_, k)
return k:gsub("([a-z])([A-Z])", "%1 %2")
end})
local DefaultDB = {
version = VERSION, --配置的版本號
ShowItemBorder = false, --物品直角邊框 #暂停用#
EnableItemLevel = true, --物品等級
ShowColoredItemLevelString = false, --裝等文字隨物品品質
ShowCorruptedMark = false, --腐蚀装备标记
ShowItemSlotString = true, --物品部位文字
EnableItemLevelBag = true,
EnableItemLevelBank = true,
EnableItemLevelMerchant = true,
EnableItemLevelTrade = true,
EnableItemLevelGuildBank = true,
EnableItemLevelAuction = true,
EnableItemLevelAltEquipment = true,
EnableItemLevelPaperDoll = true,
EnableItemLevelGuildNews = true,
EnableItemLevelChat = false,
EnableItemLevelLoot = true,
EnableItemLevelOther = true,
ShowInspectAngularBorder = false, --觀察面板直角邊框
ShowInspectColoredLabel = true, --觀察面板高亮橙裝武器標簽
TierSetTable = {},
seasonID = 0,
ShowCharacterItemSheet = true, --顯示玩家自己裝備列表
ShowInspectItemSheet = true, --顯示观察对象装备列表 --20190318Added
ShowOwnFrameWhenInspecting = false, --觀察同時顯示自己裝備列表
ShowItemStats = false, --顯示裝備屬性統計
EnablePartyItemLevel = true, --小隊裝等
SendPartyItemLevelToSelf = true, --發送小隊裝等到自己面板
SendPartyItemLevelToParty = false, --發送小隊裝等到隊伍頻道
ShowPartySpecialization = true, --顯示隊友天賦
EnableRaidItemLevel = false, --團隊裝等
EnableMouseItemLevel = true, --鼠標裝等
EnableMouseSpecialization = false, --鼠標天賦
EnableMouseWeaponLevel = false, --鼠標武器等級
EnableMouseTierSet = true, --鼠標套裝數量
PaperDollItemLevelOutsideString = false, --PaperDoll文字外邊顯示(沒有在配置面板)
ItemLevelAnchorPoint = "TOP", --裝等位置
ShowPluginGreenState = false, --裝備綠字屬性前綴顯示
ShowGemAndEnchant = true, --显示宝石和附魔
}
local options = {
--{ key = "ShowItemBorder" },
{ key = "ShowGemAndEnchant" },
{ key = "EnableItemLevel",
child = {
{ key = "ShowColoredItemLevelString" },
{ key = "ShowCorruptedMark" },
{ key = "ShowItemSlotString" },
},
subtype = {
xpos = 490, ypos = -50,
{ key = "Other" },
{ key = "Bag" },
{ key = "Bank" },
{ key = "AltEquipment" },
{ key = "GuildNews" },
{ key = "Chat" },
-- { key = "GuildBank" },
{ key = "Merchant" },
-- { key = "Trade" },
{ key = "PaperDoll" },
-- { key = "Loot" },
},
anchorkey = "ItemLevelAnchorPoint",
},
{ key = "ShowInspectAngularBorder" },
{ key = "ShowInspectColoredLabel" },
{ key = "ShowCharacterItemSheet" },
{ key = "ShowInspectItemSheet",
child = {
{ key = "ShowOwnFrameWhenInspecting" },
{ key = "ShowItemStats" },
}
},
{ key = "EnablePartyItemLevel",
child = {
{ key = "ShowPartySpecialization" },
{ key = "SendPartyItemLevelToSelf" },
{ key = "SendPartyItemLevelToParty" },
}
},
{ key = "EnableRaidItemLevel",
checkedFunc = function() TinyInspectRaidFrame:Show() end,
uncheckedFunc = function() TinyInspectRaidFrame:Hide() end,
},
{ key = "EnableMouseItemLevel",
child = {
{ key = "EnableMouseSpecialization" },
{ key = "EnableMouseWeaponLevel" },
{ key = "EnableMouseTierSet" },
}
},
}
if (GetLocale():sub(1,2) == "zh") then
tinsert(options, { key = "ShowPluginGreenState" })
end
TinyInspectDB = {}
local function CallCustomFunc(self)
local checked = self:GetChecked()
if (checked and self.checkedFunc) then
self.checkedFunc(self)
end
if (not checked and self.uncheckedFunc) then
self.uncheckedFunc(self)
end
end
local function StatusSubCheckbox(self, status)
local checkbox
for i = 1, self:GetNumChildren() do
checkbox = select(i, self:GetChildren())
if (checkbox.key) then
checkbox:SetEnabled(status)
StatusSubCheckbox(checkbox, status)
end
end
if (status and self.SubtypeFrame) then
self.SubtypeFrame:Show()
elseif (not status and self.SubtypeFrame) then
self.SubtypeFrame:Hide()
end
end
local function OnClickCheckbox(self)
local status = self:GetChecked()
TinyInspectDB[self.key] = status
StatusSubCheckbox(self, status)
CallCustomFunc(self)
end
local function CreateSubtypeFrame(list, parent, xpos, ypos)
if (not list) then return end
if (not parent.SubtypeFrame) then
parent.SubtypeFrame = CreateFrame("Frame", nil, parent, BackdropTemplateMixin and "BackdropTemplate" or nil)
parent.SubtypeFrame:SetScale(0.92)
parent.SubtypeFrame:SetPoint("TOPLEFT", parent, "TOPLEFT", xpos or 300, ypos or 20)
parent.SubtypeFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
tileSize = 8,
edgeSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4}
})
parent.SubtypeFrame:SetBackdropColor(0, 0, 0, 0.6)
parent.SubtypeFrame:SetBackdropBorderColor(0.6, 0.6, 0.6)
parent.SubtypeFrame.title = parent.SubtypeFrame:CreateFontString(nil, "BORDER", "GameFontNormalOutline")
parent.SubtypeFrame.title:SetPoint("TOPLEFT", 16, -18)
parent.SubtypeFrame.title:SetText(L[parent.key])
end
local checkbox
for i, v in ipairs(list) do
checkbox = CreateFrame("CheckButton", nil, parent.SubtypeFrame, "InterfaceOptionsCheckButtonTemplate")
checkbox.key = parent.key .. v.key
checkbox.checkedFunc = v.checkedFunc
checkbox.uncheckedFunc = v.uncheckedFunc
checkbox.Text:SetText(L[v.key])
checkbox:SetScript("OnClick", OnClickCheckbox)
checkbox:SetPoint("TOPLEFT", parent.SubtypeFrame, "TOPLEFT", 16, -46-(i-1)*30)
end
parent.SubtypeFrame:SetSize(168, #list*30+58)
end
local function CreateAnchorFrame(anchorkey, parent)
if (not anchorkey) then return end
local CreateAnchorButton = function(frame, anchorPoint)
local button = CreateFrame("Button", nil, frame)
button.anchorPoint = anchorPoint
button:SetSize(12, 12)
button:SetPoint(anchorPoint)
button:SetNormalTexture("Interface\\Buttons\\WHITE8X8")
if (TinyInspectDB[frame.anchorkey] == anchorPoint) then
button:GetNormalTexture():SetVertexColor(1, 0.2, 0.1)
end
button:SetScript("OnClick", function(self)
local parent = self:GetParent()
local anchorPoint = self.anchorPoint
local anchorOrig = TinyInspectDB[parent.anchorkey]
if (parent[anchorOrig]) then
parent[anchorOrig]:GetNormalTexture():SetVertexColor(1, 1, 1)
end
self:GetNormalTexture():SetVertexColor(1, 0.2, 0.1)
TinyInspectDB[parent.anchorkey] = anchorPoint
end)
frame[anchorPoint] = button
end
local frame = CreateFrame("Frame", nil, parent.SubtypeFrame or parent, BackdropTemplateMixin and "BackdropTemplate")
frame.anchorkey = anchorkey
frame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Buttons\\WHITE8X8",
edgeSize = 2,
})
frame:SetBackdropColor(0, 0, 0, 0.7)
frame:SetBackdropBorderColor(1, 1, 1, 1)
frame:SetSize(80, 80)
frame:SetPoint("TOPLEFT", parent, "TOPLEFT", 530, 44)
CreateAnchorButton(frame, "TOPLEFT")
CreateAnchorButton(frame, "LEFT")
CreateAnchorButton(frame, "BOTTOMLEFT")
CreateAnchorButton(frame, "TOP")
CreateAnchorButton(frame, "BOTTOM")
CreateAnchorButton(frame, "TOPRIGHT")
CreateAnchorButton(frame, "RIGHT")
CreateAnchorButton(frame, "BOTTOMRIGHT")
CreateAnchorButton(frame, "CENTER")
end
local function CreateCheckbox(list, parent, anchor, offsetx, offsety)
local checkbox, subbox
local stepx, stepy = 20, 25
if (not list) then return offsety end
for i, v in ipairs(list) do
checkbox = CreateFrame("CheckButton", nil, parent, "InterfaceOptionsCheckButtonTemplate")
checkbox.key = v.key
checkbox.checkedFunc = v.checkedFunc
checkbox.uncheckedFunc = v.uncheckedFunc
checkbox.Text:SetText(L[v.key])
checkbox:SetScript("OnClick", OnClickCheckbox)
checkbox:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", offsetx, -6-offsety)
offsety = offsety + stepy
offsety = CreateCheckbox(v.child, checkbox, anchor, offsetx+stepx, offsety)
CreateSubtypeFrame(v.subtype, checkbox, v.subtype and v.subtype.xpos, v.subtype and v.subtype.ypos)
CreateAnchorFrame(v.anchorkey, checkbox)
end
return offsety
end
local function InitCheckbox(parent)
local checkbox
for i = 1, parent:GetNumChildren() do
checkbox = select(i, parent:GetChildren())
if (checkbox.key) then
checkbox:SetChecked(TinyInspectDB[checkbox.key])
StatusSubCheckbox(checkbox, checkbox:GetChecked())
CallCustomFunc(checkbox)
InitCheckbox(checkbox)
end
end
if (parent.SubtypeFrame) then
InitCheckbox(parent.SubtypeFrame)
end
end
local function InitSettings(source, target, fullClean)
for i, j in pairs(source) do
if type(j) == "table" then
if target[i] == nil or type(target[i]) ~= "table" then target[i] = {} end
for k, v in pairs(j) do
if target[i][k] == nil then
target[i][k] = v
end
end
else
if target[i] == nil then target[i] = j end
end
end
for i, j in pairs(target) do
if source[i] == nil then target[i] = nil end
if fullClean and type(j) == "table" then
for k, v in pairs(j) do
if type(v) ~= "table" and source[i] and source[i][k] == nil then
target[i][k] = nil
end
end
end
end
end
local frame = CreateFrame("Frame")
frame.title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
frame.title:SetPoint("TOPLEFT", 18, -16)
frame.title:SetText(addon)
CreateCheckbox(options, frame, frame.title, 18, 9)
local category = Settings.RegisterCanvasLayoutCategory(frame, addon)
Settings.RegisterAddOnCategory(category)
LibEvent:attachEvent("ADDON_LOADED", function(self, addonName)
if (addonName == addon) then
InitSettings(DefaultDB, TinyInspectDB, true)
InitCheckbox(frame)
end
end)
SLASH_TinyInspect1 = "/tinyinspect"
SLASH_TinyInspect2 = "/ti"
function SlashCmdList.TinyInspect(msg, editbox)
if (msg == "raid") then
return ToggleFrame(TinyInspectRaidFrame)
end
Settings.OpenToCategory(category.ID)
end