fix gui.cpp

This commit is contained in:
John Alanbrook 2024-08-19 07:47:27 -05:00
parent 849c85cd7a
commit 05acefd683
2 changed files with 7 additions and 6 deletions

View file

@ -40,16 +40,14 @@ JSC_CCALL(imgui_mainmenubar,
}
)
const char* imempty = "##empty";
JSC_CCALL(imgui_menuitem,
char *name = !JS_Is(argv[0]) ? imempty : js2strdup(argv[0]);
char *name = js2strdup(argv[0]);
char *keyfn = JS_IsUndefined(argv[1]) ? NULL : js2strdup(argv[1]);
bool on = JS_IsUndefined(argv[3]) ? false : js2boolean(argv[3]);
if (ImGui::MenuItem(name,keyfn, &on))
if (ImGui::MenuItem(JS_Is(argv[0]) ? name : "##empty" ,keyfn, &on))
script_call_sym(argv[2], 0, NULL);
if (name != imempty) free(name);
if (JS_Is(argv[0])) free(name);
if (keyfn) free(keyfn);
return boolean2js(on);

View file

@ -412,6 +412,9 @@ HMM_Vec3 js2vec3(JSValue v)
HMM_Vec3 js2vec3f(JSValue v)
{
HMM_Vec3 vec;
if (JS_IsArray(js, v))
return js2vec3(v);
else
vec.x = vec.y = vec.z = js2number(v);
return vec;
}