use emmaemu::{
    chip8::computer::Chip8Computer,
    constants::{CHIP8_MEMORY_SIZE, CHIP8_VIDEO_HEIGHT, CHIP8_VIDEO_WIDTH},
};
use imgui::*;
use ratatui::symbols::half_block;
use sys::{ImColor, ImVec2, ImVector_ImU32};
use support::emmagui_support::EmmaGui;
mod support;

fn hello_world_window(ui: &Ui) {

    let mut value = 1;
    let choices = ["test test this is 1", "test test this is 2"];
    ui.window("EmmaGui")
        .size([300.0, 110.0], Condition::FirstUseEver)
        .build(|| {
            ui.text_wrapped("Hello world!");
            ui.text_wrapped("こんにちは世界！");
            if ui.button(choices[value]) {
                value += 1;
                value %= 2;
            }

            ui.button("This...is...imgui-rs!");
            ui.separator();
            let mouse_pos = ui.io().mouse_pos;
            ui.text(format!(
                "Mouse Position: ({:.1},{:.1})",
                mouse_pos[0], mouse_pos[1]
            ));
        });
}


fn main() {
    let system = Chip8Computer::default();
    support::simple_init(file!(), move |_, ui| {

        hello_world_window(ui);

        let mut to_display = Box::new(Vec::new());
        for i in 0..0xFF {
            to_display.push(i);
        }

        EmmaGui::hex_memory_display(to_display, 0x7F, 0x80,ui);

        EmmaGui::system_memory_render(system.memory, ui);

        system.memory.gui_render(ui);

    });
}
