View Single Post
12/22/15, 04:56 PM   #17
Wandamey
Guest
Posts: n/a
there is an example in votan's answer,I colored it, you'll have to temper with it a bit, he uses the var dirty to even tell if it was necessary to update or not. Now that your counting function is shortened to a minimum, you can run it each time you open the map.

Originally Posted by votan View Post
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


maybe try this instead
but as I said, i can't test it and i'm the queen of typos. good luck

Code:
local function WorldMapStateChanged(oldState, newState)
    if (newState == SCENE_FRAGMENT_SHOWING) then
	UpdateBaitsCountFunction()
   end
end



WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)
GAMEPAD_WORLD_MAP_SCENE:RegisterCallback("StateChange", WorldMapStateChanged)

Edit : and still a super slow typer.

It's not map change, it's Scene State change . just try it. or i'll check another example with the standard scene manager.

But anyway it's time for me to call it a day, and soon circonian will be there and make us all look like unwiped kids with a one line function that does everything you always dreamt of and even more.

Last edited by Wandamey : 12/22/15 at 05:06 PM.
  Reply With Quote