Skip to content

Commit

Permalink
feat: command to reset faulted indicators
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <[email protected]>
  • Loading branch information
Octol1ttle committed Nov 21, 2023
1 parent b16be93 commit 3ab202b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ru.octol1ttle.flightassistant.alerts.ECAMSoundData;
import ru.octol1ttle.flightassistant.commands.ResetAllComputersCommand;
import ru.octol1ttle.flightassistant.commands.ResetFaultedComputersCommand;
import ru.octol1ttle.flightassistant.commands.ResetFaultedIndicatorsCommand;
import ru.octol1ttle.flightassistant.commands.SetAutoThrustSpeedCommand;
import ru.octol1ttle.flightassistant.commands.SwitchDisplayModeCommand;
import ru.octol1ttle.flightassistant.computers.ComputerHost;
Expand Down Expand Up @@ -98,7 +99,9 @@ private static void setupKeycCode() {
private static void setupCommand() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
LiteralCommandNode<FabricClientCommandSource> node = dispatcher.register(literal("flightassistant")
.then(literal("toggle").executes(new SwitchDisplayModeCommand()))
.then(literal("toggle").executes(
new SwitchDisplayModeCommand())
)
.then(literal("speed")
.then(argument("targetSpeed", IntegerArgumentType.integer(10, 30))
.executes(new SetAutoThrustSpeedCommand())))
Expand All @@ -109,6 +112,9 @@ private static void setupCommand() {
.then(literal("faulted")
.executes(new ResetFaultedComputersCommand()))
)
.then(literal("indicators")
.executes(new ResetFaultedIndicatorsCommand())
)
)
);
dispatcher.register(literal("flas").redirect(node));
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/ru/octol1ttle/flightassistant/HudRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,21 @@ public void render(DrawContext context, MinecraftClient mc) {
context.getMatrices().pop();
}

public void resetFaulted() {
for (HudComponent component : faulted) {
faulted.remove(component);
components.add(component);
}
}

@Override
public void render(DrawContext context, TextRenderer textRenderer) {
throw new IllegalStateException();
}

@Override
public void renderFaulted(DrawContext context, TextRenderer textRenderer) {

throw new IllegalStateException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ru.octol1ttle.flightassistant.commands;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import ru.octol1ttle.flightassistant.HudRenderer;

public class ResetFaultedIndicatorsCommand implements Command<FabricClientCommandSource> {
@Override
public int run(CommandContext<FabricClientCommandSource> context) {
if (HudRenderer.INSTANCE != null) {
HudRenderer.INSTANCE.resetFaulted();
}
return 0;
}
}

0 comments on commit 3ab202b

Please sign in to comment.