2024-02-01 03:12:24 -05:00
|
|
|
#include <libreborn/libreborn.h>
|
|
|
|
|
|
|
|
#include <mods/text-input-box/TextInputScreen.h>
|
|
|
|
|
|
|
|
// VTable
|
|
|
|
void TextInputScreen::setup(Screen_vtable *vtable) {
|
|
|
|
vtable->keyPressed = [](Screen *super2, int key) {
|
|
|
|
Screen_keyPressed_non_virtual(super2, key);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
2024-02-01 14:56:16 -05:00
|
|
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
|
|
|
TextInputBox *textInput = (*self->m_textInputs)[i];
|
2024-02-01 03:12:24 -05:00
|
|
|
textInput->keyPressed(key);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
vtable->keyboardNewChar = [](Screen *super2, char key) {
|
|
|
|
Screen_keyboardNewChar_non_virtual(super2, key);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
2024-02-01 14:56:16 -05:00
|
|
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
|
|
|
TextInputBox *textInput = (*self->m_textInputs)[i];
|
2024-02-01 03:12:24 -05:00
|
|
|
textInput->charPressed(key);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
vtable->mouseClicked = [](Screen *super2, int x, int y, int param_1) {
|
|
|
|
Screen_mouseClicked_non_virtual(super2, x, y, param_1);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
2024-02-01 14:56:16 -05:00
|
|
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
|
|
|
TextInputBox *textInput = (*self->m_textInputs)[i];
|
2024-02-01 03:12:24 -05:00
|
|
|
textInput->onClick(x, y);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
vtable->render = [](Screen *super2, int x, int y, float param_1) {
|
|
|
|
Screen_render_non_virtual(super2, x, y, param_1);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
2024-02-01 14:56:16 -05:00
|
|
|
for (int i = 0; i < int(self->m_textInputs->size()); i++) {
|
|
|
|
TextInputBox *textInput = (*self->m_textInputs)[i];
|
2024-02-01 03:12:24 -05:00
|
|
|
textInput->tick();
|
|
|
|
textInput->render();
|
|
|
|
}
|
|
|
|
};
|
2024-02-01 14:56:16 -05:00
|
|
|
vtable->init = [](Screen *super2) {
|
|
|
|
Screen_init_non_virtual(super2);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
|
|
|
self->m_textInputs = new std::vector<TextInputBox *>;
|
|
|
|
};
|
|
|
|
vtable->removed = [](Screen *super2) {
|
|
|
|
Screen_removed_non_virtual(super2);
|
|
|
|
TextInputScreen *self = (TextInputScreen *) super2;
|
|
|
|
delete self->m_textInputs;
|
|
|
|
};
|
2024-02-01 03:12:24 -05:00
|
|
|
}
|