use bevy::prelude::*;
use bevy::render::camera::RenderTarget;
use bevy::window::{PrimaryWindow, WindowRef, WindowResolution};
use bevy_egui::EguiMultipassSchedule;
use crate::editor_state::EditorWindow;
use crate::EditorWindowContextPass;
pub fn handle_editor_hotkeys(
input: Res<ButtonInput<KeyCode>>,
primary_window: Query<Entity, With<PrimaryWindow>>,
mut commands: Commands,
) {
if input.pressed(KeyCode::ControlLeft) && input.just_pressed(KeyCode::KeyO) {
if let Ok(_primary_entity) = primary_window.single() {
spawn_editor_window(&mut commands);
}
}
}
fn spawn_editor_window(commands: &mut Commands) {
let window_entity = commands.spawn((
Window {
title: "Gearbox Editor".to_string(),
resolution: WindowResolution::new(1200.0, 800.0),
..default()
},
EditorWindow,
)).id();
commands.spawn((
Camera3d::default(),
Camera {
target: RenderTarget::Window(WindowRef::Entity(window_entity)),
..default()
},
EguiMultipassSchedule::new(EditorWindowContextPass),
EditorWindow, ));
info!("🪟 Spawned new editor window");
}