Fix visibility handling for Tour cards
Panel visibility isn't inhered by the children, so each element in the panel has to have the visibility set directly.
This commit is contained in:
parent
1c3260edf3
commit
bdadfdcc9f
@ -179,19 +179,33 @@ do
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor)
|
tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor)
|
||||||
tourCardTemplate.attributes.visibility = playerColor
|
|
||||||
tourCardTemplate.children[1].attributes.id = internal.getUiId(NARRATOR_ID, playerColor)
|
tourCardTemplate.children[1].attributes.id = internal.getUiId(NARRATOR_ID, playerColor)
|
||||||
tourCardTemplate.children[2].children[1].attributes.id = internal.getUiId(TEXT_ID, playerColor)
|
tourCardTemplate.children[2].children[1].attributes.id = internal.getUiId(TEXT_ID, playerColor)
|
||||||
tourCardTemplate.children[3].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)
|
tourCardTemplate.children[3].attributes.id = internal.getUiId(NEXT_BUTTON_ID, playerColor)
|
||||||
tourCardTemplate.children[4].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)
|
|
||||||
tourCardTemplate.children[3].attributes.onClick = self.getGUID().."/nextCard"
|
tourCardTemplate.children[3].attributes.onClick = self.getGUID().."/nextCard"
|
||||||
|
tourCardTemplate.children[4].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor)
|
||||||
tourCardTemplate.children[4].attributes.onClick = self.getGUID().."/stopTour"
|
tourCardTemplate.children[4].attributes.onClick = self.getGUID().."/stopTour"
|
||||||
|
internal.setDeepVisibility(tourCardTemplate, playerColor)
|
||||||
|
|
||||||
local globalXml = Global.UI.getXmlTable()
|
local globalXml = Global.UI.getXmlTable()
|
||||||
table.insert(globalXml, tourCardTemplate)
|
table.insert(globalXml, tourCardTemplate)
|
||||||
Global.UI.setXmlTable(globalXml)
|
Global.UI.setXmlTable(globalXml)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Panels don't cause their children to inherit their visibility value, so this recurses down the
|
||||||
|
-- XML table to set all children to the same visibility.
|
||||||
|
---@param xmlUi Table. Lua table describing the XML
|
||||||
|
---@param playerColor String. String color of the player to make this visible for
|
||||||
|
internal.setDeepVisibility = function(xmlUi, playerColor)
|
||||||
|
xmlUi.attributes.visibility = "" .. playerColor
|
||||||
|
log(xmlUi.attributes.id)
|
||||||
|
if xmlUi.children ~= nil then
|
||||||
|
for _, child in ipairs(xmlUi.children) do
|
||||||
|
internal.setDeepVisibility(child, playerColor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
internal.getUiId = function(baseId, playerColor)
|
internal.getUiId = function(baseId, playerColor)
|
||||||
return baseId .. "_" .. playerColor
|
return baseId .. "_" .. playerColor
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user