core.get_bindings

This commit is contained in:
MihailRis 2024-03-27 19:42:42 +03:00
parent 0838208fb6
commit aa243ba852
2 changed files with 19 additions and 3 deletions

View File

@ -66,9 +66,10 @@ static void create_controls_panel(Engine* engine) {
panel->add(trackbar);
}
auto scrollPanel = std::make_shared<Panel>(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<Panel>(guiutil::create(
"<panel size='400,200' padding='2' interval='1' max-length='400' color='#0000004C'>"
"</panel>"
));
for (auto& entry : Events::bindings){
std::string bindname = entry.first;

View File

@ -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<l_open_world>},
{"close_world", lua_wrap_errors<l_close_world>},
{"delete_world", lua_wrap_errors<l_delete_world>},
{"get_bindings", lua_wrap_errors<l_get_bindings>},
{"quit", lua_wrap_errors<l_quit>},
{NULL, NULL}
};