diff --git a/modsettings/SnapPoints.json b/modsettings/SnapPoints.json index 11cad351..de68106b 100644 --- a/modsettings/SnapPoints.json +++ b/modsettings/SnapPoints.json @@ -56,446 +56,6 @@ "z": 0 } }, - { - "Position": { - "x": -43.37, - "y": 1.647, - "z": 15.19 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.644, - "z": 7.57 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.642, - "z": -0.03 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.64, - "z": -7.7 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.638, - "z": -15.28 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.629, - "z": -15.28 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.631, - "z": -7.7 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.633, - "z": -0.03 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.635, - "z": 7.57 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.638, - "z": 15.19 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.628, - "z": 15.19 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.626, - "z": 7.57 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.624, - "z": -0.03 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.622, - "z": -7.7 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.62, - "z": -15.28 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.61, - "z": -15.28 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.613, - "z": -7.7 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.615, - "z": -0.03 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.617, - "z": 7.57 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.619, - "z": 15.19 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.611, - "z": 15.19 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.608, - "z": 7.57 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.606, - "z": -0.03 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.603, - "z": -7.7 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.602, - "z": -15.28 - }, - "Rotation": { - "x": 0, - "y": 270, - "z": 0 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.645, - "z": 11.46 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.643, - "z": 3.86 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.641, - "z": -3.83 - } - }, - { - "Position": { - "x": -43.37, - "y": 1.639, - "z": -11.51 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.631, - "z": -11.51 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.632, - "z": -3.83 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.634, - "z": 3.86 - } - }, - { - "Position": { - "x": -36.773, - "y": 1.636, - "z": 11.46 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.626, - "z": 11.46 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.625, - "z": 3.86 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.623, - "z": -3.83 - } - }, - { - "Position": { - "x": -30.224, - "y": 1.621, - "z": -11.51 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.612, - "z": -11.51 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.614, - "z": -3.83 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.616, - "z": 3.86 - } - }, - { - "Position": { - "x": -23.677, - "y": 1.619, - "z": 11.46 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.609, - "z": 11.46 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.607, - "z": 3.86 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.605, - "z": -3.83 - } - }, - { - "Position": { - "x": -17.12, - "y": 1.603, - "z": -11.51 - } - }, { "Position": { "x": 22.951, diff --git a/objects/Connectionmarkers.170f10/Custom_Tile.7234af.json b/objects/Connectionmarkers.170f10/Custom_Tile.7234af.json index 98f1e8f3..94463f6d 100644 --- a/objects/Connectionmarkers.170f10/Custom_Tile.7234af.json +++ b/objects/Connectionmarkers.170f10/Custom_Tile.7234af.json @@ -156,6 +156,9 @@ } }, "Sticky": true, + "Tags": [ + "Location" + ], "Tooltip": true, "Transform": { "posX": -50.369, diff --git a/objects/Playarea.721ba2.json b/objects/Playarea.721ba2.json index 17f0b18f..2ce861e3 100644 --- a/objects/Playarea.721ba2.json +++ b/objects/Playarea.721ba2.json @@ -4,6 +4,700 @@ "y": 0, "z": 0 }, + "AttachedSnapPoints": [ + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": -1.09 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": -0.43 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": 0.23 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": 0.89 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": 1.53, + "y": 0.1, + "z": 1.55 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": -1.09 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": -0.43 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": 0.23 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": 0.89 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": 1.148, + "y": 0.1, + "z": 1.55 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": -1.09 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": -0.43 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": 0.23 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": 0.89 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": 0.765, + "y": 0.1, + "z": 1.55 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": -1.09 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": -0.43 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": 0.23 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": 0.89 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": 0.383, + "y": 0.1, + "z": 1.55 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": -1.09 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": -0.43 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": 0.23 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": 0.89 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": 0, + "y": 0.1, + "z": 1.55 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": -1.09 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": -0.43 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": 0.23 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": 0.89 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": -0.383, + "y": 0.1, + "z": 1.55 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": -1.09 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": -0.43 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": 0.23 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": 0.89 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": -0.765, + "y": 0.1, + "z": 1.55 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": -1.09 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": -0.43 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": 0.23 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": 0.89 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": -1.148, + "y": 0.1, + "z": 1.55 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": -1.09 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": -0.76 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": -0.43 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": -0.1 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": 0.23 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": 0.56 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": 0.89 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": 1.22 + } + }, + { + "Position": { + "x": -1.53, + "y": 0.1, + "z": 1.55 + }, + "Rotation": { + "x": 0, + "y": 0, + "z": 0 + } + } + ], "Autoraise": true, "ColorDiffuse": { "b": 1, diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index c6e3321c..c5ff4d35 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -36,6 +36,7 @@ local IS_RESHUFFLING = false local bagSearchers = {} local hideTitleSplashWaitFunctionId = nil local playmatAPI = require("playermat/PlaymatApi") +local playAreaAPI = require("core/PlayAreaApi") --------------------------------------------------------- -- data for tokens @@ -819,6 +820,11 @@ function applyOptionPanelChange(id, state) -- update master clue counter getObjectFromGUID("4a3aa4").setVar("useClickableCounters", state) + -- option: Draw 1 button + elseif id == "PlayAreaSnapTags" then + playAreaAPI.setLimitSnapsByType(state) + optionPanel[id] = state + -- option: Show Title on placing scenarios elseif id == "showTitleSplash" then optionPanel[id] = state @@ -945,6 +951,7 @@ function onClick_defaultSettings() -- clean reset of variable optionPanel = { useSnapTags = true, + PlayAreaSnapTags = false, showDrawButton = false, useClueClickers = false, showTitleSplash = true, diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 3fa91628..4397dbc1 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -443,3 +443,56 @@ end function showLocationLinks() return not LOC_LINK_EXCLUDE_SCENARIOS[currentScenario] end + +-- Sets this playmat's snap points to limit snapping to locations or not. +-- If matchTypes is false, snap points will be reset to snap all cards. +---@param matchTypes Boolean Whether snap points should only snap for the matching card types. +function setLimitSnapsByType(matchTypes) + local snaps = self.getSnapPoints() + for i, snap in ipairs(snaps) do + local snapTags = snaps[i].tags + if matchTypes then + if snapTags == nil then + snaps[i].tags = { "Location" } + else + table.insert(snaps[i].tags, "Location") + end + else + snaps[i].tags = nil + end + end + self.setSnapPoints(snaps) +end + +-- rebuilds local snap points (could be useful in the future again) +function buildSnaps() + local upperleft = { x = 1.53, z = -1.09} + local lowerright = {x = -1.53, z = 1.55} + local snaps = {} + + -- creates 81 snap points, for uneven rows + columns it makes a rotation snap point + for i = 1, 9 do + for j = 1, 9 do + local snap = {} + snap.position = {} + snap.position.x = round(upperleft.x - (upperleft.x - lowerright.x) * (i - 1) / 8, 3) + snap.position.y = 0.1 + snap.position.z = round(upperleft.z - (upperleft.z - lowerright.z) * (j - 1) / 8, 3) + + -- enable rotation snaps for uneven rows / columns + if (i % 2 ~= 0) and (j % 2 ~= 0) then + snap.rotation = {0, 0, 0} + snap.rotation_snap = true + end + + table.insert(snaps, snap) + end + end + self.setSnapPoints(snaps) +end + +-- utility function +function round(num, numDecimalPlaces) + local mult = 10^(numDecimalPlaces or 0) + return math.floor(num * mult + 0.5) / mult +end diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 49e54769..157cc600 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -41,5 +41,12 @@ do getObjectFromGUID(PLAY_AREA_GUID).call("onScenarioChanged", scenarioName) end + -- Sets this playmat's snap points to limit snapping to locations or not. + -- If matchTypes is false, snap points will be reset to snap all cards. + ---@param matchTypes Boolean Whether snap points should only snap for the matching card types. + PlayAreaApi.setLimitSnapsByType = function(matchCardTypes) + getObjectFromGUID(PLAY_AREA_GUID).call("setLimitSnapsByType", matchCardTypes) + end + return PlayAreaApi end diff --git a/xml/OptionPanel.xml b/xml/OptionPanel.xml index c63c85d9..bb47ea38 100644 --- a/xml/OptionPanel.xml +++ b/xml/OptionPanel.xml @@ -142,6 +142,20 @@ + + + + + Enable snap tags for play area + Only cards with the tag "Location" will snap (official cards are supported by default). Disable this if you are having issues with custom content. + + + + + + +