dont try to build when hovered on ui elements lol
parent
baf70d4533
commit
a3845ef537
|
|
@ -11,6 +11,8 @@ import xyz.valnet.hadean.util.Layers;
|
||||||
|
|
||||||
public class BuildLayer extends GameObject implements IMouseCaptureArea {
|
public class BuildLayer extends GameObject implements IMouseCaptureArea {
|
||||||
|
|
||||||
|
private boolean hovered = false;
|
||||||
|
|
||||||
private Camera camera;
|
private Camera camera;
|
||||||
|
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
@ -46,14 +48,12 @@ public class BuildLayer extends GameObject implements IMouseCaptureArea {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEnter() {
|
public void mouseEnter() {
|
||||||
// TODO Auto-generated method stub
|
hovered = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseLeave() {
|
public void mouseLeave() {
|
||||||
// TODO Auto-generated method stub
|
hovered = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float x, y;
|
private float x, y;
|
||||||
|
|
@ -61,10 +61,10 @@ public class BuildLayer extends GameObject implements IMouseCaptureArea {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDown(int button) {
|
public void mouseDown(int button) {
|
||||||
if(button == 1 && active) {
|
if(button == 1 && active && hovered) {
|
||||||
listener.cancel();
|
listener.cancel();
|
||||||
deactiveate();
|
deactiveate();
|
||||||
} else if(button == 0 && active) {
|
} else if(button == 0 && active && hovered) {
|
||||||
Vector2f worldcoords = camera.screen2world(App.mouseX, App.mouseY);
|
Vector2f worldcoords = camera.screen2world(App.mouseX, App.mouseY);
|
||||||
mouseDown = true;
|
mouseDown = true;
|
||||||
x = worldcoords.x;
|
x = worldcoords.x;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||||
|
|
||||||
import xyz.valnet.engine.graphics.Drawing;
|
import xyz.valnet.engine.graphics.Drawing;
|
||||||
import xyz.valnet.engine.math.Vector4f;
|
import xyz.valnet.engine.math.Vector4f;
|
||||||
|
import xyz.valnet.engine.scenegraph.IMouseCaptureArea;
|
||||||
import xyz.valnet.hadean.gameobjects.BottomBar;
|
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||||
import xyz.valnet.hadean.gameobjects.Camera;
|
import xyz.valnet.hadean.gameobjects.Camera;
|
||||||
import xyz.valnet.hadean.gameobjects.Stockpile;
|
import xyz.valnet.hadean.gameobjects.Stockpile;
|
||||||
|
|
@ -21,7 +22,7 @@ import xyz.valnet.hadean.util.Assets;
|
||||||
import xyz.valnet.hadean.util.Layers;
|
import xyz.valnet.hadean.util.Layers;
|
||||||
import xyz.valnet.hadean.util.SmartBoolean;
|
import xyz.valnet.hadean.util.SmartBoolean;
|
||||||
|
|
||||||
public class BuildTab extends Tab implements ISelectionChangeListener {
|
public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCaptureArea {
|
||||||
|
|
||||||
private Selection selection;
|
private Selection selection;
|
||||||
private BuildLayer buildLayer;
|
private BuildLayer buildLayer;
|
||||||
|
|
@ -124,4 +125,27 @@ public class BuildTab extends Tab implements ISelectionChangeListener {
|
||||||
public String getTabName() {
|
public String getTabName() {
|
||||||
return "Build";
|
return "Build";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEnter() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseLeave() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDown(int button) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseUp(int button) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector4f getBox() {
|
||||||
|
float left = lerp(-width - padding, padding, progress);
|
||||||
|
return new Vector4f((int) left, padding, (int) width, 576 - padding * 2 - BottomBar.bottomBarHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLayer() {
|
||||||
|
return Layers.GENERAL_UI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue