update to 1.16.5, add close button

This commit is contained in:
Joseph Garcia 2021-01-19 13:59:41 -06:00
parent ae9bbe4337
commit b9a5edab1a
2 changed files with 15 additions and 13 deletions

View File

@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.3
loader_version=0.10.6+build.214
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.1
loader_version=0.11.1
# Mod Properties
mod_version = 1.0.1
mod_version = 1.1.0
maven_group = com.josyf.commandbuttons
archives_base_name = command-gui-buttons
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.25.1+build.416-1.16
fabric_version=0.29.3+1.16

View File

@ -5,6 +5,7 @@ import com.josyf.commandbuttons.ConfigFile;
import io.github.cottonmc.cotton.gui.client.BackgroundPainter;
import io.github.cottonmc.cotton.gui.client.LightweightGuiDescription;
import io.github.cottonmc.cotton.gui.widget.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.TranslatableText;
import org.json.simple.JSONObject;
@ -20,20 +21,23 @@ public class ButtonGUI extends LightweightGuiDescription {
// initialize root panel of GUI
WGridPanel root = new WGridPanel();
setupBackground(root);
// Text GUI, not needed yet
// WLabel label = new WLabel(new LiteralText("Test"), 0xFFFFFF);
// root.add(label, 0, 4, 2, 1);
addCloseButton(root);
// Add delete toggle button
WToggleButton delToggle = new WToggleButton(new TranslatableText("Delete"));
root.add(delToggle, 17, 0, 3, 1);
root.add(delToggle, 0, 11, 3, 1);
addSavedButtons(root, delToggle);
addCommandSection(root, delToggle);
root.validate(this);
}
private void addCloseButton(WGridPanel root) {
WButton escButton = new WButton(new TranslatableText("x"));
escButton.setOnClick(() -> MinecraftClient.getInstance().player.closeScreen());
root.add(escButton, 17, 1, 2, 2);
}
private void addCommandSection(WGridPanel root, WToggleButton toggle) {
// Add text field for command NAME entry
WTextField nameTextField = new WTextField();
@ -49,9 +53,7 @@ public class ButtonGUI extends LightweightGuiDescription {
// Add button for command entry
WButton addCmdBtn = new WButton(new TranslatableText("+"));
addCmdBtn.setOnClick(() -> {
addGUIButton(root, nameTextField, commandTextField, toggle);
});
addCmdBtn.setOnClick(() -> addGUIButton(root, nameTextField, commandTextField, toggle));
root.add(addCmdBtn, 18, 12, 1, 1);
}