From 7c1791ec2a6443408d1aaabfa66312ab4274f3b1 Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Sun, 17 May 2026 13:27:16 +0200 Subject: [PATCH 1/8] Added `SMODS.card_to_image()` util func +Title, allows rendering one card to an image file (for e.g. easily sharing how Editions look). --- src/utils.lua | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/utils.lua b/src/utils.lua index ceada06d1..e7d896834 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -4151,4 +4151,68 @@ function SMODS.add_to_deck(card, args) local area = args.area or G.jokers area:emplace(card) return card +end + +-- Hook for the below Util function +local sprite_draw_from_ref = Sprite.draw_from +function Sprite:draw_from(...) + local old_filter_min, old_filter_mag + if self.atlas and SMODS.texture_filter_override then + old_filter_min, old_filter_mag = self.atlas.image:getFilter() + self.atlas.image:setFilter(SMODS.texture_filter_override, SMODS.texture_filter_override) + end + local ret = sprite_draw_from_ref(self, ...) + if self.atlas and SMODS.texture_filter_override then + self.atlas.image:setFilter(old_filter_min, old_filter_mag) + end + return ret +end + +-- Hook for the below Util function +local sprite_draw_self_ref = Sprite.draw_self +function Sprite:draw_self(...) + local old_filter_min, old_filter_mag + if self.atlas and SMODS.texture_filter_override then + old_filter_min, old_filter_mag = self.atlas.image:getFilter() + self.atlas.image:setFilter(SMODS.texture_filter_override, SMODS.texture_filter_override) + end + local ret = sprite_draw_self_ref(self, ...) + if self.atlas and SMODS.texture_filter_override then + self.atlas.image:setFilter(old_filter_min, old_filter_mag) + end + return ret +end + +-- Util function to render one card to a .png file (usually saved to the mods folder's parent directory) +function SMODS.card_to_image(card, scale, filename) + if not type(card) == "table" then return end + local key = ((card.config or {}).center or {}).key or "card_to_image" + scale = scale or 2.0 + filename = (filename or key == "j_joker" and "jimbo" or key) .. ".png" + + local canvas = love.graphics.newCanvas(71 * scale, 95 * scale, {type = '2d', readable = true}) + canvas:setFilter('nearest', 'nearest') + + local old_t = SMODS.shallow_copy(card.T) + local old_shadow = card.no_shadow + local old_rm = G.SETTINGS.reduced_motion + card.T.r = 0 + local w = card.T.w / G.TILE_H * G.TILESCALE + local h = card.T.h / G.TILE_H * G.TILESCALE + local old_scale = card.T.scale + card.T.scale = scale + card:hard_set_T(w/2*(scale-1), h/2*(scale-1), w, h) + card.no_shadow = true + G.SETTINGS.reduced_motion = true + SMODS.texture_filter_override = "nearest" + canvas:renderTo(card.draw, card) + SMODS.texture_filter_override = nil + G.SETTINGS.reduced_motion = old_rm + card.no_shadow = old_shadow + card.T.scale = old_scale + card:hard_set_T(old_t.x, old_t.y, old_t.w, old_t.h) + + local image_data = canvas:newImageData() + image_data:encode("png", filename) + print("SMODS : Saved card image to "..love.filesystem.getSaveDirectory().."/"..filename) end \ No newline at end of file From efb453b7258998fa034371b5ed5dabf4bf10259d Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Sun, 17 May 2026 13:33:34 +0200 Subject: [PATCH 2/8] Added LSP defs +Title --- lsp_def/utils.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lsp_def/utils.lua b/lsp_def/utils.lua index 8a5ae28ab..fe0e6a510 100644 --- a/lsp_def/utils.lua +++ b/lsp_def/utils.lua @@ -868,4 +868,10 @@ function SMODS.copy_card(card, args) end ---@param card Card|table Card to add ---@param args {set: string?, area: CardArea|table?, playing_card: integer?}? ---@return Card|table -function SMODS.add_to_deck(card, args) end \ No newline at end of file +function SMODS.add_to_deck(card, args) end + +-- Util function to render one card to a .png file (usually saved to the mods folder's parent directory) +---@param card Card|table Card to save as an image +---@param scale number? Scale to render the card at (default = 2.0) +---@param filename string? Name of the file +function SMODS.card_to_image(card, scale, filename) end \ No newline at end of file From e830e5f3370138536158f875b6c95299aa433336 Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Sun, 17 May 2026 13:35:10 +0200 Subject: [PATCH 3/8] More LSP def +Title --- lsp_def/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp_def/utils.lua b/lsp_def/utils.lua index fe0e6a510..303f358ac 100644 --- a/lsp_def/utils.lua +++ b/lsp_def/utils.lua @@ -873,5 +873,5 @@ function SMODS.add_to_deck(card, args) end -- Util function to render one card to a .png file (usually saved to the mods folder's parent directory) ---@param card Card|table Card to save as an image ---@param scale number? Scale to render the card at (default = 2.0) ----@param filename string? Name of the file +---@param filename string? Name of the file (default = [center.key]) function SMODS.card_to_image(card, scale, filename) end \ No newline at end of file From 6f7018100ec192759189bd3012b5abd0d1a207cb Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Sun, 17 May 2026 14:24:56 +0200 Subject: [PATCH 4/8] Fixed the func breaking at different window resolutions *Title --- src/utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.lua b/src/utils.lua index e7d896834..08825f24d 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -4197,8 +4197,8 @@ function SMODS.card_to_image(card, scale, filename) local old_shadow = card.no_shadow local old_rm = G.SETTINGS.reduced_motion card.T.r = 0 - local w = card.T.w / G.TILE_H * G.TILESCALE - local h = card.T.h / G.TILE_H * G.TILESCALE + local w = card.T.w / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 -- Don't ask me why I had to multiply by 1.5 here, I do not know,,, (this may have been brute-tinkered) + local h = card.T.h / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 local old_scale = card.T.scale card.T.scale = scale card:hard_set_T(w/2*(scale-1), h/2*(scale-1), w, h) From 6ba55e08055ec22337a6bb8c8d0a6b069ba581de Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Sun, 17 May 2026 22:41:00 +0200 Subject: [PATCH 5/8] Evil precision error fix *Title, (I'm scared help) --- src/utils.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.lua b/src/utils.lua index 08825f24d..e050c37c9 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -4197,8 +4197,8 @@ function SMODS.card_to_image(card, scale, filename) local old_shadow = card.no_shadow local old_rm = G.SETTINGS.reduced_motion card.T.r = 0 - local w = card.T.w / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 -- Don't ask me why I had to multiply by 1.5 here, I do not know,,, (this may have been brute-tinkered) - local h = card.T.h / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 + local w = card.T.w/G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- Don't ask me why I had to multiply by 1.5 * 763/768 here, I do not know,,, (this may have been brute-tinkered) + local h = card.T.h/G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- (well the times 763/768 is to remove an extra pixel in height for scales == 2.0 -> 16.0 (at least)) local old_scale = card.T.scale card.T.scale = scale card:hard_set_T(w/2*(scale-1), h/2*(scale-1), w, h) From feedc326185cb5b8c4c1f1755d4132f57ffe5a64 Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Wed, 20 May 2026 10:53:28 +0200 Subject: [PATCH 6/8] Updated LSP def *Title --- lsp_def/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp_def/utils.lua b/lsp_def/utils.lua index 303f358ac..f3b505a92 100644 --- a/lsp_def/utils.lua +++ b/lsp_def/utils.lua @@ -870,7 +870,7 @@ function SMODS.copy_card(card, args) end ---@return Card|table function SMODS.add_to_deck(card, args) end --- Util function to render one card to a .png file (usually saved to the mods folder's parent directory) +-- Util function to render one card to a `.png` file, saved to `love.filesystem.getSaveDirectory()` ---@param card Card|table Card to save as an image ---@param scale number? Scale to render the card at (default = 2.0) ---@param filename string? Name of the file (default = [center.key]) From 038a1c593537292dbec222f4c61faaf8ca00e697 Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Mon, 15 Jun 2026 23:08:57 +0200 Subject: [PATCH 7/8] Refactored out unnecessary setting of `T.w/h` in favor of just `T.scale` */-Title, this also fixes Seals/etc. rendering at the wrong size. --- lsp_def/utils.lua | 2 +- src/utils.lua | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lsp_def/utils.lua b/lsp_def/utils.lua index 9e232f113..c925fe879 100644 --- a/lsp_def/utils.lua +++ b/lsp_def/utils.lua @@ -892,6 +892,6 @@ function SMODS.add_to_deck(card, args) end -- Util function to render one card to a `.png` file, saved to `love.filesystem.getSaveDirectory()` ---@param card Card|table Card to save as an image ----@param scale number? Scale to render the card at (default = 2.0) +---@param scale number? Scale to render the card at (default = G.SETTINGS.GRAPHICS.texture_scaling) ---@param filename string? Name of the file (default = [center.key]) function SMODS.card_to_image(card, scale, filename) end \ No newline at end of file diff --git a/src/utils.lua b/src/utils.lua index b338b0b00..e3bbf8b1b 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -4263,7 +4263,7 @@ end function SMODS.card_to_image(card, scale, filename) if not type(card) == "table" then return end local key = ((card.config or {}).center or {}).key or "card_to_image" - scale = scale or 2.0 + scale = scale or G.SETTINGS.GRAPHICS.texture_scaling filename = (filename or key == "j_joker" and "jimbo" or key) .. ".png" local canvas = love.graphics.newCanvas(71 * scale, 95 * scale, {type = '2d', readable = true}) @@ -4273,11 +4273,9 @@ function SMODS.card_to_image(card, scale, filename) local old_shadow = card.no_shadow local old_rm = G.SETTINGS.reduced_motion card.T.r = 0 - local w = card.T.w/G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- Don't ask me why I had to multiply by 1.5 * 763/768 here, I do not know,,, (this may have been brute-tinkered) - local h = card.T.h/G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- (well the times 763/768 is to remove an extra pixel in height for scales == 2.0 -> 16.0 (at least)) local old_scale = card.T.scale - card.T.scale = scale - card:hard_set_T(w/2*(scale-1), h/2*(scale-1), w, h) + card.T.scale = scale / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- Don't ask me why I had to multiply by 1.5 * 763/768 here, I do not know,,, (this may have been brute-tinkered) (well the times 763/768 is to remove an extra pixel in height for scales == 2.0 -> 16.0 (at least)) + card:hard_set_T(card.T.w/2*(card.T.scale-1), card.T.h/2*(card.T.scale-1)) card.no_shadow = true G.SETTINGS.reduced_motion = true SMODS.texture_filter_override = "nearest" From a1d29173226d60ec35b01518e47b156b8e2ae328 Mon Sep 17 00:00:00 2001 From: AllUniversal Date: Tue, 21 Jul 2026 16:23:52 +0200 Subject: [PATCH 8/8] Added `f2(+scale)` Keybind and fixed more pixel precision problems. +/*Title --- src/game_object.lua | 18 +++++++++++++++++- src/utils.lua | 7 ++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/game_object.lua b/src/game_object.lua index 4dfd9157c..ff1c64a2c 100644 --- a/src/game_object.lua +++ b/src/game_object.lua @@ -3709,7 +3709,7 @@ SMODS.UndiscoveredCompat = { end } - SMODS.Keybind { + SMODS.Keybind { key_pressed = 'f5', held_keys = { "lalt" }, event = 'pressed', @@ -3719,6 +3719,22 @@ SMODS.UndiscoveredCompat = { end } + SMODS.Keybind { + key_pressed = 'f2', + event = 'pressed', + action = function(self) + local target = G.CONTROLLER.hovering.target or G.CONTROLLER.focused.target + if not _RELEASE_MODE and target and type(target.is) == "function" and target:is(Card) then + local scale = 0 + for i=0,9,1 do + if love.keyboard.isDown(""..i) then scale = scale + (i == 0 and 10 or i) end + end + if scale <= 0 then scale = G.SETTINGS.GRAPHICS.texture_scaling end + SMODS.card_to_image(target, scale) + end + end + } + ------------------------------------------------------------------------------------------------- ------- API CODE GameObject.Achievement ------------------------------------------------------------------------------------------------- diff --git a/src/utils.lua b/src/utils.lua index 22f7ff206..1bb29b061 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -4338,8 +4338,9 @@ function SMODS.card_to_image(card, scale, filename) local old_rm = G.SETTINGS.reduced_motion card.T.r = 0 local old_scale = card.T.scale - card.T.scale = scale / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 * 763/768 -- Don't ask me why I had to multiply by 1.5 * 763/768 here, I do not know,,, (this may have been brute-tinkered) (well the times 763/768 is to remove an extra pixel in height for scales == 2.0 -> 16.0 (at least)) - card:hard_set_T(card.T.w/2*(card.T.scale-1), card.T.h/2*(card.T.scale-1)) + card.T.scale = scale / G.TILE_H * G.window_prev.orig_scale * G.window_prev.orig_scale/G.TILESCALE * 1.5 -- Don't ask me why I had to multiply by 1.5 here, and by the per-dimension factors below, I do not know,,, (this may have been brute-tinkered) + local w, h = old_t.w * 0.997, old_t.h * 0.99348 -- (well these factors are needed to remove extra pixels in height/width for scales == 2.0 -> 16.0 (at least)) + card:hard_set_T(w/2*(card.T.scale-1), h/2*(card.T.scale-1), w, h) card.no_shadow = true G.SETTINGS.reduced_motion = true SMODS.texture_filter_override = "nearest" @@ -4352,7 +4353,7 @@ function SMODS.card_to_image(card, scale, filename) local image_data = canvas:newImageData() image_data:encode("png", filename) - print("SMODS : Saved card image to "..love.filesystem.getSaveDirectory().."/"..filename) + print("SMODS : Saved card image to "..love.filesystem.getSaveDirectory().."/"..filename .. " at scale " .. scale) end function Card:is_suit_shade(shade, bypass_debuff)