mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Android: Implement touch controls opacity option.
This commit is contained in:
		
							parent
							
								
									0c2f076dc4
								
							
						
					
					
						commit
						467301bc4e
					
				
					 8 changed files with 95 additions and 9 deletions
				
			
		|  | @ -617,6 +617,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram | ||||||
|                     true |                     true | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|  |                 R.id.menu_emulation_adjust_opacity -> { | ||||||
|  |                     showAdjustOpacityDialog() | ||||||
|  |                     true | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 R.id.menu_emulation_joystick_rel_center -> { |                 R.id.menu_emulation_joystick_rel_center -> { | ||||||
|                     EmulationMenuSettings.joystickRelCenter = |                     EmulationMenuSettings.joystickRelCenter = | ||||||
|                         !EmulationMenuSettings.joystickRelCenter |                         !EmulationMenuSettings.joystickRelCenter | ||||||
|  | @ -793,6 +798,37 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram | ||||||
|             .show() |             .show() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     private fun showAdjustOpacityDialog() { | ||||||
|  |         val sliderBinding = DialogSliderBinding.inflate(layoutInflater) | ||||||
|  | 
 | ||||||
|  |         sliderBinding.apply { | ||||||
|  |             slider.valueTo = 100f | ||||||
|  |             slider.value = preferences.getInt("controlOpacity", 100).toFloat() | ||||||
|  |             slider.addOnChangeListener( | ||||||
|  |                 Slider.OnChangeListener { slider: Slider, progress: Float, _: Boolean -> | ||||||
|  |                     textValue.text = (progress.toInt()).toString() | ||||||
|  |                     setControlOpacity(slider.value.toInt()) | ||||||
|  |                 }) | ||||||
|  |             textValue.text = (sliderBinding.slider.value.toInt()).toString() | ||||||
|  |             textUnits.text = "%" | ||||||
|  |         } | ||||||
|  |         val previousProgress = sliderBinding.slider.value.toInt() | ||||||
|  | 
 | ||||||
|  |         MaterialAlertDialogBuilder(requireContext()) | ||||||
|  |             .setTitle(R.string.emulation_control_opacity) | ||||||
|  |             .setView(sliderBinding.root) | ||||||
|  |             .setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int -> | ||||||
|  |                 setControlOpacity(previousProgress) | ||||||
|  |             } | ||||||
|  |             .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> | ||||||
|  |                 setControlOpacity(sliderBinding.slider.value.toInt()) | ||||||
|  |             } | ||||||
|  |             .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int -> | ||||||
|  |                 setControlOpacity(100) | ||||||
|  |             } | ||||||
|  |             .show() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private fun setControlScale(scale: Int) { |     private fun setControlScale(scale: Int) { | ||||||
|         preferences.edit() |         preferences.edit() | ||||||
|             .putInt("controlScale", scale) |             .putInt("controlScale", scale) | ||||||
|  | @ -800,6 +836,13 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram | ||||||
|         binding.surfaceInputOverlay.refreshControls() |         binding.surfaceInputOverlay.refreshControls() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     private fun setControlOpacity(opacity: Int) { | ||||||
|  |         preferences.edit() | ||||||
|  |             .putInt("controlOpacity", opacity) | ||||||
|  |             .apply() | ||||||
|  |         binding.surfaceInputOverlay.refreshControls() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     private fun showResetOverlayDialog() { |     private fun showResetOverlayDialog() { | ||||||
|         MaterialAlertDialogBuilder(requireContext()) |         MaterialAlertDialogBuilder(requireContext()) | ||||||
|             .setTitle(getString(R.string.emulation_touch_overlay_reset)) |             .setTitle(getString(R.string.emulation_touch_overlay_reset)) | ||||||
|  | @ -813,6 +856,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram | ||||||
|     private fun resetInputOverlay() { |     private fun resetInputOverlay() { | ||||||
|         preferences.edit() |         preferences.edit() | ||||||
|             .putInt("controlScale", 50) |             .putInt("controlScale", 50) | ||||||
|  |             .putInt("controlOpacity", 100) | ||||||
|             .apply() |             .apply() | ||||||
| 
 | 
 | ||||||
|         val editor = preferences.edit() |         val editor = preferences.edit() | ||||||
|  |  | ||||||
|  | @ -891,11 +891,13 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex | ||||||
|             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() |             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() | ||||||
|             scale /= 100f |             scale /= 100f | ||||||
|              |              | ||||||
|  |             val opacity: Int = preferences.getInt("controlOpacity", 100) * 255 / 100 | ||||||
|  | 
 | ||||||
|             // Initialize the InputOverlayDrawableButton. |             // Initialize the InputOverlayDrawableButton. | ||||||
|             val defaultStateBitmap = getBitmap(context, defaultResId, scale) |             val defaultStateBitmap = getBitmap(context, defaultResId, scale) | ||||||
|             val pressedStateBitmap = getBitmap(context, pressedResId, scale) |             val pressedStateBitmap = getBitmap(context, pressedResId, scale) | ||||||
|             val overlayDrawable = |             val overlayDrawable = | ||||||
|                 InputOverlayDrawableButton(res, defaultStateBitmap, pressedStateBitmap, buttonId) |                 InputOverlayDrawableButton(res, defaultStateBitmap, pressedStateBitmap, buttonId, opacity) | ||||||
| 
 | 
 | ||||||
|             // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. |             // The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay. | ||||||
|             // These were set in the input overlay configuration menu. |             // These were set in the input overlay configuration menu. | ||||||
|  | @ -947,6 +949,8 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex | ||||||
|             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() |             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() | ||||||
|             scale /= 100f |             scale /= 100f | ||||||
| 
 | 
 | ||||||
|  |             val opacity: Int = preferences.getInt("controlOpacity", 100) * 255 / 100 | ||||||
|  | 
 | ||||||
|             // Initialize the InputOverlayDrawableDpad. |             // Initialize the InputOverlayDrawableDpad. | ||||||
|             val defaultStateBitmap = getBitmap(context, defaultResId, scale) |             val defaultStateBitmap = getBitmap(context, defaultResId, scale) | ||||||
|             val pressedOneDirectionStateBitmap = getBitmap(context, pressedOneDirectionResId, scale) |             val pressedOneDirectionStateBitmap = getBitmap(context, pressedOneDirectionResId, scale) | ||||||
|  | @ -959,7 +963,8 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex | ||||||
|                 buttonUp, |                 buttonUp, | ||||||
|                 buttonDown, |                 buttonDown, | ||||||
|                 buttonLeft, |                 buttonLeft, | ||||||
|                 buttonRight |                 buttonRight, | ||||||
|  |                 opacity | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             // The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay. |             // The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay. | ||||||
|  | @ -1004,6 +1009,8 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex | ||||||
|             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() |             scale *= (preferences.getInt("controlScale", 50) + 50).toFloat() | ||||||
|             scale /= 100f |             scale /= 100f | ||||||
| 
 | 
 | ||||||
|  |             val opacity: Int = preferences.getInt("controlOpacity", 100) * 255 / 100 | ||||||
|  | 
 | ||||||
|             // Initialize the InputOverlayDrawableJoystick. |             // Initialize the InputOverlayDrawableJoystick. | ||||||
|             val bitmapOuter = getBitmap(context, resOuter, scale) |             val bitmapOuter = getBitmap(context, resOuter, scale) | ||||||
|             val bitmapInnerDefault = getBitmap(context, defaultResInner, scale) |             val bitmapInnerDefault = getBitmap(context, defaultResInner, scale) | ||||||
|  | @ -1040,7 +1047,8 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex | ||||||
|                 bitmapInnerPressed, |                 bitmapInnerPressed, | ||||||
|                 outerRect, |                 outerRect, | ||||||
|                 innerRect, |                 innerRect, | ||||||
|                 joystick |                 joystick, | ||||||
|  |                 opacity | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             // Need to set the image's position |             // Need to set the image's position | ||||||
|  |  | ||||||
|  | @ -25,7 +25,8 @@ class InputOverlayDrawableButton( | ||||||
|     res: Resources, |     res: Resources, | ||||||
|     defaultStateBitmap: Bitmap, |     defaultStateBitmap: Bitmap, | ||||||
|     pressedStateBitmap: Bitmap, |     pressedStateBitmap: Bitmap, | ||||||
|     val id: Int |     val id: Int, | ||||||
|  |     val opacity: Int | ||||||
| ) { | ) { | ||||||
|     var trackId: Int |     var trackId: Int | ||||||
|     private var previousTouchX = 0 |     private var previousTouchX = 0 | ||||||
|  | @ -34,6 +35,7 @@ class InputOverlayDrawableButton( | ||||||
|     private var controlPositionY = 0 |     private var controlPositionY = 0 | ||||||
|     val width: Int |     val width: Int | ||||||
|     val height: Int |     val height: Int | ||||||
|  |     private val opacityId: Int | ||||||
|     private val defaultStateBitmap: BitmapDrawable |     private val defaultStateBitmap: BitmapDrawable | ||||||
|     private val pressedStateBitmap: BitmapDrawable |     private val pressedStateBitmap: BitmapDrawable | ||||||
|     private var pressedState = false |     private var pressedState = false | ||||||
|  | @ -41,6 +43,7 @@ class InputOverlayDrawableButton( | ||||||
|     init { |     init { | ||||||
|         this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap) |         this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap) | ||||||
|         this.pressedStateBitmap = BitmapDrawable(res, pressedStateBitmap) |         this.pressedStateBitmap = BitmapDrawable(res, pressedStateBitmap) | ||||||
|  |         this.opacityId = this.opacity | ||||||
|         trackId = -1 |         trackId = -1 | ||||||
|         width = this.defaultStateBitmap.intrinsicWidth |         width = this.defaultStateBitmap.intrinsicWidth | ||||||
|         height = this.defaultStateBitmap.intrinsicHeight |         height = this.defaultStateBitmap.intrinsicHeight | ||||||
|  | @ -111,7 +114,11 @@ class InputOverlayDrawableButton( | ||||||
|         controlPositionY = y |         controlPositionY = y | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun draw(canvas: Canvas) = currentStateBitmapDrawable.draw(canvas) |     fun draw(canvas: Canvas) { | ||||||
|  |         val bitmapDrawable: BitmapDrawable = currentStateBitmapDrawable | ||||||
|  |         bitmapDrawable.alpha = opacityId | ||||||
|  |         bitmapDrawable.draw(canvas) | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     private val currentStateBitmapDrawable: BitmapDrawable |     private val currentStateBitmapDrawable: BitmapDrawable | ||||||
|         get() = if (pressedState) pressedStateBitmap else defaultStateBitmap |         get() = if (pressedState) pressedStateBitmap else defaultStateBitmap | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ import org.citra.citra_emu.NativeLibrary | ||||||
|  * @param downId                          Identifier for the down button. |  * @param downId                          Identifier for the down button. | ||||||
|  * @param leftId                          Identifier for the left button. |  * @param leftId                          Identifier for the left button. | ||||||
|  * @param rightId                         Identifier for the right button. |  * @param rightId                         Identifier for the right button. | ||||||
|  |  * @param opacity                         0-255 alpha value | ||||||
|  */ |  */ | ||||||
| class InputOverlayDrawableDpad( | class InputOverlayDrawableDpad( | ||||||
|     res: Resources, |     res: Resources, | ||||||
|  | @ -33,7 +34,8 @@ class InputOverlayDrawableDpad( | ||||||
|     val upId: Int, |     val upId: Int, | ||||||
|     val downId: Int, |     val downId: Int, | ||||||
|     val leftId: Int, |     val leftId: Int, | ||||||
|     val rightId: Int |     val rightId: Int, | ||||||
|  |     val opacity: Int | ||||||
| ) { | ) { | ||||||
|     var trackId: Int |     var trackId: Int | ||||||
|     private var previousTouchX = 0 |     private var previousTouchX = 0 | ||||||
|  | @ -42,6 +44,7 @@ class InputOverlayDrawableDpad( | ||||||
|     private var controlPositionY = 0 |     private var controlPositionY = 0 | ||||||
|     val width: Int |     val width: Int | ||||||
|     val height: Int |     val height: Int | ||||||
|  |     private val opacityId: Int | ||||||
|     private val defaultStateBitmap: BitmapDrawable |     private val defaultStateBitmap: BitmapDrawable | ||||||
|     private val pressedOneDirectionStateBitmap: BitmapDrawable |     private val pressedOneDirectionStateBitmap: BitmapDrawable | ||||||
|     private val pressedTwoDirectionsStateBitmap: BitmapDrawable |     private val pressedTwoDirectionsStateBitmap: BitmapDrawable | ||||||
|  | @ -54,6 +57,7 @@ class InputOverlayDrawableDpad( | ||||||
|         this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap) |         this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap) | ||||||
|         this.pressedOneDirectionStateBitmap = BitmapDrawable(res, pressedOneDirectionStateBitmap) |         this.pressedOneDirectionStateBitmap = BitmapDrawable(res, pressedOneDirectionStateBitmap) | ||||||
|         this.pressedTwoDirectionsStateBitmap = BitmapDrawable(res, pressedTwoDirectionsStateBitmap) |         this.pressedTwoDirectionsStateBitmap = BitmapDrawable(res, pressedTwoDirectionsStateBitmap) | ||||||
|  |         this.opacityId = this.opacity | ||||||
|         width = this.defaultStateBitmap.intrinsicWidth |         width = this.defaultStateBitmap.intrinsicWidth | ||||||
|         height = this.defaultStateBitmap.intrinsicHeight |         height = this.defaultStateBitmap.intrinsicHeight | ||||||
|         trackId = -1 |         trackId = -1 | ||||||
|  | @ -125,6 +129,7 @@ class InputOverlayDrawableDpad( | ||||||
| 
 | 
 | ||||||
|         // Pressed up |         // Pressed up | ||||||
|         if (upButtonState && !leftButtonState && !rightButtonState) { |         if (upButtonState && !leftButtonState && !rightButtonState) { | ||||||
|  |             pressedOneDirectionStateBitmap.alpha = opacityId | ||||||
|             pressedOneDirectionStateBitmap.draw(canvas) |             pressedOneDirectionStateBitmap.draw(canvas) | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  | @ -133,6 +138,7 @@ class InputOverlayDrawableDpad( | ||||||
|         if (downButtonState && !leftButtonState && !rightButtonState) { |         if (downButtonState && !leftButtonState && !rightButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(180f, px.toFloat(), py.toFloat()) |             canvas.rotate(180f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedOneDirectionStateBitmap.alpha = opacityId | ||||||
|             pressedOneDirectionStateBitmap.draw(canvas) |             pressedOneDirectionStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|  | @ -142,6 +148,7 @@ class InputOverlayDrawableDpad( | ||||||
|         if (leftButtonState && !upButtonState && !downButtonState) { |         if (leftButtonState && !upButtonState && !downButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(270f, px.toFloat(), py.toFloat()) |             canvas.rotate(270f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedOneDirectionStateBitmap.alpha = opacityId | ||||||
|             pressedOneDirectionStateBitmap.draw(canvas) |             pressedOneDirectionStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|  | @ -151,6 +158,7 @@ class InputOverlayDrawableDpad( | ||||||
|         if (rightButtonState && !upButtonState && !downButtonState) { |         if (rightButtonState && !upButtonState && !downButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(90f, px.toFloat(), py.toFloat()) |             canvas.rotate(90f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedOneDirectionStateBitmap.alpha = opacityId | ||||||
|             pressedOneDirectionStateBitmap.draw(canvas) |             pressedOneDirectionStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|  | @ -158,6 +166,7 @@ class InputOverlayDrawableDpad( | ||||||
| 
 | 
 | ||||||
|         // Pressed up left |         // Pressed up left | ||||||
|         if (upButtonState && leftButtonState && !rightButtonState) { |         if (upButtonState && leftButtonState && !rightButtonState) { | ||||||
|  |             pressedTwoDirectionsStateBitmap.alpha = opacityId | ||||||
|             pressedTwoDirectionsStateBitmap.draw(canvas) |             pressedTwoDirectionsStateBitmap.draw(canvas) | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|  | @ -166,6 +175,7 @@ class InputOverlayDrawableDpad( | ||||||
|         if (upButtonState && !leftButtonState && rightButtonState) { |         if (upButtonState && !leftButtonState && rightButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(90f, px.toFloat(), py.toFloat()) |             canvas.rotate(90f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedTwoDirectionsStateBitmap.alpha = opacityId | ||||||
|             pressedTwoDirectionsStateBitmap.draw(canvas) |             pressedTwoDirectionsStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|  | @ -175,6 +185,7 @@ class InputOverlayDrawableDpad( | ||||||
|         if (downButtonState && leftButtonState && !rightButtonState) { |         if (downButtonState && leftButtonState && !rightButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(270f, px.toFloat(), py.toFloat()) |             canvas.rotate(270f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedTwoDirectionsStateBitmap.alpha = opacityId | ||||||
|             pressedTwoDirectionsStateBitmap.draw(canvas) |             pressedTwoDirectionsStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|  | @ -184,12 +195,14 @@ class InputOverlayDrawableDpad( | ||||||
|         if (downButtonState && !leftButtonState && rightButtonState) { |         if (downButtonState && !leftButtonState && rightButtonState) { | ||||||
|             canvas.save() |             canvas.save() | ||||||
|             canvas.rotate(180f, px.toFloat(), py.toFloat()) |             canvas.rotate(180f, px.toFloat(), py.toFloat()) | ||||||
|  |             pressedTwoDirectionsStateBitmap.alpha = opacityId | ||||||
|             pressedTwoDirectionsStateBitmap.draw(canvas) |             pressedTwoDirectionsStateBitmap.draw(canvas) | ||||||
|             canvas.restore() |             canvas.restore() | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // Not pressed |         // Not pressed | ||||||
|  |         defaultStateBitmap.alpha = opacityId | ||||||
|         defaultStateBitmap.draw(canvas) |         defaultStateBitmap.draw(canvas) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -28,6 +28,7 @@ import kotlin.math.sqrt | ||||||
|  * @param rectOuter          [Rect] which represents the outer joystick bounds. |  * @param rectOuter          [Rect] which represents the outer joystick bounds. | ||||||
|  * @param rectInner          [Rect] which represents the inner joystick bounds. |  * @param rectInner          [Rect] which represents the inner joystick bounds. | ||||||
|  * @param joystickId         Identifier for which joystick this is. |  * @param joystickId         Identifier for which joystick this is. | ||||||
|  |  * @param opacity            0-255 alpha value | ||||||
|  */ |  */ | ||||||
| class InputOverlayDrawableJoystick( | class InputOverlayDrawableJoystick( | ||||||
|     res: Resources, |     res: Resources, | ||||||
|  | @ -36,7 +37,8 @@ class InputOverlayDrawableJoystick( | ||||||
|     bitmapInnerPressed: Bitmap, |     bitmapInnerPressed: Bitmap, | ||||||
|     rectOuter: Rect, |     rectOuter: Rect, | ||||||
|     rectInner: Rect, |     rectInner: Rect, | ||||||
|     val joystickId: Int |     val joystickId: Int, | ||||||
|  |     val opacity: Int | ||||||
| ) { | ) { | ||||||
|     var trackId = -1 |     var trackId = -1 | ||||||
|     var xAxis = 0f |     var xAxis = 0f | ||||||
|  | @ -47,6 +49,7 @@ class InputOverlayDrawableJoystick( | ||||||
|     private var previousTouchY = 0 |     private var previousTouchY = 0 | ||||||
|     val width: Int |     val width: Int | ||||||
|     val height: Int |     val height: Int | ||||||
|  |     private val opacityId: Int | ||||||
|     private var virtBounds: Rect |     private var virtBounds: Rect | ||||||
|     private var origBounds: Rect |     private var origBounds: Rect | ||||||
|     private val outerBitmap: BitmapDrawable |     private val outerBitmap: BitmapDrawable | ||||||
|  | @ -69,6 +72,7 @@ class InputOverlayDrawableJoystick( | ||||||
|         width = bitmapOuter.width |         width = bitmapOuter.width | ||||||
|         height = bitmapOuter.height |         height = bitmapOuter.height | ||||||
|         bounds = rectOuter |         bounds = rectOuter | ||||||
|  |         opacityId = opacity | ||||||
|         defaultStateInnerBitmap.bounds = rectInner |         defaultStateInnerBitmap.bounds = rectInner | ||||||
|         pressedStateInnerBitmap.bounds = rectInner |         pressedStateInnerBitmap.bounds = rectInner | ||||||
|         virtBounds = bounds |         virtBounds = bounds | ||||||
|  | @ -76,10 +80,14 @@ class InputOverlayDrawableJoystick( | ||||||
|         boundsBoxBitmap.alpha = 0 |         boundsBoxBitmap.alpha = 0 | ||||||
|         boundsBoxBitmap.bounds = virtBounds |         boundsBoxBitmap.bounds = virtBounds | ||||||
|         setInnerBounds() |         setInnerBounds() | ||||||
|  |         defaultStateInnerBitmap.alpha = opacity | ||||||
|  |         pressedStateInnerBitmap.alpha = opacity | ||||||
|  |         outerBitmap.alpha = opacity | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fun draw(canvas: Canvas?) { |     fun draw(canvas: Canvas?) { | ||||||
|         outerBitmap.draw(canvas!!) |         outerBitmap.draw(canvas!!) | ||||||
|  |         currentStateBitmapDrawable.alpha = opacityId | ||||||
|         currentStateBitmapDrawable.draw(canvas) |         currentStateBitmapDrawable.draw(canvas) | ||||||
|         boundsBoxBitmap.draw(canvas) |         boundsBoxBitmap.draw(canvas) | ||||||
|     } |     } | ||||||
|  | @ -100,7 +108,7 @@ class InputOverlayDrawableJoystick( | ||||||
|             } |             } | ||||||
|             pressedState = true |             pressedState = true | ||||||
|             outerBitmap.alpha = 0 |             outerBitmap.alpha = 0 | ||||||
|             boundsBoxBitmap.alpha = 255 |             boundsBoxBitmap.alpha = opacityId | ||||||
|             if (EmulationMenuSettings.joystickRelCenter) { |             if (EmulationMenuSettings.joystickRelCenter) { | ||||||
|                 virtBounds.offset( |                 virtBounds.offset( | ||||||
|                     xPosition - virtBounds.centerX(), |                     xPosition - virtBounds.centerX(), | ||||||
|  | @ -117,7 +125,7 @@ class InputOverlayDrawableJoystick( | ||||||
|             pressedState = false |             pressedState = false | ||||||
|             xAxis = 0.0f |             xAxis = 0.0f | ||||||
|             yAxis = 0.0f |             yAxis = 0.0f | ||||||
|             outerBitmap.alpha = 255 |             outerBitmap.alpha = opacityId | ||||||
|             boundsBoxBitmap.alpha = 0 |             boundsBoxBitmap.alpha = 0 | ||||||
|             virtBounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom) |             virtBounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom) | ||||||
|             bounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom) |             bounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom) | ||||||
|  |  | ||||||
|  | @ -23,6 +23,10 @@ | ||||||
|         android:id="@+id/menu_emulation_adjust_scale" |         android:id="@+id/menu_emulation_adjust_scale" | ||||||
|         android:title="@string/emulation_control_scale" /> |         android:title="@string/emulation_control_scale" /> | ||||||
| 
 | 
 | ||||||
|  |     <item | ||||||
|  |         android:id="@+id/menu_emulation_adjust_opacity" | ||||||
|  |         android:title="@string/emulation_control_opacity" /> | ||||||
|  | 
 | ||||||
|     <group android:checkableBehavior="all"> |     <group android:checkableBehavior="all"> | ||||||
|         <item |         <item | ||||||
|             android:id="@+id/menu_emulation_joystick_rel_center" |             android:id="@+id/menu_emulation_joystick_rel_center" | ||||||
|  |  | ||||||
|  | @ -315,6 +315,7 @@ Se esperan fallos gráficos temporales cuando ésta esté activado.</string> | ||||||
|     <string name="emulation_done">Hecho</string> |     <string name="emulation_done">Hecho</string> | ||||||
|     <string name="emulation_toggle_controls">Activar Controles</string> |     <string name="emulation_toggle_controls">Activar Controles</string> | ||||||
|     <string name="emulation_control_scale">Ajustar Escala</string> |     <string name="emulation_control_scale">Ajustar Escala</string> | ||||||
|  |     <string name="emulation_control_opacity">Ajustar Opacidad</string> | ||||||
|     <string name="emulation_control_joystick_rel_center">Posición central relativa del stick</string> |     <string name="emulation_control_joystick_rel_center">Posición central relativa del stick</string> | ||||||
|     <string name="emulation_control_dpad_slide_enable">Deslizamiento de la Cruceta</string> |     <string name="emulation_control_dpad_slide_enable">Deslizamiento de la Cruceta</string> | ||||||
|     <string name="emulation_open_settings">Abrir Configuración</string> |     <string name="emulation_open_settings">Abrir Configuración</string> | ||||||
|  |  | ||||||
|  | @ -329,6 +329,7 @@ | ||||||
|     <string name="emulation_done">Done</string> |     <string name="emulation_done">Done</string> | ||||||
|     <string name="emulation_toggle_controls">Toggle Controls</string> |     <string name="emulation_toggle_controls">Toggle Controls</string> | ||||||
|     <string name="emulation_control_scale">Adjust Scale</string> |     <string name="emulation_control_scale">Adjust Scale</string> | ||||||
|  |     <string name="emulation_control_opacity">Adjust Opacity</string> | ||||||
|     <string name="emulation_control_joystick_rel_center">Relative Stick Center</string> |     <string name="emulation_control_joystick_rel_center">Relative Stick Center</string> | ||||||
|     <string name="emulation_control_dpad_slide_enable">D-Pad Sliding</string> |     <string name="emulation_control_dpad_slide_enable">D-Pad Sliding</string> | ||||||
|     <string name="emulation_open_settings">Open Settings</string> |     <string name="emulation_open_settings">Open Settings</string> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue