Thread Tools Display Modes
08-23-10, 06:18 PM   #1
blkdrgn
A Warpwood Thunder Caller
 
blkdrgn's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 91
Looking for help.

Hello, I am looking to have very very minimal nameplates.

I have permission from an author to modify however i cannot figure out a few things in the lua. If anyone is interested in helping me , please send me a PM for more details..

Thank you.
__________________
Missconfused 80 Dk
Missbehavied 80 Hunter
Missconduct 80 Rogue
Missconstrew 80 Mage
-Many other lower level alts=)
  Reply With Quote
08-23-10, 07:35 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Generally if you want help with code, the best thing to do is post the code, and explain what you're having trouble with. Everyone who reads/posts on these forums does so as a hobby in their spare time. Not only is it unlikely that you'll find someone who wants to provide free private one-on-one programming tutoring, but taking things like this to private messages defeats the whole point of having a forum community in the first place.
  Reply With Quote
08-23-10, 07:46 PM   #3
blkdrgn
A Warpwood Thunder Caller
 
blkdrgn's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 91
That makes sense.

I will get the exact lines here in a bit..
__________________
Missconfused 80 Dk
Missbehavied 80 Hunter
Missconduct 80 Rogue
Missconstrew 80 Mage
-Many other lower level alts=)
  Reply With Quote
08-24-10, 06:58 AM   #4
blkdrgn
A Warpwood Thunder Caller
 
blkdrgn's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 91
Basically what I am trying to do is strip down these nameplates to a bear minimum. I am trying to get rid of the cast bar/class icons/different values for bars (one bar color for all), anything that is not a health bar.


I have already removed a lot of things, but now its at the point where the two things I am trying to remove i can not. I am trying to learn more lua as I go, but I am down to missing ends, and things that I simply cannot figure out.



Code:
local barcolor = {.6,.6,.6}
local fontsize = 9
local font = [[Interface\AddOns\bdmedia\CalibriBold.ttf]]
local statusbar = [[Interface\AddOns\bdmedia\bdtex2]]
local solid = [[Interface\AddOns\BDNplates\solid2]]
local flags = ""


local numkids, lastupdate, select = 0, 0, select
local f = CreateFrame("Frame")
local backdrop = {
	edgeFile = nil, edgeSize = 0,
	insets = {left = 3, right = 3, top = 3, bottom = 3}
}

local function GetClass(r, g, b)
	local r, g, b = floor(r*100+.5)/100, floor(g*100+.5)/100, floor(b*100+.5)/100
	for class, color in pairs(RAID_CLASS_COLORS) do
		if RAID_CLASS_COLORS[class].r == r and RAID_CLASS_COLORS[class].g == g and RAID_CLASS_COLORS[class].b == b then
			return class
		end
	end
	return 0
end

local function ClassIconTexCoord(r, g, b)
	class = GetClass(r,g,b)
	if not (class==0) then
		local texcoord = CLASS_BUTTONS[class]
		if (texcoord) then
			return unpack(texcoord)
		end
	end
	return 0.5, 0.75, 0.5, 0.75
end

local isvalidframe = function(frame)
	if frame:GetName() then
		return
	end
	overlayRegion = select(2, frame:GetRegions())
	return overlayRegion and overlayRegion:GetObjectType() == "Texture" and overlayRegion:GetTexture() == "Interface\\Tooltips\\Nameplate-Border"
end

local function updatetime(self, curValue)
	local minValue, maxValue = self:GetMinMaxValues()
	if self.channeling then
		self.time:SetFormattedText("%.1f ", curValue)
	else
		self.time:SetFormattedText("%.1f ", maxValue - curValue)
	end
end

local ThreatUpdate = function(self, elapsed)
	self.elapsed = self.elapsed + elapsed
	if self.elapsed >= 0.2 then
		if not self.oldglow:IsShown() then
			self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
		else
			self.healthBar.hpGlow:SetBackdropBorderColor(self.oldglow:GetVertexColor())
		end
		self.healthBar:SetStatusBarColor(self.r, self.g, self.b)
		self.elapsed = 0
	end
end
local UpdateFrame = function(self)	
	SetCVar("ShowClassColorInNameplate", 1)
	local r, g, b = self.healthBar:GetStatusBarColor()
	
	newr, newg, newb = unpack(barcolor)
	self.icon:SetTexCoord(ClassIconTexCoord(r, g, b))
	
	self.healthBar:SetStatusBarColor(unpack(barcolor))
	
	self.r, self.g, self.b = newr, newg, newb	
	
	self.healthBar:ClearAllPoints()
	self.healthBar:SetPoint("CENTER", self.healthBar:GetParent())
	self.healthBar:SetHeight(10)
	self.healthBar:SetWidth(100)

	self.castBar:ClearAllPoints()
	self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -4)
	self.castBar:SetHeight(5)
	self.castBar:SetWidth(100)

	self.highlight:ClearAllPoints()
	self.highlight:SetAllPoints(self.healthBar)
	self.overlay:SetAllPoints(self.healthBar)

	self.name:SetText(self.oldname:GetText())
	self.name:SetTextColor(r, g, b)

	local level, elite, mylevel = tonumber(self.level:GetText()), self.elite:IsShown(), UnitLevel("player")
	self.level:ClearAllPoints()
	self.level:SetPoint("RIGHT", self.healthBar, "LEFT", -2, 1)
	if self.boss:IsShown() then
		self.level:SetText("B")
		self.level:SetTextColor(0.8, 0.05, 0)
		self.level:Show()
	else
		self.level:SetText(level..(elite and "+" or ""))
	end
end

local FixCastbar = function(self)
	self.castbarOverlay:Hide()
	self:SetHeight(5)
	self:ClearAllPoints()
	self:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -4)
end

local ColorCastBar = function(self, shielded)
	if shielded then
		self:SetStatusBarColor(0.8, 0.05, 0)
		self.cbGlow:SetBackdropBorderColor(0.75, 0.75, 0.75)
	else
		self.cbGlow:SetBackdropBorderColor(0, 0, 0)
	end
end

local OnSizeChanged = function(self)
	self.needFix = true
end

local OnValueChanged = function(self, curValue)
	updatetime(self, curValue)
	if self.needFix then
		FixCastbar(self)
		self.needFix = nil
	end
end

local OnShow = function(self)
	self.channeling  = UnitChannelInfo("target") 
	FixCastbar(self)
	ColorCastBar(self, self.shieldedRegion:IsShown())
end

local OnHide = function(self)
	self.highlight:Hide()
	self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
end

local OnEvent = function(self, event, unit)
	if unit == "target" then
		if self:IsShown() then
			ColorCastBar(self, event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
		end
	end
end

local CreateFrame = function(frame)
	if frame.done then
		return
	end
	frame.nameplate = true
	frame.healthBar, frame.castBar = frame:GetChildren()
	local r, g, b = frame.healthBar:GetStatusBarColor()
	local healthBar, castBar = frame.healthBar, frame.castBar
	local glowRegion, overlayRegion, castbarOverlay, shieldedRegion, spellIconRegion, highlightRegion, nameTextRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame:GetRegions()
	
	frame.overlay = overlayRegion
	
	frame.oldname = nameTextRegion
	nameTextRegion:Hide()
	
	local newNameRegion = frame:CreateFontString()
	newNameRegion:SetPoint("BOTTOM", healthBar, "TOP", 0, 3)
	newNameRegion:SetFont(font, fontsize, flags)
	frame.name = newNameRegion
	
	frame.border = CreateFrame("Frame", nil, frame.healthBar)
	frame.border:SetAllPoints(healthBar)
	frame.border:SetBackdrop( { 
		bgFile = nil, 
		edgeFile = solid, 
		tile = false, tileSize = 0, edgeSize = 1, 
		insets = { left = -1, right = -1, top = -1, bottom = -1 }
	})
	frame.border:SetBackdropBorderColor(unpack(barcolor))

	local classicontexture = frame:CreateTexture(nil, "OVERLAY")
	classicontexture:SetPoint("BOTTOM", healthBar, "TOP", 0, 10)
	classicontexture:SetTexture("Interface\\WorldStateFrame\\Icons-Classes")
	classicontexture:SetWidth(40)
	classicontexture:SetHeight(40)
	frame.icon = classicontexture
	
	frame.level = levelTextRegion
	levelTextRegion:SetFont(font, fontsize, flags)	
	frame.level:SetShadowOffset(0,0)
	
	local f = CreateFrame("Frame")
	f:RegisterEvent("PLAYER_REGEN_ENABLED")
	f:SetScript("OnEvent", function()
		frame:SetHeight(10)
		frame:SetWidth(100)
	end)
 
	if not InCombatLockdown() then
		frame:SetHeight(10)
		frame:SetWidth(100)
	end
	
	healthBar:SetStatusBarTexture(statusbar)

	healthBar.hpBackground = healthBar:CreateTexture(nil, "BORDER")
	healthBar.hpBackground:SetAllPoints(healthBar)
	healthBar.hpBackground:SetTexture(statusbar)
	healthBar.hpBackground:SetVertexColor(0.15, 0.15, 0.15)

	healthBar.hpGlow = CreateFrame("Frame", nil, healthBar)
	healthBar.hpGlow:SetPoint("TOPLEFT", healthBar, "TOPLEFT", -4.5, 4)
	healthBar.hpGlow:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", 4.5, -4.5)
	healthBar.hpGlow:SetBackdrop(backdrop)
	healthBar.hpGlow:SetBackdropColor(0, 0, 0)
	healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)

	castBar.castbarOverlay = castbarOverlay
	castBar.healthBar = healthBar
	castBar.shieldedRegion = shieldedRegion
	castBar:SetStatusBarTexture(statusbar)

	castBar:HookScript("OnShow", OnShow)
	castBar:HookScript("OnSizeChanged", OnSizeChanged)
	castBar:HookScript("OnValueChanged", OnValueChanged)
	castBar:HookScript("OnEvent", OnEvent)
	castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
	castBar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")

	castBar.time = castBar:CreateFontString(nil, "ARTWORK")
	castBar.time:SetPoint("RIGHT", castBar, "LEFT", -2, 1)
	castBar.time:SetFont(font, fontsize, flags)
	castBar.time:SetTextColor(0.84, 0.75, 0.65)
	castBar.time:SetShadowOffset(1.25, -1.25)

	castBar.cbBackground = castBar:CreateTexture(nil, "BORDER")
	castBar.cbBackground:SetAllPoints(castBar)
	castBar.cbBackground:SetTexture(statusbar)
	castBar.cbBackground:SetVertexColor(0.15, 0.15, 0.15)

	castBar.cbGlow = CreateFrame("Frame", nil, castBar)
	castBar.cbGlow:SetPoint("TOPLEFT", castBar, "TOPLEFT", -4.5, 4)
	castBar.cbGlow:SetPoint("BOTTOMRIGHT", castBar, "BOTTOMRIGHT", 4.5, -4.5)
	castBar.cbGlow:SetBackdrop(backdrop)
	castBar.cbGlow:SetBackdropColor(0, 0, 0)
	castBar.cbGlow:SetBackdropBorderColor(0, 0, 0)

	spellIconRegion:SetHeight(0.01)
	spellIconRegion:SetWidth(0.01)
	
	highlightRegion:SetTexture(statusbar)
	highlightRegion:SetVertexColor(0.25, 0.25, 0.25)
	frame.highlight = highlightRegion

	raidIconRegion:ClearAllPoints()
	raidIconRegion:SetPoint("LEFT", healthBar, "RIGHT", 2, 0)
	raidIconRegion:SetHeight(15)
	raidIconRegion:SetWidth(15)

	frame.oldglow = glowRegion
	frame.elite = stateIconRegion
	frame.boss = bossIconRegion

	frame.done = true

	glowRegion:SetTexture(nil)
	overlayRegion:SetTexture(nil)
	shieldedRegion:SetTexture(nil)
	castbarOverlay:SetTexture(nil)
	stateIconRegion:SetTexture(nil)
	bossIconRegion:SetTexture(nil)

	UpdateFrame(frame)
	frame:SetScript("OnShow", UpdateFrame)
	frame:SetScript("OnHide", OnHide)

	frame.elapsed = 0
	frame:SetScript("OnUpdate", ThreatUpdate)
end


local function OnUpdate(self, elapsed)
	lastupdate = lastupdate + elapsed
	if lastupdate > 0.1 then
		lastupdate = 0
		if WorldFrame:GetNumChildren() ~= numkids then
			numkids = WorldFrame:GetNumChildren()
			for i = 1, select("#", WorldFrame:GetChildren()) do
				frame = select(i, WorldFrame:GetChildren())
				if isvalidframe(frame) then
					CreateFrame(frame)
				end
			end
		end
	end
end

f:SetScript("OnUpdate", OnUpdate)
f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
__________________
Missconfused 80 Dk
Missbehavied 80 Hunter
Missconduct 80 Rogue
Missconstrew 80 Mage
-Many other lower level alts=)

Last edited by blkdrgn : 08-24-10 at 07:01 AM.
  Reply With Quote
08-24-10, 09:48 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, you can get rid of the cast bars by simply turning off the "Show cast bars on nameplates" option in the default UI.

To get rid of the class icon, just delete all the parts that refer to it:
Code:
	local classicontexture = frame:CreateTexture(nil, "OVERLAY")
	classicontexture:SetPoint("BOTTOM", healthBar, "TOP", 0, 10)
	classicontexture:SetTexture("Interface\\WorldStateFrame\\Icons-Classes")
	classicontexture:SetWidth(40)
	classicontexture:SetHeight(40)
	frame.icon = classicontexture

self.icon:SetTexCoord(ClassIconTexCoord(r, g, b))

local function ClassIconTexCoord(r, g, b)
	class = GetClass(r,g,b)
	if not (class==0) then
		local texcoord = CLASS_BUTTONS[class]
		if (texcoord) then
			return unpack(texcoord)
		end
	end
	return 0.5, 0.75, 0.5, 0.75
end

local function GetClass(r, g, b)
	local r, g, b = floor(r*100+.5)/100, floor(g*100+.5)/100, floor(b*100+.5)/100
	for class, color in pairs(RAID_CLASS_COLORS) do
		if RAID_CLASS_COLORS[class].r == r and RAID_CLASS_COLORS[class].g == g and RAID_CLASS_COLORS[class].b == b then
			return class
		end
	end
	return 0
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Looking for help.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off