W.I.P dynamic pointer size according to GUI scale

This commit is contained in:
SerpentSpirale 2021-07-19 09:11:51 +02:00
parent a4b37a7929
commit 047a9f6043
5 changed files with 11 additions and 3 deletions

View file

@ -934,6 +934,8 @@ public class BaseMainActivity extends LoggableActivity {
if(scale < this.guiScale || guiScale == 0){
this.guiScale = scale;
}
if(gamepad != null) gamepad.notifyGUISizeChange(this.guiScale);
}
public int handleGuiBar(int x, int y) {

View file

@ -276,6 +276,12 @@ public class Gamepad {
getCurrentMap().TRIGGER_RIGHT.update(event.getAxisValue(MotionEvent.AXIS_RTRIGGER) > 0.5);
}
public void notifyGUISizeChange(int newSize){
//Change the pointer size to match UI
int size = (int) ((22 * newSize) / gameActivity.scaleFactor);
gameActivity.runOnUiThread(() -> pointerView.setLayoutParams(new FrameLayout.LayoutParams(size, size)));
}
private GamepadMap getCurrentMap(){
return currentMap;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

View file

@ -41,9 +41,9 @@
<ImageView
android:id="@+id/console_pointer"
android:visibility="invisible"
android:layout_width="64px"
android:layout_height="64px"
android:visibility="visible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/pointer" />
</net.kdt.pojavlaunch.customcontrols.ControlLayout>