From b25cd85071f62bdb1c60535126ecc2e345a48a3c Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Mon, 1 Jul 2024 13:05:26 -0500 Subject: [PATCH] more gui --- scripts/engine.js | 4 ++-- scripts/render.js | 2 +- source/engine/gui.cpp | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/engine.js b/scripts/engine.js index 36b9220..e085a41 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -422,8 +422,8 @@ game.doc.pause = "Pause game simulation."; game.doc.play = "Resume or start game simulation."; game.doc.camera = "Current camera."; -game.texture = function (path) { - if (game.texture.cache[path]) return game.texture.cache[path]; +game.texture = function (path, force = false) { + if (force && game.texture.cache[path]) return game.texture.cache[path]; if (!io.exists(path)) { console.warn(`Missing texture: ${path}`); diff --git a/scripts/render.js b/scripts/render.js index 78143d0..85d4a43 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -518,7 +518,7 @@ render.text = function(str, pos, size = 1, color = Color.white, wrap = -1, ancho render.image = function(tex, pos, scale = 1, rotation = 0, color = Color.white, dimensions = [tex.width, tex.height]) { var t = os.make_transform(); t.pos = pos; - t.scale = [scale,scale]; + t.scale = [scale,scale,scale]; render.setpipeline(render.spriteshader.pipe); render.setunim4(0, render.spriteshader.vs.unimap.model.slot, t); render.shader_apply_material(render.spriteshader, { diff --git a/source/engine/gui.cpp b/source/engine/gui.cpp index 4c784af..7d12f01 100644 --- a/source/engine/gui.cpp +++ b/source/engine/gui.cpp @@ -40,13 +40,21 @@ JSC_CCALL(imgui_menuitem, JSC_CCALL(imgui_beginmenubar, ImGui::BeginMenuBar()) JSC_CCALL(imgui_endmenubar, ImGui::EndMenuBar()) +JSC_SSCALL(imgui_textinput, + char buffer[512]; + strncpy(buffer, str2, 512); + ImGui::InputText(str, buffer, sizeof(buffer)); + ret = str2js(buffer); +) + static const JSCFunctionListEntry js_imgui_funcs[] = { MIST_FUNC_DEF(imgui, begin, 1), MIST_FUNC_DEF(imgui, end,0), MIST_FUNC_DEF(imgui, beginmenu, 1), MIST_FUNC_DEF(imgui, menuitem, 3), MIST_FUNC_DEF(imgui, beginmenubar, 0), - MIST_FUNC_DEF(imgui, endmenubar, 0) + MIST_FUNC_DEF(imgui, endmenubar, 0), + MIST_FUNC_DEF(imgui, textinput, 2), }; static int started = 0;