Skip to content

Commit

Permalink
Merge branch 'main' into action-tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
Chr1Z93 committed Nov 20, 2024
2 parents dc4c73b + e18d783 commit 5cbaa37
Show file tree
Hide file tree
Showing 22 changed files with 304 additions and 280 deletions.
49 changes: 9 additions & 40 deletions objects/FlexTableControl.bd69bd.ttslua
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
tableHeightOffset = -9

function onSave()
return JSON.encode({ tid = tableImageData, cd = checkData })
function updateSave()
self.script_state = JSON.encode({ tid = tableImageData, cd = checkData })
end

function onload(saved_data)
if saved_data ~= "" then
local loaded_data = JSON.decode(saved_data)
function onload(savedData)
if savedData and savedData ~= "" then
local loaded_data = JSON.decode(savedData)
tableImageData = loaded_data.tid
checkData = loaded_data.cd
else
tableImageData = {}
checkData = { move = false, scale = false }
updateSave()
end

--Disables interactable status of objects with GUID in list
Expand Down Expand Up @@ -83,6 +84,7 @@ function click_saveSurface(_, color)
if findInImageDataIndex(url, nickname) == nil then
--Save doesn't exist already
table.insert(tableImageData, { url = url, name = nickname })
updateSave()
broadcastToAll("Image URL saved to memory.", { 0.2, 0.9, 0.2 })
--Refresh buttons
self.clearButtons()
Expand Down Expand Up @@ -111,6 +113,7 @@ end
function click_deleteMemory(_, color, index)
if permissionCheck(color) then
table.remove(tableImageData, index)
updateSave()
self.clearButtons()
createOpenCloseButton()
createSurfaceButtons()
Expand Down Expand Up @@ -166,28 +169,10 @@ function click_checkMove(_, color)
local buttonEntry = findButton(self, find_func)
self.editButton({ index = buttonEntry.index, label = string.char(10008) })
end
updateSave()
end
end

--Checks/unchecks scale box for hands
--This button was disabled for technical reasons
--[[
function click_checkScale(_, color)
if permissionCheck(color) then
local find_func = function(o) return o.click_function=="click_checkScale" end
if checkData.scale == true then
checkData.scale = false
local buttonEntry = findButton(self, find_func)
self.editButton({index=buttonEntry.index, label=""})
else
checkData.scale = true
local buttonEntry = findButton(self, find_func)
self.editButton({index=buttonEntry.index, label=string.char(10008)})
end
end
end
]]

--Alters scale of elements and moves them
function changeTableScale(width, depth)
--Scaling factors used to translate scale to position offset
Expand Down Expand Up @@ -506,13 +491,6 @@ function createScaleButtons()
font_size = 200,
font_color = { 1, 1, 1 }
})
--Disabled due to me removing the feature for technical reasons
--[[
self.createButton({
label="Scale Hands:", click_function="none",
position={-8.3,0,4}, height=0, width=0, font_size=200, font_color={1,1,1}
})
]]
--Checkboxes
local label = ""
if checkData.move == true then label = string.char(10008) end
Expand All @@ -526,15 +504,6 @@ function createScaleButtons()
width = 224,
font_size = 200,
})
--[[
local label = ""
if checkData.scale == true then label = string.char(10008) end
self.createButton({
label=label, click_function="click_checkScale",
function_owner=self, tooltip="Check to scale the width of hands when table is rescaled",
position={-6.8,0,4}, height=224, width=224, font_size=200,
})
]]
--Apply button
self.createButton({
label = "Apply Scale",
Expand Down
2 changes: 1 addition & 1 deletion objects/PatchNotes.f47225.luascriptstate
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"tooltip": "None",
"value": [
"Arkham Horror LCG SCE 4.0.1 - 11/18/2024"
"Arkham Horror LCG SCE 4.0.1 - 11/20/2024"
]
},
{
Expand Down
13 changes: 5 additions & 8 deletions src/accessories/AdditionalVictoryPointsCard.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local MIN_VALUE = -10
local MAX_VALUE = 99
local vp, notes

function onSave()
return JSON.encode({ vp = vp, notes = notes })
function updateSave()
self.script_state = JSON.encode({ vp = vp, notes = notes })
end

function onLoad(savedData)
Expand All @@ -16,6 +16,7 @@ function onLoad(savedData)
else
vp = 1
notes = "Click to type"
updateSave()
end

createButtons()
Expand Down Expand Up @@ -52,17 +53,13 @@ function createTextbox()
})
end

function updateNotes()
function updateMetadata()
local md = JSON.decode(self.getGMNotes())
md.victory = vp
self.setGMNotes(JSON.encode(md))
victoryDisplayApi.update()
end

function updateSave()
self.script_state = JSON.encode({ vp = vp, notes = notes })
end

function input_function(_, _, inputValue, selected)
if selected == false then
notes = inputValue
Expand All @@ -74,5 +71,5 @@ function click_function(_, _, isRightClick)
vp = math.min(math.max(vp + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)
self.editButton({ index = 0, label = tostring(vp) })
updateSave()
updateNotes()
updateMetadata()
end
14 changes: 11 additions & 3 deletions src/accessories/TokenArranger.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ function loadData(loadedData)
includeDrawnTokens = loadedData.includeDrawnTokens

updateUI()
updateSave()
Wait.time(layout, 1.5)
end

-- saving the precedence settings and information on the most recently loaded data
function onSave()
return JSON.encode(getSaveData())
function updateSave()
self.script_state = JSON.encode(getSaveData())
end

-- loading data, button creation and initial layouting
Expand Down Expand Up @@ -104,6 +105,7 @@ function onLoad(savedData)
includeDrawnTokens = not includeDrawnTokens
local text = includeDrawnTokens and " " or " not "
broadcastToAll("Token Arranger will" .. text .. "include currently drawn chaos tokens.", "Orange")
updateSave()
layout()
end)

Expand All @@ -114,6 +116,7 @@ function onLoad(savedData)
percentage = "basic"
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
end
updateSave()
layout()
end)

Expand All @@ -124,6 +127,7 @@ function onLoad(savedData)
percentage = "cumulative"
end
broadcastToAll("Percentages are unreliable when using tokens that draw other tokens (bless or curse for example).", "Yellow")
updateSave()
layout()
end)
end
Expand All @@ -145,6 +149,7 @@ function tokenClick(isRightClick, index)
index = index - 1,
value = tokenPrecedence[TOKEN_NAMES[index]][1]
})
updateSave()
layout()
end

Expand All @@ -154,8 +159,9 @@ function tokenInput(input, selected, index)
local num = tonumber(input)
if num ~= nil then
tokenPrecedence[TOKEN_NAMES[index]][1] = num
updateSave()
layout()
end
layout()
end
end

Expand All @@ -175,6 +181,7 @@ function loadDefaultValues()
["Frost"] = { -105, 10},
[""] = { 0, 11}
}
updateSave()
end

-- creates buttons and inputs
Expand Down Expand Up @@ -422,5 +429,6 @@ function onTokenDataChanged(parameters)
end

updateUI()
updateSave()
layout()
end
32 changes: 0 additions & 32 deletions src/core/DataHelper.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,6 @@ modeData = {
}
}

function onSave()
return JSON.encode(SPAWNED_PLAYER_CARD_GUIDS)
end

function onLoad(savedData)
if savedData and savedData ~= '' then
SPAWNED_PLAYER_CARD_GUIDS = JSON.decode(savedData)
else
SPAWNED_PLAYER_CARD_GUIDS = {}
end
end

function getSpawnedPlayerCardGuid(params)
local guid = params[1]
if SPAWNED_PLAYER_CARD_GUIDS == nil then
return nil
else
return SPAWNED_PLAYER_CARD_GUIDS[guid]
end
end

function setSpawnedPlayerCardGuid(params)
local guid = params[1]
local value = params[2]
if SPAWNED_PLAYER_CARD_GUIDS ~= nil then
SPAWNED_PLAYER_CARD_GUIDS[guid] = value
return true
else
return false
end
end

-- called by "Global" during encounter card drawing
function checkHiddenCard(name)
for _, n in ipairs(HIDDEN_CARD_DATA) do
Expand Down
5 changes: 4 additions & 1 deletion src/core/GUIDReferenceHandler.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ local editsToIndex = {
}

-- save function to keep edits to the index
function onSave() return JSON.encode({ editsToIndex = editsToIndex }) end
function updateSave()
self.script_state = JSON.encode({ editsToIndex = editsToIndex })
end

-- load function to restore edits to the index
function onLoad(savedData)
Expand Down Expand Up @@ -165,6 +167,7 @@ function editIndex(params)
else
editsToIndex[params.owner] = nil
end
updateSave()
updateMainIndex()
end

Expand Down
25 changes: 1 addition & 24 deletions src/core/GameKeyHandler.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,6 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
return
end

-- initialize list of objects to move (and store local position + rotation)
local additionalObjects = {}
for _, obj in ipairs(searchLib.onObject(hoveredObject, "isTileOrToken")) do
if not obj.locked then
local data = {
object = obj,
localPos = hoveredObject.positionToLocal(obj.getPosition()),
localRot = obj.getRotation() - cardRot
}
table.insert(additionalObjects, data)
end
end

-- get the rotation of the owning playermat (or Mythos)
local cardOwner = guidReferenceApi.getOwnerOfObject(hoveredObject)
local ownerRotation = Vector(0, 270, 0)
Expand All @@ -101,17 +88,7 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
local newCardRot = cardRot:setAt("y", matRotation.y + cardRot.y - ownerRotation.y)

-- move the main card to threat area
hoveredObject.setRotation(newCardRot)
hoveredObject.setPosition(threatAreaPos)

-- move tokens/tiles (to new global position)
for _, data in ipairs(additionalObjects) do
data.object.setPosition(hoveredObject.positionToWorld(data.localPos))

local newRot = data.localRot + Vector(0, newCardRot.y, 0)
newRot.y = roundToMultiple(newRot.y, 45)
data.object.setRotation(newRot)
end
GlobalApi.moveCardWithTokens(hoveredObject, threatAreaPos, newCardRot)

-- contruct feedback message (hide name when face-down + enabled setting)
local cardName = hoveredObject.getName()
Expand Down
Loading

0 comments on commit 5cbaa37

Please sign in to comment.