Removed seemingly redundant opacityId value

This commit is contained in:
OpenSauce04 2024-04-13 17:12:15 +01:00 committed by OpenSauce
parent d22afdb97f
commit c9f6f6e40e
3 changed files with 13 additions and 19 deletions

View File

@ -36,7 +36,6 @@ class InputOverlayDrawableButton(
private var controlPositionY = 0
val width: Int
val height: Int
private val opacityId: Int
private val defaultStateBitmap: BitmapDrawable
private val pressedStateBitmap: BitmapDrawable
private var pressedState = false
@ -44,7 +43,6 @@ class InputOverlayDrawableButton(
init {
this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap)
this.pressedStateBitmap = BitmapDrawable(res, pressedStateBitmap)
this.opacityId = this.opacity
trackId = -1
width = this.defaultStateBitmap.intrinsicWidth
height = this.defaultStateBitmap.intrinsicHeight
@ -119,7 +117,7 @@ class InputOverlayDrawableButton(
fun draw(canvas: Canvas) {
val bitmapDrawable: BitmapDrawable = currentStateBitmapDrawable
bitmapDrawable.alpha = opacityId
bitmapDrawable.alpha = opacity
bitmapDrawable.draw(canvas)
}

View File

@ -45,7 +45,6 @@ class InputOverlayDrawableDpad(
private var controlPositionY = 0
val width: Int
val height: Int
private val opacityId: Int
private val defaultStateBitmap: BitmapDrawable
private val pressedOneDirectionStateBitmap: BitmapDrawable
private val pressedTwoDirectionsStateBitmap: BitmapDrawable
@ -58,7 +57,6 @@ class InputOverlayDrawableDpad(
this.defaultStateBitmap = BitmapDrawable(res, defaultStateBitmap)
this.pressedOneDirectionStateBitmap = BitmapDrawable(res, pressedOneDirectionStateBitmap)
this.pressedTwoDirectionsStateBitmap = BitmapDrawable(res, pressedTwoDirectionsStateBitmap)
this.opacityId = this.opacity
width = this.defaultStateBitmap.intrinsicWidth
height = this.defaultStateBitmap.intrinsicHeight
trackId = -1
@ -141,7 +139,7 @@ class InputOverlayDrawableDpad(
// Pressed up
if (upButtonState && !leftButtonState && !rightButtonState) {
pressedOneDirectionStateBitmap.alpha = opacityId
pressedOneDirectionStateBitmap.alpha = opacity
pressedOneDirectionStateBitmap.draw(canvas)
return
}
@ -150,7 +148,7 @@ class InputOverlayDrawableDpad(
if (downButtonState && !leftButtonState && !rightButtonState) {
canvas.save()
canvas.rotate(180f, px.toFloat(), py.toFloat())
pressedOneDirectionStateBitmap.alpha = opacityId
pressedOneDirectionStateBitmap.alpha = opacity
pressedOneDirectionStateBitmap.draw(canvas)
canvas.restore()
return
@ -160,7 +158,7 @@ class InputOverlayDrawableDpad(
if (leftButtonState && !upButtonState && !downButtonState) {
canvas.save()
canvas.rotate(270f, px.toFloat(), py.toFloat())
pressedOneDirectionStateBitmap.alpha = opacityId
pressedOneDirectionStateBitmap.alpha = opacity
pressedOneDirectionStateBitmap.draw(canvas)
canvas.restore()
return
@ -170,7 +168,7 @@ class InputOverlayDrawableDpad(
if (rightButtonState && !upButtonState && !downButtonState) {
canvas.save()
canvas.rotate(90f, px.toFloat(), py.toFloat())
pressedOneDirectionStateBitmap.alpha = opacityId
pressedOneDirectionStateBitmap.alpha = opacity
pressedOneDirectionStateBitmap.draw(canvas)
canvas.restore()
return
@ -178,7 +176,7 @@ class InputOverlayDrawableDpad(
// Pressed up left
if (upButtonState && leftButtonState && !rightButtonState) {
pressedTwoDirectionsStateBitmap.alpha = opacityId
pressedTwoDirectionsStateBitmap.alpha = opacity
pressedTwoDirectionsStateBitmap.draw(canvas)
return
}
@ -187,7 +185,7 @@ class InputOverlayDrawableDpad(
if (upButtonState && !leftButtonState && rightButtonState) {
canvas.save()
canvas.rotate(90f, px.toFloat(), py.toFloat())
pressedTwoDirectionsStateBitmap.alpha = opacityId
pressedTwoDirectionsStateBitmap.alpha = opacity
pressedTwoDirectionsStateBitmap.draw(canvas)
canvas.restore()
return
@ -197,7 +195,7 @@ class InputOverlayDrawableDpad(
if (downButtonState && leftButtonState && !rightButtonState) {
canvas.save()
canvas.rotate(270f, px.toFloat(), py.toFloat())
pressedTwoDirectionsStateBitmap.alpha = opacityId
pressedTwoDirectionsStateBitmap.alpha = opacity
pressedTwoDirectionsStateBitmap.draw(canvas)
canvas.restore()
return
@ -207,14 +205,14 @@ class InputOverlayDrawableDpad(
if (downButtonState && !leftButtonState && rightButtonState) {
canvas.save()
canvas.rotate(180f, px.toFloat(), py.toFloat())
pressedTwoDirectionsStateBitmap.alpha = opacityId
pressedTwoDirectionsStateBitmap.alpha = opacity
pressedTwoDirectionsStateBitmap.draw(canvas)
canvas.restore()
return
}
// Not pressed
defaultStateBitmap.alpha = opacityId
defaultStateBitmap.alpha = opacity
defaultStateBitmap.draw(canvas)
}

View File

@ -52,7 +52,6 @@ class InputOverlayDrawableJoystick(
private var previousTouchY = 0
val width: Int
val height: Int
private val opacityId: Int
private var virtBounds: Rect
private var origBounds: Rect
private val outerBitmap: BitmapDrawable
@ -75,7 +74,6 @@ class InputOverlayDrawableJoystick(
width = bitmapOuter.width
height = bitmapOuter.height
bounds = rectOuter
opacityId = opacity
defaultStateInnerBitmap.bounds = rectInner
pressedStateInnerBitmap.bounds = rectInner
virtBounds = bounds
@ -90,7 +88,7 @@ class InputOverlayDrawableJoystick(
fun draw(canvas: Canvas?) {
outerBitmap.draw(canvas!!)
currentStateBitmapDrawable.alpha = opacityId
currentStateBitmapDrawable.alpha = opacity
currentStateBitmapDrawable.draw(canvas)
boundsBoxBitmap.draw(canvas)
}
@ -111,7 +109,7 @@ class InputOverlayDrawableJoystick(
}
pressedState = true
outerBitmap.alpha = 0
boundsBoxBitmap.alpha = opacityId
boundsBoxBitmap.alpha = opacity
if (EmulationMenuSettings.joystickRelCenter) {
virtBounds.offset(
xPosition - virtBounds.centerX(),
@ -131,7 +129,7 @@ class InputOverlayDrawableJoystick(
yAxis = 0.0f
angle = 0.0f
radius = 0.0f
outerBitmap.alpha = opacityId
outerBitmap.alpha = opacity
boundsBoxBitmap.alpha = 0
virtBounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom)
bounds = Rect(origBounds.left, origBounds.top, origBounds.right, origBounds.bottom)