Merge branch 'argonui:main' into campaign-exporter-fix

This commit is contained in:
Entrox-Licher 2024-01-15 18:16:32 -05:00 committed by GitHub
commit 82366e91f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 171 additions and 266 deletions

View File

@ -173,7 +173,6 @@
"TokenSpawnTracker.e3ffc9",
"TokenSource.124381",
"GameData.3dbe47",
"PlayermatClickInterceptor.3dbe55",
"SCEDTour.0e5aa8",
"InstructionGenerator.240522",
"PlayerCards.2d30ee",

View File

@ -1 +1 @@
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showPlayermatHider":false,"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}
{"acknowledgedUpgradeVersions":[],"optionPanel":{"cardLanguage":"en","changePlayAreaImage":false,"playAreaConnectionColor":{"a":1,"b":0.4,"g":0.4,"r":0.4},"playAreaConnections":true,"playAreaSnapTags":true,"showAttachmentHelper":false,"showCleanUpHelper":false,"showCYOA":false,"showDisplacementTool":false,"showDrawButton":false,"showHandHelper":[],"showSearchAssistant":[],"showTitleSplash":true,"useClueClickers":false,"useResourceCounters":"disabled","useSnapTags":true}}

View File

@ -17,7 +17,6 @@
"CYOACampaignGuides.e87ea2",
"AttachmentHelper.7f4976",
"SearchAssistant.17aed0",
"PlayermatHider.a758b2",
"HandHelper.450688",
"DisplacementTool.0f1374",
"CleanUpHelper.26cf4b"

View File

@ -1,60 +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": 3
},
"ImageScalar": 1,
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/2115061845796985108/F0ADB7094641DA966FFA3AF0CC6987D33D2D9591/",
"WidthScale": 0
},
"Description": "Use the buttons to show / hide a playermat.",
"DragSelectable": true,
"GMNotes": "",
"GUID": "a758b2",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
"LuaScript": "require(\"accessories/PlayermatHider\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Playermat Hider",
"Snap": true,
"Sticky": true,
"Tags": [
"CleanUpHelper_ignore"
],
"Tooltip": true,
"Transform": {
"posX": 0,
"posY": 2,
"posZ": 0,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 3,
"scaleY": 1,
"scaleZ": 3
},
"Value": 0,
"XmlUI": "\u003cInclude src=\"accessories/PlayermatHider.xml\"/\u003e"
}

View File

@ -1,50 +0,0 @@
{
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0,
"g": 0,
"r": 0
},
"Description": "This object is used to hide playmats beneath the table.",
"DragSelectable": true,
"GMNotes": "",
"GUID": "3dbe55",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScriptState": "false",
"LuaScript_path": "PlayermatClickInterceptor.3dbe55.ttslua",
"MeasureMovement": false,
"Name": "BlockSquare",
"Nickname": "PlayermatClickInterceptor",
"Snap": true,
"Sticky": true,
"Tags": [
"CameraZoom_ignore",
"CleanUpHelper_ignore",
"displacement_excluded"
],
"Tooltip": false,
"Transform": {
"posX": -27.94,
"posY": -0.5,
"posZ": 0,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 84,
"scaleY": 1.5,
"scaleZ": 70
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1,15 +0,0 @@
local interactable = false
function onSave() return JSON.encode(interactable) end
function onLoad(savedData)
if savedData and savedData ~= "" then
interactable = JSON.decode(savedData)
end
self.interactable = interactable
end
function setState(state)
interactable = state
self.interactable = interactable
end

View File

@ -280,13 +280,14 @@ function tidyPlayerMatCoroutine()
local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
if trash == nil then
printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red")
return 1
break
end
local objList
if i < 5 then
objList = playmatApi.searchAroundPlaymat(COLORS[i])
else
-- Victory Display + Mythos Area
objList = searchLib.inArea({ -2, 2, 10 }, { 0, 270, 0 }, { 55, 1, 13.5 })
end

View File

@ -1,33 +1,21 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local playmatApi = require("playermat/PlaymatApi")
function onClick_hideShow(player, matColor)
function onClick_hide(player, matColor)
local objects = guidReferenceApi.getObjectsByOwner(matColor)
local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
local pos = objects.Playermat.getPosition()
local mod = (pos.y > 0) and -2 or 2
if not objects.Playermat then return end
-- move all objects
for _, obj in pairs(objects) do
obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
end
player.showConfirmDialog("Really remove this playmat and related objects? This can't be reversed.",
function()
-- remove action tokens
local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
for _, obj in ipairs(actionTokens) do
obj.destruct()
end
-- move action tokens
for _, obj in ipairs(actionTokens) do
obj.setLock(pos.y > 0)
obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
end
-- set state of interceptor block
local allMats = guidReferenceApi.getObjectsByType("Playermat")
local state = false
for owner, mat in pairs(allMats) do
if mat.getPosition().y < 0 then
state = true
break
end
end
local interceptor = getObjectFromGUID("3dbe55")
interceptor.call("setState", state)
-- remove mat owned objects
for _, obj in pairs(objects) do
obj.destruct()
end
end)
end

View File

@ -24,5 +24,17 @@ do
return getGuidHandler().call("getObjectsByOwner", owner)
end
-- sends new information to the reference handler to edit the main index
---@param owner String Parent of the object
---@param type String Type of the object
---@param guid String GUID of the object
GUIDReferenceApi.editIndex = function(owner, type, guid)
return getGuidHandler().call("editIndex", {
owner = owner,
type = type,
guid = guid
})
end
return GUIDReferenceApi
end

View File

@ -91,12 +91,43 @@ local GuidReferences = {
}
}
local editsToIndex = {
White = {},
Orange = {},
Green = {},
Red = {},
Mythos = {}
}
-- save function to keep edits to the index
function onSave() return JSON.encode({ editsToIndex = editsToIndex }) end
-- load function to restore edits to the index
function onLoad(savedData)
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
editsToIndex = loadedData.editsToIndex
updateMainIndex()
end
end
-- merges the main index and the edits
function updateMainIndex()
for owner, subTable in pairs(editsToIndex) do
for type, guid in pairs(subTable) do
GuidReferences[owner][type] = guid
end
end
end
-- returns an object reference for the requested owner and type
function getObjectByOwnerAndType(params)
local owner = params.owner or "Mythos"
local type = params.type
return getObjectFromGUID(GuidReferences[owner][type])
end
-- returns a list of objects for the requested type
function getObjectsByType(type)
local objList = {}
for owner, objects in pairs(GuidReferences) do
@ -108,6 +139,7 @@ function getObjectsByType(type)
return objList
end
-- returns a list of objects for the requested owner
function getObjectsByOwner(owner)
local objList = {}
for type, guid in pairs(GuidReferences[owner]) do
@ -118,3 +150,9 @@ function getObjectsByOwner(owner)
end
return objList
end
-- makes an edit to the main index
function editIndex(params)
editsToIndex[params.owner][params.type] = params.guid
updateMainIndex()
end

View File

@ -253,7 +253,7 @@ function switchSeat(playerColor, direction)
end
-- swap color
navigationOverlayApi.loadCamera(playerColor, usedColors[index])
navigationOverlayApi.loadCamera(Player[playerColor], usedColors[index])
end
-- takes a clue from a location, player needs to hover the clue directly or the location

View File

@ -1215,6 +1215,45 @@ function returnResourceCounterId(name)
end
end
-- called by the playermat removal selection dropdown
function playermatRemovalSelected(player, selectedIndex, id)
if selectedIndex == "0" then return end
local matColorList = { "White", "Orange", "Green", "Red" }
local matColor = matColorList[tonumber(selectedIndex)]
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
if mat then
-- confirmation dialog about deletion
player.pingTable(mat.getPosition())
player.showConfirmDialog("Do you really want to remove " .. matColor .. "'s playermat and related objects? This can't be reversed.", function() removePlayermat(matColor) end)
else
-- info dialog that it is already deleted
player.showInfoDialog(matColor .. "'s playermat has already been removed.")
end
-- set selected value back to first option
UI.setAttribute(id, "value", 0)
end
-- removes a playermat and all related objects from play
---@param matColor String Color of the playermat to remove
function removePlayermat(matColor)
local matObjects = guidReferenceApi.getObjectsByOwner(matColor)
if not matObjects.Playermat then return end
-- remove action tokens
local actionTokens = playmatApi.searchAroundPlaymat(matColor, "isActionToken")
for _, obj in ipairs(actionTokens) do
obj.destruct()
end
-- remove mat owned objects
for _, obj in pairs(matObjects) do
obj.destruct()
end
end
-- sets the option panel to the correct state (corresponding to 'optionPanel')
function updateOptionPanelState()
for id, optionValue in pairs(optionPanel) do
@ -1289,22 +1328,22 @@ function applyOptionPanelChange(id, state)
-- option: Show hand helper for each player
elseif id == "showHandHelper" then
for i, color in ipairs(MAT_COLORS) do
local pos = playmatApi.transformLocalPosition({0.05, 0, -1.182}, color)
local rot = playmatApi.returnRotation(color)
optionPanel[id][i] = spawnOrRemoveHelper(state, "Hand Helper", pos, rot)
local helperName = "Hand Helper"
local spawnData = playmatApi.getHelperSpawnData("All", helperName)
local i = 0
for color, data in pairs(spawnData) do
i = i + 1
optionPanel[id][i] = spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)
end
-- option: Show playermat hider
elseif id == "showPlayermatHider" then
optionPanel[id] = spawnOrRemoveHelper(state, "Playermat Hider", {-48, 1.6, 46})
-- option: Show search assistant for each player
elseif id == "showSearchAssistant" then
for i, color in ipairs(MAT_COLORS) do
local pos = playmatApi.transformLocalPosition({-0.3, 0, -1.182}, color)
local rot = playmatApi.returnRotation(color)
optionPanel[id][i] = spawnOrRemoveHelper(state, "Search Assistant", pos, rot)
local helperName = "Search Assistant"
local spawnData = playmatApi.getHelperSpawnData("All", helperName)
local i = 0
for color, data in pairs(spawnData) do
i = i + 1
optionPanel[id][i] = spawnOrRemoveHelper(state, helperName, data.position, data.rotation, color)
end
-- option: Show attachment helper
@ -1326,13 +1365,17 @@ end
---@param name String Name of the helper object
---@param position Vector Position of the object (where it will spawn)
---@param rotation Vector Rotation of the object for spawning (default: {0, 270, 0})
---@param owner String Owner of the object (defaults to "Mythos")
---@return. GUID of the spawnedObj (or nil if object was removed)
function spawnOrRemoveHelper(state, name, position, rotation)
function spawnOrRemoveHelper(state, name, position, rotation, owner)
if (type(state) == "table" and #state == 0) then
return removeHelperObject(name)
elseif state then
Player.getPlayers()[1].pingTable(position)
return spawnHelperObject(name, position, rotation).getGUID()
local spawnedGUID = spawnHelperObject(name, position, rotation).getGUID()
local cleanName = name:gsub("%s+", "")
guidReferenceApi.editIndex(owner or "Mythos", cleanName, spawnedGUID)
return spawnedGUID
else
return removeHelperObject(name)
end
@ -1376,7 +1419,6 @@ function removeHelperObject(name)
local referenceTable = {
["Clean Up Helper"] = "showCleanUpHelper",
["Hand Helper"] = "showHandHelper",
["Playermat Hider"] = "showPlayermatHider",
["Search Assistant"] = "showSearchAssistant",
["Displacement Tool"] = "showDisplacementTool",
["Attachment Helper"] = "showAttachmentHelper",
@ -1431,7 +1473,6 @@ function onClick_defaultSettings()
showDisplacementTool = false,
showDrawButton = false,
showHandHelper = {},
showPlayermatHider = false,
showSearchAssistant = {},
showTitleSplash = true,
useClueClickers = false,

View File

@ -25,9 +25,9 @@ do
-- loads the specified camera for a player
---@param player TTSPlayerInstance Player whose camera should be moved
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
NavigationOverlayApi.loadCamera = function(playerColor, camera)
NavigationOverlayApi.loadCamera = function(player, camera)
getNOHandler().call("loadCameraFromApi", {
playerColor = playerColor,
player = player,
camera = camera
})
end

View File

@ -292,7 +292,7 @@ function getDynamicViewBounds(objList)
end
function loadCameraFromApi(params)
loadCamera(Player[params.playerColor], params.camera)
loadCamera(params.player, params.camera)
end
-- loads the specified camera for a player

View File

@ -96,6 +96,26 @@ do
end
end
-- Returns a table with spawn data (position and rotation) for a helper object
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param helperName String Name of the helper object
PlaymatApi.getHelperSpawnData = function(matColor, helperName)
local resultTable = {}
local localPositionTable = {
["Hand Helper"] = {0.05, 0, -1.182},
["Search Assistant"] = {-0.3, 0, -1.182}
}
for color, mat in pairs(getMatForColor(matColor)) do
resultTable[color] = {
position = mat.positionToWorld(localPositionTable[helperName]),
rotation = mat.getRotation()
}
end
return resultTable
end
-- Triggers the Upkeep for the requested playmat
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@param playerColor String Color of the calling player (for messages)

View File

@ -297,6 +297,28 @@
</Cell>
</Row>
<!-- Option: remove a player mat -->
<Row class="option-text"
tooltip="Remove an unused playermat for more table space.&#xA;Displayed are the default colors.">
<Cell class="option-singleColumn">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Remove a playermat</Text>
</Panel>
</Cell>
<Cell class="option-doubleColumn">
<Panel class="doubleColumn-wrapper">
<Dropdown id="removePlayermat"
onValueChanged="playermatRemovalSelected(selectedIndex)">
<Option>Click to select</Option>
<Option>1: White</Option>
<Option>2: Orange</Option>
<Option>3: Green</Option>
<Option>4: Red</Option>
</Dropdown>
</Panel>
</Cell>
</Row>
<!-- Group: fan-made accessories -->
<Row class="group-header">
<Cell class="group-header">
@ -351,7 +373,7 @@
<!-- Option: show displacement tool -->
<Row class="option-text"
tooltip="This allows moving all objects on the main playmat&#xA;in a chosen direction.">
tooltip="This allows moving all objects on the main play area&#xA;in a chosen direction.">
<Cell class="option-text">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Displacement Tool</Text>
@ -377,20 +399,6 @@
</Cell>
</Row>
<!-- Option: show playermat hider -->
<Row class="option-text"
tooltip="Use this tool to hide unused playermats&#xA;for more table space.">
<Cell class="option-text">
<Panel class="singleColumn-wrapper">
<Text class="option-header">Playmat Hider</Text>
</Panel>
</Cell>
<Cell class="option-button">
<Toggle id="showPlayermatHider"
onValueChanged="onClick_toggleOption(showPlayermatHider)"/>
</Cell>
</Row>
<!-- Option: show search assistant -->
<Row class="option-text"
tooltip="Quickly search 3, 6, 9 or the top X&#xA;cards of your deck!">

View File

@ -1,76 +0,0 @@
<Defaults>
<Text color="White"
fontSize="110"
alignment="MiddleLeft"
font="font_teutonic-arkham"/>
<Button fontSize="110"
height="200"
width="600"
hoverClass="bGrey"
pressClass="bWhite"
selectClass="bWhite"
color="#aaaaaa"
font="font_teutonic-arkham"/>
<Button class="bGrey"
color="grey"/>
<Button class="bWhite"
color="white"/>
<Button class="activeTab"
color="#ffffff"/>
<Row preferredHeight="300"/>
</Defaults>
<TableLayout height="1600"
width="1800"
columnWidths="1000 800"
rotation="0 0 180"
position="0 0 -11"
scale="0.1 0.1 0.1"
cellBackgroundColor="none">
<Row preferredHeight="400">
<Cell columnSpan="2">
<Text fontSize="200"
alignment="UpperCenter">Playermat Hider</Text>
</Cell>
</Row>
<Row>
<Cell>
<Text color="White">Playermat 1 (White)</Text>
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(White)">Show / Hide</Button>
</Panel>
</Cell>
</Row>
<Row>
<Cell>
<Text color="Orange">Playermat 2 (Orange)</Text>
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Orange)">Show / Hide</Button>
</Panel>
</Cell>
</Row>
<Row>
<Cell>
<Text color="Green">Playermat 3 (Green)</Text>
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Green)">Show / Hide</Button>
</Panel>
</Cell>
</Row>
<Row>
<Cell>
<Text color="Red">Playermat 4 (Red)</Text>
</Cell>
<Cell>
<Panel>
<Button onClick="onClick_hideShow(Red)">Show / Hide</Button>
</Panel>
</Cell>
</Row>
</TableLayout>