Fix layout relative to tooltip boxes

This commit is contained in:
Raven Szewczyk committed 2023-07-04 20:08:42 +01:00
1 parent c4c7d6d055
commit 75e8270bad
2 files changed
+16 -6

No files matched your search

+15 -5
View File
@@ -258,6 +258,7 @@ public class ItemsGrid {
}
private int recipeTooltipSlotIdx = -1;
private int recipeTooltipLines = 2;
private Runnable recipeTooltipUpdater = null;
private GuiRecipe<?> recipeTooltipGui = null;
@@ -276,6 +277,7 @@ public class ItemsGrid {
}
private void drawRecipeTooltip(int mousex, int mousey) {
final Minecraft mc = Minecraft.getMinecraft();
ItemPanelSlot focused = getSlotMouseOver(mousex, mousey);
if (focused == null) {
recipeTooltipSlotIdx = -1;
@@ -324,6 +326,12 @@ public class ItemsGrid {
recipeTooltipGui.guiTop = 0;
recipeTooltipGui.guiLeft = 0;
}
recipeTooltipLines = 2;
if (focused.item != null && mc.currentScreen instanceof GuiContainer) {
final List<String> tooltip = GuiContainerManager
.itemDisplayNameMultiline(focused.item, (GuiContainer) mc.currentScreen, true);
recipeTooltipLines = tooltip.size();
}
};
}
if (recipeTooltipGui == null) {
@@ -331,12 +339,14 @@ public class ItemsGrid {
}
GL11.glPushMatrix();
GL11.glTranslatef(
mousex,
(mousey > height / 2) ? mousey - recipeTooltipGui.getHeightAsWidget() : mousey + 32,
100);
final float tooltipYOffset;
if (mousey > height / 2) {
tooltipYOffset = mousey - recipeTooltipGui.getHeightAsWidget() + 8;
} else {
tooltipYOffset = mousey - 7 + (recipeTooltipLines * 10);
}
GL11.glTranslatef(mousex, tooltipYOffset, 100);
final Minecraft mc = Minecraft.getMinecraft();
final GuiContainer gui;
if (mc.currentScreen instanceof GuiRecipe) {
gui = ((GuiRecipe<?>) mc.currentScreen).firstGui;
@@ -226,7 +226,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
final int recipesPerPage = getRecipesPerPage();
overlayButtons = new GuiButton[recipesPerPage];
final int xOffset = limitToOneRecipe ? (xSize / 2) : (width / 2);
final int yOffset = limitToOneRecipe ? 0 : guiTop;
final int yOffset = limitToOneRecipe ? -14 : guiTop;
final String overlayKeyName = NEIClientConfig
.getKeyName(NEIClientConfig.getKeyBinding("gui.overlay_use"), true);
for (int i = 0; i < recipesPerPage; i++) {