refactor: replace references to Events with Input

This commit is contained in:
MihailRis
2025-04-02 14:55:53 +03:00
parent 4c48afbb90
commit b202d1455b
15 changed files with 160 additions and 116 deletions
+7 -3
View File
@@ -178,10 +178,10 @@ void GUI::actFocused() {
focus = nullptr;
return;
}
for (auto codepoint : Events::codepoints) {
for (auto codepoint : input.getCodepoints()) {
focus->typed(codepoint);
}
for (auto key : Events::pressedKeys) {
for (auto key : input.getPressedKeys()) {
focus->keyPressed(key);
}
@@ -205,7 +205,7 @@ void GUI::act(float delta, const Viewport& vp) {
updateTooltip(delta);
const auto& cursor = input.getCursor();
if (!Events::isCursorLocked()) {
if (!cursor.locked) {
actMouse(delta, cursor);
} else {
if (hover) {
@@ -357,3 +357,7 @@ void GUI::toggleDebug() {
const Input& GUI::getInput() const {
return engine.getInput();
}
Input& GUI::getInput() {
return engine.getInput();
}
+1
View File
@@ -157,5 +157,6 @@ namespace gui {
void toggleDebug();
const Input& getInput() const;
Input& getInput();
};
}
+2 -1
View File
@@ -281,7 +281,8 @@ bool SlotView::isHighlighted() const {
}
void SlotView::performLeftClick(ItemStack& stack, ItemStack& grabbed) {
if (layout.taking && Events::pressed(keycode::LEFT_SHIFT)) {
const auto& input = gui.getInput();
if (layout.taking && input.pressed(keycode::LEFT_SHIFT)) {
if (layout.shareFunc) {
layout.shareFunc(layout.index, stack);
}
+1 -1
View File
@@ -587,7 +587,7 @@ static std::shared_ptr<UINode> read_input_bind_box(
UiXmlReader& reader, const xml::xmlelement& element
) {
auto bindname = element.attr("binding").getText();
auto& found = Events::requireBinding(bindname);
auto& found = reader.getGUI().getInput().getBindings().require(bindname);
glm::vec4 padding = element.attr("padding", "6").asVec4();
auto bindbox =
std::make_shared<InputBindBox>(reader.getGUI(), found, padding);