View Single Post
01-28-11, 04:42 AM   #23
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Kendian View Post
I hate to ask, Nibleheim, seeing as you've already repaired everything that I was unable to in my personal ui......but, would you happen to know the script, to call a panel based on stance? I.e., bear form, cat form, prot spec/ret spec, aspect of the suck (cheetah) etc? I would be ever so grateful, and would send loads of cookies.
Alright, this took me ages to type out, bleh!

To set color based on stance:

-- OnLoad
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
-- OnEvent
Code:
if not self.StanceTable then
	self.StanceTable = {
		["DEATHKNIGHT"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Blood Presence
			[2] = {r = 1, g = 1, b = 1},	-- Frost Presence
			[3] = {r = 1, g = 1, b = 1},	-- Unholy Presence 
		},
		["DRUID"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Bear/Dire Bear Form
			[2] = {r = 1, g = 1, b = 1},	-- Aquatic Form
			[3] = {r = 1, g = 1, b = 1},	-- Cat Form
			[4] = {r = 1, g = 1, b = 1},	-- Travel Form
			[5] = {r = 1, g = 1, b = 1},	-- Moonkin/Tree Form (Unless feral. If no moonkin/tree form present, (swift) flight form is form 5)
			[6] = {r = 1, g = 1, b = 1},	-- Flight Form 
		},
		["PALADIN"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Devotion Aura
			[2] = {r = 1, g = 1, b = 1},	-- Retribution Aura
			[3] = {r = 1, g = 1, b = 1},	-- Concentration Aura
			[4] = {r = 1, g = 1, b = 1},	-- Shadow Resistance Aura
			[5] = {r = 1, g = 1, b = 1},	-- Frost Resistance Aura
			[6] = {r = 1, g = 1, b = 1},	-- Fire Resistance Aura
			[7] = {r = 1, g = 1, b = 1},	-- Crusader Aura
		},
		["PRIEST"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Shadowform 
		},
		["ROGUE"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Stealth
		},
		["SHAMAN"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Ghost Wolf
		},
		["WARRIOR"] = {
			[1] = {r = 1, g = 1, b = 1},	-- Battle Stance
			[2] = {r = 1, g = 1, b = 1},	-- Defensive Stance
			[3] = {r = 1, g = 1, b = 1},	-- Berserker Stance 
		},
	}
end

local Stance = GetShapeshiftForm()
local _, Class = UnitClass("player")
local Color = {r = 1, g = 1, b = 1}

if Stance > 0 then
	Color = self.StanceTable[Class][Stance]
end

self.bg:SetVertexColor(Color.r, Color.g, Color.b, self.bg:GetAlpha())
Note, you'll have to set all the colors in the table. Values are between 0 and 1.


To show a panel based on stance:

-- OnLoad
Code:
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM")
self:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
-- OnEvent
Code:
local DefaultFrame = kgPanels:FetchFrame("MyDefaultPanelName")
if not self.StanceTable then
	self.StanceTable = {
		["DEATHKNIGHT"] = {
			[1] = "MyPanelName",	-- Blood Presence
			[2] = "MyPanelName",	-- Frost Presence
			[3] = "MyPanelName",	-- Unholy Presence 
		},
		["DRUID"] = {
			[1] = "MyPanelName",	-- Bear/Dire Bear Form
			[2] = "MyPanelName",	-- Aquatic Form
			[3] = "MyPanelName",	-- Cat Form
			[4] = "MyPanelName",	-- Travel Form
			[5] = "MyPanelName",	-- Moonkin/Tree Form (Unless feral. If no moonkin/tree form present, (swift) flight form is form 5)
			[6] = "MyPanelName",	-- Flight Form 
		},
		["PALADIN"] = {
			[1] = "MyPanelName",	-- Devotion Aura
			[2] = "MyPanelName",	-- Retribution Aura
			[3] = "MyPanelName",	-- Concentration Aura
			[4] = "MyPanelName",	-- Shadow Resistance Aura
			[5] = "MyPanelName",	-- Frost Resistance Aura
			[6] = "MyPanelName",	-- Fire Resistance Aura
			[7] = "MyPanelName",	-- Crusader Aura
		},
		["PRIEST"] = {
			[1] = "MyPanelName",	-- Shadowform 
		},
		["ROGUE"] = {
			[1] = "MyPanelName",	-- Stealth
		},
		["SHAMAN"] = {
			[1] = "MyPanelName",	-- Ghost Wolf
		},
		["WARRIOR"] = {
			[1] = "MyPanelName",	-- Battle Stance
			[2] = "MyPanelName",	-- Defensive Stance
			[3] = "MyPanelName",	-- Berserker Stance 
		},
	}
end

local Stance = GetShapeshiftForm()
local _, Class = UnitClass("player")

local ShowFrame
if Stance == 0 then
	ShowFrame = DefaultFrame
else
	ShowFrame = kgPanels:FetchFrame(self.StanceTable[Class][Stance])
end

if ( self.LastShownFrame and self.LastShownFrame ~= ShowFrame ) then
	self.LastShownFrame:Hide()
elseif ShowFrame ~= DefaultFrame then
	DefaultFrame:Hide()
end

ShowFrame:Show()
self.LastShownFrame = ShowFrame
You'll have to change all the MyPanelName to the names of the panels in kgPanels you want to show/hide.


Edit: All this is completely untested, but hopefully it works and/or it'll provide a base for you to get it to work. I think I'm out of here
  Reply With Quote