Skip to content

Commit 137bc3e

Browse files
Fix Center Unlock Text (#1262)
* Fix Center Unlock Text Unlocks normally only differentiate Vouchers, with the default being Jokers. This makes sense in vanilla, as you can only unlock Vouchers and Jokers. Steamodded adds methods for mod developers to implement locked consumables, editions and enhancements, but currently does not adjust the unlock text to differentiate between different unlockable types. This is a pretty barebones and primitive implementation of adjusting the unlock box text to account for other types, and could benefit from a more sophisticated implementation, such as relying on a util function that could support additional modded object types. Additionally, even though the vanilla text for unlock type is always ``G.C.BLUE``, I wonder if it would be acceptable to implement support for adjusting that as well, however that is beyond the scope of this. * Adjustments + Util Function Instead of having this long series of conditions, let's implement the much better solution of using ```localize('k_'..string.lower(card and card.center and card.center.set or 'unknown'))``` to solve the problem. Let's additionally wrap this in a util helper function which will be what the patch code overwrites the original string argument with, so that mod developers can hook it if they wish to implement specific circumstances where they would like to replace the text of the unlock type. This is a solution I feel that is fully within the spirit of SMODS. * Correction The original variable in the UI code is ``card_center``, not ``card`` * Change from patches.regex to patches.pattern Whoops * Small explainer comment on the util function --------- Co-authored-by: Casimir Eisenach <casimirusenormus@hotmail.de>
1 parent 446c1cb commit 137bc3e

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

localization/en-us.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ return {
373373
b_deckskins_def = 'Default Colours',
374374
b_limit = 'Up to ',
375375
b_retrigger_single = 'time',
376-
b_retrigger_plural = 'times'
376+
b_retrigger_plural = 'times',
377+
k_enhanced = 'Enhancement'
377378
},
378379
v_dictionary = {
379380
c_types = '#1# Types',

lovely/fixes.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,3 +909,12 @@ payload = '''
909909
localize{type = 'other', key = 'card_chips'..(specific_vars.nominal_chips < 0 and '_minus' or ''), nodes = desc_nodes, vars = {specific_vars.nominal_chips}}
910910
'''
911911
match_indent = true
912+
913+
# Fix Consumable unlock text saying "Joker unlocked" instead of specific consumable type
914+
[[patches]]
915+
[patches.pattern]
916+
target = "functions/UI_definitions.lua"
917+
pattern = '''{n=G.UIT.O, config={object = DynaText({string = {card_center.set == 'Voucher' and localize('k_voucher') or localize('k_joker')}, colours = {G.C.BLUE},shadow = true, rotate = true, bump = true, pop_in = 0.3, pop_in_rate = 2, scale = 1.2})}}'''
918+
position = "at"
919+
payload = '''{n=G.UIT.O, config={object = DynaText({string = { SMODS.create_unlock_text(card_center) }, colours = { G.C.BLUE }, shadow = true, rotate = true, bump = true, pop_in = 0.3, pop_in_rate = 2, scale = 1.2})}}'''
920+
match_indent = true

src/utils.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,6 +3716,7 @@ function SMODS.get_badge_text_colour(key)
37163716
end
37173717
end
37183718

3719+
37193720
function SMODS.resolve_ui_shaders(shader, send)
37203721
local shaders = {}
37213722
-- simple single shader
@@ -3936,4 +3937,9 @@ SMODS.mod_blind_size = function(blind_size_mod)
39363937
blind_size_mod.effect.update_blind_size = true
39373938
end
39383939
delay(0.2)
3940+
end
3941+
3942+
-- Simple unlock text function, created to give mod authors an option to hook rather than patch for their use cases.
3943+
function SMODS.create_unlock_text(center)
3944+
return localize('k_'..string.lower(center and center.set or 'unknown'))
39393945
end

0 commit comments

Comments
 (0)