Merge pull request #908 from argonui/navigation-overlay

Fixed navigation overlay non-playermat cameras
This commit is contained in:
dscarpac 2024-10-12 09:14:36 -05:00 committed by GitHub
commit 027d0ba3c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 40 deletions

View File

@ -449,7 +449,7 @@ function switchSeat(playerColor, direction)
end
-- swap color
navigationOverlayApi.loadCamera(Player[playerColor], usedColors[index])
navigationOverlayApi.loadCamera(Player[playerColor], _, usedColors[index])
end
function takeClueFromLocationWhite(_, hoveredObject)

View File

@ -24,11 +24,13 @@ do
-- loads the specified camera for a player
---@param player tts__Player Player whose camera should be moved
---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to
NavigationOverlayApi.loadCamera = function(player, camera)
---@param index? number Index of the camera view to load
---@param matColor? string Color of the playermat to swap to
NavigationOverlayApi.loadCamera = function(player, index, matColor)
getNOHandler().call("loadCameraFromApi", {
player = player,
camera = camera
index = index,
matColor = matColor
})
end

View File

@ -287,36 +287,19 @@ function getDynamicViewBounds(objList)
end
function loadCameraFromApi(params)
loadCamera(params.player, params.camera)
loadCamera(params.player, params.index, params.matColor)
end
-- loads the specified camera for a player
---@param player tts__Player Player whose camera should be moved
---@param camera number|string If number: Index of the camera view to load | If string: Color of the playermat to swap to
function loadCamera(player, camera)
local lookHere, index, matColor
---@param index? number Index of the camera view to load
---@param matColor? string Color of the playermat to swap to
function loadCamera(player, index, matColor)
-- need at least one of these parameters
if not index and not matColor then return end
local matColorList = { "White", "Orange", "Green", "Red" }
local indexList = {
White = 3,
Orange = 4,
Green = 5,
Red = 6
}
if tonumber(camera) then
index = tonumber(camera)
matColor = matColorList[index - 2] -- mat index 1 - 4
else
index = indexList[camera]
matColor = camera
end
-- if mat is removed, end here
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
if mat == nil then
printToColor("Couldn't find this playermat.", player.color)
return
end
local lookHere
-- dynamic view of the play area
if index == 2 then
@ -330,7 +313,17 @@ function loadCamera(player, camera)
distance = 0.8 * math.max(bounds.diffX, bounds.diffZ) + 7
}
-- dynamic view of the clicked play mat
elseif index >= 3 and index <= 6 then
elseif (index >= 3 and index <= 6) or matColor then
-- maybe get matColor (mat index 1 - 4)
matColor = matColor or matColorList[index - 2]
-- if mat is removed, end here
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
if mat == nil then
printToColor("Couldn't find this playermat.", player.color)
return
end
-- check if anyone (except for yourself) has claimed this color
local isClaimed = false