Update KekEngine, Update ConsoleElement
This commit is contained in:
parent
639d2ce889
commit
98e01b7e9a
2
dependencies/kekengine
vendored
2
dependencies/kekengine
vendored
@ -1 +1 @@
|
|||||||
Subproject commit bbee789593fda91071e2d06a0320c05d12b59649
|
Subproject commit 638c7165076a0f43eaeef4fda6d4d2828e2cb292
|
@ -26,6 +26,12 @@ ConsoleElement::ConsoleElement(kek::UIValue x, kek::UIValue y, kek::UIValue w, k
|
|||||||
textFieldElement->cursor->color = kek::Colors::WHITE;
|
textFieldElement->cursor->color = kek::Colors::WHITE;
|
||||||
textFieldElement->textElement->color = kek::Colors::WHITE;
|
textFieldElement->textElement->color = kek::Colors::WHITE;
|
||||||
addChild(textFieldElement);
|
addChild(textFieldElement);
|
||||||
|
|
||||||
|
textFieldElement->onSubmit = kek::SubmitCallback([](std::string text, void *data) {
|
||||||
|
ConsoleElement *_this = (ConsoleElement *) data;
|
||||||
|
_this->onCommand(CommandEvent{text});
|
||||||
|
},
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleElement::~ConsoleElement() {
|
ConsoleElement::~ConsoleElement() {
|
||||||
|
@ -41,9 +41,9 @@ void gameLoop(GLFWwindow *window, void *) {}
|
|||||||
|
|
||||||
void startGame() {
|
void startGame() {
|
||||||
ConsoleElement *console = new ConsoleElement(uiPx(10), uiPx(10), uiSw(1) - uiPx(20), uiSh(1) - uiPx(20));
|
ConsoleElement *console = new ConsoleElement(uiPx(10), uiPx(10), uiSw(1) - uiPx(20), uiSh(1) - uiPx(20));
|
||||||
console->textFieldElement->onSubmit = SubmitCallback([](std::string text, void *data) {
|
console->onCommand = CommandCallback([](CommandEvent event, void *data) {
|
||||||
ConsoleElement *_console = (ConsoleElement *) data;
|
ConsoleElement *_console = (ConsoleElement *) data;
|
||||||
_console->textElement->setText(_console->textElement->getText() + "\n" + "> " + text);
|
_console->textElement->setText(_console->textElement->getText() + "\n" + "> " + event.command);
|
||||||
_console->textFieldElement->setText("");
|
_console->textFieldElement->setText("");
|
||||||
UI::focusElement(_console->textFieldElement);
|
UI::focusElement(_console->textFieldElement);
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "uielements.h"
|
#include "uielements.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
struct CommandEvent {
|
||||||
|
std::string command;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef kek::GenericCallable<CommandEvent> CommandCallback;
|
||||||
|
|
||||||
class ConsoleElement: public kek::RectangleElement {
|
class ConsoleElement: public kek::RectangleElement {
|
||||||
|
|
||||||
@ -9,6 +16,8 @@ class ConsoleElement: public kek::RectangleElement {
|
|||||||
kek::TextElement *textElement;
|
kek::TextElement *textElement;
|
||||||
kek::TextFieldElement *textFieldElement;
|
kek::TextFieldElement *textFieldElement;
|
||||||
|
|
||||||
|
CommandCallback onCommand;
|
||||||
|
|
||||||
ConsoleElement(kek::UIValue x, kek::UIValue y, kek::UIValue w, kek::UIValue h);
|
ConsoleElement(kek::UIValue x, kek::UIValue y, kek::UIValue w, kek::UIValue h);
|
||||||
|
|
||||||
virtual ~ConsoleElement();
|
virtual ~ConsoleElement();
|
||||||
|
Loading…
Reference in New Issue
Block a user