-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstartup.lua
340 lines (297 loc) · 12.3 KB
/
startup.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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
FurC = FurC or {}
local this = FurC
this.name = "FurnitureCatalogue"
this.author = "manavortex"
this.tag = "FurC"
this.version = 4085000 -- will be AUTOREPLACED with AddonVersion
this.CharacterName = nil
this.website = "https://www.esoui.com/downloads/fileinfo.php?id=1617"
this.settings = {}
local src = this.Constants.ItemSources
local ver = this.Constants.Versioning
this.AchievementVendors = {}
this.LuxuryFurnisher = {}
this.Recipes = {}
this.Rolis = {}
this.Faustina = {}
this.RolisRecipes = {}
this.FaustinaRecipes = {}
this.Books = {}
this.EventItems = {}
this.PVP = {}
this.MiscItemSources = {}
this.RumourRecipes = {}
local defaults = {
hideMats = true,
dontScanTradingHouse = false,
enableDebug = false,
data = {},
filterCraftingType = {},
filterQuality = {},
resetDropdownChoice = false,
useTinyUi = true,
useInventoryIcons = true,
fontSize = 18,
gui = {
lastX = 100,
lastY = 100,
width = 650,
height = 550,
},
dropdownDefaults = {
Source = 1,
Character = 1,
Version = 1,
},
accountCharacters = {},
-- tooltips
disableTooltips = false,
coloredTooltips = true,
dateFormat = "YYYY-MM-DD",
hideKnowledge = false,
hideBooks = true,
hideDoubtfuls = true,
hideCrownstore = true,
hideRumourEntry = false,
hideCrownStoreEntry = false,
wipeDatabase = false,
hideUiButtons = {
FURC_RUMOUR = false,
FURC_CROWN = false,
},
}
local sourceIndicesKeys = {}
local function getSourceIndicesKeys()
sourceIndicesKeys[src.NONE] = "off"
sourceIndicesKeys[src.FAVE] = "favorites"
sourceIndicesKeys[src.CRAFTING] = "craft_all"
sourceIndicesKeys[src.CRAFTING_KNOWN] = "craft_known"
sourceIndicesKeys[src.CRAFTING_UNKNOWN] = "craft_unknown"
sourceIndicesKeys[src.VENDOR] = "purch_gold"
sourceIndicesKeys[src.PVP] = "purch_ap"
sourceIndicesKeys[src.WRIT_VENDOR] = "writ_vendor"
sourceIndicesKeys[src.CROWN] = "crownstore"
sourceIndicesKeys[src.RUMOUR] = "rumour"
sourceIndicesKeys[src.LUXURY] = "luxury"
sourceIndicesKeys[src.OTHER] = "other"
--sourceIndicesKeys[src.ROLIS] = "ROLIS"
--sourceIndicesKeys[src.DROP] = "DROP"
--sourceIndicesKeys[src.JUSTICE] = "JUSTICE"
--sourceIndicesKeys[src.FISHING] = "FISHING"
--sourceIndicesKeys[src.GUILDSTORE] = "GUILDSTORE"
--sourceIndicesKeys[src.FESTIVAL_DROP] = "FESTIVAL_DROP"
return sourceIndicesKeys
end
this.GetSourceIndicesKeys = getSourceIndicesKeys
local choicesSource = {}
local function getChoicesSource()
choicesSource[src.NONE] = GetString(SI_FURC_FILTER_SRC_NONE)
choicesSource[src.FAVE] = GetString(SI_FURC_FILTER_SRC_FAVE)
choicesSource[src.CRAFTING] = GetString(SI_FURC_FILTER_SRC_CRAFTING)
choicesSource[src.CRAFTING_KNOWN] = GetString(SI_FURC_FILTER_SRC_CRAFTING_KNOWN)
choicesSource[src.CRAFTING_UNKNOWN] = GetString(SI_FURC_FILTER_SRC_CRAFTING_UNKNOWN)
choicesSource[src.VENDOR] = GetString(SI_FURC_FILTER_SRC_SOLD_GOLD)
choicesSource[src.PVP] = GetString(SI_FURC_FILTER_SRC_SOLD_AP)
choicesSource[src.WRIT_VENDOR] = GetString(SI_FURC_FILTER_SRC_SOLD_WRIT)
choicesSource[src.CROWN] = GetString(SI_FURC_FILTER_SRC_CROWN)
choicesSource[src.RUMOUR] = GetString(SI_FURC_FILTER_SRC_RUMOUR)
choicesSource[src.LUXURY] = GetString(SI_FURC_FILTER_SRC_LUX)
choicesSource[src.OTHER] = GetString(SI_FURC_FILTER_SRC_OTHER)
--choicesSource[src.ROLIS] = "ROLIS"
--choicesSource[src.DROP] = "DROP"
--choicesSource[src.JUSTICE] = "JUSTICE"
--choicesSource[src.FISHING] = "FISHING"
--choicesSource[src.GUILDSTORE] = "GUILDSTORE"
--choicesSource[src.FESTIVAL_DROP] = "FESTIVAL_DROP"
return choicesSource
end
this.GetChoicesSource = getChoicesSource
local tooltipsSource = {}
local function getTooltipsSource()
tooltipsSource[src.NONE] = GetString(SI_FURC_FILTER_SRC_NONE_TT)
tooltipsSource[src.FAVE] = GetString(SI_FURC_FILTER_SRC_FAVE_TT)
tooltipsSource[src.CRAFTING] = GetString(SI_FURC_FILTER_SRC_CRAFTING_TT)
tooltipsSource[src.CRAFTING_KNOWN] = GetString(SI_FURC_FILTER_SRC_CRAFTING_KNOWN_TT)
tooltipsSource[src.CRAFTING_UNKNOWN] = GetString(SI_FURC_FILTER_SRC_CRAFTING_UNKNOWN_TT)
tooltipsSource[src.VENDOR] = GetString(SI_FURC_FILTER_SRC_SOLD_GOLD_TT)
tooltipsSource[src.PVP] = GetString(SI_FURC_FILTER_SRC_SOLD_AP_TT)
tooltipsSource[src.CROWN] = GetString(SI_FURC_FILTER_SRC_CROWN_TT)
tooltipsSource[src.WRIT_VENDOR] = GetString(SI_FURC_FILTER_SRC_SOLD_WRIT_TT)
tooltipsSource[src.RUMOUR] = GetString(SI_FURC_FILTER_SRC_RUMOUR_TT)
tooltipsSource[src.LUXURY] = GetString(SI_FURC_FILTER_SRC_LUX_TT)
tooltipsSource[src.OTHER] = GetString(SI_FURC_FILTER_SRC_OTHER_TT)
--tooltipsSource[src.ROLIS] = "ROLIS"
--tooltipsSource[src.DROP] = "DROP"
--tooltipsSource[src.JUSTICE] = "JUSTICE"
--tooltipsSource[src.FISHING] = "FISHING"
--tooltipsSource[src.GUILDSTORE] = "GUILDSTORE"
--tooltipsSource[src.FESTIVAL_DROP] = "FESTIVAL_DROP"
return tooltipsSource
end
this.GetTooltipsSource = getTooltipsSource
-- [UPGRADING GAME VERSIONS, PTS compatibility]
this.DropdownData = {
ChoicesVersion = {
[ver.NONE] = GetString(SI_FURC_FILTER_VERSION_OFF),
[ver.HOMESTEAD] = GetString(SI_FURC_FILTER_VERSION_HS),
[ver.MORROWIND] = GetString(SI_FURC_FILTER_VERSION_M),
[ver.REACH] = GetString(SI_FURC_FILTER_VERSION_R),
[ver.CLOCKWORK] = GetString(SI_FURC_FILTER_VERSION_CC),
[ver.DRAGONS] = GetString(SI_FURC_FILTER_VERSION_DRAGON),
[ver.ALTMER] = GetString(SI_FURC_FILTER_VERSION_ALTMER),
[ver.SLAVES] = GetString(SI_FURC_FILTER_VERSION_SLAVES),
[ver.WEREWOLF] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF),
[ver.WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL),
[ver.KITTY] = GetString(SI_FURC_FILTER_VERSION_KITTY),
[ver.SCALES] = GetString(SI_FURC_FILTER_VERSION_SCALES),
[ver.DRAGON2] = GetString(SI_FURC_FILTER_VERSION_DRAGON2),
[ver.HARROW] = GetString(SI_FURC_FILTER_VERSION_HARROW),
[ver.SKYRIM] = GetString(SI_FURC_FILTER_VERSION_SKYRIM),
[ver.STONET] = GetString(SI_FURC_FILTER_VERSION_STONET),
[ver.MARKAT] = GetString(SI_FURC_FILTER_VERSION_MARKAT),
[ver.FLAMES] = GetString(SI_FURC_FILTER_VERSION_FLAMES),
[ver.BLACKW] = GetString(SI_FURC_FILTER_VERSION_BLACKW),
[ver.DEADL] = GetString(SI_FURC_FILTER_VERSION_DEADL),
[ver.TIDES] = GetString(SI_FURC_FILTER_VERSION_TIDES),
[ver.BRETON] = GetString(SI_FURC_FILTER_VERSION_BRETON),
[ver.DEPTHS] = GetString(SI_FURC_FILTER_VERSION_DEPTHS),
[ver.DRUID] = GetString(SI_FURC_FILTER_VERSION_DRUID),
[ver.SCRIBE] = GetString(SI_FURC_FILTER_VERSION_SCRIBE),
[ver.NECROM] = GetString(SI_FURC_FILTER_VERSION_NECROM),
[ver.BASED] = GetString(SI_FURC_FILTER_VERSION_BASED),
[ver.ENDLESS] = GetString(SI_FURC_FILTER_VERSION_ENDLESS),
[ver.SCIONS] = GetString(SI_FURC_FILTER_VERSION_SCIONS),
[ver.WEALD] = GetString(SI_FURC_FILTER_VERSION_WEALD),
[ver.BASE43] = GetString(SI_FURC_FILTER_VERSION_BASE43),
[ver.BASE44] = GetString(SI_FURC_FILTER_VERSION_BASE44),
},
TooltipsVersion = {
[ver.NONE] = GetString(SI_FURC_FILTER_VERSION_OFF_TT),
[ver.HOMESTEAD] = GetString(SI_FURC_FILTER_VERSION_HS_TT),
[ver.MORROWIND] = GetString(SI_FURC_FILTER_VERSION_M_TT),
[ver.REACH] = GetString(SI_FURC_FILTER_VERSION_R_TT),
[ver.CLOCKWORK] = GetString(SI_FURC_FILTER_VERSION_CC_TT),
[ver.DRAGONS] = GetString(SI_FURC_FILTER_VERSION_DRAGON_TT),
[ver.ALTMER] = GetString(SI_FURC_FILTER_VERSION_ALTMER_TT),
[ver.SLAVES] = GetString(SI_FURC_FILTER_VERSION_SLAVES_TT),
[ver.WEREWOLF] = GetString(SI_FURC_FILTER_VERSION_WEREWOLF_TT),
[ver.WOTL] = GetString(SI_FURC_FILTER_VERSION_WOTL_TT),
[ver.KITTY] = GetString(SI_FURC_FILTER_VERSION_KITTY_TT),
[ver.SCALES] = GetString(SI_FURC_FILTER_VERSION_SCALES_TT),
[ver.DRAGON2] = GetString(SI_FURC_FILTER_VERSION_DRAGON2_TT),
[ver.HARROW] = GetString(SI_FURC_FILTER_VERSION_HARROW_TT),
[ver.SKYRIM] = GetString(SI_FURC_FILTER_VERSION_SKYRIM_TT),
[ver.STONET] = GetString(SI_FURC_FILTER_VERSION_STONET_TT),
[ver.MARKAT] = GetString(SI_FURC_FILTER_VERSION_MARKAT_TT),
[ver.FLAMES] = GetString(SI_FURC_FILTER_VERSION_FLAMES_TT),
[ver.BLACKW] = GetString(SI_FURC_FILTER_VERSION_BLACKW_TT),
[ver.DEADL] = GetString(SI_FURC_FILTER_VERSION_DEADL_TT),
[ver.TIDES] = GetString(SI_FURC_FILTER_VERSION_TIDES_TT),
[ver.BRETON] = GetString(SI_FURC_FILTER_VERSION_BRETON_TT),
[ver.DEPTHS] = GetString(SI_FURC_FILTER_VERSION_DEPTHS_TT),
[ver.DRUID] = GetString(SI_FURC_FILTER_VERSION_DRUID_TT),
[ver.SCRIBE] = GetString(SI_FURC_FILTER_VERSION_SCRIBE_TT),
[ver.NECROM] = GetString(SI_FURC_FILTER_VERSION_NECROM_TT),
[ver.BASED] = GetString(SI_FURC_FILTER_VERSION_BASED_TT),
[ver.ENDLESS] = GetString(SI_FURC_FILTER_VERSION_ENDLESS_TT),
[ver.SCIONS] = GetString(SI_FURC_FILTER_VERSION_SCIONS_TT),
[ver.WEALD] = GetString(SI_FURC_FILTER_VERSION_WEALD_TT),
[ver.BASE43] = GetString(SI_FURC_FILTER_VERSION_BASE43_TT),
[ver.BASE44] = GetString(SI_FURC_FILTER_VERSION_BASE44_TT),
},
ChoicesCharacter = {
[1] = GetString(SI_FURC_FILTER_CHAR_OFF),
},
TooltipsCharacter = {
[1] = GetString(SI_FURC_FILTER_CHAR_OFF_TT),
},
-- will be set in setupSourceDropdown
ChoicesSource = {},
TooltipsSource = {},
}
function this.UpdateDropdowns()
this.DropdownData.ChoicesSource = this.GetChoicesSource()
this.DropdownData.TooltipsSource = this.GetTooltipsSource()
end
local function setupSourceDropdown()
this.UpdateDropdowns()
this.SourceIndices = getSourceIndicesKeys()
end
local logger
--- Gets the current logger or creates it if it doesn't exist yet
--- @return Logger logger instance
function this.getOrCreateLogger()
if logger then
return logger
end -- return existing reference
if not LibDebugLogger then
local function ignore(...) end -- black hole for most property calls, like logger:Debug
local function info(self, ...)
local prefix = string.format("[%s]: ", this.tag)
if tostring(...):find("%%") then
d(prefix .. string.format(...))
else
d(prefix .. tostring(...))
end
end
logger = {}
logger.Verbose = ignore
logger.Debug = ignore
logger.Info = info
logger.Warn = ignore
logger.Error = ignore
logger.Log = ignore
logger.LOG_LEVEL_VERBOSE = "V"
logger.LOG_LEVEL_DEBUG = "D"
logger.LOG_LEVEL_INFO = "I"
logger.LOG_LEVEL_WARNING = "W"
logger.LOG_LEVEL_ERROR = "E"
logger.SetMinLevelOverride = ignore
return logger
end
-- use logger from library
logger = LibDebugLogger(this.tag)
logger.LOG_LEVEL_VERBOSE = LibDebugLogger.LOG_LEVEL_VERBOSE
logger.LOG_LEVEL_DEBUG = LibDebugLogger.LOG_LEVEL_DEBUG
logger.LOG_LEVEL_INFO = LibDebugLogger.LOG_LEVEL_INFO
logger.LOG_LEVEL_WARNING = LibDebugLogger.LOG_LEVEL_WARNING
logger.LOG_LEVEL_ERROR = LibDebugLogger.LOG_LEVEL_ERROR
-- set initial log level
if this.settings.enableDebug then
logger:SetMinLevelOverride(logger.LOG_LEVEL_DEBUG)
else
logger:SetMinLevelOverride(logger.LOG_LEVEL_INFO)
end
return logger
end
-- initialization stuff
local function initialise(eventCode, addOnName)
if addOnName ~= this.name then
return
end
this.settings = ZO_SavedVars:NewAccountWide(this.name .. "_Settings", 2, nil, defaults)
-- setup the "source" dropdown for the menu
setupSourceDropdown()
this.CreateSettings(this.settings, defaults)
this.Logger = this.getOrCreateLogger()
this.Logger:Debug("Initialising..." .. eventCode)
this.CharacterName = zo_strformat(GetUnitName("player"))
this.InitGui()
this.CreateTooltips()
this.InitRightclickMenu()
this.SetupInventoryRecipeIcons()
local scanFiles = false
if this.settings.version < this.version then
this.settings.version = this.version
scanFiles = true
end
this.ScanRecipes(scanFiles, not this.GetSkipInitialScan())
this.settings.databaseVersion = this.version
SLASH_COMMANDS["/fur"] = FurnitureCatalogue_Toggle
this.SetFilter(true)
EVENT_MANAGER:UnregisterForEvent(this.name, EVENT_ADD_ON_LOADED)
this.Logger:Debug("Initialisation complete")
end
ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_FURNITURE_CATALOGUE", "Toggle main window")
ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_FURNITURE_CATALOGUE_RECIPE", "Toggle Blueprint on tooltip")
EVENT_MANAGER:RegisterForEvent(this.name, EVENT_ADD_ON_LOADED, initialise)