comparison DependencyLoader_Core/frontend.lua @ 0:9852fcd5e59e

initial import
author mckenziemc
date Tue, 30 Nov 2010 16:13:04 -0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:9852fcd5e59e
1 -- main.lua
2 --
3
4 local addonName, addonTable = ...
5
6
7 local DependencyLoader = LibStub("AceAddon-3.0"):NewAddon(addonName)
8 _G[addonName] = DependencyLoader
9
10 local libPrint = LibStub("LibPrint-1.0")
11 DependencyLoader.printStream = libPrint:NewStream("DependencyLoader", "DpLdr", print)
12 DependencyLoader.debugStream = libPrint:NewStream("DependencyLoader", "DpLdr", "mcm")
13
14 -- temp
15 DependencyLoader.classes = addonTable.classes
16
17 function DependencyLoader:Print(...)
18 self.printStream:Print(...)
19 end
20
21
22 function DependencyLoader:Debug(...)
23 self.debugStream:Print(...)
24 end
25
26
27 function DependencyLoader:OnInitialize()
28 self:Debug("Initializing and enabling", addonName)
29 self:Enable()
30 end
31
32
33 function DependencyLoader:OnEnable()
34 self.core = addonTable.classes.Core:New()
35
36 self:Print("Enabled", addonName)
37
38 self:FixCurrentAddons()
39 end
40
41 function DependencyLoader:OnDisable()
42 self:Print("Disabled", addonName)
43 end
44
45
46 -- TODO: move this into core?
47
48 -- Enables any dependencies needed by the addons
49 -- that have already been enabled
50 function DependencyLoader:FixCurrentAddons()
51 local core = self.core
52
53 for i=1, GetNumAddOns() do
54 local addon = self.core:GetAddon(i)
55
56 if addon:IsEnabled() then
57 if addon:IsLoaded() then
58 -- TODO: it might still help to enable its embeds
59 else
60 self:Debug("Checking", addon:GetName())
61
62 if addonTable.classes.Core:ForceLoadAvailable() then
63 if core:CanForceLoadTree(addon:GetName()) then
64 core:ForceLoadTree(addon:GetName())
65 else
66 print("Can't force load", addon:GetName())
67 end
68 else
69 if core:CanLoDTree(addon:GetName()) then
70 core:PrepareLoDTree(addon:GetName())
71 else
72 print("Couldn't load", addon:GetName(), "on demand.")
73 end
74 end
75 end
76 end
77 end
78 end
79
80
81
82
83