From 25e07b1e4621e8317312edec8675acc4aabbf608 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 8 May 2023 22:13:12 +0200 Subject: [PATCH] removal of obsolete files --- objects/OptionPanelSource.830bd0.json | 1 - .../NavigationOverlay.a8affa.json | 56 ----- .../CameraPlacementHelper.cecc3e.json | 52 ---- .../CameraPlacementHelper.cecc3e.ttslua | 174 -------------- .../NavigationOverlay.e5803c.json | 227 ------------------ .../NavigationOverlayTile.9f2481.json | 56 ----- src/core/Global.ttslua | 4 +- src/core/NavigationOverlayApi.ttslua | 6 + src/core/NavigationOverlayHandler.ttslua | 213 +++++++--------- xml/NavigationOverlay.xml | 2 +- 10 files changed, 91 insertions(+), 700 deletions(-) delete mode 100644 objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa.json delete mode 100644 objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.json delete mode 100644 objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua delete mode 100644 objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlay.e5803c.json delete mode 100644 objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json diff --git a/objects/OptionPanelSource.830bd0.json b/objects/OptionPanelSource.830bd0.json index e71eea07..623fc02b 100644 --- a/objects/OptionPanelSource.830bd0.json +++ b/objects/OptionPanelSource.830bd0.json @@ -18,7 +18,6 @@ "TokenArranger.022907", "CYOACampaignGuides.e87ea2", "AttachmentHelper.7f4976", - "NavigationOverlay.a8affa", "SearchAssistant.17aed0", "HandHelper.450688", "DisplacementTool.0f1374", diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa.json b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa.json deleted file mode 100644 index b02bc2b4..00000000 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "Bag": { - "Order": 0 - }, - "ColorDiffuse": { - "b": 0, - "g": 0.36652, - "r": 0.70588 - }, - "ContainedObjects_order": [ - "NavigationOverlay.e5803c", - "CameraPlacementHelper.cecc3e", - "NavigationOverlayTile.9f2481" - ], - "ContainedObjects_path": "NavigationOverlay.a8affa", - "Description": "", - "DragSelectable": true, - "GMNotes": "", - "GUID": "a8affa", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MaterialIndex": -1, - "MeasureMovement": false, - "MeshIndex": -1, - "Name": "Bag", - "Nickname": "Navigation Overlay", - "Snap": true, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": 76.955, - "posY": 36.39, - "posZ": 4.123, - "rotX": 0, - "rotY": 180, - "rotZ": 0, - "scaleX": 1, - "scaleY": 1, - "scaleZ": 1 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.json b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.json deleted file mode 100644 index f6ead70c..00000000 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 0.18382, - "g": 0.18382, - "r": 0.18382 - }, - "CustomAssetbundle": { - "AssetbundleSecondaryURL": "", - "AssetbundleURL": "http://cloud-3.steamusercontent.com/ugc/880873968289806692/67F62868DF65CD9CC43F3CDCDED7BACA0F075422/", - "LoopingEffectIndex": 0, - "MaterialIndex": 2, - "TypeIndex": 4 - }, - "Description": "[b]Camera Placement Helper[/b]\n\nIf you want to use another object as the focus for the camera, you may do so by enter its GUID into this object's NAME field.\n\nIf you put a space and a number, the camera rotation will be offset by that amount. POSITIVE NUMBERS ONLY.\n\n[i]Example:[/i]\ncecc3e 90\n", - "DragSelectable": true, - "GMNotes": "", - "GUID": "cecc3e", - "Grid": false, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScriptState": "", - "LuaScript_path": "OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua", - "MeasureMovement": false, - "Name": "Custom_Assetbundle", - "Nickname": "Camera Placement Helper", - "Snap": false, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -12.658, - "posY": 3.538, - "posZ": 28.573, - "rotX": 0, - "rotY": 270, - "rotZ": 0, - "scaleX": 0.58, - "scaleY": 0.58, - "scaleZ": 0.58 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua deleted file mode 100644 index 21236238..00000000 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/CameraPlacementHelper.cecc3e.ttslua +++ /dev/null @@ -1,174 +0,0 @@ ---Data tables used in button creation -ref_modifyPitchButtons = { - { offset = -0.37, func = function() click_modify(-1, 0) end }, - { offset = -1.11, func = function() click_modify(-5, 0) end }, - { offset = 0.37, func = function() click_modify(1, 0) end }, - { offset = 1.11, func = function() click_modify(5, 0) end }, -} -ref_modifyDistanceButtons = { - { offset = -0.37, func = function() click_modify(-1, 1) end }, - { offset = -1.11, func = function() click_modify(-5, 1) end }, - { offset = 0.37, func = function() click_modify(1, 1) end }, - { offset = 1.11, func = function() click_modify(5, 1) end }, -} - ---On-demand save function, remembers pitch and distance values -function updateSave() - self.script_state = JSON.encode({ pitch = pitch, distance = distance }) -end - ---Startup, loading memory -function onload(saved_data) - --Loads the tracking for if the game has started yet - if saved_data ~= "" then - local loaded_data = JSON.decode(saved_data) - pitch = loaded_data.pitch - distance = loaded_data.distance - else - pitch = 45 - distance = 30 - end - - createInputs() - createButtons() -end - ---Activated by finishing writing in the input box, updates save info -function input_entered(inputString, stillEditing, typeIndex) - if stillEditing == false then - --Check to avoid empty input strings - if tonumber(inputString) == nil then inputString = 0 end - --Update save data - if typeIndex == 0 then - pitch = inputString - else - distance = inputString - end - updateSave() - end -end - ---Activated by button, the -5 -1 +1 +5 buttons -function click_modify(amount, typeIndex) - if typeIndex == 0 then - pitch = pitch + amount - self.editInput({ index = typeIndex, value = pitch }) - else - distance = distance + amount - self.editInput({ index = typeIndex, value = distance }) - end - updateSave() -end - ---Activated by button, uses the data to move the camera -function click_setCamera(_, color) - --Check if there is another object to use instead of self - local targetObj = self - local nameGUID = string.sub(self.getName(), 1, 6) - if getObjectFromGUID(nameGUID) ~= nil then - targetObj = getObjectFromGUID(nameGUID) - end - - --Check if there is an offset to use instead of 180 - local offsetY = 180 - local offsetString = string.sub(self.getName(), 7) - if tonumber(string.match(offsetString, "%d+")) ~= nil then - offsetY = tonumber(string.match(offsetString, "%d+")) - end - - --Move camera into position around object - local pos = targetObj.getPosition() - local rot = targetObj.getRotation() - rot.y = rot.y + offsetY - Player[color].lookAt({ position = pos, pitch = pitch, yaw = rot.y, distance = distance }) - - --Send values to main tile - for _, v in ipairs(getObjects()) do - if v.getName() == "Navigation Overlay Tile" then - v.call('updateEditCamera', { { pos.x, pos.y, pos.z }, tonumber(pitch), rot.y, tonumber(distance) }) - break - end - end -end - ---Button/Input creation ---Text boxes for number input -function createInputs() - local funcName = "inputFuncNamePitch" - local func = function(_, _, x, z) input_entered(x, z, 0) end - self.setVar(funcName, func) - self.createInput({ - input_function = funcName, - function_owner = self, - label = "input", - alignment = 2, - position = { -3.4, 0.35, -0.21 }, - rotation = { 0, 0, 0 }, - height = 420, - width = 1400, - font_size = 400, - color = { 57 / 255, 46 / 255, 40 / 255 }, - font_color = { 1, 1, 1 }, - value = pitch, - validation = 3 - }) - local funcName = "inputFuncNameDistance" - local func = function(_, _, x, z) input_entered(x, z, 1) end - self.setVar(funcName, func) - self.createInput({ - input_function = funcName, - function_owner = self, - label = "input", - alignment = 4, - position = { 3.4, 0.35, -0.21 }, - rotation = { 0, 0, 0 }, - height = 420, - width = 1400, - font_size = 400, - color = { 57 / 255, 46 / 255, 40 / 255 }, - font_color = { 1, 1, 1 }, - value = distance, - validation = 3 - }) -end - ---Center button and -5 - +5 buttons -function createButtons() - self.createButton({ - click_function = "click_setCamera", - function_owner = self, - position = { 0, 0.4, 0 }, - height = 900, - width = 900, - color = { 1, 1, 1, 0 }, - tooltip = "Set camera to this angle" - }) - - for i, ref in ipairs(ref_modifyPitchButtons) do - local funcName = "pitchModifyFunction_" .. i - self.setVar(funcName, ref.func) - local pos = { -3.4 + ref.offset, 0.3, 0.6 } - self.createButton({ - click_function = funcName, - function_owner = self, - position = pos, - height = 240, - width = 320, - color = { 1, 1, 1, 0 } - }) - end - - for i, ref in ipairs(ref_modifyDistanceButtons) do - local funcName = "distanceModifyFunction_" .. i - self.setVar(funcName, ref.func) - local pos = { 3.4 + ref.offset, 0.3, 0.6 } - self.createButton({ - click_function = funcName, - function_owner = self, - position = pos, - height = 240, - width = 320, - color = { 1, 1, 1, 0 } - }) - end -end diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlay.e5803c.json b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlay.e5803c.json deleted file mode 100644 index 8c2b8b7e..00000000 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlay.e5803c.json +++ /dev/null @@ -1,227 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "Description": "Controls a movable overlay allowing for quick movement to various parts of the table. There should only be one tile per table.\n\nFull Table: Displays a larger overlay corresponding to the whole table.\n\nPlay Area: Displays a much smaller overlay only covering the play area.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "e5803c", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Notecard", - "Nickname": "Navigation Overlay", - "Snap": true, - "States": { - "2": { - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "Description": "If there is only 1 player, clicking a button to move to a playmat will change the player's color to that playmat's color. Changes to camera settings will apply to all colors.\n\nIf there is more than 1 player, displaying the overlay or editing a camera setting will only apply to your color.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "3051f2", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Notecard", - "Nickname": "Navigation Overlay", - "Snap": true, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -69.47138, - "posY": 1.551499, - "posZ": -50.97995, - "rotX": -6.706855e-8, - "rotY": 90.00628, - "rotZ": 3.98763333e-9, - "scaleX": 0.7, - "scaleY": 1, - "scaleZ": 0.7 - }, - "Value": 0, - "XmlUI": "" - }, - "3": { - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "Description": "Edit Camera: TTS does not make accessing camera settings easy, so this is done using a modified version of MrStump's Camera Placement Helper.\n\nTo use the Helper, place it in the position you want the camera to look, with the desired rotation. Set the Pitch and Distance values. Click \"Set camera to this angle\".", - "DragSelectable": true, - "GMNotes": "", - "GUID": "579a11", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Notecard", - "Nickname": "Navigation Overlay: Edit Camera (1/2)", - "Snap": true, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -69.47138, - "posY": 1.55149889, - "posZ": -50.97995, - "rotX": -4.66551136e-8, - "rotY": 90.00628, - "rotZ": 9.637148e-9, - "scaleX": 0.7, - "scaleY": 1, - "scaleZ": 0.7 - }, - "Value": 0, - "XmlUI": "" - }, - "4": { - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "Description": "1. Click \"Edit Camera\"\n2. Click a button in the overlay, it will turn green.\n3. Use the Camera Placement Helper to set the camera view.\n4. When clicking \"Set camera to this angle\" produces the correct camera view, click the green button in the overlay again to set the camera. Click a red button to cancel.", - "DragSelectable": true, - "GMNotes": "", - "GUID": "045a3e", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Notecard", - "Nickname": "Navigation Overlay: Edit Camera (2/2)", - "Snap": true, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -69.47138, - "posY": 1.55149889, - "posZ": -50.97995, - "rotX": -1.21061817e-7, - "rotY": 90.00628, - "rotZ": 9.462388e-8, - "scaleX": 0.7, - "scaleY": 1, - "scaleZ": 0.7 - }, - "Value": 0, - "XmlUI": "" - }, - "5": { - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "Description": "Claim Color: This is useful if you are running a game where one person controls 2 colors, and one controls the other two, and you wish to have your player color switch when you click White or Red, but not if you click Green or Orange.\n\nWhen you click Claim Color, the playmat areas of the overlay will turn white. Clicking one will allow you to switch to that color with the overlay. ", - "DragSelectable": true, - "GMNotes": "", - "GUID": "516664", - "Grid": true, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Notecard", - "Nickname": "Navigation Overlay: Claim Colors", - "Snap": true, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -38.4611664, - "posY": 1.59, - "posZ": -1.54776835, - "rotX": 5.3783765e-8, - "rotY": 90.00012, - "rotZ": 8.552772e-8, - "scaleX": 0.7, - "scaleY": 1, - "scaleZ": 0.7 - }, - "Value": 0, - "XmlUI": "" - } - }, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -37.692, - "posY": 3.67, - "posZ": 9.23, - "rotX": 0, - "rotY": 90, - "rotZ": 0, - "scaleX": 0.7, - "scaleY": 1, - "scaleZ": 0.7 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json b/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json deleted file mode 100644 index ffad7d19..00000000 --- a/objects/OptionPanelSource.830bd0/NavigationOverlay.a8affa/NavigationOverlayTile.9f2481.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "AltLookAngle": { - "x": 0, - "y": 0, - "z": 0 - }, - "Autoraise": true, - "ColorDiffuse": { - "b": 1, - "g": 1, - "r": 1 - }, - "CustomImage": { - "CustomTile": { - "Stackable": false, - "Stretch": true, - "Thickness": 0.1, - "Type": 0 - }, - "ImageScalar": 1, - "ImageURL": "http://cloud-3.steamusercontent.com/ugc/2021591230456185506/15AF790F0622B57C1F629DB3A8C38F2A99D0EB1B/", - "WidthScale": 0 - }, - "Description": "", - "DragSelectable": true, - "GMNotes": "", - "GUID": "9f2481", - "Grid": false, - "GridProjection": false, - "Hands": false, - "HideWhenFaceDown": false, - "IgnoreFoW": false, - "LayoutGroupSortIndex": 0, - "Locked": false, - "LuaScript": "", - "LuaScriptState": "", - "MeasureMovement": false, - "Name": "Custom_Tile", - "Nickname": "Navigation Overlay Tile", - "Snap": false, - "Sticky": true, - "Tooltip": true, - "Transform": { - "posX": -12.93, - "posY": 3.562, - "posZ": 28.568, - "rotX": 0, - "rotY": 270, - "rotZ": 1, - "scaleX": 3, - "scaleY": 1, - "scaleZ": 3 - }, - "Value": 0, - "XmlUI": "" -} diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index f932bf9e..7ccd62f2 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -38,6 +38,7 @@ local soundCubeApi = require("core/SoundCubeApi") local mythosAreaApi = require("core/MythosAreaApi") local tokenArrangerApi = require("accessories/TokenArrangerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") +local navigationOverlayApi = require("core/NavigationOverlayApi") -- online functionality related variables local MOD_VERSION = "3.1.0" @@ -643,8 +644,7 @@ end function onClick_toggleUi(player, title) if title == "Navigation Overlay" then - local navigationOverlayHandler = getObjectFromGUID("797ede") - navigationOverlayHandler.call("cycleVisibility", player.color) + navigationOverlayApi.cycleVisibility(player.color) return end diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index 75ea968a..2a462807 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -12,5 +12,11 @@ do }) end + -- Changes the Navigation Overlay view ("Full View" --> "Play Areas" --> "Closed" etc.) + ---@param playerColor String Color of the player to update the visibility for + NavigationOverlayApi.cycleVisibility = function(playerColor) + getObjectFromGUID(HANDLER_GUID).call("cycleVisibility", playerColor) + end + return NavigationOverlayApi end diff --git a/src/core/NavigationOverlayHandler.ttslua b/src/core/NavigationOverlayHandler.ttslua index 22169792..b6031cdb 100644 --- a/src/core/NavigationOverlayHandler.ttslua +++ b/src/core/NavigationOverlayHandler.ttslua @@ -1,4 +1,5 @@ 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 @@ -58,13 +59,16 @@ defaultCameraParams = { { position = { -59.08, 1.55, -83 }, distance = 27 } -- 18. Additions } -local cameraParams = { {}, {}, {}, {} } -local playermatData = { {}, {}, {}, {} } local editing = false local claiming = false +local cameraParams = {} local visibility = {} local claims = {} +--------------------------------------------------------- +-- save/load functionality +--------------------------------------------------------- + function onSave() return JSON.encode({ cameras = cameraParams, @@ -89,27 +93,30 @@ function onLoad(savedData) updateVisibility() end +--------------------------------------------------------- +-- visibility related functions +--------------------------------------------------------- + function cycleVisibility(color) setVisibility("next", color) end +function copyVisibility(params) + visibility[params.targetColor] = { + full = visibility[params.startColor].full, + play = visibility[params.startColor].play + } + updateVisibility() +end + function setVisibility(type, color) if type == "next" then if visibility[color].full then - visibility[color] = { - full = false, - play = true - } + visibility[color] = { full = false, play = true } elseif visibility[color].play then - visibility[color] = { - full = false, - play = false - } + visibility[color] = { full = false, play = false } else - visibility[color] = { - full = true, - play = false - } + visibility[color] = { full = true, play = false } end elseif type == "toggle" then visibility[color] = { @@ -117,60 +124,43 @@ function setVisibility(type, color) play = not visibility[color].play } else - visibility[color] = { - full = false, - play = false - } + visibility[color] = { full = false, play = false } end updateVisibility() end -function getIndices(color) - local playerCount = #getSeatedPlayers() - - if playerCount == 0 then - return {} - elseif playerCount == 1 then - return { 1, 2, 3, 4 } - else - return { getIndexForPlayerColor(color) } - end -end - -function resetCameras() - for v = 1, 4 do - cameraParams[v] = {} - for i = 1, #defaultCameraParams do - cameraParams[v][i] = {} - cameraParams[v][i].position = defaultCameraParams[i].position - cameraParams[v][i].pitch = 75 - cameraParams[v][i].yaw = 90 - cameraParams[v][i].distance = defaultCameraParams[i].distance - end - end -end - -- update XML visibility function updateVisibility() - local fullColors = "Black" - local playColors = "Black" + local colorString = {full = "", play = ""} for color, v in pairs(visibility) do if v.full then - fullColors = fullColors .. '|' .. color + if colorString.full == "" then + colorString.full = color + else + colorString.full = colorString.full .. '|' .. color + end elseif v.play then - playColors = playColors .. '|' .. color + if colorString.play == "" then + colorString.play = color + else + colorString.play = colorString.play .. '|' .. color + end end end - log(fullColors) - log(playColors) -- update the visibility on the XML - UI.setAttribute("navPanelFull", "visibility", fullColors) - UI.setAttribute("navPanelPlay", "visibility", playColors) + UI.setAttribute("navPanelFull", "visibility", colorString.full) + UI.setAttribute("navPanelPlay", "visibility", colorString.play) + UI.setAttribute("navPanelFull", "active", colorString.full ~= "") + UI.setAttribute("navPanelPlay", "active", colorString.play ~= "") end +--------------------------------------------------------- +-- XML creating/editing +--------------------------------------------------------- + function updateXmlButtons() local ui = UI.getXmlTable() ui = updateXmlButtonHelper(ui, { @@ -249,53 +239,30 @@ function findTagWithId(ui, id) return nil end +--------------------------------------------------------- +-- core functionality +--------------------------------------------------------- + -- handles all button clicks function buttonClicked(player, _, idValue) - local buttonID = tonumber(idValue) + local index = tonumber(idValue) - if buttonID == 19 then + if index == 19 then setVisibility("toggle", player.color) return - elseif buttonID == 20 then + elseif index == 20 then setVisibility("close", player.color) return end - if editing then - if selectedEditButton < 0 then - selectedEditButton = buttonID - else - if buttonID == selectedEditButton and editDistance > 0 then - for _, v in ipairs(getIndices(color)) do - cameraParams[v][selectedEditButton].position = editPos - cameraParams[v][selectedEditButton].pitch = editPitch - cameraParams[v][selectedEditButton].yaw = editYaw - cameraParams[v][selectedEditButton].distance = editDistance - end - end - - editing = false - selectedEditButton = -1 - end - - updateXmlButtons() - elseif claiming then - if buttonID >= 3 and buttonID <= 6 then - local colors = {"White", "Orange", "Green", "Red"} - local matColor = colors[buttonID - 2] - claims[player.color][matColor] = not claims[player.color][matColor] - end - - claiming = false - updateXmlButtons() - else - loadCamera(player, _, buttonID) - end + loadCamera(player, _, index) end function loadCamera(player, _, index) + local lookHere + -- only do map zooming if the camera hasn't been specially set by user - if index == 2 and cameraParams[playerIndex][index].distance <= 0 then + if index == 2 and cameraParams[player.color][index].distance <= 0 then local zone = getObjectFromGUID("a2f932") local minX, minZ, maxX, maxZ = 100, 100, -100, -100 @@ -314,16 +281,15 @@ function loadCamera(player, _, index) end end - player.lookAt({ + lookHere = { position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 }, pitch = 75, yaw = 90, distance = 0.96 * math.max(maxX - minX, (maxZ - minZ) / 1.6) + 5 - }) + } elseif index >= 3 and index <= 6 then - local newMatIndex = index - 2 -- mat index 1 - 4 local colorList = { "White", "Orange", "Green", "Red" } - local newMatColor = colorList[newMatIndex] + local newMatColor = colorList[index - 2] -- mat index 1 - 4 local newPlayerColor = playmatApi.getPlayerColor(newMatColor) if newMatColor ~= nil and (#getSeatedPlayers() == 1 or claims[player.color][newMatColor]) then @@ -331,8 +297,8 @@ function loadCamera(player, _, index) player.changeColor(newPlayerColor) end - if cameraParams[newMatIndex][index].distance <= 0 then - local divisor, minX, maxX, minZ, maxZ + if cameraParams[player.color][index].distance <= 0 then + local minX, maxX, minZ, maxZ for _, v in pairs(playmatApi.searchPlaymat(newMatColor)) do local bounds = v.hit_object.getBounds() @@ -347,38 +313,16 @@ function loadCamera(player, _, index) maxZ = math.max(z2, maxZ or z2) end - -- White/Orange - if index == 3 or index == 4 then - divisor = {x = 1.5, z = 1.5 } -- screen ratio * 1.2 (for my macbook pro, no idea how to generalize this) - -- Green/Red - else - divisor = {x = 1.5, z = 1.5} - end - - -- need to wait if the player color changed - Wait.frames( - function() player.lookAt({ - position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 }, - pitch = 75, - yaw = playmatApi.returnRotation(newMatColor).y + 180, - distance = 0.64 * math.max((maxX - minX) / divisor.x, (maxZ - minZ) / divisor.z) + 7 - }) - end, 2) - else - Wait.frames(function() player.lookAt(cameraParams[newMatIndex][index]) end, 2) + lookHere = { + position = { (minX + maxX) / 2, 0, (minZ + maxZ) / 2 }, + pitch = 75, + yaw = playmatApi.returnRotation(newMatColor).y + 180, + distance = 0.42 * math.max(maxX - minX, maxZ - minZ) + 7 + } end - else - local playerIndex = getIndexForPlayerColor(player.color) - player.lookAt(cameraParams[playerIndex][index]) end -end - -function copyVisibility(params) - visibility[params.targetColor] = { - full = visibility[params.startColor].full, - play = visibility[params.startColor].play - } - updateVisibility() + -- delay is to account for colorswap + Wait.frames(function() player.lookAt(lookHere or cameraParams[player.color][index]) end, 2) end function beginClaimColor() @@ -405,6 +349,23 @@ function updateEditCamera(params) editDistance = params[4] end +--------------------------------------------------------- +-- functions to reset/initialize tables +--------------------------------------------------------- + +function resetCameras() + for _, color in ipairs(Player.getColors()) do + cameraParams[color] = {} + for i = 1, #defaultCameraParams do + cameraParams[color][i] = {} + cameraParams[color][i].yaw = 90 + cameraParams[color][i].pitch = 75 + cameraParams[color][i].position = defaultCameraParams[i].position + cameraParams[color][i].distance = defaultCameraParams[i].distance + end + end +end + function resetClaimColors() for _, seatedColor in ipairs(getSeatedPlayers()) do claims[seatedColor] = {} @@ -419,13 +380,3 @@ function resetVisibility() visibility[color] = { full = false, play = false } end end - -function getIndexForPlayerColor(color) - local index = { White = 1, Orange = 2, Green = 3, Red = 4 } - - if index[color] then - return index[color] - else - return -1 - end -end diff --git a/xml/NavigationOverlay.xml b/xml/NavigationOverlay.xml index 6f7890d4..a6f475d5 100644 --- a/xml/NavigationOverlay.xml +++ b/xml/NavigationOverlay.xml @@ -1,7 +1,7 @@