From 6f9d7eeefc2071da3a1a767e81fcd7ffee0b4bdf Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Wed, 18 Sep 2024 20:52:24 +0200 Subject: [PATCH] Added discard shuffle button --- modsettings/CustomUIAssets.json | 5 +++++ objects/Playermat1White.8b081b.json | 22 ---------------------- objects/Playermat2Orange.bd0ff4.json | 22 ---------------------- objects/Playermat3Green.383d8b.json | 22 ---------------------- objects/Playermat4Red.0840d5.json | 22 ---------------------- src/playermat/Playermat.ttslua | 22 +++++++++++++++++----- src/util/DeckLib.ttslua | 12 +++++++++--- 7 files changed, 31 insertions(+), 96 deletions(-) diff --git a/modsettings/CustomUIAssets.json b/modsettings/CustomUIAssets.json index b31c01af..ade19e65 100644 --- a/modsettings/CustomUIAssets.json +++ b/modsettings/CustomUIAssets.json @@ -34,6 +34,11 @@ "Type": 0, "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" }, + { + "Name": "shuffle", + "Type": 0, + "URL": "https://steamusercontent-a.akamaihd.net/ugc/2450610458447905243/AFDBF9BA4702899973FD5A5E7544C6E3F81E1366/" + }, { "Name": "option_on", "Type": 0, diff --git a/objects/Playermat1White.8b081b.json b/objects/Playermat1White.8b081b.json index 744fecd8..98effb33 100644 --- a/objects/Playermat1White.8b081b.json +++ b/objects/Playermat1White.8b081b.json @@ -342,28 +342,6 @@ "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, - "CustomUIAsset": [ - { - "Name": "option_on", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" - }, - { - "Name": "option_off", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" - }, - { - "Name": "option_button", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" - }, - { - "Name": "option_gear_white", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" - } - ], "Description": "", "DragSelectable": true, "GMNotes": "", diff --git a/objects/Playermat2Orange.bd0ff4.json b/objects/Playermat2Orange.bd0ff4.json index c17bef2c..61cd2b82 100644 --- a/objects/Playermat2Orange.bd0ff4.json +++ b/objects/Playermat2Orange.bd0ff4.json @@ -342,28 +342,6 @@ "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, - "CustomUIAsset": [ - { - "Name": "option_on", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" - }, - { - "Name": "option_off", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" - }, - { - "Name": "option_button", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" - }, - { - "Name": "option_gear_white", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" - } - ], "Description": "", "DragSelectable": true, "GMNotes": "", diff --git a/objects/Playermat3Green.383d8b.json b/objects/Playermat3Green.383d8b.json index b3229002..3e20adef 100644 --- a/objects/Playermat3Green.383d8b.json +++ b/objects/Playermat3Green.383d8b.json @@ -342,28 +342,6 @@ "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, - "CustomUIAsset": [ - { - "Name": "option_on", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" - }, - { - "Name": "option_off", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" - }, - { - "Name": "option_button", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" - }, - { - "Name": "option_gear_white", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" - } - ], "Description": "", "DragSelectable": true, "GMNotes": "", diff --git a/objects/Playermat4Red.0840d5.json b/objects/Playermat4Red.0840d5.json index 49c88946..a1ef0a59 100644 --- a/objects/Playermat4Red.0840d5.json +++ b/objects/Playermat4Red.0840d5.json @@ -342,28 +342,6 @@ "ImageURL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115659543571/5D778EA4BC682DAE97E8F59A991BCF8CB3979B04/", "WidthScale": 0 }, - "CustomUIAsset": [ - { - "Name": "option_on", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668997008/2178787B67B3C96F3419EDBAB8420E39893756BC/" - }, - { - "Name": "option_off", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2462982115668996901/D6438ECBB11DECC6DB9987589FF526FBAD4D2368/" - }, - { - "Name": "option_button", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694733080/433021454606C80875A2D25480910CDFC05DC115/" - }, - { - "Name": "option_gear_white", - "Type": 0, - "URL": "https://steamusercontent-a.akamaihd.net/ugc/2466368617694843180/4DB761FF58E0380A11D7367DA6C25E82A5DE1AC9/" - } - ], "Description": "", "DragSelectable": true, "GMNotes": "", diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 328db880..a3ed4493 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -551,11 +551,9 @@ end function shuffleDiscardIntoDeck() local deckAreaObjects = getDeckAreaObjects() - if not deckAreaObjects.discard.is_face_down then - deckAreaObjects.discard.flip() - end - deckAreaObjects.discard.shuffle() - deckAreaObjects.discard.setPositionSmooth(self.positionToWorld(DRAW_DECK_POSITION), false, false) + if not deckAreaObjects.discard then return end + + deckLib.placeOrMergeIntoDeck({ deckAreaObjects.topCard, deckAreaObjects.discard }, self.positionToWorld(DRAW_DECK_POSITION), _, _, true) end -- utility function for Norman Withers to flip the top card to the revealed side @@ -699,6 +697,20 @@ function createXML() end end + -- create a button for shuffling the discard pile back + local shuffleDiscardXML = { + tag = "Button", + attributes = { + onClick = "shuffleDiscardIntoDeck", + width = "7", + height = "7", + position = "-182 30.5 -11", + rotation = "0 0 180", + image = "shuffle" + } + } + table.insert(xml, shuffleDiscardXML) + -- create the personal option panel local defaultsXML = { tag = "Defaults", diff --git a/src/util/DeckLib.ttslua b/src/util/DeckLib.ttslua index a20d865f..c44d645b 100644 --- a/src/util/DeckLib.ttslua +++ b/src/util/DeckLib.ttslua @@ -2,12 +2,13 @@ do local DeckLib = {} local searchLib = require("util/SearchLib") - -- places a card/deck at a position or merges into an existing deck below + -- places a card/deck at a position or merges into an existing deck ---@param objOrTable tts__Object|table Object or table of objects to move ---@param pos table New position for the object ---@param rot? table New rotation for the object ---@param below? boolean Should the object be placed below an existing deck? - DeckLib.placeOrMergeIntoDeck = function(objOrTable, pos, rot, below) + ---@param shuffle? boolean Should the resulting deck be shuffled? + DeckLib.placeOrMergeIntoDeck = function(objOrTable, pos, rot, below, shuffle) if objOrTable == nil or pos == nil then return end -- handle 'objOrTable' parameter @@ -63,11 +64,16 @@ do else targetObj = obj end + + -- this is the final object, maybe shuffle + if i == 1 and targetObj.type == "Deck" and shuffle then + targetObj.shuffle() + end end, -- check state of the object (make sure it's not moving) function() return obj.isDestroyed() or not obj.isSmoothMoving() end, 2) - end, (#objects- i) * 0.1) + end, (#objects - i) * 0.1) end end