Add controller-driven debug menu

This commit is contained in:
2026-08-30 18:33:40 +02:00
parent 1d5a07324d
commit 8b9e300277
14 changed files with 619 additions and 80 deletions
-27
View File
@@ -1,27 +0,0 @@
use bevy_egui::prelude::*;
use crate::{fighter::{FighterHitboxes, animation::FighterAnimationFrame, visual::FighterAnimations}, input::FighterInput};
use bevy::prelude::*;
pub fn input_debug(mut contexts: EguiContexts, query: Query<&FighterInput>) -> Result {
for (i, input) in query.iter().enumerate() {
const STICK_SIZE: f32 = 50.0;
const STICK_SIZE_FRACTION: f32 = 0.75;
let last_frame = input.get_last_frame();
let movement = egui::Vec2::new(last_frame.movement.x.to_num(), -last_frame.movement.y.to_num::<f32>());
egui::Window::new(format!("Input {}", i)).show(contexts.ctx_mut()?, |ui| {
let (_, rect) = ui.allocate_space(egui::Vec2::new(STICK_SIZE*(1.0 + STICK_SIZE_FRACTION), STICK_SIZE*(1.0 + STICK_SIZE_FRACTION)));
let painter = ui.painter();
let button_bg = egui::Rgba::WHITE * egui::Rgba::from_white_alpha(0.25);
painter.circle_filled(rect.center(), STICK_SIZE * 0.5, button_bg);
painter.circle_filled(
rect.center() + STICK_SIZE * 0.5 * movement,
STICK_SIZE * STICK_SIZE_FRACTION * 0.5,
button_bg,
);
ui.label(format!("X: {:.2}\nY:{:.2}", last_frame.movement.x, last_frame.movement.y));
});
}
Ok(())
}
-3
View File
@@ -3,7 +3,6 @@
use bevy::platform::collections::HashMap;
use bevy::prelude::*;
use bevy_egui::EguiPrimaryContextPass;
use bevy_ggrs::prelude::*;
use bevy_ggrs::{LocalInputs, LocalPlayers};
@@ -14,7 +13,6 @@ pub mod gamecube;
pub mod gamepad;
pub mod keyboard;
pub mod map;
pub mod debug;
pub use buffer::{FighterCommands, FighterInput};
pub use frame::FighterInputFrame;
@@ -106,7 +104,6 @@ impl Plugin for FighterInputPlugin {
})
.add_plugins(gamecube::GamecubeAdapterPlugin)
.add_systems(ReadInputs, read_local_inputs)
.add_systems(EguiPrimaryContextPass, debug::input_debug)
.add_systems(
GgrsSchedule,
buffer::postprocess_input.in_set(GameplaySet::Input),