-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleLvl.lua
More file actions
124 lines (104 loc) · 3.28 KB
/
SimpleLvl.lua
File metadata and controls
124 lines (104 loc) · 3.28 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
-- SimpleLvl Core
-- Simple leveling tracker for exp, kills, quests, and time to level.
-- Gtihub Link
-- Provide acces to the global environment without using getglobal()
-- Must be declared before simplelvlEnvironment because things in there require it
local _G = _G or getfenv(0)
local SL_DATA_VERSION = 1
local SLVersion = "1.0.0"
SimpleLvl = CreateFrame("Frame")
SimpleLvl.util = {}
SimpleLvl.tracker = {}
SimpleLvl.config = {}
SimpleLvl.ui = nil
SimpleLvl.log = nil
function SimpleLvl:Init()
self.eventFrame = CreateFrame("Frame")
self.eventFrame:SetScript("OnEvent", function()
self:OnEvent()
end)
self.eventFrame:RegisterEvent("ADDON_LOADED")
self.eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
end
function SimpleLvl:OnEvent()
if event == "ADDON_LOADED" then
if arg1 == "SimpleLvl" then
self.eventFrame:UnregisterEvent("ADDON_LOADED")
if SLDatastore == nil then
self:SetupDefaults()
elseif SLDatastore.DatabaseVersion ~= SL_DATA_VERSION then
self:Print("Datastore outdated, Settings reset back to default")
self:SetupDefaults()
end
if SLProfile == nil or not SLDatastore.data[SLProfile] then
SLProfile = "Default"
--self:Print("Profile not found, using Default profile")
end
if not SLDatastore.data[SLProfile].SilenceWelcomeMessage then
self:Print("v" .. SLVersion .. " by BeardedRasta")
end
end
elseif event == "PLAYER_ENTERING_WORLD" then
SLLoadTracker()
end
end
function SimpleLvl:SetupDefaults()
SLProfile = "Default"
SLDatastore = {
DatabaseVersion = SL_DATA_VERSION,
data = {}
}
SLDatastore.data[SLProfile] = SimpleLvl_Copy(SLData.Default, {})
SLDatastore.data[SLProfile].Name = "Default"
end
function SimpleLvl_Copy(a, b)
if type(a) ~= "table" or type(b) ~= "table" then
return
end
for k, v in pairs(a) do
if type(v) ~= "table" then
b[k] = v;
else
local x = {}
SimpleLvl_Copy(v, x);
b[k] = x;
end
end
return b
end
SLData = {
Default = {
Name = "New Profile (Default)",
SilenceWelcomeMessage = true,
locked = false,
Store = {
trackerPos = {
point = "CENTER",
parentName = "UIParent",
relativePoint = "CENTER",
xOfs = -300,
yOfs = 0,
},
ttswap = false,
trackerScale = 1,
}
}
}
SLTextures = {
Background = "Interface\\AddOns\\SimpleLvl\\Media\\background.blp",
Frame = "Interface\\AddOns\\SimpleLvl\\Media\\Frame.blp",
Button = "Interface\\AddOns\\SimpleLvl\\Media\\SimpleUI-Default.blp",
Attack = "Interface\\AddOns\\SimpleLvl\\Media\\Combat.blp",
Quest = "Interface\\AddOns\\SimpleLvl\\Media\\quest.tga",
Time = "Interface\\AddOns\\SimpleLvl\\Media\\timer_icon.tga"
}
function SimpleLvl:GetTexture(string)
if SLTextures[string] then
return SLTextures[string]
end
return ""
end
function SimpleLvl:Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("Simple |cff1a9fc0Lvl|cFFFFFFFF: " .. msg)
end
SimpleLvl:Init()