use macroquad::prelude::*;
mod lib;
use crate::lib::*;
#[macroquad::main("UI")]
async fn main() {
    let mut load = 0;
    let mut state = true;
    let mut list_contents = Vec::new();
    let mut tracker = 1;
    let mut scroll = 0;
    let mut statebut = true;
    let mut slide = 0.0;
    let mut slide2 = 0.0;
    let mut current_tab = 3;
    let mut tabs = Vec::new();
    let mut text = "enter crummy text here!:".to_string();
    for i in 0..16{
        list_contents.push("Item ".to_string() + &i.to_string());
        if i <= 7{
            tabs.push("tab ".to_string() + &i.to_string());
        }
    }

    loop {
        clear_background(LIGHTGRAY);
        draw_text("windows 9x style UI for macroquad", 250.0, 80.0, 32.0, BLACK);
        xbutton(50.0, 50.0, "Sqrt(-1) = error.org".to_string());
        statebut = xtogglebutton(50.0, 75.0, "Sqrt(-1) = toggle button".to_string(), statebut).0;
        state = xcheckbox(50.0, 100.0, state);
        scroll = xlist(50.0, 140.0, screen_width() - 100.0, 200.0, &list_contents, scroll);
        xloadbarblocks(50.0, 120.0, screen_width() - 100.0, load);
        slide = xhslider(50.0, 350.0, screen_width() - 100.0, slide);
        slide2 = xvslider(10.0, 50.0, 500.0, slide2);
        text = xinputbox(50.0, 370.0, screen_width() - 100.0, 150.0, text);
        draw_text(slide2.to_string(), 10.0, 40.0, 16.0, BLACK);
        current_tab = xtabs(50.0, 5.0, &tabs, current_tab);
        match current_tab {
            0 => draw_text("Hello,", 50.0, 35.0, 16.0, BLACK),
            1 => draw_text("how", 50.0, 35.0, 16.0, BLACK),
            2 => draw_text("are", 50.0, 35.0, 16.0, BLACK),
            3 => draw_text("you", 50.0, 35.0, 16.0, BLACK),
            4 => draw_text("today,", 50.0, 35.0, 16.0, BLACK),
            5 => draw_text("I", 50.0, 35.0, 16.0, BLACK),
            6 => draw_text("am", 50.0, 35.0, 16.0, BLACK),
            7 => draw_text("good.", 50.0, 35.0, 16.0, BLACK),
            _ => todo!()
        };

        if slide >= 0.5{
            draw_text(slide.to_string(), 50.0, 370.0, 16.0, BLACK);
        }else{
            draw_text(slide.to_string(), screen_width()-100.0, 370.0, 16.0, BLACK);
        }

        next_frame().await;
        if load >= 101{
            load = 0;
        }else{
            load += 1;
        }
    }
}
