2023-11-03 22:01:30 -05:00
|
|
|
#include "jsffi.h"
|
2023-01-10 07:13:00 -06:00
|
|
|
|
|
|
|
#include "script.h"
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "anim.h"
|
2023-12-22 11:50:03 -06:00
|
|
|
#include "timer.h"
|
2023-03-24 14:01:01 -05:00
|
|
|
#include "debug.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "debugdraw.h"
|
2023-01-10 15:41:43 -06:00
|
|
|
#include "font.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "gameobject.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "log.h"
|
2023-11-27 14:29:55 -06:00
|
|
|
#include "dsp.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "music.h"
|
2023-09-15 03:37:07 -05:00
|
|
|
#include "2dphysics.h"
|
2023-11-27 14:29:55 -06:00
|
|
|
#include "datastream.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "sound.h"
|
|
|
|
#include "sprite.h"
|
2023-02-05 17:42:36 -06:00
|
|
|
#include "stb_ds.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "string.h"
|
|
|
|
#include "window.h"
|
2023-12-04 13:38:37 -06:00
|
|
|
#include "spline.h"
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "yugine.h"
|
2023-04-21 16:57:30 -05:00
|
|
|
#include <assert.h>
|
2023-09-04 09:48:44 -05:00
|
|
|
#include "resources.h"
|
2023-09-11 02:46:12 -05:00
|
|
|
#include <sokol/sokol_time.h>
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
#include "render.h"
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
#include "model.h"
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
#include "HandmadeMath.h"
|
|
|
|
|
|
|
|
static JSValue globalThis;
|
|
|
|
|
2023-10-16 09:40:43 -05:00
|
|
|
static JSClassID js_ptr_id;
|
|
|
|
static JSClassDef js_ptr_class = { "POINTER" };
|
|
|
|
|
2023-11-29 07:32:32 -06:00
|
|
|
#define QJSCLASS(TYPE)\
|
|
|
|
static JSClassID js_ ## TYPE ## _id;\
|
|
|
|
static void js_##TYPE##_finalizer(JSRuntime *rt, JSValue val){\
|
|
|
|
TYPE *n = JS_GetOpaque(val, js_##TYPE##_id);\
|
|
|
|
TYPE##_free(n);}\
|
|
|
|
static JSClassDef js_##TYPE##_class = {\
|
|
|
|
#TYPE,\
|
2023-11-29 12:40:13 -06:00
|
|
|
.finalizer = js_##TYPE##_finalizer,\
|
2023-11-29 07:32:32 -06:00
|
|
|
};\
|
|
|
|
static TYPE *js2##TYPE (JSValue val) { return JS_GetOpaque(val,js_##TYPE##_id); }\
|
2023-11-29 12:40:13 -06:00
|
|
|
static JSValue TYPE##2js(TYPE *n) { \
|
2023-11-29 07:32:32 -06:00
|
|
|
JSValue j = JS_NewObjectClass(js,js_##TYPE##_id);\
|
|
|
|
JS_SetOpaque(j,n);\
|
|
|
|
return j; }\
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
QJSCLASS(dsp_node)
|
2023-11-29 12:40:13 -06:00
|
|
|
QJSCLASS(gameobject)
|
|
|
|
|
2023-11-29 07:32:32 -06:00
|
|
|
#define QJSCLASSPREP(TYPE) \
|
|
|
|
JS_NewClassID(&js_##TYPE##_id);\
|
|
|
|
JS_NewClass(JS_GetRuntime(js), js_##TYPE##_id, &js_##TYPE##_class);\
|
|
|
|
|
2023-02-02 17:52:15 -06:00
|
|
|
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
|
2023-05-12 13:22:05 -05:00
|
|
|
#define BYTE_TO_BINARY(byte) \
|
|
|
|
(byte & 0x80 ? '1' : '0'), \
|
|
|
|
(byte & 0x40 ? '1' : '0'), \
|
|
|
|
(byte & 0x20 ? '1' : '0'), \
|
|
|
|
(byte & 0x10 ? '1' : '0'), \
|
|
|
|
(byte & 0x08 ? '1' : '0'), \
|
|
|
|
(byte & 0x04 ? '1' : '0'), \
|
|
|
|
(byte & 0x02 ? '1' : '0'), \
|
|
|
|
(byte & 0x01 ? '1' : '0')
|
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
void js_setprop_str(JSValue obj, const char *prop, JSValue v) { JS_SetPropertyStr(js, obj, prop, v); }
|
2023-10-03 17:16:38 -05:00
|
|
|
|
2023-12-09 22:09:15 -06:00
|
|
|
JSValue jstzone()
|
|
|
|
{
|
|
|
|
time_t t = time(NULL);
|
2023-12-21 10:49:44 -06:00
|
|
|
time_t local_t = mktime(localtime(&t));
|
|
|
|
double diff = difftime(t, local_t);
|
|
|
|
return num2js(diff/3600);
|
2023-12-09 22:09:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int js2bool(JSValue v) { return JS_ToBool(js, v); }
|
|
|
|
|
|
|
|
JSValue bool2js(int b) { return JS_NewBool(js,b); }
|
|
|
|
|
|
|
|
JSValue jsdst()
|
|
|
|
{
|
|
|
|
time_t t = time(NULL);
|
2023-12-21 10:49:44 -06:00
|
|
|
return bool2js(localtime(&t)->tm_isdst);
|
2023-12-09 22:09:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
JSValue jscurtime()
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
time(&t);
|
|
|
|
JSValue jst = num2js(t);
|
|
|
|
return jst;
|
|
|
|
}
|
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
void js_setprop_num(JSValue obj, uint32_t i, JSValue v) { JS_SetPropertyUint32(js, obj, i, v); }
|
2023-11-29 12:40:13 -06:00
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
JSValue gos2ref(gameobject **go)
|
2023-11-29 12:40:13 -06:00
|
|
|
{
|
|
|
|
JSValue array = JS_NewArray(js);
|
|
|
|
for (int i = 0; i < arrlen(go); i++)
|
2023-12-19 15:34:36 -06:00
|
|
|
js_setprop_num(array,i,JS_DupValue(js,go[i]->ref));
|
2023-11-29 12:40:13 -06:00
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
JSValue js_getpropstr(JSValue v, const char *str)
|
|
|
|
{
|
|
|
|
JSValue p = JS_GetPropertyStr(js,v,str);
|
|
|
|
JS_FreeValue(js,p);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSValue js_getpropidx(JSValue v, uint32_t i)
|
|
|
|
{
|
|
|
|
JSValue p = JS_GetPropertyUint32(js,v,i);
|
|
|
|
JS_FreeValue(js,p);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2023-09-11 02:46:12 -05:00
|
|
|
uint64_t js2uint64(JSValue v)
|
|
|
|
{
|
|
|
|
int64_t i;
|
|
|
|
JS_ToInt64(js, &i, v);
|
|
|
|
uint64_t n = i;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
int js2int(JSValue v) {
|
2023-04-19 15:16:35 -05:00
|
|
|
int32_t i;
|
2023-05-12 13:22:05 -05:00
|
|
|
JS_ToInt32(js, &i, v);
|
2023-04-18 14:49:17 -05:00
|
|
|
return i;
|
2023-02-06 16:41:47 -06:00
|
|
|
}
|
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
JSValue int2js(int i) { return JS_NewInt64(js, i); }
|
2023-04-18 17:58:44 -05:00
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
JSValue str2js(const char *c) { return JS_NewString(js, c); }
|
|
|
|
const char *js2str(JSValue v) { return JS_ToCString(js, v); }
|
2023-10-10 17:37:58 -05:00
|
|
|
|
2023-12-21 17:21:01 -06:00
|
|
|
JSValue strarr2js(char **c)
|
2023-09-11 02:46:12 -05:00
|
|
|
{
|
|
|
|
JSValue arr = JS_NewArray(js);
|
2023-09-13 01:08:32 -05:00
|
|
|
for (int i = 0; i < arrlen(c); i++)
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_num(arr,i,JS_NewString(js, c[i]));
|
2023-09-11 02:46:12 -05:00
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
double js2number(JSValue v) {
|
2023-04-18 17:58:44 -05:00
|
|
|
double g;
|
2023-05-12 13:22:05 -05:00
|
|
|
JS_ToFloat64(js, &g, v);
|
2023-04-18 17:58:44 -05:00
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
JSValue float2js(double g) { return JS_NewFloat64(js, g);}
|
|
|
|
JSValue num2js(double g) { return float2js(g); }
|
2023-09-12 17:19:46 -05:00
|
|
|
struct sprite *js2sprite(JSValue v) { return id2sprite(js2int(v)); }
|
2023-05-27 07:01:17 -05:00
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
void *js2ptr(JSValue v) { return JS_GetOpaque(v,js_ptr_id); }
|
2023-04-18 17:58:44 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue ptr2js(void *ptr) {
|
2023-10-16 09:40:43 -05:00
|
|
|
JSValue obj = JS_NewObjectClass(js, js_ptr_id);
|
|
|
|
JS_SetOpaque(obj, ptr);
|
|
|
|
return obj;
|
2023-04-18 17:58:44 -05:00
|
|
|
}
|
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
struct timer *js2timer(JSValue v) { return id2timer(js2int(v)); }
|
2023-04-18 14:49:17 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
double js_get_prop_number(JSValue v, const char *p) {
|
2023-04-19 15:16:35 -05:00
|
|
|
double num;
|
2023-05-24 20:45:50 -05:00
|
|
|
JS_ToFloat64(js, &num, js_getpropstr(v,p));
|
2023-04-18 14:49:17 -05:00
|
|
|
return num;
|
2023-03-05 22:05:22 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
struct glrect js2glrect(JSValue v) {
|
2023-03-05 22:05:22 -06:00
|
|
|
struct glrect rect;
|
2023-05-12 13:22:05 -05:00
|
|
|
rect.s0 = js_get_prop_number(v, "s0");
|
|
|
|
rect.s1 = js_get_prop_number(v, "s1");
|
|
|
|
rect.t0 = js_get_prop_number(v, "t0");
|
|
|
|
rect.t1 = js_get_prop_number(v, "t1");
|
2023-03-05 22:05:22 -06:00
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
JSValue js_arridx(JSValue v, int idx) { return js_getpropidx(v, idx); }
|
2023-04-19 15:16:35 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
int js_arrlen(JSValue v) {
|
2023-04-18 14:49:17 -05:00
|
|
|
int len;
|
2023-05-24 20:45:50 -05:00
|
|
|
JS_ToInt32(js, &len, js_getpropstr( v, "length"));
|
2023-04-18 14:49:17 -05:00
|
|
|
return len;
|
|
|
|
}
|
2023-05-16 01:31:13 -05:00
|
|
|
|
|
|
|
struct rgba js2color(JSValue v) {
|
2023-05-24 20:45:50 -05:00
|
|
|
JSValue c[4];
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
c[i] = js_arridx(v,i);
|
2023-09-23 12:35:02 -05:00
|
|
|
float a = JS_IsUndefined(c[3]) ? 1.0 : js2number(c[3]);
|
2023-05-16 01:31:13 -05:00
|
|
|
struct rgba color = {
|
2023-09-23 12:35:02 -05:00
|
|
|
.r = js2number(c[0])*RGBA_MAX,
|
|
|
|
.g = js2number(c[1])*RGBA_MAX,
|
|
|
|
.b = js2number(c[2])*RGBA_MAX,
|
|
|
|
.a = a*RGBA_MAX,
|
2023-05-16 01:31:13 -05:00
|
|
|
};
|
2023-05-24 20:45:50 -05:00
|
|
|
|
2023-10-03 17:16:38 -05:00
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
JS_FreeValue(js,c[i]);
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
return color;
|
2023-04-19 15:16:35 -05:00
|
|
|
}
|
2023-01-27 12:06:16 -06:00
|
|
|
|
2023-10-31 12:38:23 -05:00
|
|
|
JSValue color2js(struct rgba color)
|
|
|
|
{
|
|
|
|
JSValue arr = JS_NewArray(js);
|
|
|
|
js_setprop_num(arr,0,JS_NewFloat64(js,(double)color.r/255));
|
|
|
|
js_setprop_num(arr,1,JS_NewFloat64(js,(double)color.g/255));
|
|
|
|
js_setprop_num(arr,2,JS_NewFloat64(js,(double)color.b/255));
|
|
|
|
js_setprop_num(arr,3,JS_NewFloat64(js,(double)color.a/255));
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2023-10-04 08:18:09 -05:00
|
|
|
struct boundingbox js2bb(JSValue v)
|
|
|
|
{
|
|
|
|
struct boundingbox bb;
|
|
|
|
bb.t = js2number(js_getpropstr(v,"t"));
|
|
|
|
bb.b = js2number(js_getpropstr(v,"b"));
|
|
|
|
bb.r = js2number(js_getpropstr(v,"r"));
|
|
|
|
bb.l = js2number(js_getpropstr(v,"l"));
|
|
|
|
return bb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 js2vec2(JSValue v)
|
2023-05-24 20:45:50 -05:00
|
|
|
{
|
|
|
|
HMM_Vec2 v2;
|
|
|
|
v2.X = js2number(js_getpropidx(v,0));
|
|
|
|
v2.Y = js2number(js_getpropidx(v,1));
|
|
|
|
return v2;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
cpBitmask js2bitmask(JSValue v) {
|
|
|
|
cpBitmask mask = 0;
|
|
|
|
int len = js_arrlen(v);
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
for (int i = 0; i < len; i++) {
|
2023-05-24 20:45:50 -05:00
|
|
|
int val = JS_ToBool(js, js_getpropidx( v, i));
|
2023-05-12 13:22:05 -05:00
|
|
|
if (!val) continue;
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
mask |= 1 << i;
|
|
|
|
}
|
2023-02-02 17:52:15 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
return mask;
|
2023-02-02 17:52:15 -06:00
|
|
|
}
|
|
|
|
|
2023-10-29 16:39:45 -05:00
|
|
|
/* Does not need to be freed by returning; but not reentrant */
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 *js2cpvec2arr(JSValue v) {
|
2023-12-12 19:35:34 -06:00
|
|
|
HMM_Vec2 *arr = NULL;
|
2023-04-18 14:49:17 -05:00
|
|
|
int n = js_arrlen(v);
|
2023-12-18 06:45:27 -06:00
|
|
|
arrsetlen(arr,n);
|
|
|
|
|
2023-04-18 14:49:17 -05:00
|
|
|
for (int i = 0; i < n; i++)
|
2023-12-18 06:45:27 -06:00
|
|
|
arr[i] = js2vec2(js_getpropidx( v, i));
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
2023-02-08 15:30:12 -06:00
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
HMM_Vec2 *jsfloat2vec(JSValue v)
|
|
|
|
{
|
|
|
|
size_t s;
|
|
|
|
void *buf = JS_GetArrayBuffer(js, &s, v);
|
|
|
|
HMM_Vec2 *arr = NULL;
|
|
|
|
int n = s/2;
|
|
|
|
n /= sizeof(float);
|
|
|
|
// arrsetcap(arr,n);
|
|
|
|
// memcpy(arr,buf,s);
|
2023-12-12 19:35:34 -06:00
|
|
|
return arr;
|
2023-02-08 15:30:12 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue bitmask2js(cpBitmask mask) {
|
2023-04-19 16:58:17 -05:00
|
|
|
JSValue arr = JS_NewArray(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
for (int i = 0; i < 11; i++)
|
|
|
|
js_setprop_num(arr,i,JS_NewBool(js,mask & 1 << i));
|
2023-04-18 14:49:17 -05:00
|
|
|
|
|
|
|
return arr;
|
2023-02-02 17:52:15 -06:00
|
|
|
}
|
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
void vec2float(HMM_Vec2 v, float *f) {
|
2023-05-12 13:22:05 -05:00
|
|
|
f[0] = v.x;
|
|
|
|
f[1] = v.y;
|
2023-01-19 18:30:23 -06:00
|
|
|
}
|
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
JSValue vec2js(HMM_Vec2 v) {
|
2023-04-19 15:16:35 -05:00
|
|
|
JSValue array = JS_NewArray(js);
|
2023-12-12 08:46:27 -06:00
|
|
|
js_setprop_num(array,0,num2js(v.x));
|
|
|
|
js_setprop_num(array,1,num2js(v.y));
|
2023-04-18 14:49:17 -05:00
|
|
|
return array;
|
2023-03-19 20:33:05 -05:00
|
|
|
}
|
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
JSValue vecarr2js(HMM_Vec2 *points, int n) {
|
2023-04-19 16:58:17 -05:00
|
|
|
JSValue array = JS_NewArray(js);
|
2023-05-12 13:22:05 -05:00
|
|
|
for (int i = 0; i < n; i++)
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_num(array,i,vec2js(points[i]));
|
|
|
|
|
2023-04-18 14:49:17 -05:00
|
|
|
return array;
|
2023-02-02 17:52:15 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_ui_text(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-12-21 17:21:01 -06:00
|
|
|
const char *s = JS_ToCString(js, argv[0]);
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 pos = js2vec2(argv[1]);
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
float size = js2number(argv[2]);
|
2023-05-16 01:31:13 -05:00
|
|
|
struct rgba c = js2color(argv[3]);
|
2023-05-12 13:22:05 -05:00
|
|
|
int wrap = js2int(argv[4]);
|
2023-10-04 17:57:37 -05:00
|
|
|
int cursor = js2int(argv[5]);
|
|
|
|
JSValue ret = JS_NewInt64(js, renderText(s, pos, size, c, wrap, cursor, 1.0));
|
2023-05-12 13:22:05 -05:00
|
|
|
JS_FreeCString(js, s);
|
|
|
|
return ret;
|
2023-03-10 13:13:48 -06:00
|
|
|
}
|
|
|
|
|
2023-10-10 17:37:58 -05:00
|
|
|
int js_print_exception(JSValue v)
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if (!JS_IsException(v))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
JSValue ex = JS_GetException(js);
|
|
|
|
|
|
|
|
const char *name = JS_ToCString(js, js_getpropstr(ex, "name"));
|
|
|
|
const char *msg = js2str(js_getpropstr(ex, "message"));
|
|
|
|
const char *stack = js2str(js_getpropstr(ex, "stack"));
|
|
|
|
int line = 0;
|
|
|
|
mYughLog(LOG_SCRIPT, LOG_ERROR, line, "script", "%s :: %s\n%s", name, msg, stack);
|
|
|
|
|
|
|
|
JS_FreeCString(js, name);
|
|
|
|
JS_FreeCString(js, msg);
|
|
|
|
JS_FreeCString(js, stack);
|
|
|
|
JS_FreeValue(js,ex);
|
|
|
|
return 1;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_gui_img(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
const char *img = JS_ToCString(js, argv[0]);
|
2023-11-30 10:47:59 -06:00
|
|
|
transform2d t;
|
|
|
|
t.pos = js2vec2(argv[1]);
|
|
|
|
t.scale = js2vec2(argv[2]);
|
|
|
|
t.angle = js2number(argv[3]);
|
|
|
|
gui_draw_img(img, t, js2bool(argv[4]), js2vec2(argv[5]), 1.0, js2color(argv[6]));
|
2023-05-12 13:22:05 -05:00
|
|
|
JS_FreeCString(js, img);
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 17:23:11 -06:00
|
|
|
}
|
|
|
|
|
2023-09-05 09:38:52 -05:00
|
|
|
struct rect js2rect(JSValue v) {
|
|
|
|
struct rect rect;
|
2023-05-24 20:45:50 -05:00
|
|
|
rect.x = js2number(js_getpropstr(v, "x"));
|
|
|
|
rect.y = js2number(js_getpropstr(v, "y"));
|
|
|
|
rect.w = js2number(js_getpropstr(v, "w"));
|
|
|
|
rect.h = js2number(js_getpropstr(v, "h"));
|
2023-04-18 17:58:44 -05:00
|
|
|
return rect;
|
|
|
|
}
|
|
|
|
|
2023-10-03 17:16:38 -05:00
|
|
|
|
2023-09-05 09:38:52 -05:00
|
|
|
JSValue rect2js(struct rect rect) {
|
2023-04-18 17:58:44 -05:00
|
|
|
JSValue obj = JS_NewObject(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_str(obj, "x", JS_NewFloat64(js, rect.x));
|
|
|
|
js_setprop_str(obj, "y", JS_NewFloat64(js, rect.y));
|
|
|
|
js_setprop_str(obj, "w", JS_NewFloat64(js, rect.w));
|
|
|
|
js_setprop_str(obj, "h", JS_NewFloat64(js, rect.h));
|
2023-04-18 17:58:44 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2023-05-30 13:07:18 -05:00
|
|
|
JSValue bb2js(struct boundingbox bb)
|
|
|
|
{
|
|
|
|
JSValue obj = JS_NewObject(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_str(obj,"t", JS_NewFloat64(js,bb.t));
|
|
|
|
js_setprop_str(obj,"b", JS_NewFloat64(js,bb.b));
|
|
|
|
js_setprop_str(obj,"r", JS_NewFloat64(js,bb.r));
|
|
|
|
js_setprop_str(obj,"l", JS_NewFloat64(js,bb.l));
|
2023-05-30 13:07:18 -05:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_spline_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-12-12 08:46:27 -06:00
|
|
|
int cmd = js2int(argv[0]);
|
2023-12-04 13:38:37 -06:00
|
|
|
/*
|
2023-12-13 19:53:09 -06:00
|
|
|
0: catmull-rom
|
|
|
|
1: bezier
|
2023-12-04 13:38:37 -06:00
|
|
|
*/
|
2023-12-13 19:53:09 -06:00
|
|
|
|
|
|
|
int type = js2int(argv[1]);
|
2023-12-12 08:46:27 -06:00
|
|
|
int d = js2int(argv[2]); /* dimensions: 1d, 2d, 3d ...*/
|
|
|
|
HMM_Vec2 *points = js2cpvec2arr(argv[3]);
|
|
|
|
float param = js2number(argv[4]);
|
2023-12-13 19:53:09 -06:00
|
|
|
HMM_Vec2 *samples = NULL;
|
|
|
|
switch(type) {
|
|
|
|
case 0:
|
|
|
|
samples = catmull_rom_ma_v2(points, param);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
samples = bezier_cb_ma_v2(points, param);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-12-12 19:35:34 -06:00
|
|
|
arrfree(points);
|
|
|
|
|
2023-12-12 08:46:27 -06:00
|
|
|
if (!samples)
|
|
|
|
return JS_UNDEFINED;
|
2023-01-27 12:06:16 -06:00
|
|
|
|
2023-12-12 08:46:27 -06:00
|
|
|
JSValue arr = vecarr2js(samples, arrlen(samples));
|
2023-12-12 19:35:34 -06:00
|
|
|
arrfree(samples);
|
2023-12-12 08:46:27 -06:00
|
|
|
|
|
|
|
return arr;
|
2023-01-27 12:06:16 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue ints2js(int *ints) {
|
2023-04-19 16:58:17 -05:00
|
|
|
JSValue arr = JS_NewArray(js);
|
2023-04-18 17:58:44 -05:00
|
|
|
for (int i = 0; i < arrlen(ints); i++)
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_num(arr,i,int2js(ints[i]));
|
2023-04-18 17:58:44 -05:00
|
|
|
|
|
|
|
return arr;
|
2023-02-05 17:42:36 -06:00
|
|
|
}
|
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
int vec_between(HMM_Vec2 p, HMM_Vec2 a, HMM_Vec2 b) {
|
|
|
|
HMM_Vec2 n;
|
2023-02-10 14:31:58 -06:00
|
|
|
n.x = b.x - a.x;
|
|
|
|
n.y = b.y - a.y;
|
2023-11-14 09:20:09 -06:00
|
|
|
n = HMM_NormV2(n);
|
2023-02-10 14:31:58 -06:00
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
return HMM_DotV2(n, HMM_SubV2(p,a)) > 0 && HMM_DotV2(HMM_MulV2F(n, -1), HMM_SubV2(p,b)) > 0;
|
2023-02-10 14:31:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determines between which two points in 'segs' point 'p' falls.
|
|
|
|
0 indicates 'p' comes before the first point.
|
|
|
|
arrlen(segs) indicates it comes after the last point.
|
|
|
|
*/
|
2023-11-14 09:20:09 -06:00
|
|
|
int point2segindex(HMM_Vec2 p, HMM_Vec2 *segs, double slop) {
|
2023-02-10 14:31:58 -06:00
|
|
|
float shortest = slop < 0 ? INFINITY : slop;
|
2023-02-08 15:30:12 -06:00
|
|
|
int best = -1;
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
for (int i = 0; i < arrlen(segs) - 1; i++) {
|
|
|
|
float a = (segs[i + 1].y - segs[i].y) / (segs[i + 1].x - segs[i].x);
|
2023-02-08 15:30:12 -06:00
|
|
|
float c = segs[i].y - (a * segs[i].x);
|
|
|
|
float b = -1;
|
|
|
|
|
2023-09-04 01:20:55 -05:00
|
|
|
float dist = fabsf(a * p.x + b * p.y + c) / sqrt(pow(a, 2) + 1);
|
2023-02-08 15:30:12 -06:00
|
|
|
|
2023-02-10 14:31:58 -06:00
|
|
|
if (dist > shortest) continue;
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
int between = vec_between(p, segs[i], segs[i + 1]);
|
2023-02-10 14:31:58 -06:00
|
|
|
|
|
|
|
if (between) {
|
2023-02-08 15:30:12 -06:00
|
|
|
shortest = dist;
|
2023-05-12 13:22:05 -05:00
|
|
|
best = i + 1;
|
2023-02-10 14:31:58 -06:00
|
|
|
} else {
|
2023-11-14 09:20:09 -06:00
|
|
|
if (i == 0 && HMM_DistV2(p,segs[0]) < slop) {
|
2023-02-10 14:31:58 -06:00
|
|
|
shortest = dist;
|
2023-05-12 13:22:05 -05:00
|
|
|
best = i;
|
2023-11-14 09:20:09 -06:00
|
|
|
} else if (i == arrlen(segs) - 2 && HMM_DistV2(p,arrlast(segs)) < slop) {
|
2023-02-10 14:31:58 -06:00
|
|
|
shortest = dist;
|
2023-05-12 13:22:05 -05:00
|
|
|
best = arrlen(segs);
|
2023-02-10 14:31:58 -06:00
|
|
|
}
|
2023-02-08 15:30:12 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-10 14:31:58 -06:00
|
|
|
if (best == 1) {
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 n;
|
2023-05-12 13:22:05 -05:00
|
|
|
n.x = segs[1].x - segs[0].x;
|
|
|
|
n.y = segs[1].y - segs[0].y;
|
2023-11-14 09:20:09 -06:00
|
|
|
n = HMM_NormV2(n);
|
|
|
|
if (HMM_DotV2(n, HMM_SubV2(p,segs[0])) < 0 ){
|
|
|
|
if (HMM_DistV2(p, segs[0]) >= slop)
|
2023-02-10 14:31:58 -06:00
|
|
|
best = -1;
|
|
|
|
else
|
|
|
|
best = 0;
|
2023-09-04 01:20:55 -05:00
|
|
|
}
|
2023-02-08 15:30:12 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
if (best == arrlen(segs) - 1) {
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 n;
|
2023-05-12 13:22:05 -05:00
|
|
|
n.x = segs[best - 1].x - segs[best].x;
|
|
|
|
n.y = segs[best - 1].y - segs[best - 1].y;
|
2023-11-14 09:20:09 -06:00
|
|
|
n = HMM_NormV2(n);
|
2023-02-08 15:30:12 -06:00
|
|
|
|
2023-11-14 09:20:09 -06:00
|
|
|
if (HMM_DotV2(n, HMM_SubV2(p, segs[best])) < 0) {
|
|
|
|
if (HMM_DistV2(p, segs[best]) >= slop)
|
2023-02-10 14:31:58 -06:00
|
|
|
best = -1;
|
|
|
|
else
|
|
|
|
best = arrlen(segs);
|
2023-09-04 01:20:55 -05:00
|
|
|
}
|
2023-02-08 15:30:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-04-18 17:58:44 -05:00
|
|
|
int cmd = js2int(argv[0]);
|
2023-04-22 16:44:26 -05:00
|
|
|
const char *str = NULL;
|
|
|
|
const char *str2 = NULL;
|
2023-12-21 17:21:01 -06:00
|
|
|
void *d1 = NULL;
|
|
|
|
void *d2 = NULL;
|
|
|
|
void *v1 = NULL;
|
|
|
|
gameobject **ids = NULL;
|
|
|
|
int *intids = NULL;
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = NULL;
|
2023-11-29 12:40:13 -06:00
|
|
|
JSValue ret = JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = JS_NewInt64(js, script_dofile(str));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
YughWarn("Do not set pawns here anymore; Do it entirely in script.");
|
|
|
|
// set_pawn(js2ptrduk_get_heapptr(duk, 1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2023-12-11 16:59:59 -06:00
|
|
|
// gameobject_free(js2gameobject(argv[1]));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
set_timescale(js2number(argv[1]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
debug_draw_phys(JS_ToBool(js, argv[1]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2023-09-06 17:48:08 -05:00
|
|
|
// renderMS = js2number(argv[1]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
2023-10-30 17:41:32 -05:00
|
|
|
updateMS = js2number(argv[1]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
physMS = js2number(argv[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2023-11-14 09:20:09 -06:00
|
|
|
phys2d_set_gravity(js2vec2(argv[1]).cp);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
sprite_delete(js2int(argv[1]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10:
|
|
|
|
YughWarn("Pawns are handled in script only now.");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = JS_NewInt64(js, file_mod_secs(str));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
str = JS_ToCString(js, argv[2]);
|
|
|
|
sprite_loadtex(id2sprite(js2int(argv[1])), str, js2glrect(argv[3]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
str2 = JS_ToCString(js, argv[2]);
|
|
|
|
play_song(str, str2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-11-27 14:29:55 -06:00
|
|
|
ret = ptr2js(dsp_source(str));
|
|
|
|
((sound*)((dsp_node*)js2ptr(ret))->data)->hook = argv[2];
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 15:
|
2023-12-18 06:45:27 -06:00
|
|
|
gameobject_draw_debug(js2gameobject(argv[1]));
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 16:
|
2023-05-24 20:45:50 -05:00
|
|
|
// dbg_color = js2color(argv[1]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 17:
|
2023-05-24 20:45:50 -05:00
|
|
|
// trigger_color = js2color(argv[1]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 18:
|
|
|
|
shape_set_sensor(js2ptr(argv[1]), JS_ToBool(js, argv[2]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 19:
|
2023-08-30 18:22:32 -05:00
|
|
|
// mini_master(js2number(argv[1]));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 20:
|
|
|
|
sprite_enabled(js2int(argv[1]), JS_ToBool(js, argv[2]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 21:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, shape_get_sensor(js2ptr(argv[1])));
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 22:
|
|
|
|
shape_enabled(js2ptr(argv[1]), JS_ToBool(js, argv[2]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 23:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, shape_is_enabled(js2ptr(argv[1])));
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 24:
|
|
|
|
timer_pause(js2timer(argv[1]));
|
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 25:
|
|
|
|
timer_stop(js2timer(argv[1]));
|
|
|
|
break;
|
2023-01-10 17:23:11 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 26:
|
|
|
|
timer_start(js2timer(argv[1]));
|
|
|
|
break;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 27:
|
|
|
|
timer_remove(js2int(argv[1]));
|
|
|
|
break;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 28:
|
|
|
|
timerr_settime(js2timer(argv[1]), js2number(argv[2]));
|
|
|
|
break;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 29:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewFloat64(js, js2timer(argv[1])->interval);
|
|
|
|
break;
|
2023-01-13 22:08:39 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 30:
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 31:
|
|
|
|
free(js2ptr(argv[1]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 32:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewFloat64(js, js2timer(argv[1])->remain_time);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 33:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, js2timer(argv[1])->on);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 34:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, js2timer(argv[1])->repeat);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 35:
|
|
|
|
js2timer(argv[1])->repeat = JS_ToBool(js, argv[2]);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 36:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->scale.XY = js2vec2(argv[2]);
|
|
|
|
gameobject_apply(js2gameobject(argv[1]));
|
|
|
|
cpSpaceReindexShapesForBody(space, js2gameobject(argv[1])->body);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 37:
|
2023-10-03 17:16:38 -05:00
|
|
|
if (!id2sprite(js2int(argv[1]))) break;
|
2023-11-30 10:47:59 -06:00
|
|
|
id2sprite(js2int(argv[1]))->t.pos = js2vec2(argv[2]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 38:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-10-03 17:16:38 -05:00
|
|
|
d1 = slurp_text(str,NULL);
|
|
|
|
ret = JS_NewString(js, d1);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 39:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
str2 = JS_ToCString(js, argv[2]);
|
|
|
|
ret = JS_NewInt64(js, slurp_write(str, str2));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 40:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->filter.categories = js2bitmask(argv[2]);
|
|
|
|
gameobject_apply(js2gameobject(argv[1]));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 41:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->filter.mask = js2bitmask(argv[2]);
|
|
|
|
gameobject_apply(js2gameobject(argv[1]));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 42:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = bitmask2js(js2gameobject(argv[1])->filter.categories);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 43:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = bitmask2js(js2gameobject(argv[1])->filter.mask);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 44:
|
2023-12-19 17:28:45 -06:00
|
|
|
go = pos2gameobject(js2vec2(argv[1]), js2number(argv[2]));
|
2023-12-12 08:46:27 -06:00
|
|
|
ret = go ? JS_DupValue(js,go->ref) : JS_UNDEFINED;
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 45:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = vec2js(mouse_pos);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 46:
|
|
|
|
set_mouse_mode(js2int(argv[1]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 47:
|
2023-09-06 17:48:08 -05:00
|
|
|
draw_grid(js2number(argv[1]), js2number(argv[2]), js2color(argv[3]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 48:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewInt64(js, mainwin.width);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 49:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewInt64(js, mainwin.height);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 50:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, action_down(js2int(argv[1])));
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 51:
|
|
|
|
draw_cppoint(js2vec2(argv[1]), js2number(argv[2]), js2color(argv[3]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 52:
|
2023-12-04 13:38:37 -06:00
|
|
|
ids = phys2d_query_box(js2vec2(argv[1]), js2vec2(argv[2]));
|
|
|
|
ret = gos2ref(ids);
|
|
|
|
arrfree(ids);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 53:
|
|
|
|
draw_box(js2vec2(argv[1]), js2vec2(argv[2]), js2color(argv[3]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 54:
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject_apply(js2gameobject(argv[1]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 55:
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-12-11 08:36:45 -06:00
|
|
|
// js2gameobject(argv[1])->flipx = JS_ToBool(js, argv[2]) ? -1 : 1;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 56:
|
2023-12-11 08:36:45 -06:00
|
|
|
// js2gameobject(argv[1])->flipy = JS_ToBool(js, argv[2]) ? -1 : 1;
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 57:
|
2023-12-11 08:36:45 -06:00
|
|
|
// ret = JS_NewBool(js, js2gameobject(argv[1])->flipx == -1 ? 1 : 0);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 58:
|
2023-12-11 08:36:45 -06:00
|
|
|
// ret = JS_NewBool(js, js2gameobject(argv[1])->flipy == -1 ? 1 : 0);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-04-22 16:44:26 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 59:
|
2023-12-12 19:35:34 -06:00
|
|
|
v1 = js2cpvec2arr(argv[2]);
|
|
|
|
ret = JS_NewInt64(js, point2segindex(js2vec2(argv[1]), v1, js2number(argv[3])));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-04-22 16:44:26 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 60:
|
2023-10-03 17:16:38 -05:00
|
|
|
if (!id2sprite(js2int(argv[1]))) break;
|
2023-05-12 13:22:05 -05:00
|
|
|
id2sprite(js2int(argv[1]))->layer = js2int(argv[2]);
|
|
|
|
break;
|
2023-04-22 16:44:26 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 61:
|
2023-12-11 08:36:45 -06:00
|
|
|
set_cam_body(js2gameobject(argv[1])->body);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 62:
|
|
|
|
add_zoom(js2number(argv[1]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 63:
|
2023-12-18 17:12:05 -06:00
|
|
|
set_cam_body(NULL);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 64:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = vec2js(tex_get_dimensions(texture_pullfromfile(str)));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 65:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-09-18 10:45:51 -05:00
|
|
|
ret = JS_NewBool(js, fexists(str));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 66:
|
2023-09-13 01:08:32 -05:00
|
|
|
ret = strarr2js(ls(","));
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 67:
|
|
|
|
opengl_rendermode(LIT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 68:
|
|
|
|
opengl_rendermode(WIREFRAME);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 69:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 70:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = vec2js(world2go(js2gameobject(argv[1]), js2vec2(argv[2])));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 71:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = vec2js(go2world(js2gameobject(argv[1]), js2vec2(argv[2])));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 72:
|
2023-11-14 09:20:09 -06:00
|
|
|
ret = vec2js((HMM_Vec2)cpSpaceGetGravity(space));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 73:
|
|
|
|
cpSpaceSetDamping(space, js2number(argv[1]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 74:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewFloat64(js, cpSpaceGetDamping(space));
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 75:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->layer = js2int(argv[2]);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 76:
|
|
|
|
set_cat_mask(js2int(argv[1]), js2bitmask(argv[2]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 77:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = int2js(js2gameobject(argv[1])->layer);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 78:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 79:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = JS_NewBool(js, phys_stepping());
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 80:
|
2023-12-04 13:38:37 -06:00
|
|
|
ids = phys2d_query_shape(js2ptr(argv[1]));
|
|
|
|
ret = gos2ref(ids);
|
|
|
|
arrfree(ids);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 81:
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 82:
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject_draw_debug(js2gameobject(argv[1]));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 83:
|
2023-12-12 19:35:34 -06:00
|
|
|
v1 = js2cpvec2arr(argv[1]);
|
2023-12-19 17:28:45 -06:00
|
|
|
draw_edge(v1, js_arrlen(argv[1]), js2color(argv[2]), js2number(argv[3]), 0, js2color(argv[2]), 10);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 84:
|
2023-12-22 07:14:44 -06:00
|
|
|
ret = consolelog ? JS_NewString(js, consolelog) : JS_NewString(js,"");
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 85:
|
2023-11-14 09:20:09 -06:00
|
|
|
ret = vec2js(HMM_ProjV2(js2vec2(argv[1]), js2vec2(argv[2])));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 86:
|
2023-12-12 19:35:34 -06:00
|
|
|
v1 = js2cpvec2arr(argv[3]);
|
2023-12-21 17:21:01 -06:00
|
|
|
intids = phys2d_query_box_points(js2vec2(argv[1]), js2vec2(argv[2]), v1, js2int(argv[4]));
|
|
|
|
ret = ints2js(intids);
|
|
|
|
arrfree(intids);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 87:
|
2023-11-15 16:42:39 -06:00
|
|
|
// str = JS_ToCString(js, argv[1]);
|
2023-08-30 18:22:32 -05:00
|
|
|
// mini_music_play(str);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 88:
|
2023-11-15 16:42:39 -06:00
|
|
|
ret = num2js(HMM_DotV2(js2vec2(argv[1]), js2vec2(argv[2])));
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 89:
|
2023-08-30 18:22:32 -05:00
|
|
|
// mini_music_stop();
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
case 90:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
window_set_icon(str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 91:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
log_print(str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 92:
|
|
|
|
logLevel = js2int(argv[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 93:
|
|
|
|
ret = int2js(logLevel);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 94:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
texture_pullfromfile(str)->opts.mips = js2bool(argv[2]);
|
|
|
|
texture_sync(str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 95:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
texture_pullfromfile(str)->opts.sprite = js2bool(argv[2]);
|
|
|
|
texture_sync(str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 96:
|
2023-05-24 20:45:50 -05:00
|
|
|
id2sprite(js2int(argv[1]))->color = js2color(argv[2]);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 97:
|
|
|
|
eye = HMM_AddV3(eye, (HMM_Vec3){0, 0.01, 0});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 98:
|
|
|
|
eye = HMM_AddV3(eye, (HMM_Vec3){0, -0.01, 0});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 99:
|
|
|
|
eye = HMM_AddV3(eye, (HMM_Vec3){-0.01, 0, 0});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 100:
|
|
|
|
eye = HMM_AddV3(eye, (HMM_Vec3){0.01, 0,0});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 101:
|
|
|
|
eye = HMM_AddV3(eye, (HMM_Vec3){0,0,-0.01});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 102:
|
|
|
|
eye = HMM_AddV3(eye,(HMM_Vec3){0,0,0.01});
|
|
|
|
break;
|
2023-10-02 07:58:17 -05:00
|
|
|
|
2023-05-25 21:55:55 -05:00
|
|
|
case 103:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = vec2js(js2gameobject(argv[1])->scale.XY);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-25 21:55:55 -05:00
|
|
|
|
|
|
|
case 104:
|
2023-12-11 08:36:45 -06:00
|
|
|
// ret = bool2js(js2gameobject(argv[1])->flipx == -1 ? 1 : 0);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-25 21:55:55 -05:00
|
|
|
|
|
|
|
case 105:
|
2023-12-11 08:36:45 -06:00
|
|
|
// ret = bool2js(js2gameobject(argv[1])->flipy == -1 ? 1 : 0);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-25 21:55:55 -05:00
|
|
|
|
|
|
|
case 106:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->e = js2number(argv[2]);
|
2023-05-25 21:55:55 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 107:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->e);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-25 21:55:55 -05:00
|
|
|
|
|
|
|
case 108:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->f = js2number(argv[2]);
|
2023-05-25 21:55:55 -05:00
|
|
|
break;
|
2023-10-03 17:16:38 -05:00
|
|
|
|
2023-05-25 21:55:55 -05:00
|
|
|
case 109:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->f);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
|
|
|
|
2023-05-25 21:55:55 -05:00
|
|
|
case 110:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->e);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-27 07:01:17 -05:00
|
|
|
|
|
|
|
case 111:
|
2023-11-30 10:47:59 -06:00
|
|
|
ret = vec2js(js2sprite(argv[1])->t.pos);
|
2023-10-03 17:16:38 -05:00
|
|
|
break;
|
2023-05-27 07:01:17 -05:00
|
|
|
|
|
|
|
case 112:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = num2js(((struct phys2d_edge*)js2ptr(argv[1]))->thickness);
|
|
|
|
break;
|
2023-05-27 07:01:17 -05:00
|
|
|
|
|
|
|
case 113:
|
2023-12-18 17:12:05 -06:00
|
|
|
js2gameobject(argv[1])->ref = argv[2];
|
2023-05-27 07:01:17 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 114:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = bool2js(js2sprite(argv[1])->enabled);
|
|
|
|
break;
|
2023-05-27 10:13:20 -05:00
|
|
|
|
|
|
|
case 115:
|
|
|
|
draw_circle(js2vec2(argv[1]), js2number(argv[2]), js2number(argv[2]), js2color(argv[3]), -1);
|
|
|
|
break;
|
2023-05-29 10:47:30 -05:00
|
|
|
|
|
|
|
case 116:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = str2js(tex_get_path(js2sprite(argv[1])->tex));
|
|
|
|
break;
|
2023-08-16 20:17:18 -05:00
|
|
|
|
2023-05-29 10:47:30 -05:00
|
|
|
case 117:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-06-08 17:27:37 -05:00
|
|
|
ret = script_runfile(str);
|
2023-05-29 10:47:30 -05:00
|
|
|
break;
|
2023-05-30 13:07:18 -05:00
|
|
|
|
|
|
|
case 118:
|
|
|
|
str = JS_ToCString(js,argv[1]);
|
2023-08-28 17:00:53 -05:00
|
|
|
ret = bb2js(text_bb(str, js2number(argv[2]), js2number(argv[3]), 1.0));
|
2023-05-30 13:07:18 -05:00
|
|
|
break;
|
2023-06-08 17:27:37 -05:00
|
|
|
|
|
|
|
case 119:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = JS_NewInt64(js, file_mod_secs(str));
|
|
|
|
break;
|
2023-06-28 11:35:41 -05:00
|
|
|
|
|
|
|
case 120:
|
|
|
|
ret = str2js(engine_info());
|
|
|
|
break;
|
2023-08-28 17:00:53 -05:00
|
|
|
case 121:
|
2023-10-03 17:16:38 -05:00
|
|
|
ret = num2js(get_timescale());
|
2023-08-28 17:00:53 -05:00
|
|
|
break;
|
2023-08-29 09:41:40 -05:00
|
|
|
case 122:
|
2023-09-07 16:46:35 -05:00
|
|
|
break;
|
2023-08-29 09:41:40 -05:00
|
|
|
|
|
|
|
case 123:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-09-07 16:46:35 -05:00
|
|
|
str2 = JS_ToCString(js, argv[3]);
|
|
|
|
script_eval_w_env(str, argv[2], str2);
|
2023-08-29 09:41:40 -05:00
|
|
|
break;
|
2023-09-04 09:48:44 -05:00
|
|
|
|
|
|
|
case 124:
|
2023-09-05 17:09:25 -05:00
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
pack_engine(str);
|
2023-09-04 09:48:44 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 125:
|
|
|
|
mainwin.width = js2int(argv[1]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 126:
|
2023-09-12 17:19:46 -05:00
|
|
|
mainwin.height = js2int(argv[1]);
|
2023-09-04 09:48:44 -05:00
|
|
|
break;
|
2023-09-11 02:46:12 -05:00
|
|
|
|
|
|
|
case 127:
|
|
|
|
ret = JS_NewInt64(js, stm_now());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 128:
|
|
|
|
ret = JS_NewFloat64(js, stm_ns(js2uint64(argv[1])));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 129:
|
|
|
|
ret = JS_NewFloat64(js, stm_us(js2uint64(argv[1])));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 130:
|
|
|
|
ret = JS_NewFloat64(js, stm_ms(js2uint64(argv[1])));
|
|
|
|
break;
|
2023-09-11 15:07:36 -05:00
|
|
|
|
|
|
|
case 131:
|
2023-09-12 07:56:40 -05:00
|
|
|
gif_rec_start(js2int(argv[1]), js2int(argv[2]), js2int(argv[3]), js2int(argv[4]));
|
2023-09-11 15:07:36 -05:00
|
|
|
break;
|
|
|
|
case 132:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
gif_rec_end(str);
|
|
|
|
break;
|
2023-09-12 12:45:54 -05:00
|
|
|
case 133:
|
2023-10-30 17:41:32 -05:00
|
|
|
ret = JS_NewFloat64(js, apptime());
|
2023-09-12 12:45:54 -05:00
|
|
|
break;
|
2023-09-13 01:08:32 -05:00
|
|
|
|
|
|
|
case 134:
|
|
|
|
str = JS_ToCString(js,argv[1]);
|
|
|
|
app_name(str);
|
|
|
|
break;
|
2023-09-15 22:40:19 -05:00
|
|
|
|
|
|
|
case 135:
|
|
|
|
ret = float2js(cam_zoom());
|
|
|
|
break;
|
2023-09-18 07:36:07 -05:00
|
|
|
|
|
|
|
case 136:
|
2023-11-15 16:42:39 -06:00
|
|
|
ret = vec2js(world2screen(js2vec2(argv[1])));
|
2023-09-18 07:36:07 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 137:
|
2023-11-15 16:42:39 -06:00
|
|
|
ret = vec2js(screen2world(js2vec2(argv[1])));
|
2023-09-18 07:36:07 -05:00
|
|
|
break;
|
2023-09-18 10:45:51 -05:00
|
|
|
|
|
|
|
case 138:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = JS_NewInt64(js, jso_file(str));
|
|
|
|
break;
|
|
|
|
|
2023-09-24 11:26:44 -05:00
|
|
|
case 139:
|
|
|
|
str = JS_ToCString(js,argv[1]);
|
|
|
|
ret = JS_NewInt64(js, gif_nframes(str));
|
|
|
|
break;
|
2023-10-04 08:18:09 -05:00
|
|
|
|
|
|
|
case 140:
|
|
|
|
sg_apply_scissor_rectf(js2number(argv[1]), js2number(argv[2]), js2number(argv[3]), js2number(argv[4]), 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 141:
|
|
|
|
text_flush(&hudproj);
|
|
|
|
break;
|
2023-10-09 18:10:10 -05:00
|
|
|
|
|
|
|
case 142:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
console_print(str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 143:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
2023-12-20 17:20:29 -06:00
|
|
|
system(str);
|
2023-10-09 18:10:10 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 144:
|
|
|
|
ret = str2js(DATA_PATH);
|
|
|
|
break;
|
2023-10-16 09:40:43 -05:00
|
|
|
|
|
|
|
case 145:
|
|
|
|
if (js2bool(argv[1])) window_makefullscreen(&mainwin);
|
|
|
|
else window_unfullscreen(&mainwin);
|
|
|
|
break;
|
2023-10-17 12:22:06 -05:00
|
|
|
case 146:
|
|
|
|
log_clear();
|
|
|
|
break;
|
2023-10-23 08:08:11 -05:00
|
|
|
|
|
|
|
case 147:
|
2023-12-04 13:38:37 -06:00
|
|
|
YughWarn("EXITING");
|
2023-10-23 08:08:11 -05:00
|
|
|
exit(js2int(argv[1]));
|
|
|
|
break;
|
2023-10-31 12:38:23 -05:00
|
|
|
case 148:
|
|
|
|
ret = color2js(id2sprite(js2int(argv[1]))->color);
|
|
|
|
break;
|
2023-11-03 08:31:06 -05:00
|
|
|
case 149:
|
|
|
|
((struct drawmodel *)js2ptr(argv[1]))->model = GetExistingModel(js2str(argv[2]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 150:
|
|
|
|
draw_drawmodel(js2ptr(argv[1]));
|
|
|
|
break;
|
2023-11-06 07:05:27 -06:00
|
|
|
|
|
|
|
case 151:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->maxvelocity = js2number(argv[2]);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 152:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->maxvelocity);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 153:
|
2023-12-11 08:36:45 -06:00
|
|
|
cpBodySetTorque(js2gameobject(argv[1])->body, js2number(argv[2]));
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 154:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->maxangularvelocity = js2number(argv[2]);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 155:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->maxangularvelocity);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 156:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->damping = js2number(argv[2]);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 157:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->damping);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
|
|
|
case 158:
|
|
|
|
break;
|
|
|
|
case 159:
|
2023-12-24 09:14:46 -06:00
|
|
|
ret = vec2js(js2gameobject(argv[1])->gravity);
|
2023-11-06 07:05:27 -06:00
|
|
|
break;
|
2023-11-16 09:27:04 -06:00
|
|
|
case 160:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = vec2js(mat_t_dir(t_world2go(js2gameobject(argv[1])), js2vec2(argv[2])));
|
2023-11-16 09:27:04 -06:00
|
|
|
break;
|
|
|
|
case 161:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = vec2js(mat_t_dir(t_go2world(js2gameobject(argv[1])), js2vec2(argv[2])));
|
2023-11-16 09:27:04 -06:00
|
|
|
break;
|
2023-11-17 15:16:13 -06:00
|
|
|
case 162:
|
|
|
|
str = JS_ToCString(js, argv[1]);
|
|
|
|
ret = int2js(remove(str));
|
|
|
|
break;
|
|
|
|
case 163:
|
|
|
|
str = JS_ToCString(js,argv[1]);
|
|
|
|
str2 = JS_ToCString(js,argv[2]);
|
|
|
|
ret = int2js(rename(str, str2));
|
|
|
|
break;
|
|
|
|
case 164:
|
2023-11-27 14:29:55 -06:00
|
|
|
unplug_node(js2ptr(argv[1]));
|
2023-11-17 15:16:13 -06:00
|
|
|
break;
|
|
|
|
case 165:
|
2023-11-27 14:29:55 -06:00
|
|
|
// ret = bool2js(sound_paused(js2ptr(argv[1])));
|
2023-11-17 15:16:13 -06:00
|
|
|
break;
|
|
|
|
case 166:
|
|
|
|
str = js2str(argv[1]);
|
|
|
|
str2 = js2str(argv[2]);
|
|
|
|
ret = int2js(cp(str, str2));
|
|
|
|
break;
|
2023-11-20 07:49:14 -06:00
|
|
|
case 167:
|
2023-12-24 09:14:46 -06:00
|
|
|
js2gameobject(argv[1])->gravity = js2vec2(argv[2]);
|
2023-11-20 07:49:14 -06:00
|
|
|
break;
|
|
|
|
case 168:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->timescale = js2number(argv[2]);
|
2023-11-20 07:49:14 -06:00
|
|
|
break;
|
|
|
|
case 169:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->timescale);
|
2023-11-20 07:49:14 -06:00
|
|
|
break;
|
2023-11-21 01:07:50 -06:00
|
|
|
case 170:
|
|
|
|
id2sprite(js2int(argv[1]))->emissive = js2color(argv[2]);
|
|
|
|
break;
|
|
|
|
case 171:
|
2023-12-11 08:36:45 -06:00
|
|
|
ret = num2js(js2gameobject(argv[1])->drawlayer);
|
2023-11-21 01:07:50 -06:00
|
|
|
break;
|
|
|
|
case 172:
|
2023-12-11 08:36:45 -06:00
|
|
|
js2gameobject(argv[1])->drawlayer = js2number(argv[2]);
|
2023-11-21 01:07:50 -06:00
|
|
|
break;
|
2023-11-22 03:51:43 -06:00
|
|
|
case 173:
|
|
|
|
str = js2str(argv[1]);
|
|
|
|
capture_screen(js2number(argv[2]), js2number(argv[3]), js2number(argv[4]), js2number(argv[5]), str);
|
|
|
|
break;
|
2023-11-27 14:29:55 -06:00
|
|
|
case 174:
|
|
|
|
str = js2str(argv[1]);
|
|
|
|
ds_openvideo(str);
|
|
|
|
break;
|
|
|
|
case 175:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = num2js((js2dsp_node(argv[1]))->gain);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 176:
|
2023-11-29 12:40:13 -06:00
|
|
|
js2dsp_node(argv[1])->gain = js2number(argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 177:
|
2023-11-29 17:31:41 -06:00
|
|
|
plugin_node(js2dsp_node(argv[1]), js2dsp_node(argv[2]));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 178:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = num2js(js2dsp_node(argv[1])->pan);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 179:
|
2023-11-29 12:40:13 -06:00
|
|
|
js2dsp_node(argv[1])->pan=js2number(argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 180:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(masterbus);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 181:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(make_node(NULL,NULL,NULL));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 182:
|
|
|
|
str = js2str(argv[1]);
|
2023-11-29 17:31:41 -06:00
|
|
|
ret = dsp_node2js(dsp_source(str));
|
2023-11-29 12:40:13 -06:00
|
|
|
((sound*)js2dsp_node(ret)->data)->hook = JS_DupValue(js,argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 183:
|
2023-11-29 12:40:13 -06:00
|
|
|
js2dsp_node(argv[1])->off = js2bool(argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 184:
|
2023-11-29 12:40:13 -06:00
|
|
|
js2dsp_node(argv[1])->pass = js2bool(argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 185:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_delay(js2number(argv[1]), js2number(argv[2])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 186:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_lpf(js2number(argv[1])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 187:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_hpf(js2number(argv[1])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 188:
|
|
|
|
str = js2str(argv[1]);
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_mod(str));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 189:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_bitcrush(js2number(argv[1]), js2number(argv[2])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 190:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_compressor());
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 191:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_limiter(js2number(argv[1])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 192:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_noise_gate(js2number(argv[1])));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 193:
|
2023-11-29 12:40:13 -06:00
|
|
|
// node_free(js2ptr(argv[1]));
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 194:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = bool2js(((sound*)js2dsp_node(argv[1])->data)->loop);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
|
|
|
case 195:
|
2023-11-29 12:40:13 -06:00
|
|
|
((sound*)js2dsp_node(argv[1])->data)->loop = js2bool(argv[2]);
|
2023-11-27 14:29:55 -06:00
|
|
|
break;
|
2023-11-27 17:04:04 -06:00
|
|
|
case 196:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = num2js(((sound*)js2dsp_node(argv[1])->data)->frame);
|
2023-11-27 17:04:04 -06:00
|
|
|
break;
|
|
|
|
case 197:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = num2js(((sound*)js2dsp_node(argv[1])->data)->data->frames);
|
2023-11-27 17:04:04 -06:00
|
|
|
break;
|
|
|
|
case 198:
|
|
|
|
ret = num2js(SAMPLERATE);
|
|
|
|
break;
|
|
|
|
case 199:
|
2023-11-29 12:40:13 -06:00
|
|
|
((sound*)js2dsp_node(argv[1])->data)->frame = js2number(argv[2]);
|
2023-11-27 17:04:04 -06:00
|
|
|
break;
|
2023-11-28 22:48:32 -06:00
|
|
|
case 200:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_pitchshift(js2number(argv[1])));
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 201:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = num2js(((sound*)js2dsp_node(argv[1])->data)->timescale);
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 202:
|
|
|
|
YughWarn("%g", js2number(argv[2]));
|
2023-11-29 12:40:13 -06:00
|
|
|
((sound*)js2dsp_node(argv[1])->data)->timescale = js2number(argv[2]);
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 203:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_whitenoise());
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 204:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_pinknoise());
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 205:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_rednoise());
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 206:
|
|
|
|
str = js2str(argv[1]);
|
|
|
|
str2 = js2str(argv[2]);
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_midi(str, make_soundfont(str2)));
|
2023-11-28 22:48:32 -06:00
|
|
|
break;
|
|
|
|
case 207:
|
2023-11-29 12:40:13 -06:00
|
|
|
ret = dsp_node2js(dsp_fwd_delay(js2number(argv[1]), js2number(argv[2])));
|
2023-11-29 07:32:32 -06:00
|
|
|
break;
|
2023-11-30 10:47:59 -06:00
|
|
|
case 208:
|
2023-12-12 08:46:27 -06:00
|
|
|
// dag_set(js2gameobject(argv[1]), js2gameobject(argv[2]));
|
2023-11-30 10:47:59 -06:00
|
|
|
break;
|
2023-12-09 22:09:15 -06:00
|
|
|
case 209:
|
|
|
|
break;
|
|
|
|
case 210:
|
|
|
|
ret = jscurtime();
|
|
|
|
break;
|
|
|
|
case 211:
|
|
|
|
ret = jstzone();
|
|
|
|
break;
|
|
|
|
case 212:
|
|
|
|
ret = jsdst();
|
|
|
|
break;
|
2023-12-20 17:20:29 -06:00
|
|
|
case 213:
|
|
|
|
free_drawmodel(js2ptr(argv[1]));
|
|
|
|
break;
|
|
|
|
case 214:
|
|
|
|
ret = int2js(go_count());
|
|
|
|
break;
|
2023-12-26 15:39:46 -06:00
|
|
|
case 215:
|
|
|
|
ret = vec2js(js2sprite(argv[1])->t.scale);
|
|
|
|
break;
|
|
|
|
case 216:
|
|
|
|
js2sprite(argv[1])->t.scale = js2vec2(argv[2]);
|
|
|
|
break;
|
|
|
|
case 217:
|
|
|
|
ret = num2js(js2sprite(argv[1])->t.angle);
|
|
|
|
break;
|
|
|
|
case 218:
|
|
|
|
js2sprite(argv[1])->t.angle = js2number(argv[2]);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (str)
|
|
|
|
JS_FreeCString(js, str);
|
|
|
|
|
|
|
|
if (str2)
|
|
|
|
JS_FreeCString(js, str2);
|
|
|
|
|
2023-10-03 17:16:38 -05:00
|
|
|
if (d1) free(d1);
|
|
|
|
if (d2) free(d2);
|
|
|
|
|
2023-12-12 19:35:34 -06:00
|
|
|
if (v1) arrfree(v1);
|
|
|
|
|
2023-10-03 17:16:38 -05:00
|
|
|
if (!JS_IsNull(ret)) {
|
2023-05-12 13:22:05 -05:00
|
|
|
return ret;
|
2023-10-03 17:16:38 -05:00
|
|
|
}
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
|
|
|
|
struct callee c;
|
|
|
|
c.fn = argv[1];
|
|
|
|
c.obj = argv[2];
|
2023-04-19 15:16:35 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
|
|
|
register_update(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
register_physics(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
register_gui(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
register_nk_gui(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
// unregister_obj(obj);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
// unregister_gui(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
register_debug(c);
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
register_pawn(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
register_gamepad(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
|
|
|
stacktrace_callee = c;
|
|
|
|
break;
|
2023-05-24 20:45:50 -05:00
|
|
|
|
|
|
|
case 10:
|
|
|
|
register_draw(c);
|
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-11 16:57:34 -06:00
|
|
|
}
|
|
|
|
|
2023-12-11 08:36:45 -06:00
|
|
|
void gameobject_add_shape_collider(gameobject *go, struct callee c, struct phys2d_shape *shape) {
|
2023-02-17 01:16:52 -06:00
|
|
|
struct shape_cb shapecb;
|
2023-03-10 13:13:48 -06:00
|
|
|
shapecb.shape = shape;
|
2023-02-17 01:16:52 -06:00
|
|
|
shapecb.cbs.begin = c;
|
2023-12-11 08:36:45 -06:00
|
|
|
arrpush(go->shape_cbs, shapecb);
|
2023-02-17 01:16:52 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int cmd = js2int(argv[0]);
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[3]);
|
2023-05-12 13:22:05 -05:00
|
|
|
struct callee c;
|
|
|
|
c.fn = argv[1];
|
|
|
|
c.obj = argv[2];
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
2023-12-11 08:36:45 -06:00
|
|
|
go->cbs.begin = c;
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
gameobject_add_shape_collider(go, c, js2ptr(argv[4]));
|
|
|
|
break;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 2:
|
|
|
|
phys2d_rm_go_handlers(go);
|
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 3:
|
2023-12-11 08:36:45 -06:00
|
|
|
go->cbs.separate = c;
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
}
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_sys_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int cmd = js2int(argv[0]);
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
|
|
|
quit();
|
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 1:
|
|
|
|
sim_start();
|
|
|
|
cpSpaceReindexStatic(space);
|
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 2:
|
2023-08-29 17:11:36 -05:00
|
|
|
sim_pause();
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 3:
|
|
|
|
sim_pause();
|
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 4:
|
|
|
|
sim_step();
|
|
|
|
break;
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 5:
|
|
|
|
return JS_NewBool(js, sim_playing());
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 6:
|
|
|
|
return JS_NewBool(js, sim_paused());
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 7:
|
2023-12-11 16:59:59 -06:00
|
|
|
return gameobject2js(MakeGameobject());
|
2023-01-10 07:13:00 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 8:
|
|
|
|
return JS_NewInt64(js, frame_fps());
|
|
|
|
|
|
|
|
case 9: /* Clear the level out */
|
|
|
|
break;
|
2023-09-06 17:48:08 -05:00
|
|
|
|
|
|
|
case 10:
|
2023-09-19 12:35:12 -05:00
|
|
|
editor_mode = js2bool(argv[1]);
|
2023-09-06 17:48:08 -05:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 07:13:00 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_make_gameobject(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-11-29 12:40:13 -06:00
|
|
|
return gameobject2js(MakeGameobject());
|
2023-01-10 07:13:00 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_yughlog(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
const char *s = JS_ToCString(js, argv[1]);
|
|
|
|
const char *f = JS_ToCString(js, argv[2]);
|
|
|
|
int line = js2int(argv[3]);
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
mYughLog(1, cmd, line, f, s);
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JS_FreeCString(js, s);
|
|
|
|
JS_FreeCString(js, f);
|
2023-04-19 16:58:17 -05:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_set_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-04-18 17:58:44 -05:00
|
|
|
int cmd = js2int(argv[0]);
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[1]);
|
2023-11-29 12:40:13 -06:00
|
|
|
|
|
|
|
if (!go) return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-01-13 13:07:44 -06:00
|
|
|
/* TODO: Possible that reindexing shapes only needs done for static shapes? */
|
2023-01-10 14:02:24 -06:00
|
|
|
switch (cmd) {
|
2023-05-12 13:22:05 -05:00
|
|
|
case 0:
|
|
|
|
gameobject_setangle(go, js2number(argv[2]));
|
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 1:
|
|
|
|
go->bodytype = js2int(argv[2]);
|
2023-05-27 07:01:17 -05:00
|
|
|
cpBodySetType(go->body, go->bodytype);
|
|
|
|
gameobject_apply(go);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 2:
|
2023-11-14 09:20:09 -06:00
|
|
|
cpBodySetPosition(go->body, js2vec2(argv[2]).cp);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 3:
|
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 4:
|
2023-11-14 09:20:09 -06:00
|
|
|
cpBodyApplyImpulseAtWorldPoint(go->body, js2vec2(argv[2]).cp, cpBodyGetPosition(go->body));
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 5:
|
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 6:
|
|
|
|
break;
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 7:
|
2023-09-21 19:51:38 -05:00
|
|
|
go->mass = js2number(argv[2]);
|
2023-05-27 07:01:17 -05:00
|
|
|
if (go->bodytype == CP_BODY_TYPE_DYNAMIC)
|
2023-09-21 19:51:38 -05:00
|
|
|
cpBodySetMass(go->body, go->mass);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
2023-01-12 17:41:54 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 8:
|
|
|
|
cpBodySetAngularVelocity(go->body, js2number(argv[2]));
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-13 13:07:44 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 9:
|
2023-11-14 09:20:09 -06:00
|
|
|
cpBodySetVelocity(go->body, js2vec2(argv[2]).cp);
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-13 13:07:44 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 10:
|
|
|
|
go->e = fmax(js2number(argv[2]), 0);
|
|
|
|
break;
|
2023-02-24 14:13:35 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 11:
|
|
|
|
go->f = fmax(js2number(argv[2]), 0);
|
|
|
|
break;
|
2023-03-17 10:25:35 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 12:
|
2023-11-14 09:20:09 -06:00
|
|
|
cpBodyApplyForceAtWorldPoint(go->body, js2vec2(argv[2]).cp, cpBodyGetPosition(go->body));
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-06-28 11:35:41 -05:00
|
|
|
|
|
|
|
case 13:
|
|
|
|
cpBodySetMoment(go->body, js2number(argv[2]));
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-11-06 07:05:27 -06:00
|
|
|
case 14:
|
2023-11-14 09:20:09 -06:00
|
|
|
cpBodyApplyForceAtLocalPoint(go->body, js2vec2(argv[2]).cp, js2vec2(argv[3]).cp);
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
}
|
|
|
|
|
2023-01-25 21:32:58 -06:00
|
|
|
cpSpaceReindexShapesForBody(space, go->body);
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_q_body(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int q = js2int(argv[0]);
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[1]);
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
if (!go) return JS_UNDEFINED;
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (q) {
|
|
|
|
case 0:
|
|
|
|
return JS_NewInt64(js, cpBodyGetType(go->body));
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 1:
|
2023-11-14 09:20:09 -06:00
|
|
|
return vec2js((HMM_Vec2)cpBodyGetPosition(go->body));
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 2:
|
|
|
|
return JS_NewFloat64(js, cpBodyGetAngle(go->body));
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 3:
|
2023-11-14 09:20:09 -06:00
|
|
|
return vec2js((HMM_Vec2)cpBodyGetVelocity(go->body));
|
2023-01-11 16:57:34 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 4:
|
|
|
|
return JS_NewFloat64(js, cpBodyGetAngularVelocity(go->body));
|
2023-03-10 13:13:48 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 5:
|
|
|
|
return JS_NewFloat64(js, cpBodyGetMass(go->body));
|
2023-03-17 10:25:35 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 6:
|
|
|
|
return JS_NewFloat64(js, cpBodyGetMoment(go->body));
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 7:
|
|
|
|
return JS_NewBool(js, phys2d_in_air(go->body));
|
2023-10-16 09:40:43 -05:00
|
|
|
|
2023-11-29 17:31:41 -06:00
|
|
|
case 8:
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject_free(go);
|
2023-11-29 17:31:41 -06:00
|
|
|
break;
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-10 14:02:24 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_make_sprite(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-09-21 12:50:39 -05:00
|
|
|
JSValue sprite = JS_NewObject(js);
|
2023-12-04 13:38:37 -06:00
|
|
|
js_setprop_str(sprite,"id",JS_NewInt64(js, make_sprite(js2gameobject(argv[0]))));
|
2023-09-21 12:50:39 -05:00
|
|
|
return sprite;
|
2023-01-12 17:41:54 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_make_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[0]);
|
2023-01-10 17:23:11 -06:00
|
|
|
|
2023-04-21 16:57:30 -05:00
|
|
|
struct phys2d_circle *circle = Make2DCircle(go);
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-04-18 17:58:44 -05:00
|
|
|
JSValue circleval = JS_NewObject(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_str(circleval, "id", ptr2js(circle));
|
|
|
|
js_setprop_str(circleval, "shape", ptr2js(&circle->shape));
|
2023-04-18 17:58:44 -05:00
|
|
|
return circleval;
|
2023-01-10 17:23:11 -06:00
|
|
|
}
|
|
|
|
|
2023-11-03 08:31:06 -05:00
|
|
|
JSValue duk_make_model(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
|
|
|
{
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[0]);
|
2023-11-03 08:31:06 -05:00
|
|
|
struct drawmodel *dm = make_drawmodel(go);
|
|
|
|
JSValue ret = JS_NewObject(js);
|
|
|
|
js_setprop_str(ret, "id", ptr2js(dm));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_cmd_circle2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
struct phys2d_circle *circle = js2ptr(argv[1]);
|
2023-01-19 13:06:32 -06:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
if (!circle) return JS_UNDEFINED;
|
2023-01-19 13:06:32 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
|
|
|
circle->radius = js2number(argv[2]);
|
|
|
|
break;
|
2023-01-19 13:06:32 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
case 1:
|
|
|
|
circle->offset = js2vec2(argv[2]);
|
|
|
|
break;
|
2023-05-25 21:55:55 -05:00
|
|
|
|
|
|
|
case 2:
|
|
|
|
return num2js(circle->radius);
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
return vec2js(circle->offset);
|
2023-05-12 13:22:05 -05:00
|
|
|
}
|
2023-10-16 09:40:43 -05:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
phys2d_applycircle(circle);
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-19 10:44:29 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_make_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[0]);
|
2023-01-25 21:32:58 -06:00
|
|
|
struct phys2d_poly *poly = Make2DPoly(go);
|
2023-10-10 17:37:58 -05:00
|
|
|
phys2d_poly_setverts(poly, NULL);
|
2023-04-18 17:58:44 -05:00
|
|
|
JSValue polyval = JS_NewObject(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_str(polyval, "id", ptr2js(poly));
|
|
|
|
js_setprop_str(polyval, "shape", ptr2js(&poly->shape));
|
2023-04-18 17:58:44 -05:00
|
|
|
return polyval;
|
2023-01-25 21:32:58 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_cmd_poly2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-04-18 17:58:44 -05:00
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
struct phys2d_poly *poly = js2ptr(argv[1]);
|
2023-12-12 19:35:34 -06:00
|
|
|
HMM_Vec2 *v1 = NULL;
|
2023-02-24 14:13:35 -06:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
if (!poly) return JS_UNDEFINED;
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
2023-12-12 19:35:34 -06:00
|
|
|
v1 = js2cpvec2arr(argv[2]);
|
|
|
|
phys2d_poly_setverts(poly, v1);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
2023-02-17 22:32:23 -06:00
|
|
|
}
|
2023-12-12 19:35:34 -06:00
|
|
|
if (v1) arrfree(v1);
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-25 21:32:58 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_make_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-12-11 08:36:45 -06:00
|
|
|
gameobject *go = js2gameobject(argv[0]);
|
2023-01-25 21:32:58 -06:00
|
|
|
struct phys2d_edge *edge = Make2DEdge(go);
|
2023-12-12 19:35:34 -06:00
|
|
|
HMM_Vec2 *points = js2cpvec2arr(argv[1]);
|
|
|
|
phys2d_edge_update_verts(edge, points);
|
|
|
|
arrfree(points);
|
2023-01-25 21:32:58 -06:00
|
|
|
|
2023-04-18 17:58:44 -05:00
|
|
|
JSValue edgeval = JS_NewObject(js);
|
2023-10-03 17:16:38 -05:00
|
|
|
js_setprop_str(edgeval, "id", ptr2js(edge));
|
|
|
|
js_setprop_str(edgeval, "shape", ptr2js(&edge->shape));
|
2023-04-18 17:58:44 -05:00
|
|
|
return edgeval;
|
2023-01-25 21:32:58 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_cmd_edge2d(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-04-18 17:58:44 -05:00
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
struct phys2d_edge *edge = js2ptr(argv[1]);
|
2023-02-08 15:30:12 -06:00
|
|
|
|
2023-10-26 11:48:02 -05:00
|
|
|
if (!edge) {
|
|
|
|
YughError("Attempted to do a cmd on edge %p. Not found.", edge);
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-10-26 11:48:02 -05:00
|
|
|
}
|
2023-02-24 14:13:35 -06:00
|
|
|
|
2023-12-12 19:35:34 -06:00
|
|
|
HMM_Vec2 *v1 = NULL;
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
switch (cmd) {
|
|
|
|
case 0:
|
2023-12-12 19:35:34 -06:00
|
|
|
v1 = js2cpvec2arr(argv[2]);
|
|
|
|
phys2d_edge_update_verts(edge,v1);
|
2023-05-12 13:22:05 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
edge->thickness = js2number(argv[2]);
|
|
|
|
break;
|
2023-02-08 15:30:12 -06:00
|
|
|
}
|
2023-12-12 19:35:34 -06:00
|
|
|
if (v1) arrfree(v1);
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-01-25 21:32:58 -06:00
|
|
|
}
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
JSValue duk_inflate_cpv(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) {
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 *points = js2cpvec2arr(argv[0]);
|
2023-04-18 17:58:44 -05:00
|
|
|
int n = js2int(argv[1]);
|
|
|
|
double d = js2number(argv[2]);
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 *infl = inflatepoints(points,d,n);
|
2023-10-29 16:39:45 -05:00
|
|
|
JSValue arr = vecarr2js(infl,arrlen(infl));
|
2023-12-12 19:35:34 -06:00
|
|
|
|
2023-10-29 16:39:45 -05:00
|
|
|
arrfree(infl);
|
2023-12-12 19:35:34 -06:00
|
|
|
arrfree(points);
|
2023-04-18 17:58:44 -05:00
|
|
|
return arr;
|
2023-03-19 20:33:05 -05:00
|
|
|
}
|
|
|
|
|
2023-06-05 10:32:45 -05:00
|
|
|
JSValue duk_cmd_points(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
|
|
|
{
|
|
|
|
int n = js_arrlen(argv[1]);
|
2023-11-14 09:20:09 -06:00
|
|
|
HMM_Vec2 points[n];
|
2023-06-05 10:32:45 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < n; i++)
|
|
|
|
points[i] = js2vec2(js_arridx(argv[1], i));
|
|
|
|
|
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
case 0:
|
|
|
|
draw_poly(points, n, js2color(argv[2]));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-11-29 12:40:13 -06:00
|
|
|
return JS_UNDEFINED;
|
2023-06-05 10:32:45 -05:00
|
|
|
}
|
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
const char *STRTEST = "TEST STRING";
|
|
|
|
|
|
|
|
JSValue duk_profile(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
|
|
|
|
{
|
|
|
|
int cmd = js2int(argv[0]);
|
|
|
|
switch(cmd) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
js2number(argv[1]);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
js2cpvec2arr(argv[1]);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return num2js(1.0);
|
|
|
|
case 4:
|
|
|
|
js2str(argv[1]);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
jsfloat2vec(argv[1]);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return JS_NewStringLen(js, STRTEST, sizeof(*STRTEST));
|
|
|
|
}
|
|
|
|
return JS_UNDEFINED;
|
|
|
|
}
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
#define DUK_FUNC(NAME, ARGS) JS_SetPropertyStr(js, globalThis, #NAME, JS_NewCFunction(js, duk_##NAME, #NAME, ARGS));
|
2023-01-10 14:02:24 -06:00
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
void ffi_load() {
|
2023-05-24 20:45:50 -05:00
|
|
|
globalThis = JS_GetGlobalObject(js);
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(yughlog, 4)
|
2023-09-12 23:32:14 -05:00
|
|
|
|
2023-09-20 13:33:11 -05:00
|
|
|
DUK_FUNC(make_gameobject, 0)
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(set_body, 3)
|
|
|
|
DUK_FUNC(q_body, 2)
|
|
|
|
|
|
|
|
DUK_FUNC(sys_cmd, 1)
|
|
|
|
|
2023-09-20 08:11:14 -05:00
|
|
|
DUK_FUNC(make_sprite, 1)
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(spline_cmd, 6)
|
|
|
|
|
2023-09-27 09:37:20 -05:00
|
|
|
DUK_FUNC(make_circle2d, 1)
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(cmd_circle2d, 6)
|
2023-10-10 17:37:58 -05:00
|
|
|
DUK_FUNC(make_poly2d, 1)
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(cmd_poly2d, 6)
|
|
|
|
DUK_FUNC(make_edge2d, 3)
|
|
|
|
DUK_FUNC(cmd_edge2d, 6)
|
2023-11-03 08:31:06 -05:00
|
|
|
DUK_FUNC(make_model,2);
|
2023-05-12 13:22:05 -05:00
|
|
|
|
2023-06-05 10:32:45 -05:00
|
|
|
DUK_FUNC(cmd_points, 5);
|
|
|
|
|
2023-05-12 13:22:05 -05:00
|
|
|
DUK_FUNC(cmd, 6)
|
|
|
|
DUK_FUNC(register, 3)
|
|
|
|
DUK_FUNC(register_collide, 6)
|
|
|
|
|
2023-10-05 08:02:12 -05:00
|
|
|
DUK_FUNC(ui_text, 8)
|
2023-06-06 15:49:55 -05:00
|
|
|
DUK_FUNC(gui_img, 10)
|
2023-05-12 13:22:05 -05:00
|
|
|
|
|
|
|
DUK_FUNC(inflate_cpv, 3)
|
|
|
|
|
2023-12-18 06:45:27 -06:00
|
|
|
DUK_FUNC(profile, 2)
|
|
|
|
|
2023-10-04 08:18:09 -05:00
|
|
|
JS_FreeValue(js,globalThis);
|
2023-10-16 09:40:43 -05:00
|
|
|
|
|
|
|
JS_NewClassID(&js_ptr_id);
|
|
|
|
JS_NewClass(JS_GetRuntime(js), js_ptr_id, &js_ptr_class);
|
2023-11-29 07:32:32 -06:00
|
|
|
|
|
|
|
QJSCLASSPREP(dsp_node);
|
2023-11-29 12:40:13 -06:00
|
|
|
QJSCLASSPREP(gameobject);
|
2023-01-10 15:41:43 -06:00
|
|
|
}
|