mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 14:45:41 +12:00
Fix words
This commit is contained in:
parent
ed0864d24f
commit
609d3fc196
11 changed files with 45 additions and 57 deletions
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:required="true"
|
android:required="true"
|
||||||
android:glEsVersion="0x0030002"/>
|
android:glEsVersion="0x0030001"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
|
|
|
@ -2,22 +2,21 @@ package com.panda3ds.pandroid.app;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.panda3ds.pandroid.R;
|
import com.panda3ds.pandroid.R;
|
||||||
import com.panda3ds.pandroid.utils.Constants;
|
import com.panda3ds.pandroid.utils.Constants;
|
||||||
import com.panda3ds.pandroid.view.PandaGlSurfaceView;
|
import com.panda3ds.pandroid.view.PandaGlSurfaceView;
|
||||||
import com.panda3ds.pandroid.view.PandaLayoutController;
|
import com.panda3ds.pandroid.view.PandaLayoutController;
|
||||||
|
|
||||||
public class GameActivity extends BaseActivity {
|
public class GameActivity extends BaseActivity {
|
||||||
private PandaGlSurfaceView pandaSurface;
|
|
||||||
private PandaLayoutController controllerLayout;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -31,20 +30,18 @@ public class GameActivity extends BaseActivity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));
|
PandaGlSurfaceView pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));
|
||||||
|
|
||||||
setContentView(R.layout.game_activity);
|
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));
|
.addView(pandaSurface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
|
||||||
controllerLayout = findViewById(R.id.controller_layout);
|
PandaLayoutController controllerLayout = findViewById(R.id.controller_layout);
|
||||||
|
|
||||||
controllerLayout.initialize();
|
controllerLayout.initialize();
|
||||||
|
|
||||||
((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> {
|
((CheckBox) findViewById(R.id.hide_screen_controller)).setOnCheckedChangeListener((buttonView, isChecked) -> findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE));
|
||||||
findViewById(R.id.overlay_controller).setVisibility(isChecked ? View.VISIBLE : View.INVISIBLE);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,15 +2,11 @@ package com.panda3ds.pandroid.math;
|
||||||
|
|
||||||
public class Vector2 {
|
public class Vector2 {
|
||||||
public float x, 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.x = x;
|
||||||
this.y = y;
|
this.y = 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) {
|
public void set(float x, float y) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ public class Constants {
|
||||||
public static final int INPUT_KEY_LEFT = 1 << 5;
|
public static final int INPUT_KEY_LEFT = 1 << 5;
|
||||||
public static final int INPUT_KEY_RIGHT = 1 << 4;
|
public static final int INPUT_KEY_RIGHT = 1 << 4;
|
||||||
|
|
||||||
public static final int INPUT_KEY_A = 1 << 0;
|
public static final int INPUT_KEY_A = 1;
|
||||||
public static final int INPUT_KEY_B = 1 << 1;
|
public static final int INPUT_KEY_B = 1 << 1;
|
||||||
public static final int INPUT_KEY_X = 1 << 10;
|
public static final int INPUT_KEY_X = 1 << 10;
|
||||||
public static final int INPUT_KEY_Y = 1 << 11;
|
public static final int INPUT_KEY_Y = 1 << 11;
|
||||||
|
@ -22,5 +22,5 @@ public class Constants {
|
||||||
public static final int N3DS_FULL_HEIGHT = 480;
|
public static final int N3DS_FULL_HEIGHT = 480;
|
||||||
|
|
||||||
public static final String EXTRA_PATH = "path";
|
public static final String EXTRA_PATH = "path";
|
||||||
public static final String LOG_TAG = "Alber";
|
public static final String LOG_TAG = "pandroid";
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
|
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
|
||||||
Log.i("pandroid", glGetString(GL_EXTENSIONS));
|
Log.i(Constants.LOG_TAG, glGetString(GL_EXTENSIONS));
|
||||||
Log.w("pandroid", glGetString(GL_VERSION));
|
Log.w(Constants.LOG_TAG, glGetString(GL_VERSION));
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package com.panda3ds.pandroid.view;
|
package com.panda3ds.pandroid.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.util.Log;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
import com.panda3ds.pandroid.utils.Constants;
|
|
||||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||||
import com.panda3ds.pandroid.view.controller.nodes.TouchScreenNodeImpl;
|
import com.panda3ds.pandroid.view.controller.nodes.TouchScreenNodeImpl;
|
||||||
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
||||||
|
|
||||||
public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl {
|
public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNodeImpl {
|
||||||
final PandaGlRenderer renderer;
|
final PandaGlRenderer renderer;
|
||||||
private int size_width;
|
private int width;
|
||||||
private int size_height;
|
private int height;
|
||||||
|
|
||||||
public PandaGlSurfaceView(Context context, String romPath) {
|
public PandaGlSurfaceView(Context context, String romPath) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -29,14 +27,14 @@ public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNode
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
size_width = getMeasuredWidth();
|
width = getMeasuredWidth();
|
||||||
size_height = getMeasuredHeight();
|
height = getMeasuredHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getSize() {
|
public Vector2 getSize() {
|
||||||
return new Vector2(size_width, size_height);
|
return new Vector2(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,10 +7,10 @@ import com.panda3ds.pandroid.math.Vector2;
|
||||||
public interface ControllerNode {
|
public interface ControllerNode {
|
||||||
@NonNull
|
@NonNull
|
||||||
default Vector2 getPosition() {
|
default Vector2 getPosition() {
|
||||||
View me = (View) this;
|
View view = (View) this;
|
||||||
|
|
||||||
int[] position = new int[2];
|
int[] position = new int[2];
|
||||||
me.getLocationInWindow(position);
|
view.getLocationInWindow(position);
|
||||||
return new Vector2(position[0], position[1]);
|
return new Vector2(position[0], position[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,18 @@ import android.graphics.Paint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
||||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||||
import com.panda3ds.pandroid.view.controller.listeners.JoystickListener;
|
import com.panda3ds.pandroid.view.controller.listeners.JoystickListener;
|
||||||
|
|
||||||
public class Joystick extends BasicControllerNode implements ControllerNode {
|
public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||||
private float stick_x = 0;
|
private float axisX = 0;
|
||||||
private float stick_y = 0;
|
private float axisY = 0;
|
||||||
|
|
||||||
private int size_width = 0;
|
private int width = 0;
|
||||||
private int size_height = 0;
|
private int height = 0;
|
||||||
|
|
||||||
private JoystickListener joystickListener;
|
private JoystickListener joystickListener;
|
||||||
|
|
||||||
|
@ -42,18 +42,18 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDrawForeground(Canvas canvas) {
|
public void onDrawForeground(Canvas canvas) {
|
||||||
size_width = getWidth();
|
width = getWidth();
|
||||||
size_height = getHeight();
|
height = getHeight();
|
||||||
|
|
||||||
int analogIconSize = size_width - getPaddingLeft();
|
int analogIconSize = width - getPaddingLeft();
|
||||||
|
|
||||||
float middleIconSize = analogIconSize / 2.0F;
|
float middleIconSize = analogIconSize / 2.0F;
|
||||||
float middle = size_width / 2.0F;
|
float middle = width / 2.0F;
|
||||||
|
|
||||||
float maxDistance = (middle - middleIconSize) * 0.9F;
|
float maxDistance = (middle - middleIconSize) * 0.9F;
|
||||||
|
|
||||||
float tx = maxDistance * stick_x;
|
float tx = maxDistance * axisX;
|
||||||
float ty = maxDistance * stick_y;
|
float ty = maxDistance * axisY;
|
||||||
|
|
||||||
float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty));
|
float radius = Vector2.distance(0.0F, 0.0F, Math.abs(tx), Math.abs(ty));
|
||||||
radius = Math.min(maxDistance, radius);
|
radius = Math.min(maxDistance, radius);
|
||||||
|
@ -62,8 +62,8 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||||
float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0));
|
float rx = (float) (radius * Math.cos(Math.PI * 2 * deg / 360.0));
|
||||||
float ry = (float) (radius * Math.sin(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));
|
axisX = Math.max(-1.0f, Math.min(1.0f, axisX));
|
||||||
stick_y = Math.max(-1.0f, Math.min(1.0f, stick_y));
|
axisY = Math.max(-1.0f, Math.min(1.0f, axisY));
|
||||||
|
|
||||||
float x = middle - middleIconSize + rx;
|
float x = middle - middleIconSize + rx;
|
||||||
float y = middle - middleIconSize + ry;
|
float y = middle - middleIconSize + ry;
|
||||||
|
@ -77,19 +77,19 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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, axisX)), Math.max(-1.0F, Math.min(1.0F, axisY))); }
|
||||||
|
|
||||||
public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; }
|
public void setJoystickListener(JoystickListener joystickListener) { this.joystickListener = joystickListener; }
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Vector2 getSize() {
|
public Vector2 getSize() {
|
||||||
return new Vector2(size_width, size_height);
|
return new Vector2(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTouch(TouchEvent event) {
|
public void onTouch(TouchEvent event) {
|
||||||
float middle = size_width / 2.0F;
|
float middle = width / 2.0F;
|
||||||
|
|
||||||
float x = event.getX();
|
float x = event.getX();
|
||||||
float y = event.getY();
|
float y = event.getY();
|
||||||
|
@ -97,17 +97,17 @@ public class Joystick extends BasicControllerNode implements ControllerNode {
|
||||||
x = Math.max(0, Math.min(middle * 2, x));
|
x = Math.max(0, Math.min(middle * 2, x));
|
||||||
y = Math.max(0, Math.min(middle * 2, y));
|
y = Math.max(0, Math.min(middle * 2, y));
|
||||||
|
|
||||||
stick_x = ((x - middle) / middle);
|
axisX = ((x - middle) / middle);
|
||||||
|
|
||||||
stick_y = ((y - middle) / middle);
|
axisY = ((y - middle) / middle);
|
||||||
|
|
||||||
if (event.getAction() == TouchEvent.ACTION_UP) {
|
if (event.getAction() == TouchEvent.ACTION_UP) {
|
||||||
stick_x = 0;
|
axisX = 0;
|
||||||
stick_y = 0;
|
axisY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joystickListener != null) {
|
if (joystickListener != null) {
|
||||||
joystickListener.onJoystickAxisChange(this, stick_x, stick_y);
|
joystickListener.onJoystickAxisChange(this, axisX, axisY);
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
package com.panda3ds.pandroid.view.controller.nodes;
|
package com.panda3ds.pandroid.view.controller.nodes;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.panda3ds.pandroid.AlberDriver;
|
import com.panda3ds.pandroid.AlberDriver;
|
||||||
import com.panda3ds.pandroid.R;
|
import com.panda3ds.pandroid.R;
|
||||||
import com.panda3ds.pandroid.utils.Constants;
|
|
||||||
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
import com.panda3ds.pandroid.view.controller.ControllerNode;
|
||||||
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
import com.panda3ds.pandroid.view.controller.TouchEvent;
|
||||||
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
import com.panda3ds.pandroid.view.renderer.ConsoleRenderer;
|
||||||
|
|
||||||
public interface TouchScreenNodeImpl extends ControllerNode {
|
public interface TouchScreenNodeImpl extends ControllerNode {
|
||||||
default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) {
|
default void onTouchScreenPress(ConsoleRenderer renderer, TouchEvent event) {
|
||||||
View me = (View) this;
|
View view = (View) this;
|
||||||
boolean hasDownEvent = me.getTag(R.id.TagEventHasDown) != null && (boolean) me.getTag(R.id.TagEventHasDown);
|
boolean hasDownEvent = view.getTag(R.id.TagEventHasDown) != null && (boolean) view.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 x = (int) (event.getX() - bounds.left);
|
||||||
|
@ -27,12 +25,12 @@ public interface TouchScreenNodeImpl extends ControllerNode {
|
||||||
|
|
||||||
AlberDriver.TouchScreenDown(x, y);
|
AlberDriver.TouchScreenDown(x, y);
|
||||||
|
|
||||||
me.setTag(R.id.TagEventHasDown, true);
|
view.setTag(R.id.TagEventHasDown, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) {
|
if (hasDownEvent && event.getAction() == TouchEvent.ACTION_UP) {
|
||||||
AlberDriver.TouchScreenUp();
|
AlberDriver.TouchScreenUp();
|
||||||
me.setTag(R.id.TagEventHasDown, false);
|
view.setTag(R.id.TagEventHasDown, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.panda3ds.pandroid.view.renderer.layout;
|
package com.panda3ds.pandroid.view.renderer.layout;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
|
||||||
|
|
||||||
public interface ConsoleLayout {
|
public interface ConsoleLayout {
|
||||||
void update(int screenWidth, int screenHeight);
|
void update(int screenWidth, int screenHeight);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.panda3ds.pandroid.view.renderer.layout;
|
package com.panda3ds.pandroid.view.renderer.layout;
|
||||||
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.Size;
|
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
|
|
||||||
public class DefaultScreenLayout implements ConsoleLayout {
|
public class DefaultScreenLayout implements ConsoleLayout {
|
||||||
|
|
Loading…
Add table
Reference in a new issue