Merge branch 'main' into taboo-2.3

This commit is contained in:
Chr1Z93 2024-11-13 18:46:01 +01:00
commit 0773605be0
8 changed files with 141 additions and 120 deletions

View File

@ -8,7 +8,7 @@
"combatIcons": 2,
"agilityIcons": 3,
"cycle": "Bad Blood",
"extraToken": "Reaction",
"extraToken": "None",
"signatures": [
{
"01012": 1,

View File

@ -54,7 +54,6 @@ function updateValue()
local hand = Player[handColor].getHandObjects()
local size = 0
for _, obj in pairs(hand) do
if obj.type == "Card" then
size = size + 1
@ -64,4 +63,3 @@ function updateValue()
-- update button label and color
self.editButton({ index = 0, font_color = "White", label = size })
end

View File

@ -4,12 +4,11 @@ atttempt to spawn clues, first we look for <LOCATION_NAME>_<GUID> and if
we find nothing we look for <LOCATION_NAME>
format is [location_guid -> clueCount]
]]
LOCATIONS_DATA_JSON = [[
{
LOCATIONS_DATA_JSON = [[{
"San Francisco": {"type": "fixed", "value": 1, "clueSide": "back"},
" Arkham": {"type": "perPlayer", "value": 1, "clueSide": "back"},
"Arkham": {"type": "perPlayer", "value": 1, "clueSide": "back"},
"Buenos Aires": {"type": "fixed", "value": 2, "clueSide": "back"},
" London": {"type": "perPlayer", "value": 2, "clueSide": "front"},
"London": {"type": "perPlayer", "value": 2, "clueSide": "front"},
"Rome": {"type": "perPlayer", "value": 3, "clueSide": "front"},
"Istanbul": {"type": "perPlayer", "value": 4, "clueSide": "front"},
"Tokyo_123abc": {"type": "perPlayer", "value": 0, "clueSide": "back"},
@ -17,30 +16,14 @@ LOCATIONS_DATA_JSON = [[
"Tokyo": {"type": "fixed", "value": 2, "clueSide": "back"},
"Shanghai_123": {"type": "fixed", "value": 12, "clueSide": "front"},
"Sydney": {"type": "fixed", "value": 0, "clueSide": "front"}
}
]]
}]]
PLAYER_CARD_DATA_JSON = [[
{
"Tool Belt": {
"tokenType": "resource",
"tokenCount": 2
},
"Tool Belt (3)": {
"tokenType": "resource",
"tokenCount": 4
},
"Yithian Rifle": {
"tokenType": "resource",
"tokenCount": 3
},
PLAYER_CARD_DATA_JSON = [[{
"xxx": {
"tokenType": "resource",
"tokenCount": 3
}
}
]]
}]]
HIDDEN_CARD_DATA = {
"Unpleasant Card (Doom)",
@ -54,14 +37,14 @@ PLAYER_CARD_DATA = JSON.decode(PLAYER_CARD_DATA_JSON)
function onload(save_state)
local playArea = getObjectFromGUID('721ba2')
playArea.call("updateLocations", {self.getGUID()})
local playerMatWhite = getObjectFromGUID('8b081b')
playerMatWhite.call("updatePlayerCards", {self.getGUID()})
local playerMatOrange = getObjectFromGUID('bd0ff4')
playerMatOrange.call("updatePlayerCards", {self.getGUID()})
local playerMatGreen = getObjectFromGUID('383d8b')
playerMatGreen.call("updatePlayerCards", {self.getGUID()})
local playerMatRed = getObjectFromGUID('0840d5')
playerMatRed.call("updatePlayerCards", {self.getGUID()})
for _, guid in ipairs({ '8b081b', 'bd0ff4', '383d8b', '0840d5'}) do
local mat = getObjectFromGUID(guid)
if mat ~= nil then
mat.call("updatePlayerCards", {self.getGUID()})
end
end
local dataHelper = getObjectFromGUID('708279')
dataHelper.call("updateHiddenCards", {self.getGUID()})
end

View File

@ -41,7 +41,7 @@ end
function toggleSubtractDoom(override)
local previousState = subtractDoom
if override then
if override ~= nil then
subtractDoom = override
else
subtractDoom = not subtractDoom

View File

@ -248,6 +248,8 @@ function addContextMenu()
end
end)
end)
self.addContextMenuItem("Randomize", randomize)
end
function updateClass(newClass)
@ -292,7 +294,7 @@ function isClassName(str)
return false
end
function onRandomize()
function randomize()
local newSymbol = listOfSymbols[math.random(1, #listOfSymbols)]
while newSymbol == "None" do

View File

@ -29,7 +29,7 @@ customizations = {
[4] = {
checkboxes = {
posZ = -0.092,
count = 2,
count = 1,
}
},
[5] = {

View File

@ -1,6 +1,6 @@
-- Common code for handling customizable card upgrade sheets
-- Define UI elements in the base card file, then include this
-- UI element definition is an array of tables, each with this structure. A row may include
-- UI element definition is an array of tables, each with this structure. A row may include
-- checkboxes (number defined by count), a text field, both, or neither (if the row has custom
-- handling, as Living Ink does)
-- {
@ -19,15 +19,16 @@
-- selectedUpgrades holds the state of checkboxes and text input, each element being:
-- selectedUpgrades[row] = { xp = #, text = "" }
local playermatApi = require("playermat/PlayermatApi")
local playermatApi = require("playermat/PlayermatApi")
-- Y position for UI elements. Visibility of checkboxes moves the checkbox inside the card object
-- when not selected.
local Y_VISIBLE = 0.25
local Y_INVISIBLE = -0.5
-- Y position for UI elements
local Y_VISIBLE = 0.25
-- Variable to check whether UI finished loading
local isLoading = true
-- Used for Summoned Servitor and Living Ink
local VECTOR_COLOR = {
local VECTOR_COLOR = {
unselected = { 0.5, 0.5, 0.5, 0.75 },
mystic = { 0.597, 0.195, 0.796 }
}
@ -35,17 +36,11 @@ local VECTOR_COLOR = {
-- These match with ArkhamDB's way of storing the data in the dropdown menu
local SUMMONED_SERVITOR_SLOT_INDICES = { arcane = "1", ally = "0", none = "" }
local rowCheckboxFirstIndex = { }
local rowInputIndex = { }
local selectedUpgrades = { }
local rowCheckboxFirstIndex = {}
local selectedUpgrades = {}
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave()
return JSON.encode({
selections = selectedUpgrades
})
function updateSave()
self.script_state = JSON.encode({ selections = selectedUpgrades })
end
-- Startup procedure
@ -60,6 +55,22 @@ function onLoad(savedData)
selfId = getSelfId()
maybeLoadLivingInkSkills()
xmlTable = {
{
tag = "Defaults",
children = {
{
tag = "Button",
attributes = {
color = "#48b028",
height = 70,
width = 70,
scale = "0.1 0.1 0.1",
}
}
}
}
}
createUi()
maybeUpdateLivingInkSkillDisplay()
maybeUpdateServitorSlotDisplay()
@ -87,7 +98,8 @@ function isUpgradeActive(row)
end
function resetSelections()
selectedUpgrades = { }
selectedUpgrades = {}
updateSave()
updateDisplay()
end
@ -103,6 +115,7 @@ function createUi()
createRowTextField(i)
end
end
self.UI.setXmlTable(xmlTable)
maybeMakeLivingInkSkillSelectionButtons()
maybeMakeServitorSlotSelectionButtons()
updateDisplay()
@ -120,54 +133,57 @@ function createRowCheckboxes(rowIndex)
local func = function() clickCheckbox(rowIndex, col) end
self.setVar(funcName, func)
local checkboxPos = getCheckboxPosition(rowIndex, col)
self.createButton({
click_function = funcName,
function_owner = self,
position = checkboxPos,
height = boxSize * 10,
width = boxSize * 10,
font_size = 1000,
scale = { 0.1, 0.1, 0.1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
local identifier = tostring(rowIndex) .. " " .. tostring(col)
local newCheckbox = {
tag = "Button",
attributes = {
onClick = funcName,
position = checkboxPos,
id = identifier,
}
}
table.insert(xmlTable, newCheckbox)
end
end
function getCheckboxPosition(row, col)
return {
x = xInitial + col * xOffset,
y = Y_VISIBLE,
z = customizations[row].checkboxes.posZ
}
return translatePosition(xInitial + col * xOffset, customizations[row].checkboxes.posZ)
end
function createRowTextField(rowIndex)
local textField = customizations[rowIndex].textField
rowInputIndex[rowIndex] = 0
local previousInputs = self.getInputs()
if previousInputs ~= nil then
rowInputIndex[rowIndex] = #previousInputs
end
local funcName = "textbox" .. rowIndex
local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end
local func = function(player, value) clickTextbox(rowIndex, value) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = textField.position,
scale = { 0.1, 0.1, 0.1 },
width = textField.width * 10,
height = inputFontsize * 10 + 75,
font_size = inputFontsize * 10.5,
color = "White",
value = ""
})
local actualPosition = translatePosition(textField.position[1], textField.position[3])
local newTextbox = {
tag = "InputField",
attributes = {
onEndEdit = funcName,
id = rowIndex,
placeholder = "Click to type",
position = actualPosition,
alignment = "UpperLeft",
width = textField.width,
height = (inputFontsize + 15),
fontSize = inputFontsize,
resizeTextForBestFit = true,
fontStyle = "Bold",
rotation = "0 0 180",
scale = "0.2 0.2 0.2",
color = "#FFFFFF",
}
}
table.insert(xmlTable, newTextbox)
end
function translatePosition(posX, posZ)
-- position values are made strings to be usabled by the XML, height (z) is always -22
local translatedPosX = tostring(posX * -100)
local translatedPosY = tostring(posZ * 100)
local combinedPos = translatedPosX .. " " .. translatedPosY .. " -22"
return combinedPos
end
function updateDisplay()
@ -195,33 +211,45 @@ function updateCheckboxes(rowIndex)
end
local checkboxIndex = rowCheckboxFirstIndex[rowIndex]
for col = 1, checkboxCount do
local pos = getCheckboxPosition(rowIndex, col)
if col <= selected then
pos.y = Y_VISIBLE
local identifier = tostring(rowIndex) .. " " .. tostring(col)
waitForUILoad(identifier, "color", "#000000")
else
pos.y = Y_INVISIBLE
local identifier = tostring(rowIndex) .. " " .. tostring(col)
waitForUILoad(identifier, "color", "#48b02800")
end
self.editButton({
index = checkboxIndex,
position = pos
})
checkboxIndex = checkboxIndex + 1
end
end
function updateTextField(rowIndex)
local inputIndex = rowInputIndex[rowIndex]
if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then
self.editInput({
index = inputIndex,
value = " " .. selectedUpgrades[rowIndex].text
})
waitForUILoad(rowIndex, "text", selectedUpgrades[rowIndex].text)
end
end
function waitForUILoad(id, attribute, value)
if isLoading then
Wait.condition(
function()
Wait.frames(
function()
isLoading = false
self.UI.setAttribute(id, attribute, value)
end,
1
)
end,
function() return not self.UI.loading end
)
else
self.UI.setAttribute(id, attribute, value)
end
end
function clickCheckbox(row, col)
if selectedUpgrades[row] == nil then
selectedUpgrades[row] = { }
selectedUpgrades[row] = {}
selectedUpgrades[row].xp = 0
end
if selectedUpgrades[row].xp == col then
@ -230,19 +258,19 @@ function clickCheckbox(row, col)
selectedUpgrades[row].xp = col
end
updateCheckboxes(row)
updateSave()
playermatApi.syncAllCustomizableCards()
end
-- Updates saved value for given text box when it loses focus
function clickTextbox(rowIndex, value, selected)
if selected == false then
if selectedUpgrades[rowIndex] == nil then
selectedUpgrades[rowIndex] = { }
end
selectedUpgrades[rowIndex].text = value:gsub("^%s*(.-)%s*$", "%1")
-- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished
Wait.frames(function() updateRowDisplay(rowIndex) end, 1)
function clickTextbox(rowIndex, value)
if selectedUpgrades[rowIndex] == nil then
selectedUpgrades[rowIndex] = {}
end
selectedUpgrades[rowIndex].text = value:gsub("^%s*(.-)%s*$", "%1")
updateSave()
-- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished
Wait.frames(function() updateRowDisplay(rowIndex) end, 1)
end
---------------------------------------------------------
@ -310,12 +338,13 @@ function updateSelectedLivingInkSkillText()
skillString = skillString .. "agility" .. ","
end
if selectedUpgrades[1] == nil then
selectedUpgrades[1] = { }
selectedUpgrades[1] = {}
end
selectedUpgrades[1].text = skillString
updateSave()
end
-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of
-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of
-- vectors set, have to refresh all 4 at once
function maybeUpdateLivingInkSkillDisplay()
if selfId ~= "09079-c" then return end
@ -377,26 +406,28 @@ end
-- toggles the clicked slot
function clickArcane()
if selectedUpgrades[6] == nil then
selectedUpgrades[6] = { }
selectedUpgrades[6] = {}
end
if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.arcane then
selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none
else
selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.arcane
end
updateSave()
maybeUpdateServitorSlotDisplay()
end
-- toggles the clicked slot
function clickAlly()
if selectedUpgrades[6] == nil then
selectedUpgrades[6] = { }
selectedUpgrades[6] = {}
end
if selectedUpgrades[6].text == SUMMONED_SERVITOR_SLOT_INDICES.ally then
selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.none
else
selectedUpgrades[6].text = SUMMONED_SERVITOR_SLOT_INDICES.ally
end
updateSave()
maybeUpdateServitorSlotDisplay()
end
@ -404,7 +435,7 @@ end
function maybeUpdateServitorSlotDisplay()
if selfId ~= "09080-c" then return end
local center = SLOT_ICON_POSITIONS["arcane"]
local center = SLOT_ICON_POSITIONS["arcane"]
local arcaneVecList = {
Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),
Vector(center.x - 0.12, Y_VISIBLE, center.z + 0.05),
@ -413,7 +444,7 @@ function maybeUpdateServitorSlotDisplay()
Vector(center.x + 0.12, Y_VISIBLE, center.z + 0.05),
}
center = SLOT_ICON_POSITIONS["ally"]
center = SLOT_ICON_POSITIONS["ally"]
local allyVecList = {
Vector(center.x + 0.07, Y_VISIBLE, center.z + 0.05),
Vector(center.x - 0.07, Y_VISIBLE, center.z + 0.05),

View File

@ -406,7 +406,14 @@ do
for guid, pos in pairs(storedPositions) do
local obj = getObjectFromGUID(guid)
obj.setPosition(mat.positionToWorld(pos))
obj.setRotation(obj.getRotation():setAt("y", rotationY))
-- offset the rotation by 180 degrees if the guid matches the player hand zones
local finalRotationY = rotationY
if obj.type == "Hand" then
finalRotationY = rotationY + 180
end
obj.setRotation(obj.getRotation():setAt("y", finalRotationY))
end
end