Skip to content

Commit 2777c14

Browse files
matteopolakCopilot
andcommitted
refactor: type replay input wiring
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c779ef78-f1e2-4b31-8c60-1b7fc8811ccb
1 parent 7d3f218 commit 2777c14

3 files changed

Lines changed: 29 additions & 32 deletions

File tree

src/maps/map_ui.gd

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,33 @@ func on_shot(mag_ammo: int, _reserve_ammo := 0) -> void:
2424
ammo_label.text = "Ammo: %d / Inf" % [mag_ammo]
2525

2626
func _ready() -> void:
27-
var settings_manager = get_node("/root/Global").settings_manager
28-
keybind_info_label.text = ("Press Ctrl to toggle UI\nPress %s to restart" % settings_manager.get_keybind_string("restart"))
27+
keybind_info_label.text = ("Press Ctrl to toggle UI\nPress %s to restart" % Global.settings_manager.get_keybind_string("restart"))
2928
done_replay_btn.pressed.connect(func() -> void: return_control_to_player.emit())
3029

31-
alt_speed_label.visible = settings_manager.value("Display", "speed")
30+
alt_speed_label.visible = Global.settings_manager.value("Display", "speed")
3231

3332
func set_frame(frame: int, total: int) -> void:
3433
tick_label.text = "Tick: %d / %d" % [frame + 1, total]
3534
replay_slider.value = frame
3635
replay_slider.max_value = total - 1
3736

38-
func set_replay_inputs(frame) -> void:
37+
func set_replay_inputs(
38+
forward_input: bool,
39+
back_input: bool,
40+
left_input: bool,
41+
right_input: bool,
42+
shoot_input: bool,
43+
ads_input: bool,
44+
reload_input: bool,
45+
) -> void:
3946
replay_input_display.set_inputs(
40-
frame.forward_input,
41-
frame.back_input,
42-
frame.left_input,
43-
frame.right_input,
44-
frame.shoot_input,
45-
frame.ads_input,
46-
frame.reload_input,
47+
forward_input,
48+
back_input,
49+
left_input,
50+
right_input,
51+
shoot_input,
52+
ads_input,
53+
reload_input,
4754
)
4855

4956
func set_replay_visible(value: bool) -> void:

src/recorder.gd

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ func set_frame(value: int) -> void:
103103
else:
104104
map.map_ui.set_speed(speed)
105105
map.map_ui.set_timer(current_frame * dt)
106-
map.map_ui.set_replay_inputs(frame)
106+
map.map_ui.set_replay_inputs(
107+
frame.forward_input,
108+
frame.back_input,
109+
frame.left_input,
110+
frame.right_input,
111+
frame.shoot_input,
112+
frame.ads_input,
113+
frame.reload_input,
114+
)
107115

108116
if prev_frame.weapon_index != frame.weapon_index:
109117
controller.weapon_handler.set_weapon(Global.game_manager.get_weapon_from_index(frame.weapon_index), is_ghost)

tests/replay_input_display_test.gd

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,8 @@ func _run() -> void:
8484
"MapUi replay_input_display export should reference ReplayContainer/V/ReplayInputDisplay",
8585
)
8686

87-
if t.check(map_ui.has_method("set_replay_inputs"), "MapUi should expose set_replay_inputs(Recorder.Frame)"):
88-
var frame := _RecorderFrame.new()
89-
frame.forward_input = true
90-
frame.back_input = false
91-
frame.left_input = false
92-
frame.right_input = true
93-
frame.shoot_input = false
94-
frame.ads_input = true
95-
frame.reload_input = false
96-
97-
map_ui.set_replay_inputs(frame)
87+
if t.check(map_ui.has_method("set_replay_inputs"), "MapUi should expose set_replay_inputs(bool, bool, bool, bool, bool, bool, bool)"):
88+
map_ui.set_replay_inputs(true, false, false, true, false, true, false)
9889
if replay_input_display != null:
9990
_check_input_state(t, replay_input_display, &"forward", true)
10091
_check_input_state(t, replay_input_display, &"right", true)
@@ -126,12 +117,3 @@ func _panel_stylebox(replay_input_display: Node, label_path: String) -> StyleBox
126117

127118
var parent_control := label.get_parent() as Control
128119
return parent_control.get_theme_stylebox("panel") if parent_control != null else null
129-
130-
class _RecorderFrame:
131-
var forward_input: bool
132-
var back_input: bool
133-
var left_input: bool
134-
var right_input: bool
135-
var shoot_input: bool
136-
var ads_input: bool
137-
var reload_input: bool

0 commit comments

Comments
 (0)