Merge pull request #272 from LoungeKatt/master
A very solid collaborative menu implementation
This commit is contained in:
commit
10b9df33ea
|
@ -311,14 +311,6 @@ public class ConfigureFragment extends Fragment {
|
|||
int count) {
|
||||
}
|
||||
});
|
||||
|
||||
Button debug_button = (Button) getView()
|
||||
.findViewById(R.id.debug_button);
|
||||
debug_button.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
generateErrorLog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void generateErrorLog() {
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.reicast.emulator.R;
|
|||
import com.reicast.emulator.emu.GL2JNIView;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
import com.reicast.emulator.emu.OnScreenMenu;
|
||||
import com.reicast.emulator.emu.VJoy;
|
||||
import com.reicast.emulator.periph.VJoy;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||
public class EditVJoyActivity extends Activity {
|
||||
|
@ -127,7 +127,11 @@ public class EditVJoyActivity extends Activity {
|
|||
if (keyCode == KeyEvent.KEYCODE_MENU
|
||||
|| keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (!popUp.isShowing()) {
|
||||
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
|
||||
} else {
|
||||
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
popUp.update(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.bda.controller.MotionEvent;
|
|||
import com.bda.controller.StateEvent;
|
||||
import com.reicast.emulator.MainActivity;
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.emu.MOGAInput;
|
||||
import com.reicast.emulator.periph.MOGAInput;
|
||||
|
||||
import de.ankri.views.Switch;
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -60,7 +61,10 @@ public class InputModFragment extends Fragment {
|
|||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
parentActivity = getActivity();
|
||||
|
||||
System.gc();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
Runtime.getRuntime().freeMemory();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
|
||||
|
||||
|
@ -387,7 +391,10 @@ public class InputModFragment extends Fragment {
|
|||
}
|
||||
|
||||
private Drawable getButtonImage(int x, int y) {
|
||||
System.gc();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
Runtime.getRuntime().freeMemory();
|
||||
System.gc();
|
||||
}
|
||||
try {
|
||||
InputStream bitmap = parentActivity.getAssets().open("buttons.png");
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
|
@ -395,7 +402,10 @@ public class InputModFragment extends Fragment {
|
|||
Bitmap image = BitmapFactory.decodeStream(bitmap, null, options);
|
||||
bitmap.close();
|
||||
bitmap = null;
|
||||
System.gc();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
Runtime.getRuntime().freeMemory();
|
||||
System.gc();
|
||||
}
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(32, 32);
|
||||
Bitmap resizedBitmap = Bitmap.createBitmap(image, x, y, 64 / sS,
|
||||
|
@ -412,7 +422,10 @@ public class InputModFragment extends Fragment {
|
|||
return getButtonImage(x, y);
|
||||
} else {
|
||||
E.printStackTrace();
|
||||
System.gc();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
Runtime.getRuntime().freeMemory();
|
||||
System.gc();
|
||||
}
|
||||
}
|
||||
}
|
||||
return parentActivity.getResources().getDrawable(R.drawable.input);
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.reicast.emulator.emu;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import tv.ouya.console.api.OuyaController;
|
||||
import android.annotation.TargetApi;
|
||||
|
@ -10,7 +9,6 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -22,17 +20,23 @@ import android.view.KeyEvent;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.Window;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.config.ConfigureFragment;
|
||||
import com.reicast.emulator.emu.OnScreenMenu.MainPopup;
|
||||
import com.reicast.emulator.emu.OnScreenMenu.VmuPopup;
|
||||
import com.reicast.emulator.periph.MOGAInput;
|
||||
import com.reicast.emulator.periph.SipEmulator;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||
public class GL2JNIActivity extends Activity {
|
||||
public GL2JNIView mView;
|
||||
OnScreenMenu menu;
|
||||
PopupWindow popUp;
|
||||
MainPopup popUp;
|
||||
VmuPopup vmuPop;
|
||||
MOGAInput moga = new MOGAInput();
|
||||
private SharedPreferences prefs;
|
||||
static String[] portId = { "_A", "_B", "_C", "_D" };
|
||||
|
@ -58,7 +62,6 @@ public class GL2JNIActivity extends Activity {
|
|||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
ConfigureFragment.getCurrentConfiguration(prefs);
|
||||
menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
|
||||
popUp = menu.createPopup();
|
||||
|
||||
/*
|
||||
* try { //int rID =
|
||||
|
@ -282,9 +285,20 @@ public class GL2JNIActivity extends Activity {
|
|||
JNIdc.setupMic(sip);
|
||||
}
|
||||
|
||||
//setup vmu screen
|
||||
JNIdc.setupVmu(menu.getVmuLcd());
|
||||
|
||||
popUp = menu.new MainPopup(this);
|
||||
vmuPop = menu.new VmuPopup(this);
|
||||
if(prefs.getBoolean("vmu_floating", false)){
|
||||
//kind of a hack - if the user last had the vmu on screen
|
||||
//inverse it and then "toggle"
|
||||
prefs.edit().putBoolean("vmu_floating", false).commit();
|
||||
//can only display a popup after onCreate
|
||||
mView.post(new Runnable() {
|
||||
public void run() {
|
||||
toggleVmu();
|
||||
}
|
||||
});
|
||||
}
|
||||
JNIdc.setupVmu(menu.getVmu());
|
||||
}
|
||||
|
||||
private void runCompatibilityMode() {
|
||||
|
@ -498,6 +512,30 @@ public class GL2JNIActivity extends Activity {
|
|||
popUpDebug.update(LayoutParams.WRAP_CONTENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
public void toggleVmu() {
|
||||
boolean showFloating = !prefs.getBoolean("vmu_floating", false);
|
||||
if(showFloating){
|
||||
if(popUp.isShowing()){
|
||||
popUp.dismiss();
|
||||
}
|
||||
//remove from popup menu
|
||||
LinearLayout parent = (LinearLayout) popUp.getContentView();
|
||||
parent.removeView(menu.getVmu());
|
||||
//add to floating window
|
||||
vmuPop.showVmu();
|
||||
vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 20, 20);
|
||||
vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
}else{
|
||||
vmuPop.dismiss();
|
||||
//remove from floating window
|
||||
LinearLayout parent = (LinearLayout) vmuPop.getContentView();
|
||||
parent.removeView(menu.getVmu());
|
||||
//add back to popup menu
|
||||
popUp.showVmu();
|
||||
}
|
||||
prefs.edit().putBoolean("vmu_floating", showFloating).commit();
|
||||
}
|
||||
|
||||
public void displayConfig(PopupWindow popUpConfig) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
|
@ -567,11 +605,13 @@ public class GL2JNIActivity extends Activity {
|
|||
}
|
||||
|
||||
private boolean showMenu() {
|
||||
if (!popUp.isShowing()) {
|
||||
displayPopUp(popUp);
|
||||
} else {
|
||||
if (popUp != null) {
|
||||
if (!menu.dismissPopUps()) {
|
||||
popUp.dismiss();
|
||||
if (!popUp.isShowing()) {
|
||||
displayPopUp(popUp);
|
||||
} else {
|
||||
popUp.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
|
|||
import android.view.View;
|
||||
|
||||
import com.reicast.emulator.MainActivity;
|
||||
import com.reicast.emulator.periph.VJoy;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -103,7 +104,10 @@ public class GL2JNIView extends GLSurfaceView
|
|||
|
||||
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
|
||||
System.gc();
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
Runtime.getRuntime().freeMemory();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean soundEndabled = prefs.getBoolean("sound_enabled", true);
|
||||
|
@ -182,7 +186,6 @@ public class GL2JNIView extends GLSurfaceView
|
|||
//configAudio(44100,250);
|
||||
|
||||
ethd.start();
|
||||
|
||||
}
|
||||
|
||||
public GLSurfaceView.Renderer getRenderer()
|
||||
|
|
|
@ -32,7 +32,7 @@ public class JNIdc
|
|||
public static native void cable(int cable);
|
||||
public static native void region(int region);
|
||||
public static native void broadcast(int broadcast);
|
||||
public static native void limitfps(int stretch);
|
||||
public static native void limitfps(int limiter);
|
||||
public static native void nobatch(int nobatch);
|
||||
public static native void mipmaps(int mipmaps);
|
||||
public static native void widescreen(int stretch);
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Environment;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
|
@ -19,16 +20,19 @@ import android.widget.PopupWindow;
|
|||
import com.reicast.emulator.MainActivity;
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.config.ConfigureFragment;
|
||||
import com.reicast.emulator.periph.VmuLcd;
|
||||
|
||||
public class OnScreenMenu {
|
||||
|
||||
private GL2JNIActivity mContext;
|
||||
private SharedPreferences prefs;
|
||||
LayoutParams params;
|
||||
private LinearLayout hlay;
|
||||
private LayoutParams params;
|
||||
private int frameskip;
|
||||
private boolean widescreen;
|
||||
private boolean limitframes;
|
||||
private boolean audiodisabled;
|
||||
|
||||
private VmuLcd vmuLcd;
|
||||
|
||||
private Vector<PopupWindow> popups;
|
||||
|
@ -47,245 +51,208 @@ public class OnScreenMenu {
|
|||
widescreen = ConfigureFragment.widescreen;
|
||||
frameskip = ConfigureFragment.frameskip;
|
||||
}
|
||||
}
|
||||
|
||||
public PopupWindow createPopup() {
|
||||
final PopupWindow popUp = new PopupWindow(mContext);
|
||||
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
params = new LayoutParams(p, p);
|
||||
|
||||
LinearLayout hlay = new LinearLayout(mContext);
|
||||
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(popUp);
|
||||
popUp.dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
vmuLcd = new VmuLcd(mContext);
|
||||
hlay.addView(vmuLcd, params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.vmu_swap, new OnClickListener() {
|
||||
vmuLcd.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.vmuSwap();
|
||||
popUp.dismiss();
|
||||
OnScreenMenu.this.mContext.toggleVmu();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.config, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
displayConfigPopup(popUp);
|
||||
popups.remove(popUp);
|
||||
popUp.dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.disk_unknown, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
displayDebugPopup(popUp);
|
||||
popups.remove(popUp);
|
||||
popUp.dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent inte = new Intent(mContext, MainActivity.class);
|
||||
mContext.startActivity(inte);
|
||||
((Activity) mContext).finish();
|
||||
}
|
||||
}), params);
|
||||
|
||||
// layout.addView(hlay,params);
|
||||
popUp.setContentView(hlay);
|
||||
return popUp;
|
||||
});
|
||||
}
|
||||
|
||||
void displayDebugPopup(final PopupWindow popUp) {
|
||||
final PopupWindow popUpDebug = new PopupWindow(mContext);
|
||||
mContext.displayDebug(new DebugPopup(mContext));
|
||||
}
|
||||
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
LayoutParams debugParams = new LayoutParams(p, p);
|
||||
public class DebugPopup extends PopupWindow {
|
||||
|
||||
LinearLayout hlay = new LinearLayout(mContext);
|
||||
public DebugPopup(Context c) {
|
||||
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
LayoutParams debugParams = new LayoutParams(p, p);
|
||||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(popUpDebug);
|
||||
popUpDebug.dismiss();
|
||||
mContext.displayPopUp(popUp);
|
||||
}
|
||||
}), debugParams);
|
||||
LinearLayout hlay = new LinearLayout(mContext);
|
||||
|
||||
hlay.addView(addbut(R.drawable.clear_cache, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(0, 0); // Killing texture cache
|
||||
popUpDebug.dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(1, 3000); // sample_Start(param);
|
||||
popUpDebug.dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
mContext.displayPopUp(OnScreenMenu.this.mContext.popUp);
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(1, 0); // sample_Start(param);
|
||||
popUpDebug.dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
hlay.addView(addbut(R.drawable.clear_cache, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(0, 0); // Killing texture cache
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
hlay.addView(addbut(R.drawable.print_stats, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(0, 2);
|
||||
popUpDebug.dismiss(); // print_stats=true;
|
||||
}
|
||||
}), debugParams);
|
||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(1, 3000); // sample_Start(param);
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(popUpDebug);
|
||||
popUpDebug.dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
hlay.addView(addbut(R.drawable.profiler, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(1, 0); // sample_Start(param);
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
popUpDebug.setContentView(hlay);
|
||||
popups.add(popUpDebug);
|
||||
mContext.displayDebug(popUpDebug);
|
||||
hlay.addView(addbut(R.drawable.print_stats, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.send(0, 2);
|
||||
dismiss(); // print_stats=true;
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
}
|
||||
}), debugParams);
|
||||
|
||||
setContentView(hlay);
|
||||
popups.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
void displayConfigPopup(final PopupWindow popUp) {
|
||||
final PopupWindow popUpConfig = new PopupWindow(mContext);
|
||||
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
LayoutParams configParams = new LayoutParams(p, p);
|
||||
|
||||
LinearLayout hlay = new LinearLayout(mContext);
|
||||
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(popUpConfig);
|
||||
popUpConfig.dismiss();
|
||||
mContext.displayPopUp(popUp);
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
View fullscreen;
|
||||
if (!widescreen) {
|
||||
fullscreen = addbut(R.drawable.widescreen, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(1);
|
||||
popUpConfig.dismiss();
|
||||
widescreen = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fullscreen = addbut(R.drawable.normal_view, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(0);
|
||||
popUpConfig.dismiss();
|
||||
widescreen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(fullscreen, params);
|
||||
|
||||
final ImageButton frames_up = new ImageButton(mContext);
|
||||
final ImageButton frames_down = new ImageButton(mContext);
|
||||
|
||||
frames_up.setImageResource(R.drawable.frames_up);
|
||||
frames_up.setScaleType(ScaleType.FIT_CENTER);
|
||||
frames_up.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
frameskip++;
|
||||
JNIdc.frameskip(frameskip);
|
||||
enableState(frames_up, frames_down);
|
||||
}
|
||||
});
|
||||
|
||||
frames_down.setImageResource(R.drawable.frames_down);
|
||||
frames_down.setScaleType(ScaleType.FIT_CENTER);
|
||||
frames_down.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
frameskip--;
|
||||
JNIdc.frameskip(frameskip);
|
||||
enableState(frames_up, frames_down);
|
||||
}
|
||||
});
|
||||
|
||||
hlay.addView(frames_up, params);
|
||||
hlay.addView(frames_down, params);
|
||||
enableState(frames_up, frames_down);
|
||||
|
||||
View framelimit;
|
||||
if (!limitframes) {
|
||||
framelimit = addbut(R.drawable.frames_limit_on,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.limitfps(1);
|
||||
popUpConfig.dismiss();
|
||||
limitframes = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
framelimit = addbut(R.drawable.frames_limit_off,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.limitfps(0);
|
||||
popUpConfig.dismiss();
|
||||
limitframes = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(framelimit, params);
|
||||
|
||||
if (prefs.getBoolean("sound_enabled", true)) {
|
||||
View audiosetting;
|
||||
if (!audiodisabled) {
|
||||
audiosetting = addbut(R.drawable.mute_sound,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mContext.mView.audioDisable(true);
|
||||
popUpConfig.dismiss();
|
||||
audiodisabled = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
audiosetting = addbut(R.drawable.enable_sound,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mContext.mView.audioDisable(false);
|
||||
popUpConfig.dismiss();
|
||||
audiodisabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(audiosetting, params);
|
||||
}
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(popUpConfig);
|
||||
popUpConfig.dismiss();
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
popUpConfig.setContentView(hlay);
|
||||
popups.add(popUpConfig);
|
||||
mContext.displayConfig(popUpConfig);
|
||||
mContext.displayConfig(new ConfigPopup(mContext));
|
||||
}
|
||||
|
||||
|
||||
public class ConfigPopup extends PopupWindow {
|
||||
|
||||
private View fullscreen;
|
||||
private View framelimit;
|
||||
|
||||
public ConfigPopup(Context c) {
|
||||
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
LayoutParams configParams = new LayoutParams(p, p);
|
||||
|
||||
LinearLayout hlay = new LinearLayout(mContext);
|
||||
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
mContext.displayPopUp(OnScreenMenu.this.mContext.popUp);
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
if (!widescreen) {
|
||||
fullscreen = addbut(R.drawable.widescreen,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(1);
|
||||
dismiss();
|
||||
widescreen = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fullscreen = addbut(R.drawable.normal_view,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(0);
|
||||
dismiss();
|
||||
widescreen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(fullscreen, params);
|
||||
|
||||
final ImageButton frames_up = new ImageButton(mContext);
|
||||
final ImageButton frames_down = new ImageButton(mContext);
|
||||
|
||||
frames_up.setImageResource(R.drawable.frames_up);
|
||||
frames_up.setScaleType(ScaleType.FIT_CENTER);
|
||||
frames_up.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
frameskip++;
|
||||
JNIdc.frameskip(frameskip);
|
||||
enableState(frames_up, frames_down);
|
||||
}
|
||||
});
|
||||
|
||||
frames_down.setImageResource(R.drawable.frames_down);
|
||||
frames_down.setScaleType(ScaleType.FIT_CENTER);
|
||||
frames_down.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
frameskip--;
|
||||
JNIdc.frameskip(frameskip);
|
||||
enableState(frames_up, frames_down);
|
||||
}
|
||||
});
|
||||
|
||||
hlay.addView(frames_up, params);
|
||||
hlay.addView(frames_down, params);
|
||||
enableState(frames_up, frames_down);
|
||||
|
||||
if (!limitframes) {
|
||||
framelimit = addbut(R.drawable.frames_limit_on,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.limitfps(1);
|
||||
dismiss();
|
||||
limitframes = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
framelimit = addbut(R.drawable.frames_limit_off,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.limitfps(0);
|
||||
dismiss();
|
||||
limitframes = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(framelimit, params);
|
||||
|
||||
if (prefs.getBoolean("sound_enabled", true)) {
|
||||
View audiosetting;
|
||||
if (!audiodisabled) {
|
||||
audiosetting = addbut(R.drawable.mute_sound,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mContext.mView.audioDisable(true);
|
||||
dismiss();
|
||||
audiodisabled = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
audiosetting = addbut(R.drawable.enable_sound,
|
||||
new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
mContext.mView.audioDisable(false);
|
||||
dismiss();
|
||||
audiodisabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(audiosetting, params);
|
||||
}
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(this);
|
||||
dismiss();
|
||||
}
|
||||
}), configParams);
|
||||
|
||||
setContentView(hlay);
|
||||
popups.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void enableState(View frames_up, View frames_down) {
|
||||
if (frameskip <= 0) {
|
||||
frames_down.setEnabled(false);
|
||||
|
@ -298,7 +265,7 @@ public class OnScreenMenu {
|
|||
frames_up.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean dismissPopUps() {
|
||||
for (PopupWindow popup : popups) {
|
||||
if (popup.isShowing()) {
|
||||
|
@ -314,6 +281,10 @@ public class OnScreenMenu {
|
|||
return (int) (dps * context.getResources().getDisplayMetrics().density + 0.5f);
|
||||
}
|
||||
|
||||
public VmuLcd getVmu() {
|
||||
return vmuLcd;
|
||||
}
|
||||
|
||||
View addbut(int x, OnClickListener ocl) {
|
||||
ImageButton but = new ImageButton(mContext);
|
||||
|
||||
|
@ -323,8 +294,88 @@ public class OnScreenMenu {
|
|||
|
||||
return but;
|
||||
}
|
||||
|
||||
public VmuLcd getVmuLcd(){
|
||||
return vmuLcd;
|
||||
|
||||
public class VmuPopup extends PopupWindow {
|
||||
LayoutParams vparams;
|
||||
LinearLayout vlay;
|
||||
|
||||
public VmuPopup(Context c) {
|
||||
super(c);
|
||||
int pX = OnScreenMenu.getPixelsFromDp(80, mContext);
|
||||
int pY = OnScreenMenu.getPixelsFromDp(56, mContext);
|
||||
vparams = new LayoutParams(pX, pY);
|
||||
vlay = new LinearLayout(mContext);
|
||||
vlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
setContentView(vlay);
|
||||
}
|
||||
|
||||
public void showVmu() {
|
||||
vmuLcd.configureScale(80);
|
||||
vlay.addView(vmuLcd, vparams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class MainPopup extends PopupWindow {
|
||||
public MainPopup(Context c) {
|
||||
int p = getPixelsFromDp(60, mContext);
|
||||
params = new LayoutParams(p, p);
|
||||
hlay = new LinearLayout(mContext);
|
||||
hlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
||||
int vpX = getPixelsFromDp(60, mContext);
|
||||
int vpY = getPixelsFromDp(42, mContext);
|
||||
LinearLayout.LayoutParams vmuParams = new LinearLayout.LayoutParams(
|
||||
vpX, vpY);
|
||||
vmuParams.weight = 1.0f;
|
||||
vmuParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
vmuParams.rightMargin = 4;
|
||||
hlay.addView(vmuLcd, vmuParams);
|
||||
|
||||
hlay.addView(addbut(R.drawable.up, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
popups.remove(MainPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.vmu_swap, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.vmuSwap();
|
||||
dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.config, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
displayConfigPopup(MainPopup.this);
|
||||
popups.remove(MainPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.disk_unknown, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
displayDebugPopup(MainPopup.this);
|
||||
popups.remove(MainPopup.this);
|
||||
dismiss();
|
||||
}
|
||||
}), params);
|
||||
|
||||
hlay.addView(addbut(R.drawable.close, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
Intent inte = new Intent(mContext, MainActivity.class);
|
||||
mContext.startActivity(inte);
|
||||
((Activity) mContext).finish();
|
||||
}
|
||||
}), params);
|
||||
|
||||
setContentView(hlay);
|
||||
}
|
||||
|
||||
public void showVmu() {
|
||||
vmuLcd.configureScale(60);
|
||||
hlay.addView(vmuLcd, 0, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.reicast.emulator.emu;
|
||||
package com.reicast.emulator.periph;
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -16,6 +16,9 @@ import com.bda.controller.KeyEvent;
|
|||
import com.bda.controller.MotionEvent;
|
||||
import com.bda.controller.StateEvent;
|
||||
import com.reicast.emulator.R;
|
||||
import com.reicast.emulator.emu.GL2JNIActivity;
|
||||
import com.reicast.emulator.emu.GL2JNIView;
|
||||
import com.reicast.emulator.emu.JNIdc;
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.reicast.emulator.emu;
|
||||
package com.reicast.emulator.periph;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.reicast.emulator.emu;
|
||||
package com.reicast.emulator.periph;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
|
@ -1,12 +1,15 @@
|
|||
package com.reicast.emulator.emu;
|
||||
package com.reicast.emulator.periph;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.reicast.emulator.emu.OnScreenMenu;
|
||||
|
||||
public class VmuLcd extends View {
|
||||
|
||||
public final static int w = 48;
|
||||
|
@ -15,14 +18,19 @@ public class VmuLcd extends View {
|
|||
private int[] image = new int[w*h];
|
||||
private Bitmap current = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||
private float scale;
|
||||
private Paint paint;
|
||||
|
||||
public VmuLcd(Context context) {
|
||||
super(context);
|
||||
|
||||
paint = new Paint();
|
||||
scale = (float)OnScreenMenu.getPixelsFromDp(60, getContext()) / w;
|
||||
Log.d("VmuLcd", "scale: "+scale);
|
||||
}
|
||||
|
||||
public void configureScale(int dp) {
|
||||
scale = (float)OnScreenMenu.getPixelsFromDp(dp, getContext()) / w;
|
||||
}
|
||||
|
||||
public void updateBytes(byte[] data){
|
||||
for(int i=0; i<h; i++){
|
||||
for(int j=0; j<w; j++){
|
||||
|
@ -33,10 +41,11 @@ public class VmuLcd extends View {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c){
|
||||
public void onDraw(Canvas c) {
|
||||
current.setPixels(image, 0, w, 0, 0, w, h);
|
||||
c.scale(scale, scale);
|
||||
c.drawBitmap(current, 0, 0, null);
|
||||
paint.setFilterBitmap(true);
|
||||
c.drawBitmap(current, 0, 0, paint);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue