Skip to content

Commit

Permalink
Fixed issue where tooltips would show the card's face up image even i…
Browse files Browse the repository at this point in the history
…f the card was flipped face down.
  • Loading branch information
Gtaray committed May 22, 2023
1 parent bacb5e5 commit 022f5aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/card_tooltip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
<sizelimits>
<dynamic />
</sizelimits>
<script file="common/scripts/card_tooltip.lua" />
<sheetdata>
<tokenfield name="image">
<tokencontrol name="image">
<anchored>
<top />
<left />
<right />
<bottom />
</anchored>
</tokenfield>
</tokencontrol>
</sheetdata>
</windowclass>
</root>
22 changes: 22 additions & 0 deletions common/scripts/card_tooltip.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function onInit()
DB.addHandler(DB.getPath(getDatabaseNode(), CardsManager.CARD_FACING_PATH), "onUpdate", updateToken);
updateToken();
end

function onClose()
DB.removeHandler(DB.getPath(getDatabaseNode(), CardsManager.CARD_FACING_PATH), "onUpdate", updateToken);
end

function updateToken()
local node = getDatabaseNode();

if not node then
return;
end

if CardsManager.isCardFaceUp(node) then
image.setPrototype(CardsManager.getCardFront(node));
else
image.setPrototype(CardsManager.getCardBack(node));
end
end

0 comments on commit 022f5aa

Please sign in to comment.