This commit is contained in:
John Alanbrook 2023-04-07 17:52:35 +00:00
parent 5ca3629406
commit b4c2625371
5 changed files with 15 additions and 9 deletions

View file

@ -173,7 +173,6 @@ duk_idx_t vecarr2duk(duk_context *duk, cpVect *points, int n)
return arr;
}
void duk_dump_stack(duk_context *duk)
{
YughInfo("DUK CALLSTACK");
@ -204,7 +203,6 @@ void duk_dump_stack(duk_context *duk)
duk_pop(duk);
}
duk_ret_t duk_gui_text(duk_context *duk) {
const char *s = duk_to_string(duk, 0);
cpVect pos = duk2vec2(duk, 1);
@ -223,8 +221,9 @@ duk_ret_t duk_ui_text(duk_context *duk)
float size = duk_to_number(duk, 2);
struct color c = duk2color(duk,3);
const float col[3] = {(float)c.r/255, (float)c.g/255, (float)c.b/255};
renderText(s, &pos, size, col, 500,-1);
return 0;
int wrap = duk_to_int(duk,4);
duk_push_int(duk,renderText(s, &pos, size, col, wrap,-1));
return 1;
}
duk_ret_t duk_cursor_text(duk_context *duk)
@ -236,7 +235,8 @@ duk_ret_t duk_cursor_text(duk_context *duk)
struct color c = duk2color(duk,3);
const float col[3] = {(float)c.r/255, (float)c.g/255, (float)c.b/255};
int cursor = duk_to_int(duk,4);
renderText(s, &pos, size, col, 500,cursor);
int wrap = duk_to_int(duk,5);
renderText(s, &pos, size, col, wrap,cursor);
return 0;
}
@ -1461,7 +1461,7 @@ void ffi_load()
DUK_FUNC(register_collide, DUK_VARARGS);
DUK_FUNC(gui_text, DUK_VARARGS);
DUK_FUNC(ui_text, 4);
DUK_FUNC(ui_text, 5);
DUK_FUNC(cursor_text,5);
DUK_FUNC(gui_img, 2);

View file

@ -259,7 +259,7 @@ void text_settype(struct sFont *mfont)
font = mfont;
}
void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw, int caret)
int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw, int caret)
{
int len = strlen(text);
drawcaret = caret;
@ -333,4 +333,6 @@ void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3
}
// glDrawArrays(GL_TRIANGLE_STRIP, 0, 4*2);
return cursor[1] - pos[1];
}

View file

@ -28,7 +28,7 @@ void font_frame(struct window *w);
struct sFont *MakeFont(const char *fontfile, int height);
void sdrawCharacter(struct Character c, mfloat_t cursor[2], float scale, struct shader *shader, float color[3]);
void text_settype(struct sFont *font);
void renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw,int caret);
int renderText(const char *text, mfloat_t pos[2], float scale, mfloat_t color[3], float lw,int caret);
unsigned char *slurp_file(const char *filename);
char *slurp_text(const char *filename);

View file

@ -171,10 +171,13 @@ static ma_sound music_sound;
void mini_music_play(char *path)
{
ma_sound_uninit(&music_sound);
int result = ma_sound_init_from_file(engine, path, MA_SOUND_FLAG_NO_SPATIALIZATION, NULL, NULL, &music_sound);
if (result != MA_SUCCESS) {
YughInfo("DID NOT LOAD SOUND!");
YughInfo("Could not load music at path: %s", path);
}
YughInfo("Loading %s...", path);
ma_sound_start(&music_sound);
}

View file

@ -66,6 +66,7 @@ struct bus *first_free_bus(struct dsp_filter in) {
void bus_free(struct bus *b)
{
if (!b) return;
b->on = 0;
return;