forked from rockingdice/AutoCategory
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAutoCategory_Global.lua
More file actions
executable file
·83 lines (65 loc) · 2.49 KB
/
AutoCategory_Global.lua
File metadata and controls
executable file
·83 lines (65 loc) · 2.49 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
AC_BAG_TYPE_BACKPACK = 1
AC_BAG_TYPE_BANK = 2
AC_BAG_TYPE_GUILDBANK = 3
AC_BAG_TYPE_CRAFTBAG = 4
AC_BAG_TYPE_CRAFTSTATION = 5
AC_BAG_TYPE_HOUSEBANK = 6
AC_BAG_TYPE_FURNVAULT = 7
AC_BAG_TYPE_VENGEANCE = 8
AC_BAG_TYPE_MIN = AC_BAG_TYPE_BACKPACK
AC_BAG_TYPE_MAX = AC_BAG_TYPE_FURNVAULT
local SF = LibSFUtils
AutoCategory = {
name = "AutoCategory",
version = SF.colors.gold:Colorize("4.6.4"),
settingName = "AutoCategory",
settingDisplayName = SF.colors.gold("AutoCategory - Revised"),
author = SF.colors.purple("Shadowfen, crafty35, RockingDice, Friday_the13_rus"),
RuleFunc = {}, -- internal and plugin rule functions
Plugins = {}, -- registered plugins
Inited = false, -- provided for the API so that external users can tell when initialization is completed
Enabled = true, -- flag to tell if AutoCategory is turned on or off
compiledRules = {},
rules = {}, -- [#] rule {rkey, name, tag, description, rule, pred, damaged, err}
ARW = {},
BulkMode = false,
}
AutoCat_Logger = SF.SafeLoggerFunction(AutoCategory, "logger", "AutoCategory")
--[[
The following SetDebug() call is commented out because it severely slows down
addon operation. Turning it on does however provide lots and lots of debug logging.
Never leave this uncommented when releasing!!
--]]
AutoCat_Logger():SetDebug(true)
-- convenience function for a call to AutoCat_Logger():Debug(SF.str(...))
-- only done for Debug() because there is no special handling for the other message levels
-- always returns nil
function AutoCategory.logDebug(...)
local n = select("#", ...)
if n == 0 then return end
local logger = AutoCat_Logger()
-- skip parameter processing if they are not going to be used.
if not logger.enabled or not logger.SFenableDebug then return end
if n == 1 then
logger:Debug(...)
else
logger:Debug(SF.str(...))
end
end
-- Namespace for the AutoCategory user interface elements
AC_UI = {}
AutoCategory.RulesW = {
ruleList= {}, -- [#] rule {rkey, name, tag, description, rule, pred, damaged, err}
ruleNames={}, -- [name] rule#
compiled = AutoCategory.compiledRules, -- [name] function
tags = {}, -- [#] tagname
tagGroups={}, -- [tag] CVT{choices{rule.name}, choicesTooltips{rule.desc/name}}
}
-- load in localization strings
SF.LoadLanguage(AutoCategory_localization_strings, "en")
function AutoCategory.foreachBag(func)
if not func then return end
for bagId = AC_BAG_TYPE_MIN, AC_BAG_TYPE_MAX do
func(bagId)
end
end