Skip to content

Commit

Permalink
Make sure pitch ladder doesn't interfere with flight mode display
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <[email protected]>
  • Loading branch information
Octol1ttle committed Mar 1, 2024
1 parent f2d93d9 commit fc7c3ec
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void drawReferenceMark(DrawContext context, float degrees, int yHorizon,

int y = MathHelper.floor((-degrees * dim.degreesPerPixel) + yHorizon);

if (y < dim.tFrame || y > dim.bFrame) {
if (outOfFrame(y)) {
return;
}

Expand All @@ -94,7 +94,7 @@ private void drawReferenceMark(DrawContext context, float degrees, int yHorizon,
}

private void drawDegreeBar(TextRenderer textRenderer, DrawContext context, float degree, int y) {
if (y < dim.tFrame || y > dim.bFrame) {
if (outOfFrame(y)) {
return;
}

Expand Down Expand Up @@ -122,7 +122,7 @@ private void drawPushArrows(TextRenderer textRenderer, DrawContext context, floa
for (float f = degrees; f <= 90; f += 10) {
int y = MathHelper.floor((-f * dim.degreesPerPixel) + yHorizon);

if (y < dim.tFrame || y > dim.bFrame) {
if (outOfFrame(y)) {
continue;
}
context.getMatrices().push();
Expand All @@ -141,13 +141,17 @@ private void drawPullArrows(TextRenderer textRenderer, DrawContext context, floa
for (float f = degrees; f >= -90; f -= 10) {
int y = MathHelper.floor((-f * dim.degreesPerPixel) + yHorizon);

if (y < dim.tFrame || y > dim.bFrame) {
if (outOfFrame(y)) {
continue;
}
drawMiddleAlignedText(textRenderer, context, text, dim.xMid, y, color);
}
}

private boolean outOfFrame(int y) {
return y < dim.tFrame || y > dim.bFrame - 20;
}

@Override
public void renderFaulted(DrawContext context, TextRenderer textRenderer) {
drawMiddleAlignedText(textRenderer, context, Text.translatable("flightassistant.pitch_short"), dim.xMid, dim.yMid - 10, FAConfig.indicator().warningColor);
Expand Down

0 comments on commit fc7c3ec

Please sign in to comment.