Skip to content

Commit ca1c29e

Browse files
committed
draw reference marks for maximum pitch with no thrust, optimum glide pitch, minimum pitch for safe descent rate
Closes #58 Signed-off-by: Octol1ttle <[email protected]>
1 parent 9df09ee commit ca1c29e

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

src/main/kotlin/ru/octol1ttle/flightassistant/api/util/extensions/StringExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ fun String.toFloatOrNullWithFallback(): Float? {
2525
}
2626

2727
fun String.formatRoot(vararg args: Any?): String {
28-
return this.format(Locale.ROOT, args)
28+
return this.format(Locale.ROOT, *args)
2929
}

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

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class AttitudeDisplay(computers: ComputerBus) : Display(computers) {
5050
if (FAConfig.display.showAttitude == DisplayOptions.AttitudeDisplayMode.HORIZON_AND_LADDER) {
5151
renderPitchBars()
5252
renderPitchLimits()
53+
drawPitchReferenceMark(47.5f)
54+
drawPitchReferenceMark(-2.2f)
55+
drawPitchReferenceMark(-38.5f)
5356
}
5457
if (!FAConfig.display.drawPitchOutsideFrame) {
5558
disableScissor()
@@ -122,18 +125,23 @@ class AttitudeDisplay(computers: ComputerBus) : Display(computers) {
122125
}
123126
}
124127

128+
private fun GuiGraphics.drawPitchReferenceMark(pitch: Float) {
129+
val y = ScreenSpace.getY(pitch) ?: return
130+
131+
val color: Int = getPitchBarColor(pitch)
132+
val leftXEnd: Int = (centerXF - halfWidth * 0.025f).toInt()
133+
val leftXStart: Int = (leftXEnd - halfWidth * 0.05f).toInt()
134+
hLineDashed(leftXStart, leftXEnd, y, 2, color)
135+
136+
val rightXStart: Int = (centerXF + halfWidth * 0.025f).toInt()
137+
val rightXEnd: Int = (rightXStart + halfWidth * 0.05f).toInt()
138+
hLineDashed(rightXStart, rightXEnd, y, 2, color)
139+
}
140+
125141
private fun GuiGraphics.drawPitchBar(pitch: Int, y: Int) {
126142
if (pitch == 0) return
127143

128-
val min: ControlInput? = computers.pitch.minimumPitch
129-
val max: ControlInput? = computers.pitch.maximumPitch
130-
val color: Int =
131-
if (max != null && pitch > max.target)
132-
if (max.status == ControlInput.Status.ACTIVE) warningColor else cautionColor
133-
else if (min != null && pitch < min.target)
134-
if (min.status == ControlInput.Status.ACTIVE) warningColor else cautionColor
135-
else
136-
primaryColor
144+
val color: Int = getPitchBarColor(pitch.toFloat())
137145

138146
val leftXEnd: Int = (centerXF - halfWidth * 0.05f).toInt()
139147
val leftXStart: Int = (leftXEnd - halfWidth * 0.075f).toInt()
@@ -148,6 +156,17 @@ class AttitudeDisplay(computers: ComputerBus) : Display(computers) {
148156
drawString(pitch.toString(), rightXEnd + 4, if (pitch > 0) y else y - 4, color)
149157
}
150158

159+
private fun getPitchBarColor(pitch: Float): Int {
160+
val min: ControlInput? = computers.pitch.minimumPitch
161+
val max: ControlInput? = computers.pitch.maximumPitch
162+
return if (max != null && pitch > max.target)
163+
if (max.status == ControlInput.Status.ACTIVE) warningColor else cautionColor
164+
else if (min != null && pitch < min.target)
165+
if (min.status == ControlInput.Status.ACTIVE) warningColor else cautionColor
166+
else
167+
primaryColor
168+
}
169+
151170
private fun GuiGraphics.renderPitchTarget(x: Int, y: Int) {
152171
val active: AutoFlightComputer.VerticalMode? = computers.autoflight.activeVerticalMode
153172
if (computers.autoflight.getPitchInput() != null && active is AutoFlightComputer.FollowsPitchMode) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FlightDirectorsDisplay(computers: ComputerBus) : Display(computers) {
2121
override fun allowedByConfig(): Boolean = true
2222

2323
override fun render(guiGraphics: GuiGraphics) {
24-
if (!computers.autoflight.flightDirectors) {
24+
if (!computers.autoflight.flightDirectors || computers.hudData.isViewMirrored) {
2525
return
2626
}
2727

0 commit comments

Comments
 (0)