05-04-24, 02:00 PM | #1 |
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) Code:
IncCalloutDB |
|
05-04-24, 08:12 PM | #2 |
The way I handled my Alt ILevel addon was to store the required information whenever that character was played and put it in the server wide saved variables rather than the character specific one. That way you can access it from any character on that server.
Fill free to take a look if you need to ( https://www.wowinterface.com/downloa...AltILevel.html )
__________________
All Level 70 Characters: Demon Warlock Resto Druid Disc Priest Resto Shaman Survival Hunter Augment Evoker Frost Mage Vengence Demon Hunter Rogue ( was subtlety ) Brewmaster Monk (TR) Prot Paladin (TR) Blood Death Knight ( TR) As you can see I am missing a warrior And .. I don't have all the allied races covered. Time Runner time when it happens again |
|
05-04-24, 09:33 PM | #3 |
Thanks for the info...But unfortunately I can't get it to work. So I'm just going to leave it as is.
|
|
05-04-24, 10:10 PM | #4 |
You primary problem is that you don't update the character information until pvpStatsFrame OnShow.
Presumably a player can "gain stats" without showing the frame so for any saved information to be worthwhile, you need to update the stats and SavedVariable information when a change happens. Then you could do something similar to your UpdatePvPStatsFrame function eg: As mentioned by Xrystal, IncCalloutDB has to be listed in your .toc as ## SavedVariables: not ## SavedVariablesPerCharacter: Then, presuming you're not using something like AceDB. When the player does/finishes something that alters the PVP stats, make sure the PVPUI is loaded and... Lua Code:
Then you can retrieve information for any character that's been saved (after ADDON_LOADED or PLAYER_LOGIN) Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-04-24 at 11:13 PM. |
|
05-05-24, 08:32 AM | #5 |
This is what I came up with, and all that shows is the current toon. The pvp stat labels are there but no data under them.
Code:
IncCalloutDB = IncCalloutDB or {} -- Function to update and save PvP stats local function UpdatePvPStats() local character = UnitName("player") .. "-" .. GetRealmName() if not IncCalloutDB[character] then IncCalloutDB[character] = { conquestValue = 0, conquestCapValue = "0 / 0", honorValue = 0, honorLevelValue = 0, soloShuffleRatingValue = "N/A" } end local SavedSettings = IncCalloutDB[character] local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID) local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID) local honorLevel = UnitHonorLevel("player") -- Update conquest point calculations SavedSettings.conquestValue = conquestInfo.quantity SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity SavedSettings.honorValue = honorInfo.quantity SavedSettings.honorLevelValue = honorLevel SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A" end local function InitializeCharacterDB() local character = UnitName("player") .. "-" .. GetRealmName() UpdatePvPStats() end -- Register event handlers and handle events local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:RegisterEvent("PLAYER_PVP_KILLS_CHANGED") frame:SetScript("OnEvent", function(self, event, arg1, ...) if event == "ADDON_LOADED" and arg1 == "IncCallout" then InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then UpdatePvPStats() end end) -- Register event handlers local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:RegisterEvent("PLAYER_PVP_KILLS_CHANGED") frame:SetScript("OnEvent", function(self, event, arg1, ...) if event == "ADDON_LOADED" and arg1 == "IncCallout" then InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then UpdatePvPStats() end end) -- Function to dynamically apply class colors and update the PvP Stats Frame when shown 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() -- Use the function to get the class color if classColor then pvpStatsFrame.playerNameValue:SetTextColor(classColor.r, classColor.g, classColor.b) -- Apply the color end UpdatePvPStats() -- Update display with the latest stats end) |
|
05-05-24, 10:50 AM | #6 |
The code has two separate frames doing the same thing??? These events could be handled by your pvpStatsFrame.
Remove ADDON_LOADED and replace it with PLAYER_LOGIN as it only fires once after ALL initial addons have loaded (including your SavedVariables). IncCalloutDB = IncCalloutDB or {} This should be inside the function or at some point during/after PLAYER_LOGIN. Where it is in the code currently, IncCalloutDB will always be nil because the game hasn't loaded the SavedVariables yet and that line creates a new empty table every /reload or Login. PLAYER_LOGOUT may not work for this because by this time, the game is shutting down. I don't see a check for the PVPUI which I think was required for some of the stats to be available?
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-05-24 at 11:09 AM. |
|
05-05-24, 11:29 AM | #7 |
I didn't notice the duplicate part. I have everything working except that it will not show the toons I have logged into and their stats. Towards the top I do have "IncCalloutDB = IncCalloutDB or {}"... Here is what I have so far:
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 local function SavePvPStats() IncCalloutDB = IncCalloutDB or {} local character = UnitName("player") .. "-" .. GetRealmName() if not IncCalloutDB[character] then IncCalloutDB[character] = {} end local SavedSettings = IncCalloutDB[character] if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then 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 SavedSettings.conquestValue = conquestInfo.quantity SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity SavedSettings.honorValue = honorInfo.quantity SavedSettings.honorLevelValue = honorLevel SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A" 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 local character = UnitName("player") .. "-" .. GetRealmName() local stats = IncCalloutDB[character] if stats then pvpStatsFrame.conquestValue:SetText(stats.conquestValue) pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue) pvpStatsFrame.honorValue:SetText(stats.honorValue) pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue) pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue) end UpdatePvPStatsFrame() end) -- Register event handlers local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:SetScript("OnEvent", function(self, event, arg1, ...) if event == "PLAYER_LOGIN" and arg1 == "IncCallout" then InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then UpdatePvPStats() end end) Last edited by Sharpedge : 05-05-24 at 11:37 AM. |
|
05-05-24, 11:37 AM | #8 |
A quick look and
Code:
IncCalloutDB = IncCalloutDB or {}
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
05-05-24, 12:02 PM | #9 |
I just added it and there is no change. The current toon that I am logged into shows in the pvp stat window like it should, but, none of the others that I do log into show at all.
Code:
local function UpdatePvPStatsFrame() IncCalloutDB = IncCalloutDB or {} 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 local function SavePvPStats() IncCalloutDB = IncCalloutDB or {} local character = UnitName("player") .. "-" .. GetRealmName() if not IncCalloutDB[character] then IncCalloutDB[character] = {} end local SavedSettings = IncCalloutDB[character] if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then 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 SavedSettings.conquestValue = conquestInfo.quantity SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity SavedSettings.honorValue = honorInfo.quantity SavedSettings.honorLevelValue = honorLevel SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A" 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 local character = UnitName("player") .. "-" .. GetRealmName() local stats = IncCalloutDB[character] if stats then pvpStatsFrame.conquestValue:SetText(stats.conquestValue) pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue) pvpStatsFrame.honorValue:SetText(stats.honorValue) pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue) pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue) end UpdatePvPStatsFrame() end) -- Register event handlers local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:SetScript("OnEvent", function(self, event, arg1, ...) if event == "PLAYER_LOGIN" and arg1 == "IncCallout" then InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then UpdatePvPStats() end end) |
|
05-05-24, 12:08 PM | #10 |
PLAYER_LOGIN doen't have a payload so it should just be:
Code:
if event == "PLAYER_LOGIN" then Code:
UpdatePvPStats() Code:
UpdatePvPStatsFrame() I'm assuming none of this is in your downloadable version of the addon so the code you post here is all I have to go on.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-05-24 at 12:15 PM. |
|
05-05-24, 12:25 PM | #11 |
Still only shows the current toon that is logged in.....Fizzle, I'm pretty sure there is an issue somewhere else in my code. I don't want to waste your time on this. I made a "test-repo" https://github.com/The-Sickness/Test-Repo
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() IncCalloutDB = IncCalloutDB or {} 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 local function SavePvPStats() IncCalloutDB = IncCalloutDB or {} local character = UnitName("player") .. "-" .. GetRealmName() if not IncCalloutDB[character] then IncCalloutDB[character] = {} end local SavedSettings = IncCalloutDB[character] if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then 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 SavedSettings.conquestValue = conquestInfo.quantity SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity SavedSettings.honorValue = honorInfo.quantity SavedSettings.honorLevelValue = honorLevel SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A" 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 local character = UnitName("player") .. "-" .. GetRealmName() local stats = IncCalloutDB[character] if stats then pvpStatsFrame.conquestValue:SetText(stats.conquestValue) pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue) pvpStatsFrame.honorValue:SetText(stats.honorValue) pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue) pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue) end UpdatePvPStatsFrame() end) local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:RegisterEvent("PLAYER_PVP_KILLS_CHANGED") frame:SetScript("OnEvent", function(self, event, ...) if event == "PLAYER_LOGIN" then IncCalloutDB = IncCalloutDB or {} InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" then SavePvPStats() elseif event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then SavePvPStats() UpdatePvPStatsFrame() end end) |
|
05-05-24, 12:30 PM | #12 |
If you mean in your Stats frame then that's all you are showing
Lua Code:
You would need to either have a way to select a charcter to show the stats for or use a scroll list of characters/stats. Check the actual SavedVariables file for you addon to see if it contains stats for multiple characters. I'll look at the test addon shortly.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
05-05-24, 12:56 PM | #13 |
Added a scroll, and checked the SavedVariables file. it shows all the info. I even deleted it and started over to make sure, and it is indeed saving.
|
|
05-05-24, 12:59 PM | #14 |
The InCallout.lua file from the test repo. See the comments starting with -- Fizz:.
Your .toc has two ## SavedVariables: entries (they can just go on the one line separated by a comma. Maybe the character information would go to IncCallout_Characters but you don't seem to do anything with it so the information is just going into IncCalloutDB...? Maybe remove IncCallout_Characters and create a characters table under IncCalloutDB and save the stats there so it's easier to differentiate between that and any other settings? Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-05-24 at 01:10 PM. |
|
05-05-24, 01:09 PM | #15 |
I don 't see a scroll list in the test code, just a single row of stats fontstrings.
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. |
|
05-05-24, 01:28 PM | #16 |
Made the changes you suggested, no change. It still just displays the current logged in toon.
Code:
-- Create the PVP Stats window frame local pvpStatsFrame = CreateFrame("Frame", "PVPStatsFrame", UIParent, "BasicFrameTemplateWithInset") pvpStatsFrame:SetSize(750, 400) -- Increased size to accommodate scrolling 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, -10) pvpStatsFrame.title:SetText("PvP Statistics") -- Create Scroll Frame and Scroll Bar local scrollFrame = CreateFrame("ScrollFrame", nil, pvpStatsFrame, "UIPanelScrollFrameTemplate") scrollFrame:SetPoint("TOPLEFT", pvpStatsFrame.title, "BOTTOMLEFT", 0, -10) scrollFrame:SetPoint("BOTTOMRIGHT", pvpStatsFrame, "BOTTOMRIGHT", -30, 10) local content = CreateFrame("Frame", nil, scrollFrame) scrollFrame:SetScrollChild(content) content:SetSize(700, 1000) local yOffset = 0 local function UpdateAllCharacterStats() -- Clear old content for i = 1, content:GetNumChildren() do local child = select(i, content:GetChildren()) child:Hide() end -- Update yOffset for new entries yOffset = 0 for character, stats in pairs(IncCalloutDB) do local statText = content:CreateFontString(nil, "OVERLAY", "GameFontNormal") statText:SetPoint("TOPLEFT", content, "TOPLEFT", 10, yOffset) statText:SetSize(680, 20) statText:SetText(format("%s: Conquest Points: %s, Honor Points: %s, Honor Level: %s, Conquest Cap: %s / %s, Solo Shuffle Rating: %s", character, stats.conquestValue, stats.honorValue, stats.honorLevelValue, stats.conquestCapValue, stats.soloShuffleRatingValue)) yOffset = yOffset - 20 end content:SetHeight(math.abs(yOffset)) end pvpStatsFrame:SetScript("OnShow", function() UpdateAllCharacterStats() end) 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() IncCalloutDB = IncCalloutDB or {} 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 local function SavePvPStats() IncCalloutDB = IncCalloutDB or {} local character = UnitName("player") .. "-" .. GetRealmName() if not IncCalloutDB[character] then IncCalloutDB[character] = {} end local SavedSettings = IncCalloutDB[character] if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then 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 SavedSettings.conquestValue = conquestInfo.quantity SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity SavedSettings.honorValue = honorInfo.quantity SavedSettings.honorLevelValue = honorLevel SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A" end end local function InitializeCharacterDB()-- Fizz: Added because it didn't exist -- I don't know what else is suppsed to go her??? SavePvPStats() 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 local character = UnitName("player") .. "-" .. GetRealmName() local stats = IncCalloutDB[character] if stats then pvpStatsFrame.conquestValue:SetText(stats.conquestValue) pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue) pvpStatsFrame.honorValue:SetText(stats.honorValue) pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue) pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue) end UpdatePvPStatsFrame() end) -- Register event handlers local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGOUT") frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") frame:RegisterEvent("HONOR_XP_UPDATE") frame:SetScript("OnEvent", function(self, event, arg1, ...) if event == "PLAYER_LOGIN" then -- Fizz: Removed the or arg1 == test InitializeCharacterDB() elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then UpdatePvPStatsFrame() -- Fizz: Changed from UpdatePvPStats() end end) Code:
IncCalloutDB = { ["Kuthad-Jaedenar"] = { ["honorLevelValue"] = 267, ["conquestValue"] = 830, ["conquestCapValue"] = "2580 / 2600", ["honorValue"] = 9357, ["soloShuffleRatingValue"] = 96, }, ["settings"] = { ["mapScale"] = 0.75, ["mapPosition"] = { ["yOfs"] = 0, ["xOfs"] = 0, ["point"] = "CENTER", ["relativePoint"] = "CENTER", }, ["resizeInPvPOnly"] = true, }, ["Peacekeeper-Jaedenar"] = { ["honorLevelValue"] = 267, ["conquestValue"] = 415, ["conquestCapValue"] = "1290 / 2600", ["soloShuffleRatingValue"] = 192, ["honorValue"] = 1390, }, ["profileKeys"] = { ["Kuthad - Jaedenar"] = "Default", ["Peacekeeper - Jaedenar"] = "Default", }, ["profiles"] = { ["Default"] = { ["fontSize"] = 14, ["font"] = "Friz Quadrata TT", ["minimap"] = { ["minimapPos"] = 45, ["hide"] = false, }, }, }, } |
|
05-05-24, 02:05 PM | #17 |
You need to go through the code with a fine tooth comb. (test the code is actually being called when expected print("xx")). You have some duplications happening that effect what's going on eg.
Lua Code:
and Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-05-24 at 02:14 PM. |
|
05-10-24, 07:33 PM | #18 |
Well, I had to go with a dropdown instead of a scroll frame. I couldn't ever get to act right. But at least I learned something new....
WoWScrnShot_051024_082651.jpg |
|
05-10-24, 08:45 PM | #19 |
I added a list to your test git version the other day. Probably needs some (much) massaging as it was just thrown together as a "how might I approach it test". Maybe it's something you can work with (if you can be bothered and if you can figure it out ) May want to use an empty SV file if you've changed the format (or want to preserve yours)
IncCallout.lua Lua Code:
__________________
Fizzlemizz Maintainer of Discord Unit Frames and Discord Art. Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus. Last edited by Fizzlemizz : 05-10-24 at 08:48 PM. |
|
05-10-24, 10:09 PM | #20 |
Wow, thank you for that. It looks pretty good. I'll have to tinker with it a little bit, but overall it looks good.
|
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » How to populate.... |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|