Skip to content

Commit 387622e

Browse files
committed
fixes
1 parent 0a38353 commit 387622e

4 files changed

Lines changed: 23 additions & 17 deletions

File tree

‎src/main/kotlin/ru/octol1ttle/flightassistant/api/alert/Alert.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class Alert(val computers: ComputerBus) {
2727
abstract fun shouldActivate(): Boolean
2828

2929
/**
30-
* Called when this alert is hidden via keybind.
30+
* Called when this alert is dismissed by the player.
3131
*/
3232
open fun onDismiss() {}
3333
}

‎src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/autoflight/base/ThrustComputer.kt‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ThrustComputer(computers: ComputerBus) : Computer(computers) {
2828
var manualThrust: Float = 0.0f
2929
private set
3030

31-
var activeInput: ControlInput? = null
31+
var lastInput: ControlInput? = null
3232
private set
3333
var noThrustSource: Boolean = false
3434
private set
@@ -43,19 +43,19 @@ class ThrustComputer(computers: ComputerBus) : Computer(computers) {
4343
val thrustSource: ThrustSource? = getThrustSource()
4444

4545
val inputs: List<ControlInput> = computers.dispatchQuery(TargetThrustQuery()).sortedBy { it.priority.value }
46-
val finalInput =
47-
if (!FAKeyMappings.isHoldingThrust()) inputs.getActiveHighestPriority().maxByOrNull { it.target }
48-
else null
46+
val maxInput = inputs.getActiveHighestPriority().maxByOrNull { it.target }
47+
48+
val activeInput = if (!FAKeyMappings.isHoldingThrust()) maxInput else null
4949
val newTarget =
50-
if (finalInput?.status == ControlInput.Status.ACTIVE) finalInput.target
50+
if (activeInput?.status == ControlInput.Status.ACTIVE) activeInput.target
5151
else manualThrust
5252

5353
targetThrust = newTarget
54-
noThrustSource = thrustSource == null && (newTarget != 0.0f || (finalInput != null && finalInput.target != 0.0f))
54+
noThrustSource = thrustSource == null && (newTarget != 0.0f || (activeInput != null && activeInput.target != 0.0f))
5555
reverseUnsupported = newTarget < 0.0f && thrustSource?.supportsReverse == false
5656

5757
val active: Boolean = !noThrustSource && !reverseUnsupported
58-
activeInput = finalInput?.copy(status = if (active) finalInput.status else ControlInput.Status.UNAVAILABLE)
58+
lastInput = maxInput?.copy(status = if (active) maxInput.status else ControlInput.Status.UNAVAILABLE)
5959

6060
if (computers.data.automationsAllowed() && targetThrust != 0.0f) {
6161
thrustSource?.tickThrust(targetThrust.coerceIn((if (thrustSource.supportsReverse) -1.0f else 0.0f)..1.0f))
@@ -105,7 +105,7 @@ class ThrustComputer(computers: ComputerBus) : Computer(computers) {
105105

106106
override fun reset() {
107107
targetThrust = 0.0f
108-
activeInput = null
108+
lastInput = null
109109
noThrustSource = false
110110
reverseUnsupported = false
111111
}

‎src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/safety/AlertComputer.kt‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,14 @@ class AlertComputer(computers: ComputerBus, private val soundManager: SoundManag
162162
if (category.activeAlerts.isEmpty()) {
163163
continue
164164
}
165-
val alert: Alert = category.activeAlerts.removeAt(0)
166-
category.ignoredAlerts.add(alert)
167-
alert.onDismiss()
168-
if (!all) {
165+
if (all) {
166+
category.ignoredAlerts.addAll(category.activeAlerts)
167+
category.activeAlerts.forEach(Alert::onDismiss)
168+
category.activeAlerts.clear()
169+
} else {
170+
val alert: Alert = category.activeAlerts.removeAt(0)
171+
category.ignoredAlerts.add(alert)
172+
alert.onDismiss()
169173
break
170174
}
171175
}
@@ -176,8 +180,10 @@ class AlertComputer(computers: ComputerBus, private val soundManager: SoundManag
176180
if (category.ignoredAlerts.isEmpty()) {
177181
continue
178182
}
179-
category.ignoredAlerts.removeAt(0)
180-
if (!all) {
183+
if (all) {
184+
category.ignoredAlerts.clear()
185+
} else {
186+
category.ignoredAlerts.removeAt(0)
181187
break
182188
}
183189
}

‎src/main/kotlin/ru/octol1ttle/flightassistant/impl/display/AutomationModesDisplay.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AutomationModesDisplay(computers: ComputerBus) : Display(computers) {
3636
private fun renderThrustMode(guiGraphics: GuiGraphics) {
3737
val thrustUnusable: Boolean = computers.thrust.noThrustSource || computers.thrust.reverseUnsupported
3838

39-
val input: ControlInput? = computers.thrust.activeInput
39+
val input: ControlInput? = computers.thrust.lastInput
4040
if ((input != null && FAKeyMappings.isHoldingThrust()) || FAKeyMappings.globalAutomationOverride.isDown) {
4141
thrustDisplay.render(guiGraphics, Component.translatable("mode.flightassistant.thrust.override").setColor(cautionColor), ControlInput.Status.ACTIVE, cautionColor)
4242
return
@@ -51,7 +51,7 @@ class AutomationModesDisplay(computers: ComputerBus) : Display(computers) {
5151
if (computers.thrust.manualThrust != 0.0f) {
5252
thrustDisplay.render(
5353
guiGraphics,
54-
if (computers.thrust.manualThrust == 1.0f) Component.translatable("mode.flightassistant.thrust.manual.toga").setColor(secondaryColor)
54+
if (computers.thrust.manualThrust == 1.0f) Component.translatable("mode.flightassistant.thrust.manual.max").setColor(secondaryColor)
5555
else if (computers.thrust.manualThrust < 0.0f) Component.translatable("mode.flightassistant.thrust.manual.reverse")
5656
else Component.translatable("mode.flightassistant.thrust.manual"),
5757
ControlInput.Status.ACTIVE, if (thrustUnusable) cautionColor else null

0 commit comments

Comments
 (0)