From 2cc575fe73c909daf05a1a6b9aa7785631e5049f Mon Sep 17 00:00:00 2001 From: Falkreon Date: Sat, 31 Aug 2019 18:30:37 -0500 Subject: Fix E-to-close, respect image settings on WToggleButton --- .../cotton/gui/client/CottonInventoryScreen.java | 22 ++++++++++++++++++---- .../cottonmc/cotton/gui/widget/WToggleButton.java | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/main/java/io') 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 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) { -- cgit