mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 08:35:37 -04:00
Add installer scaler up/down button.
This commit is contained in:
parent
6acf0dec02
commit
3d5f37aa0d
@ -37,10 +37,19 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the scale to better fit the screen */
|
/** Computes the scale to better fit the screen */
|
||||||
int[] initScaleFactors(){
|
void initScaleFactors(){
|
||||||
|
initScaleFactors(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initScaleFactors(int forcedScale){
|
||||||
//Could be optimized
|
//Could be optimized
|
||||||
|
if(forcedScale < 1) { //Auto scale
|
||||||
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
|
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
|
||||||
mScaleFactor = (3*minDimension)/1080;
|
mScaleFactor = Math.max(((3 * minDimension) / 1080) - 1, 1);
|
||||||
|
}else{
|
||||||
|
mScaleFactor = forcedScale;
|
||||||
|
}
|
||||||
|
|
||||||
int[] scales = new int[2]; //Left, Top
|
int[] scales = new int[2]; //Left, Top
|
||||||
|
|
||||||
scales[0] = (CallbackBridge.physicalWidth/2);
|
scales[0] = (CallbackBridge.physicalWidth/2);
|
||||||
@ -49,7 +58,7 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||||||
scales[1] = (CallbackBridge.physicalHeight/2);
|
scales[1] = (CallbackBridge.physicalHeight/2);
|
||||||
scales[1] -= scales[1]/mScaleFactor;
|
scales[1] -= scales[1]/mScaleFactor;
|
||||||
|
|
||||||
return scales;
|
mScales = scales;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AWTCanvasView(Context ctx) {
|
public AWTCanvasView(Context ctx) {
|
||||||
@ -65,7 +74,7 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
|
|||||||
fpsPaint.setTextSize(20);
|
fpsPaint.setTextSize(20);
|
||||||
|
|
||||||
setSurfaceTextureListener(this);
|
setSurfaceTextureListener(this);
|
||||||
mScales = initScaleFactors();
|
initScaleFactors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,9 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
private boolean isLogAllow, mSkipDetectMod;
|
private boolean isLogAllow, mSkipDetectMod;
|
||||||
|
|
||||||
private boolean rightOverride = false;
|
private boolean rightOverride = false;
|
||||||
private int[] scaleFactor = initScaleFactors();
|
private int scaleFactor;
|
||||||
|
private int[] scaleFactors = initScaleFactors();
|
||||||
|
|
||||||
private final int fingerStillThreshold = 8;
|
private final int fingerStillThreshold = 8;
|
||||||
private int initialX;
|
private int initialX;
|
||||||
private int initialY;
|
private int initialY;
|
||||||
@ -254,8 +256,8 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendScaledMousePosition(float x, float y){
|
void sendScaledMousePosition(float x, float y){
|
||||||
AWTInputBridge.sendMousePos((int) map(x,0,CallbackBridge.physicalWidth,scaleFactor[0],scaleFactor[2]),
|
AWTInputBridge.sendMousePos((int) map(x,0,CallbackBridge.physicalWidth, scaleFactors[0], scaleFactors[2]),
|
||||||
(int) map(y,0,CallbackBridge.physicalHeight,scaleFactor[1],scaleFactor[3]));
|
(int) map(y,0,CallbackBridge.physicalHeight, scaleFactors[1], scaleFactors[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceClose(View v) {
|
public void forceClose(View v) {
|
||||||
@ -330,9 +332,17 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
}
|
}
|
||||||
|
|
||||||
int[] initScaleFactors(){
|
int[] initScaleFactors(){
|
||||||
|
return initScaleFactors(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] initScaleFactors(boolean autoScale){
|
||||||
//Could be optimized
|
//Could be optimized
|
||||||
|
|
||||||
|
if(autoScale) { //Auto scale
|
||||||
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
|
int minDimension = Math.min(CallbackBridge.physicalHeight, CallbackBridge.physicalWidth);
|
||||||
int scaleFactor = (3*minDimension)/1080;
|
scaleFactor = Math.max(((3 * minDimension) / 1080) - 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
int[] scales = new int[4]; //Left, Top, Right, Bottom
|
int[] scales = new int[4]; //Left, Top, Right, Bottom
|
||||||
|
|
||||||
scales[0] = (CallbackBridge.physicalWidth/2);
|
scales[0] = (CallbackBridge.physicalWidth/2);
|
||||||
@ -350,4 +360,17 @@ public class JavaGUILauncherActivity extends LoggableActivity implements View.On
|
|||||||
return scales;
|
return scales;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void scaleDown(View view) {
|
||||||
|
scaleFactor = Math.max(scaleFactor - 1, 1);
|
||||||
|
scaleFactors = initScaleFactors(false);
|
||||||
|
mTextureView.initScaleFactors(scaleFactor);
|
||||||
|
sendScaledMousePosition(mousePointer.getX(),mousePointer.getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scaleUp(View view) {
|
||||||
|
scaleFactor = Math.min(scaleFactor + 1, 6);
|
||||||
|
scaleFactors = initScaleFactors(false);
|
||||||
|
mTextureView.initScaleFactors(scaleFactor);
|
||||||
|
sendScaledMousePosition(mousePointer.getX(),mousePointer.getY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,24 @@
|
|||||||
android:onClick="openLogOutput"
|
android:onClick="openLogOutput"
|
||||||
android:layout_toLeftOf="@id/installmod_btn2"/>
|
android:layout_toLeftOf="@id/installmod_btn2"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/installmod_scale_down"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:background="@drawable/control_button"
|
||||||
|
android:onClick="scaleDown"
|
||||||
|
android:text="@string/control_scaledown" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/installmod_scale_up"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toEndOf="@+id/installmod_scale_down"
|
||||||
|
android:background="@drawable/control_button"
|
||||||
|
android:onClick="scaleUp"
|
||||||
|
android:text="@string/control_scaleup" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -170,6 +170,8 @@
|
|||||||
<string name="control_viewout">Log output</string>
|
<string name="control_viewout">Log output</string>
|
||||||
<string name="control_adebug">Input Debug</string>
|
<string name="control_adebug">Input Debug</string>
|
||||||
<string name="control_customkey">Send custom keycode</string>
|
<string name="control_customkey">Send custom keycode</string>
|
||||||
|
<string name="control_scaleup">Scale up</string>
|
||||||
|
<string name="control_scaledown">Scale down</string>
|
||||||
<!--
|
<!--
|
||||||
<string name="control_more3"></string>
|
<string name="control_more3"></string>
|
||||||
<string name="control_more4"></string>
|
<string name="control_more4"></string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user