Go to Page... |
|
Thread Tools | Display Modes |
07-29-18, 09:49 AM | #1 |
[Solved] Custom xp,ap,azerite bar does not trigger on login, only after reloadui
Hello.
I'm in need of some help again. Since the advice I got last time was super helpful, I thought I'll try my luck again. The following code is part of my personal ui specifically the progressbar, which shows xp,ap,azerite,reputation. With my chars that are below level 110, I'm not experiencing any problems (xp bar is displayed at the first login and shows xp/restxp), but with my level 110 toons, the bar does not show until after I do a reload. I guess I'm missing something regarding the events, but my lua knowledge is limited and I can't figure it out myself. Maybe someone can help me out with this. Any help is greatly appreciated. Code:
local F, C, L = unpack(select(2, ...)) if not C.general.progressbars then return end ------------------------ -- create frames ------------------------ local backdrop = CreateFrame("Frame", nil, Minimap) backdrop:SetHeight(6) backdrop:SetPoint("BOTTOM", Minimap, "TOP") backdrop:SetPoint("BOTTOMLEFT", Minimap, "TOPLEFT", -1, -20) backdrop:SetPoint("BOTTOMRIGHT", Minimap, "TOPRIGHT", 1, 20) F.CreateBD(backdrop, .6) --xp,ap,azerite local bar = CreateFrame("StatusBar", nil, backdrop) bar:SetHeight(4) bar:SetPoint("TOP", backdrop, "TOP", 0, -1) bar:SetPoint("LEFT", backdrop, 1, 0) bar:SetPoint("RIGHT", backdrop, -1, 0) bar:SetStatusBarTexture(C.media.texture) --restxp local rest = CreateFrame("Statusbar", nil, backdrop) rest:SetHeight(4) rest:SetPoint("TOP", backdrop, "TOP", 0, -1) rest:SetPoint("LEFT", backdrop, 1, 0) rest:SetPoint("RIGHT", backdrop, -1, 0) rest:SetStatusBarTexture(C.media.texture) rest:SetFrameLevel(bar:GetFrameLevel() - 1) bar.restBar = rest --mouseframe local mouseFrame = CreateFrame("Frame", "ZenjaaUIExpBar", backdrop) mouseFrame:SetAllPoints(backdrop) mouseFrame:EnableMouse(true) ----------------------- --update bar function ----------------------- local function updateStatus() local rest = bar.restBar if rest then rest:Hide() end --xp if UnitLevel("player") < MAX_PLAYER_LEVEL then local xp, mxp, rxp = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion() bar:SetStatusBarColor(.5, 0, .75) bar:SetMinMaxValues(0, mxp) bar:SetValue(xp) bar:Show() if rxp then rest:SetStatusBarColor(0, .4, .8) rest:SetMinMaxValues(0, mxp) rest:SetValue(math.min(xp + rxp, mxp)) rest:Show() end if IsXPUserDisabled() then bar:SetStatusBarColor(.7, 0, 0) end --reputation elseif GetWatchedFactionInfo() then local _, standing, min, max, value, factionID = GetWatchedFactionInfo() local friendID, friendRep, _, _, _, _, _, friendThreshold, nextFriendThreshold = GetFriendshipReputation(factionID) if friendID then if nextFriendThreshold then min, max, value = friendThreshold, nextFriendThreshold, friendRep else min, max, value = 0, 1, 1 end standing = 5 elseif C_Reputation.IsFactionParagon(factionID) then local currentValue, threshold = C_Reputation.GetFactionParagonInfo(factionID) currentValue = mod(currentValue, threshold) min, max, value = 0, threshold, currentValue else if standing == MAX_REPUTATION_REACTION then min, max, value = 0, 1, 1 end end bar:SetStatusBarColor(FACTION_BAR_COLORS[standing].r, FACTION_BAR_COLORS[standing].g, FACTION_BAR_COLORS[standing].b, .85) bar:SetMinMaxValues(min, max) bar:SetValue(value) bar:Show() --azerite elseif C_AzeriteItem.HasActiveAzeriteItem() then local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem() local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation) bar:SetStatusBarColor(.9, .8, .6) bar:SetMinMaxValues(0, totalLevelXP) bar:SetValue(xp) bar:Show() --artifact elseif HasArtifactEquipped() then local _, _, _, _, totalXP, pointsSpent, _, _, _, _, _, _, artifactTier = C_ArtifactUI.GetEquippedArtifactInfo() local _, xp, xpForNextPoint = ArtifactBarGetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP, artifactTier) xp = xpForNextPoint == 0 and 0 or xp bar:SetStatusBarColor(.9, .8, .6) bar:SetMinMaxValues(0, xpForNextPoint) bar:SetValue(xp) bar:Show() else bar:Hide() backdrop:Hide() end end ------------------------- --tooltip function ------------------------- mouseFrame:SetScript("OnEnter", function() GameTooltip:SetOwner(mouseFrame, "ANCHOR_BOTTOMLEFT", -1, 6) GameTooltip:SetClampedToScreen( true ) GameTooltip:ClearLines() GameTooltip:AddLine(UnitName("player").." ("..LEVEL.." "..UnitLevel("player")..")", C.r, C.g, C.b) --experience if UnitLevel("player") < MAX_PLAYER_LEVEL then local xp, mxp, rxp = UnitXP("player"), UnitXPMax("player"), GetXPExhaustion() GameTooltip:AddDoubleLine("XP: ", string.format('%s/%s (%d%%)', BreakUpLargeNumbers(xp), BreakUpLargeNumbers(mxp), (xp/mxp)*100), r, g, b, 1, 1, 1) GameTooltip:AddDoubleLine("Remaining: ", string.format('%s', BreakUpLargeNumbers(mxp-xp)), r, g, b, 1, 1, 1) if rxp then GameTooltip:AddDoubleLine("Rested: ", "+"..rxp.." ("..floor(rxp/mxp*100).."%)", r, g, b, .3, .7, 1) end if IsXPUserDisabled() then GameTooltip:AddLine("|cffff0000"..XP..LOCKED) end end --reputation if GetWatchedFactionInfo() then local name, standing, min, max, value, factionID = GetWatchedFactionInfo() local friendID, _, _, _, _, _, friendTextLevel, _, nextFriendThreshold = GetFriendshipReputation(factionID) local currentRank, maxRank = GetFriendshipReputationRanks(friendID) local standingtext if friendID then if maxRank > 0 then name = name.." ("..currentRank.." / "..maxRank..")" end if not nextFriendThreshold then value = max - 1 end standingtext = friendTextLevel else if standing == MAX_REPUTATION_REACTION then max = min + 1e3 value = max - 1 end standingtext = GetText("FACTION_STANDING_LABEL"..standing, UnitSex("player")) end GameTooltip:AddLine(" ") GameTooltip:AddLine(name, 243/250, 222627/250, 57/250) GameTooltip:AddDoubleLine(standingtext, value - min.."/"..max - min.." ("..floor((value - min)/(max - min)*100).."%)", 131/250, 239/250, 131/250, 1,1,1) if C_Reputation.IsFactionParagon(factionID) then local currentValue, threshold = C_Reputation.GetFactionParagonInfo(factionID) local paraCount = floor(currentValue/threshold) currentValue = mod(currentValue, threshold) GameTooltip:AddDoubleLine("ParagonRep"..paraCount, currentValue.."/"..threshold.." ("..floor(currentValue/threshold*100).."%)", 131/250, 239/250, 131/250, 1,1,1) end end --honor if IsWatchingHonorAsXP() then local current, max, level = UnitHonor("player"), UnitHonorMax("player"), UnitHonorLevel("player") GameTooltip:AddLine(" ") GameTooltip:AddLine(HONOR, .243/250, 222627/250, 57/250) GameTooltip:AddDoubleLine(LEVEL.." "..level, current.."/"..max, 131/250, 239/250, 131/250, 1,1,1) end --azerite if C_AzeriteItem.HasActiveAzeriteItem() then local azeriteItemLocation = C_AzeriteItem.FindActiveAzeriteItem() local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation) local azeriteItemName = azeriteItem:GetItemName() local xp, totalLevelXP = C_AzeriteItem.GetAzeriteItemXPInfo(C_AzeriteItem.FindActiveAzeriteItem()) local currentLevel = C_AzeriteItem.GetPowerLevel(azeriteItemLocation) GameTooltip:AddLine(" ") GameTooltip:AddLine(azeriteItemName.." ("..format(SPELLBOOK_AVAILABLE_AT, currentLevel)..")", 243/250, 222627/250, 57/250) GameTooltip:AddDoubleLine(ARTIFACT_POWER, F.Numb(xp).."/"..F.Numb(totalLevelXP).." ("..floor(xp/totalLevelXP*100).."%)", 131/250, 239/250, 131/250, 1,1,1) end --artifact if HasArtifactEquipped() then local _, _, name, _, totalXP, pointsSpent, _, _, _, _, _, _, artifactTier = C_ArtifactUI.GetEquippedArtifactInfo() local num, xp, xpForNextPoint = ArtifactBarGetNumArtifactTraitsPurchasableFromXP(pointsSpent, totalXP, artifactTier) GameTooltip:AddLine(" ") if pointsSpent > 51 then GameTooltip:AddLine(name.." ("..format(SPELLBOOK_AVAILABLE_AT, pointsSpent).." ".."Paragon"..(pointsSpent - 51)..")", 243/250, 222627/250, 57/250) else GameTooltip:AddLine(name.." ("..format(SPELLBOOK_AVAILABLE_AT, pointsSpent)..")", 243/250, 222627/250, 57/250) end local numText = num > 0 and " ("..num..")" or "" GameTooltip:AddDoubleLine(ARTIFACT_POWER, F.Numb(totalXP)..numText, 131/250, 239/250, 131/250, 1,1,1) if xpForNextPoint ~= 0 then local perc = " ("..floor(xp/xpForNextPoint*100).."%)" GameTooltip:AddDoubleLine("Next Trait", F.Numb(xp).."/"..F.Numb(xpForNextPoint)..perc, 131/250, 239/250, 131/250, 1,1,1) end end GameTooltip:Show() end) mouseFrame:SetScript("OnMouseDown", function() if not ArtifactFrame or not ArtifactFrame:IsShown() then ShowUIPanel(SocketInventoryItem(16)) elseif ArtifactFrame and ArtifactFrame:IsShown() then HideUIPanel(ArtifactFrame) end end) mouseFrame:SetScript("OnLeave", function() GameTooltip:Hide() end) ------------------------ --events ------------------------ F.RegisterEvent("PLAYER_ENTERING_WORLD", updateStatus) F.RegisterEvent("PLAYER_XP_UPDATE", updateStatus) --xp F.RegisterEvent("PLAYER_LEVEL_UP", updateStatus) --xp F.RegisterEvent("UPDATE_EXHAUSTION", updateStatus) --xp F.RegisterEvent("ENABLE_XP_GAIN", updateStatus) --xp F.RegisterEvent("DISABLE_XP_GAIN", updateStatus) --xp F.RegisterEvent("ARTIFACT_XP_UPDATE", updateStatus) --artifact F.RegisterEvent("UNIT_INVENTORY_CHANGED", updateStatus) --artifact/azerite F.RegisterEvent("AZERITE_ITEM_EXPERIENCE_CHANGED", updateStatus) -- azerite F.RegisterEvent("UPDATE_FACTION", updateStatus) --reputation Last edited by Zenjaa : 07-30-18 at 02:06 AM. Reason: Solved |
|
WoWInterface » Developer Discussions » General Authoring Discussion » [Solved] Custom xp,ap,azerite bar does not trigger on login, only after reloadui |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|