From aa243ba8524e4d1319e2809abb9bb2b9ddf75840 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 27 Mar 2024 19:42:42 +0300 Subject: [PATCH] core.get_bindings --- src/frontend/menu/menu_settings.cpp | 7 ++++--- src/logic/scripting/lua/libcore.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/frontend/menu/menu_settings.cpp b/src/frontend/menu/menu_settings.cpp index 94e6db94..7d15570f 100644 --- a/src/frontend/menu/menu_settings.cpp +++ b/src/frontend/menu/menu_settings.cpp @@ -66,9 +66,10 @@ static void create_controls_panel(Engine* engine) { panel->add(trackbar); } - auto scrollPanel = std::make_shared(glm::vec2(400, 200), glm::vec4(2.0f), 1.0f); - scrollPanel->setColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.3f)); - scrollPanel->setMaxLength(400); + auto scrollPanel = std::dynamic_pointer_cast(guiutil::create( + "" + "" + )); for (auto& entry : Events::bindings){ std::string bindname = entry.first; diff --git a/src/logic/scripting/lua/libcore.cpp b/src/logic/scripting/lua/libcore.cpp index 293bab73..bb4e57f3 100644 --- a/src/logic/scripting/lua/libcore.cpp +++ b/src/logic/scripting/lua/libcore.cpp @@ -6,6 +6,7 @@ #include "../../../frontend/menu/menu.h" #include "../../../frontend/screens.h" #include "../../../logic/LevelController.h" +#include "../../../window/Events.h" #include "../../../window/Window.h" #include "../scripting.h" @@ -52,6 +53,19 @@ static int l_delete_world(lua_State* L) { return 0; } +static int l_get_bindings(lua_State* L) { + auto& bindings = Events::bindings; + lua_createtable(L, bindings.size(), 0); + + int i = 0; + for (auto& entry : bindings) { + lua_pushstring(L, entry.first.c_str()); + lua_rawseti(L, -2, i + 1); + i++; + } + return 1; +} + static int l_quit(lua_State* L) { Window::setShouldClose(true); return 0; @@ -62,6 +76,7 @@ const luaL_Reg corelib [] = { {"open_world", lua_wrap_errors}, {"close_world", lua_wrap_errors}, {"delete_world", lua_wrap_errors}, + {"get_bindings", lua_wrap_errors}, {"quit", lua_wrap_errors}, {NULL, NULL} };