Removed most usage of Scene#hit

This commit is contained in:
Anuken
2024-08-16 16:00:47 -04:00
parent 7963923013
commit 8e8b99d421
8 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -158,7 +158,7 @@ public class UI implements ApplicationListener, Loadable{
Core.scene.draw(); Core.scene.draw();
if(Core.input.keyTap(KeyCode.mouseLeft) && Core.scene.hasField()){ 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)){ if(!(e instanceof TextField)){
Core.scene.setKeyboardFocus(null); Core.scene.setKeyboardFocus(null);
} }
+1 -1
View File
@@ -329,7 +329,7 @@ public class MapView extends Element implements GestureListener{
return Core.scene != null && Core.scene.getKeyboardFocus() != null return Core.scene != null && Core.scene.getKeyboardFocus() != null
&& Core.scene.getKeyboardFocus().isDescendantOf(ui.editor) && Core.scene.getKeyboardFocus().isDescendantOf(ui.editor)
&& ui.editor.isShown() && tool == EditorTool.zoom && && ui.editor.isShown() && tool == EditorTool.zoom &&
Core.scene.hit(Core.input.mouse().x, Core.input.mouse().y, true) == this; Core.scene.getHoverElement() == this;
} }
@Override @Override
+1 -1
View File
@@ -171,7 +171,7 @@ public class LCanvas extends Table{
} }
StatementElem checkHovered(){ StatementElem checkHovered(){
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); Element e = Core.scene.getHoverElement();
if(e != null){ if(e != null){
while(e != null && !(e instanceof StatementElem)){ while(e != null && !(e instanceof StatementElem)){
e = e.parent; e = e.parent;
+1 -1
View File
@@ -111,7 +111,7 @@ public class Minimap extends Table{
update(() -> { update(() -> {
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); Element e = Core.scene.getHoverElement();
if(e != null && e.isDescendantOf(this)){ if(e != null && e.isDescendantOf(this)){
requestScroll(); requestScroll();
}else if(hasScroll()){ }else if(hasScroll()){
@@ -587,7 +587,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
@Override @Override
public void act(float delta){ 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); scene.setScrollFocus(PlanetDialog.this);
} }
@@ -472,7 +472,7 @@ public class ResearchDialog extends BaseDialog{
if(mobile){ if(mobile){
tapped(() -> { tapped(() -> {
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); Element e = Core.scene.getHoverElement();
if(e == this){ if(e == this){
hoverNode = null; hoverNode = null;
rebuild(); rebuild();
@@ -67,7 +67,7 @@ public class BlockConfigFragment{
} }
public boolean hasConfigMouse(){ 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)); return e != null && (e == table || e.isDescendantOf(table));
} }
@@ -615,7 +615,7 @@ public class PlacementFragment{
blocksSelect.margin(4).marginTop(0); blocksSelect.margin(4).marginTop(0);
blockPane = blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> { blockPane = blocksSelect.pane(blocks -> blockTable = blocks).height(194f).update(pane -> {
if(pane.hasScroll()){ 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)){ if(result == null || !result.isDescendantOf(pane)){
Core.scene.setScrollFocus(null); Core.scene.setScrollFocus(null);
} }