add proper fnl modules to demo
This commit is contained in:
parent
9bb9fa5f5b
commit
47c4f2045c
14 changed files with 510 additions and 240 deletions
|
|
@ -59,8 +59,13 @@ static const char* pxl8_ffi_cdefs =
|
|||
"i32 pxl8_gfx_create_texture(pxl8_gfx* ctx, const u8* pixels, u32 width, u32 height);\n"
|
||||
"void pxl8_gfx_upload_atlas(pxl8_gfx* ctx);\n"
|
||||
"typedef struct pxl8_input_state pxl8_input_state;\n"
|
||||
"bool pxl8_key_down(const pxl8_input_state* input, i32 key);\n"
|
||||
"bool pxl8_key_pressed(const pxl8_input_state* input, i32 key);\n"
|
||||
"bool pxl8_key_down(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"bool pxl8_key_pressed(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"bool pxl8_key_released(const pxl8_input_state* input, const char* key_name);\n"
|
||||
"int pxl8_mouse_wheel_x(const pxl8_input_state* input);\n"
|
||||
"int pxl8_mouse_wheel_y(const pxl8_input_state* input);\n"
|
||||
"int pxl8_mouse_x(const pxl8_input_state* input);\n"
|
||||
"int pxl8_mouse_y(const pxl8_input_state* input);\n"
|
||||
"void pxl8_lua_debug(const char* msg);\n"
|
||||
"void pxl8_lua_error(const char* msg);\n"
|
||||
"void pxl8_lua_info(const char* msg);\n"
|
||||
|
|
@ -168,12 +173,15 @@ static const char* pxl8_ffi_cdefs =
|
|||
"void pxl8_ui_input_scroll(pxl8_ui* ui, int x, int y);\n"
|
||||
"void pxl8_ui_input_text(pxl8_ui* ui, const char* text);\n"
|
||||
"bool pxl8_ui_button(pxl8_ui* ui, const char* label);\n"
|
||||
"bool pxl8_ui_checkbox(pxl8_ui* ui, const char* label, bool* state);\n"
|
||||
"void pxl8_ui_indent(pxl8_ui* ui, int amount);\n"
|
||||
"void pxl8_ui_label(pxl8_ui* ui, const char* text);\n"
|
||||
"void pxl8_ui_layout_row(pxl8_ui* ui, int item_count, const int* widths, int height);\n"
|
||||
"int pxl8_ui_menu(pxl8_ui* ui, pxl8_menu_item* items, int item_count);\n"
|
||||
"void pxl8_ui_panel(pxl8_ui* ui, pxl8_bounds rect, pxl8_frame_theme* theme);\n"
|
||||
"bool pxl8_ui_window_begin(pxl8_ui* ui, const char* title, pxl8_bounds rect, int options);\n"
|
||||
"void pxl8_ui_window_end(pxl8_ui* ui);\n"
|
||||
"void pxl8_ui_window_set_open(pxl8_ui* ui, const char* title, bool open);\n"
|
||||
"pxl8_frame_theme pxl8_ui_theme_default(void);\n";
|
||||
|
||||
void pxl8_lua_info(const char* msg) {
|
||||
|
|
@ -246,6 +254,18 @@ pxl8_script* pxl8_script_create(void) {
|
|||
|
||||
if (luaL_dofile(script->L, "lib/fennel/fennel.lua") == 0) {
|
||||
lua_setglobal(script->L, "fennel");
|
||||
|
||||
lua_getglobal(script->L, "fennel");
|
||||
lua_getfield(script->L, -1, "install");
|
||||
if (lua_isfunction(script->L, -1)) {
|
||||
if (lua_pcall(script->L, 0, 0, 0) != 0) {
|
||||
pxl8_warn("Failed to install fennel searcher: %s", lua_tostring(script->L, -1));
|
||||
lua_pop(script->L, 1);
|
||||
}
|
||||
} else {
|
||||
lua_pop(script->L, 1);
|
||||
}
|
||||
lua_pop(script->L, 1);
|
||||
}
|
||||
|
||||
script->last_error[0] = '\0';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue