View Single Post
12/22/15, 02:58 PM   #11
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by SnowmanDK View Post
IF I understand this all right, then I can't just cache the amount in a variable for later use, as the amount can change when you move bait to/from your bank, when you pick up bait, when you get it from a mail and so on UNLESS I set it to update in all those cases... The only exception is if I can set it to ONLY update when the map is opened, but I guess it would have to be some sort of a prehook function to make sure the pin data is updated before you point to the pins (correct me if I am wrong).

The most important thing is to make it update the amount of correct bait on the correct pins when the map is opened.

My current solution does check all 9 and it does take multiple stacks into account.
As it is it updates every time there is a change in the bag content by doing a EVENT_INVENTORY_SINGLE_SLOT_UPDATE.
It is not optimal, I know, but it works for now
Hi,

well am not as deep in your problem, as you But the tooltip creator of the map pins is/can be a callback-function, which can do anything you want before adding text to the tooltip.

you can count the baits the first time a pin is hovered (creator callback is called the first time) and cache the values until map gets closed again.

uncomplete example:
Code:
...
local dirty = true
...
	local creator = {
		creator = function(pin)
			local _, tag = pin:GetPinTypeAndTag()
if dirty then
--count baits, if first time and cache
dirty = false
end
--fill text variable
			if IsInGamepadPreferredMode() then
				ZO_MapLocationTooltip_Gamepad:AddLine(text)
			else
				local r, g, b = ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()
				InformationTooltip:AddLine(text, "", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, TEXT_ALIGN_CENTER)
			end
		end,
		tooltip = 1,
	}

	self.layout = {
		level = data.settings.pinLevel or 30,
		size = data.settings.pinSize or 32,
		insetX = 4,
		insetY = 4,
		texture = "esoui/art/icons/achievements_indexicon_fishing_down.dds",
		tint = function(pin)
			local _, tag = pin:GetPinTypeAndTag()
			return tag:GetColor()
		end,
	}

	ZO_WorldMap_AddCustomPin(data.pinType, LayoutPins, nil, self.layout, creator)
...

do
	local function WorldMapStateChanged(oldState, newState)
		if (newState == SCENE_FRAGMENT_HIDING) then
			dirty=true
-- next time count baits again
		end
	end
	WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)
	GAMEPAD_WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)
end
...
For counting the baits, you could try circonian's idea.

/edit: Ok, I'm even more slow
  Reply With Quote