xml split, code cleanup (WIP)

This commit is contained in:
Chr1Z93 2023-05-06 15:44:30 +02:00
parent 71bd43baf7
commit 3c6d890b16
3 changed files with 272 additions and 378 deletions

View File

@ -22,6 +22,18 @@
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/2021591230456185506/15AF790F0622B57C1F629DB3A8C38F2A99D0EB1B/", "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2021591230456185506/15AF790F0622B57C1F629DB3A8C38F2A99D0EB1B/",
"WidthScale": 0 "WidthScale": 0
}, },
"CustomUIAssets": [
{
"Name": "OverlayLarge",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2021591230441678995/7B413A821136969D8723687A2AD66773B3F8FEED/"
},
{
"Name": "OverlaySmall",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/2021591230447630077/18C86248B9BDAF1DE01B67791439A39EE4F97B60/"
}
],
"Description": "", "Description": "",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",
@ -53,5 +65,5 @@
"scaleZ": 3 "scaleZ": 3
}, },
"Value": 0, "Value": 0,
"XmlUI": "" "XmlUI_path": "OptionPanelSource.830bd0/NavigationOverlayTile.9f2481.xml"
} }

View File

@ -0,0 +1,27 @@
<!-- Defaults -->
<Defaults>
<Panel class="navPanel"
allowDragging="true"
returnToOriginalPositionWhenReleased="false"
rectAlignment="LowerRight"
offsetXY="-40 0">
</Panel>
</Defaults>
<!-- full Panel -->
<Panel id="navPanelFull"
height="358"
width="455"
class="navPanel">
<image id="backgroundImage"
image="OverlayLarge" />
</Panel>
<!-- Play Area only -->
<Panel id="navPanelPlay"
height="208"
width="205"
class="navPanel">
<image id="backgroundImage"
image="OverlaySmall" />
</Panel>

View File

@ -1,107 +1,7 @@
local buttonCount = 20 local playAreaApi = require("core/PlayAreaApi")
local cameraCount = 18 local playmatApi = require("playermat/PlaymatApi")
function onLoad(saved_data) fullButtonData = {
self.createButton({
label = "",
tooltip = "Display full overlay",
click_function = "displayFull",
function_owner = self,
position = { 0.0, 0.1, -0.63 },
height = 70,
width = 700,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Display only play area",
click_function = "displayPlayArea",
function_owner = self,
position = { 0.0, 0.1, -0.39 },
height = 70,
width = 700,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Close overlay",
click_function = "closeOverlay",
function_owner = self,
position = { 0.0, 0.1, -0.16 },
height = 70,
width = 700,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Modify a camera position",
click_function = "beginSetCamera",
function_owner = self,
position = { 0.0, 0.1, 0.19 },
height = 70,
width = 700,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Claim a color (you will switch to this color when clicking in the overlay)",
click_function = "beginClaimColor",
function_owner = self,
position = { -0.22, 0.1, 0.42 },
height = 70,
width = 475,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Reset all color claims",
click_function = "resetClaimColors",
function_owner = self,
position = { 0.48, 0.1, 0.42 },
height = 70,
width = 230,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
self.createButton({
label = "",
tooltip = "Reset camera positions to default",
click_function = "resetCameras",
function_owner = self,
position = { 0.0, 0.1, 0.78 },
height = 70,
width = 700,
scale = { x = 1, y = 1, z = 1 },
color = { 1, 0, 0, 0 }
})
defaultCameraParams = {
{ position = { -1.626, -2.5, 0 }, pitch = 74, yaw = 90, distance = 17.844 }, -- 1. ActAgenda
{ position = { -27.822, -2.5, 0.424 }, pitch = 74, yaw = 90, distance = -1 }, -- 2. Map
{ position = { -31.592, -2.5, 26.392 }, pitch = 74, yaw = 180, distance = -1 }, -- 3. Green playmat
{ position = { -55.026, -2.5, 12.052 }, pitch = 74, yaw = 90, distance = -1 }, -- 4. White playmat
{ position = { -55.026, -2.5, -11.479 }, pitch = 74, yaw = 90, distance = -1 }, -- 5. Orange playmat
{ position = { -31.592, -2.5, -26.392 }, pitch = 74, yaw = 0, distance = -1 }, -- 6. Red playmat
{ position = { -3.029, 1.652, 24.296 }, pitch = 74, yaw = 90, distance = 16 }, -- 7. Victory / SetAside
{ position = { -2.936, 1.552, -26.757 }, pitch = 74, yaw = 90, distance = 16 }, -- 8. Guide
{ position = { -11.833, 1.491, -0.145 }, pitch = 74, yaw = 90, distance = 10 }, -- 9. Player count
{ position = { -48.352, 1.552, -0.055 }, pitch = 74, yaw = 90, distance = 10 }, -- 10. Bless/Curse
{ position = { 12.560, 1.912, 0.458 }, pitch = 74, yaw = 90, distance = 35 }, -- 11. Scenarios
{ position = { 57.835, 1.552, 75.385 }, pitch = 74, yaw = 90, distance = 22 }, -- 12. Player card panel
{ position = { 60.377, 1.552, 55.941 }, pitch = 74, yaw = 90, distance = 10 }, -- 13. Card search panel
{ position = { 27.482, 1.480, 71.057 }, pitch = 74, yaw = 90, distance = 35 }, -- 14. Player card area
{ position = { -19.481, 1.552, 70.880 }, pitch = 74, yaw = 90, distance = 22 }, -- 15. Deck builder
{ position = { -52.918, 1.478, 70.899 }, pitch = 74, yaw = 90, distance = 42 }, -- 16. Rules area
{ position = { 24.551, 2.222, -71.284 }, pitch = 60, yaw = 90, distance = 60 }, -- 17. Cycle area
{ position = { -59.077, 1.462, -85.472 }, pitch = 74, yaw = 90, distance = 27 } -- 18. Additions
}
fullButtonData = {
{ id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda { id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda
{ id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map { id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map
{ id = "3", width = "36", height = "70", offsetX = "-62", offsetY = "-66" }, -- Green { id = "3", width = "36", height = "70", offsetX = "-62", offsetY = "-66" }, -- Green
@ -122,9 +22,9 @@ function onLoad(saved_data)
{ id = "18", width = "56", height = "60", offsetX = "182", offsetY = "-124" }, -- Additions { id = "18", width = "56", height = "60", offsetX = "182", offsetY = "-124" }, -- Additions
{ id = "19", width = "20", height = "20", offsetX = "-8", offsetY = "150" }, -- Shrink { id = "19", width = "20", height = "20", offsetX = "-8", offsetY = "150" }, -- Shrink
{ id = "20", width = "20", height = "20", offsetX = "12", offsetY = "150" } -- Close { id = "20", width = "20", height = "20", offsetX = "12", offsetY = "150" } -- Close
} }
playButtonData = { playButtonData = {
{ id = "1", width = "80", height = "33", offsetX = "0", offsetY = "55" }, { id = "1", width = "80", height = "33", offsetX = "0", offsetY = "55" },
{ id = "2", width = "78", height = "70", offsetX = "0", offsetY = "-8" }, { id = "2", width = "78", height = "70", offsetX = "0", offsetY = "-8" },
{ id = "3", width = "35", height = "66", offsetX = "-65", offsetY = "-10" }, { id = "3", width = "35", height = "66", offsetX = "-65", offsetY = "-10" },
@ -137,9 +37,9 @@ function onLoad(saved_data)
{ id = "10", width = "32", height = "12", offsetX = "0", offsetY = "-48" }, { id = "10", width = "32", height = "12", offsetX = "0", offsetY = "-48" },
{ id = "19", width = "20", height = "20", offsetX = "-10", offsetY = "80" }, { id = "19", width = "20", height = "20", offsetX = "-10", offsetY = "80" },
{ id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" } { id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" }
} }
playermatData = { playermatData = {
{ {
guid = '383d8b', guid = '383d8b',
origin = { x = -25.00, y = 0, z = 26.20 }, origin = { x = -25.00, y = 0, z = 26.20 },
@ -192,37 +92,105 @@ function onLoad(saved_data)
zOffset = -0.06, zOffset = -0.06,
claims = { false, false, false, true } claims = { false, false, false, true }
} }
} }
editing = false defaultCameraParams = {
claiming = false { position = { -1.626, -2.5, 0 }, pitch = 74, yaw = 90, distance = 18 }, -- 1. ActAgenda
selectedEditButton = -1 { position = { -27.822, -2.5, 0.424 }, pitch = 74, yaw = 90, distance = -1 }, -- 2. Map
editPos = { 0, 0, 0 } { position = { -31.592, -2.5, 26.392 }, pitch = 74, yaw = 180, distance = -1 }, -- 3. Green playmat
editPitch = 0 { position = { -55.026, -2.5, 12.052 }, pitch = 74, yaw = 90, distance = -1 }, -- 4. White playmat
editYaw = 0 { position = { -55.026, -2.5, -11.479 }, pitch = 74, yaw = 90, distance = -1 }, -- 5. Orange playmat
editDistance = 0 { position = { -31.592, -2.5, -26.392 }, pitch = 74, yaw = 0, distance = -1 }, -- 6. Red playmat
{ position = { -3.029, 1.652, 24.296 }, pitch = 74, yaw = 90, distance = 16 }, -- 7. Victory / SetAside
{ position = { -2.936, 1.552, -26.757 }, pitch = 74, yaw = 90, distance = 16 }, -- 8. Guide
{ position = { -11.833, 1.491, -0.145 }, pitch = 74, yaw = 90, distance = 10 }, -- 9. Player count
{ position = { -48.352, 1.552, -0.055 }, pitch = 74, yaw = 90, distance = 10 }, -- 10. Bless/Curse
{ position = { 12.560, 1.912, 0.458 }, pitch = 74, yaw = 90, distance = 35 }, -- 11. Scenarios
{ position = { 57.835, 1.552, 75.385 }, pitch = 74, yaw = 90, distance = 22 }, -- 12. Player card panel
{ position = { 60.377, 1.552, 55.941 }, pitch = 74, yaw = 90, distance = 10 }, -- 13. Card search panel
{ position = { 27.482, 1.480, 71.057 }, pitch = 74, yaw = 90, distance = 35 }, -- 14. Player card area
{ position = { -19.481, 1.552, 70.880 }, pitch = 74, yaw = 90, distance = 22 }, -- 15. Deck builder
{ position = { -52.918, 1.478, 70.899 }, pitch = 74, yaw = 90, distance = 42 }, -- 16. Rules area
{ position = { 24.551, 2.222, -71.284 }, pitch = 60, yaw = 90, distance = 60 }, -- 17. Cycle area
{ position = { -59.077, 1.462, -85.472 }, pitch = 74, yaw = 90, distance = 27 } -- 18. Additions
}
if saved_data ~= "" then editing = false
local loaded_data = JSON.decode(saved_data) claiming = false
cameraParams = loaded_data.cameras selectedEditButton = -1
fullVisibility = loaded_data.fullVis editPos = { 0, 0, 0 }
playVisibility = loaded_data.playVis editPitch = 0
editYaw = 0
editDistance = 0
function onLoad(savedData)
local buttonParameters = {}
buttonParameters.function_owner = self
buttonParameters.label = ""
-- index 0: Full Area
buttonParameters.tooltip = "Display full overlay"
buttonParameters.click_function = "displayFull"
buttonParameters.position = { x = 0, y = 0.1, z = -0.63 }
buttonParameters.height = 70
buttonParameters.width = 700
buttonParameters.color = { 1, 0, 0, 0 }
self.createButton(buttonParameters)
-- index 1: Play Area
buttonParameters.tooltip = "Display only play area"
buttonParameters.click_function = "displayPlayArea"
buttonParameters.position = { x = 0, y = 0.1, z = -0.39 }
self.createButton(buttonParameters)
-- index 2: Close Overlay
buttonParameters.tooltip = "Close overlay"
buttonParameters.click_function = "closeOverlay"
buttonParameters.position = { x = 0, y = 0.1, z = -0.16 }
self.createButton(buttonParameters)
-- index 3: Modify Camera
buttonParameters.tooltip = "Modify a camera position"
buttonParameters.click_function = "beginSetCamera"
buttonParameters.position = { x = 0, y = 0.1, z = 0.19 }
self.createButton(buttonParameters)
-- index 4: Claim a color
buttonParameters.tooltip = "Claim a color (you will switch to this color when clicking in the overlay)"
buttonParameters.click_function = "beginClaimColor"
buttonParameters.width = 475
buttonParameters.position = { x = -0.22, y = 0.1, z = 0.42 }
self.createButton(buttonParameters)
-- index 4: Reset color claims
buttonParameters.tooltip = "Reset all color claims"
buttonParameters.click_function = "resetClaimColors"
buttonParameters.width = 230
buttonParameters.position = { x = 0.48, y = 0.1, z = 0.42 }
self.createButton(buttonParameters)
-- index 5: Reset camera positions
buttonParameters.tooltip = "Reset camera positions to default"
buttonParameters.click_function = "resetCameras"
buttonParameters.width = 700
buttonParameters.position = { x = 0, y = 0.1, z = 0.78 }
self.createButton(buttonParameters)
if savedData ~= "" then
local loadedData = JSON.decode(savedData)
cameraParams = loadedData.cameras
fullVisibility = loadedData.fullVis
playVisibility = loadedData.playVis
for i = 1, 4 do for i = 1, 4 do
playermatData[i].claims = loaded_data.claims[i] playermatData[i].claims = loadedData.claims[i]
end end
else else
cameraParams = { {}, {}, {}, {} } cameraParams = { {}, {}, {}, {} }
for cam = 1, 4 do for i = 1, 4 do
cameraParams[cam] = {} for j = 1, #defaultCameraParams do
cameraParams[i][j] = defaultCameraParams[j]
for i = 1, cameraCount do
cameraParams[cam][i] = {}
cameraParams[cam][i].position = defaultCameraParams[i].position
cameraParams[cam][i].pitch = defaultCameraParams[i].pitch
cameraParams[cam][i].yaw = defaultCameraParams[i].yaw
cameraParams[cam][i].distance = defaultCameraParams[i].distance
end end
end end
@ -230,7 +198,7 @@ function onLoad(saved_data)
playVisibility = { false, false, false, false } playVisibility = { false, false, false, false }
end end
resetOverlay() updateOverlay()
end end
function onSave() function onSave()
@ -248,51 +216,35 @@ function onSave()
}) })
end end
function displayFull(object, color) function displayFull(_, color)
local playerCount = getPlayerCount() setVisibility("full", color)
local colors
if playerCount == 0 then
return
elseif playerCount == 1 then
colors = { 1, 2, 3, 4 }
else
colors = { getIndexForPlayerColor(color) }
end
for i, v in ipairs(colors) do
if v > 0 then
fullVisibility[v] = true
playVisibility[v] = false
end
end
resetOverlay()
end end
function displayPlayArea(object, color) function displayPlayArea(_, color)
local playerCount = getPlayerCount() setVisibility("play", color)
local colors end
if playerCount == 0 then function setVisibility(type, color)
return local colors = getColors(color)
elseif playerCount == 1 then local visibility
colors = { 1, 2, 3, 4 }
if type == "full" then
visibility = {full = true, play = false}
else else
colors = { getIndexForPlayerColor(color) } visibility = {full = false, play = true}
end end
for _, v in ipairs(colors) do for _, v in ipairs(colors) do
if v > 0 then if v > 0 then
fullVisibility[v] = false fullVisibility[v] = visibility.full
playVisibility[v] = true playVisibility[v] = visibility.play
end end
end end
resetOverlay() updateOverlay()
end end
function resetCameras(object, color) function getColors(color)
local playerCount = getPlayerCount() local playerCount = getPlayerCount()
local colors local colors
@ -303,6 +255,11 @@ function resetCameras(object, color)
else else
colors = { getIndexForPlayerColor(color) } colors = { getIndexForPlayerColor(color) }
end end
return colors
end
function resetCameras(_, color)
local colors = getColors(color)
for iv, v in ipairs(colors) do for iv, v in ipairs(colors) do
if v > 0 then if v > 0 then
@ -317,19 +274,7 @@ function resetCameras(object, color)
end end
function closeOverlay(object, color) function closeOverlay(object, color)
local playerCount = getPlayerCount() local colors = getColors(color)
local colors
editing = false
claiming = false
if playerCount == 0 then
return
elseif playerCount == 1 then
colors = { 1, 2, 3, 4 }
else
colors = { getIndexForPlayerColor(color) }
end
for _, v in ipairs(colors) do for _, v in ipairs(colors) do
if v > 0 then if v > 0 then
@ -338,20 +283,11 @@ function closeOverlay(object, color)
end end
end end
resetOverlay() updateOverlay()
end end
function resizeOverlay(object, color) function resizeOverlay(object, color)
local playerCount = getPlayerCount() local colors = getColors(color)
local colors
if playerCount == 0 then
return
elseif playerCount == 1 then
colors = { 1, 2, 3, 4 }
else
colors = { getIndexForPlayerColor(color) }
end
for _, v in ipairs(colors) do for _, v in ipairs(colors) do
if v > 0 then if v > 0 then
@ -361,37 +297,12 @@ function resizeOverlay(object, color)
end end
end end
resetOverlay() updateOverlay()
end end
function resetOverlay() function updateOverlay()
local guid = self.getGUID() local color, panel
local color local xml = self.UI.getXml()
local panel
local existingXml = UI.getXml()
local openingXml = ''
-- try to only remove our panels
for p = 1, 2 do
i, j = string.find(existingXml, '<Panel id="navPanel')
if i and i > 1 and string.len(openingXml) == 0 then
openingXml = string.sub(existingXml, 1, i - 1)
end
if i then
local panelXml = string.sub(existingXml, i)
k, m = string.find(panelXml, '</Panel>')
existingXml = string.sub(panelXml, m + 1)
else
break
end
end
local xml = openingXml .. [[
]] .. existingXml
local fullColors = '' local fullColors = ''
local playColors = '' local playColors = ''
@ -418,15 +329,12 @@ function resetOverlay()
end end
if string.len(fullColors) > 0 then if string.len(fullColors) > 0 then
data = fullButtonData -- TODO update visibility
xml = xml .. [[<Panel id="navPanelFull" height="358" width="455" visibility="]] .. fullColors ..
xml = xml ..
[[<Panel id="navPanelFull" height="358" width="455" visibility="]] ..
fullColors ..
[[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0"> [[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0">
<image id="backgroundImage" image="OverlayLarge" />]] <image id="backgroundImage" image="OverlayLarge" />]]
for _, d in ipairs(data) do for _, d in ipairs(fullButtonData) do
local buttonID = tonumber(d.id) local buttonID = tonumber(d.id)
if editing and buttonID < 19 then if editing and buttonID < 19 then
@ -447,27 +355,21 @@ function resetOverlay()
color = "rgba(0,1,0,0)" color = "rgba(0,1,0,0)"
end end
-- TODO button creation
xml = xml .. [[<button xml = xml .. [[<button
onClick="]] .. guid .. [[/buttonClicked" onClick="buttonClicked" id="]] .. d.id .. [["
id="]] .. d.id .. [["
height="]] .. d.height .. [[" height="]] .. d.height .. [["
width="]] .. d.width .. [[" width="]] .. d.width .. [["
offsetXY="]] .. d.offsetX .. " " .. d.offsetY .. [[" offsetXY="]] .. d.offsetX .. " " .. d.offsetY .. [["
color="]] .. color .. [[" color="]] .. color .. [["></button>]]
>
</button>
]]
end end
xml = xml .. [[ </Panel>]]
end end
if string.len(playColors) > 0 then if string.len(playColors) > 0 then
data = playButtonData data = playButtonData
xml = xml .. [[ -- TODO update visibility
<Panel id="navPanelPlay" height="208" width="205" visibility="]] .. xml = xml .. [[<Panel id="navPanelPlay" height="208" width="205" visibility="]] .. playColors ..
playColors ..
[[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0"> [[" allowDragging="true" returnToOriginalPositionWhenReleased="false" rectAlignment="LowerRight" offsetXY="-40 0">
<image id="backgroundImage" image="OverlaySmall" />]] <image id="backgroundImage" image="OverlaySmall" />]]
@ -492,56 +394,19 @@ function resetOverlay()
color = "rgba(0,1,0,0)" color = "rgba(0,1,0,0)"
end end
xml = xml .. [[<button -- TODO button creation
onClick="]] .. guid .. [[/buttonClicked" xml = xml .. [[<button onClick="buttonClicked" id="]] .. d.id .. [["
id="]] .. d.id .. [["
height="]] .. d.height .. [[" height="]] .. d.height .. [["
width="]] .. d.width .. [[" width="]] .. d.width .. [["
offsetXY="]] .. d.offsetX .. " " .. d.offsetY .. [[" offsetXY="]] .. d.offsetX .. " " .. d.offsetY .. [["
color="]] .. color .. [[" color="]] .. color .. [["></button>]]
>
</button>
]]
end end
xml = xml .. [[ </Panel>]] xml = xml .. [[ </Panel>]]
end end
local existingAssets = UI.getCustomAssets()
local largeOverlay = nil
local smallOverlay = nil
for _, v in pairs(existingAssets) do
for _, vv in pairs(v) do
if vv == 'OverlayLarge' then
largeOverlay = v
end
if vv == 'OverlaySmall' then
smallOverlay = v
end
end
end
local largeURL = 'http://cloud-3.steamusercontent.com/ugc/2021591230441678995/7B413A821136969D8723687A2AD66773B3F8FEED/'
local smallURL = 'http://cloud-3.steamusercontent.com/ugc/2021591230447630077/18C86248B9BDAF1DE01B67791439A39EE4F97B60/'
if largeOverlay == nil then
largeOverlay = { name = 'OverlayLarge', url = largeURL }
table.insert(existingAssets, largeOverlay)
else
largeOverlay.url = largeURL
end
if smallOverlay == nil then
smallOverlay = { name = 'OverlaySmall', url = smallURL }
table.insert(existingAssets, smallOverlay)
else
smallOverlay.url = smallURL
end
UI.setXml(xml, existingAssets)
end end
-- handles all button clicks
function buttonClicked(player, _, idValue) function buttonClicked(player, _, idValue)
local buttonID = tonumber(idValue) local buttonID = tonumber(idValue)
@ -558,16 +423,9 @@ function buttonClicked(player, _, idValue)
selectedEditButton = buttonID selectedEditButton = buttonID
else else
if buttonID == selectedEditButton and editDistance > 0 then if buttonID == selectedEditButton and editDistance > 0 then
local playerCount = getPlayerCount() local colors = getColors(color)
local colors
if playerCount == 1 then for _, v in ipairs(colors) do
colors = { 1, 2, 3, 4 }
else
colors = { getIndexForPlayerColor(player.color) }
end
for i, v in ipairs(colors) do
cameraParams[v][selectedEditButton].position = editPos cameraParams[v][selectedEditButton].position = editPos
cameraParams[v][selectedEditButton].pitch = editPitch cameraParams[v][selectedEditButton].pitch = editPitch
cameraParams[v][selectedEditButton].yaw = editYaw cameraParams[v][selectedEditButton].yaw = editYaw
@ -579,7 +437,7 @@ function buttonClicked(player, _, idValue)
selectedEditButton = -1 selectedEditButton = -1
end end
resetOverlay() updateOverlay()
elseif claiming then elseif claiming then
if buttonID >= 3 and buttonID <= 6 then if buttonID >= 3 and buttonID <= 6 then
local colorID = buttonID - 2 local colorID = buttonID - 2
@ -607,7 +465,7 @@ function buttonClicked(player, _, idValue)
end end
claiming = false claiming = false
resetOverlay() updateOverlay()
else else
loadCamera(player, _, idValue) loadCamera(player, _, idValue)
end end
@ -619,7 +477,7 @@ function loadCamera(player, _, idValue)
local playerIndex = getIndexForPlayerColor(playerColor) local playerIndex = getIndexForPlayerColor(playerColor)
-- only do map zooming if the camera hasn't been specially set by user -- only do map zooming if the camera hasn't been specially set by user
if index == 2 and cameraParams[playerIndex][index].distance <= 0.0 then if index == 2 and cameraParams[playerIndex][index].distance <= 0 then
local mapObjects = Physics.cast({ local mapObjects = Physics.cast({
origin = { x = -29.2, y = 0, z = 0.0 }, origin = { x = -29.2, y = 0, z = 0.0 },
direction = { x = 0, y = 1, z = 0 }, direction = { x = 0, y = 1, z = 0 },
@ -683,7 +541,7 @@ function loadCamera(player, _, idValue)
end end
end end
if cameraParams[newMatIndex][index].distance <= 0.0 then if cameraParams[newMatIndex][index].distance <= 0 then
local matObjects = Physics.cast({ local matObjects = Physics.cast({
origin = playermatData[newMatIndex].origin, origin = playermatData[newMatIndex].origin,
direction = { x = 0, y = 1, z = 0 }, direction = { x = 0, y = 1, z = 0 },
@ -737,13 +595,10 @@ function loadCamera(player, _, idValue)
local d = 0.64 * scale + 7 local d = 0.64 * scale + 7
-- need to wait if the player color changed -- need to wait if the player color changed
Wait.frames(function() Wait.frames(
player.lookAt({ position = { centerX, 0, centerZ }, pitch = 75.823, yaw = yaw, distance = d }) function() player.lookAt({ position = { centerX, 0, centerZ }, pitch = 75.823, yaw = yaw, distance = d }) end, 2)
end, 2)
else else
Wait.frames(function() Wait.frames(function() player.lookAt(cameraParams[newMatIndex][index]) end, 2)
player.lookAt(cameraParams[newMatIndex][index])
end, 2)
end end
else else
player.lookAt(cameraParams[playerIndex][index]) player.lookAt(cameraParams[playerIndex][index])
@ -758,7 +613,7 @@ function beginSetCamera(object, color)
end end
editing = true editing = true
resetOverlay() updateOverlay()
end end
function updateEditCamera(params) function updateEditCamera(params)
@ -776,7 +631,7 @@ function beginClaimColor(object, color)
end end
claiming = true claiming = true
resetOverlay() updateOverlay()
end end
function resetClaimColors(object, color) function resetClaimColors(object, color)