diff options
| author | Lioncash <mathew1800@gmail.com> | 2014-07-16 19:04:35 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2014-07-16 19:04:35 -0400 |
| commit | 30e4366d280b4e801de4caa86cb787901d733e7b (patch) | |
| tree | daad54523e7f1842ecedeeaae02237099d4975aa /Source/Android/src | |
| parent | 9481af886b627b7b6dd745941baed3239b0dbd46 (diff) | |
| parent | cd9a0b6f4d42710b2a2f7bdf1eb867de2b2517ae (diff) | |
Merge pull request #580 from SeannyM/smaller-b
[Android] User configurable input overlay scaling
Diffstat (limited to 'Source/Android/src')
2 files changed, 62 insertions, 6 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java index 054690a072..2f2fdb9a53 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/overlay/InputOverlay.java @@ -186,8 +186,31 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener // SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableButton. final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context); + // Decide scale based on button ID + float scale; + float overlaySize = sPrefs.getInt("controls_size", 25); + overlaySize += 25; + overlaySize /= 50; + + switch (resId) + { + case R.drawable.gcpad_b: + scale = 0.13f * overlaySize; + break; + case R.drawable.gcpad_x: + case R.drawable.gcpad_y: + scale = 0.18f * overlaySize; + break; + case R.drawable.gcpad_start: + scale = 0.12f * overlaySize; + break; + default: + scale = 0.20f * overlaySize; + break; + } + // Initialize the InputOverlayDrawableButton. - final Bitmap bitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, resId), 0.20f); + final Bitmap bitmap = resizeBitmap(context, BitmapFactory.decodeResource(res, resId), scale); final InputOverlayDrawableButton overlayDrawable = new InputOverlayDrawableButton(res, bitmap, buttonId); // String ID of the Drawable. This is what is passed into SharedPreferences @@ -231,7 +254,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context); // Initialize the InputOverlayDrawableJoystick. - final Bitmap bitmapOuter = resizeBitmap(context, BitmapFactory.decodeResource(res, resOuter), 0.30f); + float overlaySize = sPrefs.getInt("controls_size", 20); + overlaySize += 30; + overlaySize /= 50; + final Bitmap bitmapOuter = resizeBitmap(context, BitmapFactory.decodeResource(res, resOuter), 0.30f * overlaySize); final Bitmap bitmapInner = BitmapFactory.decodeResource(res, resInner); // String ID of the Drawable. This is what is passed into SharedPreferences diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java index 30288179ef..65a1ae4df6 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/overlayconfig/OverlayConfigButton.java @@ -76,13 +76,43 @@ public final class OverlayConfigButton extends Button implements OnTouchListener // Set the button as its own OnTouchListener. setOnTouchListener(this); - // Set the button's icon that represents it. - setBackground(resizeDrawable(getResources().getDrawable(drawableId), - drawableId == R.drawable.gcpad_joystick_range ? 0.30f : 0.20f)); - // Get the SharedPreferences instance. sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + // Decide scale based on button ID + + // SeekBars are not able to set a minimum value, only a maximum value, which complicates + // things a bit. What happens here is after the SeekBar's value is retrieved, 25 is + // added so the value will never go below 25. It is then divided by 50 (25 + 25) so the + // default value will be 100%. + float scale; + float overlaySize = sharedPrefs.getInt("controls_size", 25); + overlaySize += 25; + overlaySize /= 50; + + switch (drawableId) + { + case R.drawable.gcpad_b: + scale = 0.13f * overlaySize; + break; + case R.drawable.gcpad_x: + case R.drawable.gcpad_y: + scale = 0.18f * overlaySize; + break; + case R.drawable.gcpad_start: + scale = 0.12f * overlaySize; + break; + case R.drawable.gcpad_joystick_range: + scale = 0.30f * overlaySize; + break; + default: + scale = 0.20f * overlaySize; + break; + } + + // Set the button's icon that represents it. + setBackground(resizeDrawable(getResources().getDrawable(drawableId), scale)); + // Check if this button has previous values set that aren't the default. final float x = sharedPrefs.getFloat(buttonId+"-X", -1f); final float y = sharedPrefs.getFloat(buttonId+"-Y", -1f); |
