mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
(Android) set opacity overlay
This commit is contained in:
parent
f5f712f050
commit
7967086058
21
android/phoenix/res/layout/seek_dialog.xml
Normal file
21
android/phoenix/res/layout/seek_dialog.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/seekbar_dialog"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekbar_bar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:max="100" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/seekbar_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -188,6 +188,10 @@
|
|||||||
android:targetClass="org.retroarch.browser.OverlayActivity"
|
android:targetClass="org.retroarch.browser.OverlayActivity"
|
||||||
android:targetPackage="org.retroarch" />
|
android:targetPackage="org.retroarch" />
|
||||||
</Preference>
|
</Preference>
|
||||||
|
<org.retroarch.browser.SeekbarPreference
|
||||||
|
android:summary="Set the opacity of the touch overlay."
|
||||||
|
android:title="Overlay opacity"
|
||||||
|
android:key="input_overlay_opacity" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="Custom Binds">
|
<PreferenceCategory android:title="Custom Binds">
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
|
@ -342,6 +342,7 @@ public class RetroArch extends Activity implements
|
|||||||
if (useOverlay) {
|
if (useOverlay) {
|
||||||
String overlayPath = prefs.getString("input_overlay", getCacheDir() + "/Overlays/snes-landscape.cfg");
|
String overlayPath = prefs.getString("input_overlay", getCacheDir() + "/Overlays/snes-landscape.cfg");
|
||||||
config.setString("input_overlay", overlayPath);
|
config.setString("input_overlay", overlayPath);
|
||||||
|
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
||||||
} else {
|
} else {
|
||||||
config.setString("input_overlay", "");
|
config.setString("input_overlay", "");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.retroarch.browser;
|
||||||
|
|
||||||
|
import org.retroarch.R;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.preference.DialogPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class SeekbarPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
float seek_value;
|
||||||
|
SeekBar bar;
|
||||||
|
TextView text;
|
||||||
|
public SeekbarPreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View onCreateDialogView()
|
||||||
|
{
|
||||||
|
LayoutInflater inflater = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE));
|
||||||
|
View view = inflater.inflate(R.layout.seek_dialog, null);
|
||||||
|
bar = (SeekBar) view.findViewById(R.id.seekbar_bar);
|
||||||
|
text = (TextView) view.findViewById(R.id.seekbar_text);
|
||||||
|
seek_value = getPersistedFloat(1.0f);
|
||||||
|
int prog = (int) (seek_value * 100);
|
||||||
|
bar.setProgress(prog);
|
||||||
|
text.setText(String.valueOf(prog) + "%");
|
||||||
|
bar.setOnSeekBarChangeListener(this);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDialogClosed(boolean positiveResult) {
|
||||||
|
super.onDialogClosed(positiveResult);
|
||||||
|
|
||||||
|
if (positiveResult) {
|
||||||
|
persistFloat(seek_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
seek_value = (float) progress / 100.0f;
|
||||||
|
text.setText(String.valueOf((int)(seek_value * 100)) + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
}
|
@ -240,6 +240,7 @@ struct settings
|
|||||||
unsigned turbo_duty_cycle;
|
unsigned turbo_duty_cycle;
|
||||||
|
|
||||||
char overlay[PATH_MAX];
|
char overlay[PATH_MAX];
|
||||||
|
float overlay_opacity;
|
||||||
} input;
|
} input;
|
||||||
|
|
||||||
char libretro[PATH_MAX];
|
char libretro[PATH_MAX];
|
||||||
|
@ -285,7 +285,7 @@ input_overlay_t *input_overlay_new(const char *overlay)
|
|||||||
ol->iface->enable(ol->iface_data, true);
|
ol->iface->enable(ol->iface_data, true);
|
||||||
ol->enable = true;
|
ol->enable = true;
|
||||||
|
|
||||||
input_overlay_set_alpha_mod(ol, 1.0f);
|
input_overlay_set_alpha_mod(ol, g_settings.input.overlay_opacity);
|
||||||
|
|
||||||
return ol;
|
return ol;
|
||||||
|
|
||||||
|
@ -233,6 +233,7 @@ void config_set_defaults(void)
|
|||||||
g_settings.input.netplay_client_swap_input = netplay_client_swap_input;
|
g_settings.input.netplay_client_swap_input = netplay_client_swap_input;
|
||||||
g_settings.input.turbo_period = turbo_period;
|
g_settings.input.turbo_period = turbo_period;
|
||||||
g_settings.input.turbo_duty_cycle = turbo_duty_cycle;
|
g_settings.input.turbo_duty_cycle = turbo_duty_cycle;
|
||||||
|
g_settings.input.overlay_opacity = 1.0f;
|
||||||
g_settings.input.debug_enable = input_debug_enable;
|
g_settings.input.debug_enable = input_debug_enable;
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
g_settings.input.autodetect_enable = input_autodetect_enable;
|
g_settings.input.autodetect_enable = input_autodetect_enable;
|
||||||
@ -688,6 +689,7 @@ bool config_load_file(const char *path)
|
|||||||
CONFIG_GET_INT(input.turbo_duty_cycle, "input_duty_cycle");
|
CONFIG_GET_INT(input.turbo_duty_cycle, "input_duty_cycle");
|
||||||
|
|
||||||
CONFIG_GET_PATH(input.overlay, "input_overlay");
|
CONFIG_GET_PATH(input.overlay, "input_overlay");
|
||||||
|
CONFIG_GET_FLOAT(input.overlay_opacity, "input_overlay_opacity");
|
||||||
CONFIG_GET_BOOL(input.debug_enable, "input_debug_enable");
|
CONFIG_GET_BOOL(input.debug_enable, "input_debug_enable");
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
CONFIG_GET_BOOL(input.autodetect_enable, "input_autodetect_enable");
|
CONFIG_GET_BOOL(input.autodetect_enable, "input_autodetect_enable");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user