~starkingdoms/starkingdoms

1aa4b3b1144024bc1d831e9f69f7aba1b61a6a0b — core 11 months ago aa2aade
ui experiments & the matrix math is wrong
1 files changed, 34 insertions(+), 2 deletions(-)

M starkingdoms-client/src/lib.rs
M starkingdoms-client/src/lib.rs => starkingdoms-client/src/lib.rs +34 -2
@@ 6,7 6,7 @@ use bevy_ecs::event::{EventReader, Events};
use bevy_ecs::schedule::Schedule;
use bevy_ecs::system::ResMut;
use bevy_ecs::world::World;
use egui::Context;
use egui::{Context, DragValue};
use tracing::info;
use winit::event_loop::{ControlFlow, EventLoop};



@@ 100,12 100,44 @@ fn zoom_camera_on_mouse_events(mut events: EventReader<MouseWheelEvent>, mut cam

pub struct Gui {}
impl UiRenderable for Gui {
    fn render(&mut self, ctx: &Context, _world: &mut World) {
    fn render(&mut self, ctx: &Context, world: &mut World) {
        egui::Window::new("Main Menu")
            .resizable(false)
            .show(ctx, |ui| {
                ui.heading("StarKingdoms.TK");
                ui.label("A game about floating through space");
                ui.separator();

                let mut sprites = world.query::<(&mut Translation, &mut Scale, &SpriteTexture, &mut Rotation)>();
                for (mut pos, mut scale, tex, mut rot) in sprites.iter_mut(world) {
                    ui.heading(&tex.texture);
                    
                    egui::Grid::new("sprite_grid")
                        .num_columns(2)
                        .spacing([40.0, 4.0])
                        .striped(true)
                        .show(ui, |ui| {
                            ui.label("X");
                            ui.add(DragValue::new(&mut pos.x).speed(0.1));
                            ui.end_row();

                            ui.label("Y");
                            ui.add(DragValue::new(&mut pos.y).speed(0.1));
                            ui.end_row();

                            ui.label("Width");
                            ui.add(DragValue::new(&mut scale.width).speed(0.1));
                            ui.end_row();

                            ui.label("Height");
                            ui.add(DragValue::new(&mut scale.height).speed(0.1));
                            ui.end_row();

                            ui.label("Rotation");
                            ui.add(DragValue::new(&mut rot.radians).speed(0.1));
                            ui.end_row();
                        });
                }
            });
    }
}