Thread Tools Display Modes
05-04-24, 02:00 PM   #1
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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
05-04-24, 08:12 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,950
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 )
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
05-04-24, 09:33 PM   #3
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
Thanks for the info...But unfortunately I can't get it to work. So I'm just going to leave it as is.
  Reply With Quote
05-04-24, 10:10 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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:
  1. IncCalloutDB = IncCalloutDB or {}
  2. local character = UnitName("player") .. "-" .. GetRealmName()
  3. if not IncCalloutDB[character] then
  4.     IncCalloutDB[character] = {}
  5. end
  6. local SavedSettings = IncCalloutDB[character]
  7. local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
  8. local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
  9. local honorLevel = UnitHonorLevel("player")  
  10.  
  11. -- Updated conquest point calculations
  12. local currentConquestPoints = conquestInfo.quantity
  13. local totalEarnedConquest = conquestInfo.totalEarned  -- Total conquest points earned ever
  14. local weeklyEarnedConquest = conquestInfo.quantityEarnedThisWeek  -- Total conquest points earned this week
  15. local conquestCap = conquestInfo.maxQuantity  -- Dynamically fetch the current conquest cap
  16. local displayedConquestProgress = math.min(totalEarnedConquest, conquestCap)  -- Ensure displayed value does not exceed cap
  17.  
  18. local rating = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX)
  19. local soloShuffleRating = rating or "N/A"
  20.  
  21. -- Save the data
  22. SavedSettings.conquestValue = currentConquestPoints
  23. SavedSettings.conquestCapValue = displayedConquestProgress .. " / " .. conquestCap
  24. SavedSettings.honorValue = honorInfo.quantity
  25. SavedSettings.honorLevelValue = honorLevel
  26. SavedSettings.soloShuffleRatingValue = soloShuffleRating
  27. -- etc...

Then you can retrieve information for any character that's been saved (after ADDON_LOADED or PLAYER_LOGIN)
Lua Code:
  1. if IncCalloutDB then
  2.    for character, stats in pairs(IncCalloutDB) do
  3.        -- character -- is the character-realm of a saved toon
  4.        -- stats.conquestValue -- conquestValue for the character
  5.        -- stats.conquestCapValue -- conquestCapValue for the character
  6.    end
  7. end
__________________
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.
  Reply With Quote
05-05-24, 08:32 AM   #5
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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)
  Reply With Quote
05-05-24, 10:50 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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.
  Reply With Quote
05-05-24, 11:29 AM   #7
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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)
I made a test repo in case you wanna see the full code...I prolly messed up somewhere: https://github.com/The-Sickness/Test-Repo

Last edited by Sharpedge : 05-05-24 at 11:37 AM.
  Reply With Quote
05-05-24, 11:37 AM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
A quick look and
Code:
IncCalloutDB = IncCalloutDB or {}
is in the function SavePvPStats which is never called in the code you posted?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-05-24, 12:02 PM   #9
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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)
  Reply With Quote
05-05-24, 12:08 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
PLAYER_LOGIN doen't have a payload so it should just be:
Code:
if event == "PLAYER_LOGIN" then
Your other event calls
Code:
UpdatePvPStats()
Which maybe should be
Code:
UpdatePvPStatsFrame()
I still don't see SavePvPStats() being called anywhere in that code you just posted unless it's in InitializeCharacterDB which I don't see the code for either.

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.
  Reply With Quote
05-05-24, 12:25 PM   #11
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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)
  Reply With Quote
05-05-24, 12:30 PM   #12
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
If you mean in your Stats frame then that's all you are showing
Lua Code:
  1. local character = UnitName("player") .. "-" .. GetRealmName() -- Get the stats for the current character from the DB
  2. local stats = IncCalloutDB[character]
  3. if stats then
  4.     pvpStatsFrame.conquestValue:SetText(stats.conquestValue) -- and show them
  5.     ...

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.
  Reply With Quote
05-05-24, 12:56 PM   #13
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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.
  Reply With Quote
05-05-24, 12:59 PM   #14
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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:
  1. -- IncCallout (Rebuild of Incoming-BG)
  2. -- Made by Sharpedge_Gaming
  3. -- v6.4 - 10.2.6
  4.  
  5. -- Load embedded libraries
  6. local LibStub = LibStub or _G.LibStub
  7. --local AceDB = LibStub("AceDB-3.0")
  8. local AceDB = LibStub:GetLibrary("AceDB-3.0")
  9. --local AceAddon = LibStub("AceAddon-3.0")
  10. local AceAddon = LibStub:GetLibrary("AceAddon-3.0")
  11. --local AceConfig = LibStub("AceConfig-3.0")
  12. local AceConfig = LibStub:GetLibrary("AceConfig-3.0")
  13. --local AceConfigDialog = LibStub("AceConfigDialog-3.0")
  14. local AceConfigDialog = LibStub:GetLibrary("AceConfigDialog-3.0")
  15. --local icon = LibStub("LibDBIcon-1.0")
  16. local icon = LibStub:GetLibrary("LibDBIcon-1.0")
  17. --local LDB = LibStub("LibDataBroker-1.1")
  18. local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
  19. --local LSM = LibStub ("LibSharedMedia-3.0")
  20. local LSM = LibStub("LibSharedMedia-3.0")
  21. local AceGUI = LibStub("AceGUI-3.0")
  22.  
  23. local addonName, addonNamespace = ...
  24. IncDB = IncDB or {}
  25. IncCalloutDB = IncCalloutDB or {}
  26. addonNamespace.addon = addon
  27. addonNamespace.db = IncDB
  28.  
  29.  
  30. local defaults = {
  31.     profile = {
  32.         buttonColor = {r = 1, g = 0, b = 0, a = 1}, -- Default to red
  33.         fontColor = {r = 1, g = 1, b = 1, a = 1},  -- Default to white
  34.         opacity = 1,
  35.         sendMoreIndex = 1,
  36.         incIndex = 1,
  37.         allClearIndex = 1,
  38.         logoColor = {r = 1, g = 1, b = 1, a = 1}, -- Default logo color
  39.         scale = 1,
  40.         isLocked = false,
  41.         worldMapScale = 1,
  42.         conquestFont = "Friz Quadrata TT",
  43.         conquestFontSize = 14,
  44.         conquestFontColor = {r = 1, g = 1, b = 1, a = 1}, -- white
  45.         honorFont = "Friz Quadrata TT",
  46.         honorFontSize = 14,
  47.         honorFontColor = {r = 1, g = 1, b = 1, a = 1}, -- white
  48.         selectedLogo = "None", -- Default logo selection
  49.     },
  50. }
  51.  
  52. local buttonTexts = {}
  53. local buttons = {}
  54. local playerFaction
  55.  
  56. local buttonMessageIndices = {
  57.     sendMore = 1,
  58.     inc = 1,
  59.     allClear = 1
  60. }
  61.  
  62. SLASH_INC1 = "/inc"
  63.  
  64. local customRaidWarningFrame = CreateFrame("Frame", "CustomRaidWarningFrame", UIParent)
  65. customRaidWarningFrame:SetHeight(50)
  66. customRaidWarningFrame:SetPoint("TOP", UIParent, "TOP", 0, -200)
  67. customRaidWarningFrame:SetWidth(UIParent:GetWidth())
  68.  
  69. customRaidWarningFrame.text = customRaidWarningFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge")
  70. customRaidWarningFrame.text:SetAllPoints(true)
  71. customRaidWarningFrame.text:SetJustifyH("CENTER")
  72. customRaidWarningFrame.text:SetJustifyV("MIDDLE")
  73.  
  74. customRaidWarningFrame:Hide()
  75.  
  76. local CONQUEST_CURRENCY_ID = 1602
  77. local HONOR_CURRENCY_ID = 1792
  78.  
  79. -- Main GUI Frame
  80. local IncCallout = CreateFrame("Frame", "IncCalloutMainFrame", UIParent, "BackdropTemplate")
  81. IncCallout:SetSize(225, 240)  
  82. IncCallout:SetPoint("CENTER")
  83. IncCallout:SetMovable(true)
  84. IncCallout:EnableMouse(true)
  85. IncCallout:RegisterForDrag("LeftButton")
  86. IncCallout:SetScript("OnDragStart", IncCallout.StartMoving)
  87. IncCallout:SetScript("OnDragStop", IncCallout.StopMovingOrSizing)
  88.  
  89. local closeButton = CreateFrame("Button", nil, IncCallout, "UIPanelCloseButton")
  90. closeButton:SetPoint("TOPRIGHT", IncCallout, "TOPRIGHT", -5, -5)
  91. closeButton:SetSize(24, 24)  
  92. closeButton:SetScript("OnClick", function()
  93.     IncCallout:Hide()  
  94. end)
  95.  
  96. closeButton:SetScript("OnEnter", function(self)
  97.     GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  98.     GameTooltip:SetText("Close the Window", nil, nil, nil, nil, true)
  99.     GameTooltip:Show()
  100. end)
  101. closeButton:SetScript("OnLeave", function()
  102.     GameTooltip:Hide()
  103. end)
  104.  
  105. -- Create the PVP Stats window frame
  106. local pvpStatsFrame = CreateFrame("Frame", "PVPStatsFrame", UIParent, "BasicFrameTemplateWithInset")
  107. pvpStatsFrame:SetSize(750, 100)
  108. pvpStatsFrame:SetPoint("CENTER")
  109. pvpStatsFrame:SetMovable(true)
  110. pvpStatsFrame:EnableMouse(true)
  111. pvpStatsFrame:RegisterForDrag("LeftButton")
  112. pvpStatsFrame:SetScript("OnDragStart", pvpStatsFrame.StartMoving)
  113. pvpStatsFrame:SetScript("OnDragStop", pvpStatsFrame.StopMovingOrSizing)
  114. pvpStatsFrame:Hide()
  115.  
  116. pvpStatsFrame.title = pvpStatsFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
  117. pvpStatsFrame.title:SetPoint("TOP", pvpStatsFrame, "TOP", 0, -5)  -- Adjust this value to move the title up or down
  118. pvpStatsFrame.title:SetText("PvP Statistics")
  119.  
  120. local TOP_MARGIN = -25
  121.  
  122. local function createStatLabelAndValueHorizontal(parent, labelText, xOffset, textColor)
  123.     local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  124.     label:SetPoint("TOPLEFT", parent, "TOPLEFT", xOffset, TOP_MARGIN)
  125.     label:SetText(labelText)
  126.     label:SetTextColor(unpack(textColor))
  127.    
  128.     local value = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  129.     value:SetPoint("TOP", label, "BOTTOM", 0, -2)  
  130.     value:SetTextColor(1, 0.84, 0)
  131.     return label, value
  132. end
  133.  
  134. pvpStatsFrame.playerNameLabel, pvpStatsFrame.playerNameValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Player Name:", 10, {1, 1, 1})
  135. pvpStatsFrame.conquestLabel, pvpStatsFrame.conquestValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Conquest Points:", 130, {0, 0.75, 1})
  136. pvpStatsFrame.honorLabel, pvpStatsFrame.honorValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Honor Points:", 250, {1, 0.5, 0})
  137. pvpStatsFrame.honorLevelLabel, pvpStatsFrame.honorLevelValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Honor Level:", 370, {0.58, 0, 0.82})
  138. pvpStatsFrame.conquestCapLabel, pvpStatsFrame.conquestCapValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Conquest Cap:", 490, {1, 0, 0})
  139. pvpStatsFrame.soloShuffleRatingLabel, pvpStatsFrame.soloShuffleRatingValue = createStatLabelAndValueHorizontal(pvpStatsFrame, "Solo Shuffle Rating:", 610, {0, 0.75, 1})
  140.  
  141. local SOLO_SHUFFLE_INDEX = 7
  142.  
  143. local function UpdatePvPStatsFrame()
  144.    
  145.     IncCalloutDB = IncCalloutDB or {}
  146.    
  147.     if not IsAddOnLoaded("Blizzard_PVPUI") then
  148.         LoadAddOn("Blizzard_PVPUI")
  149.     end
  150.  
  151.     local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
  152.     local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
  153.     local honorLevel = UnitHonorLevel("player")  
  154.  
  155.     -- Updated conquest point calculations
  156.     local currentConquestPoints = conquestInfo.quantity
  157.     local totalEarnedConquest = conquestInfo.totalEarned  -- Total conquest points earned ever
  158.     local weeklyEarnedConquest = conquestInfo.quantityEarnedThisWeek  -- Total conquest points earned this week
  159.     local conquestCap = conquestInfo.maxQuantity  -- Dynamically fetch the current conquest cap
  160.     local displayedConquestProgress = math.min(totalEarnedConquest, conquestCap)  -- Ensure displayed value does not exceed cap
  161.  
  162.     local rating = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX)
  163.     local soloShuffleRating = rating or "N/A"
  164.  
  165.     -- Display data
  166.     pvpStatsFrame.conquestValue:SetText(currentConquestPoints)
  167.     pvpStatsFrame.conquestCapValue:SetText(displayedConquestProgress .. " / " .. conquestCap)
  168.     pvpStatsFrame.honorValue:SetText(honorInfo.quantity)
  169.     pvpStatsFrame.honorLevelValue:SetText(honorLevel)  
  170.     pvpStatsFrame.soloShuffleRatingValue:SetText(soloShuffleRating)
  171.  
  172.     -- Adjust buttons based on PvP availability
  173.     local canUseRated = C_PvP.CanPlayerUseRatedPVPUI()
  174.     local canUsePremade = C_LFGInfo.CanPlayerUsePremadeGroup()
  175.  
  176.     if canUseRated then
  177.         PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton2, true)
  178.         PVPQueueFrame.CategoryButton2.tooltip = nil
  179.     end
  180.  
  181.     if canUsePremade then
  182.         PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton3, true)
  183.         PVPQueueFrame.CategoryButton3.tooltip = nil
  184.     end
  185. end
  186.  
  187.  
  188. local function GetDefaultClassColor()
  189.     local _, class = UnitClass("player")
  190.     if class then
  191.         return RAID_CLASS_COLORS[class]
  192.     end
  193. end
  194.  
  195. local function SavePvPStats()
  196.     IncCalloutDB = IncCalloutDB or {}
  197.     local character = UnitName("player") .. "-" .. GetRealmName()
  198.     if not IncCalloutDB[character] then
  199.         IncCalloutDB[character] = {}
  200.     end
  201.     local SavedSettings = IncCalloutDB[character]
  202.  
  203.     if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then
  204.         local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
  205.         local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
  206.         local honorLevel = UnitHonorLevel("player")  
  207.  
  208.         -- Updated conquest point calculations
  209.         SavedSettings.conquestValue = conquestInfo.quantity
  210.         SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity
  211.         SavedSettings.honorValue = honorInfo.quantity
  212.         SavedSettings.honorLevelValue = honorLevel  
  213.         SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A"
  214.     end
  215. end
  216.  
  217. local function InitializeCharacterDB()-- Fizz: Added because it didn't exist
  218.     -- I don't know what else is suppsed to go her???
  219.     SavePvPStats()
  220. end
  221.  
  222. pvpStatsFrame:SetScript("OnShow", function()
  223.     pvpStatsFrame.playerNameValue:SetText(UnitName("player") or "Unknown")
  224.     local classColor = GetDefaultClassColor()
  225.     if classColor then
  226.         pvpStatsFrame.playerNameValue:SetTextColor(classColor.r, classColor.g, classColor.b)
  227.     end
  228.     local character = UnitName("player") .. "-" .. GetRealmName()
  229.     local stats = IncCalloutDB[character]
  230.     if stats then
  231.         pvpStatsFrame.conquestValue:SetText(stats.conquestValue)
  232.         pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue)
  233.         pvpStatsFrame.honorValue:SetText(stats.honorValue)
  234.         pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue)  
  235.         pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue)
  236.     end
  237.     UpdatePvPStatsFrame()
  238. end)
  239.  
  240. -- Register event handlers
  241. local frame = CreateFrame("Frame")
  242. frame:RegisterEvent("PLAYER_LOGIN")
  243. frame:RegisterEvent("PLAYER_LOGOUT")
  244. frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  245. frame:RegisterEvent("HONOR_XP_UPDATE")
  246. frame:SetScript("OnEvent", function(self, event, arg1, ...)
  247.     if event == "PLAYER_LOGIN" then -- Fizz: Removed the or arg1 == test
  248.         InitializeCharacterDB()
  249.     elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then
  250.         UpdatePvPStatsFrame() -- Fizz: Changed from UpdatePvPStats()
  251.     end
  252. end)
  253.  
  254. local function ShowRaidWarning(message, duration)
  255.    
  256.     if IncDB.enableRaidWarnings then
  257.         customRaidWarningFrame.text:SetText(message)
  258.         customRaidWarningFrame.text:SetTextColor(1, 0, 0) -- Set text color to red
  259.         customRaidWarningFrame:Show()
  260.    
  261.         C_Timer.After(duration or 5, function()
  262.             customRaidWarningFrame:Hide()
  263.         end)
  264.     end
  265. end
  266.  
  267. local colorOptions = {
  268.     { name = "Semi-Transparent Black", color = {0, 0, 0, 0.5} },
  269.     { name = "Solid Black", color = {0, 0, 0, 1} },
  270.     { name = "Semi-Transparent White", color = {1, 1, 1, 0.5} },
  271.     { name = "Solid White", color = {1, 1, 1, 1} },
  272.     { name = "Semi-Transparent Red", color = {1, 0, 0, 0.5} },
  273.     { name = "Solid Red", color = {1, 0, 0, 1} },
  274.     { name = "Semi-Transparent Green", color = {0, 1, 0, 0.5} },
  275.     { name = "Solid Green", color = {0, 1, 0, 1} },
  276.     { name = "Semi-Transparent Blue", color = {0, 0, 1, 0.5} },
  277.     { name = "Solid Blue", color = {0, 0, 1, 1} },
  278.     { name = "Semi-Transparent Yellow", color = {1, 1, 0, 0.5} },
  279.     { name = "Solid Yellow", color = {1, 1, 0, 1} },
  280.     { name = "Semi-Transparent Cyan", color = {0, 1, 1, 0.5} },
  281.     { name = "Solid Cyan", color = {0, 1, 1, 1} },
  282.     { name = "Semi-Transparent Magenta", color = {1, 0, 1, 0.5} },
  283.     { name = "Solid Magenta", color = {1, 0, 1, 1} },
  284.     { name = "Semi-Transparent Orange", color = {1, 0.5, 0, 0.5} },
  285.     { name = "Solid Orange", color = {1, 0.5, 0, 1} },
  286.     { name = "Semi-Transparent Purple", color = {0.5, 0, 0.5, 0.5} },
  287.     { name = "Solid Purple", color = {0.5, 0, 0.5, 1} },
  288.     { name = "Semi-Transparent Grey", color = {0.5, 0.5, 0.5, 0.5} },
  289.     { name = "Solid Grey", color = {0.5, 0.5, 0.5, 1} },
  290.     { name = "Semi-Transparent Teal", color = {0, 0.5, 0.5, 0.5} },
  291.     { name = "Solid Teal", color = {0, 0.5, 0.5, 1} },
  292.     { name = "Semi-Transparent Pink", color = {1, 0.75, 0.8, 0.5} },
  293.     { name = "Solid Pink", color = {1, 0.75, 0.8, 1} },
  294.    
  295. }
  296.  
  297. local borderOptions = {
  298.     { name = "Azerite", file = "Interface/Tooltips/UI-Tooltip-Border-Azerite" },
  299.     { name = "Classic", file = "Interface/Tooltips/UI-Tooltip-Border" },
  300.     { name = "Sleek", file = "Interface/DialogFrame/UI-DialogBox-Border" },
  301.     { name = "Corrupted", file = "Interface/Tooltips/UI-Tooltip-Border-Corrupted" },
  302.     { name = "Maw", file = "Interface/Tooltips/UI-Tooltip-Border-Maw" },
  303.     { name = "Smooth", file = "Interface/LFGFRAME/LFGBorder" },
  304.     { name = "Glass", file = "Interface/DialogFrame/UI-DialogBox-TestWatermark-Border" },
  305.     { name = "Gold", file = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border" },
  306.     { name = "Slide", file = "Interface\\FriendsFrame\\UI-Toast-Border" },
  307.     { name = "Glow", file = "Interface\\TutorialFrame\\UI-TutorialFrame-CalloutGlow" },
  308.     { name = "Glow 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG15.blp" },
  309.     { name = "Grey", file = "Interface\\Tooltips\\UI-Tooltip-Background" },
  310.     { name = "Blue", file = "Interface\\AddOns\\IncCallout\\Textures\\BG1.png" },
  311.     { name = "Black Gloss", file = "Interface\\AddOns\\IncCallout\\Textures\\BG2.blp" },
  312.     { name = "Silverish", file = "Interface\\AddOns\\IncCallout\\Textures\\BG3.blp" },
  313.     { name = "Bevel", file = "Interface\\AddOns\\IncCallout\\Textures\\BG4.blp" },
  314.     { name = "Bevel 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG5.blp" },
  315.     { name = "Fade", file = "Interface\\AddOns\\IncCallout\\Textures\\BG6.blp" },
  316.     { name = "Fade 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG7.blp" },
  317.     { name = "Thin Line", file = "Interface\\AddOns\\IncCallout\\Textures\\BG8.blp" },
  318.     { name = "2 Tone", file = "Interface\\AddOns\\IncCallout\\Textures\\BG9.blp" },
  319.     { name = "Bluish", file = "Interface\\AddOns\\IncCallout\\Textures\\BG10.blp" },
  320.     { name = "Neon Yellow", file = "Interface\\AddOns\\IncCallout\\Textures\\BG11.blp" },
  321.     { name = "Neon Red", file = "Interface\\AddOns\\IncCallout\\Textures\\BG12.blp" },
  322.     { name = "Neon Green", file = "Interface\\AddOns\\IncCallout\\Textures\\BG13.blp" },
  323.     { name = "Neon Blue", file = "Interface\\AddOns\\IncCallout\\Textures\\BG14.blp" },
  324.     { name = "Double Yellow", file = "Interface\\AddOns\\IncCallout\\Textures\\BG16.blp" },
  325.            
  326. }
  327.  
  328. local battlegroundLocations = {
  329.     "Stables", "Blacksmith", "Lumber Mill", "Gold Mine", "Mine", "Trollbane Hall", "Defiler's Den", "Farm",
  330.     "Mage Tower", "Draenei Ruins", "Blood Elf Tower", "Fel Reaver Ruins",
  331.     "The Broken Temple", "Cauldron of Flames", "Central Bridge", "The Chilled Quagemire",
  332.     "Eastern Bridge", "Flamewatch Tower", "The Forest of Shadows", "Glacial Falls", "The Steppe of Life",
  333.     "The Sunken Ring", "Western Bridge", "Winter's Edge Tower", "Wintergrasp Fortress", "Eastpark Workshop", "Westpark Workshop ",
  334.     "Lighthouse", "Waterworks", "Mines", "Docks", "Workshop", "Horde Keep", "Alliance Keep", "Market",
  335.     "Hangar", "Refinery", "Quarry", "Wildhammer Stronghold", "Dragonmaw Stronghold",
  336.     "Silverwing Hold", "Warsong Flag Room", "Baradin Base Camp", "Rustberg Village",
  337.     "The Restless Front", "Wellson Shipyard", "Largo's Overlook", "Farson Hold",
  338.     "Forgotten Hill", "Hellscream's Grasp","Stormpike Graveyard", "Irondeep Mine", "Dun Baldar",
  339.     "Hall of the Stormpike", "Icewing Pass", "Stonehearth Outpost", "Iceblood Graveyard",
  340.     "Iceblood Garrison", "Tower Point", "Coldtooth Mine", "Dun Baldar Pass", "Icewing Bunker",
  341.     "Field of Strife", "Stonehearth Graveyard", "Stonehearth Bunker", "Frost Dagger Pass",
  342.     "Snowfall Graveyard", "Winterax Hold", "Frostwolf Graveyard", "Frostwolf Village",
  343.     "Deepwind Gorge", "Frostwolf Keep", "Hall of the Frostwolf","Temple of Kotmogu",  "Silvershard Mines", "Southshore vs. Tauren Mill", "Alterac Valley",
  344.     "Ashran", "StormShield", "The Ringing Deeps",  
  345. }
  346.  
  347. local buttonMessages = {
  348.     sendMore = {
  349.         "[Incoming-BG] We need more peeps",
  350.         "[Incoming-BG] Need help",
  351.         "[Incoming-BG] We are outnumbered",
  352.         "[Incoming-BG] Need a few more",
  353.         "[Incoming-BG] Need more",
  354.         "[Incoming-BG] Backup required",
  355.         "[Incoming-BG] We could use some help",
  356.         "[Incoming-BG] Calling for backup",
  357.         "[Incoming-BG] Could use some backup",
  358.         "[Incoming-BG] Reinforcements needed",
  359.         "[Incoming-BG] In need of additional support",
  360.         "[Incoming-BG] Calling all hands on deck",
  361.         "[Incoming-BG] Require extra manpower",
  362.         "[Incoming-BG] Assistance urgently needed",
  363.         "[Incoming-BG] Requesting more participants",
  364.        
  365.     },
  366.     inc = {
  367.         "[Incoming-BG] Incoming",
  368.         "[Incoming-BG] INC INC INC",
  369.         "[Incoming-BG] INC",
  370.         "[Incoming-BG] Gotta INC",
  371.         "[Incoming-BG] BIG INC",
  372.         "[Incoming-BG] Incoming enemy forces",
  373.         "[Incoming-BG] Incoming threat",
  374.         "[Incoming-BG] Enemy push incoming",
  375.         "[Incoming-BG] Enemy blitz incoming",
  376.         "[Incoming-BG] Enemy strike team inbound",
  377.         "[Incoming-BG] Incoming attack alert",
  378.         "[Incoming-BG] Enemy wave inbound",
  379.         "[Incoming-BG] Enemy squad closing in",
  380.         "[Incoming-BG] Anticipate enemy push",
  381.         "[Incoming-BG] Enemy forces are closing in",
  382.        
  383.     },
  384.     allClear = {
  385.         "[Incoming-BG] We are all clear",
  386.         "[Incoming-BG] All clear",
  387.         "[Incoming-BG] Looks like a ghost town",
  388.         "[Incoming-BG] All good",
  389.         "[Incoming-BG] Looking good",
  390.         "[Incoming-BG] Area secure",
  391.         "[Incoming-BG] All quiet on the front",
  392.         "[Incoming-BG] Situation is under control",
  393.         "[Incoming-BG] All quiet here",
  394.         "[Incoming-BG] We are looking good",
  395.         "[Incoming-BG] Perimeter is secured",
  396.         "[Incoming-BG] Situation is calm",
  397.         "[Incoming-BG] No threats detected",
  398.         "[Incoming-BG] All quiet on this end",
  399.         "[Incoming-BG] Area is threat-free",
  400.        
  401.     },
  402.     buffRequest = {
  403.     "[Incoming-BG] Need buffs please!",
  404.     "[Incoming-BG] Buff up, team!",
  405.     "[Incoming-BG] Could use some buffs here!",
  406.     "[Incoming-BG] Calling for all buffs, let's gear up!",
  407.     "[Incoming-BG] Looking for that magical boost, buffs needed!",
  408.     "[Incoming-BG] Time to get enchanted, where are those buffs?",
  409.     "[Incoming-BG] Let’s get buffed for the battle ahead!",
  410.     "[Incoming-BG] Buffs are our best friends, let’s have them!",
  411.     "[Incoming-BG] Ready for buffs, let's enhance our strength!",
  412.     "[Incoming-BG] Buffs needed for extra might and magic!",
  413.     "[Incoming-BG] Gimme some buffs, let’s not fall behind!"
  414.      },
  415.      healRequest = {
  416.     "[Incoming-BG] Need heals ASAP!",
  417.     "[Incoming-BG] Healing needed at my position!",
  418.     "[Incoming-BG] Can someone heal me, please?",
  419.     "[Incoming-BG] Healers, your assistance is required!",
  420.     "[Incoming-BG] I'm in dire need of healing!",
  421.     "[Incoming-BG] Could use some healing here!",
  422.     "[Incoming-BG] Healers, please focus on our location!",
  423.     "[Incoming-BG] Urgent healing needed to stay in the fight!",
  424.     "[Incoming-BG] Heal me up to keep the pressure on!",
  425.     "[Incoming-BG] Healers, attention needed here now!"  
  426.     },
  427.     efcRequest = {
  428.     "[Incoming-BG] Get the EFC!!",
  429.     "[Incoming-BG] EFC spotted, group up to kill and recover our flag!",
  430.     "[Incoming-BG] Kill the EFC on sight, let's bring that flag home!",
  431.     "[Incoming-BG] EFC is vulnerable, kill them now!",
  432.     "[Incoming-BG] Everyone on the EFC!",
  433.     "[Incoming-BG] Close in and kill the EFC, no escape allowed!",
  434.     "[Incoming-BG] EFC heading towards their base—kill them before they cap!",
  435.     "[Incoming-BG] The EFC is weak, finish them off!",
  436.     "[Incoming-BG] Kill the EFC now, they're almost at their base!",
  437.     "[Incoming-BG] It’s a race against time, kill the EFC and secure our victory!"
  438.     },
  439.     fcRequest = {
  440.     "[Incoming-BG] Protect our FC!",
  441.     "[Incoming-BG] FC needs help!!",
  442.     "[Incoming-BG] Heals on FC!",
  443.     "[Incoming-BG] Need some help with the FC.",
  444.     "[Incoming-BG] Someone needs to get the flag.",
  445.    
  446.    }
  447.  }
  448.  
  449. -- Define available logos
  450. local logos = {
  451.     None = "",
  452.     BearClaw = "Interface\\AddOns\\IncCallout\\Textures\\BearClaw.png",
  453.     BreatheFire = "Interface\\AddOns\\IncCallout\\Textures\\BreatheFire.png",
  454.     Bloody = "Interface\\AddOns\\IncCallout\\Textures\\Bloody.png",
  455.     Impact = "Interface\\AddOns\\IncCallout\\Textures\\Impact.png",
  456.     Shock = "Interface\\AddOns\\IncCallout\\Textures\\Shock.png",
  457.     Rifle = "Interface\\AddOns\\IncCallout\\Textures\\Rifle.png",
  458.     Condiment = "Interface\\AddOns\\IncCallout\\Textures\\Condiment.png",
  459.     Duplex = "Interface\\AddOns\\IncCallout\\Textures\\Duplex.png",
  460.     Eraser = "Interface\\AddOns\\IncCallout\\Textures\\Eraser.png",
  461.     Ogre = "Interface\\AddOns\\IncCallout\\Textures\\Ogre.png",
  462.     Seagram = "Interface\\AddOns\\IncCallout\\Textures\\Seagram.png",
  463.     SuperSunday = "Interface\\AddOns\\IncCallout\\Textures\\SuperSunday.png",
  464.     Minion = "Interface\\AddOns\\IncCallout\\Textures\\Minion.png",
  465.     Fire = "Interface\\AddOns\\IncCallout\\Textures\\Fire.png",
  466.     GOW = "Interface\\AddOns\\IncCallout\\Textures\\GOW.png",
  467.     Maiden = "Interface\\AddOns\\IncCallout\\Textures\\Maiden.png",
  468.     Metal = "Interface\\AddOns\\IncCallout\\Textures\\Metal.png",
  469.     Alligator = "Interface\\AddOns\\IncCallout\\Textures\\Alligator.png",
  470.     SourceCode = "Interface\\AddOns\\IncCallout\\Textures\\SourceCode.png",
  471.     InkFree = "Interface\\AddOns\\IncCallout\\Textures\\InkFree.png",
  472. }
  473.  
  474. -- Initial logo setup
  475. local logo = IncCallout:CreateTexture(nil, "ARTWORK")
  476. logo:SetSize(180, 30)
  477. logo:SetPoint("TOP", IncCallout, "TOP", -5, 30)
  478. logo:SetTexture(logos.BearClaw) -- Default logo
  479.  
  480. function IncCallout:SetLogo(selectedLogo)
  481.     if selectedLogo == "None" then
  482.         logo:Hide()  
  483.     else
  484.         local path = logos[selectedLogo]
  485.         if path then
  486.             logo:SetTexture(path)
  487.             logo:Show()
  488.         else
  489.             print("Logo path not found for:", selectedLogo)
  490.         end
  491.     end
  492. end
  493.  
  494. local fontSize = 14
  495.  
  496. local bgTexture = IncCallout:CreateTexture(nil, "BACKGROUND")
  497. bgTexture:SetColorTexture(0, 0, 0)
  498. bgTexture:SetAllPoints(IncCallout)
  499.  
  500. IncCallout:SetScript("OnDragStart", function(self)
  501.     if not IncDB.isLocked then
  502.         self:StartMoving()
  503.     end
  504. end)
  505.  
  506. IncCallout:SetScript("OnDragStop", function(self)
  507.     self:StopMovingOrSizing()
  508.    
  509.     if not IncDB.isLocked then
  510.                
  511.     end
  512. end)
  513.  
  514. -- Function to create a button
  515. local function createButton(name, width, height, text, anchor, xOffset, yOffset, onClick)
  516.     local button = CreateFrame("Button", nil, IncCallout, "BackdropTemplate")
  517.     button:SetSize(width, height)
  518.     button:SetText(text)
  519.     if type(anchor) == "table" then
  520.         button:SetPoint(anchor[1], anchor[2], anchor[3], xOffset, yOffset)
  521.     else
  522.         button:SetPoint(anchor, xOffset, yOffset)
  523.     end
  524.     button:GetFontString():SetTextColor(1, 1, 1, 1)
  525.     button:SetBackdrop({
  526.         bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  527.         edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  528.         tile = true,
  529.         tileSize = 12,
  530.         edgeSize = 7,  
  531.         insets = {left = 1, right = 1, top = 1, bottom = 1}
  532.     })
  533.  
  534.     table.insert(buttonTexts, button:GetFontString())
  535.     table.insert(buttons, button)
  536.    
  537.     button:SetScript("OnMouseDown", function(self)
  538.         self:SetBackdropColor(0, 0, 0, 0)
  539.     end)
  540.     button:SetScript("OnMouseUp", function(self, mouseButton)
  541.         if mouseButton == "LeftButton" then
  542.             self:SetBackdropColor(0, 0, 0, 0)
  543.         end
  544.     end)
  545.    
  546.     button:SetScript("OnClick", function(self, mouseButton, down)
  547.         if mouseButton == "LeftButton" and not down then
  548.             if useCustomSound then
  549.                 if IncDB.raidWarningSound and type(IncDB.raidWarningSound) == "number" then
  550.                     PlaySound(IncDB.raidWarningSound, "master")
  551.                 else
  552.                     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  553.                 end
  554.             end
  555.  
  556.             if onClick then
  557.                 onClick(self)
  558.             end
  559.         end
  560.     end)
  561.  
  562.     return button
  563. end
  564.  
  565. local function applyButtonColor()
  566.  
  567.     if not IncDB then
  568.         return
  569.     end
  570.  
  571.     local r, g, b, a
  572.     if IncDB.buttonColor then
  573.         r, g, b, a = IncDB.buttonColor.r, IncDB.buttonColor.g, IncDB.buttonColor.b, IncDB.buttonColor.a
  574.     else
  575.         r, g, b, a = 1, 0, 0, 1 -- Default to red
  576.     end
  577.     for _, button in ipairs(buttons) do
  578.         button:SetBackdropColor(r, g, b, a)        
  579.     end
  580. end
  581.  
  582. IncCallout:SetScript("OnShow", function()
  583.     if IncDB then
  584.         applyButtonColor()
  585.     end
  586. end)
  587.  
  588. local function applyBorderChange()
  589.     local selectedIndex = IncDB.selectedBorderIndex or 1
  590.     local selectedBorder = borderOptions[selectedIndex].file
  591.  
  592.     local backdropSettings = {
  593.         bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  594.         edgeFile = selectedBorder,
  595.         tile = false,
  596.         tileSize = 16,
  597.         edgeSize = 8,
  598.         insets = { left = 4, right = 4, top = 4, bottom = 4 }
  599.     }
  600.  
  601.     IncCallout:SetBackdrop(backdropSettings)   
  602. end
  603.  
  604. local function applyColorChange()
  605.     local selectedIndex = IncDB.selectedColorIndex or 1
  606.     local selectedColor = colorOptions[selectedIndex].color
  607.  
  608.     IncCallout:SetBackdropColor(unpack(selectedColor))
  609. end
  610.  
  611. local function ScaleGUI()
  612.     local scaleFactor = IncDB.scale or 1; -- Default scale is 1
  613.     IncCallout:SetScale(scaleFactor);
  614.    
  615.     local adjustedFontSize = math.floor(fontSize * scaleFactor);
  616.      
  617.     for _, buttonText in ipairs(buttonTexts) do
  618.         buttonText:SetFont("Fonts\\FRIZQT__.TTF", adjustedFontSize);
  619.     end
  620. end
  621.  
  622. local mapSizeOptions = {
  623.     { name = "Very Small", value = 0.4 },
  624.     { name = "Small", value = 0.5 },
  625.     { name = "Medium Small", value = 0.65 },
  626.     { name = "Medium", value = 0.75 }, -- Assuming this is the current default
  627.     { name = "Medium Large", value = 0.85 },
  628.     { name = "Large", value = 1.0 },
  629.     { name = "Very Large", value = 1.15 },
  630.     { name = "Huge", value = 1.3 },
  631.     { name = "Gigantic", value = 1.45 },
  632.     { name = "Colossal", value = 1.6 }
  633. }
  634.  
  635. local soundOptions = {
  636.     [8959] = "Raid Warning",
  637.     [8459] = "PVP Que ",
  638.     [15266] = "Whistle",
  639.     [12867] = "Horn",
  640.     [9656] = "Laughing",
  641.     [888] = "Level Up",
  642.     [8960] = "Ready Check",
  643.     [880] = "Drums",
  644.     [9379] = "PVP Flag",
  645.     [89880] = "Fireworks",
  646.     [176304] = "Launcher",
  647.     [34154] = "Challenge",
  648.     [12867] = "Alarm",
  649.     [161485] = "Lightning",
  650.     ["none"] = "No sound",
  651. }
  652.  
  653. local options = {
  654.     name = "Incoming-BG",
  655.     type = "group",
  656.     args = {
  657.         messageSettings = {
  658.             type = "group",
  659.             name = "Message Settings",
  660.             order = 1,
  661.             args = {
  662.                 sendMore = {
  663.     type = "select",
  664.     name = "Send More Message",
  665.     desc = "Select the message for the 'Send More' button",
  666.     values = buttonMessages.sendMore,
  667.     get = function() return IncDB.sendMoreIndex end,  -- Directly use IncDB to get the current value
  668.     set = function(_, newValue)
  669.         IncDB.sendMoreIndex = newValue  -- Directly use IncDB to save the new value
  670.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  671.     end,
  672.     order = 1,
  673. },
  674. previewSendMore = {
  675.     type = "description",
  676.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("sendMore") .. "|r" end,
  677.     fontSize = "medium",
  678.     order = 1.1,
  679. },
  680. inc = {
  681.     type = "select",
  682.     name = "INC Message",
  683.     desc = "Select the message for the 'INC' button",
  684.     values = buttonMessages.inc,
  685.     get = function() return IncDB.incIndex end,  
  686.     set = function(_, newValue)
  687.         IncDB.incIndex = newValue  
  688.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  689.     end,
  690.     order = 2,
  691. },
  692. previewInc = {
  693.     type = "description",
  694.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("inc") .. "|r" end,
  695.     fontSize = "medium",
  696.     order = 2.1,
  697. },
  698. allClear = {
  699.     type = "select",
  700.     name = "All Clear Message",
  701.     desc = "Select the message for the 'All Clear' button",
  702.     values = buttonMessages.allClear,
  703.     get = function() return IncDB.allClearIndex end,  
  704.     set = function(_, newValue)
  705.         IncDB.allClearIndex = newValue  
  706.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  707.     end,
  708.     order = 3,
  709. },
  710. previewAllClear = {
  711.     type = "description",
  712.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("allClear") .. "|r" end,
  713.     fontSize = "medium",
  714.     order = 3.1,
  715.                 },
  716.                 buffRequest = {
  717.     type = "select",
  718.     name = "Buff Request Message",
  719.     desc = "Select the message for the 'Request Buffs' button",
  720.     values = buttonMessages.buffRequest,
  721.     get = function() return IncDB.buffRequestIndex end,
  722.     set = function(_, newValue)
  723.         buttonMessageIndices.buffRequest = newValue
  724.         IncDB.buffRequestIndex = newValue
  725.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  726.     end,
  727.     order = 4,
  728. },
  729. previewBuffRequest = {
  730.     type = "description",
  731.     name = function() return addonNamespace.getPreviewText("buffRequest") end,
  732.     fontSize = "medium",
  733.     order = 4.1,
  734.     },
  735.     healRequest = {
  736.     type = "select",
  737.     name = "Heal Request Message",
  738.     desc = "Select the message for the 'Need Heals' button",
  739.     values = buttonMessages.healRequest,
  740.     get = function() return IncDB.healRequestIndex end,
  741.     set = function(_, newValue)
  742.         buttonMessageIndices.healRequest = newValue
  743.         IncDB.healRequestIndex = newValue
  744.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  745.     end,
  746.     order = 5,
  747. },
  748. previewHealRequest = {
  749.     type = "description",
  750.     name = function() return addonNamespace.getPreviewText("healRequest") end,
  751.     fontSize = "medium",
  752.     order = 5.1,
  753. },
  754. efcRequest = {
  755.     type = "select",
  756.     name = "EFC Request Message",
  757.     desc = "Select the message for the 'EFC' button",
  758.     values = buttonMessages.efcRequest,
  759.     get = function() return IncDB.efcRequestIndex end,
  760.     set = function(_, newValue)
  761.         buttonMessageIndices.efcRequest = newValue
  762.         IncDB.efcRequestIndex = newValue
  763.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  764.     end,
  765.     order = 6,
  766. },
  767. previewEFCRequest = {
  768.     type = "description",
  769.     name = function() return addonNamespace.getPreviewText("efcRequest") end,
  770.     fontSize = "medium",
  771.     order = 6.1,
  772.     },
  773.     fcRequest = {
  774.     type = "select",
  775.     name = "FC Request Message",
  776.     desc = "Select the message for the 'FC' button",
  777.     values = buttonMessages.fcRequest,
  778.     get = function() return IncDB.fcRequestIndex end,
  779.     set = function(_, newValue)
  780.         buttonMessageIndices.fcRequest = newValue
  781.         IncDB.fcRequestIndex = newValue
  782.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  783.     end,
  784.     order = 7,
  785. },
  786. previewFCRequest = {
  787.     type = "description",
  788.     name = function() return addonNamespace.getPreviewText("fcRequest") end,
  789.     fontSize = "medium",
  790.     order = 7.1,
  791.  
  792.                 },
  793.             },
  794.         },
  795.         appearanceSettings = {
  796.     type = "group",
  797.     name = "Appearance Settings",
  798.     order = 2,
  799.     args = {
  800.         fontColor = {
  801.     type = "color",
  802.     name = "Button Font Color",
  803.     desc = "Set the color of the button text.",
  804.     hasAlpha = true,
  805.     get = function()
  806.         local color = IncDB.fontColor or {r = 1, g = 1, b = 1, a = 1} -- default white
  807.         return color.r, color.g, color.b, color.a
  808.     end,
  809.     set = function(_, r, g, b, a)
  810.         IncDB.fontColor = {r = r, g = g, b = b, a = a}
  811.        
  812.         for _, buttonText in ipairs(buttonTexts) do
  813.             buttonText:SetTextColor(r, g, b, a)
  814.         end
  815.     end,
  816.     order = 1,  
  817.                                     },
  818.                     buttonColor = {
  819.                                 type = "color",
  820.                                 name = "Button Color",
  821.                                 desc = "Select the color of the buttons.",
  822.                                 order = 2,
  823.                                 hasAlpha = true,
  824.                                 get = function()
  825.                                     local currentColor = IncDB.buttonColor or {r = 1, g = 0, b = 0, a = 1} -- Default to red
  826.                                     return currentColor.r, currentColor.g, currentColor.b, currentColor.a
  827.                                  end,
  828.                                  set = function(_, r, g, b, a)
  829.                                  local color = {r = r, g = g, b = b, a = a}
  830.                                  IncDB.buttonColor = color
  831.                                  applyButtonColor()
  832.                                  end,
  833.         },
  834.         scaleOption = {
  835.                     type = "range",
  836.                     name = "GUI Window Scale",
  837.                     desc = "Adjust the scale of the GUI.",
  838.                     min = 0.5,
  839.                     max = 2.0,
  840.                     step = 0.05,
  841.                     get = function()
  842.                     return IncDB.scale or 1
  843.                  end,
  844.                    set = function(_, value)
  845.                    IncDB.scale = value
  846.                    ScaleGUI(value)
  847.                 end,
  848.         },
  849.         borderStyle = {
  850.             type = "select",
  851.             name = "Border Style",
  852.             desc = "Select the border style for the frame.",
  853.             style = "dropdown",
  854.             order = 3,
  855.             values = function()
  856.                 local values = {}
  857.                 for i, option in ipairs(borderOptions) do
  858.                     values[i] = option.name
  859.                 end
  860.                 return values
  861.             end,
  862.             get = function()
  863.                 return IncDB.selectedBorderIndex or 1
  864.             end,
  865.             set = function(_, selectedIndex)
  866.                 IncDB.selectedBorderIndex = selectedIndex
  867.                 applyBorderChange()
  868.                 applyColorChange()
  869.             end,
  870.         },
  871.         backdropColor = {
  872.             type = "select",
  873.             name = "Backdrop Color",
  874.             desc = "Select the backdrop color and transparency for the frame.",
  875.             style = "dropdown",
  876.             order = 4,
  877.             values = function()
  878.                 local values = {}
  879.                 for i, option in ipairs(colorOptions) do
  880.                     values[i] = option.name
  881.                 end
  882.                 return values
  883.             end,
  884.             get = function()
  885.                 return IncDB.selectedColorIndex or 1
  886.             end,
  887.             set = function(_, selectedIndex)
  888.                 IncDB.selectedColorIndex = selectedIndex
  889.                 applyColorChange()
  890.             end,
  891.         },
  892.         enableRaidWarnings = {
  893.             type = "toggle",
  894.             name = "Enable Raid Warnings",
  895.             desc = "Toggle Raid Warning Messages on or off.",
  896.             order = 5,
  897.             get = function() return IncDB.enableRaidWarnings end,
  898.             set = function(_, value)
  899.                 IncDB.enableRaidWarnings = value
  900.                 -- Function to toggle raid warnings
  901.             end,
  902.         },
  903.         raidWarningSound = {
  904.             type = "select",
  905.             name = "Raid Warning Sound",
  906.             desc = "Select the sound to play for Raid Warnings.",
  907.             order = 6,
  908.             values = soundOptions,
  909.             get = function() return IncDB.raidWarningSound end,
  910.             set = function(_, selectedValue)
  911.                 IncDB.raidWarningSound = selectedValue
  912.                
  913.                 if selectedValue and type(selectedValue) == "number" then
  914.                     PlaySound(selectedValue, "master")
  915.                 end
  916.             end,
  917.         },
  918.         lockGUI = {
  919.             type = "toggle",
  920.             name = "Lock GUI Window",
  921.             desc = "Lock or unlock the GUI window's position.",
  922.             order = 7,
  923.             get = function() return IncDB.isLocked end,
  924.             set = function(_, value)
  925.                 IncDB.isLocked = value
  926.                
  927.             end,
  928.             },
  929.             logoSelection = {
  930.     type = "select",
  931.     name = "Logo Selection",
  932.     desc = "Choose a logo to display at the top of the frame.",
  933.     style = "dropdown",
  934.     order = 8,
  935.     values = {
  936.         ["None"] = "None",
  937.         ["BearClaw"] = "BearClaw",
  938.         ["BreatheFire"] = "BreatheFire",
  939.         ["Bloody"] = "Bloody",
  940.         ["Impact"] = "Impact",
  941.         ["Shock"] = "Shock",
  942.         ["Rifle"] = "Rifle",
  943.         ["Condiment"] = "Condiment",
  944.         ["Duplex"] = "Duplex",
  945.         ["Eraser"] = "Eraser",
  946.         ["Ogre"] = "Ogre",
  947.         ["Seagram"] = "Seagram",
  948.         ["SuperSunday"] = "SuperSunday",
  949.         ["Minion"] = "Minion",
  950.         ["Alligator"] = "Alligator",
  951.         ["Fire"] = "Fire",
  952.         ["GOW"] = "GOW",
  953.         ["Maiden"] = "Maiden",
  954.         ["Metal"] = "Metal",
  955.         ["SourceCode"] = "SourceCode",
  956.         ["InkFree"] = "InkFree",
  957.     },
  958.     get = function(info) return IncDB.selectedLogo end,
  959.     set = function(info, value)
  960.         IncDB.selectedLogo = value
  961.         IncCallout:SetLogo(value)  
  962.     end,
  963.     },
  964.     logoColor = {
  965.     type = "color",
  966.     name = "Logo Color",
  967.     desc = "Set the color of the title logo.",
  968.     hasAlpha = true,
  969.     get = function(info)
  970.         local color = IncDB.logoColor or {1, 1, 1, 1} -- Default to white if not set
  971.         return color.r, color.g, color.b, color.a
  972.     end,
  973.     set = function(info, r, g, b, a)
  974.         IncDB.logoColor = {r = r, g = g, b = b, a = a}
  975.        
  976.         logo:SetVertexColor(r, g, b, a)
  977.     end,
  978.     order = 9,
  979.         },
  980.     },
  981. },
  982.  
  983.         mapSettings = {
  984.             type = "group",
  985.             name = "Map Settings",
  986.             order = 3,
  987.             args = {
  988.                     mapSizeChoice = {
  989.                     type = "select",
  990.                     name = "Map Size",
  991.                     desc = "Select the preferred size of the WorldMap.",
  992.                     order = 6,
  993.                     style = "dropdown",
  994.                     values = function()
  995.                         local values = {}
  996.                         for _, sizeOption in ipairs(mapSizeOptions) do
  997.                             values[sizeOption.value] = sizeOption.name
  998.                         end
  999.                         return values
  1000.                     end,
  1001.                     get = function() return IncCalloutDB.settings.mapScale end,
  1002.                     set = function(_, selectedValue)
  1003.                         IncCalloutDB.settings.mapScale = selectedValue
  1004.                         if addonNamespace.ResizeWorldMap then
  1005.                             addonNamespace.ResizeWorldMap()
  1006.                         end
  1007.                     end,
  1008.                 },
  1009.                 resizeInPvPOnly = {
  1010.                     type = "toggle",
  1011.                     name = "Resize Map in PvP Only",
  1012.                     desc = "Enable to resize the WorldMap only in PvP scenarios.",
  1013.                     order = 7,
  1014.                     get = function() return IncCalloutDB.settings.resizeInPvPOnly end,
  1015.                     set = function(_, value)
  1016.                         IncCalloutDB.settings.resizeInPvPOnly = value
  1017.                         if addonNamespace.ResizeWorldMap then
  1018.                             addonNamespace.ResizeWorldMap()
  1019.                         end
  1020.                     end,
  1021.                 },
  1022.             },
  1023.         },
  1024.        fontSettings = {
  1025.             type = "group",
  1026.             name = "Font Settings",
  1027.             order = 3,
  1028.             args = {
  1029.                 font = {
  1030.                     type = "select",
  1031.                     name = "Font",
  1032.                     desc = "Select the font for the buttons.",
  1033.                     dialogControl = "LSM30_Font",
  1034.                     values = LSM:HashTable("font"),
  1035.                     get = function()
  1036.                         return IncDB.font or "Friz Quadrata TT"
  1037.                     end,
  1038.                     set = function(_, newValue)
  1039.                         IncDB.font = newValue
  1040.                         local size = IncDB.fontSize or 14
  1041.                         for _, text in ipairs(buttonTexts) do
  1042.                             text:SetFont(LSM:Fetch("font", newValue), size)
  1043.                         end
  1044.                     end,
  1045.                     order = 1,
  1046.                 },
  1047.                 fontSize = {
  1048.                     type = "range",
  1049.                     name = "Font Size",
  1050.                     desc = "Adjust the font size for the buttons.",
  1051.                     min = 8, max = 24, step = 1,
  1052.                     get = function() return IncDB.fontSize or 14 end,
  1053.                     set = function(_, newValue)
  1054.                         IncDB.fontSize = newValue
  1055.                         local font = IncDB.font or "Friz Quadrata TT"
  1056.                         for _, text in ipairs(buttonTexts) do
  1057.                             text:SetFont(LSM:Fetch("font", font), newValue)
  1058.                         end
  1059.                     end,
  1060.                     order = 2,
  1061.                 },
  1062.             },
  1063.         },
  1064.     },
  1065. }
  1066. -- Register the options table
  1067. AceConfig:RegisterOptionsTable(addonName, options)
  1068.  
  1069. -- Create a config panel
  1070. local configPanel = AceConfigDialog:AddToBlizOptions(addonName, "Incoming-BG")
  1071. configPanel.default = function()
  1072.     buttonMessageIndices.sendMore = 1
  1073.     buttonMessageIndices.inc = 1
  1074.     buttonMessageIndices.allClear = 1
  1075.     buttonMessageIndices.buffRequest = 1
  1076.     IncDB.selectedBorderIndex = 1
  1077.  
  1078. end
  1079.  
  1080. function addonNamespace.getPreviewText(messageType)
  1081.     local previewText = "|cff00ff00[Incoming-BG] "
  1082.  
  1083.     if messageType == "sendMore" and IncDB.sendMoreIndex and buttonMessages.sendMore[IncDB.sendMoreIndex] then
  1084.         previewText = previewText .. buttonMessages.sendMore[IncDB.sendMoreIndex]
  1085.     elseif messageType == "inc" and IncDB.incIndex and buttonMessages.inc[IncDB.incIndex] then
  1086.         previewText = previewText .. buttonMessages.inc[IncDB.incIndex]
  1087.     elseif messageType == "allClear" and IncDB.allClearIndex and buttonMessages.allClear[IncDB.allClearIndex] then
  1088.         previewText = previewText .. buttonMessages.allClear[IncDB.allClearIndex]
  1089.     elseif messageType == "buffRequest" and IncDB.buffRequestIndex and buttonMessages.buffRequest[IncDB.buffRequestIndex] then
  1090.         previewText = previewText .. buttonMessages.buffRequest[IncDB.buffRequestIndex]
  1091.     elseif messageType == "healRequest" and IncDB.healRequestIndex and buttonMessages.healRequest[IncDB.healRequestIndex] then
  1092.         previewText = previewText .. buttonMessages.healRequest[IncDB.healRequestIndex]
  1093.     elseif messageType == "efcRequest" and IncDB.efcRequestIndex and buttonMessages.efcRequest[IncDB.efcRequestIndex] then
  1094.         previewText = previewText .. buttonMessages.efcRequest[IncDB.efcRequestIndex]
  1095.     elseif messageType == "fcRequest" and IncDB.fcRequestIndex and buttonMessages.fcRequest[IncDB.fcRequestIndex] then
  1096.         previewText = previewText .. buttonMessages.fcRequest[IncDB.fcRequestIndex]
  1097.     end
  1098.  
  1099.     return previewText .. "|r"
  1100. end
  1101.  
  1102.  
  1103. local messageQueue = {}
  1104. local timeLastMessageSent = 0
  1105. local MESSAGE_DELAY = 1.5 -- Delay in seconds between messages
  1106.  
  1107. local function SendMessage()
  1108.     if #messageQueue == 0 then return end
  1109.     if time() - timeLastMessageSent < MESSAGE_DELAY then return end -- Check if delay has passed
  1110.  
  1111.     local message = table.remove(messageQueue, 1)
  1112.     SendChatMessage(message.text, message.channel)
  1113.     timeLastMessageSent = time()
  1114. end
  1115.  
  1116. local function QueueMessage(text, channel)
  1117.     table.insert(messageQueue, {text = text, channel = channel})
  1118. end
  1119.  
  1120. local function ListHealers()
  1121.     local groupType, groupSize
  1122.     if IsInRaid() then
  1123.         groupType = "raid"
  1124.         groupSize = GetNumGroupMembers()
  1125.     elseif IsInGroup() then
  1126.         groupType = "party"
  1127.         groupSize = GetNumGroupMembers()
  1128.     else
  1129.         print("You are not in a group.")
  1130.         return
  1131.     end
  1132.  
  1133.     local healerNames = {}
  1134.     for i = 1, groupSize do
  1135.         local unit = groupType..i
  1136.         local role = UnitGroupRolesAssigned(unit)
  1137.         if role == "HEALER" then
  1138.             table.insert(healerNames, GetUnitName(unit, true))
  1139.         end
  1140.     end
  1141.  
  1142.     if #healerNames > 0 then
  1143.         local healerList = table.concat(healerNames, ", ")
  1144.         QueueMessage("[Incoming-BG] Healers on our team: " .. healerList .. ". Now you know who to peel for.", "INSTANCE_CHAT")
  1145.     else
  1146.         if IsInGroup() or IsInRaid() then
  1147.             QueueMessage("[Incoming-BG] We have no heals, lol..", "INSTANCE_CHAT")
  1148.         end
  1149.     end
  1150. end
  1151.  
  1152. -- Setup a frame to periodically attempt to send messages
  1153. local frame = CreateFrame("Frame")
  1154. frame:SetScript("OnUpdate", function(self, elapsed)
  1155.     SendMessage()
  1156. end)
  1157.  
  1158.  
  1159. -- Create a table to map each location to itself
  1160. local locationTable = {}
  1161. for _, location in ipairs(battlegroundLocations) do
  1162.     locationTable[location] = location
  1163. end
  1164.  
  1165. local function isInBattleground()
  1166.     local inInstance, instanceType = IsInInstance()
  1167.     return inInstance and (instanceType == "pvp" or instanceType == "arena")
  1168. end
  1169.  
  1170. local function ButtonOnClick(self)
  1171.     if not isInBattleground() then
  1172.         print("You are not in a battleground.")
  1173.         return
  1174.     end
  1175.  
  1176.     if IncDB.raidWarningSound and type(IncDB.raidWarningSound) == "number" then
  1177.         PlaySound(IncDB.raidWarningSound, "master")
  1178.     end
  1179.  
  1180.     local currentLocation = GetSubZoneText()
  1181.    
  1182.     local message = "[Incoming-BG] " .. self:GetText() .. " Incoming at " .. currentLocation
  1183.     SendChatMessage(message, "INSTANCE_CHAT")
  1184.     ShowRaidWarning(message, 2)
  1185. end
  1186.  
  1187. local f = CreateFrame("Frame")
  1188. f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  1189.  
  1190. local function UpdatePoints()
  1191.  
  1192.     if not IncDB then
  1193.         return
  1194.     end
  1195.  
  1196.     local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(CONQUEST_CURRENCY_ID)
  1197.     local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)
  1198.  
  1199. end
  1200.  
  1201. IncCallout:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  1202. IncCallout:RegisterEvent("HONOR_XP_UPDATE")
  1203. IncCallout:SetScript("OnEvent", function(self, event, ...)
  1204.     if event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" then
  1205.         UpdatePoints()
  1206.         ApplyFontSettings()
  1207.     end
  1208. end)
  1209.  
  1210. UpdatePoints()
  1211.  
  1212. f:SetScript("OnEvent", function(self, event, ...)
  1213.     if event == "ZONE_CHANGED_NEW_AREA" then
  1214.         local currentLocation = GetRealZoneText() .. " - " .. GetSubZoneText()
  1215.         local location = locationTable[currentLocation]
  1216.  
  1217.         if location then
  1218.             IncCallout:Show()  
  1219.         else
  1220.            
  1221.         end
  1222.     end
  1223. end)
  1224.  
  1225. local IncCalloutLDB = LibStub("LibDataBroker-1.1"):NewDataObject("Incoming-BG", {
  1226.     type = "data source",
  1227.     text = "Incoming-BG",
  1228.     icon = "Interface\\AddOns\\IncCallout\\Icon\\INC.png",
  1229.     OnClick = function(_, button)
  1230.         if button == "LeftButton" then
  1231.             if IncCallout:IsShown() then
  1232.                 IncCallout:Hide()
  1233.             else
  1234.                 IncCallout:Show()
  1235.             end
  1236.         else
  1237.             InterfaceOptionsFrame_OpenToCategory("Incoming-BG")
  1238.             InterfaceOptionsFrame_OpenToCategory("Incoming-BG") -- Call it twice to ensure the correct category is selected
  1239.         end
  1240.     end,
  1241.     OnMouseDown = function(self, button)
  1242.         if button == "LeftButton" then
  1243.             IncCallout:StartMoving()
  1244.         end
  1245.     end,
  1246.     OnMouseUp = function(self, button)
  1247.         if button == "LeftButton" then
  1248.             IncCallout:StopMovingOrSizing()
  1249.             local point, _, _, x, y = IncCallout:GetPoint()
  1250.             local centerX, centerY = Minimap:GetCenter()
  1251.             local scale = Minimap:GetEffectiveScale()
  1252.             x, y = (x - centerX) / scale, (y - centerY) / scale
  1253.             IncDB.minimap.minimapPos = math.deg(math.atan2(y, x)) % 360
  1254.         end
  1255.     end,
  1256.     OnTooltipShow = function(tooltip)
  1257.         tooltip:AddLine("|cffff0000Incoming-BG|r")
  1258.         tooltip:AddLine("Left Click: GUI")
  1259.         tooltip:AddLine("Right Click: Options")
  1260.         tooltip:Show()
  1261.     end,
  1262. })
  1263.  
  1264. -- Function to handle the All Clear button click event
  1265. local function AllClearButtonOnClick()
  1266.    
  1267.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1268.         PlaySound(IncDB.raidWarningSound, "master")
  1269.     else
  1270.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1271.     end
  1272.  
  1273.     local location = GetSubZoneText()
  1274.     if not location then
  1275.         print("You are not in a Battleground.")
  1276.         return
  1277.     end
  1278.  
  1279.     local message = buttonMessages.allClear[buttonMessageIndices.allClear] .. " at " .. location
  1280.     SendChatMessage(message, "INSTANCE_CHAT")
  1281.     ShowRaidWarning(message, 2)
  1282. end
  1283.  
  1284. -- Function to handle the Send More button click event
  1285. local function SendMoreButtonOnClick()
  1286.    
  1287.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1288.         PlaySound(IncDB.raidWarningSound, "master")
  1289.     else
  1290.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1291.     end
  1292.  
  1293.     local location = GetSubZoneText()
  1294.     if not location then
  1295.         print("You are not in a Battleground.")
  1296.         return
  1297.     end
  1298.  
  1299.     local message = buttonMessages.sendMore[buttonMessageIndices.sendMore] .. " at " .. location
  1300.     SendChatMessage(message, "INSTANCE_CHAT")
  1301.     ShowRaidWarning(message, 2)
  1302. end
  1303.  
  1304. -- Function to handle the INC button click event
  1305. local function IncButtonOnClick()
  1306.    
  1307.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1308.         PlaySound(IncDB.raidWarningSound, "master")
  1309.     else
  1310.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1311.     end
  1312.  
  1313.     local location = GetSubZoneText()
  1314.     if not location then
  1315.         print("You are not in a Battleground.")
  1316.         return
  1317.     end
  1318.  
  1319.     local message = buttonMessages.inc[buttonMessageIndices.inc] .. " at " .. location
  1320.     SendChatMessage(message, "INSTANCE_CHAT")
  1321.     ShowRaidWarning(message, 2)
  1322. end
  1323.  
  1324. -- Define the OnClick function for EFC
  1325. local function EFCButtonOnClick()
  1326.     if not InCombatLockdown() then
  1327.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1328.     end
  1329.    
  1330.     local inInstance, instanceType = IsInInstance()
  1331.     local chatType
  1332.  
  1333.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1334.         chatType = "INSTANCE_CHAT"
  1335.     elseif IsInRaid() then
  1336.         chatType = "RAID"
  1337.     elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
  1338.         chatType = "PARTY"
  1339.     else
  1340.         print("You're not in a PvP instance or any group.")
  1341.         return
  1342.     end
  1343.  
  1344.     local message = buttonMessages.efcRequest[IncDB.efcRequestIndex]
  1345.     SendChatMessage(message, chatType)
  1346.     ShowRaidWarning(message, 2)
  1347. end
  1348.  
  1349. -- Define the OnClick function for FC
  1350. local function FCButtonOnClick()
  1351.     if not InCombatLockdown() then
  1352.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1353.     end
  1354.    
  1355.     local inInstance, instanceType = IsInInstance()
  1356.     local chatType
  1357.  
  1358.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1359.         chatType = "INSTANCE_CHAT"
  1360.     elseif IsInRaid() then
  1361.         chatType = "RAID"
  1362.     elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
  1363.         chatType = "PARTY"
  1364.     else
  1365.         print("You're not in a PvP instance or any group.")
  1366.         return
  1367.     end
  1368.  
  1369.     local message = buttonMessages.fcRequest[IncDB.fcRequestIndex]
  1370.     SendChatMessage(message, chatType)
  1371.     ShowRaidWarning(message, 2)
  1372. end
  1373.  
  1374.  
  1375. local function HealsButtonOnClick()
  1376.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1377.         PlaySound(IncDB.raidWarningSound, "master")
  1378.     else
  1379.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1380.     end
  1381.  
  1382.     local location = GetSubZoneText()
  1383.     if not location then
  1384.         print("You are not in a Battleground.")
  1385.         return
  1386.     end
  1387.  
  1388.     if not IncDB.healRequestIndex or not buttonMessages.healRequest[IncDB.healRequestIndex] then
  1389.         print("Heal request message not set.")
  1390.         return
  1391.     end
  1392.  
  1393.     local message = buttonMessages.healRequest[IncDB.healRequestIndex] .. " Needed at " .. location
  1394.     SendChatMessage(message, "INSTANCE_CHAT")
  1395.     ShowRaidWarning(message, 2)
  1396. end
  1397.  
  1398. local function BuffRequestButtonOnClick()
  1399.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1400.  
  1401.     local messageIndex = buttonMessageIndices.buffRequest or 1
  1402.     local message = buttonMessages.buffRequest[messageIndex]
  1403.    
  1404.     if not message then
  1405.         print("No buff request message available.")
  1406.         return
  1407.     end
  1408.  
  1409.     local inInstance, instanceType = IsInInstance()
  1410.     local chatType
  1411.  
  1412.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1413.         chatType = "INSTANCE_CHAT"
  1414.     elseif IsInRaid() then
  1415.         chatType = "RAID"
  1416.     elseif IsInGroup() then
  1417.         chatType = "PARTY"
  1418.     else
  1419.         print("You're not in a PvP instance.")
  1420.         return
  1421.     end
  1422.  
  1423.     -- Send the chat message
  1424.     SendChatMessage(message, chatType)
  1425. end
  1426.  
  1427. local function onChatMessage(message)
  1428.     if string.find(message, "%[Incoming%-BG%]") then
  1429.         PlaySound(SOUNDKIT.RAID_WARNING, "master")
  1430.     end
  1431. end
  1432.  
  1433. local function ApplyFontSettings()
  1434.     if not IncDB then return end
  1435.  
  1436.     IncDB.font = IncDB.font or "Friz Quadrata TT"  
  1437.     IncDB.fontSize = IncDB.fontSize or 14  -- Default font size
  1438.  
  1439.     local fontPath = LSM:Fetch("font", IncDB.font) or STANDARD_TEXT_FONT  -- Fallback to a default font if nil
  1440.     local fontSize = IncDB.fontSize
  1441.  
  1442.     for _, text in ipairs(buttonTexts) do
  1443.         if fontPath and fontSize then
  1444.             text:SetFont(fontPath, fontSize)
  1445.         end
  1446.     end
  1447.  
  1448.    
  1449. end
  1450.  
  1451.     local function OnEvent(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20)
  1452.     if event == "ADDON_LOADED" and arg1 == "IncCallout" then
  1453.        
  1454.         db = LibStub("AceDB-3.0"):New("IncCalloutDB", defaults, true)
  1455.         IncDB = db.profile or {}
  1456.        
  1457.         -- Initialize IncDB if it doesn't exist
  1458.         if not IncDB then
  1459.             IncDB = {
  1460.                 -- Set your default values here
  1461.                 buttonColor = {r = 1, g = 0, b = 0, a = 1},
  1462.                 fontColor = {r = 1, g = 1, b = 1, a = 1},
  1463.                 -- Add other default settings as needed
  1464.             }
  1465.         end
  1466.  
  1467.         if IncCallout.SetLogo then
  1468.             IncCallout:SetLogo(IncDB.selectedLogo or "BearClaw")
  1469.         end
  1470.  
  1471.         if IncDB.logoColor then
  1472.             local color = IncDB.logoColor
  1473.             logo:SetVertexColor(color.r, color.g, color.b, color.a)
  1474.         end
  1475.  
  1476.         if IncDB.fontColor then
  1477.             local color = IncDB.fontColor
  1478.             for _, buttonText in ipairs(buttonTexts) do
  1479.                 buttonText:SetTextColor(color.r, color.g, color.b, color.a)
  1480.             end
  1481.         end
  1482.  
  1483.         applyBorderChange()
  1484.         applyColorChange()
  1485.         ApplyFontSettings()
  1486.  
  1487.         if not IncDB.minimap then
  1488.             IncDB.minimap = { hide = false, minimapPos = 45 }
  1489.         end
  1490.  
  1491.         icon:Register("IncCallout", IncCalloutLDB, IncDB.minimap)
  1492.  
  1493.     elseif event == "PLAYER_LOGIN" or event == "PLAYER_ENTERING_WORLD" then
  1494.         local inInstance, instanceType = IsInInstance()
  1495.         if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1496.             IncCallout:Show()
  1497.         else
  1498.             IncCallout:Hide()
  1499.         end
  1500.         UpdatePoints()
  1501.         ScaleGUI()
  1502.         ApplyFontSettings()
  1503.         applyButtonColor()
  1504.  
  1505.     elseif event == "PLAYER_LEAVING_WORLD" then
  1506.         IncCallout:Hide()
  1507.         applyButtonColor()
  1508.  
  1509.     elseif event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" then
  1510.         UpdatePoints()
  1511.  
  1512.     elseif event == "CHAT_MSG_INSTANCE_CHAT" then
  1513.         local message = arg1
  1514.         onChatMessage(message)
  1515.     end
  1516. end
  1517.  
  1518. -- Register the function to the frame and events
  1519. IncCallout:SetScript("OnEvent", OnEvent)
  1520. IncCallout:RegisterEvent("ADDON_LOADED")
  1521. IncCallout:RegisterEvent("PLAYER_LOGIN")
  1522. IncCallout:RegisterEvent("PLAYER_ENTERING_WORLD")
  1523. IncCallout:RegisterEvent("PLAYER_LEAVING_WORLD")  
  1524. IncCallout:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  1525. IncCallout:RegisterEvent("HONOR_XP_UPDATE")
  1526. IncCallout:RegisterEvent("CHAT_MSG_INSTANCE_CHAT")
  1527. IncCallout:RegisterEvent("WEEKLY_REWARDS_UPDATE")
  1528.  
  1529.    
  1530.  
  1531.  
  1532. local button1 = createButton("button1", 20, 22, "1", {"TOPLEFT", IncCallout, "TOPLEFT"}, 35, -40, ButtonOnClick)
  1533. local button2 = createButton("button2", 20, 22, "2", {"LEFT", button1, "RIGHT"}, 10, 0, ButtonOnClick)
  1534. local button3 = createButton("button3", 20, 22, "3", {"LEFT", button2, "RIGHT"}, 10, 0, ButtonOnClick)
  1535. local button4 = createButton("button4", 20, 22, "4", {"LEFT", button3, "RIGHT"}, 10, 0, ButtonOnClick)
  1536. local buttonZerg = createButton("buttonZerg", 40, 22, "Zerg", {"LEFT", button4, "RIGHT"}, 10, 0, ButtonOnClick)
  1537. local incButton = createButton("incButton", 95, 22, "Inc", {"TOP", button3, "BOTTOM"}, -45, -10, IncButtonOnClick)
  1538. local sendMoreButton = createButton("sendMoreButton", 95, 22, "Send More", {"LEFT", incButton, "RIGHT"}, 10, 0, SendMoreButtonOnClick)
  1539. local allClearButton = createButton("allClearButton", 95, 22, "All Clear", {"TOP", incButton, "BOTTOM"}, 0, -10, AllClearButtonOnClick)
  1540. local healsButton = createButton("healsButton", 95, 22, "Heals", {"LEFT", allClearButton, "RIGHT"}, 10, 0, HealsButtonOnClick)
  1541. local efcButton = createButton("efcButton", 95, 22, "EFC", {"TOP", allClearButton, "BOTTOM"}, 0, -10, EFCButtonOnClick)
  1542. local fcButton = createButton("fcButton", 95, 22, "FC", {"LEFT", efcButton, "RIGHT"}, 10, 0, FCButtonOnClick)
  1543. local buffButton = createButton("buffButton", 95, 22, "Buffs", {"TOP", efcButton, "BOTTOM"}, 0, -10, BuffRequestButtonOnClick)
  1544. local mapButton = createButton("mapButton", 95, 22, "Map", {"LEFT", buffButton, "RIGHT"}, 10, 0, function()
  1545.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1546.     ToggleWorldMap()
  1547. end)
  1548.  
  1549. local healerButton = createButton("healerButton", 95, 22, "Healers", {"TOP", buffButton, "BOTTOM"}, 0, -10, function()
  1550.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1551.     ListHealers()
  1552. end)
  1553.  
  1554. local pvpStatsButton = createButton("pvpStatsButton", 95, 22, "PVP Stats", {"LEFT", healerButton, "RIGHT"}, 10, 0, function()
  1555.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1556.     pvpStatsFrame:Show()
  1557. end)
  1558.  
  1559. -- Tooltip setup for the pvpStatsButton with Conquest Cap included
  1560. pvpStatsButton:SetScript("OnEnter", function(self)
  1561.     GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  1562.     GameTooltip:SetText("PVP Stats Information", nil, nil, nil, nil, true)
  1563.     GameTooltip:AddLine(" \nDisplays the following stats:\n", 1, 1, 1, true)  -- Extra line breaks for spacing
  1564.     GameTooltip:AddLine("• Honor Points: ", 1, 0.5, 0, true)  -- Orange for title
  1565.     GameTooltip:AddLine("Your current total.", 1, 1, 1, true)  -- White for description
  1566.     GameTooltip:AddLine("• Conquest Points: ", 1, 0.5, 0, true)
  1567.     GameTooltip:AddLine("Your current total.", 1, 1, 1, true)
  1568.     GameTooltip:AddLine("• Conquest Cap: ", 1, 0.5, 0, true)
  1569.     GameTooltip:AddLine("The maximum Conquest points you can earn this week.", 1, 1, 1, true)
  1570.     GameTooltip:AddLine("• Honor Level: ", 1, 0.5, 0, true)
  1571.     GameTooltip:AddLine("Your current level in the Honor system.", 1, 1, 1, true)  
  1572.     GameTooltip:AddLine("• Solo Shuffle Rating: ", 1, 0.5, 0, true)
  1573.     GameTooltip:AddLine("Your current rating in Solo Shuffle.", 1, 1, 1, true)
  1574.     GameTooltip:Show()
  1575. end)
  1576.  
  1577. pvpStatsButton:SetScript("OnLeave", function(self)
  1578.     GameTooltip:Hide()
  1579. end)
  1580.  
  1581. -- Apply the color to all the buttons
  1582. applyButtonColor()
  1583.  
  1584. -- Set OnClick functions for the buttons
  1585. allClearButton:SetScript("OnClick", AllClearButtonOnClick)
  1586. sendMoreButton:SetScript("OnClick", SendMoreButtonOnClick)
  1587. incButton:SetScript("OnClick", IncButtonOnClick)
  1588.  
  1589. -- Apply the PostClick script to each button
  1590. for _, button in ipairs(buttons) do
  1591.     button:SetScript("PostClick", function()
  1592.         applyButtonColor()
  1593.     end)
  1594. end
  1595.  
  1596. local function OnAddonLoaded(self, event, loadedAddonName)
  1597.     if loadedAddonName == addonName then
  1598.         EnsureDBSettings()
  1599.         RestoreMapPositionAndScale()  
  1600.        
  1601.         if addonNamespace.ResizeWorldMap then
  1602.             addonNamespace.ResizeWorldMap()
  1603.         end
  1604.     end
  1605. end
  1606.  
  1607. -- Slash command registration
  1608. SLASH_INC1 = "/inc"
  1609. SlashCmdList["INC"] = function()
  1610.     if IncCallout:IsShown() then
  1611.         IncCallout:Hide()
  1612.     else
  1613.         IncCallout:Show()
  1614.     end
  1615. end
  1616.  
  1617. -- New function to handle the '/incmsg' command
  1618. local function IncomingBGMessageCommandHandler(msg)
  1619.     local messageType = "INSTANCE_CHAT"  
  1620.     local message = "Peeps, yall need to get the addon Incoming-BG. It has a GUI to where all you have to do is click a button to call an INC. Beats having to type anything out. Just sayin'."  
  1621.  
  1622.     SendChatMessage(message, messageType)
  1623. end
  1624.  
  1625. SLASH_INCOMINGBGMSG1 = "/incmsg"
  1626. SlashCmdList["INCOMINGBGMSG"] = IncomingBGMessageCommandHandler
  1627.  
  1628. IncCallout:SetScript("OnEvent", OnEvent)
  1629.  
  1630. -- Register the events
  1631. IncCallout:RegisterEvent("PLAYER_ENTERING_WORLD")
  1632. IncCallout:RegisterEvent("PLAYER_LOGIN")
  1633. IncCallout:RegisterEvent("PLAYER_LOGOUT")
  1634. IncCallout:SetScript("OnEvent", OnEvent)
__________________
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.
  Reply With Quote
05-05-24, 01:09 PM   #15
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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.
  Reply With Quote
05-05-24, 01:28 PM   #16
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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)
Also here is my Saved Variables:
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,
			},
		},
	},
}
  Reply With Quote
05-05-24, 02:05 PM   #17
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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:
  1. pvpStatsFrame:SetScript("OnShow", function()
  2.     UpdateAllCharacterStats()
  3. end)

and
Lua Code:
  1. pvpStatsFrame:SetScript("OnShow", function()
  2.     pvpStatsFrame.playerNameValue:SetText(UnitName("player") or "Unknown")
  3.     local classColor = GetDefaultClassColor()
  4.     if classColor then
  5.         pvpStatsFrame.playerNameValue:SetTextColor(classColor.r, classColor.g, classColor.b)
  6.     end
  7.     local character = UnitName("player") .. "-" .. GetRealmName()
  8.     local stats = IncCalloutDB[character]
  9.     if stats then
  10.         pvpStatsFrame.conquestValue:SetText(stats.conquestValue)
  11.         pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue)
  12.         pvpStatsFrame.honorValue:SetText(stats.honorValue)
  13.         pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue)  
  14.         pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue)
  15.     end
  16.     UpdatePvPStatsFrame()
  17. end)
The second SetScript("OnShow" ... is the only one being used as it overwrites the first.
__________________
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.
  Reply With Quote
05-10-24, 07:33 PM   #18
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
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....

Click image for larger version

Name:	WoWScrnShot_051024_082651.jpg
Views:	10
Size:	116.2 KB
ID:	9882
  Reply With Quote
05-10-24, 08:45 PM   #19
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
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:
  1. -- Load embedded libraries
  2. local LibStub = LibStub or _G.LibStub
  3. --local AceDB = LibStub("AceDB-3.0")
  4. local AceDB = LibStub:GetLibrary("AceDB-3.0")
  5. --local AceAddon = LibStub("AceAddon-3.0")
  6. local AceAddon = LibStub:GetLibrary("AceAddon-3.0")
  7. --local AceConfig = LibStub("AceConfig-3.0")
  8. local AceConfig = LibStub:GetLibrary("AceConfig-3.0")
  9. --local AceConfigDialog = LibStub("AceConfigDialog-3.0")
  10. local AceConfigDialog = LibStub:GetLibrary("AceConfigDialog-3.0")
  11. --local icon = LibStub("LibDBIcon-1.0")
  12. local icon = LibStub:GetLibrary("LibDBIcon-1.0")
  13. --local LDB = LibStub("LibDataBroker-1.1")
  14. local LDB = LibStub:GetLibrary("LibDataBroker-1.1")
  15. --local LSM = LibStub ("LibSharedMedia-3.0")
  16. local LSM = LibStub("LibSharedMedia-3.0")
  17. local AceGUI = LibStub("AceGUI-3.0")
  18.  
  19. local addonName, addonNamespace = ...
  20. IncDB = IncDB or {}
  21. IncCalloutDB = IncCalloutDB or {}
  22. addonNamespace.addon = addon
  23. addonNamespace.db = IncDB
  24.  
  25.  
  26. local defaults = {
  27.     profile = {
  28.         buttonColor = {r = 1, g = 0, b = 0, a = 1}, -- Default to red
  29.         fontColor = {r = 1, g = 1, b = 1, a = 1},  -- Default to white
  30.         opacity = 1,
  31.         sendMoreIndex = 1,
  32.         incIndex = 1,
  33.         allClearIndex = 1,
  34.         logoColor = {r = 1, g = 1, b = 1, a = 1}, -- Default logo color
  35.         scale = 1,
  36.         isLocked = false,
  37.         worldMapScale = 1,
  38.         conquestFont = "Friz Quadrata TT",
  39.         conquestFontSize = 14,
  40.         conquestFontColor = {r = 1, g = 1, b = 1, a = 1}, -- white
  41.         honorFont = "Friz Quadrata TT",
  42.         honorFontSize = 14,
  43.         honorFontColor = {r = 1, g = 1, b = 1, a = 1}, -- white
  44.         selectedLogo = "None", -- Default logo selection
  45.     },
  46. }
  47.  
  48. local buttonTexts = {}
  49. local buttons = {}
  50. local playerFaction
  51.  
  52. local buttonMessageIndices = {
  53.     sendMore = 1,
  54.     inc = 1,
  55.     allClear = 1
  56. }
  57.  
  58. SLASH_INC1 = "/inc"
  59.  
  60. local customRaidWarningFrame = CreateFrame("Frame", "CustomRaidWarningFrame", UIParent)
  61. customRaidWarningFrame:SetHeight(50)
  62. customRaidWarningFrame:SetPoint("TOP", UIParent, "TOP", 0, -200)
  63. customRaidWarningFrame:SetWidth(UIParent:GetWidth())
  64.  
  65. customRaidWarningFrame.text = customRaidWarningFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalHuge")
  66. customRaidWarningFrame.text:SetAllPoints(true)
  67. customRaidWarningFrame.text:SetJustifyH("CENTER")
  68. customRaidWarningFrame.text:SetJustifyV("MIDDLE")
  69.  
  70. customRaidWarningFrame:Hide()
  71.  
  72. local CONQUEST_CURRENCY_ID = 1602
  73. local HONOR_CURRENCY_ID = 1792
  74.  
  75. -- Main GUI Frame
  76. local IncCallout = CreateFrame("Frame", "IncCalloutMainFrame", UIParent, "BackdropTemplate")
  77. IncCallout:SetSize(225, 250)  
  78. IncCallout:SetPoint("CENTER")
  79. IncCallout:SetMovable(true)
  80. IncCallout:EnableMouse(true)
  81. IncCallout:RegisterForDrag("LeftButton")
  82. IncCallout:SetScript("OnDragStart", IncCallout.StartMoving)
  83. IncCallout:SetScript("OnDragStop", IncCallout.StopMovingOrSizing)
  84.  
  85. local closeButton = CreateFrame("Button", nil, IncCallout, "UIPanelCloseButton")
  86. closeButton:SetPoint("TOPRIGHT", IncCallout, "TOPRIGHT", -5, -5)
  87. closeButton:SetSize(24, 24)  
  88. closeButton:SetScript("OnClick", function()
  89.     IncCallout:Hide()  
  90. end)
  91.  
  92. closeButton:SetScript("OnEnter", function(self)
  93.     GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  94.     GameTooltip:SetText("Close the Window", nil, nil, nil, nil, true)
  95.     GameTooltip:Show()
  96. end)
  97. closeButton:SetScript("OnLeave", function()
  98.     GameTooltip:Hide()
  99. end)
  100.  
  101. local function createStatValue(parent, xOffset, textColor)
  102.     local value = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  103.     value:SetPoint("CENTER", parent, "LEFT", xOffset, 0)  
  104. --    value:SetTextColor(1, 0.84, 0)
  105.     value:SetTextColor(unpack(textColor))
  106.     return value
  107. end
  108.  
  109. -- Create the PVP Stats window frame
  110. local pvpStatsFrame = CreateFrame("Frame", "PVPStatsFrame", UIParent, "BasicFrameTemplateWithInset")
  111. pvpStatsFrame:SetSize(750, (21 * 10) + 45)  -- Increased size to accommodate scrolling
  112. pvpStatsFrame:SetPoint("CENTER")
  113. pvpStatsFrame:SetMovable(true)
  114. pvpStatsFrame:EnableMouse(true)
  115. pvpStatsFrame:RegisterForDrag("LeftButton")
  116. pvpStatsFrame:SetScript("OnDragStart", pvpStatsFrame.StartMoving)
  117. pvpStatsFrame:SetScript("OnDragStop", pvpStatsFrame.StopMovingOrSizing)
  118. pvpStatsFrame:Hide()
  119.  
  120. pvpStatsFrame.title = pvpStatsFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
  121. pvpStatsFrame.title:SetPoint("TOP", pvpStatsFrame, "TOP", 0, -10)
  122. pvpStatsFrame.title:SetText("PvP Statistics")
  123.  
  124. -- Create Scroll Frame and Scroll Bar
  125. local ScrollableListItemMixin = {}
  126.  
  127. function ScrollableListItemMixin:Init(elementData)
  128.     self.playerName:SetText(elementData.name)
  129.     self.conquestValue:SetText(elementData.settings.conquestValue)
  130.     self.honorValue:SetText(elementData.settings.honorValue)
  131.     self.honorLevelValue:SetText(elementData.settings.honorLevelValue)
  132.     self.conquestCapValue:SetText(elementData.settings.conquestCapValue)
  133.     self.soloShuffleRatingValue:SetText(elementData.settings.soloShuffleRatingValue)
  134. end
  135. local elementExtent = 20
  136. local function AddRow(self, data)
  137.     if not self.Inited then
  138.         self.Inited = true
  139.         Mixin(self, ScrollableListItemMixin)
  140.             self:SetHeight(elementExtent) -- Gets this from elementExtent
  141.         self.playerName = createStatValue(self, 10, {1, 1, 1})
  142.         self.playerName:ClearAllPoints()
  143.         self.playerName:SetPoint("LEFT", -10, 0)
  144.         self.conquestValue = createStatValue(self, 150, {0, 0.75, 1})
  145.         self.honorValue = createStatValue(self, 270, {1, 0.5, 0})
  146.         self.honorLevelValue = createStatValue(self, 390, {0.58, 0, 0.82})
  147.         self.conquestCapValue = createStatValue(self, 510, {1, 0, 0})
  148.         self.soloShuffleRatingValue = createStatValue(self, 630, {0, 0.75, 1})
  149.     end
  150.     self:Init(data)
  151. end
  152.  
  153. pvpStatsFrame.List = CreateFrame("Frame", nil, pvpStatsFrame)
  154. pvpStatsFrame.List:SetPoint("TOPLEFT", 10, -25)
  155. pvpStatsFrame.List:SetPoint("BOTTOMRIGHT", -10, 10)
  156. pvpStatsFrame.List.ScrollBox = CreateFrame("Frame", nil, pvpStatsFrame.List, "WowScrollBoxList")
  157. pvpStatsFrame.List.ScrollBar = CreateFrame("EventFrame", nil, pvpStatsFrame.List, "WowTrimScrollBar")
  158. pvpStatsFrame.List.ScrollBar:SetPoint("TOPRIGHT")
  159. pvpStatsFrame.List.ScrollBar:SetPoint("BOTTOMRIGHT")
  160. pvpStatsFrame.List.DataProvider = CreateDataProvider()
  161.  
  162. pvpStatsFrame.List.ScrollView = CreateScrollBoxListLinearView()
  163. pvpStatsFrame.List.ScrollView:SetDataProvider(pvpStatsFrame.List.DataProvider)
  164. pvpStatsFrame.List.ScrollView:SetElementExtent(elementExtent)
  165. pvpStatsFrame.List.ScrollView:SetElementInitializer("Frame", AddRow)
  166. local paddingT = 10
  167. local paddingB = 10
  168. local paddingL = 10
  169. local paddingR = 10
  170. local spacing = 5
  171. pvpStatsFrame.List.ScrollView:SetPadding(paddingT, paddingB, paddingL, paddingR, spacing)
  172. ScrollUtil.InitScrollBoxListWithScrollBar(pvpStatsFrame.List.ScrollBox, pvpStatsFrame.List.ScrollBar, pvpStatsFrame.List.ScrollView)
  173. local anchorsWithBar = {
  174.     CreateAnchor("TOPLEFT", pvpStatsFrame.List, "TOPLEFT", 10, -25),
  175.     CreateAnchor("BOTTOMRIGHT", pvpStatsFrame.List.ScrollBar, "BOTTOMLEFT", 0, 4),
  176. }
  177.  
  178. local anchorsWithoutBar = {
  179.     CreateAnchor("TOPLEFT", pvpStatsFrame.List, "TOPLEFT", 10, -25),
  180.     CreateAnchor("BOTTOMRIGHT", pvpStatsFrame.List, "BOTTOMRIGHT", -4, 4),
  181. }
  182.  
  183. ScrollUtil.AddManagedScrollBarVisibilityBehavior(pvpStatsFrame.List.ScrollBox, pvpStatsFrame.List.ScrollBar, anchorsWithBar, anchorsWithoutBar)
  184. local yOffset = 0  
  185.  
  186. local function AddElement(name, settings)
  187.     return { name=name, settings=settings }
  188. end
  189. local init
  190. local function UpdateAllCharacterStats()
  191.     local character = UnitName("player") .. "-" .. GetRealmName()
  192. --        if not IncCalloutDB[character] then
  193. --            IncCalloutDB[character] = {}
  194. --        end
  195.     if not init then
  196.         init = true
  197.         pvpStatsFrame.List.DataProvider:Insert(AddElement(character, IncCalloutDB[character]))
  198.         local sorted = {}
  199.         for k, v in pairs(IncCalloutDB) do
  200.             if k ~= "settings" and k ~= character then
  201.                 tinsert(sorted, { name=k, settings=v })
  202.             end
  203.         end
  204.         table.sort(sorted, function(a, b)
  205.             return a.name < b.name
  206.         end)
  207.         for i, v in ipairs(sorted) do
  208.             pvpStatsFrame.List.DataProvider:Insert(AddElement(v.name, v.settings))
  209.         end
  210.     else
  211.         local collection = pvpStatsFrame.List.DataProvider:GetCollection()
  212.         -- update the current players information and chang it in the list
  213.         collection[1].name = "*" ..collection[1].name
  214.         local x = pvpStatsFrame.List.ScrollView:FindFrame(collection[1])
  215.         if x then -- update the display if it's shown
  216.             x:Init(collection[1])
  217.         end
  218.     end
  219. --[[
  220.     -- Clear old content
  221.     for i = 1, content:GetNumChildren() do
  222.         local child = select(i, content:GetChildren())
  223.         child:Hide()
  224.     end
  225.  
  226.     -- Update yOffset for new entries
  227.     yOffset = 0
  228.     for character, stats in pairs(IncCalloutDB) do
  229.         local statText = content:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  230.         statText:SetPoint("TOPLEFT", content, "TOPLEFT", 10, yOffset)
  231.         statText:SetSize(680, 20)
  232.         statText:SetText(format("%s: Conquest Points: %s, Honor Points: %s, Honor Level: %s, Conquest Cap: %s / %s, Solo Shuffle Rating: %s",
  233.                                 character, stats.conquestValue, stats.honorValue, stats.honorLevelValue, stats.conquestCapValue, stats.soloShuffleRatingValue))
  234.         yOffset = yOffset - 20
  235.     end
  236.     content:SetHeight(math.abs(yOffset))
  237. ]]--
  238. end
  239.  
  240. local TOP_MARGIN = -25
  241.  
  242. local function createStatLabel(parent, labelText, xOffset, textColor)
  243.     local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  244.     label:SetPoint("TOPLEFT", parent, "TOPLEFT", xOffset, TOP_MARGIN)
  245.     label:SetText(labelText)
  246.     label:SetTextColor(unpack(textColor))
  247.    
  248. --    local value = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  249. --    value:SetPoint("TOP", label, "BOTTOM", 0, -2)  
  250. --    value:SetTextColor(1, 0.84, 0)
  251.     return label --, value
  252. end
  253.  
  254. pvpStatsFrame.playerNameLabel = createStatLabel(pvpStatsFrame, "Player Name:", 10, {1, 1, 1})
  255. pvpStatsFrame.conquestLabel = createStatLabel(pvpStatsFrame, "Conquest Points:", 130, {0, 0.75, 1})
  256. pvpStatsFrame.honorLabel = createStatLabel(pvpStatsFrame, "Honor Points:", 250, {1, 0.5, 0})
  257. pvpStatsFrame.honorLevelLabel = createStatLabel(pvpStatsFrame, "Honor Level:", 370, {0.58, 0, 0.82})
  258. pvpStatsFrame.conquestCapLabel = createStatLabel(pvpStatsFrame, "Conquest Cap:", 490, {1, 0, 0})
  259. pvpStatsFrame.soloShuffleRatingLabel = createStatLabel(pvpStatsFrame, "Solo Shuffle Rating:", 610, {0, 0.75, 1})
  260.  
  261. local SOLO_SHUFFLE_INDEX = 7
  262.  
  263. local function UpdatePvPStatsFrame()
  264.    
  265.     IncCalloutDB = IncCalloutDB or {}
  266.    
  267.     if not IsAddOnLoaded("Blizzard_PVPUI") then
  268.         LoadAddOn("Blizzard_PVPUI")
  269.     end
  270.  
  271.     local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
  272.     local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
  273.     local honorLevel = UnitHonorLevel("player")  
  274.  
  275.     -- Updated conquest point calculations
  276.     local currentConquestPoints = conquestInfo.quantity
  277.     local totalEarnedConquest = conquestInfo.totalEarned  -- Total conquest points earned ever
  278.     local weeklyEarnedConquest = conquestInfo.quantityEarnedThisWeek  -- Total conquest points earned this week
  279.     local conquestCap = conquestInfo.maxQuantity  -- Dynamically fetch the current conquest cap
  280.     local displayedConquestProgress = math.min(totalEarnedConquest, conquestCap)  -- Ensure displayed value does not exceed cap
  281.  
  282.     local rating = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX)
  283.     local soloShuffleRating = rating or "N/A"
  284. --[[
  285.     -- Display data
  286.     pvpStatsFrame.conquestValue:SetText(currentConquestPoints)
  287.     pvpStatsFrame.conquestCapValue:SetText(displayedConquestProgress .. " / " .. conquestCap)
  288.     pvpStatsFrame.honorValue:SetText(honorInfo.quantity)
  289.     pvpStatsFrame.honorLevelValue:SetText(honorLevel)  
  290.     pvpStatsFrame.soloShuffleRatingValue:SetText(soloShuffleRating)
  291.  
  292.     -- Adjust buttons based on PvP availability
  293.     local canUseRated = C_PvP.CanPlayerUseRatedPVPUI()
  294.     local canUsePremade = C_LFGInfo.CanPlayerUsePremadeGroup()
  295. ]]--
  296.     if canUseRated then
  297.         PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton2, true)
  298.         PVPQueueFrame.CategoryButton2.tooltip = nil
  299.     end
  300.  
  301.     if canUsePremade then
  302.         PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton3, true)
  303.         PVPQueueFrame.CategoryButton3.tooltip = nil
  304.     end
  305. end
  306.  
  307. local function GetDefaultClassColor()
  308.     local _, class = UnitClass("player")
  309.     if class then
  310.         return RAID_CLASS_COLORS[class]
  311.     end
  312. end
  313.  
  314. local function SavePvPStats()
  315.     IncCalloutDB = IncCalloutDB or {}
  316.     local character = UnitName("player") .. "-" .. GetRealmName()
  317.     if not IncCalloutDB[character] then
  318.         IncCalloutDB[character] = {}
  319.     end
  320.     local SavedSettings = IncCalloutDB[character]
  321.  
  322.     if IsAddOnLoaded("Blizzard_PVPUI") or LoadAddOn("Blizzard_PVPUI") then
  323.         local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
  324.         local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)        
  325.         local honorLevel = UnitHonorLevel("player")  
  326.  
  327.         -- Updated conquest point calculations
  328.         SavedSettings.conquestValue = conquestInfo.quantity
  329.         SavedSettings.conquestCapValue = math.min(conquestInfo.totalEarned, conquestInfo.maxQuantity) .. " / " .. conquestInfo.maxQuantity
  330.         SavedSettings.honorValue = honorInfo.quantity
  331.         SavedSettings.honorLevelValue = honorLevel  
  332.         SavedSettings.soloShuffleRatingValue = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX) or "N/A"
  333.     end
  334. end
  335.  
  336. local function InitializeCharacterDB()-- Fizz: Added because it didn't exist
  337.     -- I don't know what else is suppsed to go her???
  338.     SavePvPStats()
  339. end
  340.  
  341. pvpStatsFrame:SetScript("OnShow", function()
  342.     UpdateAllCharacterStats()
  343. --[[
  344.     pvpStatsFrame.playerNameValue:SetText(UnitName("player") or "Unknown")
  345.     local classColor = GetDefaultClassColor()
  346.     if classColor then
  347.         pvpStatsFrame.playerNameValue:SetTextColor(classColor.r, classColor.g, classColor.b)
  348.     end
  349.     local character = UnitName("player") .. "-" .. GetRealmName()
  350.     local stats = IncCalloutDB[character]
  351.     if stats then
  352.         pvpStatsFrame.conquestValue:SetText(stats.conquestValue)
  353.         pvpStatsFrame.conquestCapValue:SetText(stats.conquestCapValue)
  354.         pvpStatsFrame.honorValue:SetText(stats.honorValue)
  355.         pvpStatsFrame.honorLevelValue:SetText(stats.honorLevelValue)  
  356.         pvpStatsFrame.soloShuffleRatingValue:SetText(stats.soloShuffleRatingValue)
  357.     end
  358. ]]--
  359.     UpdatePvPStatsFrame()
  360. end)
  361.  
  362. -- Register event handlers
  363. local frame = CreateFrame("Frame")
  364. frame:RegisterEvent("PLAYER_LOGIN")
  365. frame:RegisterEvent("PLAYER_LOGOUT")
  366. frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  367. frame:RegisterEvent("HONOR_XP_UPDATE")
  368. frame:SetScript("OnEvent", function(self, event, arg1, ...)
  369.     if event == "PLAYER_LOGIN" then -- Fizz: Removed the or arg1 == test
  370.         InitializeCharacterDB()
  371.     elseif event == "PLAYER_LOGOUT" or event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" or event == "PLAYER_PVP_KILLS_CHANGED" then
  372.         UpdatePvPStatsFrame() -- Fizz: Changed from UpdatePvPStats()
  373.     end
  374. end)
  375.  
  376.  
  377. local function ShowRaidWarning(message, duration)
  378.    
  379.     if IncDB.enableRaidWarnings then
  380.         customRaidWarningFrame.text:SetText(message)
  381.         customRaidWarningFrame.text:SetTextColor(1, 0, 0) -- Set text color to red
  382.         customRaidWarningFrame:Show()
  383.    
  384.         C_Timer.After(duration or 5, function()
  385.             customRaidWarningFrame:Hide()
  386.         end)
  387.     end
  388. end
  389.  
  390. local colorOptions = {
  391.     { name = "Semi-Transparent Black", color = {0, 0, 0, 0.5} },
  392.     { name = "Solid Black", color = {0, 0, 0, 1} },
  393.     { name = "Semi-Transparent White", color = {1, 1, 1, 0.5} },
  394.     { name = "Solid White", color = {1, 1, 1, 1} },
  395.     { name = "Semi-Transparent Red", color = {1, 0, 0, 0.5} },
  396.     { name = "Solid Red", color = {1, 0, 0, 1} },
  397.     { name = "Semi-Transparent Green", color = {0, 1, 0, 0.5} },
  398.     { name = "Solid Green", color = {0, 1, 0, 1} },
  399.     { name = "Semi-Transparent Blue", color = {0, 0, 1, 0.5} },
  400.     { name = "Solid Blue", color = {0, 0, 1, 1} },
  401.     { name = "Semi-Transparent Yellow", color = {1, 1, 0, 0.5} },
  402.     { name = "Solid Yellow", color = {1, 1, 0, 1} },
  403.     { name = "Semi-Transparent Cyan", color = {0, 1, 1, 0.5} },
  404.     { name = "Solid Cyan", color = {0, 1, 1, 1} },
  405.     { name = "Semi-Transparent Magenta", color = {1, 0, 1, 0.5} },
  406.     { name = "Solid Magenta", color = {1, 0, 1, 1} },
  407.     { name = "Semi-Transparent Orange", color = {1, 0.5, 0, 0.5} },
  408.     { name = "Solid Orange", color = {1, 0.5, 0, 1} },
  409.     { name = "Semi-Transparent Purple", color = {0.5, 0, 0.5, 0.5} },
  410.     { name = "Solid Purple", color = {0.5, 0, 0.5, 1} },
  411.     { name = "Semi-Transparent Grey", color = {0.5, 0.5, 0.5, 0.5} },
  412.     { name = "Solid Grey", color = {0.5, 0.5, 0.5, 1} },
  413.     { name = "Semi-Transparent Teal", color = {0, 0.5, 0.5, 0.5} },
  414.     { name = "Solid Teal", color = {0, 0.5, 0.5, 1} },
  415.     { name = "Semi-Transparent Pink", color = {1, 0.75, 0.8, 0.5} },
  416.     { name = "Solid Pink", color = {1, 0.75, 0.8, 1} },
  417.    
  418. }
  419.  
  420. local borderOptions = {
  421.     { name = "Azerite", file = "Interface/Tooltips/UI-Tooltip-Border-Azerite" },
  422.     { name = "Classic", file = "Interface/Tooltips/UI-Tooltip-Border" },
  423.     { name = "Sleek", file = "Interface/DialogFrame/UI-DialogBox-Border" },
  424.     { name = "Corrupted", file = "Interface/Tooltips/UI-Tooltip-Border-Corrupted" },
  425.     { name = "Maw", file = "Interface/Tooltips/UI-Tooltip-Border-Maw" },
  426.     { name = "Smooth", file = "Interface/LFGFRAME/LFGBorder" },
  427.     { name = "Glass", file = "Interface/DialogFrame/UI-DialogBox-TestWatermark-Border" },
  428.     { name = "Gold", file = "Interface\\DialogFrame\\UI-DialogBox-Gold-Border" },
  429.     { name = "Slide", file = "Interface\\FriendsFrame\\UI-Toast-Border" },
  430.     { name = "Glow", file = "Interface\\TutorialFrame\\UI-TutorialFrame-CalloutGlow" },
  431.     { name = "Glow 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG15.blp" },
  432.     { name = "Grey", file = "Interface\\Tooltips\\UI-Tooltip-Background" },
  433.     { name = "Blue", file = "Interface\\AddOns\\IncCallout\\Textures\\BG1.png" },
  434.     { name = "Black Gloss", file = "Interface\\AddOns\\IncCallout\\Textures\\BG2.blp" },
  435.     { name = "Silverish", file = "Interface\\AddOns\\IncCallout\\Textures\\BG3.blp" },
  436.     { name = "Bevel", file = "Interface\\AddOns\\IncCallout\\Textures\\BG4.blp" },
  437.     { name = "Bevel 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG5.blp" },
  438.     { name = "Fade", file = "Interface\\AddOns\\IncCallout\\Textures\\BG6.blp" },
  439.     { name = "Fade 2", file = "Interface\\AddOns\\IncCallout\\Textures\\BG7.blp" },
  440.     { name = "Thin Line", file = "Interface\\AddOns\\IncCallout\\Textures\\BG8.blp" },
  441.     { name = "2 Tone", file = "Interface\\AddOns\\IncCallout\\Textures\\BG9.blp" },
  442.     { name = "Bluish", file = "Interface\\AddOns\\IncCallout\\Textures\\BG10.blp" },
  443.     { name = "Neon Yellow", file = "Interface\\AddOns\\IncCallout\\Textures\\BG11.blp" },
  444.     { name = "Neon Red", file = "Interface\\AddOns\\IncCallout\\Textures\\BG12.blp" },
  445.     { name = "Neon Green", file = "Interface\\AddOns\\IncCallout\\Textures\\BG13.blp" },
  446.     { name = "Neon Blue", file = "Interface\\AddOns\\IncCallout\\Textures\\BG14.blp" },
  447.     { name = "Double Yellow", file = "Interface\\AddOns\\IncCallout\\Textures\\BG16.blp" },
  448.            
  449. }
  450.  
  451. local battlegroundLocations = {
  452.     "Stables", "Blacksmith", "Lumber Mill", "Gold Mine", "Mine", "Trollbane Hall", "Defiler's Den", "Farm",
  453.     "Mage Tower", "Draenei Ruins", "Blood Elf Tower", "Fel Reaver Ruins",
  454.     "The Broken Temple", "Cauldron of Flames", "Central Bridge", "The Chilled Quagemire",
  455.     "Eastern Bridge", "Flamewatch Tower", "The Forest of Shadows", "Glacial Falls", "The Steppe of Life",
  456.     "The Sunken Ring", "Western Bridge", "Winter's Edge Tower", "Wintergrasp Fortress", "Eastpark Workshop", "Westpark Workshop ",
  457.     "Lighthouse", "Waterworks", "Mines", "Docks", "Workshop", "Horde Keep", "Alliance Keep", "Market",
  458.     "Hangar", "Refinery", "Quarry", "Wildhammer Stronghold", "Dragonmaw Stronghold",
  459.     "Silverwing Hold", "Warsong Flag Room", "Baradin Base Camp", "Rustberg Village",
  460.     "The Restless Front", "Wellson Shipyard", "Largo's Overlook", "Farson Hold",
  461.     "Forgotten Hill", "Hellscream's Grasp","Stormpike Graveyard", "Irondeep Mine", "Dun Baldar",
  462.     "Hall of the Stormpike", "Icewing Pass", "Stonehearth Outpost", "Iceblood Graveyard",
  463.     "Iceblood Garrison", "Tower Point", "Coldtooth Mine", "Dun Baldar Pass", "Icewing Bunker",
  464.     "Field of Strife", "Stonehearth Graveyard", "Stonehearth Bunker", "Frost Dagger Pass",
  465.     "Snowfall Graveyard", "Winterax Hold", "Frostwolf Graveyard", "Frostwolf Village",
  466.     "Deepwind Gorge", "Frostwolf Keep", "Hall of the Frostwolf","Temple of Kotmogu",  "Silvershard Mines", "Southshore vs. Tauren Mill", "Alterac Valley",
  467.     "Ashran", "StormShield", "The Ringing Deeps",  
  468. }
  469.  
  470. local buttonMessages = {
  471.     sendMore = {
  472.         "[Incoming-BG] We need more peeps",
  473.         "[Incoming-BG] Need help",
  474.         "[Incoming-BG] We are outnumbered",
  475.         "[Incoming-BG] Need a few more",
  476.         "[Incoming-BG] Need more",
  477.         "[Incoming-BG] Backup required",
  478.         "[Incoming-BG] We could use some help",
  479.         "[Incoming-BG] Calling for backup",
  480.         "[Incoming-BG] Could use some backup",
  481.         "[Incoming-BG] Reinforcements needed",
  482.         "[Incoming-BG] In need of additional support",
  483.         "[Incoming-BG] Calling all hands on deck",
  484.         "[Incoming-BG] Require extra manpower",
  485.         "[Incoming-BG] Assistance urgently needed",
  486.         "[Incoming-BG] Requesting more participants",
  487.        
  488.     },
  489.     inc = {
  490.         "[Incoming-BG] Incoming",
  491.         "[Incoming-BG] INC INC INC",
  492.         "[Incoming-BG] INC",
  493.         "[Incoming-BG] Gotta INC",
  494.         "[Incoming-BG] BIG INC",
  495.         "[Incoming-BG] Incoming enemy forces",
  496.         "[Incoming-BG] Incoming threat",
  497.         "[Incoming-BG] Enemy push incoming",
  498.         "[Incoming-BG] Enemy blitz incoming",
  499.         "[Incoming-BG] Enemy strike team inbound",
  500.         "[Incoming-BG] Incoming attack alert",
  501.         "[Incoming-BG] Enemy wave inbound",
  502.         "[Incoming-BG] Enemy squad closing in",
  503.         "[Incoming-BG] Anticipate enemy push",
  504.         "[Incoming-BG] Enemy forces are closing in",
  505.        
  506.     },
  507.     allClear = {
  508.         "[Incoming-BG] We are all clear",
  509.         "[Incoming-BG] All clear",
  510.         "[Incoming-BG] Looks like a ghost town",
  511.         "[Incoming-BG] All good",
  512.         "[Incoming-BG] Looking good",
  513.         "[Incoming-BG] Area secure",
  514.         "[Incoming-BG] All quiet on the front",
  515.         "[Incoming-BG] Situation is under control",
  516.         "[Incoming-BG] All quiet here",
  517.         "[Incoming-BG] We are looking good",
  518.         "[Incoming-BG] Perimeter is secured",
  519.         "[Incoming-BG] Situation is calm",
  520.         "[Incoming-BG] No threats detected",
  521.         "[Incoming-BG] All quiet on this end",
  522.         "[Incoming-BG] Area is threat-free",
  523.        
  524.     },
  525.     buffRequest = {
  526.     "[Incoming-BG] Need buffs please!",
  527.     "[Incoming-BG] Buff up, team!",
  528.     "[Incoming-BG] Could use some buffs here!",
  529.     "[Incoming-BG] Calling for all buffs, let's gear up!",
  530.     "[Incoming-BG] Looking for that magical boost, buffs needed!",
  531.     "[Incoming-BG] Time to get enchanted, where are those buffs?",
  532.     "[Incoming-BG] Let’s get buffed for the battle ahead!",
  533.     "[Incoming-BG] Buffs are our best friends, let’s have them!",
  534.     "[Incoming-BG] Ready for buffs, let's enhance our strength!",
  535.     "[Incoming-BG] Buffs needed for extra might and magic!",
  536.     "[Incoming-BG] Gimme some buffs, let’s not fall behind!"
  537.      },
  538.      healRequest = {
  539.     "[Incoming-BG] Need heals ASAP!",
  540.     "[Incoming-BG] Healing needed at my position!",
  541.     "[Incoming-BG] Can someone heal me, please?",
  542.     "[Incoming-BG] Healers, your assistance is required!",
  543.     "[Incoming-BG] I'm in dire need of healing!",
  544.     "[Incoming-BG] Could use some healing here!",
  545.     "[Incoming-BG] Healers, please focus on our location!",
  546.     "[Incoming-BG] Urgent healing needed to stay in the fight!",
  547.     "[Incoming-BG] Heal me up to keep the pressure on!",
  548.     "[Incoming-BG] Healers, attention needed here now!"  
  549.     },
  550.     efcRequest = {
  551.     "[Incoming-BG] Get the EFC!!",
  552.     "[Incoming-BG] EFC spotted, group up to kill and recover our flag!",
  553.     "[Incoming-BG] Kill the EFC on sight, let's bring that flag home!",
  554.     "[Incoming-BG] EFC is vulnerable, kill them now!",
  555.     "[Incoming-BG] Everyone on the EFC!",
  556.     "[Incoming-BG] Close in and kill the EFC, no escape allowed!",
  557.     "[Incoming-BG] EFC heading towards their base—kill them before they cap!",
  558.     "[Incoming-BG] The EFC is weak, finish them off!",
  559.     "[Incoming-BG] Kill the EFC now, they're almost at their base!",
  560.     "[Incoming-BG] It’s a race against time, kill the EFC and secure our victory!"
  561.     },
  562.     fcRequest = {
  563.     "[Incoming-BG] Protect our FC!",
  564.     "[Incoming-BG] FC needs help!!",
  565.     "[Incoming-BG] Heals on FC!",
  566.     "[Incoming-BG] Need some help with the FC.",
  567.     "[Incoming-BG] Someone needs to get the flag.",
  568.    
  569.    }
  570.  }
  571.  
  572. -- Define available logos
  573. local logos = {
  574.     None = "",
  575.     BearClaw = "Interface\\AddOns\\IncCallout\\Textures\\BearClaw.png",
  576.     BreatheFire = "Interface\\AddOns\\IncCallout\\Textures\\BreatheFire.png",
  577.     Bloody = "Interface\\AddOns\\IncCallout\\Textures\\Bloody.png",
  578.     Impact = "Interface\\AddOns\\IncCallout\\Textures\\Impact.png",
  579.     Shock = "Interface\\AddOns\\IncCallout\\Textures\\Shock.png",
  580.     Rifle = "Interface\\AddOns\\IncCallout\\Textures\\Rifle.png",
  581.     Condiment = "Interface\\AddOns\\IncCallout\\Textures\\Condiment.png",
  582.     Duplex = "Interface\\AddOns\\IncCallout\\Textures\\Duplex.png",
  583.     Eraser = "Interface\\AddOns\\IncCallout\\Textures\\Eraser.png",
  584.     Ogre = "Interface\\AddOns\\IncCallout\\Textures\\Ogre.png",
  585.     Seagram = "Interface\\AddOns\\IncCallout\\Textures\\Seagram.png",
  586.     SuperSunday = "Interface\\AddOns\\IncCallout\\Textures\\SuperSunday.png",
  587.     Minion = "Interface\\AddOns\\IncCallout\\Textures\\Minion.png",
  588.     Fire = "Interface\\AddOns\\IncCallout\\Textures\\Fire.png",
  589.     GOW = "Interface\\AddOns\\IncCallout\\Textures\\GOW.png",
  590.     Maiden = "Interface\\AddOns\\IncCallout\\Textures\\Maiden.png",
  591.     Metal = "Interface\\AddOns\\IncCallout\\Textures\\Metal.png",
  592.     Alligator = "Interface\\AddOns\\IncCallout\\Textures\\Alligator.png",
  593.     SourceCode = "Interface\\AddOns\\IncCallout\\Textures\\SourceCode.png",
  594.     InkFree = "Interface\\AddOns\\IncCallout\\Textures\\InkFree.png",
  595. }
  596.  
  597. -- Initial logo setup
  598. local logo = IncCallout:CreateTexture(nil, "ARTWORK")
  599. logo:SetSize(180, 30)
  600. logo:SetPoint("TOP", IncCallout, "TOP", -5, 30)
  601. logo:SetTexture(logos.BearClaw) -- Default logo
  602.  
  603. function IncCallout:SetLogo(selectedLogo)
  604.     if selectedLogo == "None" then
  605.         logo:Hide()  
  606.     else
  607.         local path = logos[selectedLogo]
  608.         if path then
  609.             logo:SetTexture(path)
  610.             logo:Show()
  611.         else
  612.             print("Logo path not found for:", selectedLogo)
  613.         end
  614.     end
  615. end
  616.  
  617. local fontSize = 14
  618.  
  619. local bgTexture = IncCallout:CreateTexture(nil, "BACKGROUND")
  620. bgTexture:SetColorTexture(0, 0, 0)
  621. bgTexture:SetAllPoints(IncCallout)
  622.  
  623. IncCallout:SetScript("OnDragStart", function(self)
  624.     if not IncDB.isLocked then
  625.         self:StartMoving()
  626.     end
  627. end)
  628.  
  629. IncCallout:SetScript("OnDragStop", function(self)
  630.     self:StopMovingOrSizing()
  631.    
  632.     if not IncDB.isLocked then
  633.                
  634.     end
  635. end)
  636.  
  637. -- Function to create a button
  638. local function createButton(name, width, height, text, anchor, xOffset, yOffset, onClick)
  639.     local button = CreateFrame("Button", nil, IncCallout, "BackdropTemplate")
  640.     button:SetSize(width, height)
  641.     button:SetText(text)
  642.     if type(anchor) == "table" then
  643.         button:SetPoint(anchor[1], anchor[2], anchor[3], xOffset, yOffset)
  644.     else
  645.         button:SetPoint(anchor, xOffset, yOffset)
  646.     end
  647.     button:GetFontString():SetTextColor(1, 1, 1, 1)
  648.     button:SetBackdrop({
  649.         bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  650.         edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  651.         tile = true,
  652.         tileSize = 12,
  653.         edgeSize = 7,  
  654.         insets = {left = 1, right = 1, top = 1, bottom = 1}
  655.     })
  656.  
  657.     table.insert(buttonTexts, button:GetFontString())
  658.     table.insert(buttons, button)
  659.    
  660.     button:SetScript("OnMouseDown", function(self)
  661.         self:SetBackdropColor(0, 0, 0, 0)
  662.     end)
  663.     button:SetScript("OnMouseUp", function(self, mouseButton)
  664.         if mouseButton == "LeftButton" then
  665.             self:SetBackdropColor(0, 0, 0, 0)
  666.         end
  667.     end)
  668.    
  669.     button:SetScript("OnClick", function(self, mouseButton, down)
  670.         if mouseButton == "LeftButton" and not down then
  671.             if useCustomSound then
  672.                 if IncDB.raidWarningSound and type(IncDB.raidWarningSound) == "number" then
  673.                     PlaySound(IncDB.raidWarningSound, "master")
  674.                 else
  675.                     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  676.                 end
  677.             end
  678.  
  679.             if onClick then
  680.                 onClick(self)
  681.             end
  682.         end
  683.     end)
  684.  
  685.     return button
  686. end
  687.  
  688. local function applyButtonColor()
  689.  
  690.     if not IncDB then
  691.         return
  692.     end
  693.  
  694.     local r, g, b, a
  695.     if IncDB.buttonColor then
  696.         r, g, b, a = IncDB.buttonColor.r, IncDB.buttonColor.g, IncDB.buttonColor.b, IncDB.buttonColor.a
  697.     else
  698.         r, g, b, a = 1, 0, 0, 1 -- Default to red
  699.     end
  700.     for _, button in ipairs(buttons) do
  701.         button:SetBackdropColor(r, g, b, a)        
  702.     end
  703. end
  704.  
  705. IncCallout:SetScript("OnShow", function()
  706.     if IncDB then
  707.         applyButtonColor()
  708.     end
  709. end)
  710.  
  711. local function applyBorderChange()
  712.     local selectedIndex = IncDB.selectedBorderIndex or 1
  713.     local selectedBorder = borderOptions[selectedIndex].file
  714.  
  715.     local backdropSettings = {
  716.         bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  717.         edgeFile = selectedBorder,
  718.         tile = false,
  719.         tileSize = 16,
  720.         edgeSize = 8,
  721.         insets = { left = 4, right = 4, top = 4, bottom = 4 }
  722.     }
  723.  
  724.     IncCallout:SetBackdrop(backdropSettings)   
  725. end
  726.  
  727. local function applyColorChange()
  728.     local selectedIndex = IncDB.selectedColorIndex or 1
  729.     local selectedColor = colorOptions[selectedIndex].color
  730.  
  731.     IncCallout:SetBackdropColor(unpack(selectedColor))
  732. end
  733.  
  734. local function ScaleGUI()
  735.     local scaleFactor = IncDB.scale or 1; -- Default scale is 1
  736.     IncCallout:SetScale(scaleFactor);
  737.    
  738.     local adjustedFontSize = math.floor(fontSize * scaleFactor);
  739.      
  740.     for _, buttonText in ipairs(buttonTexts) do
  741.         buttonText:SetFont("Fonts\\FRIZQT__.TTF", adjustedFontSize);
  742.     end
  743. end
  744.  
  745. local mapSizeOptions = {
  746.     { name = "Very Small", value = 0.4 },
  747.     { name = "Small", value = 0.5 },
  748.     { name = "Medium Small", value = 0.65 },
  749.     { name = "Medium", value = 0.75 }, -- Assuming this is the current default
  750.     { name = "Medium Large", value = 0.85 },
  751.     { name = "Large", value = 1.0 },
  752.     { name = "Very Large", value = 1.15 },
  753.     { name = "Huge", value = 1.3 },
  754.     { name = "Gigantic", value = 1.45 },
  755.     { name = "Colossal", value = 1.6 }
  756. }
  757.  
  758. local soundOptions = {
  759.     [8959] = "Raid Warning",
  760.     [8459] = "PVP Que ",
  761.     [15266] = "Whistle",
  762.     [12867] = "Horn",
  763.     [9656] = "Laughing",
  764.     [888] = "Level Up",
  765.     [8960] = "Ready Check",
  766.     [880] = "Drums",
  767.     [9379] = "PVP Flag",
  768.     [89880] = "Fireworks",
  769.     [176304] = "Launcher",
  770.     [34154] = "Challenge",
  771.     [12867] = "Alarm",
  772.     [161485] = "Lightning",
  773.     ["none"] = "No sound",
  774. }
  775.  
  776. local options = {
  777.     name = "Incoming-BG",
  778.     type = "group",
  779.     args = {
  780.         messageSettings = {
  781.             type = "group",
  782.             name = "Message Settings",
  783.             order = 1,
  784.             args = {
  785.                 sendMore = {
  786.     type = "select",
  787.     name = "Send More Message",
  788.     desc = "Select the message for the 'Send More' button",
  789.     values = buttonMessages.sendMore,
  790.     get = function() return IncDB.sendMoreIndex end,  -- Directly use IncDB to get the current value
  791.     set = function(_, newValue)
  792.         IncDB.sendMoreIndex = newValue  -- Directly use IncDB to save the new value
  793.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  794.     end,
  795.     order = 1,
  796. },
  797. previewSendMore = {
  798.     type = "description",
  799.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("sendMore") .. "|r" end,
  800.     fontSize = "medium",
  801.     order = 1.1,
  802. },
  803. inc = {
  804.     type = "select",
  805.     name = "INC Message",
  806.     desc = "Select the message for the 'INC' button",
  807.     values = buttonMessages.inc,
  808.     get = function() return IncDB.incIndex end,  
  809.     set = function(_, newValue)
  810.         IncDB.incIndex = newValue  
  811.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  812.     end,
  813.     order = 2,
  814. },
  815. previewInc = {
  816.     type = "description",
  817.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("inc") .. "|r" end,
  818.     fontSize = "medium",
  819.     order = 2.1,
  820. },
  821. allClear = {
  822.     type = "select",
  823.     name = "All Clear Message",
  824.     desc = "Select the message for the 'All Clear' button",
  825.     values = buttonMessages.allClear,
  826.     get = function() return IncDB.allClearIndex end,  
  827.     set = function(_, newValue)
  828.         IncDB.allClearIndex = newValue  
  829.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  830.     end,
  831.     order = 3,
  832. },
  833. previewAllClear = {
  834.     type = "description",
  835.     name = function() return "|cff00ff00Preview: " .. addonNamespace.getPreviewText("allClear") .. "|r" end,
  836.     fontSize = "medium",
  837.     order = 3.1,
  838.                 },
  839.                 buffRequest = {
  840.     type = "select",
  841.     name = "Buff Request Message",
  842.     desc = "Select the message for the 'Request Buffs' button",
  843.     values = buttonMessages.buffRequest,
  844.     get = function() return IncDB.buffRequestIndex end,
  845.     set = function(_, newValue)
  846.         buttonMessageIndices.buffRequest = newValue
  847.         IncDB.buffRequestIndex = newValue
  848.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  849.     end,
  850.     order = 4,
  851. },
  852. previewBuffRequest = {
  853.     type = "description",
  854.     name = function() return addonNamespace.getPreviewText("buffRequest") end,
  855.     fontSize = "medium",
  856.     order = 4.1,
  857.     },
  858.     healRequest = {
  859.     type = "select",
  860.     name = "Heal Request Message",
  861.     desc = "Select the message for the 'Need Heals' button",
  862.     values = buttonMessages.healRequest,
  863.     get = function() return IncDB.healRequestIndex end,
  864.     set = function(_, newValue)
  865.         buttonMessageIndices.healRequest = newValue
  866.         IncDB.healRequestIndex = newValue
  867.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  868.     end,
  869.     order = 5,
  870. },
  871. previewHealRequest = {
  872.     type = "description",
  873.     name = function() return addonNamespace.getPreviewText("healRequest") end,
  874.     fontSize = "medium",
  875.     order = 5.1,
  876. },
  877. efcRequest = {
  878.     type = "select",
  879.     name = "EFC Request Message",
  880.     desc = "Select the message for the 'EFC' button",
  881.     values = buttonMessages.efcRequest,
  882.     get = function() return IncDB.efcRequestIndex end,
  883.     set = function(_, newValue)
  884.         buttonMessageIndices.efcRequest = newValue
  885.         IncDB.efcRequestIndex = newValue
  886.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  887.     end,
  888.     order = 6,
  889. },
  890. previewEFCRequest = {
  891.     type = "description",
  892.     name = function() return addonNamespace.getPreviewText("efcRequest") end,
  893.     fontSize = "medium",
  894.     order = 6.1,
  895.     },
  896.     fcRequest = {
  897.     type = "select",
  898.     name = "FC Request Message",
  899.     desc = "Select the message for the 'FC' button",
  900.     values = buttonMessages.fcRequest,
  901.     get = function() return IncDB.fcRequestIndex end,
  902.     set = function(_, newValue)
  903.         buttonMessageIndices.fcRequest = newValue
  904.         IncDB.fcRequestIndex = newValue
  905.         LibStub("AceConfigRegistry-3.0"):NotifyChange("IncCallout")
  906.     end,
  907.     order = 7,
  908. },
  909. previewFCRequest = {
  910.     type = "description",
  911.     name = function() return addonNamespace.getPreviewText("fcRequest") end,
  912.     fontSize = "medium",
  913.     order = 7.1,
  914.  
  915.                 },
  916.             },
  917.         },
  918.         appearanceSettings = {
  919.     type = "group",
  920.     name = "Appearance Settings",
  921.     order = 2,
  922.     args = {
  923.         fontColor = {
  924.     type = "color",
  925.     name = "Button Font Color",
  926.     desc = "Set the color of the button text.",
  927.     hasAlpha = true,
  928.     get = function()
  929.         local color = IncDB.fontColor or {r = 1, g = 1, b = 1, a = 1} -- default white
  930.         return color.r, color.g, color.b, color.a
  931.     end,
  932.     set = function(_, r, g, b, a)
  933.         IncDB.fontColor = {r = r, g = g, b = b, a = a}
  934.        
  935.         for _, buttonText in ipairs(buttonTexts) do
  936.             buttonText:SetTextColor(r, g, b, a)
  937.         end
  938.     end,
  939.     order = 1,  
  940.                                     },
  941.                     buttonColor = {
  942.                                 type = "color",
  943.                                 name = "Button Color",
  944.                                 desc = "Select the color of the buttons.",
  945.                                 order = 2,
  946.                                 hasAlpha = true,
  947.                                 get = function()
  948.                                     local currentColor = IncDB.buttonColor or {r = 1, g = 0, b = 0, a = 1} -- Default to red
  949.                                     return currentColor.r, currentColor.g, currentColor.b, currentColor.a
  950.                                  end,
  951.                                  set = function(_, r, g, b, a)
  952.                                  local color = {r = r, g = g, b = b, a = a}
  953.                                  IncDB.buttonColor = color
  954.                                  applyButtonColor()
  955.                                  end,
  956.         },
  957.         scaleOption = {
  958.                     type = "range",
  959.                     name = "GUI Window Scale",
  960.                     desc = "Adjust the scale of the GUI.",
  961.                     min = 0.5,
  962.                     max = 2.0,
  963.                     step = 0.05,
  964.                     get = function()
  965.                     return IncDB.scale or 1
  966.                  end,
  967.                    set = function(_, value)
  968.                    IncDB.scale = value
  969.                    ScaleGUI(value)
  970.                 end,
  971.         },
  972.         borderStyle = {
  973.             type = "select",
  974.             name = "Border Style",
  975.             desc = "Select the border style for the frame.",
  976.             style = "dropdown",
  977.             order = 3,
  978.             values = function()
  979.                 local values = {}
  980.                 for i, option in ipairs(borderOptions) do
  981.                     values[i] = option.name
  982.                 end
  983.                 return values
  984.             end,
  985.             get = function()
  986.                 return IncDB.selectedBorderIndex or 1
  987.             end,
  988.             set = function(_, selectedIndex)
  989.                 IncDB.selectedBorderIndex = selectedIndex
  990.                 applyBorderChange()
  991.                 applyColorChange()
  992.             end,
  993.         },
  994.         backdropColor = {
  995.             type = "select",
  996.             name = "Backdrop Color",
  997.             desc = "Select the backdrop color and transparency for the frame.",
  998.             style = "dropdown",
  999.             order = 4,
  1000.             values = function()
  1001.                 local values = {}
  1002.                 for i, option in ipairs(colorOptions) do
  1003.                     values[i] = option.name
  1004.                 end
  1005.                 return values
  1006.             end,
  1007.             get = function()
  1008.                 return IncDB.selectedColorIndex or 1
  1009.             end,
  1010.             set = function(_, selectedIndex)
  1011.                 IncDB.selectedColorIndex = selectedIndex
  1012.                 applyColorChange()
  1013.             end,
  1014.         },
  1015.         enableRaidWarnings = {
  1016.             type = "toggle",
  1017.             name = "Enable Raid Warnings",
  1018.             desc = "Toggle Raid Warning Messages on or off.",
  1019.             order = 5,
  1020.             get = function() return IncDB.enableRaidWarnings end,
  1021.             set = function(_, value)
  1022.                 IncDB.enableRaidWarnings = value
  1023.                 -- Function to toggle raid warnings
  1024.             end,
  1025.         },
  1026.         raidWarningSound = {
  1027.             type = "select",
  1028.             name = "Raid Warning Sound",
  1029.             desc = "Select the sound to play for Raid Warnings.",
  1030.             order = 6,
  1031.             values = soundOptions,
  1032.             get = function() return IncDB.raidWarningSound end,
  1033.             set = function(_, selectedValue)
  1034.                 IncDB.raidWarningSound = selectedValue
  1035.                
  1036.                 if selectedValue and type(selectedValue) == "number" then
  1037.                     PlaySound(selectedValue, "master")
  1038.                 end
  1039.             end,
  1040.         },
  1041.         lockGUI = {
  1042.             type = "toggle",
  1043.             name = "Lock GUI Window",
  1044.             desc = "Lock or unlock the GUI window's position.",
  1045.             order = 7,
  1046.             get = function() return IncDB.isLocked end,
  1047.             set = function(_, value)
  1048.                 IncDB.isLocked = value
  1049.                
  1050.             end,
  1051.             },
  1052.             logoSelection = {
  1053.     type = "select",
  1054.     name = "Logo Selection",
  1055.     desc = "Choose a logo to display at the top of the frame.",
  1056.     style = "dropdown",
  1057.     order = 8,
  1058.     values = {
  1059.         ["None"] = "None",
  1060.         ["BearClaw"] = "BearClaw",
  1061.         ["BreatheFire"] = "BreatheFire",
  1062.         ["Bloody"] = "Bloody",
  1063.         ["Impact"] = "Impact",
  1064.         ["Shock"] = "Shock",
  1065.         ["Rifle"] = "Rifle",
  1066.         ["Condiment"] = "Condiment",
  1067.         ["Duplex"] = "Duplex",
  1068.         ["Eraser"] = "Eraser",
  1069.         ["Ogre"] = "Ogre",
  1070.         ["Seagram"] = "Seagram",
  1071.         ["SuperSunday"] = "SuperSunday",
  1072.         ["Minion"] = "Minion",
  1073.         ["Alligator"] = "Alligator",
  1074.         ["Fire"] = "Fire",
  1075.         ["GOW"] = "GOW",
  1076.         ["Maiden"] = "Maiden",
  1077.         ["Metal"] = "Metal",
  1078.         ["SourceCode"] = "SourceCode",
  1079.         ["InkFree"] = "InkFree",
  1080.     },
  1081.     get = function(info) return IncDB.selectedLogo end,
  1082.     set = function(info, value)
  1083.         IncDB.selectedLogo = value
  1084.         IncCallout:SetLogo(value)  
  1085.     end,
  1086.     },
  1087.     logoColor = {
  1088.     type = "color",
  1089.     name = "Logo Color",
  1090.     desc = "Set the color of the title logo.",
  1091.     hasAlpha = true,
  1092.     get = function(info)
  1093.         local color = IncDB.logoColor or {1, 1, 1, 1} -- Default to white if not set
  1094.         return color.r, color.g, color.b, color.a
  1095.     end,
  1096.     set = function(info, r, g, b, a)
  1097.         IncDB.logoColor = {r = r, g = g, b = b, a = a}
  1098.        
  1099.         logo:SetVertexColor(r, g, b, a)
  1100.     end,
  1101.     order = 9,
  1102.         },
  1103.     },
  1104. },
  1105.  
  1106.         mapSettings = {
  1107.             type = "group",
  1108.             name = "Map Settings",
  1109.             order = 3,
  1110.             args = {
  1111.                     mapSizeChoice = {
  1112.                     type = "select",
  1113.                     name = "Map Size",
  1114.                     desc = "Select the preferred size of the WorldMap.",
  1115.                     order = 6,
  1116.                     style = "dropdown",
  1117.                     values = function()
  1118.                         local values = {}
  1119.                         for _, sizeOption in ipairs(mapSizeOptions) do
  1120.                             values[sizeOption.value] = sizeOption.name
  1121.                         end
  1122.                         return values
  1123.                     end,
  1124.                     get = function() return IncCalloutDB.settings.mapScale end,
  1125.                     set = function(_, selectedValue)
  1126.                         IncCalloutDB.settings.mapScale = selectedValue
  1127.                         if addonNamespace.ResizeWorldMap then
  1128.                             addonNamespace.ResizeWorldMap()
  1129.                         end
  1130.                     end,
  1131.                 },
  1132.                 resizeInPvPOnly = {
  1133.                     type = "toggle",
  1134.                     name = "Resize Map in PvP Only",
  1135.                     desc = "Enable to resize the WorldMap only in PvP scenarios.",
  1136.                     order = 7,
  1137.                     get = function() return IncCalloutDB.settings.resizeInPvPOnly end,
  1138.                     set = function(_, value)
  1139.                         IncCalloutDB.settings.resizeInPvPOnly = value
  1140.                         if addonNamespace.ResizeWorldMap then
  1141.                             addonNamespace.ResizeWorldMap()
  1142.                         end
  1143.                     end,
  1144.                 },
  1145.             },
  1146.         },
  1147.        fontSettings = {
  1148.             type = "group",
  1149.             name = "Font Settings",
  1150.             order = 3,
  1151.             args = {
  1152.                 font = {
  1153.                     type = "select",
  1154.                     name = "Font",
  1155.                     desc = "Select the font for the buttons.",
  1156.                     dialogControl = "LSM30_Font",
  1157.                     values = LSM:HashTable("font"),
  1158.                     get = function()
  1159.                         return IncDB.font or "Friz Quadrata TT"
  1160.                     end,
  1161.                     set = function(_, newValue)
  1162.                         IncDB.font = newValue
  1163.                         local size = IncDB.fontSize or 14
  1164.                         for _, text in ipairs(buttonTexts) do
  1165.                             text:SetFont(LSM:Fetch("font", newValue), size)
  1166.                         end
  1167.                     end,
  1168.                     order = 1,
  1169.                 },
  1170.                 fontSize = {
  1171.                     type = "range",
  1172.                     name = "Font Size",
  1173.                     desc = "Adjust the font size for the buttons.",
  1174.                     min = 8, max = 24, step = 1,
  1175.                     get = function() return IncDB.fontSize or 14 end,
  1176.                     set = function(_, newValue)
  1177.                         IncDB.fontSize = newValue
  1178.                         local font = IncDB.font or "Friz Quadrata TT"
  1179.                         for _, text in ipairs(buttonTexts) do
  1180.                             text:SetFont(LSM:Fetch("font", font), newValue)
  1181.                         end
  1182.                     end,
  1183.                     order = 2,
  1184.                 },
  1185.             },
  1186.         },
  1187.     },
  1188. }
  1189. -- Register the options table
  1190. AceConfig:RegisterOptionsTable(addonName, options)
  1191.  
  1192. -- Create a config panel
  1193. local configPanel = AceConfigDialog:AddToBlizOptions(addonName, "Incoming-BG")
  1194. configPanel.default = function()
  1195.     buttonMessageIndices.sendMore = 1
  1196.     buttonMessageIndices.inc = 1
  1197.     buttonMessageIndices.allClear = 1
  1198.     buttonMessageIndices.buffRequest = 1
  1199.     IncDB.selectedBorderIndex = 1
  1200.  
  1201. end
  1202.  
  1203. function addonNamespace.getPreviewText(messageType)
  1204.     local previewText = "|cff00ff00[Incoming-BG] "
  1205.  
  1206.     if messageType == "sendMore" and IncDB.sendMoreIndex and buttonMessages.sendMore[IncDB.sendMoreIndex] then
  1207.         previewText = previewText .. buttonMessages.sendMore[IncDB.sendMoreIndex]
  1208.     elseif messageType == "inc" and IncDB.incIndex and buttonMessages.inc[IncDB.incIndex] then
  1209.         previewText = previewText .. buttonMessages.inc[IncDB.incIndex]
  1210.     elseif messageType == "allClear" and IncDB.allClearIndex and buttonMessages.allClear[IncDB.allClearIndex] then
  1211.         previewText = previewText .. buttonMessages.allClear[IncDB.allClearIndex]
  1212.     elseif messageType == "buffRequest" and IncDB.buffRequestIndex and buttonMessages.buffRequest[IncDB.buffRequestIndex] then
  1213.         previewText = previewText .. buttonMessages.buffRequest[IncDB.buffRequestIndex]
  1214.     elseif messageType == "healRequest" and IncDB.healRequestIndex and buttonMessages.healRequest[IncDB.healRequestIndex] then
  1215.         previewText = previewText .. buttonMessages.healRequest[IncDB.healRequestIndex]
  1216.     elseif messageType == "efcRequest" and IncDB.efcRequestIndex and buttonMessages.efcRequest[IncDB.efcRequestIndex] then
  1217.         previewText = previewText .. buttonMessages.efcRequest[IncDB.efcRequestIndex]
  1218.     elseif messageType == "fcRequest" and IncDB.fcRequestIndex and buttonMessages.fcRequest[IncDB.fcRequestIndex] then
  1219.         previewText = previewText .. buttonMessages.fcRequest[IncDB.fcRequestIndex]
  1220.     end
  1221.  
  1222.     return previewText .. "|r"
  1223. end
  1224.  
  1225.  
  1226. local messageQueue = {}
  1227. local timeLastMessageSent = 0
  1228. local MESSAGE_DELAY = 1.5 -- Delay in seconds between messages
  1229.  
  1230. local function SendMessage()
  1231.     if #messageQueue == 0 then return end
  1232.     if time() - timeLastMessageSent < MESSAGE_DELAY then return end -- Check if delay has passed
  1233.  
  1234.     local message = table.remove(messageQueue, 1)
  1235.     SendChatMessage(message.text, message.channel)
  1236.     timeLastMessageSent = time()
  1237. end
  1238.  
  1239. local function QueueMessage(text, channel)
  1240.     table.insert(messageQueue, {text = text, channel = channel})
  1241. end
  1242.  
  1243. local function ListHealers()
  1244.     local groupType, groupSize
  1245.     if IsInRaid() then
  1246.         groupType = "raid"
  1247.         groupSize = GetNumGroupMembers()
  1248.     elseif IsInGroup() then
  1249.         groupType = "party"
  1250.         groupSize = GetNumGroupMembers()
  1251.     else
  1252.         print("You are not in a group.")
  1253.         return
  1254.     end
  1255.  
  1256.     local healerNames = {}
  1257.     for i = 1, groupSize do
  1258.         local unit = groupType..i
  1259.         local role = UnitGroupRolesAssigned(unit)
  1260.         if role == "HEALER" then
  1261.             table.insert(healerNames, GetUnitName(unit, true))
  1262.         end
  1263.     end
  1264.  
  1265.     if #healerNames > 0 then
  1266.         local healerList = table.concat(healerNames, ", ")
  1267.         QueueMessage("[Incoming-BG] Healers on our team: " .. healerList .. ". Now you know who to peel for.", "INSTANCE_CHAT")
  1268.     else
  1269.         if IsInGroup() or IsInRaid() then
  1270.             QueueMessage("[Incoming-BG] We have no heals, lol..", "INSTANCE_CHAT")
  1271.         end
  1272.     end
  1273. end
  1274.  
  1275. -- Setup a frame to periodically attempt to send messages
  1276. local frame = CreateFrame("Frame")
  1277. frame:SetScript("OnUpdate", function(self, elapsed)
  1278.     SendMessage()
  1279. end)
  1280.  
  1281.  
  1282. -- Create a table to map each location to itself
  1283. local locationTable = {}
  1284. for _, location in ipairs(battlegroundLocations) do
  1285.     locationTable[location] = location
  1286. end
  1287.  
  1288. local function isInBattleground()
  1289.     local inInstance, instanceType = IsInInstance()
  1290.     return inInstance and (instanceType == "pvp" or instanceType == "arena")
  1291. end
  1292.  
  1293. local function ButtonOnClick(self)
  1294.     if not isInBattleground() then
  1295.         print("You are not in a battleground.")
  1296.         return
  1297.     end
  1298.  
  1299.     if IncDB.raidWarningSound and type(IncDB.raidWarningSound) == "number" then
  1300.         PlaySound(IncDB.raidWarningSound, "master")
  1301.     end
  1302.  
  1303.     local currentLocation = GetSubZoneText()
  1304.    
  1305.     local message = "[Incoming-BG] " .. self:GetText() .. " Incoming at " .. currentLocation
  1306.     SendChatMessage(message, "INSTANCE_CHAT")
  1307.     ShowRaidWarning(message, 2)
  1308. end
  1309.  
  1310. local f = CreateFrame("Frame")
  1311. f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  1312.  
  1313. local function UpdatePoints()
  1314.  
  1315.     if not IncDB then
  1316.         return
  1317.     end
  1318.  
  1319.     local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(CONQUEST_CURRENCY_ID)
  1320.     local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)
  1321.  
  1322. end
  1323.  
  1324. IncCallout:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  1325. IncCallout:RegisterEvent("HONOR_XP_UPDATE")
  1326. IncCallout:SetScript("OnEvent", function(self, event, ...)
  1327.     if event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" then
  1328.         UpdatePoints()
  1329.         ApplyFontSettings()
  1330.     end
  1331. end)
  1332.  
  1333. UpdatePoints()
  1334.  
  1335. f:SetScript("OnEvent", function(self, event, ...)
  1336.     if event == "ZONE_CHANGED_NEW_AREA" then
  1337.         local currentLocation = GetRealZoneText() .. " - " .. GetSubZoneText()
  1338.         local location = locationTable[currentLocation]
  1339.  
  1340.         if location then
  1341.             IncCallout:Show()  
  1342.         else
  1343.            
  1344.         end
  1345.     end
  1346. end)
  1347.  
  1348. local IncCalloutLDB = LibStub("LibDataBroker-1.1"):NewDataObject("Incoming-BG", {
  1349.     type = "data source",
  1350.     text = "Incoming-BG",
  1351.     icon = "Interface\\AddOns\\IncCallout\\Icon\\INC.png",
  1352.     OnClick = function(_, button)
  1353.         if button == "LeftButton" then
  1354.             if IncCallout:IsShown() then
  1355.                 IncCallout:Hide()
  1356.             else
  1357.                 IncCallout:Show()
  1358.             end
  1359.         else
  1360.             InterfaceOptionsFrame_OpenToCategory("Incoming-BG")
  1361.             InterfaceOptionsFrame_OpenToCategory("Incoming-BG") -- Call it twice to ensure the correct category is selected
  1362.         end
  1363.     end,
  1364.     OnMouseDown = function(self, button)
  1365.         if button == "LeftButton" then
  1366.             IncCallout:StartMoving()
  1367.         end
  1368.     end,
  1369.     OnMouseUp = function(self, button)
  1370.         if button == "LeftButton" then
  1371.             IncCallout:StopMovingOrSizing()
  1372.             local point, _, _, x, y = IncCallout:GetPoint()
  1373.             local centerX, centerY = Minimap:GetCenter()
  1374.             local scale = Minimap:GetEffectiveScale()
  1375.             x, y = (x - centerX) / scale, (y - centerY) / scale
  1376.             IncDB.minimap.minimapPos = math.deg(math.atan2(y, x)) % 360
  1377.         end
  1378.     end,
  1379.     OnTooltipShow = function(tooltip)
  1380.         tooltip:AddLine("|cffff0000Incoming-BG|r")
  1381.         tooltip:AddLine("Left Click: GUI")
  1382.         tooltip:AddLine("Right Click: Options")
  1383.         tooltip:Show()
  1384.     end,
  1385. })
  1386.  
  1387. -- Function to handle the All Clear button click event
  1388. local function AllClearButtonOnClick()
  1389.    
  1390.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1391.         PlaySound(IncDB.raidWarningSound, "master")
  1392.     else
  1393.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1394.     end
  1395.  
  1396.     local location = GetSubZoneText()
  1397.     if not location then
  1398.         print("You are not in a Battleground.")
  1399.         return
  1400.     end
  1401.  
  1402.     local message = buttonMessages.allClear[buttonMessageIndices.allClear] .. " at " .. location
  1403.     SendChatMessage(message, "INSTANCE_CHAT")
  1404.     ShowRaidWarning(message, 2)
  1405. end
  1406.  
  1407. -- Function to handle the Send More button click event
  1408. local function SendMoreButtonOnClick()
  1409.    
  1410.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1411.         PlaySound(IncDB.raidWarningSound, "master")
  1412.     else
  1413.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1414.     end
  1415.  
  1416.     local location = GetSubZoneText()
  1417.     if not location then
  1418.         print("You are not in a Battleground.")
  1419.         return
  1420.     end
  1421.  
  1422.     local message = buttonMessages.sendMore[buttonMessageIndices.sendMore] .. " at " .. location
  1423.     SendChatMessage(message, "INSTANCE_CHAT")
  1424.     ShowRaidWarning(message, 2)
  1425. end
  1426.  
  1427. -- Function to handle the INC button click event
  1428. local function IncButtonOnClick()
  1429.    
  1430.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1431.         PlaySound(IncDB.raidWarningSound, "master")
  1432.     else
  1433.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1434.     end
  1435.  
  1436.     local location = GetSubZoneText()
  1437.     if not location then
  1438.         print("You are not in a Battleground.")
  1439.         return
  1440.     end
  1441.  
  1442.     local message = buttonMessages.inc[buttonMessageIndices.inc] .. " at " .. location
  1443.     SendChatMessage(message, "INSTANCE_CHAT")
  1444.     ShowRaidWarning(message, 2)
  1445. end
  1446.  
  1447. -- Define the OnClick function for EFC
  1448. local function EFCButtonOnClick()
  1449.     if not InCombatLockdown() then
  1450.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1451.     end
  1452.    
  1453.     local inInstance, instanceType = IsInInstance()
  1454.     local chatType
  1455.  
  1456.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1457.         chatType = "INSTANCE_CHAT"
  1458.     elseif IsInRaid() then
  1459.         chatType = "RAID"
  1460.     elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
  1461.         chatType = "PARTY"
  1462.     else
  1463.         print("You're not in a PvP instance or any group.")
  1464.         return
  1465.     end
  1466.  
  1467.     local message = buttonMessages.efcRequest[IncDB.efcRequestIndex]
  1468.     SendChatMessage(message, chatType)
  1469.     ShowRaidWarning(message, 2)
  1470. end
  1471.  
  1472. -- Define the OnClick function for FC
  1473. local function FCButtonOnClick()
  1474.     if not InCombatLockdown() then
  1475.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1476.     end
  1477.    
  1478.     local inInstance, instanceType = IsInInstance()
  1479.     local chatType
  1480.  
  1481.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1482.         chatType = "INSTANCE_CHAT"
  1483.     elseif IsInRaid() then
  1484.         chatType = "RAID"
  1485.     elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
  1486.         chatType = "PARTY"
  1487.     else
  1488.         print("You're not in a PvP instance or any group.")
  1489.         return
  1490.     end
  1491.  
  1492.     local message = buttonMessages.fcRequest[IncDB.fcRequestIndex]
  1493.     SendChatMessage(message, chatType)
  1494.     ShowRaidWarning(message, 2)
  1495. end
  1496.  
  1497.  
  1498. local function HealsButtonOnClick()
  1499.     if IncDB.raidWarningSound and IncDB.raidWarningSound ~= "none" and type(IncDB.raidWarningSound) == "number" then
  1500.         PlaySound(IncDB.raidWarningSound, "master")
  1501.     else
  1502.         PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1503.     end
  1504.  
  1505.     local location = GetSubZoneText()
  1506.     if not location then
  1507.         print("You are not in a Battleground.")
  1508.         return
  1509.     end
  1510.  
  1511.     if not IncDB.healRequestIndex or not buttonMessages.healRequest[IncDB.healRequestIndex] then
  1512.         print("Heal request message not set.")
  1513.         return
  1514.     end
  1515.  
  1516.     local message = buttonMessages.healRequest[IncDB.healRequestIndex] .. " Needed at " .. location
  1517.     SendChatMessage(message, "INSTANCE_CHAT")
  1518.     ShowRaidWarning(message, 2)
  1519. end
  1520.  
  1521. local function BuffRequestButtonOnClick()
  1522.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1523.  
  1524.     local messageIndex = buttonMessageIndices.buffRequest or 1
  1525.     local message = buttonMessages.buffRequest[messageIndex]
  1526.    
  1527.     if not message then
  1528.         print("No buff request message available.")
  1529.         return
  1530.     end
  1531.  
  1532.     local inInstance, instanceType = IsInInstance()
  1533.     local chatType
  1534.  
  1535.     if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1536.         chatType = "INSTANCE_CHAT"
  1537.     elseif IsInRaid() then
  1538.         chatType = "RAID"
  1539.     elseif IsInGroup() then
  1540.         chatType = "PARTY"
  1541.     else
  1542.         print("You're not in a PvP instance.")
  1543.         return
  1544.     end
  1545.  
  1546.     -- Send the chat message
  1547.     SendChatMessage(message, chatType)
  1548. end
  1549.  
  1550. local function onChatMessage(message)
  1551.     if string.find(message, "%[Incoming%-BG%]") then
  1552.         PlaySound(SOUNDKIT.RAID_WARNING, "master")
  1553.     end
  1554. end
  1555.  
  1556. local function ApplyFontSettings()
  1557.     if not IncDB then return end
  1558.  
  1559.     IncDB.font = IncDB.font or "Friz Quadrata TT"  
  1560.     IncDB.fontSize = IncDB.fontSize or 14  -- Default font size
  1561.  
  1562.     local fontPath = LSM:Fetch("font", IncDB.font) or STANDARD_TEXT_FONT  -- Fallback to a default font if nil
  1563.     local fontSize = IncDB.fontSize
  1564.  
  1565.     for _, text in ipairs(buttonTexts) do
  1566.         if fontPath and fontSize then
  1567.             text:SetFont(fontPath, fontSize)
  1568.         end
  1569.     end
  1570.  
  1571.    
  1572. end
  1573.  
  1574.     local function OnEvent(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20)
  1575.     if event == "ADDON_LOADED" and arg1 == "IncCallout" then
  1576.        
  1577.         db = LibStub("AceDB-3.0"):New("IncCalloutDB", defaults, true)
  1578.         IncDB = db.profile or {}
  1579.        
  1580.         -- Initialize IncDB if it doesn't exist
  1581.         if not IncDB then
  1582.             IncDB = {
  1583.                 -- Set your default values here
  1584.                 buttonColor = {r = 1, g = 0, b = 0, a = 1},
  1585.                 fontColor = {r = 1, g = 1, b = 1, a = 1},
  1586.                 -- Add other default settings as needed
  1587.             }
  1588.         end
  1589.  
  1590.         if IncCallout.SetLogo then
  1591.             IncCallout:SetLogo(IncDB.selectedLogo or "BearClaw")
  1592.         end
  1593.  
  1594.         if IncDB.logoColor then
  1595.             local color = IncDB.logoColor
  1596.             logo:SetVertexColor(color.r, color.g, color.b, color.a)
  1597.         end
  1598.  
  1599.         if IncDB.fontColor then
  1600.             local color = IncDB.fontColor
  1601.             for _, buttonText in ipairs(buttonTexts) do
  1602.                 buttonText:SetTextColor(color.r, color.g, color.b, color.a)
  1603.             end
  1604.         end
  1605.  
  1606.         applyBorderChange()
  1607.         applyColorChange()
  1608.         ApplyFontSettings()
  1609.  
  1610.         if not IncDB.minimap then
  1611.             IncDB.minimap = { hide = false, minimapPos = 45 }
  1612.         end
  1613.  
  1614.         icon:Register("IncCallout", IncCalloutLDB, IncDB.minimap)
  1615.  
  1616.     elseif event == "PLAYER_LOGIN" or event == "PLAYER_ENTERING_WORLD" then
  1617.         local inInstance, instanceType = IsInInstance()
  1618.         if inInstance and (instanceType == "pvp" or instanceType == "arena") then
  1619.             IncCallout:Show()
  1620.         else
  1621.             IncCallout:Hide()
  1622.         end
  1623.         UpdatePoints()
  1624.         ScaleGUI()
  1625.         ApplyFontSettings()
  1626.         applyButtonColor()
  1627.  
  1628.     elseif event == "PLAYER_LEAVING_WORLD" then
  1629.         IncCallout:Hide()
  1630.         applyButtonColor()
  1631.  
  1632.     elseif event == "CURRENCY_DISPLAY_UPDATE" or event == "HONOR_XP_UPDATE" then
  1633.         UpdatePoints()
  1634.  
  1635.     elseif event == "CHAT_MSG_INSTANCE_CHAT" then
  1636.         local message = arg1
  1637.         onChatMessage(message)
  1638.     end
  1639. end
  1640.  
  1641. -- Register the function to the frame and events
  1642. IncCallout:SetScript("OnEvent", OnEvent)
  1643. IncCallout:RegisterEvent("ADDON_LOADED")
  1644. IncCallout:RegisterEvent("PLAYER_LOGIN")
  1645. IncCallout:RegisterEvent("PLAYER_ENTERING_WORLD")
  1646. IncCallout:RegisterEvent("PLAYER_LEAVING_WORLD")  
  1647. IncCallout:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  1648. IncCallout:RegisterEvent("HONOR_XP_UPDATE")
  1649. IncCallout:RegisterEvent("CHAT_MSG_INSTANCE_CHAT")
  1650. IncCallout:RegisterEvent("WEEKLY_REWARDS_UPDATE")
  1651.  
  1652.    
  1653.  
  1654.  
  1655. local button1 = createButton("button1", 20, 22, "1", {"TOPLEFT", IncCallout, "TOPLEFT"}, 35, -40, ButtonOnClick)
  1656. local button2 = createButton("button2", 20, 22, "2", {"LEFT", button1, "RIGHT"}, 10, 0, ButtonOnClick)
  1657. local button3 = createButton("button3", 20, 22, "3", {"LEFT", button2, "RIGHT"}, 10, 0, ButtonOnClick)
  1658. local button4 = createButton("button4", 20, 22, "4", {"LEFT", button3, "RIGHT"}, 10, 0, ButtonOnClick)
  1659. local buttonZerg = createButton("buttonZerg", 40, 22, "Zerg", {"LEFT", button4, "RIGHT"}, 10, 0, ButtonOnClick)
  1660. local incButton = createButton("incButton", 95, 22, "Inc", {"TOP", button3, "BOTTOM"}, -45, -10, IncButtonOnClick)
  1661. local sendMoreButton = createButton("sendMoreButton", 95, 22, "Send More", {"LEFT", incButton, "RIGHT"}, 10, 0, SendMoreButtonOnClick)
  1662. local allClearButton = createButton("allClearButton", 95, 22, "All Clear", {"TOP", incButton, "BOTTOM"}, 0, -10, AllClearButtonOnClick)
  1663. local healsButton = createButton("healsButton", 95, 22, "Heals", {"LEFT", allClearButton, "RIGHT"}, 10, 0, HealsButtonOnClick)
  1664. local efcButton = createButton("efcButton", 95, 22, "EFC", {"TOP", allClearButton, "BOTTOM"}, 0, -10, EFCButtonOnClick)
  1665. local fcButton = createButton("fcButton", 95, 22, "FC", {"LEFT", efcButton, "RIGHT"}, 10, 0, FCButtonOnClick)
  1666. local buffButton = createButton("buffButton", 95, 22, "Buffs", {"TOP", efcButton, "BOTTOM"}, 0, -10, BuffRequestButtonOnClick)
  1667. local mapButton = createButton("mapButton", 95, 22, "Map", {"LEFT", buffButton, "RIGHT"}, 10, 0, function()
  1668.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1669.     ToggleWorldMap()
  1670. end)
  1671.  
  1672. local healerButton = createButton("healerButton", 95, 22, "Healers", {"TOP", buffButton, "BOTTOM"}, 0, -10, function()
  1673.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1674.     ListHealers()
  1675. end)
  1676.  
  1677. local pvpStatsButton = createButton("pvpStatsButton", 95, 22, "PVP Stats", {"LEFT", healerButton, "RIGHT"}, 10, 0, function()
  1678.     PlaySound(SOUNDKIT.IG_MAINMENU_OPEN)
  1679.     pvpStatsFrame:Show()
  1680. end)
  1681.  
  1682. -- Tooltip setup for the pvpStatsButton with Conquest Cap included
  1683. pvpStatsButton:SetScript("OnEnter", function(self)
  1684.     GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
  1685.     GameTooltip:SetText("PVP Stats Information", nil, nil, nil, nil, true)
  1686.     GameTooltip:AddLine(" \nDisplays the following stats:\n", 1, 1, 1, true)  -- Extra line breaks for spacing
  1687.     GameTooltip:AddLine("• Honor Points: ", 1, 0.5, 0, true)  -- Orange for title
  1688.     GameTooltip:AddLine("Your current total.", 1, 1, 1, true)  -- White for description
  1689.     GameTooltip:AddLine("• Conquest Points: ", 1, 0.5, 0, true)
  1690.     GameTooltip:AddLine("Your current total.", 1, 1, 1, true)
  1691.     GameTooltip:AddLine("• Conquest Cap: ", 1, 0.5, 0, true)
  1692.     GameTooltip:AddLine("The maximum Conquest points you can earn this week.", 1, 1, 1, true)
  1693.     GameTooltip:AddLine("• Honor Level: ", 1, 0.5, 0, true)
  1694.     GameTooltip:AddLine("Your current level in the Honor system.", 1, 1, 1, true)  
  1695.     GameTooltip:AddLine("• Solo Shuffle Rating: ", 1, 0.5, 0, true)
  1696.     GameTooltip:AddLine("Your current rating in Solo Shuffle.", 1, 1, 1, true)
  1697.     GameTooltip:Show()
  1698. end)
  1699.  
  1700. pvpStatsButton:SetScript("OnLeave", function(self)
  1701.     GameTooltip:Hide()
  1702. end)
  1703.  
  1704. -- Apply the color to all the buttons
  1705. applyButtonColor()
  1706.  
  1707. -- Set OnClick functions for the buttons
  1708. allClearButton:SetScript("OnClick", AllClearButtonOnClick)
  1709. sendMoreButton:SetScript("OnClick", SendMoreButtonOnClick)
  1710. incButton:SetScript("OnClick", IncButtonOnClick)
  1711.  
  1712. -- Apply the PostClick script to each button
  1713. for _, button in ipairs(buttons) do
  1714.     button:SetScript("PostClick", function()
  1715.         applyButtonColor()
  1716.     end)
  1717. end
  1718.  
  1719. local function OnAddonLoaded(self, event, loadedAddonName)
  1720.     if loadedAddonName == addonName then
  1721.         EnsureDBSettings()
  1722.         RestoreMapPositionAndScale()  
  1723.        
  1724.         if addonNamespace.ResizeWorldMap then
  1725.             addonNamespace.ResizeWorldMap()
  1726.         end
  1727.     end
  1728. end
  1729.  
  1730. -- Slash command registration
  1731. SLASH_INC1 = "/inc"
  1732. SlashCmdList["INC"] = function()
  1733.     if IncCallout:IsShown() then
  1734.         IncCallout:Hide()
  1735.     else
  1736.         IncCallout:Show()
  1737.     end
  1738. end
  1739.  
  1740. -- New function to handle the '/incmsg' command
  1741. local function IncomingBGMessageCommandHandler(msg)
  1742.     local messageType = "INSTANCE_CHAT"  
  1743.     local message = "Peeps, yall need to get the addon Incoming-BG. It has a GUI to where all you have to do is click a button to call an INC. Beats having to type anything out. Just sayin'."  
  1744.  
  1745.     SendChatMessage(message, messageType)
  1746. end
  1747.  
  1748. SLASH_INCOMINGBGMSG1 = "/incmsg"
  1749. SlashCmdList["INCOMINGBGMSG"] = IncomingBGMessageCommandHandler
  1750.  
  1751. IncCallout:SetScript("OnEvent", OnEvent)
  1752.  
  1753. -- Register the events
  1754. IncCallout:RegisterEvent("PLAYER_ENTERING_WORLD")
  1755. IncCallout:RegisterEvent("PLAYER_LOGIN")
  1756. IncCallout:RegisterEvent("PLAYER_LOGOUT")
  1757. IncCallout:SetScript("OnEvent", OnEvent)
__________________
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.
  Reply With Quote
05-10-24, 10:09 PM   #20
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 67
Wow, thank you for that. It looks pretty good. I'll have to tinker with it a little bit, but overall it looks good.
  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