Mercurial > wow > buffalo2
comparison Templates.lua @ 109:26938ae258b7
- Re-use the basic addon table for core mixin
- add /rl command
author | Nick@Zahhak |
---|---|
date | Mon, 06 Mar 2017 02:30:22 -0500 |
parents | a41f6b74709a |
children | 8c94bee4fdfc |
comparison
equal
deleted
inserted
replaced
108:a41f6b74709a | 109:26938ae258b7 |
---|---|
2 -- Templates.lua | 2 -- Templates.lua |
3 -- Created: 10/24/2016 9:16 AM | 3 -- Created: 10/24/2016 9:16 AM |
4 -- %file-revision% | 4 -- %file-revision% |
5 -- | 5 -- |
6 -- Mover Widget base | 6 -- Mover Widget base |
7 local ADDON, Veneer = ... | |
7 local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop | 8 local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop |
8 local debugTemplates = {} | 9 local PlaySoundKitID = DEVIAN_WORKSPACE and PlaySoundKitID or nop |
10 local ipairs, pairs = ipairs, pairs | |
11 local pack, unpack = pack, unpack | |
9 | 12 |
10 VeneerConfigLayerMixin = {} | 13 local Handler, ConfigLayer, Animation = {}, {}, {} |
11 VeneerAnimationMixin = {} | |
12 VeneerHandlerMixin = { | |
13 anchorPoint = 'CENTER', | |
14 anchorPriority = 4, | |
15 data = {}, | |
16 } | |
17 | 14 |
18 function VeneerConfigLayerMixin:OnLoad() | 15 VeneerConfigLayerMixin = ConfigLayer |
16 VeneerAnimationMixin = Animation | |
17 VeneerHandlerMixin = Handler | |
18 Handler.anchorPoint = 'CENTER' | |
19 Handler.anchorPriority = 4 | |
20 Handler.data = {} | |
21 Veneer.HandlerBase = Handler | |
22 Veneer.ConfigLayerBase = ConfigLayer | |
23 Veneer.AnimationBase = Animation | |
24 | |
25 | |
26 function ConfigLayer:OnLoad() | |
19 local handler = self:GetParent() | 27 local handler = self:GetParent() |
20 print(handler:GetName(), 'configLayers') | 28 print(handler:GetName(), 'configLayers') |
21 handler.ConfigLayers = handler.ConfigLayers or {} | 29 handler.ConfigLayers = handler.ConfigLayers or {} |
22 for i, region in ipairs(handler.ConfigLayers) do | 30 for i, region in ipairs(handler.ConfigLayers) do |
23 region:SetShown(Veneer.ConfigMode) | 31 region:SetShown(Veneer.ConfigMode) |
24 end | 32 end |
25 end | 33 end |
26 | 34 |
27 function VeneerConfigLayerMixin:OnUpdate() | 35 function ConfigLayer:OnUpdate() |
28 local handler = self:GetParent() | 36 local handler = self:GetParent() |
29 handler.ConfigLayers = handler.ConfigLayers or {} | 37 handler.ConfigLayers = handler.ConfigLayers or {} |
30 | 38 |
31 self.ConfigName:SetText(handler:GetName()) | 39 self.ConfigName:SetText(handler:GetName()) |
32 self.ConfigID:SetText(handler:GetID()) | 40 self.ConfigID:SetText(handler:GetID()) |
33 end | 41 end |
34 | 42 |
35 function VeneerAnimationMixin:OnPlay() | 43 -- Sets a state flag for use in OnUpdate conditionals |
44 function Animation:OnPlay() | |
36 PlaySoundKitID(229) | 45 PlaySoundKitID(229) |
37 self.animating = true | 46 self.animating = true |
38 print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint)) | 47 print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint)) |
39 end | 48 end |
40 function VeneerAnimationMixin:OnStop() | 49 function Animation:OnStop() |
41 PlaySoundKitID(229) | 50 PlaySoundKitID(229) |
42 self.animating = nil | 51 self.animating = nil |
43 print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) | 52 print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) |
44 end | 53 end |
45 function VeneerAnimationMixin:OnFinished() | 54 function Animation:OnFinished() |
46 PlaySoundKitID(229) | 55 PlaySoundKitID(229) |
47 self.animating = nil | 56 self.animating = nil |
48 print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) | 57 print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) |
49 end | 58 end |
50 | 59 |
51 function VeneerHandlerMixin:OnShow() | 60 -- Replace if module requires anything besides fixing frame anchors |
61 function Handler:OnShow() | |
52 self:Reanchor() | 62 self:Reanchor() |
53 Veneer:StaticReanchor(self) | 63 Veneer:StaticReanchor(self) |
54 end | 64 end |
55 function VeneerHandlerMixin:OnHide() | 65 function Handler:OnHide() |
56 Veneer:DynamicReanchor() | 66 Veneer:DynamicReanchor() |
57 end | 67 end |
58 function VeneerHandlerMixin:Reanchor (anchorAll) | 68 function Handler:Reanchor (anchorAll) |
59 Veneer:DynamicReanchor() | 69 Veneer:DynamicReanchor() |
60 end | 70 end |
61 function VeneerHandlerMixin:Setup() | 71 |
72 -- Replace if module needs to do more than reconcile SavedVariables pointers | |
73 function Handler:Setup() | |
62 local configName = self:GetName():gsub('^Veneer', '') | 74 local configName = self:GetName():gsub('^Veneer', '') |
63 VeneerData[configName] = VeneerData[configName] or self.defaultSettings or {} | 75 VeneerData[configName] = VeneerData[configName] or self.defaultSettings or {} |
64 | 76 |
65 -- reconcile any data accumulated before login trigger | |
66 for k,v in pairs(self.data) do | 77 for k,v in pairs(self.data) do |
67 if not VeneerData[configName][k] then | 78 if not VeneerData[configName][k] then |
68 print('reconciling pre-data:', k, v) | 79 print('reconciling pre-data:', k, v) |
69 VeneerData[configName][k] = v | 80 VeneerData[configName][k] = v |
70 end | 81 end |
75 self.profile = self.data[guid] | 86 self.profile = self.data[guid] |
76 print('data table loaded:', configName) | 87 print('data table loaded:', configName) |
77 self.initialized = true | 88 self.initialized = true |
78 end | 89 end |
79 | 90 |
80 function VeneerHandlerMixin:Print(...) | 91 -- Replace to stop collated outputs. |
92 function Handler:Print(...) | |
81 local txt = '|cFFFFFF00'..self:GetName()..'|r:' | 93 local txt = '|cFFFFFF00'..self:GetName()..'|r:' |
82 for i = 1, select('#', ...) do | 94 for i = 1, select('#', ...) do |
83 txt = txt .. ' '.. tostring(select(i, ...)) | 95 txt = txt .. ' '.. tostring(select(i, ...)) |
84 end | 96 end |
85 | |
86 | |
87 | |
88 DEFAULT_CHAT_FRAME:AddMessage(txt) | 97 DEFAULT_CHAT_FRAME:AddMessage(txt) |
89 end | 98 end |
90 | 99 |
91 function VeneerHandlerMixin:UpdateConfigLayers (configMode) | 100 -- Replace if not using the ConfigLayer template |
101 function Handler:UpdateConfigLayers (configMode) | |
92 -- Override to manage config visual elements when a config update is fired from /vn or login | 102 -- Override to manage config visual elements when a config update is fired from /vn or login |
93 if not self:IsShown() then | 103 if not self:IsShown() then |
94 self:SetShown(configMode) | 104 self:SetShown(configMode) |
95 self:Reanchor() | 105 self:Reanchor() |
96 end | 106 end |