-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "clear all" button to logic workbench, see #2
- Loading branch information
Showing
8 changed files
with
108 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/malte0811/controlengineering/gui/misc/ConfirmScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package malte0811.controlengineering.gui.misc; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import malte0811.controlengineering.ControlEngineering; | ||
import malte0811.controlengineering.gui.StackedScreen; | ||
import net.minecraft.client.gui.components.Button; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.TranslatableComponent; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class ConfirmScreen extends StackedScreen { | ||
public static final String OK_KEY = ControlEngineering.MODID + ".gui.ok"; | ||
public static final String CANCEL_KEY = ControlEngineering.MODID + ".gui.cancel"; | ||
|
||
private final Runnable onOk; | ||
|
||
public ConfirmScreen(Component message, Runnable onOk) { | ||
super(message); | ||
this.onOk = onOk; | ||
} | ||
|
||
protected void init() { | ||
super.init(); | ||
addRenderableWidget(new Button( | ||
this.width / 2 - 155, 110, | ||
150, 20, | ||
new TranslatableComponent(OK_KEY), | ||
$ -> { | ||
onOk.run(); | ||
onClose(); | ||
} | ||
)); | ||
addRenderableWidget(new Button( | ||
this.width / 2 - 155 + 160, 110, | ||
150, 20, | ||
new TranslatableComponent(CANCEL_KEY), $ -> onClose() | ||
)); | ||
} | ||
|
||
@Override | ||
protected void renderForeground(@Nonnull PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { | ||
drawCenteredString(matrixStack, this.font, this.title, this.width / 2, 90, -1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/malte0811/controlengineering/network/logic/ClearAll.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package malte0811.controlengineering.network.logic; | ||
|
||
import malte0811.controlengineering.logic.schematic.Schematic; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.world.level.Level; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public class ClearAll extends LogicSubPacket { | ||
public ClearAll() {} | ||
|
||
public ClearAll(FriendlyByteBuf buffer) {} | ||
|
||
@Override | ||
protected void write(FriendlyByteBuf out) {} | ||
|
||
@Override | ||
public boolean process(Schematic applyTo, Consumer<Schematic> replace, Level level) { | ||
applyTo.clear(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters