GUI to ruby
This commit is contained in:
parent
9d34354a80
commit
a296b77c45
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,3 +41,7 @@ void script_update() {
|
|||
void script_draw() {
|
||||
mrb_funcall(mrb, obj, "draw", 0);
|
||||
}
|
||||
|
||||
void script_editor() {
|
||||
mrb_funcall(mrb, obj, "editor", 0);
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue