mirror of
https://github.com/JonasunderscoreJones/Microcraft.git
synced 2025-10-26 03:59:19 +01:00
added board icon selection screen
This commit is contained in:
parent
5c34c3d4ee
commit
5b0ce01fde
15 changed files with 139 additions and 71 deletions
|
|
@ -0,0 +1,7 @@
|
|||
package me.jonasjones.microcraft.board;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public record MicrocontrollerBoardIcon(Identifier boardTextureHorizontal, Identifier boardTextureVertical, int width, int height) {}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import me.jonasjones.microcraft.gui.widget.ArduinoNanoWidget;
|
||||
import me.jonasjones.microcraft.gui.widget.BoardConfigwidget;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
|
@ -30,7 +30,7 @@ public class BoardScreen extends Screen {
|
|||
this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> {
|
||||
this.client.setScreen(this.parent);
|
||||
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
|
||||
this.client.setScreen(new ArduinoNanoWidget(this.parent));
|
||||
this.client.setScreen(new BoardConfigwidget(this.parent));
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package me.jonasjones.microcraft.gui.screens.board;
|
||||
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import static me.jonasjones.microcraft.gui.widget.BoardConfigwidget.BOARD_TEXTURE;
|
||||
|
||||
public class BoardIconSelectionScreen extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
private final MicrocontrollerBoardIcon NANO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano.png"), 128, 52);
|
||||
private final MicrocontrollerBoardIcon UNO_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-uno-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-uno.png"), 128, 90);
|
||||
private final MicrocontrollerBoardIcon PROMINI_BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-pro_mini.png"), 97, 52);
|
||||
|
||||
public BoardIconSelectionScreen(Screen parent) {
|
||||
super(Text.of("Select Board Icon"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 138, this.height / 2 - 85, NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), 0, 0, 0, NANO_BOARD_TEXTURE.boardTextureHorizontal(), NANO_BOARD_TEXTURE.width(), NANO_BOARD_TEXTURE.height(), (buttonWidget) -> {
|
||||
BOARD_TEXTURE = NANO_BOARD_TEXTURE;
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 138, this.height / 2 - 20, UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), 0, 0, 0, UNO_BOARD_TEXTURE.boardTextureHorizontal(), UNO_BOARD_TEXTURE.width(), UNO_BOARD_TEXTURE.height(), (buttonWidget) -> {
|
||||
BOARD_TEXTURE = UNO_BOARD_TEXTURE;
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 + 10, this.height / 2 - 85, PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), 0, 0, 0, PROMINI_BOARD_TEXTURE.boardTextureHorizontal(), PROMINI_BOARD_TEXTURE.width(), PROMINI_BOARD_TEXTURE.height(), (buttonWidget) -> {
|
||||
BOARD_TEXTURE = PROMINI_BOARD_TEXTURE;
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Cancel"), (button) -> {
|
||||
this.client.setScreen(this.parent);
|
||||
}).dimensions(this.width / 2 - 100, this.height / 6 + 168, 200, 20).build());
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package me.jonasjones.microcraft.gui.widget;
|
||||
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.gui.screens.ModSettings;
|
||||
import me.jonasjones.microcraft.gui.screens.board.AdvancedPinMappingScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.board.AdvancedSettingsScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.board.ProfileSelectionScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.ModCreditsScreen;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ScrollableWidget;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ArduinoNanoWidget extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
Identifier BOARD_TEXTURE = new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano.png");
|
||||
|
||||
public ArduinoNanoWidget (Screen parent) {
|
||||
super(Text.of("Microcraft Configuration"));
|
||||
this.parent = parent;
|
||||
}
|
||||
protected void init() {
|
||||
//TODO: get current profile
|
||||
addDrawableChild(ButtonWidget.builder(Text.of("[Profile]"), (buttonWidget) -> this.client.setScreen(new ProfileSelectionScreen(this))).dimensions(this.width / 2 - 100, 40, 200, 20).build());
|
||||
|
||||
//TODO: make Board texture clickable to select different texture.
|
||||
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 26, this.height / 2 - 65, 52, 130, 0, 0, 130, BOARD_TEXTURE, 52, 130, (buttonWidget) -> this.client.setScreen(this)));
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("About Microcraft"), (buttonWidget) -> this.client.setScreen(new ModCreditsScreen(this))).dimensions(this.width / 2 - 100, this.height - 30, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Advanced Pin Mapping"), (buttonWidget) -> this.client.setScreen(new AdvancedPinMappingScreen(this))).dimensions(this.width / 2 - 100, this.height - 55, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Advanced Board Settings"), (buttonWidget) -> this.client.setScreen(new AdvancedSettingsScreen(this))).dimensions(this.width / 2 - 100, this.height - 80, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(getToggleText(), (buttonWidget) -> Microcraft.toggle()).dimensions(this.width / 2 - 100, this.height - 105, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Done"), (buttonWidget) -> this.client.setScreen(this.parent)).dimensions(this.width - 60, this.height - 30, 50, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Write Program to Board"), (buttonWidget) -> this.client.setScreen(this.parent)).dimensions(this.width - 210, this.height - 30, 140, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Microcraft Settings"), (buttonWidget) -> this.client.setScreen(new ModSettings(this))).dimensions(this.width - 210, this.height - 55, 200, 20).build());
|
||||
|
||||
|
||||
}
|
||||
private Text getToggleText() {
|
||||
if (Microcraft.enabled) {
|
||||
return Text.of("Microcraft: enabled");
|
||||
} else {
|
||||
return Text.of("Microcraft: disabled");
|
||||
}
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package me.jonasjones.microcraft.gui.widget;
|
||||
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.board.MicrocontrollerBoardIcon;
|
||||
import me.jonasjones.microcraft.gui.screens.ModSettings;
|
||||
import me.jonasjones.microcraft.gui.screens.board.AdvancedPinMappingScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.board.AdvancedSettingsScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.board.BoardIconSelectionScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.board.ProfileSelectionScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.ModCreditsScreen;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.client.gui.widget.TexturedButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class BoardConfigwidget extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
//public static Identifier BOARD_TEXTURE = new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano.png");
|
||||
|
||||
public static MicrocontrollerBoardIcon BOARD_TEXTURE = new MicrocontrollerBoardIcon(new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano-sideways.png"), new Identifier(Microcraft.MOD_ID, "textures/boards/arduino-nano.png"), 128, 52);
|
||||
|
||||
public BoardConfigwidget(Screen parent) {
|
||||
super(Text.of("Microcraft Configuration"));
|
||||
this.parent = parent;
|
||||
}
|
||||
protected void init() {
|
||||
//TODO: get current profile
|
||||
addDrawableChild(ButtonWidget.builder(Text.of("[Profile]"), (buttonWidget) -> this.client.setScreen(new ProfileSelectionScreen(this))).dimensions(this.width / 2 - 50, this.height - 52, 100, 20).build());
|
||||
|
||||
//TODO: make Board texture clickable to select different texture.
|
||||
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - (BOARD_TEXTURE.height() / 2), this.height / 2 - (BOARD_TEXTURE.height() / 2) - 45, BOARD_TEXTURE.height(), BOARD_TEXTURE.width(), 0, 0, 0, BOARD_TEXTURE.boardTextureVertical(), BOARD_TEXTURE.height(), BOARD_TEXTURE.width(), (buttonWidget) -> this.client.setScreen(new BoardIconSelectionScreen(this))));
|
||||
|
||||
/*this.addDrawableChild(ButtonWidget.builder(Text.of("About Microcraft"), (buttonWidget) -> this.client.setScreen(new ModCreditsScreen(this))).dimensions(10, this.height - 30, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Advanced Pin Mapping"), (buttonWidget) -> this.client.setScreen(new AdvancedPinMappingScreen(this))).dimensions(this.width / 2 - 100, this.height - 55, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Advanced Board Settings"), (buttonWidget) -> this.client.setScreen(new AdvancedSettingsScreen(this))).dimensions(this.width / 2 - 100, this.height - 80, 200, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Done"), (buttonWidget) -> this.client.setScreen(this.parent)).dimensions(this.width - 60, this.height - 30, 50, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Write to Board and Quit"), (buttonWidget) -> this.client.setScreen(this.parent)).dimensions(this.width - 210, this.height - 30, 140, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Microcraft Settings"), (buttonWidget) -> this.client.setScreen(new ModSettings(this))).dimensions(this.width - 210, this.height - 55, 200, 20).build());*/
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("About"), (buttonWidget) -> this.client.setScreen(new ModCreditsScreen(this)))
|
||||
.dimensions(this.width / 2 - 154, this.height - 28, 75, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Pin Mapping"), (buttonWidget) -> this.client.setScreen(new AdvancedPinMappingScreen(this)))
|
||||
.dimensions(this.width / 2 + 4 + 50, this.height - 52, 100, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Board Settings"), (buttonWidget) -> this.client.setScreen(new AdvancedSettingsScreen(this)))
|
||||
.dimensions(this.width / 2 - 154, this.height - 52, 100, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Done"), (buttonWidget) -> this.client.setScreen(this.parent))
|
||||
.dimensions(this.width / 2 + 4 + 76, this.height - 28, 75, 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Save"), (buttonWidget) -> this.client.setScreen(this.parent))
|
||||
.dimensions(this.width / 2, this.height - 28, 75 , 20).build());
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.of("Settings"), (buttonWidget) -> this.client.setScreen(new ModSettings(this)))
|
||||
.dimensions(this.width / 2 - 75, this.height - 28, 70, 20).build());
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 16777215);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue