Download
(4 Kb)
Download
Updated: 10/01/21 09:52 AM
Pictures
File Info
Compatibility:
Deadlands (7.2.5)
Greymoor (6.0.5)
Updated:10/01/21 09:52 AM
Created:04/09/14 06:55 PM
Monthly downloads:21,889
Total downloads:2,642,435
Favorites:1,909
MD5:
CustomCompassPins  Popular! (More than 5000 hits)
Version: 1.32
by: Shinni, Garkin
This Library allows addons to add custom pins to the compass.

How to use:

First you have to add the pinType:
Lua Code:
  1. COMPASS_PINS:AddCustomPin( pinType, pinCallback, layout )
pinType is a unique string eg "MySkyshards"
pinCallback is a callback function which receives a pinManager (more further below)
layout is a table which specifies texture and other settings for the pins of this pinType

The callback function
The callback function is called everytime, the compass is refreshed.
This function creates the pins via the given pinManager (first and only parameter).
example:
Lua Code:
  1. function( pinManager )
  2.     for _, pin in pairs( pins ) do
  3.         pinManager:CreatePin( pinType, pinTag, pin.x, pin.y )
  4.     end
  5. end
The pinManager has only one method: CreatePin( pinType, pinTag, xLoc, yLoc )
pinType the pinType the created pin belongs to
pinTag an unique identifier for the pin. You can pass additional attributes to the pin via the pinTag, which can later be used (see layout for more information).
xLoc, yLoc position of the pin in normalized map coordinates. (0,0 = topleft, 1,1 = bottomright)


The layout table
The layout table must have the following keys:
maxDistance the maximal distance (in normalized map units) for the pin to be visible (it will slowly fade out, when the pin gets close to the maxDistance)
texture the filepath to the texture

optional keys:
FOV the field of view in radians. eg 2pi will result in the pin being always visible, pi means the pin is visible as long it is not behind the player.
sizeCallback a function which receives the pin, the angle between the player and the pin, the normalized angle (-1 = left border of the compass, 1 = right border of the compass, 0 = center of the compass), normalizedDistance (0 = same position as player, 1 = pin is at maxDistance)
This function can modify the size of the pin via pin:SetDimension(width, height)
If no function is given, the pin has a size of 32x32 and will become smaller if abs(normalizedAngle) > 0.25
additionalLayout another table with 2 components, each one needs to be a function.
The first one receives the same parameters as the sizeCallback function. It can be used to implement additional visual effects. eg: you could do something like pin:SetColor(1,0,0,1) to make the pin red.
The second function receives only a pin as parameter. As the pins are pooled (saved to be used again), the additional modifications of the pin need to be cleared again. So in the previous example this function should call pin:SetColor(1,1,1,1) to make the pin white again.

The pin object
a pin has the following attributes:
pin.xLoc x coordinate
pin.yLoc y coordinate
pin.pinType the pinType
pin.pinTag the pinTag
As the pin is the first given parameter in the layout callback functions, you can pass any data to these functions via the pinTag (eg an alternate texture that is different from the one specified in the layout table)

important functions
pin:SetAlpha(value) 1 = pin is opaque, 0 = pin is transparent. Usefull for fadeout effects.
pin:SetHidden(bool) if bool is true, the pin is invisible
pin:SetDimensions(width, height) sets the width and height of the pin (usefull if you want to implement your own a zoom effect near the border or something like that)
pin:SetColor(r, g, b, a) changes the pins color. you can create some kind of highlighting effect with this.
pin:GetNamedChild( "Background" ) returns the texture control.
v 1.32
- fixed lua error that occurs on deadlands PTS

v 1.31
- added name tags for Scootworks

v 1.30
- updated api version and added IsLibrary tag

v 1.29
- updated api version for those that use the lib as standalone

v 1.29 (Shinni)
- adding multiple pins with the same pinTag doesn't result in stuck pins anymore

v 1.28.1 (Shinni)
- changed how pins are indexed, individual pins can now be deleted and accessed directly
- removed a buggy background texture that would display behind the pin's real texture
- updated API version

v1.26 (Garkin)
- updated API version
- minor changes in callbacks

v1.25 (Garkin)
- changed timing of WorldMap update, so shuttering when map is closed should be less noticeable

v1.24 (Garkin)
- update from version 1.21 now should work correctly

v1.23 (Garkin)
- fixed bug introduced in 1.22, map should be updated correctly now

v1.22 (Garkin)
- fixed bug where library could have loaded pins for different map

v1.21 (Garkin)
- changed way to detect map change, it should be more efficient
- :AddCustomPin method now checks if arguments are valid
- callback has now just one argument mapName (eg. "auridon/auridon_base"):
CALLBACK_MANAGER:RegisterCallback("CustomCompassPins_MapChanged", function(mapName) end)

v1.20 (Garkin)
- updated APIversion to 100004
- changed GetDistanceCoefficient function
- changed update frequence from 10ms to 20ms.
- added callback "CustomCompassPins_MapChanged". To register for callback use:
CALLBACK_MANAGER:RegisterCallback("CustomCompassPins_MapChanged", function(zone, subzone) end)

v1.19 (Garkin)
- fixed issue with invalid map size

v1.18 (Garkin)
- another fix for refreshing pins and distance coefficient

v1.17 (Garkin)
- fixed bug with refreshing pins

v1.16 (Garkin)
- different method to detect map change, previous didn't work when player had no quests.

v1.15 (Garkin)
- fixed possible issue with distance coefficient
- added addon manifest (.txt)
- added delay to update function

v1.14 (Garkin)
- compass distance is now scaled with the mapsize (approximate)

v1.13
- when creating and removing a lot of pins the pinTypes could mix up, resulting in incompabilities of different addons

v1.12
- only create controls when needed

v1.11
- fixed an error where one addon could accidentally delete the pins of other addons.

v1.1
- released
Optional Files (0)


Archived Files (19)
File Name
Version
Size
Uploader
Date
1.31
4kB
Shinni
05/25/20 11:47 AM
1.30
4kB
Shinni
03/26/20 12:18 PM
1.29
4kB
Shinni
10/23/18 05:15 PM
1.29
4kB
Shinni
03/23/16 11:05 AM
1.28.1
4kB
Shinni
03/10/16 12:18 PM
1.26
4kB
Garkin
06/25/14 07:39 AM
1.25
4kB
Garkin
06/12/14 04:42 AM
1.24
4kB
Garkin
06/07/14 08:15 AM
1.23
4kB
Garkin
06/07/14 07:17 AM
1.20
3kB
Garkin
05/29/14 06:16 PM
1.19
3kB
Garkin
05/14/14 05:11 PM
1.18
3kB
Garkin
05/13/14 09:31 PM
1.17
3kB
Garkin
05/11/14 05:50 AM
1.16
3kB
Garkin
05/09/14 07:04 AM
1.15
3kB
Garkin
05/07/14 08:09 PM
1.14
3kB
Shinni
04/26/14 02:58 PM
1.13
3kB
Shinni
04/26/14 02:31 PM
1.13
2kB
Shinni
04/09/14 08:27 PM
1.1
2kB
Shinni
04/09/14 06:55 PM


Post A Reply Comment Options
Unread 04/17/14, 06:31 PM  
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view AddOns

Forum posts: 626
File comments: 2003
Uploads: 15
How similar are CustomMapPins and CustomCompassPins? I want to use TreasureMaps but it uses CustomMapPins. The front page is pretty detailed so I can look at that but just curious how similar they are.
Last edited by Sharlikran : 04/17/14 at 08:25 PM.
Report comment to moderator  
Reply With Quote
Unread 04/18/14, 05:52 AM  
Shinni
AddOn Author - Click to view AddOns

Forum posts: 167
File comments: 550
Uploads: 22
Originally Posted by Sharlikran
How similar are CustomMapPins and CustomCompassPins? I want to use TreasureMaps but it uses CustomMapPins. The front page is pretty detailed so I can look at that but just curious how similar they are.
The order of the arguments is a bit different but otherwise they work similiar.
Though I recommend to use ZO_WorldMap_AddCustomPin instead of CustomMapPins.
(more information here: http://www.esoui.com/forums/showpost...10&postcount=2)
CustomMapPins was supposed to make creating pins easier by not having to write a callback function. If you use a callback function, there is no need to use CustomMapPins in the first place.
Report comment to moderator  
Reply With Quote
Unread 04/22/14, 07:40 PM  
Adein
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 33
Uploads: 3
Hey,

I'm using your library in my addon "Group Leader". Everything works fine until a /reloadui. The pin callback is occurring and everything passed into pinManager:CreatePin() looks correct, but nothing shows up on the compass. I can send you/upload an updated/cleaner version of the code if you want, but it still has the same problem.

Any ideas?

Thanks,
Adein
Report comment to moderator  
Reply With Quote
Unread 04/24/14, 07:51 AM  
Shinni
AddOn Author - Click to view AddOns

Forum posts: 167
File comments: 550
Uploads: 22
If you upload your addon, I could test it a bit/try to find the error.
The only bug I know occurs when changing zones, but /realoadui always fixes my issues and doesn't create them. Quite interesting to see /reloadui causing an error...
Report comment to moderator  
Reply With Quote
Unread 04/24/14, 08:51 AM  
Adein
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 33
Uploads: 3
I'm pretty sure I figured it out. It was a library version conflict. The version you have here is 1.11, but HarvestMaps and Skyshards are using 1.12/1.121. I copied the version from your HarvestMaps into my addon and it seems to be fixed.
Report comment to moderator  
Reply With Quote
Unread 04/27/14, 10:37 PM  
Mars85
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 6
Uploads: 1
I wonder why aren't you using LibStub? It's made for avoiding version conflicts.
Report comment to moderator  
Reply With Quote
Unread 04/29/14, 11:09 AM  
Areo

Forum posts: 0
File comments: 1
Uploads: 0
Could you please include txt file to this as everytime i download it, its not coming with a txt file and im getting errors in game from it which i can not X out of
Report comment to moderator  
Reply With Quote
Unread 05/10/14, 12:06 AM  
Saftsuse
 
Saftsuse's Avatar

Forum posts: 13
File comments: 149
Uploads: 0
Can you please tell me som general info about callback function, just what it is in general?
Report comment to moderator  
Reply With Quote
Unread 05/10/14, 07:04 AM  
Garkin
 
Garkin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 832
File comments: 1097
Uploads: 33
Originally Posted by Saftsuse
Can you please tell me som general info about callback function, just what it is in general?
The callback function is called everytime, the compass is refreshed - i.e. when map is changed or when you call COMPASS_PINS:RefreshPins(pinType) from within your code.
This function has to create pins for the current map.

Example:
Lua Code:
  1. --sample data
  2. local pinData = {
  3.    ["auridon"] = {      --Auridon, Khenarthi's Roost
  4.       ["skywatch_base"] = {
  5.          { 0.5, 0.6 },
  6.       },      
  7.    },
  8.    ["main"] = {         --Main quest maps
  9.       ["hallsoftorment1_base"] = {
  10.          { 0.256, 0.361 },
  11.       },
  12.    },
  13. }
  14.  
  15. --callback function
  16. local function CompassPinCallback(pinManager)
  17.    if (GetMapType() > MAPTYPE_ZONE) then return end        --create pins only for: dungeon maps (0), subzone maps (1) and zone maps (2)
  18.  
  19.    local textureName = GetMapTileTexture()
  20.    textureName = string.lower(textureName)
  21.    local _,_,_,zone,subzone = string.find(textureName, "(maps/)([%w%-]+)/([%w%-]+_%w+)")
  22.    local pins
  23.  
  24.    if pinData[zone] then
  25.       if pinData[zone][subzone] ~= nil then  
  26.          pins = pinData[zone][subzone]
  27.       else
  28.          return                                             --return if no data
  29.       end
  30.    end
  31.  
  32.    for _, pin in ipairs(pins) do
  33.       -- :CreatePin(pinType, pinTag, locX, locY)
  34.       pinManager:CreatePin("My unique name for compass pin type", pin, pin[1], pin[2])
  35.    end
  36. end
You can use any other method to determine zone/subzone name, this is just what I use in my addons.
Last edited by Garkin : 05/10/14 at 07:10 AM.
Report comment to moderator  
Reply With Quote
Unread 05/21/14, 02:16 PM  
dominoid
AddOn Author - Click to view AddOns

Forum posts: 34
File comments: 276
Uploads: 2
Thought you would be the expert to answer this question. Sorry it's not directly related to your add-on library.

I love PinKiller as it hides all quest "pins" from the world view and the map view, but those pins are still available on the compass. I prefer the compass to a mini-map so I am looking for a way to hide certain (I'd even take all as an option) pins from the compass. I noticed you have the ability to set the Alpha to 0 in your library, so I thought maybe we could set other pins to alpha(0) as well. Do you know of a way to hide "stock" pins on the compass in part or in whole?

TIA
Report comment to moderator  
Reply With Quote
Unread 05/24/14, 07:10 AM  
Eleventeen

Forum posts: 16
File comments: 122
Uploads: 0
Maybe doesn't work for Craglorn?

Just got this, primary for craglorn, as it's city has zero map pins, and I was tired of search for a certain npc.

So I searched the main town there and marked everything off on my map.

When I later returned after a relog/zone, the map pins were all gone.
Report comment to moderator  
Reply With Quote
Unread 05/24/14, 09:03 AM  
Garkin
 
Garkin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 832
File comments: 1097
Uploads: 33
Originally Posted by Eleventeen
Maybe doesn't work for Craglorn?

Just got this, primary for craglorn, as it's city has zero map pins, and I was tired of search for a certain npc.

So I searched the main town there and marked everything off on my map.

When I later returned after a relog/zone, the map pins were all gone.
This is not CustomCompassPins library issue, it just shows pins on compass not on map.

It seems to be an issue of addon you use for creating custom map pins (eg. Harven's Custom Map Pins).
Report comment to moderator  
Reply With Quote
Unread 05/01/15, 04:29 PM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1019
File comments: 1531
Uploads: 31
I had this error tonight, I coulnd't say if it's CompassPin or Core UI :

Lua Code:
  1. 2015-05-01T22:10:00.290+01:00 |cff0000Lua Error: EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: attempt to index a nil value
  2. stack traceback:
  3.     EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: in function 'ZO_WorldMapFilterPanel_Shared:GetPinFilter'
  4.     EsoUI/Ingame/Map/WorldMapFilters.lua:83: in function 'WorldMapFilterPanel:LoadInitialState'
  5.     EsoUI/Ingame/Map/WorldMapFilters.lua:19: in function 'WorldMapFilterPanel:SetMapMode'
  6.     EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:111: in function 'OnMapChanged'
  7.     EsoUI/Libraries/Utility/ZO_CallbackObject.lua:104: in function 'ZO_CallbackObject:FireCallbacks'
  8.     user:/AddOns/SkyShards/Libs/CustomCompassPins/CustomCompassPins.lua:94: in function 'callback'
  9.     EsoUI/Libraries/Utility/ZO_CallbackObject.lua:104: in function 'ZO_CallbackObject:FireCallbacks'
  10.     EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
  11.     EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:160: in function 'ZO_SceneManager:HideScene'
  12.     EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:224: in function 'ZO_SceneManager:Show'|r

To reproduce :

- Go in Cyrodiil, in a locked campaign
- Die in Cyro
- Crash game
- Relog, you'll be tp near the wayshrine of your last location
- Try to display map, I think I dezoomed (changed map with right click), the error happends twice (I reloadUI, same issue).

I've also filled a bug to ZOS, because with this scenario, I cannot rez. The only possible rez is in Cyrodiil Keeps, and because I'm in the "Pve world" , i cannot do it. (Here I 'am on Malabal Tor, a friend rezzed me, that was the only solution).


Report comment to moderator  
Reply With Quote
Unread 09/01/15, 05:31 PM  
Sinful Soul

Forum posts: 1
File comments: 176
Uploads: 0
Error, IC

Skyshard, Lorebooks, Destinations, and every addon that uses this one is bugged because of this add-on now

When dying in IC I get this:


EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: attempt to index a nil value
stack traceback:
EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: in function 'ZO_WorldMapFilterPanel_Shared:GetPinFilter'
EsoUI/Ingame/Map/Keyboard/WorldMapFilters_Keyboard.lua:83: in function 'WorldMapFilterPanel:LoadInitialState'
EsoUI/Ingame/Map/Keyboard/WorldMapFilters_Keyboard.lua:19: in function 'WorldMapFilterPanel:SetMapMode'
EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:118: in function 'OnMapChanged'
EsoUI/Libraries/Utility/ZO_CallbackObject.lua:111: in function 'ZO_CallbackObject:FireCallbacks'
user:/AddOns/Destinations/Libs/CustomCompassPins/CustomCompassPins.lua:94: in function 'callback'
EsoUI/Libraries/Utility/ZO_CallbackObject.lua:111: in function 'ZO_CallbackObject:FireCallbacks'
EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:183: in function 'ZO_SceneManager:HideScene'
EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:238: in function 'ZO_Sc

The same "user:/AddOns/" bit shows for Skyshards, Lorebooks and so on.
Report comment to moderator  
Reply With Quote
Unread 09/01/15, 08:45 PM  
Garkin
 
Garkin's Avatar
AddOn Author - Click to view AddOns

Forum posts: 832
File comments: 1097
Uploads: 33
Re: Error, IC

Originally Posted by Sinful Soul
Skyshard, Lorebooks, Destinations, and every addon that uses this one is bugged because of this add-on now

When dying in IC I get this:


EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: attempt to index a nil value
stack traceback:
EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:40: in function 'ZO_WorldMapFilterPanel_Shared:GetPinFilter'
EsoUI/Ingame/Map/Keyboard/WorldMapFilters_Keyboard.lua:83: in function 'WorldMapFilterPanel:LoadInitialState'
EsoUI/Ingame/Map/Keyboard/WorldMapFilters_Keyboard.lua:19: in function 'WorldMapFilterPanel:SetMapMode'
EsoUI/Ingame/Map/WorldMapFilters_Shared.lua:118: in function 'OnMapChanged'
EsoUI/Libraries/Utility/ZO_CallbackObject.lua:111: in function 'ZO_CallbackObject:FireCallbacks'
user:/AddOns/Destinations/Libs/CustomCompassPins/CustomCompassPins.lua:94: in function 'callback'
EsoUI/Libraries/Utility/ZO_CallbackObject.lua:111: in function 'ZO_CallbackObject:FireCallbacks'
EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:183: in function 'ZO_SceneManager:HideScene'
EsoUI/Libraries/ZO_Scene/ZO_SceneManager.lua:238: in function 'ZO_Sc

The same "user:/AddOns/" bit shows for Skyshards, Lorebooks and so on.
Actually this is not error caused by CustomCompassPins library, it is caused by some addon which wants to access worldmap pin filters.

For example any addon with old version LibMapPins can show this error when you're on Imperial City map. You can try to install the latest version of LibMapPins as a stand alone addon, or update LibMapPins in addons which were not updated yet (like Lost Treasure, PublicDungeonChampions, CraftingStations etc.).
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: