diff options
author | Falkreon <falkreon@gmail.com> | 2019-08-31 18:30:37 -0500 |
---|---|---|
committer | Falkreon <falkreon@gmail.com> | 2019-08-31 18:30:37 -0500 |
commit | 2cc575fe73c909daf05a1a6b9aa7785631e5049f (patch) | |
tree | b2a47debe4cd9ba40d60e088c69f2e3039cc4809 /src/main/java/io | |
parent | f0fba38f40ad2beda06a638356d4ef47e62cd03b (diff) | |
download | LibGui-2cc575fe73c909daf05a1a6b9aa7785631e5049f.tar.gz LibGui-2cc575fe73c909daf05a1a6b9aa7785631e5049f.tar.bz2 LibGui-2cc575fe73c909daf05a1a6b9aa7785631e5049f.zip |
Fix E-to-close, respect image settings on WToggleButton
Diffstat (limited to 'src/main/java/io')
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java | 22 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index ad00784..9883427 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -1,5 +1,7 @@ package io.github.cottonmc.cotton.gui.client; +import org.lwjgl.glfw.GLFW; + import io.github.cottonmc.cotton.gui.CottonCraftingController; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; @@ -78,10 +80,22 @@ public class CottonInventoryScreen<T extends CottonCraftingController> extends A @Override public boolean keyPressed(int ch, int keyCode, int modifiers) { - if (super.keyPressed(ch, keyCode, modifiers)) return true; - if (description.getFocus()==null) return false; - description.getFocus().onKeyPressed(ch, keyCode, modifiers); - return true; + if (keyCode==GLFW.GLFW_KEY_ESCAPE) { + this.minecraft.player.closeContainer(); + return true; + } else { + //if (super.keyPressed(ch, keyCode, modifiers)) return true; + if (description.getFocus()==null) { + if (MinecraftClient.getInstance().options.keyInventory.matchesKey(ch, keyCode)) { + this.minecraft.player.closeContainer(); + return true; + } + return false; + } else { + description.getFocus().onKeyPressed(ch, keyCode, modifiers); + return true; + } + } } @Override diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java index 82813ca..8935a95 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WToggleButton.java @@ -87,7 +87,7 @@ public class WToggleButton extends WWidget { @Override public void paintBackground(int x, int y) { - ScreenDrawing.texturedRect(x, y, 18, 18, isOn ? DEFAULT_ON_IMAGE : DEFAULT_OFF_IMAGE, 0xFFFFFFFF); + ScreenDrawing.texturedRect(x, y, 18, 18, isOn ? onImage : offImage, 0xFFFFFFFF); if (label!=null) { |