From 04e7e4090d74aaa514d4241be1c9d6a3b9f4430a Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 3 Apr 2025 13:15:50 +0200 Subject: [PATCH] cleanup config ui --- src/input.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/input.rs b/src/input.rs index 5f8a47b..5f99347 100644 --- a/src/input.rs +++ b/src/input.rs @@ -96,29 +96,29 @@ impl Input { globals.mouse.clear(); } + let buttons_x = 220; + let binding_text_x = buttons_x + 135; + for action_index in 0..ActionId::SIZE { let action = ActionId::from_usize(action_index).unwrap(); d.draw_text(&format!("{action:?}"), 16, y, 20, Color::ORANGE); - if self.bindings[action_index].is_empty() { - y += 32; - } for (binding_index, binding) in self.bindings[action_index].iter().enumerate() { - if text_button(d, &globals.mouse, 160, y, 80, "remove") { + if text_button(d, &globals.mouse, buttons_x, y, 80, "remove") { self.bindings[action_index].remove(binding_index); return; } - if text_button(d, &globals.mouse, 245, y, 45, "edit") { + if text_button(d, &globals.mouse, buttons_x + 85, y, 45, "edit") { self.editing_binding = Some((action, binding_index, BindingEdit::Init)); } let trigger = format!("{:?}", binding.trigger); - d.draw_text(&trigger, 300, y, 20, Color::LIMEGREEN); - let x = 310 + d.measure_text(&trigger, 20); + d.draw_text(&trigger, binding_text_x, y + 5, 20, Color::LIMEGREEN); + let x = binding_text_x + 10 + d.measure_text(&trigger, 20); let modifiers = format!("{:?}", binding.modifiers); - d.draw_text(&modifiers, x, y, 20, Color::LIGHTBLUE); + d.draw_text(&modifiers, x, y + 5, 20, Color::LIGHTBLUE); y += 32; } - if text_button(d, &globals.mouse, 160, y, 130, "add binding") { + if text_button(d, &globals.mouse, buttons_x, y, 130, "add binding") { self.editing_binding = Some((action, self.bindings[action_index].len(), BindingEdit::Init)); }