mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add item dropping outside of inventory
This commit is contained in:
parent
0cbb740e70
commit
56c4d68c84
8 changed files with 132 additions and 21 deletions
|
|
@ -14,7 +14,6 @@
|
|||
#include "frontend/UiDocument.hpp"
|
||||
#include "frontend/locale.hpp"
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "graphics/core/LineBatch.hpp"
|
||||
#include "graphics/core/Shader.hpp"
|
||||
#include "graphics/core/Font.hpp"
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
|
|
@ -179,6 +178,8 @@ void GUI::actMouse(Frame& frame, float delta, const CursorState& cursor) {
|
|||
}
|
||||
it = mouseOver.erase(it);
|
||||
}
|
||||
|
||||
bool focusHappened = false;
|
||||
|
||||
if (input.jclicked(Mousecode::BUTTON_1)) {
|
||||
if (pressed == nullptr && this->hover) {
|
||||
|
|
@ -196,10 +197,10 @@ void GUI::actMouse(Frame& frame, float delta, const CursorState& cursor) {
|
|||
if (focus != pressed) {
|
||||
focus = pressed;
|
||||
focus->onFocus();
|
||||
return;
|
||||
focusHappened = true;
|
||||
}
|
||||
}
|
||||
if (this->hover == nullptr && focus) {
|
||||
if (this->hover == nullptr && focus && !focusHappened) {
|
||||
focus->defocus();
|
||||
focus = nullptr;
|
||||
}
|
||||
|
|
@ -208,13 +209,44 @@ void GUI::actMouse(Frame& frame, float delta, const CursorState& cursor) {
|
|||
pressed = nullptr;
|
||||
}
|
||||
|
||||
if (hover) {
|
||||
if (hover && !focusHappened) {
|
||||
for (Mousecode code : MOUSECODES_ALL) {
|
||||
if (input.jclicked(code)) {
|
||||
hover->clicked(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
performClickOutside(frame, delta, cursorPos);
|
||||
}
|
||||
|
||||
void GUI::performClickOutside(Frame& frame, float delta, glm::vec2 cursorPos) {
|
||||
auto nodes = frame.getNodes();
|
||||
std::vector<std::shared_ptr<UINode>> activeNodes;
|
||||
|
||||
for (const auto& node : nodes) {
|
||||
if (node && node->isVisible() && node->isInteractive()) {
|
||||
activeNodes.push_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
for (Mousecode code : {Mousecode::BUTTON_1, Mousecode::BUTTON_2, Mousecode::BUTTON_3}) {
|
||||
if (input.jclicked(code)) {
|
||||
bool isOverAnyNode = false;
|
||||
for (const auto& node : activeNodes) {
|
||||
if (node && node->isInside(cursorPos)) {
|
||||
isOverAnyNode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isOverAnyNode) {
|
||||
for (const auto& node : activeNodes) {
|
||||
if (node) {
|
||||
node->clickedOutside(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GUI::actFocused() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue