mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-12 00:17:51 +00:00
Allow using hash for tooltip pagination keybind (#344)
This commit is contained in:
1 parent
e8d8c1994b
commit
249cb2b308
3 files changed
+35
-30
No files matched your search
@@ -345,7 +345,7 @@ public class NEIClientConfig {
|
||||
API.addHashBind("gui.hide_bookmarks", Keyboard.KEY_B);
|
||||
API.addKeyBind("gui.getprevioussearch", Keyboard.KEY_UP);
|
||||
API.addKeyBind("gui.getnextsearch", Keyboard.KEY_DOWN);
|
||||
API.addKeyBind("gui.next_tooltip", Keyboard.KEY_Z);
|
||||
API.addHashBind("gui.next_tooltip", Keyboard.KEY_Z);
|
||||
|
||||
API.addKeyBind("world.chunkoverlay", Keyboard.KEY_F9);
|
||||
API.addKeyBind("world.moboverlay", Keyboard.KEY_F7);
|
||||
@@ -421,6 +421,36 @@ public class NEIClientConfig {
|
||||
return hash != Keyboard.CHAR_NONE && hash == NEIClientUtils.getKeyHash();
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash) {
|
||||
return getKeyName(keyBind, useHash, false);
|
||||
}
|
||||
|
||||
public static String getKeyName(int keyBind, boolean useHash, boolean showOnlyHash) {
|
||||
String keyText = "";
|
||||
|
||||
if (useHash) {
|
||||
final String DELIMITER = " + ";
|
||||
if ((keyBind & NEIClientUtils.CTRL_HASH) != 0) {
|
||||
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.SHIFT_HASH) != 0) {
|
||||
keyText += "SHIFT" + DELIMITER;
|
||||
}
|
||||
if ((keyBind & NEIClientUtils.ALT_HASH) != 0) {
|
||||
keyText += "ALT" + DELIMITER;
|
||||
}
|
||||
}
|
||||
|
||||
if (!showOnlyHash) {
|
||||
keyText += Keyboard.getKeyName(unHashKey(keyBind));
|
||||
}
|
||||
return keyText;
|
||||
}
|
||||
|
||||
public static int unHashKey(int keyBind) {
|
||||
return keyBind & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH);
|
||||
}
|
||||
|
||||
public static void bootNEI(World world) {
|
||||
if (configLoaded) return;
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ import static codechicken.lib.gui.GuiDraw.drawStringC;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
|
||||
public class OptionKeyBind extends OptionButton {
|
||||
@@ -124,31 +122,8 @@ public class OptionKeyBind extends OptionButton {
|
||||
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
String keyText = "";
|
||||
|
||||
if (useHash) {
|
||||
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
|
||||
final String DELIMITER = EnumChatFormatting.GRAY + " + " + EnumChatFormatting.RESET;
|
||||
|
||||
if ((metahash & NEIClientUtils.CTRL_HASH) == NEIClientUtils.CTRL_HASH) {
|
||||
keyText += NEIClientUtils.translate(Minecraft.isRunningOnMac ? "key.ctrl.mac" : "key.ctrl") + DELIMITER;
|
||||
}
|
||||
|
||||
if ((metahash & NEIClientUtils.SHIFT_HASH) == NEIClientUtils.SHIFT_HASH) {
|
||||
keyText += "SHIFT" + DELIMITER;
|
||||
}
|
||||
|
||||
if ((metahash & NEIClientUtils.ALT_HASH) == NEIClientUtils.ALT_HASH) {
|
||||
keyText += "ALT" + DELIMITER;
|
||||
}
|
||||
}
|
||||
|
||||
if (!editing) {
|
||||
keyText += Keyboard.getKeyName(
|
||||
getValue() & ~(NEIClientUtils.CTRL_HASH | NEIClientUtils.SHIFT_HASH | NEIClientUtils.ALT_HASH));
|
||||
}
|
||||
|
||||
return keyText;
|
||||
final int metahash = Math.max(editing ? NEIClientUtils.getMetaHash() : getValue(), 0);
|
||||
return NEIClientConfig.getKeyName(metahash, useHash, editing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -513,7 +513,7 @@ public class GuiContainerManager {
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
tooltips.size(),
|
||||
Keyboard.getKeyName(NEIClientConfig.getKeyBinding("gui.next_tooltip"))));
|
||||
NEIClientConfig.getKeyName(NEIClientConfig.getKeyBinding("gui.next_tooltip"), true)));
|
||||
}
|
||||
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user