Quantcast

Update to HereBeDragons-1.92-beta

Ludovicus [06-26-18 - 22:53]
Update to HereBeDragons-1.92-beta
Filename
libs/HereBeDragons/CHANGES.txt
libs/HereBeDragons/HereBeDragons-2.0.lua
libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
diff --git a/libs/HereBeDragons/CHANGES.txt b/libs/HereBeDragons/CHANGES.txt
index 3ffe873..99c6647 100755
--- a/libs/HereBeDragons/CHANGES.txt
+++ b/libs/HereBeDragons/CHANGES.txt
@@ -1,4 +1,54 @@
-Changes since tag 1.91-beta
+tag cd12ccfd13832690f1422c5795a3921c452298a7 1.92-beta
+Author:	Hendrik Leppkes <h.leppkes@gmail.com>
+Date:	Sat Jun 23 20:03:11 2018 +0200
+
+Tag as 1.92-beta
+
+commit f1b0f720ccce59c8139ae5e0cbfac21100c24874
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Sat Jun 23 18:53:33 2018 +0200
+
+    Fix minimap drawing zone limitation
+
+commit d087939c3b4734ac18a010420b12a4a3810ab5a2
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Sat Jun 23 18:53:18 2018 +0200
+
+    Use HBD parent map data for pin drawing
+
+commit 70c7ea002a3d702dd482958d11b7660f6ad36b7c
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Sat Jun 23 18:52:40 2018 +0200
+
+    Store the maps parent in the data table
+
+commit 3ecf06773358df59c80f66ae91de16da88b4264e
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Sat Jun 23 18:27:36 2018 +0200
+
+    Fix show flag handling in world map drawing for instance-based coordinates
+
+commit ec1e0d064b7a02ac97980fc5b7fc10adda044390
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Wed Jun 20 20:19:26 2018 +0200
+
+    Set a scaling limit for the pins so they show in a consistent size on all maps
+
+    Fixes WoWAce Issue #12
+
+commit e8e542646986796906d14abe6a8cba716e2f58c6
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Wed Jun 20 20:19:01 2018 +0200
+
+    Properly reset existing icons when re-using pins
+
+    Fixes GitHub Issue #4
+
+commit 61383763a1ce7b87379d50b534150693e2d17ab7
+Author: Hendrik Leppkes <h.leppkes@gmail.com>
+Date:   Wed Jun 13 19:50:42 2018 +0200
+
+    Fix drawing pins on the world map

 commit af699f6637a2d07ba3000273534116aefaffc679
 Author: Hendrik Leppkes <h.leppkes@gmail.com>
diff --git a/libs/HereBeDragons/HereBeDragons-2.0.lua b/libs/HereBeDragons/HereBeDragons-2.0.lua
index b9e333e..4231a8a 100755
--- a/libs/HereBeDragons/HereBeDragons-2.0.lua
+++ b/libs/HereBeDragons/HereBeDragons-2.0.lua
@@ -5,7 +5,7 @@ if select(4, GetBuildInfo()) < 80000 then
     return
 end

-local MAJOR, MINOR = "HereBeDragons-2.0", 4
+local MAJOR, MINOR = "HereBeDragons-2.0", 5
 assert(LibStub, MAJOR .. " requires LibStub")

 local HereBeDragons, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
@@ -132,9 +132,9 @@ if not oldversion or oldversion < 3 then
             right = left + (right - left) * 2

             instance, left, right, top, bottom = applyMapTransforms(instance, left, right, top, bottom)
-            mapData[id] = {left - right, top - bottom, left, top, instance = instance, name = data.name, mapType = data.mapType}
+            mapData[id] = {left - right, top - bottom, left, top, instance = instance, name = data.name, mapType = data.mapType, parent = data.parentMapID}
         else
-            mapData[id] = {0, 0, 0, 0, instance = instance or -1, name = data.name, mapType = data.mapType}
+            mapData[id] = {0, 0, 0, 0, instance = instance or -1, name = data.name, mapType = data.mapType, parent = data.parentMapID }
         end
     end

diff --git a/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua b/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
index 7aee844..8b8cf9e 100755
--- a/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
+++ b/libs/HereBeDragons/HereBeDragons-Pins-2.0.lua
@@ -5,7 +5,7 @@ if select(4, GetBuildInfo()) < 80000 then
 	return
 end

-local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 1
+local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 5
 assert(LibStub, MAJOR .. " requires LibStub")

 local pins, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
@@ -30,6 +30,9 @@ pins.worldmapProviderPin  = pins.worldmapProviderPin or CreateFromMixins(MapCanv
 -- store a reference to the active minimap object
 pins.Minimap = pins.Minimap or Minimap

+-- Data Constants
+local WORLD_MAP_ID = 947
+
 -- upvalue lua api
 local cos, sin, max = math.cos, math.sin, math.max
 local type, pairs = type, pairs
@@ -165,10 +168,25 @@ local function drawMinimapPin(pin, data)
     end
 end

+local function IsParentMap(originMapId, toCheckMapId)
+    local parentMapID = HBD.mapData[originMapId].parent
+    while parentMapID and HBD.mapData[parentMapID] do
+        local mapType = HBD.mapData[parentMapID].mapType
+        if mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then
+            return false
+        end
+        if parentMapID == toCheckMapId then
+            return true
+        end
+        parentMapID = HBD.mapData[parentMapID].parent
+    end
+    return false
+end
+
 local function UpdateMinimapPins(force)
     -- get the current player position
     local x, y, instanceID = HBD:GetPlayerWorldPosition()
-    local mapID, mapFloor = HBD:GetPlayerZone()
+    local mapID = HBD:GetPlayerZone()

     -- get data from the API for calculations
     local zoom = pins.Minimap:GetZoom()
@@ -216,7 +234,7 @@ local function UpdateMinimapPins(force)
         end

         for pin, data in pairs(minimapPins) do
-            if data.instanceID == instanceID and (not data.floor or (data.floor == mapFloor and (data.floor == 0 or data.mapID == mapID))) then
+            if data.instanceID == instanceID and (not data.uiMapID or data.uiMapID == mapID or (data.showInParentZone and IsParentMap(data.uiMapID, mapID))) then
                 activeMinimapPins[pin] = data
                 data.keep = true
                 -- draw the pin (this may reset data.keep if outside of the map)
@@ -313,6 +331,13 @@ worldmapPinsPool.creationFunc = function(framePool)
     frame:SetSize(1, 1)
     return Mixin(frame, worldmapProviderPin)
 end
+worldmapPinsPool.resetterFunc = function(pinPool, pin)
+    FramePool_HideAndClearAnchors(pinPool, pin)
+    pin:OnReleased()
+
+    pin.pinTemplate = nil
+    pin.owningMap = nil
+end

 -- register pin pool with the world map
 WorldMapFrame.pinPools["HereBeDragonsPinsTemplate"] = worldmapPinsPool
@@ -353,7 +378,7 @@ function worldmapProvider:HandlePin(icon, data)
     if not uiMapID then return end

     local x, y
-    if uiMapID == WORLDMAP_AZEROTH_ID then
+    if uiMapID == WORLD_MAP_ID then
         -- should this pin show on the world map?
         if uiMapID ~= data.uiMapID and data.worldMapShowFlag ~= HBD_PINS_WORLDMAP_SHOW_WORLD then return end

@@ -366,7 +391,7 @@ function worldmapProvider:HandlePin(icon, data)
         if uiMapID ~= data.uiMapID then
             local mapType = HBD.mapData[uiMapID].mapType
             if not data.uiMapID then
-                if mapType == Enum.UIMapType.Continent and data.worldMapShowFlag == HBD_PINS_WORLDMAP_SHOW_CONTINENT then
+                if mapType == Enum.UIMapType.Continent and data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT then
                     --pass
                 elseif mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then
                     -- fail
@@ -374,10 +399,10 @@ function worldmapProvider:HandlePin(icon, data)
                 end
             else
                 local show = false
-                local info = C_Map.GetMapInfo(data.uiMapID)
-                while info and info.parentMapID do
-                    if info.parentMapID == uiMapID then
-                        local mapType = HBD.mapData[info.parentMapID].mapType
+                local parentMapID = HBD.mapData[data.uiMapID].parent
+                while parentMapID and HBD.mapData[parentMapID] do
+                    if parentMapID == uiMapID then
+                        local mapType = HBD.mapData[parentMapID].mapType
                         -- show on any parent zones if they are normal zones
                         if data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_PARENT and
                             (mapType == Enum.UIMapType.Zone or mapType == Enum.UIMapType.Dungeon or mapType == Enum.UIMapType.Micro) then
@@ -390,7 +415,7 @@ function worldmapProvider:HandlePin(icon, data)
                         break
                         -- worldmap is handled above already
                     else
-                        info = C_Map.GetMapInfo(info.parentMapID)
+                        parentMapID = HBD.mapData[parentMapID].parent
                     end
                 end

@@ -409,6 +434,7 @@ end
 --  map pin base API
 function worldmapProviderPin:OnLoad()
     self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
+    self:SetScalingLimits(1, 1.0, 1.2)
 end

 function worldmapProviderPin:OnAcquired(icon, x, y)
@@ -418,6 +444,16 @@ function worldmapProviderPin:OnAcquired(icon, x, y)
     icon:SetParent(self)
     icon:ClearAllPoints()
     icon:SetPoint("CENTER", self, "CENTER")
+    icon:Show()
+end
+
+function worldmapProviderPin:OnReleased()
+    if self.icon then
+        self.icon:Hide()
+        self.icon:SetParent(UIParent)
+        self.icon:ClearAllPoints()
+        self.icon = nil
+    end
 end

 -- register with the world map