add proper command submission buttons to bottom of GUI

This commit is contained in:
Joseph Garcia 2020-12-11 16:18:09 -06:00
parent a1cf6d75da
commit 81a66dd837
2 changed files with 16 additions and 8 deletions

View File

@ -31,7 +31,7 @@ public class ConfigFile {
// CREATE OBJECT // CREATE OBJECT
CommandObject newCommand = new CommandObject(); CommandObject newCommand = new CommandObject();
newCommand.name = "Say Hello"; newCommand.name = "Say Hello";
newCommand.command = "Hello"; newCommand.command = "Hello 2";
// add new object to config // add new object to config
appendToFile(newCommand); appendToFile(newCommand);

View File

@ -23,13 +23,14 @@ public class ButtonGUI extends LightweightGuiDescription {
setupBackground(root); setupBackground(root);
// ######### DEBUG BUTTONS ############
// example button to create config JSON // example button to create config JSON
WButton button = new WButton(new TranslatableText("Serialize")); WButton button = new WButton(new TranslatableText("Serialize"));
button.setOnClick(() -> { button.setOnClick(() -> {
MacroButtons.printMessage(); MacroButtons.printMessage();
ConfigFile.serializeCommand(); ConfigFile.serializeCommand();
}); });
root.add(button, xValue, yValue, 4, 1); root.add(button, xValue, yValue + 9, 4, 1);
// example load serialization button // example load serialization button
WButton button2 = new WButton(new TranslatableText("Load Serialization")); WButton button2 = new WButton(new TranslatableText("Load Serialization"));
@ -37,14 +38,15 @@ public class ButtonGUI extends LightweightGuiDescription {
MacroButtons.printMessage(); MacroButtons.printMessage();
ConfigFile.loadSerialization(); ConfigFile.loadSerialization();
}); });
root.add(button2, xValue + 4, yValue, 6, 1); root.add(button2, xValue + 4, yValue + 9, 6, 1);
// read json file button // read json file button
WButton button3 = new WButton(new TranslatableText("Read command json")); WButton button3 = new WButton(new TranslatableText("Read command json"));
button3.setOnClick(() -> { button3.setOnClick(() -> {
ConfigFile.readFile(); ConfigFile.readFile();
}); });
root.add(button3, xValue + 10, yValue, 6, 1); root.add(button3, xValue + 10, yValue + 9, 6, 1);
// ######### DEBUG BUTTONS ############
// Text GUI, not needed yet // Text GUI, not needed yet
// WLabel label = new WLabel(new LiteralText("Test"), 0xFFFFFF); // WLabel label = new WLabel(new LiteralText("Test"), 0xFFFFFF);
@ -60,16 +62,22 @@ public class ButtonGUI extends LightweightGuiDescription {
} }
private void addCommandSection(WGridPanel root) { private void addCommandSection(WGridPanel root) {
// Add text field for command entry // Add text field for command NAME entry
WTextField nameTextField = new WTextField();
nameTextField.setSuggestion("Name");
root.add(nameTextField, 5, 12, 6, 1);
// Add text field for command / entry
WTextField textField = new WTextField(); WTextField textField = new WTextField();
root.add(textField, 6, 12, 6, 1); textField.setSuggestion("/command");
root.add(textField, 11, 12, 6, 1);
// Add button for command entry // Add button for command entry
WButton addCmdBtn = new WButton(new TranslatableText("+")); WButton addCmdBtn = new WButton(new TranslatableText("+"));
addCmdBtn.setOnClick(() -> { addCmdBtn.setOnClick(() -> {
addGUIButton(root, xValue); addGUIButton(root, xValue);
}); });
root.add(addCmdBtn, 13, 12, 1, 1); root.add(addCmdBtn, 18, 12, 1, 1);
} }
private void addGUIButton(WGridPanel root, int x) { private void addGUIButton(WGridPanel root, int x) {
@ -105,7 +113,7 @@ public class ButtonGUI extends LightweightGuiDescription {
private void setupBackground(WGridPanel root) { private void setupBackground(WGridPanel root) {
setRootPanel(root); setRootPanel(root);
root.setSize(300, 240); root.setSize(350, 240);
} }