Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Zoom Position #554

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/main/java/codechicken/nei/ItemZoom.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package codechicken.nei;

import static codechicken.lib.gui.GuiDraw.drawStringC;
import static codechicken.lib.gui.GuiDraw.fontRenderer;
import static codechicken.lib.gui.GuiDraw.getMousePosition;

import java.awt.Point;
import java.util.List;

Expand All @@ -15,6 +11,7 @@
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import codechicken.lib.gui.GuiDraw;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import codechicken.nei.recipe.StackInfo;
Expand Down Expand Up @@ -65,13 +62,14 @@ public void draw(int mx, int my) {
GuiContainerManager.enable2DRender();

if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.showName")) {
String dispalyName = NEIClientUtils.cropText(fontRenderer, this.displayName, this.availableAreaWidth);
drawStringC(
String dispalyName = NEIClientUtils
.cropText(GuiDraw.fontRenderer, this.displayName, this.availableAreaWidth);
GuiDraw.drawStringC(
dispalyName,
(int) ((this.xPosition + size / 2) * screenScale),
(int) ((this.yPosition + size) * screenScale) + shiftText,
NEIClientConfig.getSetting("inventory.itemzoom.nameColor").getHexValue());
shiftText += fontRenderer.FONT_HEIGHT;
shiftText += GuiDraw.fontRenderer.FONT_HEIGHT;
}

if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.enabled")
Expand All @@ -80,15 +78,16 @@ public void draw(int mx, int my) {

if (keyName != null) {
String helpText = NEIClientUtils.translate("itemzoom.toggle", keyName);
List<String> lines = fontRenderer.listFormattedStringToWidth(helpText, this.availableAreaWidth);
List<String> lines = GuiDraw.fontRenderer
.listFormattedStringToWidth(helpText, this.availableAreaWidth);

for (String line : lines) {
drawStringC(
GuiDraw.drawStringC(
line,
(int) ((this.xPosition + size / 2) * screenScale),
(int) ((this.yPosition + size) * screenScale) + 10 + shiftText,
0x66555555);
shiftText += fontRenderer.FONT_HEIGHT;
shiftText += GuiDraw.fontRenderer.FONT_HEIGHT;
}
}
}
Expand All @@ -103,17 +102,17 @@ public void resize(GuiContainer gui) {
if (stack != null && (!NEIClientConfig.getBooleanSetting("inventory.itemzoom.onlySolid")
|| Block.getBlockFromItem(stack.getItem()).getMaterial().isSolid())) {
final float screenScale = 1.0f / getScreenScale();
final float availableAreaWidth = (gui.width - (gui.xSize + gui.width) / 2) * screenScale;
final float availableAreaWidth = (gui.width - gui.xSize) / 2 * screenScale;
final float availableAreaHeight = gui.height * screenScale;
final Point mouse = getMousePosition();
final Point mouse = GuiDraw.getMousePosition();

this.scale = Math.round(getZoomAmount(gui) * getPointSize(gui) / SLOT_SIZE);
this.yPosition = (availableAreaHeight - this.scale * SLOT_SIZE) / 2;
this.xPosition = (availableAreaWidth - this.scale * SLOT_SIZE) / 2;
this.availableAreaWidth = (int) (availableAreaWidth / screenScale);

if (ItemPanels.bookmarkPanel.contains(mouse.x, mouse.y)) {
this.xPosition += (gui.guiLeft + gui.xSize) * screenScale;;
if (availableAreaWidth / screenScale >= mouse.x) {
this.xPosition = gui.width * screenScale - availableAreaWidth;
}

try {
Expand Down Expand Up @@ -166,7 +165,7 @@ private void decreaseZoom(GuiContainer gui) {
private ItemStack getStackMouseOver(GuiContainer gui) {

if (NEIClientConfig.getBooleanSetting("inventory.itemzoom.neiOnly")) {
final Point mouse = getMousePosition();
final Point mouse = GuiDraw.getMousePosition();
ItemStack stack = ItemPanels.itemPanel.getStackMouseOver(mouse.x, mouse.y);

if (stack == null) {
Expand Down