forked from Jaliborc/Wildpants
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWildpants.lua
More file actions
164 lines (132 loc) · 3.99 KB
/
Wildpants.lua
File metadata and controls
164 lines (132 loc) · 3.99 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
--[[
Wildpants.lua
Starts the addon and its settings
--]]
local ADDON, Addon = ...
local Addon = LibStub('WildAddon-1.0'):NewAddon(ADDON, Addon, 'LibItemCache-2.0')
Addon.NumBags = NUM_TOTAL_EQUIPPED_BAG_SLOTS or NUM_BAG_SLOTS
Addon.IsRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
Addon.IsClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
Addon.Version = GetAddOnMetadata(ADDON, 'Version')
local L = LibStub('AceLocale-3.0'):GetLocale(ADDON)
local SETS = ADDON .. '_Sets'
local function AsArray(table)
return setmetatable(table, {__metatable = 1})
end
local function SetDefaults(target, defaults)
defaults.__index = nil
for k, v in pairs(defaults) do
if type(v) == 'table' then
if getmetatable(v) == 1 then
target[k] = target[k] or AsArray(CopyTable(v))
else
target[k] = SetDefaults(target[k] or {}, v)
end
end
end
defaults.__index = defaults
return setmetatable(target, defaults)
end
local FrameDefaults = {
enabled = true,
money = true, broker = true,
bagToggle = true, sort = true, search = true, options = true,
strata = 'HIGH', alpha = 1,
scale = Addon.FrameScale or 1,
color = {0, 0, 0, 0.5},
x = 0, y = 0,
itemScale = Addon.ItemScale or 1,
spacing = 2,
brokerObject = Addon.Name .. 'Launcher',
hiddenRules = {contain = true},
hiddenBags = {},
rules = AsArray({
'all', 'all/normal', 'all/trade', 'all/reagent', 'all/keys', 'all/quiver',
'equip', 'equip/armor', 'equip/weapon', 'equip/trinket',
'use', 'use/consume', 'use/enhance',
'trade', 'trade/goods', 'trade/gem', 'trade/glyph', 'trade/recipe',
'quest', 'misc',
}),
}
local ProfileDefaults = {
inventory = SetDefaults({
reversedTabs = true,
borderColor = {1, 1, 1, 1},
currency = true, broker = Addon.IsClassic,
point = 'BOTTOMRIGHT',
x = -50, y = 100,
columns = 10,
width = 384,
height = 200,
}, FrameDefaults),
bank = SetDefaults({
borderColor = {1, 1, 0, 1},
currency = true,
point = 'LEFT',
columns = 14,
width = 600,
height = 500,
x = 95
}, FrameDefaults),
vault = SetDefaults({
borderColor = {1, 0, 0.98, 1},
point = 'LEFT',
columns = 10,
x = 95
}, FrameDefaults),
guild = SetDefaults({
borderColor = {0, 1, 0, 1},
point = 'CENTER',
columns = 7,
}, FrameDefaults)
}
--[[ Startup ]]--
function Addon:OnEnable()
CreateFrame('Frame', nil, InterfaceOptionsFrame or SettingsPanel):SetScript('OnShow', function()
LoadAddOn(Addon.Name .. '_Config')
end)
_G[SETS] = SetDefaults(_G[SETS] or {}, {
version = Addon.Version,
global = SetDefaults({}, ProfileDefaults),
profiles = {},
display = {banker = true, guildBanker = true, voidStorageBanker = true, crafting = true, tradePartner = true, socketing = true, auctioneer = true, merchant = true, mailInfo = true, scrappingMachine = true},
resetPlayer = true, flashFind = true, tipCount = true, serverSort = true,
glowAlpha = 0.5,
glowQuality = true, glowNew = true, glowQuest = true, glowSets = true, glowUnusable = true,
emptySlots = true, colorSlots = true,
normalColor = {1, 1, 1},
keyColor = {1, .9, .19},
quiverColor = {1, .87, .68},
soulColor = {0.64, 0.39, 1},
reagentColor = {1, .87, .68},
leatherColor = {1, .6, .45},
enchantColor = {0.64, 0.83, 1},
inscribeColor = {.64, 1, .82},
engineerColor = {0.36, 0.68, 0.52},
tackleColor = {0.42, 0.59, 1},
fridgeColor = {1, .5, .5},
gemColor = {1, .65, .98},
mineColor = {0.65, 0.53, 0.25},
herbColor = {.5, 1, .5},
})
self.sets = _G[SETS]
self.sets.version = Addon.Version
for owner, profile in pairs(self.sets.profiles) do
SetDefaults(profile, ProfileDefaults)
end
self.profile = self:GetProfile()
end
--[[ Profiles ]]--
function Addon:SetCurrentProfile(profile)
self.sets.profiles[self:GetOwnerID()] = profile and SetDefaults(profile, ProfileDefaults)
self.profile = self:GetProfile()
end
function Addon:GetProfile(owner)
return self.sets.profiles[self:GetOwnerID(owner)] or self.sets.global
end
--[[ Options ]]--
function Addon:ShowOptions()
if LoadAddOn(ADDON .. '_Config') then
Addon.GeneralOptions:Open()
end
end