GatherLite

GatherLite

1M Downloads

Fixes for World Map and Mini Map issues in Gatherlite for Classic WoW and SoM

RdmState opened this issue ยท 0 comments

commented

Here are some updated routines that make Gatherlite work correctly in Classic Era WoW. They are all from methods.lua Note: These modifications were made to Gatherlite 3.2.6.

This one fixes the pins not displaying on the world map.

function GatherLite:createWorldmapNode(node)
    local object = GatherLite:GetNodeObject(node.object)
    if not object then
        return nil
    end

    local f = GFrame:getFrame("worldmap");
    f:SetAlpha(GatherLite.db.char.worldmap.opacity);
    f:SetSize(GatherLite.db.char.worldmap.size, GatherLite.db.char.worldmap.size)
    f.texture:SetTexture(object.icon)
    f.texture:SetSize(GatherLite.db.char.worldmap.size, GatherLite.db.char.worldmap.size)
--    f:SetBackdropColor(1, 0, 0, 1);

    f.node = node;
    f.object = object
    f.type = "worldmap";
    f.TimeSinceLastUpdate = 0

    f:SetFrameStrata("TOOLTIP");
--    f:SetFrameLevel(0);

    f:SetScript("OnUpdate", nil)

    f:SetScript("OnEnter", function(self)
        GatherLite:showTooltip(self);
    end)
    f:SetScript("OnLeave", function()
        GatherLite:hideTooltip()
    end)

    GatherLite:debug(_GatherLite.DEBUG_NODE, "Create worldmap node of type", node.type);
    Pins:AddWorldMapIconMap(_GatherLite.name, f, node.mapID, node.posX, node.posY);
    return f;
end

This fixes problems with undiscovered nodes not being added to the local and global database at the same time causing them to vanish when the addon is reloaded.

function GatherLite:RegisterNode(type, nodeID, mapID, posX, posY, loot, coin)
    if (IsInInstance()) then
        return
    end

	local node = GatherLite:findExistingLocalNode(type, mapID, posX, posY);

    if (node) then
		if (node.predefined == true) then
			GatherLite:debug(_GatherLite.DEBUG_NODE, "Found predefined " .. node.type .. " node id:" .. node.object .. "," .. node.mapID .. "," .. node.posX .. "," .. node.posY);
		else
			GatherLite:debug(_GatherLite.DEBUG_NODE, "Found existing " .. node.type .. " node id:" .. node.object .. "," .. node.mapID .. "," .. node.posX .. "," .. node.posY);
		end
        return
    end

    local node = {
        type = type,
        object = nodeID,
        mapID = mapID,
        posX = posX,
        posY = posY,
        loot = {},
        coins = 0,
        date = date('*t')
    };

	-- Add node to local table.
    table.insert(_GatherLite.db, node);
    GatherLite:UpdateNode(type, nodeID, mapID, posX, posY)

	-- Retrieve updated node from local table.
	node = GatherLite:findExistingLocalNode(type, mapID, posX, posY);
	if not node then
		GatherLite:debug(_GatherLite.DEBUG_NODE, "Inserted node not found");
	end
	
	--Add node to global table.
    table.insert(GatherLite.db.global.nodes[type], node);
	GatherLite:debug(_GatherLite.DEBUG_NODE, "Adding discovered " .. node.type .. " node id:" .. node.object .. "," .. node.mapID .. "," .. node.posX .. "," .. node.posY);

	--Display node on maps.
    GatherLite:createMinimapNode(node);
    GatherLite:createWorldmapNode(node);
end

These make sure that Gatherlite doesn't think the nodes are already displayed preventing them from being displayed at all.

local function loadDatabase(type)
    GatherLite:forEach(GatherLite.db.global.nodes[type], function(node)
        local oldNode = GatherLite:findExistingLocalNode(type, node.mapID, node.posX, node.posY);
        if not oldNode then
            node.loaded = false;
            node.predefined = false;
            table.insert(_GatherLite.db, node)
        end
    end);
end

local function LoadTable(type, data)
    if data then
        GatherLite:forEach(data, function(node)
            node.type = type;
            node.coins = 0
            node.loot = {}
            node.loaded = false;
            node.predefined = true

            local _, _, instance = HBD:GetWorldCoordinatesFromZone(node.posX, node.posY, node.mapID);
            node.instance = instance;

            table.insert(_GatherLite.db, node)
        end);
    end
end