Skip to content

Commit 6a91fe7

Browse files
committed
2 parents 28a506f + 5264a1c commit 6a91fe7

File tree

3 files changed

+235
-1
lines changed

3 files changed

+235
-1
lines changed

NumericUI/scripts/mods/NumericUI/HudElementDodgeCount.lua

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,59 @@ local color_efficient = Color.terminal_text_header(255, true)
2020
local color_inefficient = Color.ui_hud_warp_charge_low(255, true)
2121
local color_limit = Color.ui_hud_warp_charge_high(255, true)
2222

23+
local timer_x_offset = (-UIWorkspaceSettings.screen.size[1]
24+
+ scenegraph_definition.container.size[1])/2
25+
26+
local timer_size_color = function(time_to_refresh, cooldown, current_dodges, force_show_max_width)
27+
-- NB: time_to_refresh will increase towards zero
28+
local t_max = cooldown
29+
if (-time_to_refresh >= t_max or force_show_max_width) and mod:get("dodge_timer_hide_full") then
30+
return
31+
end
32+
local natural_time = force_show_max_width and 0 or math.clamp((time_to_refresh + t_max) / t_max, 0, 1)
33+
local timer_size = {
34+
mod:get("dodge_timer_width") * (1 - natural_time),
35+
mod:get("dodge_timer_height"),
36+
}
37+
local timer_color = {}
38+
local color_start = Color[mod:get("color_start")](255, true)
39+
local color_end = Color[mod:get("color_end")](255, true)
40+
for i = 1, 4 do
41+
table.insert(
42+
timer_color,
43+
math.lerp(
44+
color_start[i],
45+
color_end[i],
46+
natural_time
47+
)
48+
)
49+
end
50+
-- Hide timer if dodges are full (useful when playing with the Agile blessing)
51+
if current_dodges == 0 then
52+
timer_color[1] = 0
53+
end
54+
return timer_size, timer_color
55+
end
56+
57+
local timer_pass = { {
58+
style_id = "timer",
59+
pass_type = "rect",
60+
style = {
61+
color = {255, 255, 100, 100},
62+
vertical_alignment = "top",
63+
horizontal_alignment = "center",
64+
drop_shadow = true,
65+
size = {100, 8},
66+
offset = {
67+
timer_x_offset,
68+
mod:get("dodge_timer_y_offset"),
69+
},
70+
},
71+
visibility_function = function(content, style)
72+
return mod:get("dodge_timer")
73+
end,
74+
} }
75+
2376
local style = {
2477
line_spacing = 1.2,
2578
font_size = 25,
@@ -41,6 +94,12 @@ local widget_definitions = {
4194
"container"
4295
),
4396

97+
dodge_timer = UIWidget.create_definition(
98+
timer_pass
99+
,
100+
"container"
101+
),
102+
44103
debug_dodge_count = UIWidget.create_definition({
45104
{
46105
value_id = "text",
@@ -110,6 +169,7 @@ HudElementDodgeCount.update = function(self, dt, t, ui_renderer, render_settings
110169
-- Reset to empty in case we can't fill it in
111170
self._widgets_by_name.dodge_count.content.text = ""
112171
self._widgets_by_name.debug_dodge_count.content.text = ""
172+
self._widgets_by_name.dodge_timer.style.timer.size = {0, 0}
113173

114174
if self._is_in_hub or not mod:get("dodge_count") then
115175
return
@@ -138,6 +198,27 @@ HudElementDodgeCount.update = function(self, dt, t, ui_renderer, render_settings
138198
gameplay_t
139199
)
140200

201+
local archetype = unit_data_extension:archetype()
202+
local base_dodge_template = archetype.dodge
203+
local weapon_consecutive_dodges_reset = weapon_dodge_template and weapon_dodge_template.consecutive_dodges_reset or 0
204+
local stat_buffs = buff_extension:stat_buffs()
205+
local buff_modifier = stat_buffs.dodge_cooldown_reset_modifier
206+
local buff_dodge_cooldown_reset_modifier = buff_modifier and 1 - (buff_modifier - 1) or 1
207+
local relative_cooldown = (base_dodge_template.consecutive_dodges_reset + weapon_consecutive_dodges_reset) * buff_dodge_cooldown_reset_modifier
208+
209+
local is_actually_dodging = (movement_state_component.method ~= "vaulting") and movement_state_component.is_dodging
210+
local relative_time = gameplay_t - dodge_state_component.consecutive_dodges_cooldown
211+
local force_show_max_width = current_dodges ~= 0 and (is_actually_dodging or movement_state_component.method == "sliding")
212+
local timer_size, timer_color = timer_size_color(
213+
relative_time,
214+
relative_cooldown,
215+
current_dodges,
216+
force_show_max_width
217+
)
218+
219+
self._widgets_by_name.dodge_timer.style.timer.size = timer_size or {0, 0}
220+
self._widgets_by_name.dodge_timer.style.timer.color = timer_color or Color.text_default(0, true)
221+
141222
if num_efficient_dodges == math.huge then
142223
if mod:get("show_dodge_count_for_infinite_dodge") then
143224
self._widgets_by_name.dodge_count.content.text = tostring(current_dodges)

NumericUI/scripts/mods/NumericUI/NumericUI_data.lua

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
local mod = get_mod("NumericUI")
22

3+
local color_options = {}
4+
for _, color_name in ipairs(Color.list) do
5+
table.insert(color_options, {
6+
text = color_name,
7+
value = color_name
8+
})
9+
end
10+
table.sort(color_options, function(a, b)
11+
return a.text < b.text
12+
end)
13+
14+
local function get_color_options()
15+
return table.clone(color_options)
16+
end
17+
318
return {
419
name = mod:localize("mod_name"),
520
description = mod:localize("mod_description"),
@@ -94,6 +109,54 @@ return {
94109
},
95110
},
96111
},
112+
{
113+
setting_id = "dodge_count_timer_items",
114+
type = "group",
115+
sub_widgets = {
116+
{
117+
setting_id = "dodge_timer",
118+
type = "checkbox",
119+
default_value = false,
120+
},
121+
{
122+
setting_id = "color_start",
123+
type = "dropdown",
124+
default_value = "ui_orange_light",
125+
options = get_color_options()
126+
},
127+
{
128+
setting_id = "color_end",
129+
type = "dropdown",
130+
default_value = "ui_red_light",
131+
options = get_color_options()
132+
},
133+
{
134+
setting_id = "dodge_timer_y_offset",
135+
type = "numeric",
136+
default_value = 30,
137+
range = {-50, 50},
138+
step_size_value = 2,
139+
},
140+
{
141+
setting_id = "dodge_timer_width",
142+
type = "numeric",
143+
default_value = 208,
144+
range = {0, 500},
145+
step_size_value = 4,
146+
},
147+
{
148+
setting_id = "dodge_timer_height",
149+
type = "numeric",
150+
default_value = 9,
151+
range = {0, 20},
152+
},
153+
{
154+
setting_id = "dodge_timer_hide_full",
155+
type = "checkbox",
156+
default_value = false,
157+
},
158+
},
159+
},
97160
{
98161
setting_id = "player_ammo_items",
99162
type = "group",

NumericUI/scripts/mods/NumericUI/NumericUI_localization.lua

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
return {
1+
local InputUtils = require("scripts/managers/input/input_utils")
2+
3+
local function readable(text)
4+
local readable_string = ""
5+
local tokens = string.split(text, "_")
6+
for _, token in ipairs(tokens) do
7+
local first_letter = string.sub(token, 1, 1)
8+
token = string.format("%s%s", string.upper(first_letter), string.sub(token, 2))
9+
readable_string = string.trim(string.format("%s %s", readable_string, token))
10+
end
11+
12+
return readable_string
13+
end
14+
15+
local loc = {
216
mod_name = {
317
en = "Numeric UI",
418
ru = "Числовой интерфейс",
@@ -34,6 +48,11 @@ return {
3448
ru = "Интерфейс счётчика уклонений",
3549
fr = "ATH pour le nombre d'esquive",
3650
},
51+
dodge_count_timer_items = {
52+
-- Needs loc
53+
en = "Dodge Count Reset Timer HUD",
54+
fr = "ATH pour le temps de réinitialisation du nombre d'esquive",
55+
},
3756
team_hud_items = {
3857
en = "Team HUD",
3958
["zh-cn"] = "团队 HUD",
@@ -132,6 +151,66 @@ return {
132151
ru = "Показывать количество уклонений",
133152
fr = "Affiche la quantité d'esquive",
134153
},
154+
dodge_timer = {
155+
-- Needs loc
156+
en = "Show dodge count reset timer",
157+
fr = "Affiche une barre de progrès pour la réinitialisation du nombre d'esquive",
158+
},
159+
color_start = {
160+
-- Needs loc
161+
en = "Timer color - Start",
162+
fr = "Couleur de la barre - Début",
163+
},
164+
color_start_description = {
165+
-- Needs loc
166+
en = "\nDefault value: UI Orange Light",
167+
fr = "\nValeur par défaut : UI Orange Light",
168+
},
169+
color_end = {
170+
-- Needs loc
171+
en = "Timer color - End",
172+
fr = "Couleur de la barre - Fin"
173+
},
174+
color_end_description = {
175+
-- Needs loc
176+
en = "\nDefault value: UI Red Light",
177+
fr = "\nValeur par défaut : UI Red Light",
178+
},
179+
dodge_timer_y_offset = {
180+
-- Needs loc
181+
en = "Vertical offset",
182+
fr = "Décalage vertical",
183+
},
184+
dodge_timer_y_offset_description = {
185+
-- Needs loc
186+
en = "\nDefault value: 30\n\nA higher vertical offset value moves the timer bar down",
187+
fr = "\nValeur par défaut : 30\n\nUn décalage plus grand déplace la barre vers le bas",
188+
},
189+
dodge_timer_width = {
190+
-- Needs loc
191+
en = "Width",
192+
fr = "Largeur",
193+
},
194+
dodge_timer_width_description = {
195+
-- Needs loc
196+
en = "\nDefault value: 208",
197+
fr = "\nValeur par défaut : 208",
198+
},
199+
dodge_timer_height = {
200+
-- Needs loc
201+
en = "Height",
202+
fr = "Hauteur",
203+
},
204+
dodge_timer_height_description = {
205+
-- Needs loc
206+
en = "\nDefault value: 9",
207+
fr = "\nValeur par défaut : 9",
208+
},
209+
dodge_timer_hide_full = {
210+
-- Needs loc
211+
en = "Hide dodge count reset timer when full",
212+
fr = "Cacher la barre elle est au maximum",
213+
},
135214
debug_dodge_count = {
136215
en = "Show debug dodge info",
137216
["zh-cn"] = "显示闪避调试信息",
@@ -351,3 +430,14 @@ return {
351430
en = "Clamp companion nameplates to screen",
352431
},
353432
}
433+
434+
local color_names = Color.list
435+
for _, color_name in ipairs(color_names) do
436+
local color_values = Color[color_name](255, true)
437+
local text = InputUtils.apply_color_to_input_text(readable(color_name), color_values)
438+
loc[color_name] = {
439+
en = text
440+
}
441+
end
442+
443+
return loc

0 commit comments

Comments
 (0)