From bdadfdcc9f62e4218a586f36ee5553e4188501e3 Mon Sep 17 00:00:00 2001 From: Buhallin Date: Wed, 14 Dec 2022 23:18:58 -0800 Subject: [PATCH] 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. --- src/core/tour/TourManager.ttslua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index 7a63d999..834c3570 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -179,19 +179,33 @@ do return end tourCardTemplate.attributes.id = internal.getUiId(CARD_ID, playerColor) - tourCardTemplate.attributes.visibility = 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[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[4].attributes.id = internal.getUiId(STOP_BUTTON_ID, playerColor) tourCardTemplate.children[4].attributes.onClick = self.getGUID().."/stopTour" + internal.setDeepVisibility(tourCardTemplate, playerColor) local globalXml = Global.UI.getXmlTable() table.insert(globalXml, tourCardTemplate) Global.UI.setXmlTable(globalXml) 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) return baseId .. "_" .. playerColor end