mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 02:04:59 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b77118f3ea | ||
|
|
f87690ccec | ||
|
|
530b061a97 | ||
|
|
e92e7c1e94 | ||
|
|
420f20a473 | ||
|
|
1f5c843775 |
No files matched your search
@@ -4,6 +4,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -102,6 +103,39 @@ public class FormattedTextField extends GuiTextField {
|
||||
this.editable = p_146184_1_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText(String p_146191_1_) {
|
||||
String newText = "";
|
||||
String substr = ChatAllowedCharacters.filerAllowedCharacters(p_146191_1_);
|
||||
int cursorPosition = getCursorPosition();
|
||||
int maxStringLength = getMaxStringLength();
|
||||
String text = getText();
|
||||
|
||||
if (text.isEmpty()) {
|
||||
newText = substr.substring(0, Math.min(maxStringLength, substr.length()));
|
||||
cursorPosition = newText.length();
|
||||
} else {
|
||||
int selectionEnd = getSelectionEnd();
|
||||
String textStart = text.substring(0, Math.min(cursorPosition, selectionEnd));
|
||||
String textEnd = text.substring(Math.max(cursorPosition, selectionEnd));
|
||||
newText = textStart + substr + textEnd;
|
||||
|
||||
if (newText.length() > maxStringLength) {
|
||||
newText = newText.substring(0, maxStringLength);
|
||||
}
|
||||
|
||||
cursorPosition = Math.min(textStart.length() + substr.length(), newText.length());
|
||||
}
|
||||
|
||||
setText(newText);
|
||||
setCursorPosition(cursorPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) {
|
||||
return this.func_146197_a(p_146183_1_, p_146183_2_, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
if (this.getVisible()) {
|
||||
|
||||
@@ -234,8 +234,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip")) {
|
||||
GuiContainerManager.incrementTooltipPage();
|
||||
if (NEIClientConfig.isKeyHashDown("gui.next_tooltip") && GuiContainerManager.incrementTooltipPage()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ public class LayoutStyleMinecraft extends LayoutStyle {
|
||||
final Rectangle4i area = new Rectangle4i(0, 0, 0, BUTTON_SIZE);
|
||||
|
||||
if (NEIClientConfig.isSearchWidgetCentered()) {
|
||||
area.w = gui.xSize - MARGIN * 2;
|
||||
area.w = Math.min(gui.xSize, 176) - MARGIN * 2;
|
||||
area.x = (gui.width - area.w) / 2;
|
||||
area.y = gui.height - BUTTON_SIZE - MARGIN;
|
||||
} else if (NEIClientConfig.showItemQuantityWidget()) {
|
||||
|
||||
@@ -298,7 +298,7 @@ public class NEIClientConfig {
|
||||
@Override
|
||||
public boolean onClick(int button) {
|
||||
LayoutManager.markItemsDirty();
|
||||
return super.onClick(button);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -369,6 +369,19 @@ public class NEIClientConfig {
|
||||
tag.getTag("inventory.gridRenderingCacheMode").getIntValue(0);
|
||||
API.addOption(new OptionCycled("inventory.gridRenderingCacheMode", 3, true));
|
||||
|
||||
tag.getTag("inventory.hotkeysHelpText").getBooleanValue(true);
|
||||
API.addOption(new OptionToggleButton("inventory.hotkeysHelpText", true));
|
||||
|
||||
tag.getTag("inventory.gridRenderingCacheFPS").getIntValue(8);
|
||||
API.addOption(new OptionIntegerField("inventory.gridRenderingCacheFPS", 1, 144) {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return OpenGlHelper.framebufferSupported && getIntSetting("inventory.gridRenderingCacheMode") == 1;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tag.getTag("loadPluginsInParallel").getBooleanValue(true);
|
||||
tag.getTag("itemLoadingTimeout").getIntValue(500);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import codechicken.nei.TextField;
|
||||
|
||||
public class OptionTextField extends Option {
|
||||
|
||||
protected final TextField textField = new TextField("test") {
|
||||
protected final TextField textField = new TextField("option-text-field") {
|
||||
|
||||
{
|
||||
this.h = 20;
|
||||
@@ -19,6 +19,7 @@ public class OptionTextField extends Option {
|
||||
// don't override global if text hasn't changed
|
||||
if (focused() && isValidValue(text()) && (!defaulting() || !text().equals(getTag().getValue()))) {
|
||||
getTag().setValue(text());
|
||||
OptionTextField.this.onTextChange(text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +28,20 @@ public class OptionTextField extends Option {
|
||||
if (!focus && !isValidValue(text())) setText(renderTag().getValue());
|
||||
super.setFocus(focus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey) {
|
||||
this.field.setEnabled(isEnabled());
|
||||
super.draw(mousex, mousey);
|
||||
}
|
||||
};
|
||||
|
||||
public OptionTextField(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void onTextChange(String text) {}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
textField.update();
|
||||
@@ -47,6 +56,10 @@ public class OptionTextField extends Option {
|
||||
return slot.slotWidth();
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mousex, int mousey, float frame) {
|
||||
GuiDraw.drawString(getPrefix(), 10, 6, -1);
|
||||
@@ -59,12 +72,14 @@ public class OptionTextField extends Option {
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int keycode) {
|
||||
textField.handleKeyPress(keycode, c);
|
||||
if (isEnabled()) {
|
||||
textField.handleKeyPress(keycode, c);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mousex, int mousey, int button) {
|
||||
if (textField.contains(mousex, mousey)) textField.handleClick(mousex, mousey, button);
|
||||
if (isEnabled() && textField.contains(mousex, mousey)) textField.handleClick(mousex, mousey, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +89,7 @@ public class OptionTextField extends Option {
|
||||
|
||||
@Override
|
||||
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
|
||||
if (new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
|
||||
if (isEnabled() && new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
|
||||
String tip = translateN(name + ".tip");
|
||||
if (!tip.equals(namespaced(name + ".tip"))) currenttip.add(tip);
|
||||
}
|
||||
|
||||
@@ -554,7 +554,8 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
ItemStack stack = getStackMouseOver(window);
|
||||
if (tooltip.isEmpty() && shouldShowTooltip(window)) { // mouseover tip, not holding an item
|
||||
boolean showTooltip = shouldShowTooltip(window);
|
||||
if (tooltip.isEmpty() && showTooltip) { // mouseover tip, not holding an item
|
||||
font = getFontRenderer(stack);
|
||||
if (stack != null) {
|
||||
tooltip = itemDisplayNameMultiline(stack, window, true);
|
||||
@@ -569,7 +570,7 @@ public class GuiContainerManager {
|
||||
|
||||
if (!tooltip.isEmpty()) tooltip.set(0, tooltip.get(0) + GuiDraw.TOOLTIP_LINESPACE); // add space after 'title'
|
||||
|
||||
if (shouldShowTooltip(window)) {
|
||||
if (showTooltip) {
|
||||
List<String> hotkeystips = collectHotkeyTips(mousex, mousey);
|
||||
|
||||
if (!hotkeystips.isEmpty()) {
|
||||
@@ -615,23 +616,19 @@ public class GuiContainerManager {
|
||||
}
|
||||
|
||||
private List<String> collectHotkeyTips(int mousex, int mousey) {
|
||||
Map<String, String> hotkeys = new HashMap<>();
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys);
|
||||
if (NEIClientUtils.altKey()) {
|
||||
Map<String, String> hotkeys = new HashMap<>();
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
hotkeys = handler.handleHotkeys(window, mousex, mousey, hotkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hotkeys.isEmpty()) {
|
||||
List<String> hotkeystips = new ArrayList<>();
|
||||
if (!hotkeys.isEmpty()) {
|
||||
List<String> hotkeystips = new ArrayList<>();
|
||||
|
||||
if (!NEIClientUtils.altKey()) {
|
||||
hotkeystips.add(
|
||||
EnumChatFormatting.GRAY + translate(
|
||||
"showHotkeys",
|
||||
EnumChatFormatting.GOLD + translate("key.alt") + EnumChatFormatting.GRAY));
|
||||
} else {
|
||||
Map<String, List<String>> messages = new HashMap<>();
|
||||
hotkeys.remove(null);
|
||||
hotkeys.remove("");
|
||||
@@ -664,9 +661,28 @@ public class GuiContainerManager {
|
||||
hotkeystips.set(
|
||||
hotkeystips.size() - 1,
|
||||
hotkeystips.get(hotkeystips.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
|
||||
return hotkeystips;
|
||||
}
|
||||
|
||||
return hotkeystips;
|
||||
} else if (NEIClientConfig.getBooleanSetting("inventory.hotkeysHelpText")) {
|
||||
boolean existsHotkeys = false;
|
||||
|
||||
synchronized (instanceTooltipHandlers) {
|
||||
for (IContainerTooltipHandler handler : instanceTooltipHandlers) {
|
||||
if (!handler.handleHotkeys(window, mousex, mousey, new HashMap<>()).isEmpty()) {
|
||||
existsHotkeys = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (existsHotkeys) {
|
||||
return Collections.singletonList(
|
||||
EnumChatFormatting.GRAY + translate(
|
||||
"showHotkeys",
|
||||
EnumChatFormatting.GOLD + translate("key.alt") + EnumChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
@@ -675,39 +691,50 @@ public class GuiContainerManager {
|
||||
private String getHotkeyTip(List<String> keys, String message) {
|
||||
return EnumChatFormatting.GOLD
|
||||
+ String.join(EnumChatFormatting.DARK_GRAY + " / " + EnumChatFormatting.GOLD, keys)
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ EnumChatFormatting.DARK_GRAY
|
||||
+ " - "
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ message
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
private static int tooltipPage;
|
||||
private static int maxTooltipPage;
|
||||
|
||||
public static void drawPagedTooltip(FontRenderer font, int x, int y, List<String> list) {
|
||||
if (list.isEmpty()) return;
|
||||
List<List<String>> tooltips = splitTooltipByPage(list);
|
||||
tooltipPage = tooltipPage < tooltips.size() ? tooltipPage : 0;
|
||||
if (tooltips.size() > 1) {
|
||||
tooltips.get(tooltipPage).add(
|
||||
EnumChatFormatting.ITALIC + NEIClientUtils.translate(
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
tooltips.size(),
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip")));
|
||||
maxTooltipPage = tooltips.size();
|
||||
tooltipPage = tooltipPage < maxTooltipPage ? tooltipPage : 0;
|
||||
final List<String> currentTooltip = tooltips.get(tooltipPage);
|
||||
|
||||
if (maxTooltipPage > 1) {
|
||||
final String pageTooltip = EnumChatFormatting.ITALIC + NEIClientUtils.translate(
|
||||
"inventory.tooltip.page",
|
||||
tooltipPage + 1,
|
||||
maxTooltipPage,
|
||||
NEIClientConfig.getKeyName("gui.next_tooltip"));
|
||||
|
||||
currentTooltip.set(
|
||||
currentTooltip.size() - 1,
|
||||
currentTooltip.get(currentTooltip.size() - 1) + GuiDraw.TOOLTIP_LINESPACE);
|
||||
|
||||
currentTooltip.add(pageTooltip);
|
||||
}
|
||||
|
||||
if (NEIModContainer.isGTNHLibLoaded()) {
|
||||
drawMultilineTip(
|
||||
font,
|
||||
x,
|
||||
y,
|
||||
tooltips.get(tooltipPage),
|
||||
currentTooltip,
|
||||
RenderTooltipEventHelper.getBackgroundStart(),
|
||||
RenderTooltipEventHelper.getBackgroundEnd(),
|
||||
RenderTooltipEventHelper.getBorderStart(),
|
||||
RenderTooltipEventHelper.getBorderEnd());
|
||||
return;
|
||||
} else {
|
||||
drawMultilineTip(font, x, y, currentTooltip);
|
||||
}
|
||||
drawMultilineTip(font, x, y, tooltips.get(tooltipPage));
|
||||
}
|
||||
|
||||
public static List<List<String>> splitTooltipByPage(List<String> list) {
|
||||
@@ -752,8 +779,8 @@ public class GuiContainerManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void incrementTooltipPage() {
|
||||
tooltipPage++;
|
||||
public static boolean incrementTooltipPage() {
|
||||
return tooltipPage != Math.min(tooltipPage++, maxTooltipPage);
|
||||
}
|
||||
|
||||
public void renderSlotUnderlay(Slot slot) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public class StackInfo {
|
||||
}
|
||||
|
||||
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
|
||||
if (stackA == null || stackB == null || !stackA.isItemEqual(stackB)) {
|
||||
if (stackA == null || stackB == null || stackA.getItem() != stackB.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DefaultStackStringifyHandler implements IStackStringifyHandler {
|
||||
nbTag.setInteger("Count", saveStackSize ? stack.stackSize : 1);
|
||||
nbTag.setShort("Damage", (short) stack.getItemDamage());
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
if (stack.hasTagCompound() && !stack.getTagCompound().hasNoTags()) {
|
||||
nbTag.setTag("tag", stack.getTagCompound());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ public class NEIMouseUtils {
|
||||
if (mouseBind >= 0) {
|
||||
int button = unhash(mouseBind);
|
||||
switch (button) {
|
||||
case 0:
|
||||
case MOUSE_BTN_LMB:
|
||||
mouseText.add(NEIClientUtils.translate("mouse.left"));
|
||||
break;
|
||||
case 1:
|
||||
case MOUSE_BTN_RMB:
|
||||
mouseText.add(NEIClientUtils.translate("mouse.right"));
|
||||
break;
|
||||
case 2:
|
||||
case MOUSE_BTN_MMB:
|
||||
mouseText.add(NEIClientUtils.translate("mouse.middle"));
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -24,7 +24,7 @@ public enum ReadableNumberConverter {
|
||||
/**
|
||||
* String representation of the sorted postfixes
|
||||
*/
|
||||
private static final char[] ENCODED_POSTFIXES = "KMGTPE".toCharArray();
|
||||
private static final char[] ENCODED_POSTFIXES = "kMGTPE".toCharArray();
|
||||
|
||||
private final Format format;
|
||||
|
||||
|
||||
@@ -198,6 +198,9 @@ nei.options.inventory.bookmarks.ignorePotionOverlap.false=No
|
||||
nei.options.inventory.bookmarks.worldSpecific=World Specific Bookmarks
|
||||
nei.options.inventory.bookmarks.worldSpecific.true=Yes
|
||||
nei.options.inventory.bookmarks.worldSpecific.false=No
|
||||
nei.options.inventory.hotkeysHelpText=Show Hotkeys Help Text
|
||||
nei.options.inventory.hotkeysHelpText.true=Yes
|
||||
nei.options.inventory.hotkeysHelpText.false=No
|
||||
nei.options.inventory.guirecipe=Recipes GUI
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs=JEI Style Tabs
|
||||
nei.options.inventory.guirecipe.jeiStyleTabs.true=Yes
|
||||
@@ -317,6 +320,7 @@ nei.options.inventory.gridRenderingCacheMode=Grid Rendering Cache Mode
|
||||
nei.options.inventory.gridRenderingCacheMode.0=Off
|
||||
nei.options.inventory.gridRenderingCacheMode.1=Low FPS
|
||||
nei.options.inventory.gridRenderingCacheMode.2=Freeze
|
||||
nei.options.inventory.gridRenderingCacheFPS=Grid Rendering Cache FPS
|
||||
nei.options.inventory.collapsibleItems=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled=Collapsible Items
|
||||
nei.options.inventory.collapsibleItems.enabled.true=Enabled
|
||||
|
||||
Reference in new issue
Block a user