Center the VMU display, Subclass the "other" popup menus
This commit is contained in:
parent
208aa20c18
commit
3595152cc4
|
@ -8,7 +8,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
|
@ -32,7 +32,7 @@ public class OnScreenMenu {
|
|||
private boolean widescreen;
|
||||
private boolean limitframes;
|
||||
private boolean audiodisabled;
|
||||
|
||||
|
||||
private VmuLcd vmuLcd;
|
||||
|
||||
private Vector<PopupWindow> popups;
|
||||
|
@ -60,186 +60,199 @@ public class OnScreenMenu {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -252,7 +265,7 @@ public class OnScreenMenu {
|
|||
frames_up.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean dismissPopUps() {
|
||||
for (PopupWindow popup : popups) {
|
||||
if (popup.isShowing()) {
|
||||
|
@ -267,8 +280,8 @@ public class OnScreenMenu {
|
|||
public static int getPixelsFromDp(float dps, Context context) {
|
||||
return (int) (dps * context.getResources().getDisplayMetrics().density + 0.5f);
|
||||
}
|
||||
|
||||
public VmuLcd getVmu(){
|
||||
|
||||
public VmuLcd getVmu() {
|
||||
return vmuLcd;
|
||||
}
|
||||
|
||||
|
@ -281,11 +294,12 @@ public class OnScreenMenu {
|
|||
|
||||
return but;
|
||||
}
|
||||
|
||||
public class VmuPopup extends PopupWindow{
|
||||
|
||||
public class VmuPopup extends PopupWindow {
|
||||
LayoutParams vparams;
|
||||
LinearLayout vlay;
|
||||
public VmuPopup(Context c){
|
||||
|
||||
public VmuPopup(Context c) {
|
||||
super(c);
|
||||
int pX = OnScreenMenu.getPixelsFromDp(80, mContext);
|
||||
int pY = OnScreenMenu.getPixelsFromDp(56, mContext);
|
||||
|
@ -294,22 +308,29 @@ public class OnScreenMenu {
|
|||
vlay.setOrientation(LinearLayout.HORIZONTAL);
|
||||
setContentView(vlay);
|
||||
}
|
||||
|
||||
public void showVmu(){
|
||||
|
||||
public void showVmu() {
|
||||
vmuLcd.configureScale(80);
|
||||
vlay.addView(vmuLcd, vparams);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class MainPopup extends PopupWindow{
|
||||
public MainPopup(Context c){
|
||||
|
||||
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);
|
||||
|
||||
hlay.addView(vmuLcd, params);
|
||||
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) {
|
||||
|
@ -351,8 +372,8 @@ public class OnScreenMenu {
|
|||
|
||||
setContentView(hlay);
|
||||
}
|
||||
|
||||
public void showVmu(){
|
||||
|
||||
public void showVmu() {
|
||||
vmuLcd.configureScale(60);
|
||||
hlay.addView(vmuLcd, 0, params);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue