Mercurial > wow > buffalo2
comparison ObjectiveTracker/Widgets.lua @ 38:1f8f9cc3d956
- module integration brought up to speed with current frame management structure
| author | Nenue |
|---|---|
| date | Thu, 21 Apr 2016 11:36:41 -0400 |
| parents | e84d645c8ab8 |
| children | 92534dc793f2 |
comparison
equal
deleted
inserted
replaced
| 37:e84d645c8ab8 | 38:1f8f9cc3d956 |
|---|---|
| 99 | 99 |
| 100 end | 100 end |
| 101 | 101 |
| 102 local OnClick = {} | 102 local OnClick = {} |
| 103 OnClick.CloseButton = function(self) | 103 OnClick.CloseButton = function(self) |
| 104 T:SetEnabled() | 104 T:Enable() |
| 105 if T.Conf.enabled then | 105 if T.Conf.enabled then |
| 106 T:Update() | 106 T:Update() |
| 107 end | 107 end |
| 108 | 108 |
| 109 UpdatePanelButton(self, T.Conf.enabled) | 109 UpdatePanelButton(self, T.Conf.enabled) |
| 273 T.WidgetRegistry = {} | 273 T.WidgetRegistry = {} |
| 274 local wr = T.WidgetRegistry | 274 local wr = T.WidgetRegistry |
| 275 | 275 |
| 276 --- Get a usable widget for the given achievement criteria set. | 276 --- Get a usable widget for the given achievement criteria set. |
| 277 -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block | 277 -- Returns a frame object with dimensioning parameters needed to size the receiving tracker block |
| 278 T.SetWidget = function(line, data, objectiveType, objectiveKey) | 278 T.GetWidget = function(data, objectiveType, objectiveKey) |
| 279 local print = B.print('ObjectiveWidgets') | 279 local print = B.print('ObjectiveWidgets') |
| 280 local widgetType = objectiveType | 280 local widgetType = objectiveType |
| 281 local widget | 281 local widget |
| 282 if wr[widgetType] and wr[widgetType].used[objectiveKey] then | 282 if wr[widgetType] and wr[widgetType].used[objectiveKey] then |
| 283 widget = wr[widgetType].used[objectiveKey] | 283 widget = wr[widgetType].used[objectiveKey] |
| 284 print('|cFF00FF00Updating ('..objectiveKey..')', widget) | 284 print('|cFF00FF00Updating ('..objectiveKey..')', widget) |
| 285 elseif not wr[widgetType] or #wr[widgetType].free == 0 then | 285 elseif not wr[widgetType] or #wr[widgetType].free == 0 then |
| 286 widget = CreateFrame('Frame', 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType) | 286 widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType) |
| 287 | |
| 288 print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn) | 287 print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn) |
| 289 else | 288 else |
| 290 widget = tremove(wr[widgetType].free) | 289 widget = tremove(wr[widgetType].free) |
| 291 print('|cFFFFFF00Acquiring released widget', widget:GetName()) | 290 print('|cFFFFFF00Acquiring released widget', widget:GetName()) |
| 292 end | 291 end |
| 293 | 292 |
| 294 | 293 |
| 295 wr[widgetType].used[objectiveKey] = widget | 294 wr[widgetType].used[objectiveKey] = widget |
| 296 widget.line = line | |
| 297 widget.objective = data | 295 widget.objective = data |
| 298 widget.key = objectiveKey | 296 widget.key = objectiveKey |
| 299 T.InitializeWidget(widget) | 297 T.InitializeWidget(widget) |
| 300 return widget | 298 return widget |
| 301 end | 299 end |
| 395 local progressHeight = 17 | 393 local progressHeight = 17 |
| 396 local progressBorder = 1 | 394 local progressBorder = 1 |
| 397 local progressFont = _G.VeneerCriteriaFontNormal | 395 local progressFont = _G.VeneerCriteriaFontNormal |
| 398 | 396 |
| 399 local lprint = B.print('Line') | 397 local lprint = B.print('Line') |
| 400 T.InitializeWidget.ProgressBar = function(self) | 398 T.InitializeWidget.StatusBar = function(self) |
| 401 local print = lprint | 399 local print = lprint |
| 402 local c = T.Conf.Wrapper | 400 local c = T.Conf.Wrapper |
| 403 self.height = progressHeight + c.TextSpacing | 401 self.height = progressHeight + c.TextSpacing |
| 404 self.width = c.Width - c.TextSpacing | 402 self.width = c.Width - c.TextSpacing |
| 405 self.value = self.value or 1 | 403 self.value = self.value or 1 |
| 406 self.maxValue = self.maxValue or 1 | 404 self.maxValue = self.maxValue or 1 |
| 407 | 405 |
| 408 self:SetHeight(progressHeight) | 406 self:SetHeight(progressHeight) |
| 409 self.bg:SetHeight(progressHeight) | 407 self:SetMinMaxValues(0, self.maxValue) |
| 410 self.bg:SetWidth(self.width) | 408 self:SetValue(self.value) |
| 411 self.fg:ClearAllPoints() | |
| 412 self.fg:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', progressBorder, progressBorder) | |
| 413 self.fg:SetHeight(progressHeight - progressBorder * 2) | |
| 414 | 409 |
| 415 --self.status:SetFontObject(progressFont) | 410 --self.status:SetFontObject(progressFont) |
| 416 self.status:SetText(self.objective.quantityString) | 411 self.status:SetText(self.objective.quantityString) |
| 417 end | 412 end |
| 418 | 413 |
| 419 T.UpdateWidget.ProgressBar = function (self) | 414 T.UpdateWidget.StatusBar = function (self) |
| 420 local quantity, requiredQuantity = self.value, self.maxValue | 415 local value, maxValue = self.value, self.maxValue |
| 421 print('update vals:') | 416 print('update vals:') |
| 422 for k,v in pairs(self.line) do | 417 for k,v in pairs(self) do |
| 423 print(k, v) | 418 print(k, v) |
| 424 end | 419 end |
| 425 | 420 self:SetValue(self.value) |
| 426 local progress = (quantity / requiredQuantity) | 421 local format = self.format or '%d/%d' |
| 427 if progress >= 1 then | 422 self.status:SetFormattedText(format, value, maxValue) |
| 428 self.fg:Show() | 423 local progress = (value / maxValue) |
| 429 self.fg:SetWidth(self.width - progressBorder * 2) | 424 if progress > 0 then |
| 430 elseif progress > 0 then | |
| 431 self.fg:Show() | |
| 432 print('color:', 1-progress*2 , progress*2 - 1,0,1) | 425 print('color:', 1-progress*2 , progress*2 - 1,0,1) |
| 433 print('width:', (self.width -progressBorder * 2) * progress) | 426 print('width:', (self.width -progressBorder * 2) * progress) |
| 434 self.fg:SetTexture(1-progress*2 , progress*2,0,1) | 427 self:SetStatusBarColor(1-progress*2 , progress*2,0,1) |
| 435 self.fg:SetWidth((self.width -progressBorder * 2) * progress) | |
| 436 else | |
| 437 self.fg:Hide() | |
| 438 end | 428 end |
| 439 end | 429 end |
| 440 | 430 |
| 441 | 431 |
| 442 T.InitializeWidget.Hidden = function (self) | 432 T.InitializeWidget.Hidden = function (self) |
