diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json index d24fb331..9e9f215a 100644 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json +++ b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json @@ -22,6 +22,18 @@ "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2021591230456185506/15AF790F0622B57C1F629DB3A8C38F2A99D0EB1B/", "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": "", "DragSelectable": true, "GMNotes": "", @@ -53,5 +65,5 @@ "scaleZ": 3 }, "Value": 0, - "XmlUI": "" + "XmlUI_path": "OptionPanelSource.830bd0/NavigationOverlayTile.9f2481.xml" } \ No newline at end of file diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.xml b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.xml new file mode 100644 index 00000000..888892be --- /dev/null +++ b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/src/accessories/NavigationOverlay.ttslua b/src/accessories/NavigationOverlay.ttslua index c3e50f27..67bbd906 100644 --- a/src/accessories/NavigationOverlay.ttslua +++ b/src/accessories/NavigationOverlay.ttslua @@ -1,228 +1,196 @@ -local buttonCount = 20 -local cameraCount = 18 +local playAreaApi = require("core/PlayAreaApi") +local playmatApi = require("playermat/PlaymatApi") -function onLoad(saved_data) - 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 } - }) +fullButtonData = { + { id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda + { id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map + { id = "3", width = "36", height = "70", offsetX = "-62", offsetY = "-66" }, -- Green + { id = "4", width = "70", height = "36", offsetX = "-36", offsetY = "-126" }, -- White + { id = "5", width = "70", height = "36", offsetX = "39", offsetY = "-126" }, -- Orange + { id = "6", width = "36", height = "70", offsetX = "64", offsetY = "-66" }, -- Red + { id = "7", width = "38", height = "38", offsetX = "-64", offsetY = "-3" }, -- Victory + { id = "8", width = "40", height = "40", offsetX = "66", offsetY = "-3" }, -- Guide + { id = "9", width = "56", height = "16", offsetX = "1", offsetY = "-20" }, -- Player count + { id = "10", width = "36", height = "16", offsetX = "1", offsetY = "-102" }, -- Bless/Curse + { id = "11", width = "168", height = "56", offsetX = "1", offsetY = "47" }, -- Scenarios + { id = "12", width = "52", height = "53", offsetX = "-154", offsetY = "134" }, -- Player card panel + { id = "13", width = "22", height = "22", offsetX = "-116", offsetY = "132" }, -- Search card panel + { id = "14", width = "120", height = "75", offsetX = "-152", offsetY = "70" }, -- Player card display + { id = "15", width = "40", height = "54", offsetX = "-150", offsetY = "-38" }, -- Deck builder + { id = "16", width = "104", height = "84", offsetX = "-154", offsetY = "-114" }, -- Rules area + { id = "17", width = "100", height = "170", offsetX = "152", offsetY = "72" }, -- Cycle area + { id = "18", width = "56", height = "60", offsetX = "182", offsetY = "-124" }, -- Additions + { id = "19", width = "20", height = "20", offsetX = "-8", offsetY = "150" }, -- Shrink + { id = "20", width = "20", height = "20", offsetX = "12", offsetY = "150" } -- Close +} - 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 +playButtonData = { + { id = "1", width = "80", height = "33", offsetX = "0", offsetY = "55" }, + { id = "2", width = "78", height = "70", offsetX = "0", offsetY = "-8" }, + { id = "3", width = "35", height = "66", offsetX = "-65", offsetY = "-10" }, + { id = "4", width = "68", height = "32", offsetX = "-36", offsetY = "-71" }, + { id = "5", width = "68", height = "32", offsetX = "36", offsetY = "-71" }, + { id = "6", width = "35", height = "66", offsetX = "65", offsetY = "-10" }, + { id = "7", width = "38", height = "38", offsetX = "-66", offsetY = "52" }, + { id = "8", width = "38", height = "38", offsetX = "66", offsetY = "52" }, + { id = "9", width = "50", height = "12", offsetX = "0", offsetY = "33" }, + { id = "10", width = "32", height = "12", offsetX = "0", offsetY = "-48" }, + { id = "19", width = "20", height = "20", offsetX = "-10", offsetY = "80" }, + { id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" } +} + +playermatData = { + { + guid = '383d8b', + origin = { x = -25.00, y = 0, z = 26.20 }, + scale = { x = 31.5, y = 5.10, z = 14.59 }, + orientation = { x = 0, y = 0, z = 0 }, + minX = -44.43, + maxX = -17.44, + minZ = 20.17, + maxZ = 32.97, + xOffset = -0.07, + zOffset = 0.00, + claims = { true, false, false, false } + }, + { + guid = '8b081b', + origin = { x = -54.42, y = 0, z = 20.96 }, + scale = { x = 36.63, y = 5.10, z = 14.59 }, + orientation = { x = 0, y = 270, z = 0 }, + minX = -61.4, + maxX = -48.6, + minZ = -2.39, + maxZ = 24.53, + xOffset = 0.07, + zOffset = 0.03, + claims = { false, true, false, false } + }, + { + guid = 'bd0ff4', + origin = { x = -54.42, y = 0, z = -20.96 }, + scale = { x = 36.63, y = 5.10, z = 14.59 }, + orientation = { x = 0, y = 270, z = 0 }, + minX = -61.4, + maxX = -48.6, + minZ = -24.53, + maxZ = 2.39, + xOffset = 0.07, + zOffset = 0.02, + claims = { false, false, true, false } + }, + { + guid = '0840d5', + origin = { x = -25.00, y = 0, z = -26.60 }, + scale = { x = 31.5, y = 5.10, z = 14.59 }, + orientation = { x = 0, y = 180, z = 0 }, + minX = -44.43, + maxX = -17.44, + minZ = -32.97, + maxZ = -20.17, + xOffset = 0.07, + zOffset = -0.06, + claims = { false, false, false, true } } +} - fullButtonData = { - { id = "1", width = "84", height = "33", offsetX = "1", offsetY = "2" }, -- Act/Agenda - { id = "2", width = "78", height = "69", offsetX = "1", offsetY = "-62" }, -- Map - { id = "3", width = "36", height = "70", offsetX = "-62", offsetY = "-66" }, -- Green - { id = "4", width = "70", height = "36", offsetX = "-36", offsetY = "-126" }, -- White - { id = "5", width = "70", height = "36", offsetX = "39", offsetY = "-126" }, -- Orange - { id = "6", width = "36", height = "70", offsetX = "64", offsetY = "-66" }, -- Red - { id = "7", width = "38", height = "38", offsetX = "-64", offsetY = "-3" }, -- Victory - { id = "8", width = "40", height = "40", offsetX = "66", offsetY = "-3" }, -- Guide - { id = "9", width = "56", height = "16", offsetX = "1", offsetY = "-20" }, -- Player count - { id = "10", width = "36", height = "16", offsetX = "1", offsetY = "-102" }, -- Bless/Curse - { id = "11", width = "168", height = "56", offsetX = "1", offsetY = "47" }, -- Scenarios - { id = "12", width = "52", height = "53", offsetX = "-154", offsetY = "134" }, -- Player card panel - { id = "13", width = "22", height = "22", offsetX = "-116", offsetY = "132" }, -- Search card panel - { id = "14", width = "120", height = "75", offsetX = "-152", offsetY = "70" }, -- Player card display - { id = "15", width = "40", height = "54", offsetX = "-150", offsetY = "-38" }, -- Deck builder - { id = "16", width = "104", height = "84", offsetX = "-154", offsetY = "-114" }, -- Rules area - { id = "17", width = "100", height = "170", offsetX = "152", offsetY = "72" }, -- Cycle area - { id = "18", width = "56", height = "60", offsetX = "182", offsetY = "-124" }, -- Additions - { id = "19", width = "20", height = "20", offsetX = "-8", offsetY = "150" }, -- Shrink - { id = "20", width = "20", height = "20", offsetX = "12", offsetY = "150" } -- Close - } +defaultCameraParams = { + { position = { -1.626, -2.5, 0 }, pitch = 74, yaw = 90, distance = 18 }, -- 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 +} - playButtonData = { - { id = "1", width = "80", height = "33", offsetX = "0", offsetY = "55" }, - { id = "2", width = "78", height = "70", offsetX = "0", offsetY = "-8" }, - { id = "3", width = "35", height = "66", offsetX = "-65", offsetY = "-10" }, - { id = "4", width = "68", height = "32", offsetX = "-36", offsetY = "-71" }, - { id = "5", width = "68", height = "32", offsetX = "36", offsetY = "-71" }, - { id = "6", width = "35", height = "66", offsetX = "65", offsetY = "-10" }, - { id = "7", width = "38", height = "38", offsetX = "-66", offsetY = "52" }, - { id = "8", width = "38", height = "38", offsetX = "66", offsetY = "52" }, - { id = "9", width = "50", height = "12", offsetX = "0", offsetY = "33" }, - { id = "10", width = "32", height = "12", offsetX = "0", offsetY = "-48" }, - { id = "19", width = "20", height = "20", offsetX = "-10", offsetY = "80" }, - { id = "20", width = "20", height = "20", offsetX = "10", offsetY = "80" } - } +editing = false +claiming = false +selectedEditButton = -1 +editPos = { 0, 0, 0 } +editPitch = 0 +editYaw = 0 +editDistance = 0 - playermatData = { - { - guid = '383d8b', - origin = { x = -25.00, y = 0, z = 26.20 }, - scale = { x = 31.5, y = 5.10, z = 14.59 }, - orientation = { x = 0, y = 0, z = 0 }, - minX = -44.43, - maxX = -17.44, - minZ = 20.17, - maxZ = 32.97, - xOffset = -0.07, - zOffset = 0.00, - claims = { true, false, false, false } - }, - { - guid = '8b081b', - origin = { x = -54.42, y = 0, z = 20.96 }, - scale = { x = 36.63, y = 5.10, z = 14.59 }, - orientation = { x = 0, y = 270, z = 0 }, - minX = -61.4, - maxX = -48.6, - minZ = -2.39, - maxZ = 24.53, - xOffset = 0.07, - zOffset = 0.03, - claims = { false, true, false, false } - }, - { - guid = 'bd0ff4', - origin = { x = -54.42, y = 0, z = -20.96 }, - scale = { x = 36.63, y = 5.10, z = 14.59 }, - orientation = { x = 0, y = 270, z = 0 }, - minX = -61.4, - maxX = -48.6, - minZ = -24.53, - maxZ = 2.39, - xOffset = 0.07, - zOffset = 0.02, - claims = { false, false, true, false } - }, - { - guid = '0840d5', - origin = { x = -25.00, y = 0, z = -26.60 }, - scale = { x = 31.5, y = 5.10, z = 14.59 }, - orientation = { x = 0, y = 180, z = 0 }, - minX = -44.43, - maxX = -17.44, - minZ = -32.97, - maxZ = -20.17, - xOffset = 0.07, - zOffset = -0.06, - claims = { false, false, false, true } - } - } +function onLoad(savedData) + local buttonParameters = {} + buttonParameters.function_owner = self + buttonParameters.label = "" - editing = false - claiming = false - selectedEditButton = -1 - editPos = { 0, 0, 0 } - editPitch = 0 - editYaw = 0 - editDistance = 0 + -- 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) - if saved_data ~= "" then - local loaded_data = JSON.decode(saved_data) - cameraParams = loaded_data.cameras - fullVisibility = loaded_data.fullVis - playVisibility = loaded_data.playVis + -- 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 - playermatData[i].claims = loaded_data.claims[i] + playermatData[i].claims = loadedData.claims[i] end else cameraParams = { {}, {}, {}, {} } - for cam = 1, 4 do - cameraParams[cam] = {} - - 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 + for i = 1, 4 do + for j = 1, #defaultCameraParams do + cameraParams[i][j] = defaultCameraParams[j] end end @@ -230,7 +198,7 @@ function onLoad(saved_data) playVisibility = { false, false, false, false } end - resetOverlay() + updateOverlay() end function onSave() @@ -244,55 +212,39 @@ function onSave() cameras = cameraParams, fullVis = fullVisibility, playVis = playVisibility, - claims = allclaims + claims = allclaims }) end -function displayFull(object, color) - local playerCount = getPlayerCount() - 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() +function displayFull(_, color) + setVisibility("full", color) end -function displayPlayArea(object, color) - local playerCount = getPlayerCount() - local colors +function displayPlayArea(_, color) + setVisibility("play", color) +end - if playerCount == 0 then - return - elseif playerCount == 1 then - colors = { 1, 2, 3, 4 } +function setVisibility(type, color) + local colors = getColors(color) + local visibility + + if type == "full" then + visibility = {full = true, play = false} else - colors = { getIndexForPlayerColor(color) } + visibility = {full = false, play = true} end for _, v in ipairs(colors) do if v > 0 then - fullVisibility[v] = false - playVisibility[v] = true + fullVisibility[v] = visibility.full + playVisibility[v] = visibility.play end end - resetOverlay() + updateOverlay() end -function resetCameras(object, color) +function getColors(color) local playerCount = getPlayerCount() local colors @@ -303,6 +255,11 @@ function resetCameras(object, color) else colors = { getIndexForPlayerColor(color) } end + return colors +end + +function resetCameras(_, color) + local colors = getColors(color) for iv, v in ipairs(colors) do if v > 0 then @@ -317,19 +274,7 @@ function resetCameras(object, color) end function closeOverlay(object, color) - local playerCount = getPlayerCount() - 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 + local colors = getColors(color) for _, v in ipairs(colors) do if v > 0 then @@ -338,20 +283,11 @@ function closeOverlay(object, color) end end - resetOverlay() + updateOverlay() end function resizeOverlay(object, color) - local playerCount = getPlayerCount() - local colors - - if playerCount == 0 then - return - elseif playerCount == 1 then - colors = { 1, 2, 3, 4 } - else - colors = { getIndexForPlayerColor(color) } - end + local colors = getColors(color) for _, v in ipairs(colors) do if v > 0 then @@ -361,37 +297,12 @@ function resizeOverlay(object, color) end end - resetOverlay() + updateOverlay() end -function resetOverlay() - local guid = self.getGUID() - local color - local panel - local existingXml = UI.getXml() - local openingXml = '' - - -- try to only remove our panels - for p = 1, 2 do - i, j = string.find(existingXml, ' ]] - for _, d in ipairs(data) do + for _, d in ipairs(fullButtonData) do local buttonID = tonumber(d.id) if editing and buttonID < 19 then @@ -447,27 +355,21 @@ function resetOverlay() color = "rgba(0,1,0,0)" end + -- TODO button creation xml = xml .. [[ - ]] + color="]] .. color .. [[">]] end - - xml = xml .. [[ ]] end if string.len(playColors) > 0 then data = playButtonData - xml = xml .. [[ - ]] @@ -492,56 +394,19 @@ function resetOverlay() color = "rgba(0,1,0,0)" end - xml = xml .. [[ - ]] + color="]] .. color .. [[">]] end xml = xml .. [[ ]] 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 +-- handles all button clicks function buttonClicked(player, _, idValue) local buttonID = tonumber(idValue) @@ -558,16 +423,9 @@ function buttonClicked(player, _, idValue) selectedEditButton = buttonID else if buttonID == selectedEditButton and editDistance > 0 then - local playerCount = getPlayerCount() - local colors + local colors = getColors(color) - if playerCount == 1 then - colors = { 1, 2, 3, 4 } - else - colors = { getIndexForPlayerColor(player.color) } - end - - for i, v in ipairs(colors) do + for _, v in ipairs(colors) do cameraParams[v][selectedEditButton].position = editPos cameraParams[v][selectedEditButton].pitch = editPitch cameraParams[v][selectedEditButton].yaw = editYaw @@ -579,7 +437,7 @@ function buttonClicked(player, _, idValue) selectedEditButton = -1 end - resetOverlay() + updateOverlay() elseif claiming then if buttonID >= 3 and buttonID <= 6 then local colorID = buttonID - 2 @@ -607,7 +465,7 @@ function buttonClicked(player, _, idValue) end claiming = false - resetOverlay() + updateOverlay() else loadCamera(player, _, idValue) end @@ -619,7 +477,7 @@ function loadCamera(player, _, idValue) local playerIndex = getIndexForPlayerColor(playerColor) -- 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({ origin = { x = -29.2, y = 0, z = 0.0 }, direction = { x = 0, y = 1, z = 0 }, @@ -683,7 +541,7 @@ function loadCamera(player, _, idValue) end end - if cameraParams[newMatIndex][index].distance <= 0.0 then + if cameraParams[newMatIndex][index].distance <= 0 then local matObjects = Physics.cast({ origin = playermatData[newMatIndex].origin, direction = { x = 0, y = 1, z = 0 }, @@ -737,13 +595,10 @@ function loadCamera(player, _, idValue) local d = 0.64 * scale + 7 -- need to wait if the player color changed - Wait.frames(function() - player.lookAt({ position = { centerX, 0, centerZ }, pitch = 75.823, yaw = yaw, distance = d }) - end, 2) + Wait.frames( + function() player.lookAt({ position = { centerX, 0, centerZ }, pitch = 75.823, yaw = yaw, distance = d }) end, 2) else - Wait.frames(function() - player.lookAt(cameraParams[newMatIndex][index]) - end, 2) + Wait.frames(function() player.lookAt(cameraParams[newMatIndex][index]) end, 2) end else player.lookAt(cameraParams[playerIndex][index]) @@ -758,7 +613,7 @@ function beginSetCamera(object, color) end editing = true - resetOverlay() + updateOverlay() end function updateEditCamera(params) @@ -776,7 +631,7 @@ function beginClaimColor(object, color) end claiming = true - resetOverlay() + updateOverlay() end function resetClaimColors(object, color)