Free placement subButton support

This commit is contained in:
SerpentSpirale 2021-09-06 16:57:51 +02:00 committed by SerpentSpirale
parent 2501883ca8
commit 29b7aeb999
3 changed files with 17 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import static net.kdt.pojavlaunch.customcontrols.ControlDrawerData.Orientation.D
import static net.kdt.pojavlaunch.customcontrols.ControlDrawerData.Orientation.LEFT;
import static net.kdt.pojavlaunch.customcontrols.ControlDrawerData.Orientation.RIGHT;
import static net.kdt.pojavlaunch.customcontrols.ControlDrawerData.Orientation.UP;
import static net.kdt.pojavlaunch.customcontrols.ControlDrawerData.Orientation.FREE;
import androidx.annotation.NonNull;
@ -21,37 +22,32 @@ public class ControlDrawerData {
DOWN,
LEFT,
UP,
RIGHT
RIGHT,
FREE
}
public static Orientation[] getOrientations(){
return new Orientation[]{DOWN,LEFT,UP,RIGHT};
return new Orientation[]{DOWN,LEFT,UP,RIGHT,FREE};
}
public static int orientationToInt(Orientation orientation){
switch (orientation){
case DOWN:
return 0;
case LEFT:
return 1;
case UP:
return 2;
case RIGHT:
return 3;
case DOWN: return 0;
case LEFT: return 1;
case UP: return 2;
case RIGHT: return 3;
case FREE: return 4;
}
return -1;
}
public static Orientation intToOrientation(int by){
switch (by){
case 0:
return Orientation.DOWN;
case 1:
return Orientation.LEFT;
case 2:
return Orientation.UP;
case 3:
return RIGHT;
case 0: return DOWN;
case 1: return LEFT;
case 2: return UP;
case 3: return RIGHT;
case 4: return FREE;
}
return null;
}

View File

@ -59,6 +59,7 @@ public class ControlDrawer extends ControlButton {
private void alignButtons(){
if(buttons == null) return;
if(drawerData.orientation == ControlDrawerData.Orientation.FREE) return;
for(int i=0; i < buttons.size(); ++i){
switch (drawerData.orientation){
case RIGHT:

View File

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import net.kdt.pojavlaunch.SingleTapConfirm;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
public class ControlSubButton extends ControlButton {
@ -50,7 +51,7 @@ public class ControlSubButton extends ControlButton {
@Override
public boolean onTouchEvent(MotionEvent event) {
if(!mModifiable){
if(!mModifiable || parentDrawer.drawerData.orientation == ControlDrawerData.Orientation.FREE){
return super.onTouchEvent(event);
}