-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCore.lua
More file actions
133 lines (113 loc) · 4.33 KB
/
Copy pathCore.lua
File metadata and controls
133 lines (113 loc) · 4.33 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
local addonName, GBCR = ...
GBCR.Core = {}
local Core = GBCR.Core
GBCR.Addon = GBCR.Libs.AceAddon:NewAddon(addonName, "AceComm-3.0", "AceConsole-3.0", "AceEvent-3.0")
local Globals = GBCR.Globals
local string_match = Globals.string_match
local tonumber = Globals.tonumber
local GetAddOnMetadata = Globals.GetAddOnMetadata
local Constants = GBCR.Constants
local logLevels = Constants.LOG_LEVEL
-- _G[addonName] = GBCR -- Uncomment for debugging purposes
-- Make the addon metadata universally available
local function loadMetadata(self)
local addonTitle = GetAddOnMetadata(addonName, "Title")
local addonVersion = GetAddOnMetadata(addonName, "Version") or "0.0.0"
local major, minor, patch = string_match(addonVersion, "(%d+)%.(%d+)%.(%d+)")
local addonVersionNumber = (tonumber(major) * 10000) + (tonumber(minor) * 100) + (tonumber(patch) or 0)
local addonIsOutdated = GBCR.Protocol.isAddonOutdated and
Globals.ColorizeText(Constants.COLORS.GOLD, " (a newer version is available)") or ""
local addonHeader = addonTitle .. " v" .. addonVersion .. addonIsOutdated
self.addonTitle = addonTitle
self.addonHeader = addonHeader
self.addonVersion = addonVersion
self.addonVersionNumber = addonVersionNumber
if GBCR.UI.window then
GBCR.UI.window:SetTitle(addonHeader)
end
end
-- Called when the addon is loaded
function GBCR.Addon:OnInitialize()
loadMetadata(Core)
local defaults = {
char = {bank = {inventoryTracking = true, reportReceivedDonations = true, rankFulfillment = {}}},
profile = {
combat = {hide = true},
minimap = {hide = false},
uiTransparency = false,
clockTime = "realm",
framePositions = {
inventory = {width = 850, height = 485},
debug = {width = 800, height = 400},
panes = {cartLeft = 550, previewRight = 284}
},
logLevel = logLevels.INFO.level,
debugCategories = {
COMMS = false,
WHISPER = false,
PROTOCOL = false,
SYNC = false,
CHUNK = false,
DATABASE = false,
UI = false,
ITEM = false,
SEARCH = false,
EVENTS = false,
INVENTORY = false,
ROSTER = false,
LEDGER = false
},
sortMode = "default"
},
global = {guilds = {}}
}
GBCR.db = GBCR.Libs.AceDB:New("GBCR_DB_V30011", defaults, true)
GBCR.Database:Init()
GBCR.Options:Init()
GBCR.UI.Debug:Init()
GBCR.Inventory:Init()
GBCR.Guild:Init()
GBCR.Chat.Init()
GBCR.Protocol:Init()
GBCR.UI:Init()
GBCR.Ledger:Init()
local framePositionsDebug = GBCR.db.profile.framePositions.debug
if not framePositionsDebug.left or not framePositionsDebug.top then
GBCR.UI:RestoreUI()
end
end
-- Called when the addon is enabled
function GBCR.Addon:OnEnable()
GBCR.Events:RegisterEvents()
end
-- Called when the addon is disabled
function GBCR.Addon:OnDisable()
GBCR.Events:UnregisterEvents()
GBCR.Protocol:CancelAllDebounceTimers()
GBCR.UI:StopNetworkTicker()
GBCR.Protocol.gossipLoopRunning = false
GBCR.Protocol.isAcceptingIncoming = false
GBCR.Protocol.isProcessingQueue = false
local function cancelTimer(holder, field)
if holder[field] then
holder[field]:Cancel();
holder[field] = nil
end
end
cancelTimer(GBCR.Protocol, "timerLoginHashBroadcast")
cancelTimer(GBCR.Protocol, "printVersionsTimer")
cancelTimer(GBCR.Protocol, "itemLoadWatchdog")
cancelTimer(GBCR.Guild, "timerRebuildGuildRosterInfo")
cancelTimer(GBCR.Events, "timerRefreshOnlineMembersCache")
cancelTimer(GBCR.Events, "bankCloseTimeoutTimer")
cancelTimer(GBCR.Events, "timerBagUpdateDelayedScanInventory")
cancelTimer(GBCR.Events, "timerGetItemInfoReceivedScanInventory")
cancelTimer(GBCR.Ledger, "timerLedgerFirstChange")
cancelTimer(GBCR.Ledger, "timerLedgerUpdateBroadcast")
cancelTimer(GBCR.UI, "clockTicker")
cancelTimer(GBCR.UI, "syncPulseTicker")
cancelTimer(GBCR.UI, "searchTimer")
cancelTimer(GBCR.UI, "resizeTimer")
end
-- Export functions for other modules
Core.LoadMetadata = loadMetadata