Merge branch 'main' into visuals-restoration

This commit is contained in:
MihailRis 2025-12-16 01:12:00 +03:00
commit c017273374
20 changed files with 105 additions and 54 deletions

View file

@ -404,22 +404,22 @@ void BlocksRenderer::blockCube(
}
} else {
if (isOpen(coord + Z, block, variant)) {
face(coord, X, Y, Z, texfaces[5], pickLight(coord + Z), lights);
face(coord, X, Y, Z, texfaces[5], lights ? pickLight(coord + Z) : glm::vec4(1,1,1,0), lights);
}
if (isOpen(coord - Z, block, variant)) {
face(coord, -X, Y, -Z, texfaces[4], pickLight(coord - Z), lights);
face(coord, -X, Y, -Z, texfaces[4], lights ? pickLight(coord - Z) : glm::vec4(1,1,1,0), lights);
}
if (isOpen(coord + Y, block, variant)) {
face(coord, X, -Z, Y, texfaces[3], pickLight(coord + Y), lights);
face(coord, X, -Z, Y, texfaces[3], lights ? pickLight(coord + Y) : glm::vec4(1,1,1,0), lights);
}
if (isOpen(coord - Y, block, variant)) {
face(coord, X, Z, -Y, texfaces[2], pickLight(coord - Y), lights);
face(coord, X, Z, -Y, texfaces[2], lights ? pickLight(coord - Y) : glm::vec4(1,1,1,0), lights);
}
if (isOpen(coord + X, block, variant)) {
face(coord, -Z, Y, X, texfaces[1], pickLight(coord + X), lights);
face(coord, -Z, Y, X, texfaces[1], lights ? pickLight(coord + X) : glm::vec4(1,1,1,0), lights);
}
if (isOpen(coord - X, block, variant)) {
face(coord, Z, Y, -X, texfaces[0], pickLight(coord - X), lights);
face(coord, Z, Y, -X, texfaces[0], lights ? pickLight(coord - X) : glm::vec4(1,1,1,0), lights);
}
}
}

View file

@ -146,11 +146,18 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
}
this->hover = hover;
auto node = hover;
while (node) {
if (mouseOver.find(hover) != mouseOver.end()) {
break;
if (std::find_if(
mouseOver.begin(),
mouseOver.end(),
[&hover](const std::weak_ptr<UINode>& weak) {
auto locked = weak.lock();
return locked && locked == hover;
}) != mouseOver.end()) {
break;
}
mouseOver.insert(node);
mouseOver.push_back(node);
node->setMouseOver(true);
auto parent = node->getParent();
if (parent) {
@ -159,12 +166,14 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
}
for (auto it = mouseOver.begin(); it != mouseOver.end(); ) {
auto node = *it;
if (node->isInside(cursor.pos)) {
++it;
continue;
auto node = it->lock();
if (node) {
if (node->isInside(cursor.pos)) {
++it;
continue;
}
node->setMouseOver(false);
}
node->setMouseOver(false);
it = mouseOver.erase(it);
}
@ -270,6 +279,7 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
auto& page = menu->getCurrent();
if (page.panel) {
menu->setSize(page.panel->getSize());
page.panel->refresh();
if (auto panel = std::dynamic_pointer_cast<gui::Panel>(page.panel)) {
panel->cropToContent();
}

View file

@ -81,7 +81,7 @@ namespace gui {
std::unique_ptr<Camera> uicamera;
std::shared_ptr<Menu> menu;
std::queue<runnable> postRunnables;
std::set<std::shared_ptr<UINode>> mouseOver;
std::vector<std::weak_ptr<UINode>> mouseOver;
PageLoaderFunc pagesLoader;