Mercurial > wow > reaction
diff classes/ReBar.lua @ 8:c05fd3e18b4f
Version 0.31
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Tue, 20 Mar 2007 21:33:59 +0000 |
parents | f920db5fc6b1 |
children | f3a7bfebc283 |
line wrap: on
line diff
--- a/classes/ReBar.lua Tue Mar 20 21:25:29 2007 +0000 +++ b/classes/ReBar.lua Tue Mar 20 21:33:59 2007 +0000 @@ -149,13 +149,19 @@ -- create the bar and control widgets - self.barFrame = CreateFrame("Frame", "ReBar"..id, config.parent and getglobal(config.parent) or UIParent, "ReBarTemplate") + local name = "ReBar"..id + self.barFrame = CreateFrame("Frame", name, config.parent and getglobal(config.parent) or UIParent, "ReBarTemplate") self.controlFrame = getglobal(self.barFrame:GetName().."Controls") self.controlFrame.reBar = self self.barFrame:SetClampedToScreen(true) + -- get references to sub-frames + self.labelString = getglobal(name.."ControlsLabelString") + self.upArrow = getglobal(name.."PageUp") + self.downArrow = getglobal(name.."PageDown") + self.pageNum = getglobal(name.."PageNumber") + -- set the text label on the control widget - self.labelString = getglobal(self.controlFrame:GetName().."LabelString") self.labelString:SetText(id) -- initial stateheader state @@ -178,8 +184,8 @@ -- register page up/down buttons with ReBound for keybinding if ReBound then - ReBound:AddKeybindTarget(getglobal(self.barFrame:GetName().."PageUp")) - ReBound:AddKeybindTarget(getglobal(self.barFrame:GetName().."PageDown")) + ReBound:AddKeybindTarget(self.upArrow) + ReBound:AddKeybindTarget(self.downArrow) end -- add bar to anchorTargets list @@ -281,19 +287,6 @@ self:ApplyVisibility() end -function ReBar.prototype:GetOpacity() - return tonumber(self.config.opacity) or 100 -end - -function ReBar.prototype:SetOpacity( o ) - o = tonumber(o) - if o then - self.config.opacity = o - self:ApplyVisibility() - return self.config.opacity - end -end - function ReBar.prototype:GetButtonList() return self.buttons end @@ -378,20 +371,19 @@ function ReBar.prototype:ApplyAutoStanceSwitch() local switch = self:GetAutoStanceSwitch() - local _, class = UnitClass("player") if switch then -- check that the number of pages available is sufficient - local totalPages = nStancePages[class] + (self:GetAutoStealthSwitch() and 1 or 0) + local totalPages = nStancePages[playerClass] + (self:GetAutoStealthSwitch() and 1 or 0) if self:GetPages() < totalPages then self:SetPages(totalPages) end - for form, spec in pairs(stanceMaps[class]) do + for form, spec in pairs(stanceMaps[playerClass]) do self.barFrame:SetAttribute("statemap-stance-"..form,spec) end -- set initial value self.barFrame:SetAttribute("state-stance",GetShapeshiftForm(true)) else - for form, _ in pairs(stanceMaps[class]) do + for form, _ in pairs(stanceMaps[playerClass]) do self.barFrame:SetAttribute("statemap-stance-"..form, ATTRIBUTE_NOOP) end end @@ -415,21 +407,20 @@ function ReBar.prototype:ApplyAutoStealthSwitch() local switch = self:GetAutoStealthSwitch() - local _, class = UnitClass("player") if switch then -- check that the number of pages available is sufficient - local totalPages = (self:GetAutoStanceSwitch() and nStancePages[class] > 0 and nStancePages[class] or 1) + 1 + local totalPages = (self:GetAutoStanceSwitch() and nStancePages[playerClass] > 0 and nStancePages[playerClass] or 1) + 1 if self:GetPages() < totalPages then self:SetPages(totalPages) end local s, s2 - if class == "DRUID" and not self:GetAutoStanceSwitch() then + if playerClass == "DRUID" and not self:GetAutoStanceSwitch() then -- change mapping for cat->prowl and prowl->cat to 1:2 and 2:1 since no stance mapping s = "1:2" s2 = "2:1" end - self.barFrame:SetAttribute("statemap-stealth-1",s or stealthMaps[class]) - self.barFrame:SetAttribute("statemap-stealth-0",s2 or unstealthMaps[class]) + self.barFrame:SetAttribute("statemap-stealth-1",s or stealthMaps[playerClass]) + self.barFrame:SetAttribute("statemap-stealth-0",s2 or unstealthMaps[playerClass]) -- set initial value self.barFrame:SetAttribute("state-stealth",IsStealthed() or 0) else @@ -462,13 +453,16 @@ function ReBar.prototype:RefreshPageControls() local b = self.barFrame; - local upArrow = getglobal(b:GetName().."PageUp") - local downArrow = getglobal(b:GetName().."PageDown") - local pageNum = getglobal(b:GetName().."PageNumber") + local upArrow = self.upArrow + local downArrow = self.downArrow + local pageNum = self.pageNum if self:GetPages() > 1 and self.config.pages.showControls then local loc = self.config.pages.controlsLoc + upArrow:SetAttribute("hidestates",nil) + downArrow:SetAttribute("hidestates",nil) + pageNum:ClearAllPoints() upArrow:ClearAllPoints() downArrow:ClearAllPoints() @@ -519,6 +513,9 @@ downArrow:Show() pageNum:Show() else + upArrow:SetAttribute("hidestates","1-"..self:GetPages()) + downArrow:SetAttribute("hidestates","1-"..self:GetPages()) + upArrow:Hide() downArrow:Hide() pageNum:Hide() @@ -566,10 +563,6 @@ function ReBar.prototype:ApplyVisibility() local v = self.config.visible or not self.locked - if tonumber(self.config.opacity) then - self.barFrame:SetAlpha(self.config.opacity / 100) - end - if v then self.barFrame:Show() else @@ -831,3 +824,4 @@ GameTooltip:AddLine("Drag to add/remove buttons") GameTooltip:Show() end +