mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Run clang-format on .java files
This commit is contained in:
parent
a40e74a15d
commit
ed0864d24f
24 changed files with 634 additions and 771 deletions
1
src/pandroid/app/.gitignore
vendored
1
src/pandroid/app/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/build
|
|
@ -36,11 +36,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
implementation("com.google.android.material:material:1.8.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
package com.panda3ds.pandroid;
|
||||
|
||||
public class AlberDriver {
|
||||
|
||||
AlberDriver() {
|
||||
super();
|
||||
}
|
||||
AlberDriver() { super(); }
|
||||
|
||||
public static native void Initialize();
|
||||
public static native void RunFrame(int fbo);
|
||||
|
@ -18,7 +15,5 @@ public class AlberDriver {
|
|||
public static native void TouchScreenUp();
|
||||
public static native void TouchScreenDown(int x, int y);
|
||||
|
||||
static {
|
||||
System.loadLibrary("Alber");
|
||||
}
|
||||
static { System.loadLibrary("Alber"); }
|
||||
}
|
|
@ -2,5 +2,4 @@ package com.panda3ds.pandroid.app;
|
|||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
public class BaseActivity extends AppCompatActivity {}
|
||||
|
|
|
@ -9,9 +9,7 @@ import android.view.WindowManager;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.panda3ds.pandroid.R;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
import com.panda3ds.pandroid.view.PandaGlSurfaceView;
|
||||
|
@ -26,8 +24,7 @@ public class GameActivity extends BaseActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if(!intent.hasExtra(Constants.EXTRA_PATH)){
|
||||
|
||||
if (!intent.hasExtra(Constants.EXTRA_PATH)) {
|
||||
setContentView(new FrameLayout(this));
|
||||
Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
|
@ -38,19 +35,16 @@ public class GameActivity extends BaseActivity {
|
|||
|
||||
setContentView(R.layout.game_activity);
|
||||
|
||||
((FrameLayout)findViewById(R.id.panda_gl_frame))
|
||||
((FrameLayout) findViewById(R.id.panda_gl_frame))
|
||||
.addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
||||
controllerLayout = findViewById(R.id.controller_layout);
|
||||
|
||||
controllerLayout.initialize();
|
||||
|
||||
((CheckBox)findViewById(R.id.hide_screen_controller))
|
||||
.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
findViewById(R.id.overlay_controller)
|
||||
.setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
|
||||
((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.panda3ds.pandroid.app;
|
||||
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
import static android.provider.Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION;
|
||||
|
||||
import android.content.Intent;
|
||||
|
@ -7,15 +9,10 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
import com.panda3ds.pandroid.R;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
import com.panda3ds.pandroid.utils.PathUtils;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
|
@ -38,15 +35,13 @@ public class MainActivity extends BaseActivity {
|
|||
startActivity(intent);
|
||||
}
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, new String[]{READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
ActivityCompat.requestPermissions(this, new String[] {READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
ActivityCompat.requestPermissions(this, new String[] {WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
findViewById(R.id.load_rom).setOnClickListener(v->{
|
||||
openFile();
|
||||
});
|
||||
findViewById(R.id.load_rom).setOnClickListener(v -> { openFile(); });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,8 +50,7 @@ public class MainActivity extends BaseActivity {
|
|||
if (resultCode == RESULT_OK) {
|
||||
String path = PathUtils.getPath(getApplicationContext(), data.getData());
|
||||
Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show();
|
||||
startActivity(new Intent(this, GameActivity.class)
|
||||
.putExtra(Constants.EXTRA_PATH, path));
|
||||
startActivity(new Intent(this, GameActivity.class).putExtra(Constants.EXTRA_PATH, path));
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
package com.panda3ds.pandroid.math;
|
||||
|
||||
public class Vector2 {
|
||||
public float x,y;
|
||||
public Vector2(Vector2 value){
|
||||
this(value.x,value.y);
|
||||
}
|
||||
public float x, y;
|
||||
public Vector2(Vector2 value) { this(value.x, value.y); }
|
||||
|
||||
public Vector2(float x, float y){
|
||||
public Vector2(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public float distanceTo(Vector2 vec){
|
||||
return distance(x,y,vec.x, vec.y);
|
||||
}
|
||||
public float distanceTo(Vector2 vec) { return distance(x, y, vec.x, vec.y); }
|
||||
|
||||
public static float distance(float x, float y, float x2, float y2){
|
||||
return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
|
||||
}
|
||||
public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); }
|
||||
|
||||
public void set(float x, float y) {
|
||||
this.x = x;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.panda3ds.pandroid.utils;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final int INPUT_KEY_UP = 1 << 6;
|
||||
public static final int INPUT_KEY_DOWN = 1 << 7;
|
||||
public static final int INPUT_KEY_LEFT = 1 << 5;
|
||||
|
|
|
@ -10,44 +10,37 @@ import android.provider.DocumentsContract;
|
|||
import android.provider.MediaStore;
|
||||
|
||||
public class PathUtils {
|
||||
|
||||
public static String getPath(final Context context, final Uri uri) {
|
||||
|
||||
// DocumentProvider
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) {
|
||||
|
||||
if (isExternalStorageDocument(uri)) {// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri)) { // ExternalStorageProvider
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
String storageDefinition;
|
||||
|
||||
|
||||
if("primary".equalsIgnoreCase(type)){
|
||||
|
||||
if ("primary".equalsIgnoreCase(type)) {
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
|
||||
} else {
|
||||
|
||||
if(Environment.isExternalStorageRemovable()){
|
||||
if (Environment.isExternalStorageRemovable()) {
|
||||
storageDefinition = "EXTERNAL_STORAGE";
|
||||
|
||||
} else{
|
||||
} else {
|
||||
storageDefinition = "SECONDARY_STORAGE";
|
||||
}
|
||||
|
||||
return System.getenv(storageDefinition) + "/" + split[1];
|
||||
}
|
||||
|
||||
} else if (isDownloadsDocument(uri)) {// DownloadsProvider
|
||||
} else if (isDownloadsDocument(uri)) { // DownloadsProvider
|
||||
|
||||
final String id = DocumentsContract.getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(
|
||||
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
|
||||
} else if (isMediaDocument(uri)) {// MediaProvider
|
||||
} else if (isMediaDocument(uri)) { // MediaProvider
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
@ -62,22 +55,19 @@ public class PathUtils {
|
|||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[]{
|
||||
split[1]
|
||||
};
|
||||
final String[] selectionArgs = new String[] {split[1]};
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
|
||||
} else if ("content".equalsIgnoreCase(uri.getScheme())) {// MediaStore (and general)
|
||||
} else if ("content".equalsIgnoreCase(uri.getScheme())) { // MediaStore (and general)
|
||||
|
||||
// Return the remote address
|
||||
if (isGooglePhotosUri(uri))
|
||||
return uri.getLastPathSegment();
|
||||
if (isGooglePhotosUri(uri)) return uri.getLastPathSegment();
|
||||
|
||||
return getDataColumn(context, uri, null, null);
|
||||
|
||||
} else if ("file".equalsIgnoreCase(uri.getScheme())) {// File
|
||||
} else if ("file".equalsIgnoreCase(uri.getScheme())) { // File
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
|
@ -85,12 +75,9 @@ public class PathUtils {
|
|||
}
|
||||
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
|
||||
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = {
|
||||
column
|
||||
};
|
||||
final String[] projection = {column};
|
||||
|
||||
try {
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
|
||||
|
@ -99,27 +86,16 @@ public class PathUtils {
|
|||
return cursor.getString(column_index);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
if (cursor != null) cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isExternalStorageDocument(Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); }
|
||||
|
||||
public static boolean isExternalStorageDocument(Uri uri) {
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
public static boolean isDownloadsDocument(Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); }
|
||||
|
||||
public static boolean isMediaDocument(Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); }
|
||||
|
||||
public static boolean isDownloadsDocument(Uri uri) {
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean isMediaDocument(Uri uri) {
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
public static boolean isGooglePhotosUri(Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); }
|
||||
}
|
|
@ -1,22 +1,20 @@
|
|||
package com.panda3ds.pandroid.view;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import static android.opengl.GLES32.*;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.util.Log;
|
||||
|
||||
import com.panda3ds.pandroid.AlberDriver;
|
||||
import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
||||
import com.panda3ds.pandroid.view.renderer.layout.ConsoleLayout;
|
||||
import com.panda3ds.pandroid.view.renderer.layout.DefaultScreenLayout;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer {
|
||||
|
||||
private final String romPath;
|
||||
private ConsoleLayout displayLayout;
|
||||
private int screenWidth, screenHeight;
|
||||
|
@ -35,10 +33,10 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer
|
|||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
if (screenTexture != 0) {
|
||||
glDeleteTextures(1, new int[]{screenTexture}, 0);
|
||||
glDeleteTextures(1, new int[] {screenTexture}, 0);
|
||||
}
|
||||
if (screenFbo != 0) {
|
||||
glDeleteFramebuffers(1, new int[]{screenFbo}, 0);
|
||||
glDeleteFramebuffers(1, new int[] {screenFbo}, 0);
|
||||
}
|
||||
super.finalize();
|
||||
}
|
||||
|
@ -79,19 +77,15 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer
|
|||
Rect bottomScreen = displayLayout.getBottomDisplayBounds();
|
||||
|
||||
glBlitFramebuffer(
|
||||
0, Constants.N3DS_FULL_HEIGHT,
|
||||
Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT,
|
||||
topScreen.left, screenHeight - topScreen.top,
|
||||
topScreen.right, screenHeight - topScreen.bottom,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
0, Constants.N3DS_FULL_HEIGHT, Constants.N3DS_WIDTH, Constants.N3DS_HALF_HEIGHT, topScreen.left, screenHeight - topScreen.top,
|
||||
topScreen.right, screenHeight - topScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
|
||||
// Remove the black bars on the bottom screen
|
||||
glBlitFramebuffer(
|
||||
40, Constants.N3DS_HALF_HEIGHT,
|
||||
Constants.N3DS_WIDTH - 40, 0,
|
||||
bottomScreen.left, screenHeight - bottomScreen.top,
|
||||
bottomScreen.right, screenHeight - bottomScreen.bottom,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
40, Constants.N3DS_HALF_HEIGHT, Constants.N3DS_WIDTH - 40, 0, bottomScreen.left, screenHeight - bottomScreen.top, bottomScreen.right,
|
||||
screenHeight - bottomScreen.bottom, GL_COLOR_BUFFER_BIT, GL_LINEAR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||
|
@ -26,9 +24,7 @@ public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNode
|
|||
setRenderer(renderer);
|
||||
}
|
||||
|
||||
public ConsoleRenderer getRenderer() {
|
||||
return renderer;
|
||||
}
|
||||
public ConsoleRenderer getRenderer() { return renderer; }
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.panda3ds.pandroid.view;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.panda3ds.pandroid.AlberDriver;
|
||||
import com.panda3ds.pandroid.R;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
|
@ -11,52 +10,39 @@ import com.panda3ds.pandroid.view.controller.nodes.Button;
|
|||
import com.panda3ds.pandroid.view.controller.nodes.Joystick;
|
||||
|
||||
public class PandaLayoutController extends ControllerLayout {
|
||||
public PandaLayoutController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
public PandaLayoutController(Context context) { super(context); }
|
||||
|
||||
public PandaLayoutController(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public PandaLayoutController(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
|
||||
public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
public PandaLayoutController(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void initialize(){
|
||||
int[] keyButtonList = {
|
||||
R.id.button_a, Constants.INPUT_KEY_A,
|
||||
R.id.button_b, Constants.INPUT_KEY_B,
|
||||
R.id.button_y, Constants.INPUT_KEY_Y,
|
||||
R.id.button_x, Constants.INPUT_KEY_X,
|
||||
public void initialize() {
|
||||
int[] keyButtonList = {R.id.button_a, Constants.INPUT_KEY_A, R.id.button_b, Constants.INPUT_KEY_B,
|
||||
R.id.button_y, Constants.INPUT_KEY_Y, R.id.button_x, Constants.INPUT_KEY_X,
|
||||
|
||||
R.id.button_left, Constants.INPUT_KEY_LEFT,
|
||||
R.id.button_right, Constants.INPUT_KEY_RIGHT,
|
||||
R.id.button_up, Constants.INPUT_KEY_UP,
|
||||
R.id.button_down, Constants.INPUT_KEY_DOWN,
|
||||
R.id.button_left, Constants.INPUT_KEY_LEFT, R.id.button_right, Constants.INPUT_KEY_RIGHT,
|
||||
R.id.button_up, Constants.INPUT_KEY_UP, R.id.button_down, Constants.INPUT_KEY_DOWN,
|
||||
|
||||
R.id.button_start, Constants.INPUT_KEY_START,
|
||||
R.id.button_select, Constants.INPUT_KEY_SELECT,
|
||||
R.id.button_start, Constants.INPUT_KEY_START, R.id.button_select, Constants.INPUT_KEY_SELECT,
|
||||
|
||||
R.id.button_l, Constants.INPUT_KEY_L,
|
||||
R.id.button_r, Constants.INPUT_KEY_R
|
||||
};
|
||||
R.id.button_l, Constants.INPUT_KEY_L, R.id.button_r, Constants.INPUT_KEY_R};
|
||||
|
||||
for (int i = 0; i < keyButtonList.length; i+=2){
|
||||
final int keyCode = keyButtonList[i+1];
|
||||
((Button)findViewById(keyButtonList[i])).setStateListener((btn, pressed)->{
|
||||
if (pressed) AlberDriver.KeyDown(keyCode);
|
||||
else AlberDriver.KeyUp(keyCode);
|
||||
for (int i = 0; i < keyButtonList.length; i += 2) {
|
||||
final int keyCode = keyButtonList[i + 1];
|
||||
((Button) findViewById(keyButtonList[i])).setStateListener((btn, pressed) -> {
|
||||
if (pressed)
|
||||
AlberDriver.KeyDown(keyCode);
|
||||
else
|
||||
AlberDriver.KeyUp(keyCode);
|
||||
});
|
||||
}
|
||||
|
||||
((Joystick)findViewById(R.id.left_analog))
|
||||
.setJoystickListener((joystick, axisX, axisY) -> {
|
||||
AlberDriver.SetCirclepadAxis((int)(axisX*0x9C), (int)(axisY*0x9C)*-1);
|
||||
((Joystick) findViewById(R.id.left_analog)).setJoystickListener((joystick, axisX, axisY) -> {
|
||||
AlberDriver.SetCirclepadAxis((int) (axisX * 0x9C), (int) (axisY * 0x9C) * -1);
|
||||
});
|
||||
|
||||
refreshChildren();
|
||||
|
|
|
@ -7,51 +7,42 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ControllerLayout extends RelativeLayout {
|
||||
|
||||
private final HashMap<Integer, ControllerNode> activeTouchEvents = new HashMap<>();
|
||||
private final ArrayList<ControllerNode> controllerNodes = new ArrayList<>();
|
||||
|
||||
public ControllerLayout(Context context) {
|
||||
this(context,null);
|
||||
}
|
||||
public ControllerLayout(Context context) { this(context, null); }
|
||||
|
||||
public ControllerLayout(Context context, AttributeSet attrs) {
|
||||
this(context, attrs,0);
|
||||
}
|
||||
public ControllerLayout(Context context, AttributeSet attrs) { this(context, attrs, 0); }
|
||||
|
||||
public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr,0 );
|
||||
}
|
||||
public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); }
|
||||
|
||||
public ControllerLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public void refreshChildren(){
|
||||
public void refreshChildren() {
|
||||
ArrayList<ControllerNode> nodes = new ArrayList<>();
|
||||
populateNodesArray(this, nodes);
|
||||
|
||||
//Need Reverse: First view is in back and last view is in front for respect android View hierarchy
|
||||
// Need Reverse: First view is in back and last view is in front for respect android View hierarchy
|
||||
Collections.reverse(nodes);
|
||||
|
||||
controllerNodes.clear();
|
||||
controllerNodes.addAll(nodes);
|
||||
}
|
||||
|
||||
private void populateNodesArray(ViewGroup group, ArrayList<ControllerNode> list){
|
||||
for (int i = 0; i < group.getChildCount(); i++){
|
||||
private void populateNodesArray(ViewGroup group, ArrayList<ControllerNode> list) {
|
||||
for (int i = 0; i < group.getChildCount(); i++) {
|
||||
View view = group.getChildAt(i);
|
||||
if(view instanceof ControllerNode){
|
||||
if (view instanceof ControllerNode) {
|
||||
list.add((ControllerNode) view);
|
||||
} else if (view instanceof ViewGroup) {
|
||||
populateNodesArray((ViewGroup) view, list);
|
||||
|
@ -63,20 +54,20 @@ public class ControllerLayout extends RelativeLayout {
|
|||
public boolean onTouchEvent(MotionEvent event) {
|
||||
int index = event.getActionIndex();
|
||||
|
||||
switch (event.getActionMasked()){
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
case MotionEvent.ACTION_POINTER_UP: {
|
||||
int id = event.getPointerId(index);
|
||||
processTouch(true, event.getX(index), event.getY(index), id);
|
||||
}break;
|
||||
} break;
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
||||
int id = event.getPointerId(index);
|
||||
processTouch(false, event.getX(index), event.getY(index), id);
|
||||
}break;
|
||||
} break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
for (int id = 0; id < event.getPointerCount(); id++){
|
||||
for (int id = 0; id < event.getPointerCount(); id++) {
|
||||
processTouch(false, event.getX(id), event.getY(id), id);
|
||||
}
|
||||
break;
|
||||
|
@ -84,27 +75,27 @@ public class ControllerLayout extends RelativeLayout {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void processTouch(boolean up, float x, float y, int index){
|
||||
private void processTouch(boolean up, float x, float y, int index) {
|
||||
int[] globalPosition = new int[2];
|
||||
getLocationInWindow(globalPosition);
|
||||
|
||||
int action = TouchEvent.ACTION_MOVE;
|
||||
|
||||
if ((!activeTouchEvents.containsKey(index))){
|
||||
if (up)return;
|
||||
if ((!activeTouchEvents.containsKey(index))) {
|
||||
if (up) return;
|
||||
ControllerNode node = null;
|
||||
for (ControllerNode item: controllerNodes){
|
||||
for (ControllerNode item : controllerNodes) {
|
||||
Vector2 pos = item.getPosition();
|
||||
Vector2 size= item.getSize();
|
||||
Vector2 size = item.getSize();
|
||||
|
||||
float cx = (pos.x - globalPosition[0]);
|
||||
float cy = (pos.y - globalPosition[1]);
|
||||
if(item.isVisible() && x > cx && x < cx+size.x && y > cy && y < cy+size.y){
|
||||
if (item.isVisible() && x > cx && x < cx + size.x && y > cy && y < cy + size.y) {
|
||||
node = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (node != null){
|
||||
if (node != null) {
|
||||
activeTouchEvents.put(index, node);
|
||||
action = TouchEvent.ACTION_DOWN;
|
||||
} else {
|
||||
|
@ -122,9 +113,9 @@ public class ControllerLayout extends RelativeLayout {
|
|||
x -= pos.x;
|
||||
y -= pos.y;
|
||||
|
||||
node.onTouch(new TouchEvent(x,y,action));
|
||||
node.onTouch(new TouchEvent(x, y, action));
|
||||
|
||||
if(up){
|
||||
if (up) {
|
||||
activeTouchEvents.remove(index);
|
||||
}
|
||||
}
|
||||
|
@ -152,5 +143,4 @@ public class ControllerLayout extends RelativeLayout {
|
|||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
package com.panda3ds.pandroid.view.controller;
|
||||
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
|
||||
public interface ControllerNode {
|
||||
|
||||
@NonNull
|
||||
default Vector2 getPosition(){
|
||||
default Vector2 getPosition() {
|
||||
View me = (View) this;
|
||||
|
||||
int[] position = new int[2];
|
||||
|
@ -18,9 +14,7 @@ public interface ControllerNode {
|
|||
return new Vector2(position[0], position[1]);
|
||||
}
|
||||
|
||||
default boolean isVisible(){
|
||||
return ((View)this).isShown();
|
||||
}
|
||||
default boolean isVisible() { return ((View) this).isShown(); }
|
||||
|
||||
@NonNull Vector2 getSize();
|
||||
|
||||
|
|
|
@ -6,21 +6,15 @@ public class TouchEvent {
|
|||
public static final int ACTION_UP = 2;
|
||||
|
||||
private final int action;
|
||||
private final float x,y;
|
||||
private final float x, y;
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
public float getX() { return x; }
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
public float getY() { return y; }
|
||||
|
||||
public int getAction() {
|
||||
return action;
|
||||
}
|
||||
public int getAction() { return action; }
|
||||
|
||||
public TouchEvent(float x, float y, int action){
|
||||
public TouchEvent(float x, float y, int action) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.action = action;
|
||||
|
|
|
@ -2,23 +2,15 @@ package com.panda3ds.pandroid.view.controller.nodes;
|
|||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
||||
|
||||
public abstract class BasicControllerNode extends AppCompatTextView implements ControllerNode {
|
||||
public BasicControllerNode(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
public BasicControllerNode(@NonNull Context context) { super(context); }
|
||||
|
||||
public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs) { super(context, attrs); }
|
||||
|
||||
public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
public BasicControllerNode(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
}
|
||||
|
|
|
@ -5,11 +5,9 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||
|
@ -17,7 +15,7 @@ import com.panda3ds.pandroid.view.controller.listeners.ButtonStateListener;
|
|||
|
||||
public class Button extends BasicControllerNode {
|
||||
private boolean pressed = false;
|
||||
private int width,height;
|
||||
private int width, height;
|
||||
|
||||
private ButtonStateListener stateListener;
|
||||
|
||||
|
@ -43,30 +41,26 @@ public class Button extends BasicControllerNode {
|
|||
height = getHeight();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
private void init() {
|
||||
setTextAlignment(TEXT_ALIGNMENT_CENTER);
|
||||
setGravity(Gravity.CENTER);
|
||||
}
|
||||
|
||||
public void setStateListener(ButtonStateListener stateListener) {
|
||||
this.stateListener = stateListener;
|
||||
}
|
||||
public void setStateListener(ButtonStateListener stateListener) { this.stateListener = stateListener; }
|
||||
|
||||
public boolean isPressed() {
|
||||
return pressed;
|
||||
}
|
||||
public boolean isPressed() { return pressed; }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vector2 getSize() {
|
||||
return new Vector2(width,height);
|
||||
return new Vector2(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(TouchEvent event) {
|
||||
pressed = event.getAction() != TouchEvent.ACTION_UP;
|
||||
setAlpha(pressed ? 0.2F : 1.0F);
|
||||
if (stateListener != null){
|
||||
if (stateListener != null) {
|
||||
stateListener.onButtonPressedChange(this, pressed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,32 +6,25 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||
import com.panda3ds.pandroid.view.controller.listeners.JoystickListener;
|
||||
|
||||
|
||||
public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||
private float stick_x = 0;
|
||||
private float stick_y = 0;
|
||||
|
||||
private int size_width = 0;
|
||||
private int size_height= 0;
|
||||
private int size_height = 0;
|
||||
|
||||
private JoystickListener joystickListener;
|
||||
|
||||
public Joystick(Context context) {
|
||||
this(context,null);
|
||||
}
|
||||
public Joystick(Context context) { this(context, null); }
|
||||
|
||||
public Joystick(Context context, AttributeSet attrs) {
|
||||
this(context, attrs,0);
|
||||
}
|
||||
public Joystick(Context context, AttributeSet attrs) { this(context, attrs, 0); }
|
||||
|
||||
public Joystick(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
@ -52,7 +45,7 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
|||
size_width = getWidth();
|
||||
size_height = getHeight();
|
||||
|
||||
int analogIconSize = size_width-getPaddingLeft();
|
||||
int analogIconSize = size_width - getPaddingLeft();
|
||||
|
||||
float middleIconSize = analogIconSize / 2.0F;
|
||||
float middle = size_width / 2.0F;
|
||||
|
@ -65,65 +58,55 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
|||
float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty));
|
||||
radius = Math.min(maxDistance, radius);
|
||||
|
||||
double deg = Math.atan2(ty,tx) * (180.0/Math.PI);
|
||||
float rx = (float) (radius*Math.cos(Math.PI * 2 * deg/360.0));
|
||||
float ry = (float) (radius*Math.sin(Math.PI * 2 * deg/360.0));
|
||||
double deg = Math.atan2(ty, tx) * (180.0 / Math.PI);
|
||||
float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0));
|
||||
float ry = (float) (radius * Math.sin(Math.PI * 2 * deg / 360.0));
|
||||
|
||||
stick_x = Math.max(-1.0f, Math.min(1.0f, stick_x));
|
||||
stick_y = Math.max(-1.0f, Math.min(1.0f, stick_y));
|
||||
|
||||
|
||||
float x = middle-middleIconSize+rx;
|
||||
float y = middle-middleIconSize+ry;
|
||||
|
||||
float x = middle - middleIconSize + rx;
|
||||
float y = middle - middleIconSize + ry;
|
||||
|
||||
Drawable foreground = getForeground();
|
||||
if (foreground != null){
|
||||
foreground.setBounds((int) x, (int) y, (int) (x+analogIconSize), (int) (y+analogIconSize));
|
||||
if (foreground != null) {
|
||||
foreground.setBounds((int) x, (int) y, (int) (x + analogIconSize), (int) (y + analogIconSize));
|
||||
foreground.draw(canvas);
|
||||
} else {
|
||||
canvas.drawOval(x, y, x+analogIconSize,y+analogIconSize,paint);
|
||||
canvas.drawOval(x, y, x + analogIconSize, y + analogIconSize, paint);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 getAxis() {
|
||||
return new Vector2(
|
||||
Math.max(-1.0F, Math.min(1.0F, stick_x)),
|
||||
Math.max(-1.0F, Math.min(1.0F, stick_y))
|
||||
);
|
||||
}
|
||||
public Vector2 getAxis() { return new Vector2(Math.max(-1.0F, Math.min(1.0F, stick_x)), Math.max(-1.0F, Math.min(1.0F, stick_y))); }
|
||||
|
||||
public void setJoystickListener(JoystickListener joystickListener) {
|
||||
this.joystickListener = joystickListener;
|
||||
}
|
||||
public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; }
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Vector2 getSize() {
|
||||
return new Vector2(size_width,size_height);
|
||||
return new Vector2(size_width, size_height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch(TouchEvent event) {
|
||||
|
||||
float middle = size_width/2.0F;
|
||||
float middle = size_width / 2.0F;
|
||||
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
x = Math.max(0, Math.min(middle*2, x));
|
||||
y = Math.max(0, Math.min(middle*2, y));
|
||||
x = Math.max(0, Math.min(middle * 2, x));
|
||||
y = Math.max(0, Math.min(middle * 2, y));
|
||||
|
||||
stick_x = ((x-middle)/middle);
|
||||
stick_x = ((x - middle) / middle);
|
||||
|
||||
stick_y = ((y-middle)/middle);
|
||||
stick_y = ((y - middle) / middle);
|
||||
|
||||
if (event.getAction() == TouchEvent.ACTION_UP){
|
||||
if (event.getAction() == TouchEvent.ACTION_UP) {
|
||||
stick_x = 0;
|
||||
stick_y = 0;
|
||||
}
|
||||
|
||||
if (joystickListener != null){
|
||||
if (joystickListener != null) {
|
||||
joystickListener.onJoystickAxisChange(this, stick_x, stick_y);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.panda3ds.pandroid.view.controller.nodes;
|
|||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.panda3ds.pandroid.AlberDriver;
|
||||
import com.panda3ds.pandroid.R;
|
||||
import com.panda3ds.pandroid.utils.Constants;
|
||||
|
@ -12,26 +11,26 @@ import com.panda3ds.pandroid.view.controller.TouchEvent;
|
|||
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
||||
|
||||
public interface TouchScreenNodeImpl extends ControllerNode {
|
||||
default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event){
|
||||
|
||||
default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) {
|
||||
View me = (View) this;
|
||||
boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown);
|
||||
|
||||
Rect bounds = renderer.getLayout().getBottomDisplayBounds();;
|
||||
Rect bounds = renderer.getLayout().getBottomDisplayBounds();
|
||||
;
|
||||
|
||||
if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom){
|
||||
if (event.getX() >= bounds.left && event.getY() >= bounds.top && event.getX() <= bounds.right && event.getY() <= bounds.bottom) {
|
||||
int x = (int) (event.getX() - bounds.left);
|
||||
int y = (int) (event.getY() - bounds.top);
|
||||
|
||||
x = Math.round((x/(float)bounds.width())*320);
|
||||
y = Math.round((y/(float)bounds.height())*240);
|
||||
x = Math.round((x / (float) bounds.width()) * 320);
|
||||
y = Math.round((y / (float) bounds.height()) * 240);
|
||||
|
||||
AlberDriver.TouchScreenDown(x,y);
|
||||
AlberDriver.TouchScreenDown(x, y);
|
||||
|
||||
me.setTag(R.id.TagEventHasDown, true);
|
||||
}
|
||||
|
||||
if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP){
|
||||
if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) {
|
||||
AlberDriver.TouchScreenUp();
|
||||
me.setTag(R.id.TagEventHasDown, false);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.panda3ds.pandroid.view.renderer.layout;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
|
||||
public interface ConsoleLayout {
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.panda3ds.pandroid.view.renderer.layout;
|
|||
|
||||
import android.graphics.Rect;
|
||||
import android.util.Size;
|
||||
|
||||
import com.panda3ds.pandroid.math.Vector2;
|
||||
|
||||
public class DefaultScreenLayout implements ConsoleLayout {
|
||||
|
@ -21,54 +20,51 @@ public class DefaultScreenLayout implements ConsoleLayout {
|
|||
|
||||
@Override
|
||||
public void setBottomDisplaySourceSize(int width, int height) {
|
||||
bottomSourceSize.set(width,height);
|
||||
bottomSourceSize.set(width, height);
|
||||
updateBounds();
|
||||
}
|
||||
@Override
|
||||
public void setTopDisplaySourceSize(int width, int height) {
|
||||
topSourceSize.set(width,height);
|
||||
topSourceSize.set(width, height);
|
||||
updateBounds();
|
||||
}
|
||||
|
||||
private void updateBounds(){
|
||||
private void updateBounds() {
|
||||
int screenWidth = (int) screenSize.x;
|
||||
int screenHeight = (int) screenSize.y;
|
||||
|
||||
if (screenWidth > screenHeight){
|
||||
|
||||
if (screenWidth > screenHeight) {
|
||||
int topDisplayWidth = (int) ((screenHeight / topSourceSize.y) * topSourceSize.x);
|
||||
int topDisplayHeight = screenHeight;
|
||||
|
||||
if (topDisplayWidth > (screenWidth*0.7)){
|
||||
if (topDisplayWidth > (screenWidth * 0.7)) {
|
||||
topDisplayWidth = (int) (screenWidth * 0.7);
|
||||
topDisplayHeight = (int) ((topDisplayWidth/topSourceSize.x)* topSourceSize.y);
|
||||
topDisplayHeight = (int) ((topDisplayWidth / topSourceSize.x) * topSourceSize.y);
|
||||
}
|
||||
|
||||
int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/ bottomSourceSize.x)* bottomSourceSize.y);
|
||||
|
||||
int bottomDisplayHeight = (int) (((screenWidth - topDisplayWidth) / bottomSourceSize.x) * bottomSourceSize.y);
|
||||
|
||||
topDisplay.set(0, 0, topDisplayWidth, topDisplayHeight);
|
||||
bottomDisplay.set(topDisplayWidth, 0, topDisplayWidth+(screenWidth-topDisplayWidth), bottomDisplayHeight);
|
||||
bottomDisplay.set(topDisplayWidth, 0, topDisplayWidth + (screenWidth - topDisplayWidth), bottomDisplayHeight);
|
||||
} else {
|
||||
int topScreenHeight = (int) ((screenWidth/ topSourceSize.x) * topSourceSize.y);
|
||||
topDisplay.set(0,0,screenWidth,topScreenHeight);
|
||||
int topScreenHeight = (int) ((screenWidth / topSourceSize.x) * topSourceSize.y);
|
||||
topDisplay.set(0, 0, screenWidth, topScreenHeight);
|
||||
|
||||
int bottomDisplayHeight = (int)((screenWidth/ bottomSourceSize.x) * bottomSourceSize.y);
|
||||
int bottomDisplayHeight = (int) ((screenWidth / bottomSourceSize.x) * bottomSourceSize.y);
|
||||
int bottomDisplayWidth = screenWidth;
|
||||
int bottomDisplayX = 0;
|
||||
|
||||
if (topScreenHeight + bottomDisplayHeight > screenHeight){
|
||||
bottomDisplayHeight = (screenHeight-topScreenHeight);
|
||||
bottomDisplayWidth = (int) ((bottomDisplayHeight/ bottomSourceSize.y)*bottomSourceSize.x);
|
||||
bottomDisplayX = (screenWidth-bottomDisplayX)/2;
|
||||
if (topScreenHeight + bottomDisplayHeight > screenHeight) {
|
||||
bottomDisplayHeight = (screenHeight - topScreenHeight);
|
||||
bottomDisplayWidth = (int) ((bottomDisplayHeight / bottomSourceSize.y) * bottomSourceSize.x);
|
||||
bottomDisplayX = (screenWidth - bottomDisplayX) / 2;
|
||||
}
|
||||
|
||||
topDisplay.set(0,0, screenWidth,topScreenHeight);
|
||||
bottomDisplay.set(bottomDisplayX, topScreenHeight, bottomDisplayX+bottomDisplayWidth,topScreenHeight+bottomDisplayHeight);
|
||||
topDisplay.set(0, 0, screenWidth, topScreenHeight);
|
||||
bottomDisplay.set(bottomDisplayX, topScreenHeight, bottomDisplayX + bottomDisplayWidth, topScreenHeight + bottomDisplayHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Rect getBottomDisplayBounds() {
|
||||
return bottomDisplay;
|
||||
|
|
Loading…
Add table
Reference in a new issue