#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Atmosphere {
    #[default]
    None,
    Sky,
    CloudySky,
    Space,
    Nebula,
    Sunset,
    Hdr,
}

impl Atmosphere {
    pub const ALL: &'static [Atmosphere] = &[
        Atmosphere::None,
        Atmosphere::Sky,
        Atmosphere::CloudySky,
        Atmosphere::Space,
        Atmosphere::Nebula,
        Atmosphere::Sunset,
        Atmosphere::Hdr,
    ];

    pub fn next(self) -> Self {
        let all = Self::ALL;
        let current_index = all.iter().position(|&a| a == self).unwrap_or(0);
        let next_index = (current_index + 1) % all.len();
        all[next_index]
    }

    pub fn previous(self) -> Self {
        let all = Self::ALL;
        let current_index = all.iter().position(|&a| a == self).unwrap_or(0);
        let prev_index = if current_index == 0 {
            all.len() - 1
        } else {
            current_index - 1
        };
        all[prev_index]
    }
}

pub struct Graphics {
    pub compute_grayscale_enabled: bool,
    pub gpu_culling_enabled: bool,
    pub show_grid: bool,
    pub atmosphere: Atmosphere,
    pub render_layer_world_enabled: bool,
    pub render_layer_overlay_enabled: bool,
    pub use_fullscreen: bool,
    pub show_cursor: bool,
    pub clear_color: [f32; 4],
    pub ui_scale: Option<f32>,
}

impl Default for Graphics {
    fn default() -> Self {
        Self {
            compute_grayscale_enabled: false,
            gpu_culling_enabled: true,
            show_grid: false,
            atmosphere: Atmosphere::None,
            render_layer_world_enabled: true,
            render_layer_overlay_enabled: true,
            use_fullscreen: false,
            show_cursor: true,
            clear_color: [0.0, 0.0, 0.0, 1.0],
            ui_scale: None,
        }
    }
}
