diff --git a/README.md b/README.md index 52791ad..e03f65d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ The easily moddable, programming minded, 2D-first game engine. The aim is to make the fastest way to make games. -See the [documentation](doc/prosperon.org) for more information, including how to compile. +Using ... +* Sokol for rendering +* Chipmunk2D for physics +* imgui for easy editor UI +* Clay for game UI + +Includes an implementation for Nota, and Kim. *Prosperon is useful, but is a work in progress. Breaking changes are frequent.* diff --git a/icons/compass.png b/icons/compass.png new file mode 100644 index 0000000..c46542c Binary files /dev/null and b/icons/compass.png differ diff --git a/icons/crossed-swords.png b/icons/crossed-swords.png new file mode 100644 index 0000000..d385b45 Binary files /dev/null and b/icons/crossed-swords.png differ diff --git a/icons/dice.png b/icons/dice.png new file mode 100644 index 0000000..e4bc09a Binary files /dev/null and b/icons/dice.png differ diff --git a/icons/heart.png b/icons/heart.png new file mode 100644 index 0000000..29adff6 Binary files /dev/null and b/icons/heart.png differ diff --git a/icons/random.png b/icons/random.png new file mode 100644 index 0000000..f97c30d Binary files /dev/null and b/icons/random.png differ diff --git a/icons/scorpion.png b/icons/scorpion.png new file mode 100644 index 0000000..1cc01f4 Binary files /dev/null and b/icons/scorpion.png differ diff --git a/icons/snail.png b/icons/snail.png new file mode 100644 index 0000000..cdc39bd Binary files /dev/null and b/icons/snail.png differ diff --git a/icons/snake.png b/icons/snake.png new file mode 100644 index 0000000..5748e56 Binary files /dev/null and b/icons/snake.png differ diff --git a/icons/trade.png b/icons/trade.png new file mode 100644 index 0000000..5574497 Binary files /dev/null and b/icons/trade.png differ diff --git a/scripts/base.js b/scripts/base.js index 3752595..fe9e158 100644 --- a/scripts/base.js +++ b/scripts/base.js @@ -1080,7 +1080,9 @@ Object.defineProperty(Array.prototype, 'empty', { Object.defineProperty(Array.prototype, 'push_unique', { value: function(x) { - if (!this.includes(x)) this.push(x); + var inc = !this.includes(x); + if (inc) this.push(x); + return inc; }}); Object.defineProperty(Array.prototype, 'unique', { diff --git a/source/engine/gui.cpp b/source/engine/gui.cpp index b076bea..1040eeb 100644 --- a/source/engine/gui.cpp +++ b/source/engine/gui.cpp @@ -81,16 +81,30 @@ JSC_SCALL(imgui_lineplot, JSC_SSCALL(imgui_textinput, char buffer[512]; - strncpy(buffer, str2, 512); + if (JS_IsUndefined(argv[1])) + buffer[0] = 0; + else + strncpy(buffer, str2, 512); + ImGui::InputText(str, buffer, sizeof(buffer)); - ret = str2js(buffer); + if (strcmp(buffer, str2)) + ret = str2js(buffer); + else + ret = JS_DupValue(js,argv[1]); ) JSC_SSCALL(imgui_textbox, char buffer[512]; - strncpy(buffer, str2, 512); + if (JS_IsUndefined(argv[1])) + buffer[0] = 0; + else + strncpy(buffer, str2, 512); + ImGui::InputTextMultiline(str, buffer, sizeof(buffer)); - ret = str2js(buffer); + if (strcmp(buffer, str2)) + ret = str2js(buffer); + else + ret = JS_DupValue(js,argv[1]); ) JSC_SCALL(imgui_text, ImGui::Text(str) ) @@ -145,6 +159,41 @@ JSC_SCALL(imgui_slider, } ) +JSC_SCALL(imgui_intslider, + int low = JS_IsUndefined(argv[2]) ? 0.0 : js2number(argv[2]); + int high = JS_IsUndefined(argv[3]) ? 1.0 : js2number(argv[3]); + + if (JS_IsArray(js, argv[1])) { + int n = js_arrlen(argv[1]); + float a[n]; + js2floatarr(argv[1], n, a); + int b[n]; + for (int i = 0; i < n; i++) + b[i] = a[i]; + + switch(n) { + case 2: + ImGui::SliderInt2(str, b, low, high); + break; + case 3: + ImGui::SliderInt3(str, b, low, high); + break; + case 4: + ImGui::SliderInt3(str, b, low, high); + break; + } + + for (int i = 0; i < n; i++) + a[i] = b[i]; + + ret = floatarr2js(n, a); + } else { + int val = js2number(argv[1]); + ImGui::SliderInt(str, &val, low, high); + ret = number2js(val); + } +) + JSC_SCALL(imgui_checkbox, bool val = js2boolean(argv[1]); ImGui::Checkbox(str, &val); @@ -537,6 +586,7 @@ static const JSCFunctionListEntry js_imgui_funcs[] = { MIST_FUNC_DEF(imgui, pushid, 1), MIST_FUNC_DEF(imgui, popid, 0), MIST_FUNC_DEF(imgui, slider, 4), + MIST_FUNC_DEF(imgui, intslider, 4), MIST_FUNC_DEF(imgui, menubar, 1), MIST_FUNC_DEF(imgui, mainmenubar, 1), MIST_FUNC_DEF(imgui, menuitem, 3),