Mercurial > wow > reaction
changeset 174:09f7af2f53f8
Pretty totem bar textures
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 20 Oct 2010 00:41:10 +0000 |
parents | 49d49063cb79 |
children | df68b5a40490 |
files | classes/MultiCastButton.lua |
diffstat | 1 files changed, 122 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/classes/MultiCastButton.lua Tue Oct 19 22:07:21 2010 +0000 +++ b/classes/MultiCastButton.lua Wed Oct 20 00:41:10 2010 +0000 @@ -52,7 +52,11 @@ this is to slightly optimize texture load performance, but it makes the UI code more clumsy. Each totem button and arrow has a colored border indicating its elemental type. - TODO: update code to use these pretty per-slot icons, or start setting a border. + + TODO: + - make whether to show the colored border configurable (looks really bad with ButtonFacade:Zoomed) + - apply ButtonFacade to the flyout buttons? Or at least zoom the textures slightly? + - use a multiplier with SetTexCoord on totem bar texture? Design Notes: - Only the header has a secure context. All other frames execute in its context. @@ -149,9 +153,15 @@ local _arrow_openFlyout = -- function(self) [[ local slot = self:GetAttribute("bar-idx") + local totemID = totemIDsBySlot[slot - (summonSlot or 0)] + if totemID == 0 then + totemID = "summon" + end + local lastButton, lastPage for page, b in ipairs(flyoutChildren) do b:Hide() + b:SetAttribute("totemSlot",totemID) if slot == summonSlot then local spellID = self:GetParent():GetAttribute("spell-page"..page) if spellID then @@ -162,8 +172,6 @@ lastPage = page end else - local offset = summonSlot or 0 - local totemID = totemIDsBySlot[slot - offset] local spell = select(page, 0, GetMultiCastTotemSpells(totemID) ) if spell then b:SetAttribute("type","multispell") @@ -181,6 +189,7 @@ close:ClearAllPoints() close:SetPoint("BOTTOM",lastButton,"TOP",0,0) -- TODO: better anchoring close:Show() + control:CallMethod("UpdateFlyoutTextures",totemID) end flyout:ClearAllPoints() @@ -224,14 +233,57 @@ -- -- The Blizzard totem bar textures are all actually one big texture, --- with texcoord offsets +-- with texcoord offsets. Shamelessly stolen from FrameXML/MultiCastActionBarFrame.lua -- local TOTEM_TEXTURE = "Interface\\Buttons\\UI-TotemBar" -local FLYOUT_UP_BUTTON_TCOORDS = { 99/128, 127/128, 84/256, 102/256 } local FLYOUT_UP_BUTTON_HL_TCOORDS = { 72/128, 92/128, 88/256, 98/256 } -local FLYOUT_DOWN_BUTTON_TCOORDS = { 99/128, 127/128, 65/256, 83/256 } local FLYOUT_DOWN_BUTTON_HL_TCOORDS = { 72/128, 92/128, 69/256, 79/256 } -local EMPTY_SLOT_TCOORDS = { 66/128, 96/128, 3/256, 33/256 } + +local SLOT_EMPTY_TCOORDS = { + [EARTH_TOTEM_SLOT] = { 66/128, 96/128, 3/256, 33/256 }, + [FIRE_TOTEM_SLOT] = { 67/128, 97/128, 100/256, 130/256 }, + [WATER_TOTEM_SLOT] = { 39/128, 69/128, 209/256, 239/256 }, + [AIR_TOTEM_SLOT] = { 66/128, 96/128, 36/256, 66/256 }, +} + +local SLOT_OVERLAY_TCOORDS = { + [EARTH_TOTEM_SLOT] = { 1/128, 35/128, 172/256, 206/256 }, + [FIRE_TOTEM_SLOT] = { 36/128, 70/128, 172/256, 206/256 }, + [WATER_TOTEM_SLOT] = { 1/128, 35/128, 207/256, 240/256 }, + [AIR_TOTEM_SLOT] = { 36/128, 70/128, 137/256, 171/256 }, +} + +local FLYOUT_UP_BUTTON_TCOORDS = { + ["summon"] = { 99/128, 127/128, 84/256, 102/256 }, + [EARTH_TOTEM_SLOT] = { 99/128, 127/128, 160/256, 178/256 }, + [FIRE_TOTEM_SLOT] = { 99/128, 127/128, 122/256, 140/256 }, + [WATER_TOTEM_SLOT] = { 99/128, 127/128, 199/256, 217/256 }, + [AIR_TOTEM_SLOT] = { 99/128, 127/128, 237/256, 255/256 }, +} + +local FLYOUT_DOWN_BUTTON_TCOORDS = { + ["summon"] = { 99/128, 127/128, 65/256, 83/256 }, + [EARTH_TOTEM_SLOT] = { 99/128, 127/128, 141/256, 159/256 }, + [FIRE_TOTEM_SLOT] = { 99/128, 127/128, 103/256, 121/256 }, + [WATER_TOTEM_SLOT] = { 99/128, 127/128, 180/256, 198/256 }, + [AIR_TOTEM_SLOT] = { 99/128, 127/128, 218/256, 236/256 }, +} + +local FLYOUT_TOP_TCOORDS = { + ["summon"] = { 33/128, 65/128, 1/256, 23/256 }, + [EARTH_TOTEM_SLOT] = { 0/128, 32/128, 46/256, 68/256 }, + [FIRE_TOTEM_SLOT] = { 33/128, 65/128, 46/256, 68/256 }, + [WATER_TOTEM_SLOT] = { 0/128, 32/128, 1/256, 23/256 }, + [AIR_TOTEM_SLOT] = { 0/128, 32/128, 91/256, 113/256 }, +} + +local FLYOUT_MIDDLE_TCOORDS = { + ["summon"] = { 33/128, 65/128, 23/256, 43/256 }, + [EARTH_TOTEM_SLOT] = { 0/128, 32/128, 68/256, 88/256 }, + [FIRE_TOTEM_SLOT] = { 33/128, 65/128, 68/256, 88/256 }, + [WATER_TOTEM_SLOT] = { 0/128, 32/128, 23/256, 43/256 }, + [AIR_TOTEM_SLOT] = { 0/128, 32/128, 113/256, 133/256 }, +} local eventList = { "ACTIONBAR_SLOT_CHANGED", @@ -291,11 +343,22 @@ local offset = bar.summonSlot and 1 or 0 local slot = SHAMAN_TOTEM_PRIORITIES[idx - offset] local baseAction = barFrame:GetAttribute("baseActionID") + slot + self.totemSlot = slot f:SetAttribute("type","action") f:SetAttribute("action", baseAction + (page - 1) * NUM_MULTI_CAST_BUTTONS_PER_PAGE) for i = 1, NUM_MULTI_CAST_PAGES do f:SetAttribute("action-page"..i, baseAction + (i-1) * NUM_MULTI_CAST_BUTTONS_PER_PAGE) end + if not f.overlayTex then + local tx = f:CreateTexture("OVERLAY") + tx:SetTexture(TOTEM_TEXTURE) + tx:SetTexCoord(unpack(SLOT_OVERLAY_TCOORDS[self.totemSlot])) + tx:SetWidth(34) + tx:SetHeight(34) + tx:SetPoint("CENTER") + tx:Show() + f.overlayTex = tx + end end f:SetAttribute("bar-idx",idx) @@ -320,12 +383,12 @@ end -- Set up a proxy for the icon texture for use with ButtonFacade - self.frames.icon.SetTexCoordRaw = self.frames.icon.SetTexCoord + local SetTexCoordRaw = self.frames.icon.SetTexCoord self.frames.icon.SetTexCoord = function( tx, ... ) if self:GetIconTexture() == TOTEM_TEXTURE then - tx:SetTexCoordRaw(unpack(EMPTY_SLOT_TCOORDS)) + SetTexCoordRaw(tx,select(2,self:GetIconTexture())) else - tx:SetTexCoordRaw(...) + SetTexCoordRaw(tx,...) end end @@ -334,14 +397,16 @@ f:Show() - -- open arrow + -- open arrow and flyout background textures if idx ~= bar.recallSlot then - local arrow = CreateFrame("Button", nil, f, "SecureFrameTemplate") + local arrow = f._arrowFrame or CreateFrame("Button", nil, f, "SecureFrameTemplate") + f._arrowFrame = arrow arrow:SetWidth(28) - arrow:SetHeight(12) + arrow:SetHeight(18) arrow:SetPoint("BOTTOM",self:GetFrame(),"TOP",0,0) -- TODO: better anchoring arrow:SetNormalTexture(TOTEM_TEXTURE) - arrow:GetNormalTexture():SetTexCoord( unpack(FLYOUT_UP_BUTTON_TCOORDS) ) + local slot = self.totemSlot or "summon" + arrow:GetNormalTexture():SetTexCoord( unpack(FLYOUT_UP_BUTTON_TCOORDS[slot]) ) arrow:SetHighlightTexture(TOTEM_TEXTURE) arrow:GetHighlightTexture():SetTexCoord( unpack(FLYOUT_UP_BUTTON_HL_TCOORDS) ) arrow:SetAttribute("bar-idx",idx) @@ -356,7 +421,12 @@ end function MultiCast:Destroy() - local barFrame = self:GetFrame() + local barFrame = self.bar:GetFrame() + local f = self:GetFrame() + pcall( barFrame.UnwrapScript, barFrame, f, "OnEnter" ) -- ignore errors + if f._arrowFrame then + pcall( barFrame.UnwrapScript, barFrame, f._arrowFrame,"OnClick" ) -- ignore errors + end Super.Destroy(self) end @@ -414,7 +484,7 @@ if tx then return tx else - return TOTEM_TEXTURE, unpack(EMPTY_SLOT_TCOORDS) + return TOTEM_TEXTURE, unpack(SLOT_EMPTY_TCOORDS[self.totemSlot or 1]) end end @@ -516,7 +586,8 @@ local spellID = frame:GetAttribute("spell") if spellID == 0 or spellID == nil then frame.icon:SetTexture(TOTEM_TEXTURE) - frame.icon:SetTexCoord( unpack(EMPTY_SLOT_TCOORDS) ) + local slot = tonumber(frame:GetAttribute("totemSlot")) or 1 + frame.icon:SetTexCoord( unpack(SLOT_EMPTY_TCOORDS[slot]) ) else frame.icon:SetTexture(GetSpellTexture(GetSpellInfo(spellID))) frame.icon:SetTexCoord(0,1,0,1) @@ -594,14 +665,41 @@ local close = CreateFrame("Button", nil, flyout, "SecureFrameTemplate") close:SetWidth(28) - close:SetHeight(12) - close:SetPoint("TOP") + close:SetHeight(18) + close:SetPoint("BOTTOM",flyout,"TOP") close:SetNormalTexture(TOTEM_TEXTURE) - close:GetNormalTexture():SetTexCoord( unpack(FLYOUT_DOWN_BUTTON_TCOORDS) ) + close:GetNormalTexture():SetTexCoord(unpack(FLYOUT_DOWN_BUTTON_TCOORDS["summon"])) close:SetHighlightTexture(TOTEM_TEXTURE) close:GetHighlightTexture():SetTexCoord( unpack(FLYOUT_DOWN_BUTTON_HL_TCOORDS) ) f:SetFrameRef("close",close) f:WrapScript(close, "OnClick", _closeFlyout) + close:Show() + + local midTx = flyout:CreateTexture("BACKGROUND") + midTx:SetWidth(32) + midTx:SetHeight(20) + midTx:SetPoint("BOTTOM") + midTx:SetTexture(TOTEM_TEXTURE) + midTx:SetTexCoord(unpack(FLYOUT_MIDDLE_TCOORDS["summon"])) + midTx:Show() + + local topTx = flyout:CreateTexture("BACKGROUND") + topTx:SetWidth(32) + topTx:SetHeight(20) + topTx:SetTexture(TOTEM_TEXTURE) + midTx:SetTexCoord(unpack(FLYOUT_TOP_TCOORDS["summon"])) + topTx:SetPoint("BOTTOM",midTx,"TOP",0,-10) + topTx:Show() + + function flyout:UpdateTextures(slot) + slot = slot or "summon" + close:GetNormalTexture():SetTexCoord(unpack(FLYOUT_DOWN_BUTTON_TCOORDS[slot])) + midTx:ClearAllPoints() + midTx:SetPoint("BOTTOM") + midTx:SetPoint("TOP",close,"BOTTOM",0,0) + midTx:SetTexCoord(unpack(FLYOUT_MIDDLE_TCOORDS[slot])) + topTx:SetTexCoord(unpack(FLYOUT_TOP_TCOORDS[slot])) + end -- create flyout buttons for i = 1, 10 do -- maximum 9 spells + 1 empty slot @@ -632,6 +730,10 @@ end end + function f:UpdateFlyoutTextures(slot) + flyout:UpdateTextures(slot) + end + f:Execute(_bar_init) end