Skip to content

Commit c09c08d

Browse files
committed
make all Card:draw patches use new API
1 parent d73c897 commit c09c08d

File tree

8 files changed

+189
-196
lines changed

8 files changed

+189
-196
lines changed

Cryptid.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
--- MOD_AUTHOR: [MathIsFun_, Cryptid and Balatro Discords]
66
--- MOD_DESCRIPTION: Adds unbalanced ideas to Balatro.
77
--- BADGE_COLOUR: 708b91
8-
--- DEPENDENCIES: [Talisman>=2.0.9, Steamodded>=1.0.0~ALPHA-1312c]
8+
--- DEPENDENCIES: [Talisman>=2.0.9, Steamodded>=1.0.0~BETA-0301a]
99
--- VERSION: 0.5.5~dev
1010
--- PRIORITY: 2147483647
1111

lib/ui.lua

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
-- ui.lua - Code used for new UI elements/changes in Cryptid
2+
3+
-- Add/modify Steamodded Draw Steps to work with Cryptid
4+
5+
-- Edition Decks
6+
SMODS.DrawStep {
7+
key = 'back_edition',
8+
order = 5,
9+
func = function(self)
10+
if safe_get(self, "area", "config", "type") == "deck" then
11+
local currentBack = self.params.viewed_back and G.GAME.viewed_back or G.GAME.selected_back
12+
if currentBack.effect.config.cry_force_edition and not currentBack.effect.config.cry_antimatter then
13+
if currentBack.effect.config.cry_force_edition_shader then
14+
self.children.back:draw_shader(currentBack.effect.config.cry_force_edition_shader , nil, self.ARGS.send_to_shader, true)
15+
else
16+
self.children.back:draw_shader(currentBack.effect.config.cry_force_edition , nil, self.ARGS.send_to_shader, true)
17+
end
18+
end
19+
if currentBack.effect.config.cry_force_seal and not currentBack.effect.config.hide_seal and not currentBack.effect.config.cry_antimatter then
20+
G.shared_seals[currentBack.effect.config.cry_force_seal]:draw_shader('dissolve', nil, nil, true, self.children.center)
21+
if currentBack.effect.config.cry_force_seal == 'Gold' then G.shared_seals[currentBack.effect.config.cry_force_seal]:draw_shader('voucher', nil, self.ARGS.send_to_shader, true, self.children.center) end
22+
end
23+
if currentBack.effect.config.cry_force_sticker and not currentBack.effect.config.cry_antimatter then
24+
for k, v in pairs(SMODS.Stickers) do
25+
if currentBack.effect.config.cry_force_sticker == v.key then
26+
if v and v.draw and type(v.draw) == 'function' then
27+
v:draw(self)
28+
else
29+
G.shared_stickers[v.key].role.draw_major = self
30+
G.shared_stickers[v.key]:draw_shader('dissolve', nil, nil, true, self.children.center)
31+
G.shared_stickers[v.key]:draw_shader('voucher', nil, self.ARGS.send_to_shader, true, self.children.center)
32+
end
33+
end
34+
end
35+
end
36+
if currentBack.effect.config.cry_antimatter or currentBack.effect.config.cry_force_edition == 'negative' then
37+
self.children.back:draw_shader('negative', nil, self.ARGS.send_to_shader, true)
38+
self.children.center:draw_shader('negative_shine', nil, self.ARGS.send_to_shader, true)
39+
end
40+
if currentBack.effect.center.edeck_type then
41+
local edition, enhancement, sticker, suit, seal = cry_get_enchanced_deck_info(currentBack)
42+
local sprite = cry_edeck_atlas_update(currentBack.effect.center)
43+
self.children.back.atlas = G.ASSET_ATLAS[sprite.atlas] or self.children.back.atlas
44+
self.children.back.sprite_pos = sprite.pos
45+
self.children.back:reset()
46+
if currentBack.effect.center.edeck_type == 'edition' then
47+
self.children.back:draw_shader(edition, nil, self.ARGS.send_to_shader, true)
48+
if edition == 'negative' then
49+
self.children.back:draw_shader('negative', nil, self.ARGS.send_to_shader, true)
50+
self.children.center:draw_shader('negative_shine', nil, self.ARGS.send_to_shader, true)
51+
end
52+
end
53+
if currentBack.effect.center.edeck_type == 'seal' then
54+
G.shared_seals[seal]:draw_shader('dissolve', nil, nil, true, self.children.center)
55+
if seal == 'Gold' then G.shared_seals[seal]:draw_shader('voucher', nil, self.ARGS.send_to_shader, true, self.children.center) end
56+
end
57+
if currentBack.effect.center.edeck_type == 'sticker' then
58+
for k, v in pairs(SMODS.Stickers) do
59+
if sticker == v.key then
60+
if v and v.draw and type(v.draw) == 'function' then
61+
v:draw(self)
62+
else
63+
G.shared_stickers[v.key].role.draw_major = self
64+
G.shared_stickers[v.key]:draw_shader('dissolve', nil, nil, true, self.children.center)
65+
G.shared_stickers[v.key]:draw_shader('voucher', nil, self.ARGS.send_to_shader, true, self.children.center)
66+
end
67+
end
68+
end
69+
end
70+
end
71+
end
72+
end,
73+
conditions = {vortex = false, facing = 'back'}
74+
}
75+
-- Third Layer
76+
SMODS.DrawStep {
77+
key = 'floating_sprite2',
78+
order = 59,
79+
func = function(self)
80+
if self.ability.name == 'cry-Gateway' and (self.config.center.discovered or self.bypass_discovery_center) then
81+
local scale_mod2 = 0.07-- + 0.02*math.cos(1.8*G.TIMERS.REAL) + 0.00*math.cos((G.TIMERS.REAL - math.floor(G.TIMERS.REAL))*math.pi*14)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^3
82+
local rotate_mod2 = 0--0.05*math.cos(1.219*G.TIMERS.REAL) + 0.00*math.cos((G.TIMERS.REAL)*math.pi*5)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^2
83+
self.children.floating_sprite2:draw_shader('dissolve',0, nil, nil, self.children.center,scale_mod2, rotate_mod2,nil, 0.1--[[ + 0.03*math.cos(1.8*G.TIMERS.REAL)--]],nil, 0.6)
84+
self.children.floating_sprite2:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod2, rotate_mod2)
85+
86+
local scale_mod = 0.05 + 0.05*math.sin(1.8*G.TIMERS.REAL) + 0.07*math.sin((G.TIMERS.REAL - math.floor(G.TIMERS.REAL))*math.pi*14)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^3
87+
local rotate_mod = 0.1*math.sin(1.219*G.TIMERS.REAL) + 0.07*math.sin((G.TIMERS.REAL)*math.pi*5)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^2
88+
89+
self.children.floating_sprite.role.draw_major = self
90+
self.children.floating_sprite:draw_shader('dissolve',0, nil, nil, self.children.center,scale_mod, rotate_mod,nil, 0.1 + 0.03*math.sin(1.8*G.TIMERS.REAL),nil, 0.6)
91+
self.children.floating_sprite:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod)
92+
end
93+
if self.config.center.soul_pos and self.config.center.soul_pos.extra and (self.config.center.discovered or self.bypass_discovery_center) then
94+
local scale_mod = 0.07-- + 0.02*math.cos(1.8*G.TIMERS.REAL) + 0.00*math.cos((G.TIMERS.REAL - math.floor(G.TIMERS.REAL))*math.pi*14)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^3
95+
local rotate_mod = 0--0.05*math.cos(1.219*G.TIMERS.REAL) + 0.00*math.cos((G.TIMERS.REAL)*math.pi*5)*(1 - (G.TIMERS.REAL - math.floor(G.TIMERS.REAL)))^2
96+
self.children.floating_sprite2:draw_shader('dissolve',0, nil, nil, self.children.center,scale_mod, rotate_mod,nil, 0.1--[[ + 0.03*math.cos(1.8*G.TIMERS.REAL)--]],nil, 0.6)
97+
self.children.floating_sprite2:draw_shader('dissolve', nil, nil, nil, self.children.center, scale_mod, rotate_mod)
98+
end
99+
end,
100+
conditions = {vortex = false, facing = 'front'}
101+
}
102+
SMODS.draw_ignore_keys.floating_sprite2 = true

lovely/enhanced.toml

Lines changed: 0 additions & 105 deletions
This file was deleted.

lovely/gateway.toml

Lines changed: 0 additions & 28 deletions
This file was deleted.

lovely/lib_gameset.toml

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -158,37 +158,6 @@ payload = '''if _c.cry_disabled or (_c.force_gameset and _c.force_gameset == 'di
158158
end'''
159159
match_indent = true
160160

161-
# render gameset as sticker
162-
[[patches]]
163-
[patches.pattern]
164-
target = "card.lua"
165-
pattern = "if self.sticker and G.shared_stickers[self.sticker] then"
166-
position = "before"
167-
payload = '''
168-
if not Cryptid.shared_gamesets then
169-
Cryptid.shared_gamesets = {
170-
modest = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["cry_gameset"], {x = 0,y = 0}),
171-
mainline = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["cry_gameset"], {x = 1,y = 0}),
172-
madness = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["cry_gameset"], {x = 2,y = 0}),
173-
custom = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["cry_gameset"], {x = 3,y = 0}),
174-
selected = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["cry_sticker"], {x = 0,y = 4}),
175-
}
176-
end
177-
local gameset_key
178-
if self.config.center.force_gameset then
179-
gameset_key = self.config.center.force_gameset
180-
if gameset_key ~= "disabled" and gameset_key ~= "modest" and gameset_key ~= "mainline" and gameset_key ~= "madness" then
181-
gameset_key = "custom"
182-
end
183-
end
184-
if self.gameset_select and Cryptid.shared_gamesets[gameset_key] then
185-
Cryptid.shared_gamesets[gameset_key].role.draw_major = self
186-
Cryptid.shared_gamesets[gameset_key]:draw_shader('dissolve', nil, nil, nil, self.children.center)
187-
Cryptid.shared_gamesets[gameset_key]:draw_shader('voucher', nil, self.ARGS.send_to_shader, nil, self.children.center)
188-
end
189-
'''
190-
match_indent = true
191-
192161
# replace rarity badge with gameset
193162
[[patches]]
194163
[patches.pattern]
@@ -220,18 +189,6 @@ end
220189
'''
221190
match_indent = true
222191

223-
224-
# make disabled cards visually debuffed
225-
# warning: this also patches a lot of extra stuff, but that shouldn't matter
226-
# since you shouldn't be able to access them outside of the collection anyway
227-
[[patches]]
228-
[patches.pattern]
229-
target = "card.lua"
230-
pattern = "if self.debuff then"
231-
position = "at"
232-
payload = "if self.debuff or cry_get_gameset(self) == 'disabled' or (self.config.center.gameset_config and self.config.center.gameset_config[cry_get_gameset(self)] and self.config.center.gameset_config[cry_get_gameset(self)].disabled) or (self.config.center.cry_disabled and not self.gameset_select) then"
233-
match_indent = true
234-
235192
# Descriptions for Backs and Blinds in gameset UI
236193
[[patches]]
237194
[patches.pattern]

lovely/lib_misc.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ end
7979
'''
8080
match_indent = true
8181

82-
# If your exotic sprites are getting screwed up, this is probably why
83-
# This really needs to be turned into a regex patch
84-
[[patches]]
85-
[patches.pattern]
86-
target = "card.lua"
87-
pattern = '''if not v.custom_draw and k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end'''
88-
position = "at"
89-
payload = '''if not v.custom_draw and k ~= 'focused_ui' and k ~= "front" and k ~= "back" and k ~= "soul_parts" and k ~= "center" and k ~= 'floating_sprite' and k ~= 'floating_sprite2' and k~= "shadow" and k~= "use_button" and k ~= 'buy_button' and k ~= 'buy_and_use_button' and k~= "debuff" and k ~= 'price' and k~= 'particles' and k ~= 'h_popup' then v:draw() end'''
90-
match_indent = true
91-
9282

9383
# Custom variables in info queue
9484
[[patches]]

0 commit comments

Comments
 (0)