Mercurial > wow > buffalo2
comparison ObjectiveTracker/Widgets.lua @ 43:9480bd904f4c
- file name organizing
author | Nenue |
---|---|
date | Mon, 25 Apr 2016 13:51:58 -0400 |
parents | 92534dc793f2 |
children |
comparison
equal
deleted
inserted
replaced
42:c73051785f19 | 43:9480bd904f4c |
---|---|
1 local B = select(2,...).frame | 1 local B = select(2,...).frame |
2 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 2 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
3 local print = B.print('WidgetFactory') | 3 local print = B.print('WidgetFactory') |
4 local tprint = B.print('Tracker') | |
4 local _G, UIParent = _G, UIParent | 5 local _G, UIParent = _G, UIParent |
5 local GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown = GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown | 6 local GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown = GetQuestLogSpecialItemInfo, IsQuestLogSpecialItemInRange, GetQuestLogSpecialItemCooldown |
6 local CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll = CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame, VeneerObjectiveScroll | 7 local CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame = CooldownFrame_SetTimer, SetItemButtonTextureVertexColor, CreateFrame |
7 local tremove, tContains, pairs, ipairs, setmetatable, floor = tremove, tContains, pairs, ipairs, setmetatable, floor | 8 local pairs, ipairs, floor = pairs, ipairs, floor |
8 local SetItemButtonTexture, SetItemButtonCount = SetItemButtonTexture, SetItemButtonCount | 9 local SetItemButtonTexture, SetItemButtonCount = SetItemButtonTexture, SetItemButtonCount |
9 local ToggleWorldMap, GetTrackedAchievements, GetTasksTable = ToggleWorldMap, GetTrackedAchievements, GetTasksTable | 10 local ToggleWorldMap = ToggleWorldMap |
10 -- GLOBALS: Veneer_QuestObjectiveItem_UpdateCooldown, Veneer_QuestObjectiveItem_OnUpdate | 11 -- GLOBALS: Veneer_QuestObjectiveItem_UpdateCooldown, Veneer_QuestObjectiveItem_OnUpdate |
11 --- frame refs | 12 |
13 --- Functions for generating and recycling the miscellaneous interface widgets specified by quests | |
12 local Wrapper = _G.VeneerObjectiveWrapper | 14 local Wrapper = _G.VeneerObjectiveWrapper |
13 local Scroller = Wrapper.scrollArea | 15 local Scroller = Wrapper.scrollArea |
14 local CloseButton = Wrapper.CloseButton | 16 local CloseButton = Wrapper.CloseButton |
15 local QuestMapButton = Wrapper.QuestMapButton | 17 local QuestMapButton = Wrapper.QuestMapButton |
16 local Scroll = _G.VeneerObjectiveScroll | 18 local Scroll = _G.VeneerObjectiveScroll |
111 | 113 |
112 OnClick.QuestMapButton = function() | 114 OnClick.QuestMapButton = function() |
113 ToggleWorldMap() | 115 ToggleWorldMap() |
114 end | 116 end |
115 | 117 |
118 --- Get a usable widget for the given achievement criteria set. | |
119 -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block | |
120 local wr = T.WidgetRegistry | |
121 T.GetWidget = function(data, objectiveType, objectiveKey) | |
122 local print = B.print('ObjectiveWidgets') | |
123 local widgetType = objectiveType | |
124 local widget | |
125 local isNew | |
126 if wr[widgetType] and wr[widgetType].used[objectiveKey] then | |
127 widget = wr[widgetType].used[objectiveKey] | |
128 print('|cFF00FF00Updating ('..objectiveKey..')', widget) | |
129 elseif not wr[widgetType] or #wr[widgetType].free == 0 then | |
130 -- creating a new frame | |
131 isNew = true | |
132 widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType) | |
133 print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn) | |
134 T.UpdateSchema(widgetType, data.schema or 'default') | |
135 else | |
136 -- recycling for a different criteria set | |
137 isNew = true | |
138 widget = tremove(wr[widgetType].free) | |
139 print('|cFFFFFF00Acquiring released widget', widget:GetName()) | |
140 end | |
141 | |
142 for k,v in pairs(data) do | |
143 if not widget[k] then | |
144 widget[k] = v | |
145 tprint('widget', widget:GetName(), k, v) | |
146 end | |
147 end | |
148 | |
149 wr[widgetType].used[objectiveKey] = widget | |
150 widget.objective = data | |
151 widget.key = objectiveKey | |
152 T.InitializeWidget(widget, isNew) | |
153 return widget | |
154 end | |
155 | |
156 local wr = T.WidgetRegistry | |
157 --- WidgetTemplate 'OnLoad' | |
158 T.RegisterWidget = function(frame) | |
159 local print = B.print('ObjectiveWidgets') | |
160 local widgetType = frame.widgetType | |
161 if not wr[frame.widgetType] then | |
162 print('|cFFFF4400[[WidgetTemplate]]|r', widgetType) | |
163 wr[widgetType] = { lastn = 1, free = {}, used = {}, usedIndex = {}, freeIndex = {} } | |
164 else | |
165 print('|cFF0088FF+ [[WidgetTemplate]]r', widgetType, wr[widgetType].lastn) | |
166 wr[widgetType].lastn = wr[widgetType].lastn + 1 | |
167 end | |
168 end | |
116 | 169 |
117 T.InitializeWidgets = function() | 170 T.InitializeWidgets = function() |
118 local panelButtons = T.buttons | 171 local panelButtons = T.buttons |
119 --- tracker scroll | 172 --- tracker scroll |
120 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel) | 173 Scroller:SetScript('OnMouseWheel', Scroller_OnMouseWheel) |