forked from MilleXIV/XIV_Databar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.lua
317 lines (258 loc) · 9.34 KB
/
settings.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
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
-----------------------------------------------------------------
-- CONFIGURATION FILE DO NOT TOUCH ANYTHING BELLOW HERE
-----------------------------------------------------------------
local addon, ns = ...
local cfg = {}
ns.cfg = cfg
cfg.NAME = UnitName("player")
cfg.CLASS = select(2, UnitClass("player"))
cfg.cc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[cfg.CLASS] --CLASS COLOR
--media path
cfg.mediaFolder = "Interface\\AddOns\\"..addon.."\\media\\"
---------------------------------------------
-- DO NOT TOUCH ANYTHING ABOVE HERE
---------------------------------------------
cfg.color = {
normal = {1,1,1,.75}, -- SETS THE SAME COLOR FOR THE TEXT
inactive = {1,1,1,.25}, -- SET THE COLOR FOR THE INACTICE ICONS
hover = {cfg.cc.r,cfg.cc.g,cfg.cc.b,.75}, -- DOES NOT CHANGE THE TEXTCOLOR
barcolor = {.094,.094,.094,.75}, -- THE COLOR OF THE BAR
--barcolor = {.05,.05,.05,0}, -- THE COLOR OF THE BAR
}
if cfg.CLASS == "PRIEST" then cfg.color.hover = {.5,.5,0,.75} end -- ADDED BEACUSE NORMALY THE PRIEST COLOR IS THE SAME AS THE NORMAL COLOR
cfg.text = {
font = cfg.mediaFolder.."homizio_bold.ttf", -- SETS THE FONT
normalFontSize = 12, -- SET THE SIZE OF THE TEXTS
smallFontSize = 11, -- SETS THE SIZE OF THE SMALLER TEXTS
}
cfg.core = {
height = 35,
position = "BOTTOM", -- THE POSITION OF THE BAR USE "BOTTOM" OR "TOP"
scale = 0.83, -- SCALE BAR TO GET ROOM FOR ALL THE ICONS AND TEXT
strata = "HIGH", -- AT WHAT STRATA THE BAR SHOULD BE AT
}
cfg.micromenu = {
show = true, -- USES THIS MODULE
showTooltip = true, -- ADDS TOOLTIPS FOR THE SOSIAL FRAMES
}
cfg.armor = {
show = true, -- USES THIS MODULE
minArmor = 20, -- WHEN THE ANVIL GOES FROM INACTIVE TO ACTIVE
maxArmor = 75, -- AT WHAT % IT WILL SHOW ARMORTEXT INSTEAD OF ILVL
}
cfg.talent = {
show = true, -- USES THIS MODULE
}
cfg.clock = {
show = true, -- USES THIS MODULE
showTooltip = true, -- SHOWS SOME INFO AND REALMTIME OR LOCAL TIME
}
cfg.tradeSkill = {
show = true, -- USES THIS MODULE
showTooltip = true, -- SHOW WHAT TRADESKILLS THAT ARE ON COOLDOWN
}
cfg.currency = {
show = true, -- USES THIS MODULE
showXPbar = true, -- SHOW A XP-BAR ON YOUR CHARACTERS THAT HAS NOT REACHED MAX LVL
showTooltip = true, -- SHOWS YOUR RECOURCES ACCORING TO THE DESCRIPTION OR YOUR XP INFO
textOnRight = true,
}
cfg.system = {
show = true, -- USES THIS MODULE
showTooltip = true, -- SHOWS A LIST OF ADDONS AND HOW MUCH SYSTEM THEY USE
addonList = 10, -- SHOW HOW MANY ADDONS TO SHOW ON HOVER
addonListShift = 25, -- SHOW HOW MANY ADDONS TO SHOW ON HOVER WHILE SHIFT IS DOWN
showWorldPing = true,
}
cfg.gold = {
showTooltip = true, -- SHOWS THE GOLD OF YOUR OTHER CHARACTERS ON THE SAME SERVER AND SAME SIDE
show = true, -- USES THIS MODULE
firstWeekday = 2, -- 1 is Sunday, 2 is Monday, different countries have different first day of the week
showFreeBagSpace = false,
}
cfg.heartstone = {
show = true, -- USES THIS MODULE
showTooltip = true, -- SHOWS THE COOLDOWN ON MOUSEOVER
}
cfg.useConfig = false -- !! DO NOT TOUCH !!
---------------------------------------------
-- DO NOT TOUCH ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING !!
---------------------------------------------
-- CREATE THE CORE FRAME
---------------------------------------------
local unpack = unpack
local SX_bottombar = CreateFrame("Frame","SX_bottombar", UIParent)
SX_bottombar:SetSize(0, cfg.core.height)
SX_bottombar:SetScale(cfg.core.scale)
SX_bottombar:SetFrameStrata(cfg.core.strata)
SX_bottombar:SetPoint(cfg.core.position)
SX_bottombar:SetPoint("LEFT")
SX_bottombar:SetPoint("RIGHT")
cfg.SXframe = SX_bottombar
local coreTexture = SX_bottombar:CreateTexture(nil,"BACKGROUND",nil,-8)
coreTexture:SetAllPoints()
coreTexture:SetColorTexture(unpack(cfg.color.barcolor))
cfg.tooltipPos = "ANCHOR_TOP"
if cfg.core.position ~= "BOTTOM" then
cfg.tooltipPos = "ANCHOR_BOTTOM",0,-20
end
local SX_databarConfig = CreateFrame("Frame",nil, UIParent)
SX_databarConfig:SetPoint("CENTER")
--SX_databarConfig:Hide()
cfg.SXconfigFrame = nil
if cfg.useConfig then
cfg.SXconfigFrame = SX_databarConfig
end
local eventframe = CreateFrame("Frame",nil, UIParent)
eventframe:RegisterEvent("PET_BATTLE_OPENING_START")
eventframe:RegisterEvent("PET_BATTLE_CLOSE")
eventframe:SetScript("OnEvent", function(self,event, ...)
if (event == "PET_BATTLE_OPENING_START") then
SX_bottombar:Hide()
elseif (event == "PET_BATTLE_CLOSE") then
SX_bottombar:Show()
end
end)
---------------------------------------------
-- SAVED VARIABLES TABLE
---------------------------------------------
-- copies missing fields from source table
function CopyTable(src, dest)
if type(dest) ~= "table" then
dest = {}
end
for k, v in pairs(src) do
if type(v) == "table" then
dest[k] = CopyTable(v, dest[k])
elseif type(v) ~= type(dest[k]) then
dest[k] = v
end
end
return dest
end
-- removes everything that is present in source table from another table
function DiffTable(src, dest)
if type(dest) ~= "table" then
return {}
end
if type(src) ~= "table" then
return dest
end
for k, v in pairs(dest) do
if type(v) == "table" then
if not next(DiffTable(src[k], v)) then
dest[k] = nil
end
elseif v == src[k] then
dest[k] = nil
end
end
return dest
end
local function ConvertDateToNumber(month, day, year)
month = gsub(month, "(%d)(%d?)", function(d1, d2) return d2 == "" and "0"..d1 or d1..d2 end) -- converts M to MM
day = gsub(day, "(%d)(%d?)", function(d1, d2) return d2 == "" and "0"..d1 or d1..d2 end) -- converts D to DD
return tonumber(year..month..day)
end
--------------
-- DEFAULTS --
--------------
local D = {
["money_related_stuff"] = {}
}
-----------
-- STUFF --
-----------
local function Controller_OnEvent(self, event, arg)
if event == "ADDON_LOADED" and arg == addon then -- "test" is addon name
local CONFIG = CopyTable(D, TEST_CONFIG)
ns.CONFIG = CONFIG -- makes this table available throughout addon
local playerName, playerFaction, playerRealm = UnitName("player"), UnitFactionGroup("player"), GetRealmName()
if not CONFIG["money_related_stuff"][playerRealm] then
CONFIG["money_related_stuff"][playerRealm] = {} -- creates a table if it doesn't exist
end
local realmData = CONFIG["money_related_stuff"][playerRealm] -- just an alias
ns.realmData = realmData
if not realmData[playerFaction] then
realmData[playerFaction] = {} -- creates a table if it doesn't exist
end
local factionData = realmData[playerFaction]
ns.factionData = factionData
if not factionData[playerName] then
factionData[playerName] = {} -- creates a table if it doesn't exist
end
ns.playerData = factionData[playerName]
self:UnregisterEvent("ADDON_LOADED")
elseif event == "PLAYER_LOGIN" then
local playerData = ns.playerData
if not playerData["CLASS"] then
playerData["CLASS"] = cfg.CLASS
end
local weekday, month, day, year = CalendarGetDate()
local today = ConvertDateToNumber(month, day, year)
local updateData
if playerData.lastLoginDate then
if playerData.lastLoginDate < today then -- is true, if last time player logged in was the day before or even earlier
playerData.lastLoginDate = today
updateData = true
end
else
playerData.lastLoginDate = today
updateData = true
end
if updateData then -- daily updates
if playerData["money_on_first_weekday"] then
if weekday == cfg.gold.firstWeekday then -- 1 is Sunday, 2 is Monday, different countries have different first day of the week
playerData["money_on_first_weekday"] = GetMoney()
end
else
playerData["money_on_first_weekday"] = GetMoney()
end
playerData["money_on_first_login_today"] = GetMoney()
end
playerData["money_on_session_start"] = GetMoney() -- this one resets on every single login or UI reload
self:UnregisterEvent("PLAYER_LOGIN")
elseif event == "PLAYER_LOGOUT" then
TEST_CONFIG = DiffTable(D, ns.CONFIG) -- writes data into TEST_CONFIG table
end
end
local Controller = CreateFrame("Frame")
Controller:RegisterEvent("ADDON_LOADED")
Controller:RegisterEvent("PLAYER_LOGIN")
Controller:RegisterEvent("PLAYER_LOGOUT")
Controller:SetScript("OnEvent", Controller_OnEvent)
---------------------------------------------
-- SHORTENER FUNCTIONS
---------------------------------------------
cfg.specCoords = {
-- index left right top bottom
[ 1] = { 0.00, 0.25, 0.00, 1 },
[ 2] = { 0.25, 0.50, 0.00, 1 },
[ 3] = { 0.50, 0.75, 0.00, 1 },
[ 4] = { 0.75, 1.00, 0.00, 1 },
}
cfg.SVal = function(val)
if val > 1E10 then
return (floor(val/1E9)).."b"
elseif val > 1E9 then
return (floor((val/1E9)*10)/10).."b"
elseif val > 1E7 then
return (floor(val/1E6)).."m"
elseif val > 1E6 then
return (floor((val/1E6)*10)/10).."m"
elseif val > 1E4 then
return (floor(val/1E3)).."k"
elseif val >= 1E3 then
return (floor(val/1E3)) .. (" %03d"):format(val % 1E3)
else
return val
end
end
function cfg.hex(r, g, b)
if r then
if (type(r) == "table") then
if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end
end
return ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255)
end
end