mod effects;
mod slide;
mod slide_show_config;
mod slides;
mod text_drawer;

use macroquad::prelude::*;

use crate::slide_show_config::{Context, SlideShowTheme};
use crate::slides::Slideshow;
use crate::slides::title::Title;
use crate::text_drawer::{Justified, TextConfigBuilder};

fn window_conf() -> Conf {
    Conf {
        window_title: "On Deck".to_owned(),
        fullscreen: true,
        platform: miniquad::conf::Platform {
            ..Default::default()
        },
        ..Default::default()
    }
}

#[macroquad::main(window_conf)]
async fn main() {
    let heading = load_ttf_font("fonts/BoldPixels.ttf").await.unwrap();
    let body = load_ttf_font("fonts/ByteBounce.ttf").await.unwrap();

    let slide_show_theme = SlideShowTheme {
        title_config: TextConfigBuilder::default()
            .justification(Justified::Center)
            .font_size(250)
            .font(&heading)
            .color(WHITE)
            .build(),
        heading_config: TextConfigBuilder::default()
            .justification(Justified::CenterHorizontal)
            .font(&heading)
            .color(WHITE)
            .font_size(100)
            .build(),
        body_config: TextConfigBuilder::default()
            .justification(Justified::Left)
            .font(&body)
            .font_size(50)
            .color(WHITE)
            .build(),
    };

    let mut slideshow = Slideshow::new(Context::new(slide_show_theme));

    slideshow.add_slide(Title::new("Software As a Bit".to_string()));

    loop {
        if slideshow.handle_slide_show() {
            return;
        }

        next_frame().await;
    }
}
