-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwinda.lua
More file actions
98 lines (84 loc) · 2.67 KB
/
winda.lua
File metadata and controls
98 lines (84 loc) · 2.67 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
print("|c0000FFFFWelcome to winda !|r")
-- addon init
local addonName, WD = ... -- addon name and winda table
-- wdPrint(...)
wdPrint("Welcome to "..addonName.." !")
local tinsert, next = table.insert, next
local tonumber, tostring = tonumber, tostring
local GetAddOnMetadata = GetAddOnMetadata
-- prepare
local Winda = {} -- winda handle
local Deploy = {} -- configs for winda
local L = {} -- Locales
local DB = {} -- Databases
-- sub prepare
local version = {}
------------------------------------------------------------------------
-- Core winda
-- Entities private value for entities info
-- these entities are module entity (just like Bags, Bars, etc.)
-- module has own entity which is frame
local entities, entityQueue = {}, {}
function Winda:RegisterEntity(name)
if entities[name] then wdPrint("Module <"..name.."> has been registered.") return end
local module = {}
module.name = name
entities[name] = module
tinsert(entityQueue, module)
return module
end
function Winda:GetEntity(name)
if not entities[name] then wdPrint("Module <"..name.."> does not exist.") return end
return entities[name]
end
-- winda event register
local events = {} -- event trace
function Winda:LoginEvent (args) -- player login
-- body...
-- version
local an = addonName
local vstr = tostring(GetAddOnMetadata(an, "Version"))
local major, minor, fix = wdStrsplit(".", vstr)
version.major = tonumber(major)
version.minor = tonumber(minor)
version.fix = tonumber(fix)
version.string = vstr
WD.version = version
-- entities
for _, entity in next, entityQueue do
if entity.OnLogin then
entity:OnLogin()
else
wdPrint("Module <"..entity.name.."> does not loaded.")
end
end
end
------------------------------------------------------------------------
-- Deploy
Winda.VERSION_STRING = "@project-version@ Classic"
------------------------------------------------------------------------
-- DB
DB.addonName = addonName
------------------------------------------------------------------------
-- frame handle
do
local handle = CreateFrame("Frame")
handle:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
handle:RegisterEvent("PLAYER_LOGIN", Winda.LoginEvent)
handle:SetScript("OnEvent", function(_, event, ...)
-- wdPrint(CombatLogGetCurrentEventInfo())
if event == "PLAYER_LOGIN" then
Winda:LoginEvent()
end
end)
-- setup frame handle
Winda.entity = handle
end
------------------------------------------------------------------------
-- wd settings
WD[1] = Winda
WD[2] = Deploy
WD[3] = L
WD[4] = DB
-- global wd
_G[addonName] = WD