blob: bc1c6b5630097a2e88d7a1f82de9bc4b83704fca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package gregtech.nei;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import codechicken.lib.gui.GuiDraw;
public class NEIHandlerAbsoluteTooltip {
private final Rectangle area;
private final String tooltip;
private Dimension displaySize;
public NEIHandlerAbsoluteTooltip(String tooltip, Rectangle area) {
this.tooltip = tooltip;
this.area = area;
}
public void handleTooltip(List<String> currenttip, int recipeIndex) {
displaySize = GuiDraw.displaySize();
if (shouldAddTooltip(recipeIndex)) {
currenttip.add(tooltip);
}
}
private boolean shouldAddTooltip(int recipeIndex) {
return isPageFirstRecipe(recipeIndex) && mouseInArea();
}
private boolean mouseInArea() {
Point mousePos = getRelMouse();
return area.contains(mousePos);
}
private Point getRelMouse() {
int ySize = Math.min(Math.max(displaySize.height - 68, 166), 370);
int guiLeft = (displaySize.width - 176) / 2;
int guiTop = (displaySize.height - ySize) / 2 + 10;
Point mousePos = GuiDraw.getMousePosition();
return new Point(mousePos.x - guiLeft - 5, mousePos.y - guiTop - 38);
}
private boolean isPageFirstRecipe(int recipe) {
int actualRecipesPerPage = getActualRecipesPerPage();
return actualRecipesPerPage < 2 || recipe % 2 == 0;
}
private int getActualRecipesPerPage() {
int ySize = Math.min(Math.max(displaySize.height - 68, 166), 370);
return (ySize - (12 * 3)) / 135;
}
}
|