updated .gitignore
|
|
@ -1,25 +1,32 @@
|
|||
package me.jonasjones.arduinoctrls;
|
||||
package me.jonasjones.microcraft;
|
||||
|
||||
import me.jonasjones.arduinoctrls.config.ModConfigs;
|
||||
import me.jonasjones.arduinoctrls.debug.LedBlink;
|
||||
import me.jonasjones.arduinoctrls.util.VerboseLogger;
|
||||
import me.jonasjones.microcraft.config.ModConfigs;
|
||||
import me.jonasjones.microcraft.util.boardmanager.SerialNumberScanner;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ArduinoControls implements ClientModInitializer {
|
||||
import java.io.IOException;
|
||||
|
||||
public class Microcraft implements ClientModInitializer {
|
||||
// This logger is used to write text to the console and the log file.
|
||||
// It is considered best practice to use your mod id as the logger's name.
|
||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
||||
|
||||
public static final String MOD_ID = "arduinoctrls";
|
||||
public static final String MOD_ID = "microcraft";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
public static Logger VERBOSELOGGER = LoggerFactory.getLogger(MOD_ID + " - VERBOSE LOGGER");
|
||||
|
||||
public static boolean enabled = true;
|
||||
|
||||
public static void toggle() {
|
||||
enabled = !enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
//message from mod to confirm that it has been loaded
|
||||
LOGGER.info("UwU from Arduino Controls!");
|
||||
LOGGER.info("Microcraft Initialized!");
|
||||
|
||||
// register configs
|
||||
ModConfigs.registerConfigs();
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package me.jonasjones.microcraft.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
public class BoardsConfig {
|
||||
|
||||
public BoardsConfig() {
|
||||
}
|
||||
|
||||
// DON'T TOUCH THE FOLLOWING CODE
|
||||
private static BoardsConfig instance;
|
||||
|
||||
public static BoardsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = fromDefaults();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void load(File file) {
|
||||
instance = fromFile(file);
|
||||
|
||||
// no config file found
|
||||
if (instance == null) {
|
||||
instance = fromDefaults();
|
||||
}
|
||||
}
|
||||
|
||||
public static void load(String file) {
|
||||
load(new File(file));
|
||||
}
|
||||
|
||||
private static BoardsConfig fromDefaults() {
|
||||
BoardsConfig config = new BoardsConfig();
|
||||
return config;
|
||||
}
|
||||
|
||||
public void toFile(String file) {
|
||||
toFile(new File(file));
|
||||
}
|
||||
|
||||
public void toFile(File file) {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String jsonConfig = gson.toJson(this);
|
||||
FileWriter writer;
|
||||
try {
|
||||
writer = new FileWriter(file);
|
||||
writer.write(jsonConfig);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static BoardsConfig fromFile(File configFile) {
|
||||
try {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile)));
|
||||
return gson.fromJson(reader, BoardsConfig.class);
|
||||
} catch (FileNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
return gson.toJson(this);
|
||||
}}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package me.jonasjones.arduinoctrls.config;
|
||||
package me.jonasjones.microcraft.config;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import me.jonasjones.arduinoctrls.config.SimpleConfig.DefaultConfig;
|
||||
import me.jonasjones.microcraft.config.SimpleConfig.DefaultConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package me.jonasjones.arduinoctrls.config;
|
||||
package me.jonasjones.microcraft.config;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import me.jonasjones.arduinoctrls.ArduinoControls;
|
||||
import me.jonasjones.arduinoctrls.util.VerboseLogger;
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.util.VerboseLogger;
|
||||
|
||||
public class ModConfigs {
|
||||
public static SimpleConfig CONFIGMAIN;
|
||||
|
|
@ -45,8 +45,8 @@ public class ModConfigs {
|
|||
|
||||
createConfigs();
|
||||
|
||||
CONFIGMAIN = SimpleConfig.of(ArduinoControls.MOD_ID + "-main").provider(configMain).request();
|
||||
CONFIGLISTS = SimpleConfig.of(ArduinoControls.MOD_ID + "-lists").provider(configLists).request();
|
||||
CONFIGMAIN = SimpleConfig.of(Microcraft.MOD_ID + "-main").provider(configMain).request();
|
||||
CONFIGLISTS = SimpleConfig.of(Microcraft.MOD_ID + "-lists").provider(configLists).request();
|
||||
|
||||
assignConfigs();
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package me.jonasjones.arduinoctrls.config;
|
||||
package me.jonasjones.microcraft.config;
|
||||
/*
|
||||
* Copyright (c) 2021 magistermaks
|
||||
* Slightly modified by Jonas_Jones 2022
|
||||
|
|
@ -22,8 +22,8 @@ package me.jonasjones.arduinoctrls.config;
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import me.jonasjones.arduinoctrls.ArduinoControls;
|
||||
import me.jonasjones.arduinoctrls.util.VerboseLogger;
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.util.VerboseLogger;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -138,13 +138,13 @@ public class SimpleConfig {
|
|||
String identifier = "Config '" + request.filename + "'";
|
||||
|
||||
if (!request.file.exists()) {
|
||||
ArduinoControls.LOGGER.info(identifier + " is missing, generating default one...");
|
||||
Microcraft.LOGGER.info(identifier + " is missing, generating default one...");
|
||||
|
||||
try {
|
||||
createConfig();
|
||||
} catch (IOException e) {
|
||||
ArduinoControls.LOGGER.error(identifier + " failed to generate!");
|
||||
ArduinoControls.LOGGER.trace(String.valueOf(e));
|
||||
Microcraft.LOGGER.error(identifier + " failed to generate!");
|
||||
Microcraft.LOGGER.trace(String.valueOf(e));
|
||||
broken = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -153,8 +153,8 @@ public class SimpleConfig {
|
|||
try {
|
||||
loadConfig();
|
||||
} catch (Exception e) {
|
||||
ArduinoControls.LOGGER.error(identifier + " failed to load!");
|
||||
ArduinoControls.LOGGER.trace(String.valueOf(e));
|
||||
Microcraft.LOGGER.error(identifier + " failed to load!");
|
||||
Microcraft.LOGGER.trace(String.valueOf(e));
|
||||
broken = true;
|
||||
}
|
||||
}
|
||||
12
src/main/java/me/jonasjones/microcraft/data/BoardData.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package me.jonasjones.microcraft.data;
|
||||
|
||||
public class BoardData {
|
||||
public int arduinoNanoPins = 22;
|
||||
|
||||
public enum board {
|
||||
Custom,
|
||||
ArduinoNano,
|
||||
ArduinoUno,
|
||||
ArduinoProMini
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import me.jonasjones.microcraft.gui.widget.ArduinoNanoWidget;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class BoardScreen extends Screen {
|
||||
private final Screen parent;
|
||||
|
||||
public BoardScreen (Screen parent) {
|
||||
super(Text.of("Microcraft Configuration"));
|
||||
this.parent = parent;
|
||||
}
|
||||
protected void init() {
|
||||
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height / 6 + 12, 150, 20, Text.of("Configure Microcontrollers"), (button) -> {
|
||||
this.client.setScreen(new SelectDevice(this));
|
||||
}));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Configure Microcraft"), (button) -> {
|
||||
this.client.setScreen(new ModSettings(this));
|
||||
}));
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, ScreenTexts.DONE, (button) -> {
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.client.setScreen(new ArduinoNanoWidget(this.parent));
|
||||
}
|
||||
|
||||
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,4 +1,4 @@
|
|||
package me.jonasjones.arduinoctrls.gui.screens;
|
||||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
|
@ -13,7 +13,7 @@ public class GuiHome extends Screen {
|
|||
private final Screen parent;
|
||||
|
||||
public GuiHome (Screen parent) {
|
||||
super(Text.of("MicrocontrollerMC Controls"));
|
||||
super(Text.of("Microcraft Configuration"));
|
||||
this.parent = parent;
|
||||
}
|
||||
protected void init() {
|
||||
|
|
@ -22,13 +22,14 @@ public class GuiHome extends Screen {
|
|||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height / 6 + 12, 150, 20, Text.of("Configure Microcontrollers"), (button) -> {
|
||||
this.client.setScreen(new SelectDevice(this));
|
||||
}));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Configure MicrocontrollerMC"), (button) -> {
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Configure Microcraft"), (button) -> {
|
||||
this.client.setScreen(new ModSettings(this));
|
||||
}));
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, ScreenTexts.DONE, (button) -> {
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false));
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
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;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModCreditsScreen extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
public ModCreditsScreen(Screen parent) {
|
||||
super(Text.of("About Microcraft"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
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,4 +1,4 @@
|
|||
package me.jonasjones.arduinoctrls.gui.screens;
|
||||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package me.jonasjones.arduinoctrls.gui.screens;
|
||||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package me.jonasjones.arduinoctrls.gui.screens;
|
||||
package me.jonasjones.microcraft.gui.screens;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
|
@ -49,10 +49,10 @@ public class SelectDevice extends Screen {
|
|||
this.client.keyboard.setRepeatEvents(true);
|
||||
this.searchBox = new TextFieldWidget(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.searchBox, Text.translatable("selectWorld.search"));
|
||||
this.searchBox.setChangedListener((search) -> {
|
||||
this.levelList.filter(search);
|
||||
//this.levelList.filter(search);
|
||||
});
|
||||
SelectWorldScreen uwu = new SelectWorldScreen(this);
|
||||
this.levelList = new WorldListWidget(uwu, this.client, this.width, this.height, 48, this.height - 64, 36, this.getSearchFilter(), this.levelList);
|
||||
//this.levelList = new WorldListWidget(uwu, this.client, this.width, this.height, 48, this.height - 64, 36, this.getSearchFilter(), this.levelList);
|
||||
this.addSelectableChild(this.searchBox);
|
||||
this.addSelectableChild(this.levelList);
|
||||
this.selectButton = (ButtonWidget)this.addDrawableChild(new ButtonWidget(this.width / 2 - 154, this.height - 52, 150, 20, Text.translatable("selectWorld.select"), (button) -> {
|
||||
|
|
@ -91,7 +91,7 @@ public class SelectDevice extends Screen {
|
|||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.tooltip = null;
|
||||
this.levelList.render(matrices, mouseX, mouseY, delta);
|
||||
//this.levelList.render(matrices, mouseX, mouseY, delta);
|
||||
this.searchBox.render(matrices, mouseX, mouseY, delta);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 8, 16777215);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package me.jonasjones.microcraft.gui.screens.board;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class AdvancedPinMappingScreen extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
public AdvancedPinMappingScreen(Screen parent) {
|
||||
super(Text.of("Advanced Pin Mapping"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
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,21 @@
|
|||
package me.jonasjones.microcraft.gui.screens.board;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class AdvancedSettingsScreen extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
public AdvancedSettingsScreen(Screen parent) {
|
||||
super(Text.of("Advanced Board Settings"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
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,24 @@
|
|||
package me.jonasjones.microcraft.gui.screens.board;
|
||||
|
||||
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;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ProfileSelectionScreen extends Screen {
|
||||
|
||||
private final Screen parent;
|
||||
|
||||
public ProfileSelectionScreen(Screen parent) {
|
||||
super(Text.of("Profile Selection Screen"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
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,42 @@
|
|||
package me.jonasjones.microcraft.gui.screens.board;
|
||||
|
||||
import me.jonasjones.microcraft.gui.screens.ModSettings;
|
||||
import me.jonasjones.microcraft.gui.screens.SelectDevice;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class TextureSelectScreen extends Screen {
|
||||
private final Screen parent;
|
||||
|
||||
public TextureSelectScreen(Screen parent) {
|
||||
super(Text.of("Microcraft Configuration"));
|
||||
this.parent = parent;
|
||||
}
|
||||
protected void init() {
|
||||
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 155, this.height / 6 + 12, 150, 20, Text.of("Configure Microcontrollers"), (button) -> {
|
||||
this.client.setScreen(new SelectDevice(this));
|
||||
}));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 + 5, this.height / 6 + 12, 150, 20, Text.of("Configure Microcraft"), (button) -> {
|
||||
this.client.setScreen(new ModSettings(this));
|
||||
}));
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 168, 200, 20, ScreenTexts.DONE, (button) -> {
|
||||
this.client.setScreen(this.parent);
|
||||
}));
|
||||
this.addDrawableChild(new net.minecraft.client.gui.widget.CheckboxWidget(50, 50, 100, 20, Text.of("uwu checkbox"), false));
|
||||
}
|
||||
|
||||
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,70 @@
|
|||
//
|
||||
// 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(new ButtonWidget(this.width / 2 - 100, 40, 200, 20, Text.of("[Profile]"), (buttonWidget) -> this.client.setScreen(new ProfileSelectionScreen(this))));
|
||||
|
||||
//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(new ButtonWidget(this.width / 2 - 100, this.height - 30, 200, 20, Text.of("About Microcraft"), (buttonWidget) -> this.client.setScreen(new ModCreditsScreen(this))));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 55, 200, 20, Text.of("Advanced Pin Mapping"), (buttonWidget) -> this.client.setScreen(new AdvancedPinMappingScreen(this))));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 80, 200, 20, Text.of("Advanced Board Settings"), (buttonWidget) -> this.client.setScreen(new AdvancedSettingsScreen(this))));
|
||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height - 105, 200, 20, getToggleText(), (buttonWidget) -> Microcraft.toggle()));
|
||||
this.addDrawableChild(new ButtonWidget(this.width - 60, this.height - 30, 50, 20, Text.of("Done"), (buttonWidget) -> this.client.setScreen(this.parent)));
|
||||
this.addDrawableChild(new ButtonWidget(this.width - 210, this.height - 30, 140, 20, Text.of("Write Program to Board"), (buttonWidget) -> this.client.setScreen(this.parent)));
|
||||
this.addDrawableChild(new ButtonWidget(this.width - 210, this.height - 55, 200, 20, Text.of("Microcraft Settings"), (buttonWidget) -> this.client.setScreen(new ModSettings(this))));
|
||||
|
||||
this.addDrawableChild(new )
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package me.jonasjones.arduinoctrls.mixin;
|
||||
package me.jonasjones.microcraft.mixin;
|
||||
|
||||
import me.jonasjones.arduinoctrls.gui.screens.GuiHome;
|
||||
import me.jonasjones.microcraft.gui.screens.GuiHome;
|
||||
import net.minecraft.client.gui.screen.GameMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
|
@ -12,16 +12,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.jonasjones.microcraft.Microcraft.MOD_ID;
|
||||
|
||||
@Mixin(GameMenuScreen.class)
|
||||
public class GameMenuScreenMixin extends Screen {
|
||||
final Identifier ICON_TEXTURE = new Identifier("arduinoctrls", "logo_16x9.png");
|
||||
|
||||
protected GameMenuScreenMixin(Text title) {super(title);}
|
||||
|
||||
|
||||
@Inject(at = @At("HEAD"),method = "initWidgets")
|
||||
private void gameMenuScreenButton(CallbackInfo ci) {
|
||||
final Identifier ICON_TEXTURE = new Identifier("arduinoctrls", "gui/button_icon.png");
|
||||
final Identifier ICON_TEXTURE = new Identifier(MOD_ID, "gui/button_icon.png");
|
||||
|
||||
int buttonX = this.width / 2 + 108;
|
||||
int buttonY = this.height / 4 + 8;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package me.jonasjones.arduinoctrls.mixin;
|
||||
package me.jonasjones.microcraft.mixin;
|
||||
|
||||
import me.jonasjones.arduinoctrls.gui.screens.GuiHome;
|
||||
import me.jonasjones.microcraft.gui.screens.BoardScreen;
|
||||
import me.jonasjones.microcraft.gui.screens.GuiHome;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
|
|
@ -12,23 +13,25 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static me.jonasjones.microcraft.Microcraft.MOD_ID;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public abstract class ArduinoMixin extends Screen {
|
||||
protected ArduinoMixin(Text title) {
|
||||
public abstract class TitleScreenButtonMixin extends Screen {
|
||||
protected TitleScreenButtonMixin(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "initWidgetsNormal")
|
||||
private void titleScreenButton(int y, int spacingY, CallbackInfo ci) {
|
||||
|
||||
final Identifier ICON_TEXTURE = new Identifier("arduinoctrls", "gui/button_icon.png");
|
||||
final Identifier ICON_TEXTURE = new Identifier(MOD_ID, "textures/gui/button_icon.png");
|
||||
|
||||
int buttonX = this.width / 2 + 104;
|
||||
int buttonY = y + spacingY * 2;
|
||||
|
||||
this.addDrawableChild(new ButtonWidget(buttonX, buttonY, 20, 20, Text.of(""), (button) -> {
|
||||
this.client.setScreen(new GuiHome(this));
|
||||
this.client.setScreen(new BoardScreen(this));
|
||||
}));
|
||||
this.addDrawableChild( new TexturedButtonWidget(buttonX, buttonY, 20, 20, 0, 0, 0, ICON_TEXTURE, 20, 20, (buttonWidget) -> this.client.setScreen(new GuiHome(this))));
|
||||
this.addDrawableChild( new TexturedButtonWidget(buttonX, buttonY, 20, 20, 0, 0, 0, ICON_TEXTURE, 20, 20, (buttonWidget) -> this.client.setScreen(new BoardScreen(this))));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package me.jonasjones.microcraft.object;
|
||||
|
||||
public class MicroBoard {
|
||||
|
||||
public String name;
|
||||
public int id;
|
||||
public String port;
|
||||
public int baudrate;
|
||||
public String model;
|
||||
public PinMap pins = new PinMap();
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
package me.jonasjones.microcraft.object;
|
||||
|
||||
public class PinMap {
|
||||
}
|
||||
|
|
@ -1,33 +1,32 @@
|
|||
package me.jonasjones.arduinoctrls.util;
|
||||
package me.jonasjones.microcraft.util;
|
||||
|
||||
import jdk.jfr.StackTrace;
|
||||
import me.jonasjones.arduinoctrls.ArduinoControls;
|
||||
import me.jonasjones.arduinoctrls.config.ModConfigs;
|
||||
import me.jonasjones.microcraft.Microcraft;
|
||||
import me.jonasjones.microcraft.config.ModConfigs;
|
||||
|
||||
public class VerboseLogger {
|
||||
public static void info(String message) {
|
||||
if (ModConfigs.VERBOSE) {
|
||||
ArduinoControls.VERBOSELOGGER.info(message);
|
||||
Microcraft.VERBOSELOGGER.info(message);
|
||||
}
|
||||
}
|
||||
public void debug(String message) {
|
||||
if (ModConfigs.VERBOSE) {
|
||||
ArduinoControls.VERBOSELOGGER.debug(message);
|
||||
Microcraft.VERBOSELOGGER.debug(message);
|
||||
}
|
||||
}
|
||||
public static void error(String message) {
|
||||
if (ModConfigs.VERBOSE) {
|
||||
ArduinoControls.VERBOSELOGGER.error(message);
|
||||
Microcraft.VERBOSELOGGER.error(message);
|
||||
}
|
||||
}
|
||||
public static void trace( String message) {
|
||||
if (ModConfigs.VERBOSE) {
|
||||
ArduinoControls.VERBOSELOGGER.trace(message);
|
||||
Microcraft.VERBOSELOGGER.trace(message);
|
||||
}
|
||||
}
|
||||
public static void warn( String message) {
|
||||
if (ModConfigs.VERBOSE) {
|
||||
ArduinoControls.VERBOSELOGGER.warn(message);
|
||||
Microcraft.VERBOSELOGGER.warn(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package me.jonasjones.microcraft.util.boardmanager;
|
||||
|
||||
|
||||
import com.fazecast.jSerialComm.SerialPort;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SerialNumberScanner {
|
||||
public static List<String> scan() {
|
||||
SerialPort[] ports = SerialPort.getCommPorts();
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (SerialPort port : ports) {
|
||||
System.out.println(port.getSystemPortName());
|
||||
list.add(port.getSystemPortName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 4 KiB After Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 570 B After Width: | Height: | Size: 570 B |
|
Before Width: | Height: | Size: 566 B After Width: | Height: | Size: 566 B |
|
After Width: | Height: | Size: 3.1 KiB |
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "me.jonasjones.arduinoctrls.mixin",
|
||||
"package": "me.jonasjones.microcraft.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ArduinoMixin",
|
||||
"TitleScreenButtonMixin",
|
||||
"GameMenuScreenMixin"
|
||||
],
|
||||
"injectors": {
|
||||