From 8e8b99d42195bf66c1396e4559c6c75e661e2271 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 16 Aug 2024 16:00:47 -0400 Subject: [PATCH] Removed most usage of Scene#hit --- core/src/mindustry/core/UI.java | 2 +- core/src/mindustry/editor/MapView.java | 2 +- core/src/mindustry/logic/LCanvas.java | 2 +- core/src/mindustry/ui/Minimap.java | 2 +- core/src/mindustry/ui/dialogs/PlanetDialog.java | 2 +- core/src/mindustry/ui/dialogs/ResearchDialog.java | 2 +- core/src/mindustry/ui/fragments/BlockConfigFragment.java | 2 +- core/src/mindustry/ui/fragments/PlacementFragment.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index d634e122b5..085f97d6d8 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -158,7 +158,7 @@ public class UI implements ApplicationListener, Loadable{ Core.scene.draw(); if(Core.input.keyTap(KeyCode.mouseLeft) && Core.scene.hasField()){ - Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); + Element e = Core.scene.getHoverElement(); if(!(e instanceof TextField)){ Core.scene.setKeyboardFocus(null); } diff --git a/core/src/mindustry/editor/MapView.java b/core/src/mindustry/editor/MapView.java index dd1c447f61..4131bc2bcd 100644 --- a/core/src/mindustry/editor/MapView.java +++ b/core/src/mindustry/editor/MapView.java @@ -329,7 +329,7 @@ public class MapView extends Element implements GestureListener{ return Core.scene != null && Core.scene.getKeyboardFocus() != null && Core.scene.getKeyboardFocus().isDescendantOf(ui.editor) && ui.editor.isShown() && tool == EditorTool.zoom && - Core.scene.hit(Core.input.mouse().x, Core.input.mouse().y, true) == this; + Core.scene.getHoverElement() == this; } @Override diff --git a/core/src/mindustry/logic/LCanvas.java b/core/src/mindustry/logic/LCanvas.java index c2fc83138b..dd3c0133cd 100644 --- a/core/src/mindustry/logic/LCanvas.java +++ b/core/src/mindustry/logic/LCanvas.java @@ -171,7 +171,7 @@ public class LCanvas extends Table{ } StatementElem checkHovered(){ - Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); + Element e = Core.scene.getHoverElement(); if(e != null){ while(e != null && !(e instanceof StatementElem)){ e = e.parent; diff --git a/core/src/mindustry/ui/Minimap.java b/core/src/mindustry/ui/Minimap.java index 99c7a32303..ee03fc2435 100644 --- a/core/src/mindustry/ui/Minimap.java +++ b/core/src/mindustry/ui/Minimap.java @@ -111,7 +111,7 @@ public class Minimap extends Table{ update(() -> { - Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); + Element e = Core.scene.getHoverElement(); if(e != null && e.isDescendantOf(this)){ requestScroll(); }else if(hasScroll()){ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index c8f4fb44c2..6ef9bb6397 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -587,7 +587,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{ @Override public void act(float delta){ - if(scene.getDialog() == PlanetDialog.this && !scene.hit(input.mouseX(), input.mouseY(), true).isDescendantOf(e -> e instanceof ScrollPane)){ + if(scene.getDialog() == PlanetDialog.this && (scene.getHoverElement() == null || !scene.getHoverElement().isDescendantOf(e -> e instanceof ScrollPane))){ scene.setScrollFocus(PlanetDialog.this); } diff --git a/core/src/mindustry/ui/dialogs/ResearchDialog.java b/core/src/mindustry/ui/dialogs/ResearchDialog.java index a251419f31..e601e02b5d 100644 --- a/core/src/mindustry/ui/dialogs/ResearchDialog.java +++ b/core/src/mindustry/ui/dialogs/ResearchDialog.java @@ -472,7 +472,7 @@ public class ResearchDialog extends BaseDialog{ if(mobile){ tapped(() -> { - Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); + Element e = Core.scene.getHoverElement(); if(e == this){ hoverNode = null; rebuild(); diff --git a/core/src/mindustry/ui/fragments/BlockConfigFragment.java b/core/src/mindustry/ui/fragments/BlockConfigFragment.java index 356c63fca4..79ad799a3a 100644 --- a/core/src/mindustry/ui/fragments/BlockConfigFragment.java +++ b/core/src/mindustry/ui/fragments/BlockConfigFragment.java @@ -67,7 +67,7 @@ public class BlockConfigFragment{ } public boolean hasConfigMouse(){ - Element e = Core.scene.hit(Core.input.mouseX(), Core.graphics.getHeight() - Core.input.mouseY(), true); + Element e = Core.scene.getHoverElement(); return e != null && (e == table || e.isDescendantOf(table)); } diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index 2c3e6ad524..8bbc475022 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -615,7 +615,7 @@ public class PlacementFragment{ blocksSelect.margin(4).marginTop(0); blockPane = blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> { if(pane.hasScroll()){ - Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); + Element result = Core.scene.getHoverElement(); if(result == null || !result.isDescendantOf(pane)){ Core.scene.setScrollFocus(null); }