use crate::slide::Slide;
use crate::slide_show_config::Context;
use macroquad::input::{KeyCode, is_key_pressed};

pub mod title;

pub struct Slideshow<'a> {
    pub current_slide: usize,
    pub slides: Vec<Box<dyn Slide>>,
    pub ctx: Context<'a>,
}

impl<'a> Slideshow<'a> {
    pub fn new(ctx: Context<'a>) -> Self {
        Self {
            current_slide: 0,
            slides: vec![],
            ctx,
        }
    }

    pub fn add_slide(&mut self, slide: Box<dyn Slide>) {
        self.slides.push(slide);
    }

    pub fn handle_slide_show(&mut self) -> bool {
        if is_key_pressed(KeyCode::Escape) {
            return true;
        };

        self.slides[self.current_slide].display(&self.ctx);

        false
    }
}
