diff --git a/source/editor/editor.c b/source/editor/editor.c index 1718bcb..0f14fc6 100755 --- a/source/editor/editor.c +++ b/source/editor/editor.c @@ -421,8 +421,8 @@ static void edit_mouse_cb(GLFWwindow *w, int button, int action, int mods) } } -struct nk_context *ctx; -struct nk_glfw nkglfw = {0}; +static struct nk_context *ctx; +static struct nk_glfw nkglfw = {0}; void editor_init(struct mSDLWindow *window) { diff --git a/source/engine/mrbffi.c b/source/engine/mrbffi.c index 8160949..6906e6f 100644 --- a/source/engine/mrbffi.c +++ b/source/engine/mrbffi.c @@ -7,6 +7,9 @@ extern mrb_state *mrb; +#include "nuklear.h" +extern struct nk_context *ctx; + int fib(int n) { if (n < 2) return n; @@ -28,8 +31,16 @@ mrb_value mrb_load(mrb_state *mrb, mrb_value self) { return self; } +mrb_value mrb_ui_label(mrb_state *mrb, mrb_value self) { + char *str; + mrb_get_args(mrb, "z", &str); + nk_labelf(ctx, NK_TEXT_LEFT, "%s", str); + return self; +} + void ffi_load() { mrb_define_method(mrb, mrb->object_class, "fib", mrb_fib, MRB_ARGS_REQ(1)); mrb_define_method(mrb, mrb->object_class, "load", mrb_load, MRB_ARGS_REQ(1)); + mrb_define_method(mrb, mrb->object_class, "ui_label", mrb_ui_label, MRB_ARGS_REQ(1)); } diff --git a/source/engine/script.c b/source/engine/script.c index 1cf2578..06d9eba 100755 --- a/source/engine/script.c +++ b/source/engine/script.c @@ -40,4 +40,8 @@ void script_update() { void script_draw() { mrb_funcall(mrb, obj, "draw", 0); +} + +void script_editor() { + mrb_funcall(mrb, obj, "editor", 0); } \ No newline at end of file diff --git a/source/engine/script.h b/source/engine/script.h index 90427e0..0cdb760 100755 --- a/source/engine/script.h +++ b/source/engine/script.h @@ -6,5 +6,6 @@ void script_run(const char *script); void script_dofile(const char *file); void script_update(); void script_draw(); +void script_editor(); #endif