Update some things.
This commit is contained in:
parent
f215bc3742
commit
f9d6e7a70a
35 changed files with 575 additions and 905 deletions
|
|
@ -14,14 +14,14 @@ struct DrawUI {};
|
|||
|
||||
}
|
||||
|
||||
static std::unordered_map<Key, nk_keys> ArtifactToNuklear {};
|
||||
static std::array<nk_keys, static_cast<size_t>(Key::Last) + 1> ArtifactToNuklear {};
|
||||
|
||||
namespace {
|
||||
|
||||
static struct _nkInit {
|
||||
_nkInit() {
|
||||
// Populate the Artifact-to-Nuklear key map.
|
||||
#define X(nuklear, artifact) ArtifactToNuklear[Key::artifact] = nuklear
|
||||
#define X(nuklear, artifact) ArtifactToNuklear[static_cast<int>(Key::artifact)] = nuklear
|
||||
X(NK_KEY_CTRL, ControlLeft);
|
||||
X(NK_KEY_CTRL, ControlRight);
|
||||
|
||||
|
|
@ -47,37 +47,36 @@ static struct _nkInit {
|
|||
|
||||
void UIRenderer::init() {
|
||||
printf("UI: %p", graphics);
|
||||
window = graphics->window;
|
||||
|
||||
window->listen<Events::InputBegin>([this](auto ev) {
|
||||
graphics->window->listen<Events::InputBegin>([this](auto ev) {
|
||||
nk_input_begin(&ctx);
|
||||
});
|
||||
|
||||
window->listen<Events::InputEnd>([this](auto ev) {
|
||||
graphics->window->listen<Events::InputEnd>([this](auto ev) {
|
||||
nk_input_end(&ctx);
|
||||
});
|
||||
|
||||
window->listen<Events::CursorPosEvent>([this](auto ev) {
|
||||
graphics->window->listen<Events::CursorPosEvent>([this](auto ev) {
|
||||
nk_input_motion(&ctx, ev.x, ev.y);
|
||||
});
|
||||
|
||||
window->listen<Events::ScrollEvent>([this](auto ev) {
|
||||
graphics->window->listen<Events::ScrollEvent>([this](auto ev) {
|
||||
nk_input_scroll(&ctx, nk_vec2(ev.dx, ev.dy));
|
||||
});
|
||||
|
||||
window->listen<Events::MouseEvent>([this](auto ev) {
|
||||
graphics->window->listen<Events::MouseEvent>([this](auto ev) {
|
||||
nk_input_button(&ctx, ev.button == Events::MOUSE_BUTTON_RIGHT ? NK_BUTTON_RIGHT : NK_BUTTON_LEFT, (int)ev.x, (int)ev.y, ev.state);
|
||||
});
|
||||
|
||||
window->listen<Events::KeyDownEvent>([this](auto ev) {
|
||||
nk_input_key(&ctx, ArtifactToNuklear[ev.key], true);
|
||||
graphics->window->listen<Events::KeyDownEvent>([this](auto ev) {
|
||||
nk_input_key(&ctx, ArtifactToNuklear[static_cast<int>(ev.key)], true);
|
||||
});
|
||||
|
||||
window->listen<Events::KeyUpEvent>([this](auto ev) {
|
||||
nk_input_key(&ctx, ArtifactToNuklear[ev.key], false);
|
||||
graphics->window->listen<Events::KeyUpEvent>([this](auto ev) {
|
||||
nk_input_key(&ctx, ArtifactToNuklear[static_cast<int>(ev.key)], false);
|
||||
});
|
||||
|
||||
window->listen<Events::CharInputEvent>([this](auto ev) {
|
||||
graphics->window->listen<Events::CharInputEvent>([this](auto ev) {
|
||||
nk_input_char(&ctx, ev.codepoint);
|
||||
});
|
||||
|
||||
|
|
@ -102,7 +101,6 @@ void UIRenderer::init() {
|
|||
fclose(fontFile);
|
||||
font = nk_font_atlas_add_from_memory(&atlas, fontData, fontSize, 13.0f, nullptr);
|
||||
} else {
|
||||
fprintf(stderr, (std::string("Failed to load font: ") + assetPath + "/fonts/Arial.ttf\n").c_str());
|
||||
font = nk_font_atlas_add_default(&atlas, 13.0f, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue