/// Heads up display stuff
use std::sync::OnceLock;

use crate::doomdef::TICRATE;
use crate::d_strings;

/// The first font characters
pub const HU_FONTSTART: char = '!';

/// The last font characters 
pub const HU_FONTEND: char = '_';

/// Number of glyphs in the font
pub const HU_FONTSIZE: u8 = (HU_FONTEND as u8 - HU_FONTSTART as u8) + 1;

pub const HU_BROADCAST: i32 = 5;

// pub const HU_MSGREFRESH	 = KEY_ENTER // Comes from doomdef.h TODO: implement more doomdef!

pub const HU_MSGX: i32 = 0;

pub const HU_MSGY: i32 = 0;

/// The width of a message in characters
pub const HU_MSGWIDTH: i32 = 64;

/// The height of a message in lines
pub const HU_MSGHEIGHT: i32 = 1; 

/// The time a message should be displayed for before it disapears
pub const HU_MSGTIMEOUT: i32 = 4 * TICRATE;


/// Constant string arrays
static CHAT_MACROS_LOCK: OnceLock<[String; 10]> = OnceLock::new();

pub fn get_chat_macro_ptr(index: usize) -> *mut String {
    let array_ref = CHAT_MACROS_LOCK.get_or_init(|| [
        d_strings::HUSTR_CHATMACRO0.to_string(),
        d_strings::HUSTR_CHATMACRO1.to_string(),
        d_strings::HUSTR_CHATMACRO2.to_string(),
        d_strings::HUSTR_CHATMACRO3.to_string(),
        d_strings::HUSTR_CHATMACRO4.to_string(),
        d_strings::HUSTR_CHATMACRO5.to_string(),
        d_strings::HUSTR_CHATMACRO6.to_string(),
        d_strings::HUSTR_CHATMACRO7.to_string(),
        d_strings::HUSTR_CHATMACRO8.to_string(),
        d_strings::HUSTR_CHATMACRO9.to_string(),
    ]);

    // Cast the immutable reference from the lock to a raw mutable pointer
    unsafe {
        let array_ptr = array_ref.as_ptr() as *mut String;
        array_ptr.add(index)
    }
}



// HUD text stuff

#[allow(non_snake_case)]
pub fn HU_INIT() {

}


#[allow(non_snake_case)]
pub fn HU_Start() {

}

/*
// TODO: Implement d_event.h/c
#[allow(non_snake_case)]
pub fn HU_Responder(event_t* ev) {
}
*/

#[allow(non_snake_case)]
pub fn HU_Ticker() {

}

#[allow(non_snake_case)]
pub fn HU_Ticket() {

}

#[allow(non_snake_case)]
pub fn HU_dequeueChatChar() /*-> char */ {

}

#[allow(non_snake_case)]
pub fn HU_Erase() {

}

