HizurosWoWAddOns / LFR_of_the_past

GNU General Public License v3.0
1 stars 2 forks source link

Fix for 10.x gosssip frames :) #2

Open QartemisT opened 1 year ago

fubaWoW commented 1 year ago

@QartemisT Fix for 10.x gosssip frames :)

Well... TLTR: NO! this does not fix anything in 10.x!

for my first tests with the "new" gossip frame in 10.x, the only and "clean" way is to hook GossipOptionButtonMixin function Setup and do "the action" directly on gossip button creation.

my function looks like this for now:

hooksecurefunc(GossipOptionButtonMixin, "Setup", function(self, optionInfo)
    local id,_ = UnitGUID("npc");
    if id then
        _,_,_,_,_,id = strsplit('-',id);
        id = tonumber(id);
    end
    if id and ns.npcID[id] and not IsControlKeyDown() then
        ScanSavedInstances();
        NPC_ID = id;            
        local buttonID = optionInfo.orderIndex + 1
        local instanceID
        if ns.gossip2instance[NPC_ID] and #ns.gossip2instance[NPC_ID]>0 then
            instanceID = ns.gossip2instance[NPC_ID][buttonID];
        end
        if instanceID then
            local data = {
                groupName = false,
                instanceID = instanceID,
                instance = {GetLFGDungeonInfo(instanceID)},
                numEncounters = {0,0},
                encounters = {}
            };
            if data.instance[name]~=data.instance[name2] then
                data.groupName = data.instance[name2];
            end
            local bossIndexes = {};
            if ns.instance2bosses[instanceID] then
                bossIndexes = ns.instance2bosses[instanceID];
                data.numEncounters[2] = #ns.instance2bosses[instanceID];
            else
                data.numEncounters[2] = GetLFGDungeonNumEncounters(instanceID);
                for i=1, data.numEncounters[2] do
                    tinsert(bossIndexes,i);
                end
            end
            for _,i in ipairs(bossIndexes) do
                local boss, _, isKilled = GetLFGDungeonEncounterInfo(instanceID,i);
                local n = (data.instance[name2] or data.instance[name]).."-"..data.instance[difficulty];
                if not isKilled and killedEncounter[n] and killedEncounter[n][boss] then
                    isKilled = true;
                end
                if isKilled then
                    data.numEncounters[1] = data.numEncounters[1] + 1;
                    tinsert(data.encounters,boss);
                end
            end
            local showID = "";
            if false then
                showID = " " .. C("blue","("..instanceID..")");
            end
            -- gossip text replacement
            self:SetText(
                data.instance[name]..showID.."\n"..
                "|Tinterface\\lfgframe\\ui-lfg-icon-heroic:12:12:0:0:32:32:0:16:0:16|t "..C("dkred",_G.GENERIC_FRACTION_STRING:format(data.numEncounters[1],data.numEncounters[2])).. " || ".. C("dkgray",data.instance[name2]) .. "\n")
            -- gossip icon replacement
            self.icon = 1502548
        end
    end
end)

this "kinda works"... but there is SO MUCH more to do! there are also so many other errors like RegisterOptions

QartemisT commented 1 year ago

@fubaWoW You're claiming that's the ONLY way to do it... And yet I have the exact code that I suggessted, and have it working locally :P

Sure, I don't have the rest of the code, only the gossip frame onshow hook, but the PR submit was purely for "fixing gossip frame"... which it does.