-- Début du fichier
local addonName = "RaidPlayerExport"; local addon = LibStub("AceAddon-3.0"):GetAddon(addonName); if not addon then return end
SLASH_RaidPLAYEREXPORT1, SLASH_RaidPLAYEREXPORT2 = "/rpe", "/raidplayerexport"

function SlashCmdHandler(msg) 
    local command = msg and strlower(msg) or ""; 
    if command == "reset" then 
        addon.frames.container:ClearAllPoints(); 
        addon.frames.container:SetPoint("CENTER"); 
        addon.frames.container:SetWidth(addon.FRAME_WIDTH_MAIN); 
        addon.frames.loot:Hide(); 
        print("|cff00ff00[RPE]|r Position réinitialisée."); 
        addon:ToggleWindows()
    else 
        addon:ToggleWindows() 
    end 
end
SlashCmdList["RaidPLAYEREXPORT"] = SlashCmdHandler

local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("GROUP_ROSTER_UPDATE")

eventFrame:SetScript("OnEvent", function(self, event, ...)
    if event == "ADDON_LOADED" then 
        local loadedAddonName = ...; 
        if loadedAddonName == addonName then 
            addon:CreateFrames(); 
            local LDB = LibStub("LibDataBroker-1.1"); 
            local LibDBIcon = LibStub("LibDBIcon-1.0"); 
            local dataObject = LDB:NewDataObject(addonName, { 
                type = "launcher", 
                label = "RaidPlayerExport", 
                -- --- MODIFIÉ --- Le chemin pointe maintenant vers le dossier Logo.
                icon = "Interface/AddOns/"..addonName.."/Media/Logo/Logo.tga", 
                OnClick = function(_, button) if button == "LeftButton" then addon:ToggleWindows() end end, 
                OnTooltipShow = function(tooltip) tooltip:AddLine("RaidPlayerExport"); tooltip:AddLine("|cffeda55f/rpe reset|r pour recentrer.") end, 
            }); 
            LibDBIcon:Register(addonName, dataObject, addon.db.profile.minimap); 
            self:UnregisterEvent("ADDON_LOADED") 
        end
    elseif event == "GROUP_ROSTER_UPDATE" then 
        if addon.frames.container and addon.frames.container:IsShown() then addon:UpdateRaidList() end
    end
end)

function addon:ShowLootFrame()
    local displayText = "\n\nLa fonctionnalité d'historique de butin\nest en cours de développement."
    
    self.frames.lootHistory.officialText = displayText
    self.frames.lootHistory:SetText(displayText)
    self.frames.loot:Show()
end

function addon:ToggleLootFrame() 
    local lootFrame = self.frames.loot; 
    local container = self.frames.container; 
    if lootFrame:IsShown() then 
        lootFrame:Hide(); 
        container:SetWidth(self.FRAME_WIDTH_MAIN) 
    else 
        container:SetWidth(self.FRAME_WIDTH_MAIN + self.FRAME_WIDTH_LOOT + self.FRAME_SPACING); 
        self:ShowLootFrame() 
    end 
end

function addon:ToggleWindows() 
    local container = self.frames.container; 
    if container:IsShown() then 
        container:Hide() 
    else 
        container:Show()
        self:UpdateRaidList()
    end 
end
-- Fin du fichier