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

View File

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

View File

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