Skip to content

Commit 28788f9

Browse files
committed
replace "Manual pitch override" with "Global automation override"
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent 23b48b2 commit 28788f9

File tree

9 files changed

+24
-21
lines changed

9 files changed

+24
-21
lines changed

src/main/kotlin/ru/octol1ttle/flightassistant/FAKeyMappings.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object FAKeyMappings {
1616
lateinit var openFlightAssistantSetup: KeyMapping
1717

1818
lateinit var autopilotDisconnect: KeyMapping
19-
lateinit var manualPitchOverride: KeyMapping
19+
lateinit var globalAutomationOverride: KeyMapping
2020

2121
lateinit var hideCurrentAlert: KeyMapping
2222
lateinit var showHiddenAlert: KeyMapping
@@ -31,7 +31,7 @@ object FAKeyMappings {
3131
openFlightAssistantSetup = addKeyMapping("open_flightassistant_setup", GLFW.GLFW_KEY_KP_ENTER)
3232

3333
autopilotDisconnect = addKeyMapping("autopilot_disconnect", GLFW.GLFW_KEY_CAPS_LOCK) // TODO: replace with "Toggle FD", "Toggle A/T", "Toggle AP"
34-
manualPitchOverride = addKeyMapping("manual_pitch_override", GLFW.GLFW_KEY_RIGHT_ALT)
34+
globalAutomationOverride = addKeyMapping("global_automation_override", GLFW.GLFW_KEY_LEFT_ALT)
3535

3636
hideCurrentAlert = addKeyMapping("hide_current_alert", GLFW.GLFW_KEY_KP_0)
3737
showHiddenAlert = addKeyMapping("show_hidden_alert", GLFW.GLFW_KEY_KP_DECIMAL)
@@ -65,7 +65,6 @@ object FAKeyMappings {
6565
}
6666
computers.autoflight.setAutoPilot(false, alert = false)
6767
}
68-
computers.pitch.manualOverride = manualPitchOverride.isDown
6968

7069
while (hideCurrentAlert.consumeClick()) {
7170
computers.alert.hideCurrentAlert()

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/autoflight/AutoFlightComputer.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ru.octol1ttle.flightassistant.impl.computer.autoflight
33
import kotlin.math.abs
44
import net.minecraft.network.chat.Component
55
import net.minecraft.resources.ResourceLocation
6+
import ru.octol1ttle.flightassistant.FAKeyMappings
67
import ru.octol1ttle.flightassistant.FlightAssistant
78
import ru.octol1ttle.flightassistant.api.autoflight.ControlInput
89
import ru.octol1ttle.flightassistant.api.autoflight.FlightController
@@ -87,7 +88,8 @@ class AutoFlightComputer(computers: ComputerBus) : Computer(computers), FlightCo
8788
return
8889
}
8990

90-
if (computers.pitch.manualOverride) {
91+
if (FAKeyMappings.globalAutomationOverride.isDown) {
92+
setAutoThrust(false, alert = false)
9193
setAutoPilot(false, alert = false)
9294
}
9395

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/autoflight/FireworkComputer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FireworkComputer(computers: ComputerBus, private val mc: Minecraft) : Comp
4040
if (player.level().isClientSide() && computers.data.flying && stack.item is FireworkRocketItem) {
4141
val explosive = FAConfig.safety.fireworkLockExplosive && !isEmptyOrSafe(player, hand)
4242
val anyTerrainAhead = FAConfig.safety.fireworkLockObstacles && anyTerrainAhead()
43-
if (explosive || anyTerrainAhead) {
43+
if (computers.data.automationsAllowed() && (explosive || anyTerrainAhead)) {
4444
//? if >=1.21.2 {
4545
/*return@RightClickItem net.minecraft.world.InteractionResult.FAIL
4646
*///?} else

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import ru.octol1ttle.flightassistant.api.util.throwIfNotInRange
1818

1919
class PitchComputer(computers: ComputerBus) : Computer(computers), FlightController {
2020
private val controllers: MutableList<FlightController> = ArrayList()
21-
internal var manualOverride: Boolean = false
2221

2322
var minimumPitch: ControlInput? = null
2423
private set
@@ -85,7 +84,7 @@ class PitchComputer(computers: ComputerBus) : Computer(computers), FlightControl
8584
}
8685

8786
private fun canMoveOrBlockPitch(): Boolean {
88-
return !manualOverride && !computers.protections.protectionsLost && computers.data.automationsAllowed()
87+
return computers.data.automationsAllowed() && !computers.protections.protectionsLost
8988
}
9089

9190
private fun updateSafePitches() {

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/data/AirDataComputer.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import net.minecraft.tags.DamageTypeTags
1010
import net.minecraft.util.Mth
1111
import net.minecraft.world.damagesource.DamageSource
1212
import net.minecraft.world.phys.Vec3
13+
import ru.octol1ttle.flightassistant.FAKeyMappings
1314
import ru.octol1ttle.flightassistant.FlightAssistant
1415
import ru.octol1ttle.flightassistant.api.computer.Computer
1516
import ru.octol1ttle.flightassistant.api.computer.ComputerBus
@@ -77,6 +78,9 @@ class AirDataComputer(computers: ComputerBus, private val mc: Minecraft) : Compu
7778
}
7879

7980
fun automationsAllowed(checkFlying: Boolean = true): Boolean {
81+
if (FAKeyMappings.globalAutomationOverride.isDown) {
82+
return false
83+
}
8084
return (!checkFlying || flying) && (FAConfig.global.automationsAllowedInOverlays || (mc.screen == null && mc.overlay == null))
8185
}
8286

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class AlertComputer(computers: ComputerBus, private val soundManager: SoundManag
101101
.add(
102102
ComputerFaultAlert(
103103
computers, PitchComputer.ID, Component.translatable("alert.flightassistant.flight_controls.pitch_fault"), listOf(
104-
Component.translatable("alert.flightassistant.flight_controls.pitch_fault.use_manual_pitch"),
104+
Component.translatable("alert.flightassistant.flight_controls.pitch_fault.use_automation_override"),
105105
)))
106106
.add(ProtectionsLostAlert(computers))
107107
)

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class AutomationModesDisplay(computers: ComputerBus) : Display(computers) {
2727
}
2828

2929
override fun render(guiGraphics: GuiGraphics) {
30+
if (FAKeyMappings.globalAutomationOverride.isDown) {
31+
return
32+
}
3033
renderThrustMode(guiGraphics)
3134
renderPitchMode(guiGraphics)
3235
renderInput(guiGraphics, headingDisplay, computers.heading.activeInput)
@@ -76,10 +79,6 @@ class AutomationModesDisplay(computers: ComputerBus) : Display(computers) {
7679
}
7780

7881
private fun renderPitchMode(guiGraphics: GuiGraphics) {
79-
if (computers.pitch.manualOverride) {
80-
pitchDisplay.render(guiGraphics, Component.translatable("mode.flightassistant.vertical.override").setColor(cautionColor), ControlInput.Status.ACTIVE, cautionColor)
81-
return
82-
}
8382
renderInput(guiGraphics, pitchDisplay, computers.pitch.activeInput)
8483
}
8584

@@ -103,12 +102,14 @@ class AutomationModesDisplay(computers: ComputerBus) : Display(computers) {
103102
text.appendWithSeparation(Component.translatable("short.flightassistant.autopilot"))
104103
}
105104

106-
automationStatusDisplay.render(
107-
guiGraphics,
108-
if (text.siblings.isNotEmpty()) text else null, ControlInput.Status.ACTIVE,
105+
val color =
109106
if (computers.autoflight.autopilotAlert) warningColor
110107
else if (computers.autoflight.autoThrustAlert) cautionColor
111108
else null
109+
automationStatusDisplay.render(
110+
guiGraphics,
111+
if (text.siblings.isNotEmpty()) text else null, ControlInput.Status.ACTIVE,
112+
if (FATickCounter.totalTicks % 20 >= 10) color else null
112113
)
113114
}
114115

src/main/resources/assets/flightassistant/lang/en_us.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ alert.flightassistant: # TODO: get rid of alert categories, more flexible alert
4848
.: F/CTL
4949
pitch_fault:
5050
.: PITCH LIMIT FAULT
51-
use_manual_pitch: ' -MAN PITCH OVRD: USE'
51+
use_automation_override: ' -AUTOMATION OVERRIDE: USE'
5252
protections_lost:
5353
.: PROTECT LOST
5454
enable_air_data: ' -AIR DATA: OFF THEN ON'
@@ -332,7 +332,6 @@ menu.flightassistant:
332332

333333
mode.flightassistant:
334334
thrust:
335-
override: THR OVRD # TODO: single key to override all
336335
manual:
337336
.: MAN THR
338337
reverse: MAN REV
@@ -347,7 +346,6 @@ mode.flightassistant:
347346
takeoff: THR TO # TODO: fix confusion with TOGA somehow
348347
landing: THR LAND
349348
vertical:
350-
override: PITCH OVRD # TODO: single key to override all
351349
void_protection: VOID PROT
352350
void_escape: VOID ESC
353351
stall_protection: STALL PROT
@@ -422,7 +420,7 @@ key.flightassistant:
422420
toggle_enabled: Toggle mod enabled
423421
open_flightassistant_setup: Open FlightAssistant setup screen
424422
autopilot_disconnect: Disconnect autopilot
425-
manual_pitch_override: Manual pitch override (hold)
423+
global_automation_override: Global automation override (hold)
426424
hide_current_alert: Hide currently active alert
427425
show_hidden_alert: Show last hidden alert
428426
thrust:

src/main/resources/assets/flightassistant/lang/ru_ru.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ alert.flightassistant:
5252
.: УПР/ПОЛЕТ
5353
pitch_fault:
5454
.: ОТКАЗ ОГРАН УГЛА НАКЛ
55-
use_manual_pitch: ' -РУЧН УПР УГЛ НАКЛ: ИСПОЛЬЗ'
55+
use_automation_override: ' -ПРИНУД ОТКЛ АВТОМАТ: ИСПОЛЬЗ'
5656
protections_lost:
5757
.: ЗАЩИТЫ ПОТЕРЯНЫ
5858
enable_air_data: ' -КОМП ДАННЫХ ПОЛЕТА: ВЫКЛ ЗАТЕМ ВКЛ'
@@ -425,7 +425,7 @@ key.flightassistant:
425425
toggle_enabled: Включить/выключить мод
426426
open_flight_setup: Открыть экран настройки полёта
427427
autopilot_disconnect: Отключить автопилот
428-
manual_pitch_override: Принудительное ручное управление углом наклона (зажать)
428+
global_automation_override: Принудительное отключение автоматики (зажать)
429429
hide_current_alert: Скрыть активное предупреждение
430430
show_hidden_alert: Показать скрытое предупреждение
431431
thrust:

0 commit comments

Comments
 (0)