Ship Routes: solid sea lanes around the continents, labelled edge markers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
63eebfc8bd
commit
216e6f90b8
6 changed files with 555 additions and 301 deletions
|
|
@ -10,14 +10,22 @@ local function check(cond, msg)
|
|||
end
|
||||
end
|
||||
|
||||
-- world rects: top/bottom are world X, left/right world Y
|
||||
-- Map rects from the client's UiMapAssignment.db2. top/bottom are world X, left/right world Y.
|
||||
local RECTS = {
|
||||
[1415] = { inst = 0, top = 4000, bottom = -16000, left = 4000, right = -7000, type = 2 },
|
||||
[1414] = { inst = 1, top = 10000, bottom = -12000, left = 5000, right = -8000, type = 2 },
|
||||
[1437] = { inst = 0, top = -2000, bottom = -4500, left = 0, right = -3000, type = 3 }, -- "Wetlands"
|
||||
[2521] = { inst = 2991, top = 2500, bottom = 0, left = 1500, right = -1500, type = 3 },
|
||||
[1415] = { inst = 0, top = 7467, bottom = -16000, left = 16000, right = -19200, type = 2 },
|
||||
[1414] = { inst = 1, top = 12800, bottom = -11733, left = 17067, right = -19733, type = 2 },
|
||||
[1437] = { inst = 0, top = -1500, bottom = -4800, left = 200, right = -4800, type = 3 }, -- "Wetlands"
|
||||
[2521] = { inst = 2991, top = 4956, bottom = 1248, left = 4231, right = -1331, type = 3 },
|
||||
}
|
||||
local ON_WORLD = { [1415] = { 0.55, 0.95, 0.1, 0.9 }, [1414] = { 0.05, 0.45, 0.1, 0.9 } }
|
||||
-- how each continent's world area sits on the Azeroth map (947): u0, u1, v0, v1, xmin, xmax, ymin, ymax
|
||||
local ON_947 = {
|
||||
[0] = { 0.5505, 0.8966, 0.0994, 0.8691, -16000, 6933, -7467, 8000 },
|
||||
[1] = { 0.0399, 0.4083, 0.0855, 0.9234, -12800, 12267, -9600, 6933 },
|
||||
}
|
||||
local function to947(inst, x, y)
|
||||
local a = ON_947[inst]
|
||||
return a[1] + (a[8] - y) / (a[8] - a[7]) * (a[2] - a[1]), a[3] + (a[6] - x) / (a[6] - a[5]) * (a[4] - a[3])
|
||||
end
|
||||
|
||||
Enum = { UIMapType = { Cosmic = 0, World = 1, Continent = 2, Zone = 3 } }
|
||||
function CreateVector2D(x, y)
|
||||
|
|
@ -35,8 +43,11 @@ C_Map = {
|
|||
return r.inst, CreateVector2D(r.top + (r.bottom - r.top) * v.y, r.left + (r.right - r.left) * v.x)
|
||||
end,
|
||||
GetMapRectOnMap = function(id, top)
|
||||
local r = top == 947 and ON_WORLD[id]
|
||||
if r then return r[1], r[2], r[3], r[4] end
|
||||
local r = RECTS[id]
|
||||
if top ~= 947 or not r or not ON_947[r.inst] then return nil end
|
||||
local u1, v1 = to947(r.inst, r.top, r.left)
|
||||
local u2, v2 = to947(r.inst, r.bottom, r.right)
|
||||
return u1, u2, v1, v2
|
||||
end,
|
||||
GetMapInfoAtPosition = function(id, u, v)
|
||||
return { mapID = id * 10 }
|
||||
|
|
@ -112,6 +123,14 @@ WorldMapFrame = {
|
|||
local pin = CreateFromMixins(ShipRoutesPinMixin)
|
||||
pin.map = self
|
||||
pin.Disc, pin.Ring, pin.Glyph = region(), region(), region()
|
||||
local label = region()
|
||||
function label:GetFont() return "font", 10 end
|
||||
function label:SetFont(_, _, flags) self.flags = flags end
|
||||
function label:ClearAllPoints() self.point = nil end
|
||||
function label:SetPoint(p, _, rp) self.point = { p, rp } end
|
||||
function label:SetJustifyH(j) self.justify = j end
|
||||
function label:SetText(t) self.text = t end
|
||||
pin.Label = label
|
||||
function pin:SetSize(w) self.size = w end
|
||||
function pin:SetPosition(u, v) self.u, self.v = u, v end
|
||||
pin:OnLoad()
|
||||
|
|
@ -147,12 +166,21 @@ check(provider ~= nil, "provider attached to the world map")
|
|||
|
||||
local function find(kind, name)
|
||||
for _, p in ipairs(pins) do
|
||||
if p.kind == kind then
|
||||
local stop = p.route.stops[p.index]
|
||||
if stop[1] == name then return p end
|
||||
if p.kind == kind and kind == "dock" and p.route.stops[p.index][1] == name then
|
||||
return p
|
||||
end
|
||||
if p.kind == kind and kind == "exit" then
|
||||
for _, e in ipairs(p.exits) do
|
||||
if e.route.stops[e.far][1] == name then return p end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function count(kind)
|
||||
local n = 0
|
||||
for _, p in ipairs(pins) do if p.kind == kind then n = n + 1 end end
|
||||
return n
|
||||
end
|
||||
local function visibleLines()
|
||||
local n = 0
|
||||
for _, l in ipairs(allLines) do if l.shown then n = n + 1 end end
|
||||
|
|
@ -163,27 +191,44 @@ end
|
|||
check(#ns.routes == 12, "twelve routes, got " .. #ns.routes)
|
||||
for _, r in ipairs(ns.routes) do
|
||||
check(#r.stops >= 2, "route " .. r.path .. " has two or more stops")
|
||||
for _, p in ipairs(r.parts) do
|
||||
check(#p >= 4 and #p % 2 == 0, "route " .. r.path .. " part has coordinate pairs")
|
||||
check(#r.legs == (#r.stops == 2 and 1 or #r.stops), "route " .. r.path .. " has one leg per stop pair")
|
||||
for _, leg in ipairs(r.legs) do
|
||||
check(#leg >= 6 and #leg % 3 == 0, "route " .. r.path .. " leg has point triples")
|
||||
check(leg[1] == r.stops[leg.from][2] and leg[2] == math.floor(r.stops[leg.from][3] + 0.5) or not leg.smooth,
|
||||
"route " .. r.path .. " lane starts at its dock")
|
||||
end
|
||||
end
|
||||
|
||||
-- projection: EK corner and centre
|
||||
local proj = ns.GetProjector(1415)
|
||||
local u, v = proj(0, 4000, 4000)
|
||||
-- projection: EK map corner and centre, a world map point, and the world map itself
|
||||
local u, v = ns.Project(1415, 0, 7467, 16000)
|
||||
check(math.abs(u) < 1e-9 and math.abs(v) < 1e-9, "top left projects to 0,0")
|
||||
u, v = proj(0, -6000, -1500)
|
||||
u, v = ns.Project(1415, 0, (7467 - 16000) / 2, (16000 - 19200) / 2)
|
||||
check(math.abs(u - 0.5) < 1e-9 and math.abs(v - 0.5) < 1e-9, "centre projects to 0.5,0.5")
|
||||
check(proj(1, 0, 0) == nil, "other instance does not project")
|
||||
local wu, wv = to947(0, -14278, 583)
|
||||
u, v = ns.Project(947, 0, -14278, 583)
|
||||
check(math.abs(u - wu) < 1e-9 and math.abs(v - wv) < 1e-9, "Booty Bay lands where the client puts it on the world map")
|
||||
u, v = ns.Project(1415, -1, wu, wv)
|
||||
local bu, bv = ns.Project(1415, 0, -14278, 583)
|
||||
check(math.abs(u - bu) < 1e-9 and math.abs(v - bv) < 1e-9, "a world map point maps back onto the continent")
|
||||
u = ns.Project(1415, 1, -4016, -4741)
|
||||
check(u and u < 0, "Theramore lies off the west edge of the EK map")
|
||||
check(ns.Project(947, 2991, 1848, 569) == nil, "Zephras Isle has no place on the world map")
|
||||
|
||||
-- Eastern Kingdoms
|
||||
mapID = 1415
|
||||
provider:RefreshAllData()
|
||||
check(find("dock", "Stormwind Harbor") ~= nil, "Stormwind Harbor dock on EK")
|
||||
check(find("dock", "Southshore") ~= nil, "Southshore dock on EK")
|
||||
check(find("dock", "Riverglades") ~= nil, "Riverglades dock on EK")
|
||||
check(find("dock", "Theramore Isle") == nil, "no Kalimdor docks on EK")
|
||||
local exitToTheramore = find("exit", "Theramore Isle")
|
||||
check(exitToTheramore ~= nil, "exit arrow toward Theramore on EK")
|
||||
check(exitToTheramore and exitToTheramore.Glyph.rotation ~= nil, "exit arrow is rotated")
|
||||
local toTheramore = find("exit", "Theramore Isle")
|
||||
check(toTheramore ~= nil, "edge marker toward Theramore on EK")
|
||||
check(toTheramore and toTheramore.Glyph.rotation ~= nil, "edge arrow is rotated")
|
||||
check(toTheramore and toTheramore.u <= 0.03, "Theramore marker sits on the west edge")
|
||||
check(toTheramore and toTheramore.Label.text:find("Theramore Isle", 1, true), "edge marker is labelled")
|
||||
check(toTheramore and toTheramore.Label.point[1] == "LEFT", "west edge label reads inward")
|
||||
check(find("exit", "Zephras Isle") == nil, "no edge marker toward Zephras Isle")
|
||||
check(find("exit", "Grom'gol") == nil, "no edge marker for a route that stays on the map")
|
||||
check(visibleLines() > 50, "route lines drawn on EK, got " .. visibleLines())
|
||||
check(provider.overlay.level == 100, "overlay frame level set")
|
||||
for _, l in ipairs(allLines) do
|
||||
|
|
@ -192,6 +237,9 @@ for _, l in ipairs(allLines) do
|
|||
break
|
||||
end
|
||||
end
|
||||
for _, p in ipairs(pins) do
|
||||
check(p.u >= 0 and p.u <= 1 and p.v >= 0 and p.v <= 1, "pins sit on the map")
|
||||
end
|
||||
|
||||
-- tooltip at Menethil's Southshore pier
|
||||
local menethil
|
||||
|
|
@ -203,7 +251,7 @@ menethil:OnMouseEnter()
|
|||
local tip = table.concat(tipLines, "\n")
|
||||
check(tip:find("Boat to Southshore, then Auberdine", 1, true), "tooltip lists next stops in order:\n" .. tip)
|
||||
check(tip:find("Also from here:", 1, true) and tip:find("Boat to Theramore Isle", 1, true), "tooltip lists the other pier:\n" .. tip)
|
||||
check(provider.highlight == menethil.route, "hover highlights the route")
|
||||
check(provider.highlight and provider.highlight[menethil.route], "hover highlights the route")
|
||||
local dim, bright = 0, 0
|
||||
for _, l in ipairs(allLines) do
|
||||
if l.shown and l.layer == "ARTWORK" then
|
||||
|
|
@ -222,18 +270,41 @@ menethil:OnMouseClickAction("RightButton")
|
|||
check(shownMap == nil, "right click does nothing")
|
||||
check(menethil.passthrough == "RightButton", "right click passes through to the map")
|
||||
|
||||
-- world map: both continents, jump connectors instead of exit arrows
|
||||
-- Kalimdor: the Southshore and Menethil lanes leave the east edge together, Stormwind's apart
|
||||
mapID = 1414
|
||||
provider:RefreshAllData()
|
||||
local lane = find("exit", "Southshore")
|
||||
check(lane ~= nil, "edge marker toward Southshore on Kalimdor")
|
||||
local onLane = {}
|
||||
for _, e in ipairs(lane and lane.exits or {}) do onLane[e.route.stops[e.far][1]] = true end
|
||||
check(onLane["Menethil Harbor"], "Southshore and Menethil lanes share one marker")
|
||||
check(find("exit", "Stormwind Harbor") ~= nil and find("exit", "Stormwind Harbor") ~= lane, "Stormwind lane has its own marker")
|
||||
check(lane and lane.u >= 0.97, "Auberdine lane marker on the east edge")
|
||||
check(lane and lane.Label.point[1] == "RIGHT", "east edge label reads inward")
|
||||
lane:OnMouseEnter()
|
||||
tip = table.concat(tipLines, "\n")
|
||||
check(tip:find("Boat from Southshore", 1, true) and tip:find("Boat to Menethil Harbor", 1, true),
|
||||
"edge tooltip names each lane:\n" .. tip)
|
||||
local lit = 0
|
||||
for r in pairs(provider.highlight or {}) do lit = lit + 1 end
|
||||
check(lit == 2, "hovering the lane lights both routes on it, got " .. lit)
|
||||
lane:OnMouseLeave()
|
||||
lane:OnMouseClickAction("LeftButton")
|
||||
check(shownMap ~= nil, "clicking an edge marker opens a map")
|
||||
|
||||
-- world map: everything on it, nothing to point off-map
|
||||
mapID = 947
|
||||
provider:RefreshAllData()
|
||||
check(find("dock", "Theramore Isle") ~= nil and find("dock", "Menethil Harbor") ~= nil, "both continents on the world map")
|
||||
check(find("exit", "Theramore Isle") == nil, "no exit arrow when the far side shows")
|
||||
check(find("dock", "Zephras Isle") == nil, "Zephras Isle not placed on the mock world map")
|
||||
check(count("exit") == 0, "no edge markers on the world map, got " .. count("exit"))
|
||||
check(find("dock", "Zephras Isle") == nil, "Zephras Isle not on the world map")
|
||||
|
||||
-- zone map: docks outside it are left out
|
||||
-- zone map: docks outside it are left out, its lanes are labelled at the edge
|
||||
mapID = 1437
|
||||
provider:RefreshAllData()
|
||||
check(find("dock", "Menethil Harbor") ~= nil, "Menethil on its zone map")
|
||||
check(find("dock", "Stormwind Harbor") == nil, "Stormwind not on the Wetlands map")
|
||||
check(find("exit", "Theramore Isle") ~= nil and find("exit", "Southshore") ~= nil, "Wetlands edge markers toward Theramore and Southshore")
|
||||
|
||||
-- faction filter
|
||||
faction = "Horde"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue