settings panel moved to xml (WIP)
This commit is contained in:
@@ -11,8 +11,8 @@ static debug::Logger logger("level-control");
|
||||
|
||||
LevelController::LevelController(EngineSettings& settings, Level* level)
|
||||
: settings(settings), level(level),
|
||||
blocks(std::make_unique<BlocksController>(level, settings.chunks.padding)),
|
||||
chunks(std::make_unique<ChunksController>(level, settings.chunks.padding)),
|
||||
blocks(std::make_unique<BlocksController>(level, settings.chunks.padding.get())),
|
||||
chunks(std::make_unique<ChunksController>(level, settings.chunks.padding.get())),
|
||||
player(std::make_unique<PlayerController>(level, settings, blocks.get())) {
|
||||
|
||||
scripting::on_world_load(this);
|
||||
@@ -21,8 +21,10 @@ LevelController::LevelController(EngineSettings& settings, Level* level)
|
||||
void LevelController::update(float delta, bool input, bool pause) {
|
||||
player->update(delta, input, pause);
|
||||
glm::vec3 position = player->getPlayer()->hitbox->position;
|
||||
level->loadMatrix(position.x, position.z, settings.chunks.loadDistance + settings.chunks.padding * 2);
|
||||
chunks->update(settings.chunks.loadSpeed);
|
||||
level->loadMatrix(position.x, position.z,
|
||||
settings.chunks.loadDistance.get() +
|
||||
settings.chunks.padding.get() * 2);
|
||||
chunks->update(settings.chunks.loadSpeed.get());
|
||||
|
||||
// erease null pointers
|
||||
level->objects.erase(
|
||||
|
||||
@@ -130,6 +130,29 @@ static int l_str_setting(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_get_setting_info(lua_State* L) {
|
||||
auto name = lua_tostring(L, 1);
|
||||
auto setting = scripting::engine->getSettingsHandler().getSetting(name);
|
||||
if (auto number = dynamic_cast<NumberSetting*>(setting)) {
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushnumber(L, number->getMin());
|
||||
lua_setfield(L, -2, "min");
|
||||
lua_pushnumber(L, number->getMax());
|
||||
lua_setfield(L, -2, "max");
|
||||
return 1;
|
||||
}
|
||||
if (auto integer = dynamic_cast<IntegerSetting*>(setting)) {
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushinteger(L, integer->getMin());
|
||||
lua_setfield(L, -2, "min");
|
||||
lua_pushinteger(L, integer->getMax());
|
||||
lua_setfield(L, -2, "max");
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "unsupported setting type");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_quit(lua_State* L) {
|
||||
Window::setShouldClose(true);
|
||||
return 0;
|
||||
@@ -165,6 +188,7 @@ const luaL_Reg corelib [] = {
|
||||
{"get_setting", lua_wrap_errors<l_get_setting>},
|
||||
{"set_setting", lua_wrap_errors<l_set_setting>},
|
||||
{"str_setting", lua_wrap_errors<l_str_setting>},
|
||||
{"get_setting_info", lua_wrap_errors<l_get_setting_info>},
|
||||
{"quit", lua_wrap_errors<l_quit>},
|
||||
{"get_default_generator", lua_wrap_errors<l_get_default_generator>},
|
||||
{"get_generators", lua_wrap_errors<l_get_generators>},
|
||||
|
||||
Reference in New Issue
Block a user