WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   XP Bar Text post 5.2 (https://www.wowinterface.com/forums/showthread.php?t=46050)

10leej 03-13-13 11:11 PM

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).

Phanx 03-14-13 03:52 AM

Quote:

Originally Posted by 10leej (Post 274629)
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. :p

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. :p

10leej 03-14-13 12:48 PM

Why you have to be so cruel? :(

Anyways to my understanding no errors, what mod are you using?

Phanx 03-14-13 01:58 PM

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)


10leej 03-14-13 04:24 PM

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)

Phanx 03-14-13 08:20 PM

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.

10leej 03-15-13 12:00 AM

Quote:

Originally Posted by Phanx (Post 274671)
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.

Would love to see it :)

Phanx 03-15-13 02:16 AM

http://i.imgur.com/ajdu39o.jpg

Quest tracker also fades in in mouseover. Not really happy with the cooldown bar or nameplates, but too lazy to do anything about them.

I was looking at some old screenshots while uploading that one, though... might re-try some old ideas soon.

10leej 03-15-13 02:35 AM

Looks pretty neat. Definitely gonna fool around with it.

10leej 03-19-13 04:52 PM

In the end it turns out my XP bar works perfectly fine, it's just that the roommate was level 90.

So now I suppose I should get it to check for level and if layer is capped turn it off. (not sure how to do this, but a quick API search should prove fruitful)

EDIT:
maybe something like
Lua Code:
  1. if playerMaxXP = UnitXPMax("player") then
  2.   return
  3. else
  4.   --XP bar code here
  5. end

not sure if that's correct

Maybe I can finally get around to adding rep support I've never really been concerned with.

Phanx 03-19-13 07:55 PM

Code:

if UnitLevel("player") == MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] then
    return
end

Just stick that at the top of the file. You don't need to wrap the rest of the file in an "else-end" block; "return" in the file-level scope stops execution of the rest of the file.

10leej 03-19-13 11:04 PM

Quote:

Originally Posted by Phanx (Post 274862)
Code:

if UnitLevel("player") == MAX_PLAYER_LEVEL_TABLE[GetExpansionLevel()] then
    return
end

Just stick that at the top of the file. You don't need to wrap the rest of the file in an "else-end" block; "return" in the file-level scope stops execution of the rest of the file.

Ah why thank you good sir, or mam (not sure the name is awefully unisexual)

JDoubleU00 03-21-13 08:56 AM

Not to derail the original topic, but Phanx, you only use 6 action buttons? I'm constantly trying to tweak how my UI looks and functions.

10leej 03-21-13 09:31 AM

Quote:

Originally Posted by rocnroll (Post 274938)
Not to derail the original topic, but Phanx, you only use 6 action buttons? I'm constantly trying to tweak how my UI looks and functions.

If you look there's another actionbar above the initial six buttons

Phanx 03-21-13 01:55 PM

Yes, I only use 6 action buttons. Most of them have at least two actions, using modifier-aware macros, and there is a second page I can switch to with Shift+Mousewheel. Everything else is keybound or on OPie. My shaman does have a second 4-button bar with totem flyouts, though someday I'll stop being so lazy and put them in OPie.

For example, button 5 in my screenshot is a macro like this (may not be exact because I'm at work and typing from memory):
/cast [mod:ctrl] [btn:4] Maim; [mod:alt] [btn:3] Savage Roar; [mod:shift] [btn:2] Ferocious Bite; Rip
There's a second bar in that screenshot because I haven't played my druid since Wrath and haven't figured out how I want to keybind those abilities yet, so for now I'm just clicking on them (I know, I know). The pet bar appears in the same space, so if my druid gets a temporary pet for a quest or something it's going to be kind of awkward. :p

Actually, it just occurred to me that I don't have a second page in Cat Form, so I can just put the things from that second bar on there. Problem solved!


All times are GMT -6. The time now is 08:16 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI