Thread Tools Display Modes
09/13/14, 08:26 PM   #1
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
CustomCompassPins problem

Hi

I am trying to use custom pins like this:
Lua Code:
  1. local zoneIndex = GetCurrentMapZoneIndex()
  2.             local COMP = ZoneToAchievements[872][zoneIndex]
  3.             local desc, completed, required = GetAchievementCriterion(872, COMP)
  4.             if completed ~= required then
  5.                 COMPASS_PINS.pinLayouts[PINS_MAIQ].maxDistance = savedVariables.pinTextureMisc.maxDistance
  6.                 COMPASS_PINS.pinManager:CreatePin(PINS_MAIQ, pinData, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  7.             elseif savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] == true then
  8.                 COMPASS_PINS.pinLayouts[PINS_MAIQ].texture = "Destinations/Icons/maiq_colored_Green.dds"
  9.                 COMPASS_PINS.pinLayouts[PINS_MAIQ].maxDistance = savedVariables.pinTextureMisc.maxDistance
  10.                 COMPASS_PINS.pinManager:CreatePin(PINS_MAIQ, pinData, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  11.                 local index = savedVariables.pinTextureMaiq.type
  12.                 COMPASS_PINS.pinLayouts[PINS_MAIQ].texture = pinTextures.maiq[index]
  13.             end
Problem is, it seems like this line is ignored:
COMPASS_PINS.pinLayouts[PINS_MAIQ].texture = "Destinations/Icons/maiq_colored_Green.dds"

Shouldn't that line force that specific pin to be used, overriding the set texture for PINS_MAIQ?
  Reply With Quote
09/13/14, 09:36 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
I'd probably use additional layout:

Lua Code:
  1. local pinLayout_MaiqCompass = {
  2.     maxDistance = savedVariables.pinTextureMisc.maxDistance,
  3.     level = pinTextureLevelMaiq,
  4.     texture = pinTextures.maiq[pinTextureTypeMaiq],
  5.     size = pinTextureSizeMaiq,
  6.     additionalLayout = {
  7.         function(pin)
  8.             if savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] then
  9.                 local zoneIndex = GetCurrentMapZoneIndex()
  10.                 local criterion = ZoneToAchevements[872][zoneIndex]
  11.                 local _, completed, required = GetAchievementCriterion(872, criterion)
  12.                 if completed == required then
  13.                     local icon = pin:GetNamedChild("Background")
  14.                     icon:SetTexture("Destinations/Icons/maiq_colored_Green.dds")
  15.                 end
  16.             end
  17.         end,
  18.         function(pin) end, --reset function, must be present. Texture is set automatically, so I will leave it empty.
  19.     },
  20. }
  21.  
  22. local function AddMaiqCompassPins() --copy&paste from the current version of Destinations, I have just removed one line from the function
  23.     if savedVariables.filters[PINS_MISC] == false or (GetMapType() ~= MAPTYPE_ZONE) then return end
  24.     if savedVariables.filters[PINS_ACHIEVEMENTS_COMPASS] == false or savedVariables.filters[PINS_ACHIEVEMENTS] == false then return end
  25.     local data = ACHDataStore[GetCurrentMapZoneIndex()]
  26.     if not data then return end
  27.     for _, pinData in ipairs(data) do
  28.         local TYPE = pinData[ACHDataIndex.TYPE]
  29.         if TYPE == 1 then
  30.             local zoneIndex = GetCurrentMapZoneIndex()
  31.             local COMP = ZoneToAchievements[872][zoneIndex]
  32.             local desc, completed, required = GetAchievementCriterion(872, COMP)
  33.             if completed ~= required or savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] == true then
  34.                 COMPASS_PINS.pinManager:CreatePin(PINS_MAIQ, pinData, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  35.             end
  36.         end
  37.     end
  38. end
  39.  
  40. COMPASS_PINS:AddCustomPin(PINS_MAIQ, AddMaiqCompassPins, pinLayout_MaiqCompass)
  41. COMPASS_PINS:RefreshPins(PINS_MAIQ)

EDIT:
Your code doesn't work because pin is not created immediately. CreatePin function just inserts pin information (i.e. reference to the pinLayout and pin coordiantes) to the internal table and pin itself is created when it should be displayed on the compass. If you want to modify pin texture, you will have to use additionalLayout or sizeCallback functions.
Another solution would be using two different pin types with different pin layouts - one of complete and second for incomplete achievements.

Last edited by Garkin : 09/14/14 at 04:17 AM.
  Reply With Quote
09/14/14, 12:00 AM   #3
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Oh and as far as I can remember compass pin textures are stored in pinTexture, aboveTexture, belowTexture.
  Reply With Quote
09/14/14, 09:20 AM   #4
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
@Garkin: I did think about that. Thanks
@Fyrakin: I'll keep that in mind. Thanks

I consider this one closed then
  Reply With Quote
09/14/14, 01:26 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Fyrakin View Post
Oh and as far as I can remember compass pin textures are stored in pinTexture, aboveTexture, belowTexture.
CustomCompassPins doesn't use the same pins as ZOS compass, so it works a bit different way. Only texture you should be using with CustomCompasPins library is pin:GetNamedChild("Background").
  Reply With Quote
09/14/14, 02:37 PM   #6
Fyrakin
 
Fyrakin's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 129
Originally Posted by Garkin View Post
CustomCompassPins doesn't use the same pins as ZOS compass, so it works a bit different way. Only texture you should be using with CustomCompasPins library is pin:GetNamedChild("Background").
I think that one is for belowTexture, but I'm not sure.
  Reply With Quote
09/14/14, 07:55 PM   #7
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
I'd probably use additional layout:

Lua Code:
  1. local pinLayout_MaiqCompass = {
  2.     maxDistance = savedVariables.pinTextureMisc.maxDistance,
  3.     level = pinTextureLevelMaiq,
  4.     texture = pinTextures.maiq[pinTextureTypeMaiq],
  5.     size = pinTextureSizeMaiq,
  6.     additionalLayout = {
  7.         function(pin)
  8.             if savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] then
  9.                 local zoneIndex = GetCurrentMapZoneIndex()
  10.                 local criterion = ZoneToAchevements[872][zoneIndex]
  11.                 local _, completed, required = GetAchievementCriterion(872, criterion)
  12.                 if completed == required then
  13.                     local icon = pin:GetNamedChild("Background")
  14.                     icon:SetTexture("Destinations/Icons/maiq_colored_Green.dds")
  15.                 end
  16.             end
  17.         end,
  18.         function(pin) end, --reset function, must be present. Texture is set automatically, so I will leave it empty.
  19.     },
  20. }
  21.  
  22. local function AddMaiqCompassPins() --copy&paste from the current version of Destinations, I have just removed one line from the function
  23.     if savedVariables.filters[PINS_MISC] == false or (GetMapType() ~= MAPTYPE_ZONE) then return end
  24.     if savedVariables.filters[PINS_ACHIEVEMENTS_COMPASS] == false or savedVariables.filters[PINS_ACHIEVEMENTS] == false then return end
  25.     local data = ACHDataStore[GetCurrentMapZoneIndex()]
  26.     if not data then return end
  27.     for _, pinData in ipairs(data) do
  28.         local TYPE = pinData[ACHDataIndex.TYPE]
  29.         if TYPE == 1 then
  30.             local zoneIndex = GetCurrentMapZoneIndex()
  31.             local COMP = ZoneToAchievements[872][zoneIndex]
  32.             local desc, completed, required = GetAchievementCriterion(872, COMP)
  33.             if completed ~= required or savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] == true then
  34.                 COMPASS_PINS.pinManager:CreatePin(PINS_MAIQ, pinData, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  35.             end
  36.         end
  37.     end
  38. end
  39.  
  40. COMPASS_PINS:AddCustomPin(PINS_MAIQ, AddMaiqCompassPins, pinLayout_MaiqCompass)
  41. COMPASS_PINS:RefreshPins(PINS_MAIQ)

EDIT:
Your code doesn't work because pin is not created immediately. CreatePin function just inserts pin information (i.e. reference to the pinLayout and pin coordiantes) to the internal table and pin itself is created when it should be displayed on the compass. If you want to modify pin texture, you will have to use additionalLayout or sizeCallback functions.
Another solution would be using two different pin types with different pin layouts - one of complete and second for incomplete achievements.
After fixing a spelling mistake you made then I made it work. Thanks as always Garkin

I know this part below is not a CompassPins problem.
Now I need to make it show the pin text in a different color for the zones that's not completed.
I am thinking of the "Lightbringer/Give to the Poor/Crime Pays" achievements in particular.
When I have "Show completed achievements" on, then it shows the not completed ones with the correct pin, BUT it shows the text for the completed and not completed together.
I'd like a custom color for the not completed ones, so they stand out.
Let's say a green for completed ones and red for not completed (just to have some colors).
  Reply With Quote
09/14/14, 08:49 PM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Pin text - you mean tooltips? If you use the same tooltip creator as for POI pins:
Lua Code:
  1. local pinTooltipCreator = {
  2.     creator = function(pin)
  3.         local _, pinTag = pin:GetPinTypeAndTag()
  4.         for _, lineData in ipairs(pinTag) do
  5.             SetTooltipText(InformationTooltip, lineData)
  6.         end
  7.     end,
  8.     tooltip = InformationTooltip,
  9. }

You can use the following add callback to show colored tooltip lines:
Lua Code:
  1. local function OtherpinTypeCallback(pinManager)
  2.     if not LMP:IsEnabled(PINS_LB_GTTP_CP) or savedVariables.filters[PINS_ACHIEVEMENTS] == false or (GetMapType() ~= MAPTYPE_ZONE) then return end
  3.     local zoneIndex = GetCurrentMapZoneIndex()
  4.     local data = ACHDataStore[zoneIndex]
  5.     if not data then return end
  6.     for _, pinData in ipairs(data) do
  7.         local TYPE = pinData[ACHDataIndex.TYPE]
  8.         if TYPE == 2 then
  9.             local COMP = ZoneToAchievements[767167][zoneIndex]
  10.             local _, completedLB, requiredLB = GetAchievementCriterion(873, COMP)
  11.             local _, completedGTTP, requiredGTTP = GetAchievementCriterion(871, COMP)
  12.             local _, completedCP, requiredCP = GetAchievementCriterion(869, COMP)
  13.             local completed = completedLB + completedGTTP + completedCP
  14.             local required = requiredLB + requiredGTTP + requiredCP
  15.             local tooltipText = {}
  16.             table.insert(tooltipText, table.concat( {completedLB == requiredLB and "|c00FF00" or "|cFF0000", ACHids[873], "|r"} ))
  17.             table.insert(tooltipText, table.concat( {completedGTTP == requiredGTTP and "|c00FF00" or "|cFF0000", ACHids[871], "|r"} ))
  18.             table.insert(tooltipText, table.concat( {completedCP == requiredCP and "|c00FF00" or "|cFF0000", ACHids[869], "|r"} ))
  19.             if completed ~= required or savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] == true then
  20.                 LMP:CreatePin(PINS_LB_GTTP_CP, tooltipText, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  21.             end
  22.         end
  23.     end
  24. end

Last edited by Garkin : 09/14/14 at 08:57 PM.
  Reply With Quote
09/14/14, 09:37 PM   #9
SnowmanDK
 
SnowmanDK's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 161
Originally Posted by Garkin View Post
Pin text - you mean tooltips? If you use the same tooltip creator as for POI pins:
Lua Code:
  1. local pinTooltipCreator = {
  2.     creator = function(pin)
  3.         local _, pinTag = pin:GetPinTypeAndTag()
  4.         for _, lineData in ipairs(pinTag) do
  5.             SetTooltipText(InformationTooltip, lineData)
  6.         end
  7.     end,
  8.     tooltip = InformationTooltip,
  9. }

You can use the following add callback to show colored tooltip lines:
Lua Code:
  1. local function OtherpinTypeCallback(pinManager)
  2.     if not LMP:IsEnabled(PINS_LB_GTTP_CP) or savedVariables.filters[PINS_ACHIEVEMENTS] == false or (GetMapType() ~= MAPTYPE_ZONE) then return end
  3.     local zoneIndex = GetCurrentMapZoneIndex()
  4.     local data = ACHDataStore[zoneIndex]
  5.     if not data then return end
  6.     for _, pinData in ipairs(data) do
  7.         local TYPE = pinData[ACHDataIndex.TYPE]
  8.         if TYPE == 2 then
  9.             local COMP = ZoneToAchievements[767167][zoneIndex]
  10.             local _, completedLB, requiredLB = GetAchievementCriterion(873, COMP)
  11.             local _, completedGTTP, requiredGTTP = GetAchievementCriterion(871, COMP)
  12.             local _, completedCP, requiredCP = GetAchievementCriterion(869, COMP)
  13.             local completed = completedLB + completedGTTP + completedCP
  14.             local required = requiredLB + requiredGTTP + requiredCP
  15.             local tooltipText = {}
  16.             table.insert(tooltipText, table.concat( {completedLB == requiredLB and "|c00FF00" or "|cFF0000", ACHids[873], "|r"} ))
  17.             table.insert(tooltipText, table.concat( {completedGTTP == requiredGTTP and "|c00FF00" or "|cFF0000", ACHids[871], "|r"} ))
  18.             table.insert(tooltipText, table.concat( {completedCP == requiredCP and "|c00FF00" or "|cFF0000", ACHids[869], "|r"} ))
  19.             if completed ~= required or savedVariables.filters[SHOW_COMPLETED_ACHIEVEMENTS] == true then
  20.                 LMP:CreatePin(PINS_LB_GTTP_CP, tooltipText, pinData[ACHDataIndex.X], pinData[ACHDataIndex.Y])
  21.             end
  22.         end
  23.     end
  24. end
Yet again Garkin to the rescue!
Thank you once more
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » CustomCompassPins problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off