use std::collections::HashMap;
use winit::event::ElementState;
use winit::keyboard::KeyCode;

#[derive(Default, Clone)]
pub struct SecondaryWindows {
    pub states: Vec<SecondaryWindowState>,
    pub pending_spawns: Vec<WindowSpawnRequest>,
    pub focused_index: Option<usize>,
}

#[derive(Clone)]
pub struct WindowSpawnRequest {
    pub title: String,
    pub width: u32,
    pub height: u32,
    pub egui_enabled: bool,
}

#[derive(Clone)]
pub struct SecondaryWindowState {
    pub index: usize,
    pub title: String,
    pub size: (u32, u32),
    pub is_focused: bool,
    pub input: SecondaryWindowInput,
    pub close_requested: bool,
    pub egui_enabled: bool,
}

#[derive(Clone)]
pub struct SecondaryWindowInput {
    pub mouse_position: nalgebra_glm::Vec2,
    pub mouse_position_delta: nalgebra_glm::Vec2,
    pub mouse_state: crate::ecs::input::resources::MouseState,
    pub keyboard_keystates: HashMap<KeyCode, ElementState>,
    pub mouse_wheel_delta: nalgebra_glm::Vec2,
    pub raw_mouse_delta: nalgebra_glm::Vec2,
    pub frame_keys: Vec<(KeyCode, bool)>,
    pub frame_chars: Vec<char>,
}

impl Default for SecondaryWindowInput {
    fn default() -> Self {
        Self {
            mouse_position: nalgebra_glm::Vec2::zeros(),
            mouse_position_delta: nalgebra_glm::Vec2::zeros(),
            mouse_state: crate::ecs::input::resources::MouseState::empty(),
            keyboard_keystates: HashMap::new(),
            mouse_wheel_delta: nalgebra_glm::Vec2::zeros(),
            raw_mouse_delta: nalgebra_glm::Vec2::zeros(),
            frame_keys: Vec::new(),
            frame_chars: Vec::new(),
        }
    }
}
