mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-19 01:27:18 -04:00
Roll back ControlInterface.canSnap
This commit is contained in:
parent
8e669caa2e
commit
a7809df1a5
@ -128,6 +128,7 @@ public class ControlDrawer extends ControlButton {
|
|||||||
setVisibility(isVisible ? VISIBLE : GONE);
|
setVisibility(isVisible ? VISIBLE : GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if(!getControlLayoutParent().getModifiable()){
|
if(!getControlLayoutParent().getModifiable()){
|
||||||
@ -163,9 +164,9 @@ public class ControlDrawer extends ControlButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean cantSnap(ControlInterface button) {
|
public boolean canSnap(ControlInterface button) {
|
||||||
boolean result = !super.cantSnap(button);
|
boolean result = super.canSnap(button);
|
||||||
return !result || containsChild(button);
|
return result && !containsChild(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
|
@ -184,17 +184,18 @@ public interface ControlInterface extends View.OnLongClickListener {
|
|||||||
* @param button The button to check
|
* @param button The button to check
|
||||||
* @return whether or not the button
|
* @return whether or not the button
|
||||||
*/
|
*/
|
||||||
default boolean cantSnap(ControlInterface button){
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
|
default boolean canSnap(ControlInterface button){
|
||||||
float MIN_DISTANCE = Tools.dpToPx(8);
|
float MIN_DISTANCE = Tools.dpToPx(8);
|
||||||
|
|
||||||
if(button == this) return true;
|
if(button == this) return false;
|
||||||
return net.kdt.pojavlaunch.utils.MathUtils.dist(
|
return !(net.kdt.pojavlaunch.utils.MathUtils.dist(
|
||||||
button.getControlView().getX() + button.getControlView().getWidth() / 2f,
|
button.getControlView().getX() + button.getControlView().getWidth() / 2f,
|
||||||
button.getControlView().getY() + button.getControlView().getHeight() / 2f,
|
button.getControlView().getY() + button.getControlView().getHeight() / 2f,
|
||||||
getControlView().getX() + getControlView().getWidth() / 2f,
|
getControlView().getX() + getControlView().getWidth() / 2f,
|
||||||
getControlView().getY() + getControlView().getHeight() / 2f)
|
getControlView().getY() + getControlView().getHeight() / 2f)
|
||||||
> Math.max(button.getControlView().getWidth() / 2f + getControlView().getWidth() / 2f,
|
> Math.max(button.getControlView().getWidth() / 2f + getControlView().getWidth() / 2f,
|
||||||
button.getControlView().getHeight() / 2f + getControlView().getHeight() / 2f) + MIN_DISTANCE;
|
button.getControlView().getHeight() / 2f + getControlView().getHeight() / 2f) + MIN_DISTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -217,7 +218,7 @@ public interface ControlInterface extends View.OnLongClickListener {
|
|||||||
|
|
||||||
for(ControlInterface button : ((ControlLayout) getControlView().getParent()).getButtonChildren()){
|
for(ControlInterface button : ((ControlLayout) getControlView().getParent()).getButtonChildren()){
|
||||||
//Step 1: Filter unwanted buttons
|
//Step 1: Filter unwanted buttons
|
||||||
if(cantSnap(button)) continue;
|
if(!canSnap(button)) continue;
|
||||||
|
|
||||||
//Step 2: Get Coordinates
|
//Step 2: Get Coordinates
|
||||||
float button_top = button.getControlView().getY();
|
float button_top = button.getControlView().getY();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user