comparison ObjectiveTracker/Schema.lua @ 37:e84d645c8ab8

- revised the tracker update function to build its complete data list up front and use the values as points of comparison for determining possible out of place blocks, which will be iterated over afterward to remove what wasn't re-used - also entailed revising the exact role of global event handlers and function hooks, limiting their directions of communication so one doesn't end up calling the other multiple or inifinity times - schema handling polish
author Nenue
date Mon, 18 Apr 2016 07:56:23 -0400
parents 69d03f8e293e
children 1f8f9cc3d956
comparison
equal deleted inserted replaced
36:a487841050be 37:e84d645c8ab8
5 -- Created: 4/15/2016 11:36 PM 5 -- Created: 4/15/2016 11:36 PM
6 6
7 local B = select(2,...).frame 7 local B = select(2,...).frame
8 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') 8 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
9 local setmetatable, type, rawset = setmetatable, type, rawset 9 local setmetatable, type, rawset = setmetatable, type, rawset
10 local print = B.print('Schema') 10 local print = B.print('Tracker')
11 local lprint = B.print('Layout')
12 local oprint = B.print('Objectives')
11 T.defaults.Schema = setmetatable({}, { 13 T.defaults.Schema = setmetatable({}, {
12 __newindex = function(schemas,layerName, layerTable) 14 __newindex = function(schemas,layerName, layerTable)
13 -- tracker/block/line 15 -- tracker/block/line
14 if type(layerTable) == 'table' then 16 if type(layerTable) == 'table' then
17
18 print('adding layer', layerName)
19 for k,v in pairs(layerTable) do
20 print(' incorporated schema', k)
21 if type(v) == 'table' and k ~= 'default' then
22 setmetatable(v, {
23 __index = function(schemaTable, key)
24 print(' substituting default "'..tostring(schemas[layerName].default[key])..'" for |cFF00FFFF', layerName..'|r.|cFF0088FF'..k..'|r.'..key)
25 return schemas[layerName].default[key]
26 end
27 })
28 end
29 end
15 rawset(schemas, layerName, setmetatable(layerTable, { 30 rawset(schemas, layerName, setmetatable(layerTable, {
16 __index = function(layerTable, schemaName)
17
18 end,
19 __newindex = function(layerTable, schemaName, schemaTable) 31 __newindex = function(layerTable, schemaName, schemaTable)
20 -- schema table 32 -- schema table
21 if type(schemaTable) == 'table' then 33 if type(schemaTable) == 'table' then
34 print('adding schema', schemaName, 'to', layerName, 'layers')
35
36
22 rawset(layerTable, schemaName, setmetatable(schemaTable, { 37 rawset(layerTable, schemaName, setmetatable(schemaTable, {
23 __index = function(schemaTable, key) 38 __index = function(schemaTable, key)
24 print('substituting a default value for |cFF00FFFF', layerName..'|r.|cFF0088FF'..schemaName..'|r.'..key) 39 print(' substituting default "'..tostring(schemas[layerName].default[key])..'" for |cFF00FFFF', layerName..'|r.|cFF0088FF'..schemaName..'|r.'..key)
25 return layerTable.default[key] 40 rawset(schemaTable, key, schemas[layerName].default[key])
41 return schemas[layerName].default[key]
26 end 42 end
27 })) 43 }))
28 end 44 end
29 end, 45 end,
30 })) 46 }))
31 end 47 end
32 end 48 end
33 }) 49 })
34 50
35 T.defaults.Schema = { 51 T.defaults.Schema.tracker = {
36 tracker = { 52 default = {
37 default = { 53 headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0},
38 headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}, 54 headerFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'},
39 headerFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'}, 55 blockSpacing = 1,
40 blockSpacing = 1, 56 }
41 } 57 }
58 T.defaults.Schema.block = {
59 default = {
60 titleColor = {1, 0.7, 0, 1},
61 titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .125},
62 textbg = {'HORIZONTAL', 0, 0, 0, 0, 0, 0, 0, 0.4 },
63 selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225},
64 titleFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'},
65 textFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'},
66 titleIndent = 4,
67 titleSpacing = 3,
68 selectionIndent = 5,
69 textIndent = 3,
70 textSpacing = 3,
71 rewardSize = 24,
42 }, 72 },
43 block = { 73 achievement = {
44 default = { 74 titleColor = {0, 0.7, 1, 1},
45 titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .125},
46 textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 },
47 selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225},
48 titleFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'},
49 textFont = {[[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'},
50 titleIndent = 4,
51 titleSpacing = 3,
52 textIndent = 3,
53 textSpacing = 3,
54 rewardSize = 24,
55 },
56 daily = {
57 titlebg = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125},
58 textbg = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 },
59 },
60 weekly = {
61 titlebg = {'HORIZONTAL', 0, .35, .7, .25, 0, .35, .7, .125},
62 textbg = {'HORIZONTAL', 0, .35, .7, .1, 0, .35, .7, .075 },
63 },
64 account = {
65 titlebg = {'HORIZONTAL', .1, .1, .1, .25, .1, .1, .1, .125},
66 textbg = {'HORIZONTAL', .1, .1, .1, 0.4, .1, .1, .1, .085 },
67 },
68 -- alliance
69 faction_1 = {
70 titlebg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 },
71 textbg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 },
72 },
73 -- horde
74 faction_2 = {
75 titlebg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 },
76 textbg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 },
77 }
78 }, 75 },
79 line = { 76 achievement_account = {
80 default = { 77 titleColor = {.35, 0.7, 1, 1},
81 textColor = {.5,.75,1},
82 textSpacing = 3,
83 textIndent = 3,
84 },
85 completed = {
86 textColor = {0, 1, 0}
87 },
88 failed = {
89 textColor = {1,0,0 }
90 },
91 autocomplete = {
92 textColor = {0,1,0 }
93 },
94 objectColor = {
95 textColor = {0,1,1}
96 },
97 monster = {
98 textColor = {1,1,0}
99 },
100 item = {
101 textColor = {1,.25,.5}
102 }
103 }, 78 },
104 widget = { 79 daily = {
105 progressbar = { 80 titleColor = {0, 0.7, 1, 1},
81 titlebg = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125},
82 textbg = {'HORIZONTAL', 0, .7, 1, .075, 0, 1, .7, .1},
83 },
84 weekly = {
85 titleColor = {.25, 0.7, 1, 1},
86 titlebg = {'HORIZONTAL', 0, .35, .7, .25, 0, .35, .7, .125},
87 textbg = {'HORIZONTAL', 0, .35, .7, .1, 0, .35, .7, .075 },
88 },
89 account = {
90 titlebg = {'HORIZONTAL', .1, .1, .1, .25, .1, .1, .1, .125},
91 textbg = {'HORIZONTAL', .1, .1, .1, 0.4, .1, .1, .1, .085 },
92 },
93 -- alliance
94 faction_1 = {
95 titlebg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 },
96 textbg = {'HORIZONTAL', .2, .4, 1, 0.4, .2, .4, 1, .085 },
97 },
98 -- horde
99 faction_2 = {
100 titlebg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 },
101 textbg = {'HORIZONTAL', .6, 0, 0.4, 0.4, .6, 0, 0.4, .085 },
102 }
103 }
104 T.defaults.Schema.line = {
105 default = {
106 textColor = {.5,.75,1},
107 textSpacing = 3,
108 textIndent = 3,
109 },
110 completed = {
111 textColor = {0, 1, 0}
112 },
113 failed = {
114 textColor = {1,0,0 }
115 },
116 autocomplete = {
117 textColor = {0,1,0 }
118 },
119 objectColor = {
120 textColor = {0,1,1}
121 },
122 monster = {
123 textColor = {1,1,0}
124 },
125 item = {
126 textColor = {1,.25,.5}
127 }
128 }
129 T.defaults.Schema.widget = {
130 progressbar = {
106 131
107 }, 132 },
108 timer = { 133 timer = {
109 134
110 } 135 }
111 },
112 } 136 }