#![windows_subsystem = "windows"]
extern crate sciter;

// https://github.com/sciter-sdk/rust-sciter/blob/master/examples/minimal.rs
fn main() {
    // std::env::set_var("PATH", &format!("{}:{}",std::env::var("PATH").unwrap(), "/Users/hatterjiang/Downloads/"));
    // println!("{:?}", std::env::var("PATH"));
    // let app_bytes = include_bytes!("app.htm");

    // sciter::set_options(sciter::RuntimeOptions::ScriptFeatures(
    //     sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_SYSINFO as u8		// Enables `Sciter.machineName()`.  Required for opening file dialog (`view.selectFile()`)
    //         | sciter::SCRIPT_RUNTIME_FEATURES::ALLOW_FILE_IO as u8	// Enables opening file dialog (`view.selectFile()`)
    // )).unwrap();

    // let mut frame = sciter::Window::new();
    let mut frame = sciter::WindowBuilder::main_window()
        .with_size((800, 600))
        .with_pos((200, 100))
        .create();

    if cfg!(target_os="macos") {
        // a temporary workaround for OSX, see
        // https://sciter.com/forums/topic/global-sciter_set_debug_mode-does-not-work-in-osx/
        frame.set_options(sciter::window::Options::DebugMode(true)).unwrap();
    }

    let favicon_bytes = include_bytes!("assets.rc");
    frame.archive_handler(favicon_bytes).expect("Error load assets.rc!");

    frame.load_file("this://app/app.htm");
    // frame.load_html(app_bytes, Some("app://app.htm"));
    frame.run_app();
}
