ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   CustomCompassPins problem (https://www.esoui.com/forums/showthread.php?t=2231)

SnowmanDK 09/13/14 08:26 PM

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?

Garkin 09/13/14 09:36 PM

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.

Fyrakin 09/14/14 12:00 AM

Oh and as far as I can remember compass pin textures are stored in pinTexture, aboveTexture, belowTexture.

SnowmanDK 09/14/14 09:20 AM

@Garkin: I did think about that. Thanks :)
@Fyrakin: I'll keep that in mind. Thanks :)

I consider this one closed then ;)

Garkin 09/14/14 01:26 PM

Quote:

Originally Posted by Fyrakin (Post 12113)
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").

Fyrakin 09/14/14 02:37 PM

Quote:

Originally Posted by Garkin (Post 12123)
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.

SnowmanDK 09/14/14 07:55 PM

Quote:

Originally Posted by Garkin (Post 12110)
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 :banana:

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).

Garkin 09/14/14 08:49 PM

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

SnowmanDK 09/14/14 09:37 PM

Quote:

Originally Posted by Garkin (Post 12128)
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 :)


All times are GMT -6. The time now is 02:42 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI