Thread Tools Display Modes
03-13-13, 11:11 PM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
XP Bar Text post 5.2

The way the XP looks before 5.2

Post 5.2 it's just thew grey bar from what my roommate told me.

source code I've been using since..... I forget when.

I was aware they changed the unitframe text, but not the XP bar. Would like to figure out how to get it to even work with the in game option for enabling/disabling the text. Then again I could probably figure it out if I allowed myself to login, but I gave up online gaming for lent (terrible choice by the way, I don't recommend it).
__________________
Tweets YouTube Website
  Reply With Quote
03-14-13, 03:52 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by 10leej View Post
I gave up online gaming for lent (terrible choice by the way, I don't recommend it).
Well, as I understand it, whatever you give up is supposed to be something that feels like a big sacrifice to go without, so that sounds like a good choice actually.

Anyway, I don't have time to read all your code at the moment, but my personal XP bar mod has been working without any issues since some time back in BC, so I'm fairly confident nothing has changed. Are there any error messages? Does the bar work other than being the wrong color? etc.

Maybe you should just have your roommate post... posting on an online gaming forum seems like it might be against the spirit of your Lent sacrifice.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-14-13, 12:48 PM   #3
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Why you have to be so cruel?

Anyways to my understanding no errors, what mod are you using?
__________________
Tweets YouTube Website
  Reply With Quote
03-14-13, 01:58 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, it was originally jExp, but I basically rewrote it because the original code was too messy. The only parts that have changed in the last 3-4 years are the texture paths, color values, and bar height. It's currently huge because I'm using it as a backdrop for my Broker bar.

Code:
local BAR_TEXTURE = "Interface\\AddOns\\PhanxMedia\\statusbar\\Savant1"
local XP_COLOR   = { r = 0.2, g = 0,    b = 0.5 }
local REST_COLOR = { r = 0,   g = 0.25, b = 0.6 }

local f = CreateFrame("Frame", "jExp", UIParent)
f:SetFrameStrata("LOW")
f:SetPoint("BOTTOMLEFT", UIParent)
f:SetPoint("BOTTOMRIGHT", UIParent)
f:SetHeight(35)

local bg = f:CreateTexture(nil, "BACKGROUND")
bg:SetTexture(BAR_TEXTURE)
bg:SetVertexColor(0.1, 0.1, 0.1)
bg:SetPoint("BOTTOMLEFT")
bg:SetPoint("BOTTOMRIGHT")
bg:SetPoint("TOP", 0, 1)
f.bg = bg

local rest = CreateFrame("StatusBar", nil, f)
rest:SetStatusBarTexture(BAR_TEXTURE)
rest:SetStatusBarColor(REST_COLOR.r, REST_COLOR.g, REST_COLOR.b / 2)
rest:SetPoint("BOTTOMLEFT")
rest:SetPoint("BOTTOMRIGHT")
rest:SetPoint("TOP")
f.rest = rest

local bar = CreateFrame("StatusBar", nil, rest)
bar:SetStatusBarTexture(BAR_TEXTURE)
bar:SetStatusBarColor(XP_COLOR.r, XP_COLOR.g, XP_COLOR.b)
bar:SetPoint("BOTTOMLEFT")
bar:SetPoint("BOTTOMRIGHT")
bar:SetPoint("TOP")
f.bar = bar

local shadow = bar:CreateTexture(nil, "BACKGROUND")
shadow:SetTexture("Interface\\AddOns\\PhanxBorder\\Shadow")
shadow:SetTexCoord(1/3, 2/3, 0, 1/3)
shadow:SetVertexColor(0, 0, 0)
shadow:SetPoint("LEFT", f, "TOPLEFT")
shadow:SetPoint("RIGHT", f, "TOPRIGHT")
shadow:SetHeight(21)
f.shadow = shadow

local border = bar:CreateTexture(nil, "OVERLAY")
border:SetTexture("Interface\\AddOns\\PhanxBorder\\Border")
border:SetTexCoord(1/3, 2/3, 0, 1/3)
border:SetVertexColor(0.3, 0.3, 0.3)
border:SetPoint("LEFT", f, "TOPLEFT")
border:SetPoint("RIGHT", f, "TOPRIGHT")
border:SetHeight(18)
f.border = border

function f:ShowXP()
	local cur, max, rcur = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion()

	bar:SetStatusBarColor(XP_COLOR.r, XP_COLOR.g, XP_COLOR.b)
	bar:SetMinMaxValues(0, max)
	bar:SetValue(cur)

	if rcur then
		rest:SetMinMaxValues(0, max)
		if cur + rcur > max then
			rest:SetValue(max)
		else
			rest:SetValue(cur + rcur)
		end
	else
		rest:SetMinMaxValues(0, 1)
		rest:SetValue(0)
	end

	f.showing = "XP"
end

function f:ShowRep()
	local name, standing, min, max, cur = GetWatchedFactionInfo()
	if not name then
		return self:ShowXP()
	end

	bar:SetStatusBarColor(FACTION_BAR_COLORS[standing].r * 0.5, FACTION_BAR_COLORS[standing].g * 0.5, FACTION_BAR_COLORS[standing].b * 0.5)
	bar:SetMinMaxValues(min, max)
	bar:SetValue(cur)

	rest:SetMinMaxValues(0, 1)
	rest:SetValue(0)

	f.showing = "FACTION"
end

local MAX_LEVEL = MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()]
function f:Update(event)
	if C_PetBattles.IsInBattle() then
		return f:Hide()
	end
	f:Show()
	if UnitLevel("player") == MAX_LEVEL or IsControlKeyDown() then
		f:ShowRep()
	else
		f:ShowXP()
	end
end

f:RegisterEvent("MODIFIER_STATE_CHANGED")
f:RegisterEvent("PET_BATTLE_OPENING_START")
f:RegisterEvent("PET_BATTLE_CLOSE")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_LEVEL_UP")
f:RegisterEvent("PLAYER_XP_UPDATE")
f:RegisterEvent("UPDATE_EXHAUSTION")
f:RegisterEvent("UPDATE_FACTION")

f:SetScript("OnEvent", f.Update)
hooksecurefunc("SetWatchedFactionIndex", f.Update)

f:EnableMouse(true)

f:SetScript("OnEnter", function(self)
	local mxp = UnitXPMax("player")
	local xp = UnitXP("player")
	local rxp = GetXPExhaustion()
	local name, standing, minrep, maxrep, value = GetWatchedFactionInfo()

	GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
	GameTooltip:AddLine("jExp")
	if UnitLevel("player") ~= MAX_PLAYER_LEVEL then
		GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, xp.."|cffffd100/|r"..mxp.." |cffffd100/|r "..floor((xp/mxp)*1000)/10 .."%",NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1)
		if rxp then
			GameTooltip:AddDoubleLine(TUTORIAL_TITLE26, rxp .." |cffffd100/|r ".. floor((rxp/mxp)*1000)/10 .."%", NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1)
		end
		if name then
			GameTooltip:AddLine(" ")
		end
	end
	if name then
		GameTooltip:AddDoubleLine(FACTION, name, NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1)
		GameTooltip:AddDoubleLine(STANDING, getglobal("FACTION_STANDING_LABEL"..standing), NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b)
		GameTooltip:AddDoubleLine(REPUTATION, value-minrep .."|cffffd100/|r"..maxrep-minrep.." |cffffd100/|r "..floor((value-minrep)/(maxrep-minrep)*1000)/10 .."%", NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1)
	end

	GameTooltip:Show()
end)

f:SetScript("OnLeave", function()
	GameTooltip:Hide()
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-14-13, 04:24 PM   #5
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Well I'll look into this, got about 2 weeks before I can personally test anything >.>

Never though of using an XP bar as a backround for anything before.... Might play around with that once I get around to rewritting my data text. Course I'd probably have to change my XP bar to a more classic style than the (what I prefer to call it) retro style I use for it. (sadly I feel the XP bar was the best thing about my UI, lmao)
__________________
Tweets YouTube Website
  Reply With Quote
03-14-13, 08:20 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It works pretty well with the muted colors. I'm currently using Bazooka with the background set to fully transparent and fade-in on mouseover. I'll post a screenshot later when I'm at home.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » XP Bar Text post 5.2


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