Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-04-24, 02:00 PM   #1
Sharpedge
A Cliff Giant
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 75
How to populate....

By looking at the image you can see one that is called PvP Statistics. I have made it to show various stats, etc. I also have put the players name. What I can not figure out is how to "list" all of the toons that I log into. That way I can see all of their stats in one spot, per say. I have like 8 alts as I'm sure many who use my addon do as well. Can someone point me in the right direction, again lol.....

Here is my code for just the frames and labels:
Code:
local pvpStatsFrame = CreateFrame("Frame", "PVPStatsFrame", UIParent, "BasicFrameTemplateWithInset")
pvpStatsFrame:SetSize(750, 100)
pvpStatsFrame:SetPoint("CENTER")
pvpStatsFrame:SetMovable(true)
pvpStatsFrame:EnableMouse(true)
pvpStatsFrame:RegisterForDrag("LeftButton")
pvpStatsFrame:SetScript("OnDragStart", pvpStatsFrame.StartMoving)
pvpStatsFrame:SetScript("OnDragStop", pvpStatsFrame.StopMovingOrSizing)
pvpStatsFrame:Hide() 

pvpStatsFrame.title = pvpStatsFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
pvpStatsFrame.title:SetPoint("TOP", pvpStatsFrame, "TOP", 0, -5)  -- Adjust this value to move the title up or down
pvpStatsFrame.title:SetText("PvP Statistics")

local TOP_MARGIN = -25

local function createStatLabelAndValueHorizontal(parent, labelText, xOffset, textColor)
    local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    label:SetPoint("TOPLEFT", parent, "TOPLEFT", xOffset, TOP_MARGIN)
    label:SetText(labelText)
    label:SetTextColor(unpack(textColor))
    
    local value = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    value:SetPoint("TOP", label, "BOTTOM", 0, -2)  
    value:SetTextColor(1, 0.84, 0)
    return label, value
end

pvpStatsFrame.playerNameLabel, pvpStatsFrame.playerNameValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Player Name:", 10, {1, 1, 1})
pvpStatsFrame.conquestLabel, pvpStatsFrame.conquestValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Conquest Points:", 130, {0, 0.75, 1})
pvpStatsFrame.honorLabel, pvpStatsFrame.honorValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Honor Points:", 250, {1, 0.5, 0})
pvpStatsFrame.honorLevelLabel, pvpStatsFrame.honorLevelValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Honor Level:", 370, {0.58, 0, 0.82})
pvpStatsFrame.conquestCapLabel, pvpStatsFrame.conquestCapValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Conquest Cap:", 490, {1, 0, 0})
pvpStatsFrame.soloShuffleRatingLabel, pvpStatsFrame.soloShuffleRatingValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Solo Shuffle Rating:", 610, {0, 0.75, 1})

local SOLO_SHUFFLE_INDEX = 7

local function UpdatePvPStatsFrame()
    if not IsAddOnLoaded("Blizzard_PVPUI") then
        LoadAddOn("Blizzard_PVPUI")
    end

    local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
    local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
    local honorLevel = UnitHonorLevel("player")  

    -- Updated conquest point calculations
    local currentConquestPoints = conquestInfo.quantity
    local totalEarnedConquest = conquestInfo.totalEarned  -- Total conquest points earned ever
    local weeklyEarnedConquest = conquestInfo.quantityEarnedThisWeek  -- Total conquest points earned this week
    local conquestCap = conquestInfo.maxQuantity  -- Dynamically fetch the current conquest cap
    local displayedConquestProgress = math.min(totalEarnedConquest, conquestCap)  -- Ensure displayed value does not exceed cap

    local rating = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX)
    local soloShuffleRating = rating or "N/A"

    -- Display data
    pvpStatsFrame.conquestValue:SetText(currentConquestPoints)
    pvpStatsFrame.conquestCapValue:SetText(displayedConquestProgress .. " / " .. conquestCap)
    pvpStatsFrame.honorValue:SetText(honorInfo.quantity)
    pvpStatsFrame.honorLevelValue:SetText(honorLevel)  
    pvpStatsFrame.soloShuffleRatingValue:SetText(soloShuffleRating)

    -- Adjust buttons based on PvP availability
    local canUseRated = C_PvP.CanPlayerUseRatedPVPUI()
    local canUsePremade = C_LFGInfo.CanPlayerUsePremadeGroup()

    if canUseRated then
        PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton2, true)
        PVPQueueFrame.CategoryButton2.tooltip = nil
    end

    if canUsePremade then
        PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton3, true)
        PVPQueueFrame.CategoryButton3.tooltip = nil
    end
end

local function GetDefaultClassColor()
    local _, class = UnitClass("player")
    if class then
        return RAID_CLASS_COLORS[class]
    end
end

pvpStatsFrame:SetScript("OnShow", function()
    pvpStatsFrame.playerNameValue:SetText(UnitName("player") or "Unknown")
    local classColor = GetDefaultClassColor()  
    if classColor then
        pvpStatsFrame.playerNameValue:SetTextColor(classColor.r, classColor.g, classColor.b)  
    end
    UpdatePvPStatsFrame()  
end)
Here is my saved variable:
Code:
IncCalloutDB
https://imgur.com/tUPYYn9
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » How to populate....


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