fix: input F1..F25 key codes & add binding 'chunks.reload'
This commit is contained in:
parent
d316a5f818
commit
ad62b759fb
@ -1,4 +1,5 @@
|
|||||||
devtools.console="key:grave-accent"
|
devtools.console="key:grave-accent"
|
||||||
|
chunks.reload="key:f5"
|
||||||
movement.forward="key:w"
|
movement.forward="key:w"
|
||||||
movement.back="key:s"
|
movement.back="key:s"
|
||||||
movement.left="key:a"
|
movement.left="key:a"
|
||||||
|
|||||||
@ -13,6 +13,7 @@ graphics.gamma.tooltip=Lighting brightness curve
|
|||||||
graphics.backlight.tooltip=Backlight to prevent total darkness
|
graphics.backlight.tooltip=Backlight to prevent total darkness
|
||||||
|
|
||||||
# Bindings
|
# Bindings
|
||||||
|
chunks.reload=Reload Chunks
|
||||||
devtools.console=Console
|
devtools.console=Console
|
||||||
movement.forward=Forward
|
movement.forward=Forward
|
||||||
movement.back=Back
|
movement.back=Back
|
||||||
|
|||||||
@ -60,6 +60,7 @@ settings.UI Sounds=Звуки Интерфейса
|
|||||||
settings.V-Sync=Вертикальная Синхронизация
|
settings.V-Sync=Вертикальная Синхронизация
|
||||||
|
|
||||||
# Управление
|
# Управление
|
||||||
|
chunks.reload=Перезагрузить Чанки
|
||||||
devtools.console=Консоль
|
devtools.console=Консоль
|
||||||
movement.forward=Вперёд
|
movement.forward=Вперёд
|
||||||
movement.back=Назад
|
movement.back=Назад
|
||||||
|
|||||||
@ -10,6 +10,7 @@ inline const std::string TEXTURE_NOTFOUND = "notfound";
|
|||||||
|
|
||||||
// built-in bindings
|
// built-in bindings
|
||||||
inline const std::string BIND_DEVTOOLS_CONSOLE = "devtools.console";
|
inline const std::string BIND_DEVTOOLS_CONSOLE = "devtools.console";
|
||||||
|
inline const std::string BIND_CHUNKS_RELOAD = "chunks.reload";
|
||||||
inline const std::string BIND_MOVE_FORWARD = "movement.forward";
|
inline const std::string BIND_MOVE_FORWARD = "movement.forward";
|
||||||
inline const std::string BIND_MOVE_BACK = "movement.back";
|
inline const std::string BIND_MOVE_BACK = "movement.back";
|
||||||
inline const std::string BIND_MOVE_LEFT = "movement.left";
|
inline const std::string BIND_MOVE_LEFT = "movement.left";
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "LevelScreen.hpp"
|
#include "LevelScreen.hpp"
|
||||||
|
|
||||||
|
#include "../../core_defs.hpp"
|
||||||
#include "../hud.hpp"
|
#include "../hud.hpp"
|
||||||
#include "../LevelFrontend.hpp"
|
#include "../LevelFrontend.hpp"
|
||||||
#include "../../audio/audio.hpp"
|
#include "../../audio/audio.hpp"
|
||||||
@ -47,6 +48,9 @@ LevelScreen::LevelScreen(Engine* engine, std::unique_ptr<Level> level)
|
|||||||
keepAlive(settings.camera.fov.observe([=](double value) {
|
keepAlive(settings.camera.fov.observe([=](double value) {
|
||||||
controller->getPlayer()->camera->setFov(glm::radians(value));
|
controller->getPlayer()->camera->setFov(glm::radians(value));
|
||||||
}));
|
}));
|
||||||
|
keepAlive(Events::getBinding(BIND_CHUNKS_RELOAD).onactived.add([=](){
|
||||||
|
controller->getLevel()->chunks->saveAndClear();
|
||||||
|
}));
|
||||||
|
|
||||||
animator = std::make_unique<TextureAnimator>();
|
animator = std::make_unique<TextureAnimator>();
|
||||||
animator->addAnimations(assets->getAnimations());
|
animator->addAnimations(assets->getAnimations());
|
||||||
@ -114,9 +118,6 @@ void LevelScreen::updateHotkeys() {
|
|||||||
if (Events::jpressed(keycode::F3)) {
|
if (Events::jpressed(keycode::F3)) {
|
||||||
controller->getPlayer()->debug = !controller->getPlayer()->debug;
|
controller->getPlayer()->debug = !controller->getPlayer()->debug;
|
||||||
}
|
}
|
||||||
if (Events::jpressed(keycode::F5)) {
|
|
||||||
controller->getLevel()->chunks->saveAndClear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelScreen::update(float delta) {
|
void LevelScreen::update(float delta) {
|
||||||
|
|||||||
@ -98,6 +98,14 @@ void Events::pollEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binding& Events::getBinding(const std::string& name) {
|
||||||
|
auto found = bindings.find(name);
|
||||||
|
if (found == bindings.end()) {
|
||||||
|
throw std::runtime_error("binding '"+name+"' does not exists");
|
||||||
|
}
|
||||||
|
return found->second;
|
||||||
|
}
|
||||||
|
|
||||||
void Events::bind(const std::string& name, inputtype type, keycode code) {
|
void Events::bind(const std::string& name, inputtype type, keycode code) {
|
||||||
bind(name, type, static_cast<int>(code));
|
bind(name, type, static_cast<int>(code));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
static void toggleCursor();
|
static void toggleCursor();
|
||||||
|
|
||||||
|
static Binding& getBinding(const std::string& name);
|
||||||
static void bind(const std::string& name, inputtype type, keycode code);
|
static void bind(const std::string& name, inputtype type, keycode code);
|
||||||
static void bind(const std::string& name, inputtype type, mousecode code);
|
static void bind(const std::string& name, inputtype type, mousecode code);
|
||||||
static void bind(const std::string& name, inputtype type, int code);
|
static void bind(const std::string& name, inputtype type, int code);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ void input_util::initialize() {
|
|||||||
keycodes[std::to_string(i)] = GLFW_KEY_0+i;
|
keycodes[std::to_string(i)] = GLFW_KEY_0+i;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 25; i++) {
|
for (int i = 0; i < 25; i++) {
|
||||||
keycodes["f"+std::to_string(i)] = GLFW_KEY_F1+i;
|
keycodes["f"+std::to_string(i+1)] = GLFW_KEY_F1+i;
|
||||||
}
|
}
|
||||||
for (char i = 'a'; i <= 'z'; i++) {
|
for (char i = 'a'; i <= 'z'; i++) {
|
||||||
keycodes[std::string({i})] = GLFW_KEY_A-'a'+i;
|
keycodes[std::string({i})] = GLFW_KEY_A-'a'+i;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user