Add a snappable check to fix interference with the hud snap logic
This commit is contained in:
parent
ed0bd8c187
commit
2dab44227a
|
@ -15,6 +15,7 @@ import org.lwjgl.input.Keyboard;
|
|||
*/
|
||||
public class DraggableHudComponent extends HudComponent {
|
||||
|
||||
private boolean snappable;
|
||||
private boolean dragging;
|
||||
private float deltaX;
|
||||
private float deltaY;
|
||||
|
@ -27,6 +28,7 @@ public class DraggableHudComponent extends HudComponent {
|
|||
public DraggableHudComponent(String name) {
|
||||
this.setName(name);
|
||||
this.setVisible(false);
|
||||
this.setSnappable(true);
|
||||
this.setX(Minecraft.getMinecraft().displayWidth / 2.0f);
|
||||
this.setY(Minecraft.getMinecraft().displayHeight / 2.0f);
|
||||
}
|
||||
|
@ -155,7 +157,7 @@ public class DraggableHudComponent extends HudComponent {
|
|||
|
||||
if (button == 0) {
|
||||
if (this.isDragging()) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || !this.isSnappable()) {
|
||||
this.setDragging(false);
|
||||
return;
|
||||
}
|
||||
|
@ -165,7 +167,7 @@ public class DraggableHudComponent extends HudComponent {
|
|||
for (HudComponent component : Seppuku.INSTANCE.getHudManager().getComponentList()) {
|
||||
if (component instanceof DraggableHudComponent) {
|
||||
DraggableHudComponent draggable = (DraggableHudComponent) component;
|
||||
if (draggable != this && this.collidesWith(draggable) && draggable.isVisible()) {
|
||||
if (draggable != this && this.collidesWith(draggable) && draggable.isVisible() && draggable.isSnappable()) {
|
||||
if ((this.getY() + (this.getH() / 2)) < (draggable.getY() + (draggable.getH() / 2))) { // top
|
||||
this.setY(draggable.getY() - this.getH());
|
||||
this.glueSide = GlueSide.TOP;
|
||||
|
@ -226,8 +228,12 @@ public class DraggableHudComponent extends HudComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean collides() {
|
||||
return false;
|
||||
public boolean isSnappable() {
|
||||
return snappable;
|
||||
}
|
||||
|
||||
public void setSnappable(boolean snappable) {
|
||||
this.snappable = snappable;
|
||||
}
|
||||
|
||||
public boolean isDragging() {
|
||||
|
|
|
@ -26,6 +26,7 @@ public final class HubComponent extends DraggableHudComponent {
|
|||
public HubComponent() {
|
||||
super("Hub");
|
||||
this.setVisible(true);
|
||||
this.setSnappable(false);
|
||||
this.setW(100);
|
||||
this.setH(100);
|
||||
this.setX((Minecraft.getMinecraft().displayWidth / 2) - (this.getW() / 2));
|
||||
|
|
|
@ -22,6 +22,8 @@ public final class TutorialComponent extends PopupComponent {
|
|||
"- Both top and bottom parts of a component are able to be glued to.";
|
||||
|
||||
this.setTextData(tutorialData);
|
||||
|
||||
this.setSnappable(false);
|
||||
this.setW(200);
|
||||
this.setH(173);
|
||||
this.setX((Minecraft.getMinecraft().displayWidth / 2) - (this.getW() / 2));
|
||||
|
|
|
@ -29,6 +29,7 @@ public final class ModuleListComponent extends DraggableHudComponent {
|
|||
public ModuleListComponent(Module.ModuleType type) {
|
||||
super(StringUtils.capitalize(type.name().toLowerCase()));
|
||||
this.type = type;
|
||||
this.setSnappable(false);
|
||||
this.setW(100);
|
||||
this.setH(100);
|
||||
this.setX((Minecraft.getMinecraft().displayWidth / 2) - (this.getW() / 2));
|
||||
|
|
Loading…
Reference in New Issue