mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-15 17:54:50 +00:00
Added keyboard shortcuts to NEI And More... (#271)
* Added keyboard shortcuts to NEI * OptionButton: Add Tooltip to long prefix * fix formatting * Tooltip shown when shift is held
This commit is contained in:
1 parent
529f4374d6
commit
fb9d517f78
30 files changed
+756
-306
No files matched your search
@@ -6,8 +6,10 @@ import static codechicken.lib.gui.GuiDraw.drawStringC;
|
||||
import static codechicken.lib.gui.GuiDraw.getStringWidth;
|
||||
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -53,7 +55,7 @@ public abstract class OptionButton extends Option {
|
||||
public Rectangle buttonSize() {
|
||||
if (getPrefix() == null) return new Rectangle(0, 0, slot.slotWidth(), 20);
|
||||
|
||||
int width = Math.max(60, getStringWidth(getButtonText()));
|
||||
int width = Math.max(60, getStringWidth(getButtonText()) + 8);
|
||||
return new Rectangle(slot.slotWidth() - width, 0, width, 20);
|
||||
}
|
||||
|
||||
@@ -69,14 +71,34 @@ public abstract class OptionButton extends Option {
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
if (tooltip == null) return null;
|
||||
String s = translateN(tooltip);
|
||||
if (s.equals(namespaced(tooltip))) return null;
|
||||
return s;
|
||||
String tip = null;
|
||||
|
||||
if (tooltip != null) {
|
||||
String s = translateN(tooltip);
|
||||
|
||||
if (!s.equals(namespaced(tooltip))) {
|
||||
tip = s;
|
||||
}
|
||||
}
|
||||
|
||||
if (tip == null && getPrefix() != null) {
|
||||
final int width = getStringWidth(getPrefix());
|
||||
final Rectangle b = buttonSize();
|
||||
|
||||
if (width >= b.x) {
|
||||
tip = translateN(name);
|
||||
}
|
||||
}
|
||||
|
||||
return tip;
|
||||
}
|
||||
|
||||
public void drawPrefix() {
|
||||
if (getPrefix() != null) drawString(getPrefix(), 10, 6, -1);
|
||||
final String prefix = getPrefix();
|
||||
if (prefix != null) {
|
||||
final Rectangle b = buttonSize();
|
||||
drawString(NEIClientUtils.cropText(Minecraft.getMinecraft().fontRenderer, prefix, b.x - 10), 10, 6, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawButton(int mx, int my) {
|
||||
|
||||
Reference in new issue
Block a user