Skip to content

Commit 8bb768b

Browse files
authored
Fix: Update Blind's description with set_text (Fixes #1233) and properly update name with loc_vars (#1243)
* Fix: Update Blind's description with `set_text` (Fixes #1233) * Also change name with loc_vars
1 parent 283b510 commit 8bb768b

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

lovely/blind.toml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,25 @@ end
386386
[[patches]]
387387
[patches.pattern]
388388
target = 'functions/UI_definitions.lua'
389-
pattern = "local text_table = loc_target"
389+
pattern = '''
390+
local loc_name = localize{type = 'name_text', key = blind_choice.config.key, set = 'Blind'}
391+
local text_table = loc_target
392+
'''
390393
match_indent = true
391394
position = 'at'
392395
payload = '''
396+
local loc_name = localize{type = 'name_text', key = target.key or blind_choice.config.key, set = target.set or 'Blind'}
393397
local text_table = G.localization.descriptions[target.set][target.key].text_parsed
394398
'''
395399

396400
# create_UIBox_blind_popup()
397401
[[patches]]
398402
[patches.pattern]
399403
target = 'functions/UI_definitions.lua'
400-
pattern = '''local loc_target = localize{type = 'raw_descriptions', key = blind.key, set = 'Blind', vars = vars or blind.vars}'''
404+
pattern = '''
405+
local loc_target = localize{type = 'raw_descriptions', key = blind.key, set = 'Blind', vars = vars or blind.vars}
406+
local loc_name = localize{type = 'name_text', key = blind.key, set = 'Blind'}
407+
'''
401408
match_indent = true
402409
position = 'at'
403410
payload = '''
@@ -410,7 +417,8 @@ if blind.collection_loc_vars and type(blind.collection_loc_vars) == 'function' t
410417
target.scale = res.scale
411418
target.text_colour = res.text_colour
412419
end
413-
local loc_target = G.localization.descriptions[target.set][target.key].text_parsed'''
420+
local loc_target = G.localization.descriptions[target.set][target.key].text_parsed
421+
local loc_name = localize{type = 'name_text', key = target.key or blind.key, set = target.set or 'Blind'}'''
414422

415423
[[patches]]
416424
[patches.pattern]
@@ -424,6 +432,36 @@ payload = '''
424432
ability_text[#ability_text + 1] = {n=G.UIT.R, config={align = "cm"}, nodes=SMODS.localize_box(v, {default_col = target.text_colour or G.C.WHITE, shadow = true, vars = target.vars, scale = target.scale})}
425433
'''
426434

435+
# create_UIBox_round_scores_row()
436+
[[patches]]
437+
[patches.pattern]
438+
target = 'functions/UI_definitions.lua'
439+
pattern = '''
440+
local blind_choice = {config = G.GAME.blind.config.blind or G.P_BLINDS.bl_small}
441+
'''
442+
match_indent = true
443+
position = 'after'
444+
payload = '''
445+
local target = {type = 'name_text', key = blind_choice.config.key, set = 'Blind'}
446+
if blind_choice.config.loc_vars and type(blind_choice.config.loc_vars) == 'function' then
447+
local res = blind_choice.config:loc_vars() or {}
448+
target.key = res.key or target.key
449+
target.set = res.set or target.set
450+
end
451+
'''
452+
453+
[[patches]]
454+
[patches.pattern]
455+
target = 'functions/UI_definitions.lua'
456+
pattern = '''
457+
{n=G.UIT.O, config={object = DynaText({string = localize{type ='name_text', key = blind_choice.config.key, set = 'Blind'}, colours = {G.C.WHITE},shadow = true, float = true,maxw = 2.2, scale = 0.45})}}
458+
'''
459+
match_indent = true
460+
position = 'at'
461+
payload = '''
462+
{n=G.UIT.O, config={object = DynaText({string = localize(target), colours = {G.C.WHITE},shadow = true, float = true,maxw = 2.2, scale = 0.45})}}
463+
'''
464+
427465
# get_new_boss()
428466
[[patches]]
429467
[patches.pattern]

lovely/blind_ui.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ position = 'before'
7575
payload = '''
7676
EMPTY(self.loc_debuff_lines)
7777
if G.localization.descriptions[target.set][target.key] then
78+
self.update_loc_debuff_lines = true
79+
self.loc_name = self.name == '' and self.name or localize{type ='name_text', key = target.key, set = target.set}
7880
for k, v in ipairs(G.localization.descriptions[target.set][target.key].text_parsed) do
7981
self.loc_debuff_lines[k] = v
8082
end

src/overrides.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ G.FUNCS.HUD_blind_debuff = function(e)
1717
local excess_height = (0.3 + padding)*(num_lines - 5)
1818
padding = padding - excess_height / (num_lines + 1)
1919
end
20-
e.config.padding = padding
20+
e.config.padding = padding
21+
if G.GAME.blind.update_loc_debuff_lines then
22+
for i = 1, #e.children do
23+
e.children[i]:remove()
24+
e.children[i] = nil
25+
end
26+
G.GAME.blind.update_loc_debuff_lines = nil
27+
end
2128
if num_lines > #e.children then
2229
for i = #e.children + 1, num_lines do
2330
local node_def

0 commit comments

Comments
 (0)