addition of edit button to set pitch
This commit is contained in:
parent
2297ea294d
commit
caa273e7e1
@ -37,12 +37,12 @@
|
||||
{
|
||||
"Name": "OverlayLarge",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2021591230441678995/7B413A821136969D8723687A2AD66773B3F8FEED/"
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2038486957000838167/1EF958D11A228817099C310F97817F61F84DDD91/"
|
||||
},
|
||||
{
|
||||
"Name": "OverlaySmall",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2021591230447630077/18C86248B9BDAF1DE01B67791439A39EE4F97B60/"
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2038486957000850722/37F0D4848BA08788F79DB2D3FB6D11429CB1F861/"
|
||||
},
|
||||
{
|
||||
"Name": "NavigationOverlayIcon",
|
||||
|
@ -1,29 +1,30 @@
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
fullButtonData = {
|
||||
{ id = "1", width = "84", height = "33", offset = "1 2" }, -- Act/Agenda
|
||||
{ id = "2", width = "78", height = "69", offset = "1 -62" }, -- Map
|
||||
{ id = "3", width = "70", height = "36", offset = "-38 -126" }, -- White
|
||||
{ id = "4", width = "70", height = "36", offset = "38 -126" }, -- Orange
|
||||
{ id = "5", width = "36", height = "70", offset = "-63 -66" }, -- Green
|
||||
{ id = "6", width = "36", height = "70", offset = "63 -66" }, -- Red
|
||||
{ id = "7", width = "38", height = "38", offset = "-65 -3" }, -- Victory
|
||||
{ id = "8", width = "40", height = "40", offset = "65 -3" }, -- Guide
|
||||
{ id = "9", width = "56", height = "16", offset = "1 -20" }, -- Player count
|
||||
{ id = "10", width = "36", height = "16", offset = "1 -102" }, -- Bless/Curse
|
||||
{ id = "11", width = "168", height = "56", offset = "1 47" }, -- Scenarios
|
||||
{ id = "12", width = "52", height = "53", offset = "-154 134" }, -- Player card panel
|
||||
{ id = "13", width = "22", height = "22", offset = "-116 132" }, -- Search card panel
|
||||
{ id = "14", width = "120", height = "75", offset = "-152 70" }, -- Player card display
|
||||
{ id = "15", width = "40", height = "54", offset = "-150 -38" }, -- Deck builder
|
||||
{ id = "16", width = "104", height = "84", offset = "-154 -114" }, -- Rules area
|
||||
{ id = "17", width = "100", height = "170", offset = "152 72" }, -- Cycle area
|
||||
{ id = "18", width = "56", height = "60", offset = "182 -124" }, -- Additions
|
||||
{ id = "19", width = "20", height = "20", offset = "-8 150" }, -- Shrink
|
||||
{ id = "20", width = "20", height = "20", offset = "12 150" } -- Close
|
||||
fullButtonData = {
|
||||
{ id = "1", width = "84", height = "33", offset = "1 2" }, -- 1. Act/Agenda
|
||||
{ id = "2", width = "78", height = "69", offset = "1 -62" }, -- 2. Map
|
||||
{ id = "3", width = "70", height = "36", offset = "-38 -126" }, -- 3. White
|
||||
{ id = "4", width = "70", height = "36", offset = "38 -126" }, -- 4. Orange
|
||||
{ id = "5", width = "36", height = "70", offset = "-63 -66" }, -- 5. Green
|
||||
{ id = "6", width = "36", height = "70", offset = "63 -66" }, -- 6. Red
|
||||
{ id = "7", width = "38", height = "38", offset = "-65 -3" }, -- 7. Victory
|
||||
{ id = "8", width = "40", height = "40", offset = "65 -3" }, -- 8. Guide
|
||||
{ id = "9", width = "56", height = "16", offset = "1 -20" }, -- 9. Player count
|
||||
{ id = "10", width = "36", height = "16", offset = "1 -102" }, -- 10. Bless/Curse
|
||||
{ id = "11", width = "168", height = "56", offset = "1 47" }, -- 11. Scenarios
|
||||
{ id = "12", width = "52", height = "53", offset = "-154 134" }, -- 12. Player card panel
|
||||
{ id = "13", width = "22", height = "22", offset = "-116 132" }, -- 13. Search card panel
|
||||
{ id = "14", width = "120", height = "75", offset = "-152 70" }, -- 14. Player card display
|
||||
{ id = "15", width = "40", height = "54", offset = "-150 -38" }, -- 15. Deck builder
|
||||
{ id = "16", width = "104", height = "84", offset = "-154 -114" }, -- 16. Rules area
|
||||
{ id = "17", width = "100", height = "170", offset = "152 72" }, -- 17. Cycle area
|
||||
{ id = "18", width = "56", height = "60", offset = "182 -124" }, -- 18. Additions
|
||||
{ id = "19", width = "20", height = "20", offset = "0 150" }, -- 19. Shrink
|
||||
{ id = "20", width = "20", height = "20", offset = "20 150" }, -- 20. Close
|
||||
{ id = "21", width = "20", height = "20", offset = "-20 150" } -- 21. Settings
|
||||
}
|
||||
|
||||
playButtonData = {
|
||||
playButtonData = {
|
||||
{ id = "1", width = "80", height = "33", offset = "0 55" },
|
||||
{ id = "2", width = "78", height = "70", offset = "0 -8" },
|
||||
{ id = "3", width = "68", height = "32", offset = "-36 -71" },
|
||||
@ -34,12 +35,13 @@ playButtonData = {
|
||||
{ id = "8", width = "38", height = "38", offset = "66 52" },
|
||||
{ id = "9", width = "50", height = "12", offset = "0 33" },
|
||||
{ id = "10", width = "32", height = "12", offset = "0 -48" },
|
||||
{ id = "19", width = "20", height = "20", offset = "-10 80" },
|
||||
{ id = "20", width = "20", height = "20", offset = "10 80" }
|
||||
{ id = "19", width = "20", height = "20", offset = "0 80" },
|
||||
{ id = "20", width = "20", height = "20", offset = "20 80" },
|
||||
{ id = "21", width = "20", height = "20", offset = "-20 80" }
|
||||
}
|
||||
|
||||
defaultCameraData = {
|
||||
{ position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. ActAgenda
|
||||
cameraData = {
|
||||
{ position = { -1.6, 1.55, 0 }, distance = 18 }, -- 1. Act/Agenda
|
||||
{ position = { -28, 1.55, 0 }, distance = -1 }, -- 2. Map
|
||||
{ position = { -31.6, 1.55, 26.4 }, distance = -1 }, -- 3. Green playmat
|
||||
{ position = { -55, 1.55, 12.05 }, distance = -1 }, -- 4. White playmat
|
||||
@ -59,11 +61,9 @@ defaultCameraData = {
|
||||
{ position = { -59.08, 1.55, -83 }, distance = 27 } -- 18. Additions
|
||||
}
|
||||
|
||||
local editing = false
|
||||
local claiming = false
|
||||
local cameraData = {}
|
||||
local visibility = {}
|
||||
local claims = {}
|
||||
local visibility = {}
|
||||
local claims = {}
|
||||
local pitch = {}
|
||||
|
||||
---------------------------------------------------------
|
||||
-- save/load functionality
|
||||
@ -71,25 +71,28 @@ local claims = {}
|
||||
|
||||
function onSave()
|
||||
return JSON.encode({
|
||||
cameras = cameraData,
|
||||
visibility = visibility,
|
||||
claims = claims
|
||||
claims = claims,
|
||||
pitch = pitch
|
||||
})
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData ~= "" then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
cameraData = loadedData.cameras
|
||||
visibility = loadedData.visibility
|
||||
claims = loadedData.claims
|
||||
pitch = loadedData.pitch
|
||||
else
|
||||
resetCameras()
|
||||
resetClaimColors()
|
||||
resetVisibility()
|
||||
|
||||
-- default state for visibility
|
||||
for _, color in ipairs(Player.getColors()) do
|
||||
visibility[color] = { full = false, play = false }
|
||||
end
|
||||
end
|
||||
|
||||
updateXmlButtons()
|
||||
createXmlButtons()
|
||||
updateVisibility()
|
||||
end
|
||||
|
||||
@ -132,7 +135,7 @@ end
|
||||
|
||||
-- update XML visibility
|
||||
function updateVisibility()
|
||||
local colorString = {full = "", play = ""}
|
||||
local colorString = { full = "", play = "" }
|
||||
|
||||
for color, v in pairs(visibility) do
|
||||
if v.full then
|
||||
@ -158,17 +161,17 @@ function updateVisibility()
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- XML creating/editing
|
||||
-- XML button creation
|
||||
---------------------------------------------------------
|
||||
|
||||
function updateXmlButtons()
|
||||
function createXmlButtons()
|
||||
local ui = UI.getXmlTable()
|
||||
ui = updateXmlButtonHelper(ui, {
|
||||
ui = createXmlButtonHelper(ui, {
|
||||
data = fullButtonData,
|
||||
id = "navPanelFull",
|
||||
overlay = "OverlayLarge"
|
||||
})
|
||||
ui = updateXmlButtonHelper(ui, {
|
||||
ui = createXmlButtonHelper(ui, {
|
||||
data = playButtonData,
|
||||
id = "navPanelPlay",
|
||||
overlay = "OverlaySmall"
|
||||
@ -177,7 +180,7 @@ function updateXmlButtons()
|
||||
end
|
||||
|
||||
-- XML button creation
|
||||
function updateXmlButtonHelper(ui, params)
|
||||
function createXmlButtonHelper(ui, params)
|
||||
local color
|
||||
local guid = self.getGUID()
|
||||
local xml = findTagWithId(ui, params.id)
|
||||
@ -193,26 +196,6 @@ function updateXmlButtonHelper(ui, params)
|
||||
|
||||
-- add all buttons
|
||||
for _, d in ipairs(params.data) do
|
||||
local buttonID = tonumber(d.id)
|
||||
|
||||
if editing and buttonID < 19 then
|
||||
if selectedEditButton < 0 then
|
||||
color = "rgba(1,1,1,1)"
|
||||
elseif buttonID == selectedEditButton then
|
||||
color = "rgba(0,1,0,1)"
|
||||
else
|
||||
color = "rgba(1,0,0,1)"
|
||||
end
|
||||
elseif claiming and buttonID < 19 then
|
||||
if buttonID >= 3 and buttonID <= 6 then
|
||||
color = "rgba(1,1,1,1)"
|
||||
else
|
||||
color = "rgba(1,0,0,1)"
|
||||
end
|
||||
else
|
||||
color = "rgba(0,1,0,0)"
|
||||
end
|
||||
|
||||
table.insert(xml.children, {
|
||||
tag = "button",
|
||||
attributes = {
|
||||
@ -221,7 +204,7 @@ function updateXmlButtonHelper(ui, params)
|
||||
height = d.height,
|
||||
width = d.width,
|
||||
offsetXY = d.offset,
|
||||
color = color
|
||||
color = "rgba(0,1,0,0)"
|
||||
}
|
||||
})
|
||||
end
|
||||
@ -249,15 +232,22 @@ function buttonClicked(player, _, idValue)
|
||||
|
||||
if index == 19 then
|
||||
setVisibility("toggle", player.color)
|
||||
return
|
||||
elseif index == 20 then
|
||||
setVisibility("close", player.color)
|
||||
return
|
||||
elseif index == 21 then
|
||||
player.showInputDialog("Please enter your desired viewing angle in degrees (90 = bird's-eye view):", "75", updatePitch)
|
||||
else
|
||||
loadCamera(player, _, index)
|
||||
end
|
||||
|
||||
loadCamera(player, _, index)
|
||||
end
|
||||
|
||||
function updatePitch(input, playerColor)
|
||||
local number = tonumber(input) or 75
|
||||
if number > 90 then number = 90 end
|
||||
pitch[playerColor] = number
|
||||
end
|
||||
|
||||
-- generates a table with rectangular bounds for provided objects
|
||||
function getDynamicViewBounds(objList)
|
||||
local count = 0
|
||||
local totalBounds = {
|
||||
@ -267,7 +257,7 @@ function getDynamicViewBounds(objList)
|
||||
maxZ = -60
|
||||
}
|
||||
|
||||
for i, obj in pairs(objList) do
|
||||
for _, obj in pairs(objList) do
|
||||
-- handling for Physics.cast() results
|
||||
if not obj.type then obj = obj.hit_object end
|
||||
|
||||
@ -302,85 +292,56 @@ function getDynamicViewBounds(objList)
|
||||
return totalBounds
|
||||
end
|
||||
|
||||
-- loads the specified camera for a player
|
||||
function loadCamera(player, _, index)
|
||||
local lookHere
|
||||
|
||||
-- only do map zooming if the camera hasn't been specially set by user
|
||||
if index == 2 and cameraData[player.color][index].distance <= 0 then
|
||||
-- dynamic view of the play area
|
||||
if index == 2 then
|
||||
local bounds = getDynamicViewBounds(getObjectFromGUID("a2f932").getObjects())
|
||||
|
||||
lookHere = {
|
||||
position = { bounds.middleX, 1.55, bounds.middleZ },
|
||||
pitch = 75,
|
||||
yaw = 90,
|
||||
distance = 0.8 * math.max(bounds.diffX, bounds.diffZ) + 7
|
||||
}
|
||||
-- dynamic view of the clicked play mat
|
||||
elseif index >= 3 and index <= 6 then
|
||||
local matColorList = { "White", "Orange", "Green", "Red" }
|
||||
local matColor = matColorList[index - 2] -- mat index 1 - 4
|
||||
|
||||
if #getSeatedPlayers() == 1 or claims[player.color][matColor] then
|
||||
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
||||
copyVisibility({startColor = player.color, targetColor = newPlayerColor})
|
||||
copyVisibility({ startColor = player.color, targetColor = newPlayerColor })
|
||||
player.changeColor(newPlayerColor)
|
||||
end
|
||||
|
||||
if cameraData[player.color][index].distance <= 0 then
|
||||
local bounds = getDynamicViewBounds(playmatApi.searchPlaymat(matColor))
|
||||
local bounds = getDynamicViewBounds(playmatApi.searchPlaymat(matColor))
|
||||
|
||||
lookHere = {
|
||||
position = { bounds.middleX, 0, bounds.middleZ },
|
||||
pitch = 75,
|
||||
yaw = playmatApi.returnRotation(matColor).y + 180,
|
||||
distance = 0.42 * math.max(bounds.diffX, bounds.diffZ) + 7
|
||||
}
|
||||
end
|
||||
lookHere = {
|
||||
position = { bounds.middleX, 0, bounds.middleZ },
|
||||
yaw = playmatApi.returnRotation(matColor).y + 180,
|
||||
distance = 0.42 * math.max(bounds.diffX, bounds.diffZ) + 7
|
||||
}
|
||||
end
|
||||
|
||||
-- get default data if no dynamic view (play area or play mat) was loaded
|
||||
if not lookHere then
|
||||
lookHere = cameraData[index]
|
||||
lookHere.yaw = 90
|
||||
end
|
||||
|
||||
-- set pitch to default if not edited
|
||||
lookHere.pitch = pitch[player.color] or 75
|
||||
|
||||
-- delay is to account for colorswap
|
||||
Wait.frames(function() player.lookAt(lookHere or cameraData[player.color][index]) end, 2)
|
||||
end
|
||||
|
||||
function beginClaimColor()
|
||||
claiming = true
|
||||
updateXmlButtons()
|
||||
end
|
||||
|
||||
function beginSetCamera()
|
||||
editing = true
|
||||
updateXmlButtons()
|
||||
end
|
||||
|
||||
-- TO-DO: update this
|
||||
editPos = { 0, 0, 0 }
|
||||
editPitch = 0
|
||||
editYaw = 0
|
||||
editDistance = 0
|
||||
selectedEditButton = -1
|
||||
|
||||
function updateEditCamera(params)
|
||||
editPos = params[1]
|
||||
editPitch = params[2]
|
||||
editYaw = params[3]
|
||||
editDistance = params[4]
|
||||
Wait.frames(function() player.lookAt(lookHere) end, 2)
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- functions to reset/initialize tables
|
||||
---------------------------------------------------------
|
||||
|
||||
function resetCameras()
|
||||
for _, color in ipairs(Player.getColors()) do
|
||||
cameraData[color] = {}
|
||||
for i = 1, #defaultCameraData do
|
||||
cameraData[color][i] = {}
|
||||
cameraData[color][i].yaw = 90
|
||||
cameraData[color][i].pitch = 75
|
||||
cameraData[color][i].position = defaultCameraData[i].position
|
||||
cameraData[color][i].distance = defaultCameraData[i].distance
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function resetClaimColors()
|
||||
for _, seatedColor in ipairs(getSeatedPlayers()) do
|
||||
claims[seatedColor] = {}
|
||||
@ -389,9 +350,3 @@ function resetClaimColors()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function resetVisibility()
|
||||
for _, color in ipairs(Player.getColors()) do
|
||||
visibility[color] = { full = false, play = false }
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user