2nd step of GlobalApi
This commit is contained in:
parent
82344361df
commit
513749427b
@ -1,7 +1,12 @@
|
||||
local GlobalApi = require("core/GlobalApi")
|
||||
|
||||
function onLoad()
|
||||
self.addContextMenuItem("Download", download)
|
||||
end
|
||||
|
||||
function download(playerColor)
|
||||
Global.call('placeholder_download', { url = self.getGMNotes(), player = Player[playerColor], replace = self.guid })
|
||||
local url = self.getGMNotes()
|
||||
local player = Player[playerColor]
|
||||
local replace = self.guid
|
||||
GlobalApi.placeholderDownload(url, player, replace)
|
||||
end
|
||||
|
@ -67,6 +67,23 @@ do
|
||||
return Global.call("canTouchChaosTokens")
|
||||
end
|
||||
|
||||
ChaosBagApi.activeRedrawEffect = function(validTokens, invalidTokens, returnToPool, drawSpecificToken)
|
||||
Global.call("activeRedrawEffect", {
|
||||
validTokens = validTokens,
|
||||
invalidTokens = invalidTokens,
|
||||
returnToPool = returnToPool,
|
||||
drawSpecificToken = drawSpecificToken
|
||||
})
|
||||
end
|
||||
|
||||
ChaosBagApi.getReadableTokenName = function(tokenName)
|
||||
return Global.call("getReadableTokenName", tokenName)
|
||||
end
|
||||
|
||||
ChaosBagApi.getChaosTokenName = function(chosenToken)
|
||||
return Global.call("getChaosTokenName", chosenToken)
|
||||
end
|
||||
|
||||
-- draws a chaos token to a playermat
|
||||
---@param mat tts__Object Playermat that triggered this
|
||||
---@param drawAdditional boolean Controls whether additional tokens should be drawn
|
||||
|
@ -1226,11 +1226,6 @@ function changeWindowVisibilityForColor(color, windowId, overrideState, owner)
|
||||
return visible
|
||||
end
|
||||
|
||||
-- forwards the call to the onClick function
|
||||
function togglePlayAreaGallery(playerColor)
|
||||
changeWindowVisibilityForColor(playerColor, "playareaGallery")
|
||||
end
|
||||
|
||||
-- updates the preview window
|
||||
function updatePreviewWindow()
|
||||
local item = library[contentToShow][currentListItem]
|
||||
|
@ -13,6 +13,18 @@ do
|
||||
Global.call("titleSplash", scenarioName)
|
||||
end
|
||||
|
||||
function GlobalApi.changeWindowVisibility(playerColor, windowId, owner)
|
||||
Global.call("changeWindowVisibilityForColorWrapper", {
|
||||
color = playerColor,
|
||||
windowId = windowId,
|
||||
owner = owner
|
||||
})
|
||||
end
|
||||
|
||||
function GlobalApi.updateGlobalXml(globalXml)
|
||||
Global.call("updateGlobalXml", globalXml)
|
||||
end
|
||||
|
||||
-- loads saved options
|
||||
---@param options table Set a new state for the option table
|
||||
function GlobalApi.loadOptionPanelSettings(options)
|
||||
|
@ -33,7 +33,7 @@ end
|
||||
|
||||
-- click function for main button
|
||||
function onClick_toggleGallery(_, playerColor)
|
||||
Global.call("togglePlayAreaGallery", playerColor)
|
||||
GlobalApi.changeWindowVisibility(playerColor, "playareaGallery")
|
||||
end
|
||||
|
||||
function getDataSubTableByIndex(dataTable, index)
|
||||
@ -96,7 +96,7 @@ function updatePlayAreaGallery()
|
||||
end
|
||||
|
||||
playareaList.attributes.height = round(#playareaList.children / 2, 0) * 380
|
||||
Global.call("updateGlobalXml", globalXml)
|
||||
GlobalApi.updateGlobalXml(globalXml)
|
||||
Wait.time(highlightTabAndItem, 0.1)
|
||||
end
|
||||
|
||||
@ -117,7 +117,7 @@ function onClick_image(player, _, id)
|
||||
local dataForSelection = getDataSubTableByIndex(dataForType, selectionIndex)
|
||||
local newURL = dataForSelection[imageIndex].URL
|
||||
playAreaApi.updateSurface(newURL)
|
||||
Global.call("togglePlayAreaGallery", player.color)
|
||||
GlobalApi.changeWindowVisibility(player.color, "playareaGallery")
|
||||
end
|
||||
|
||||
function highlightTabAndItem()
|
||||
|
@ -51,6 +51,8 @@ As a nice reminder the XML button takes on the Frost color and icon with the tex
|
||||
> require...
|
||||
----------------------------------------------------------]]
|
||||
|
||||
local chaosBagApi = require("chaosBag/ChaosBagApi")
|
||||
|
||||
-- intentionally global
|
||||
hasXML = true
|
||||
isHelperEnabled = false
|
||||
@ -97,9 +99,5 @@ function createHelperXML()
|
||||
end
|
||||
|
||||
function triggerXMLTokenLabelCreation()
|
||||
Global.call("activeRedrawEffect", {
|
||||
VALID_TOKENS = VALID_TOKENS,
|
||||
INVALID_TOKENS = INVALID_TOKENS,
|
||||
RETURN_TO_POOL = RETURN_TO_POOL
|
||||
})
|
||||
chaosBagApi.activeRedrawEffect(VALID_TOKENS, INVALID_TOKENS, RETURN_TO_POOL)
|
||||
end
|
||||
|
@ -1,22 +1,21 @@
|
||||
require("playercards/CardsWithHelper")
|
||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||
|
||||
-- intentionally global
|
||||
hasXML = false
|
||||
isHelperEnabled = false
|
||||
|
||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||
hasXML = false
|
||||
isHelperEnabled = false
|
||||
|
||||
-- XML background color for each token
|
||||
local tokenColor = {
|
||||
["Skull"] = "#4A0400E6",
|
||||
["Cultist"] = "#173B0BE6",
|
||||
["Tablet"] = "#1D2238E6",
|
||||
["Skull"] = "#4A0400E6",
|
||||
["Cultist"] = "#173B0BE6",
|
||||
["Tablet"] = "#1D2238E6",
|
||||
["Elder Thing"] = "#4D2331E6",
|
||||
["Auto-fail"] = "#9B0004E6",
|
||||
["Bless"] = "#9D702CE6",
|
||||
["Curse"] = "#633A84E6",
|
||||
["Frost"] = "#404450E6",
|
||||
[""] = "#77674DE6"
|
||||
["Auto-fail"] = "#9B0004E6",
|
||||
["Bless"] = "#9D702CE6",
|
||||
["Curse"] = "#633A84E6",
|
||||
["Frost"] = "#404450E6",
|
||||
[""] = "#77674DE6"
|
||||
}
|
||||
|
||||
function updateSave()
|
||||
@ -42,7 +41,7 @@ end
|
||||
|
||||
function makeXMLButton()
|
||||
-- get name of the icon for the sigil ("token" + lowercase name without space characters)
|
||||
local sigilName = Global.call("getReadableTokenName", sigil)
|
||||
local sigilName = chaosBagApi.getReadableTokenName(sigil)
|
||||
local iconName = "token-" .. string.lower(sigilName)
|
||||
iconName = iconName:gsub("%s", "-")
|
||||
|
||||
@ -109,13 +108,13 @@ function chooseSigil(player)
|
||||
-- get list of readable names
|
||||
local readableNames = {}
|
||||
for token, _ in pairs(tokenColor) do
|
||||
table.insert(readableNames, Global.call("getReadableTokenName", token))
|
||||
table.insert(readableNames, chaosBagApi.getReadableTokenName(token))
|
||||
end
|
||||
|
||||
-- prompt player to choose sigil
|
||||
player.showOptionsDialog("Choose Sigil", readableNames, 1,
|
||||
function(chosenToken)
|
||||
sigil = Global.call("getChaosTokenName", chosenToken)
|
||||
sigil = chaosBagApi.getChaosTokenName(chosenToken)
|
||||
makeXMLButton()
|
||||
end
|
||||
)
|
||||
@ -139,16 +138,14 @@ function resolveSigil()
|
||||
end
|
||||
|
||||
if not match then
|
||||
broadcastToAll(Global.call("getReadableTokenName", sigil) .. " not found in chaos bag", "Red")
|
||||
broadcastToAll(chaosBagApi.getReadableTokenName(sigil) .. " not found in chaos bag", "Red")
|
||||
return
|
||||
end
|
||||
|
||||
Global.call("activeRedrawEffect", {
|
||||
DRAW_SPECIFIC_TOKEN = sigil,
|
||||
VALID_TOKENS = {
|
||||
["Tablet"] = true,
|
||||
["Elder Thing"] = true,
|
||||
["Cultist"] = true
|
||||
}
|
||||
})
|
||||
local VALID_TOKENS = {
|
||||
["Tablet"] = true,
|
||||
["Elder Thing"] = true,
|
||||
["Cultist"] = true
|
||||
}
|
||||
chaosBagApi.activeRedrawEffect(VALID_TOKENS, _, _, sigil)
|
||||
end
|
||||
|
@ -1,5 +1,6 @@
|
||||
local chaosBagApi = require("chaosbag/ChaosBagApi")
|
||||
local deckLib = require("util/DeckLib")
|
||||
local GlobalApi = require("core/GlobalApi")
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local mythosAreaApi = require("core/MythosAreaApi")
|
||||
local navigationOverlayApi = require("core/NavigationOverlayApi")
|
||||
@ -916,11 +917,7 @@ function createXML()
|
||||
end
|
||||
|
||||
function onClick_hideOrShowOptions(player)
|
||||
Global.call("changeWindowVisibilityForColorWrapper", {
|
||||
color = player.color,
|
||||
windowId = "optionPanelMain",
|
||||
owner = self
|
||||
})
|
||||
GlobalApi.changeWindowVisibility(player.color, "optionPanelMain", self)
|
||||
end
|
||||
|
||||
function onClick_textureSelect(player)
|
||||
@ -950,16 +947,8 @@ function onClick_handColorSelect(player)
|
||||
handZone.setValue(newColor)
|
||||
|
||||
-- update visibility for old and new color
|
||||
Global.call("changeWindowVisibilityForColorWrapper", {
|
||||
color = playerColor,
|
||||
windowId = "optionPanelMain",
|
||||
owner = self
|
||||
})
|
||||
Global.call("changeWindowVisibilityForColorWrapper", {
|
||||
color = newColor,
|
||||
windowId = "optionPanelMain",
|
||||
owner = self
|
||||
})
|
||||
GlobalApi.changeWindowVisibility(playerColor, "optionPanelMain", self)
|
||||
GlobalApi.changeWindowVisibility(newColor, "optionPanelMain", self)
|
||||
navigationOverlayApi.copyVisibility(playerColor, newColor)
|
||||
|
||||
-- if there was a seated player, reseat to the new color
|
||||
|
Loading…
x
Reference in New Issue
Block a user