Compare commits

...
Author SHA1 Message Date
Jason Mitchell 4c36d0625e Reorg & restyle GuiRecipe to look a bit more like JEI
Add gregtech hax to avoid overlapping
2021-03-24 21:12:18 -07:00
Jason Mitchell 5bfcc73459 Shift everything instead of conditionally 2021-03-24 18:23:30 -07:00
Lex bc1dd44c41 shift of the bookmark border 2021-03-24 18:20:20 -07:00
5 changed files with 76 additions and 31 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@ mc_version=1.7.10
forge_version=10.13.4.1614-1.7.10
ccl_version=1.1.3.138
ccc_version=1.0.7.+
mod_version=2.1.0-GTNH-beta3
mod_version=2.1.0-GTNH-beta4
+3 -4
View File
@@ -150,7 +150,7 @@ public class BookmarkPanel extends ItemPanel {
@Override
public int getNextX(GuiContainer gui) {
return gui.width - prev.w - 2 - ((gui.xSize + gui.width) /2 + 2);
return gui.width - prev.w - 2 - ((gui.xSize + gui.width) /2 + 2) - 16;
}
@Override
@@ -160,7 +160,7 @@ public class BookmarkPanel extends ItemPanel {
@Override
public int getPageX(GuiContainer gui) {
return gui.guiLeft * 3 / 2 + gui.xSize + 1 - ((gui.xSize + gui.width) /2 + 2);
return gui.guiLeft * 3 / 2 + gui.xSize + 1 - ((gui.xSize + gui.width) / 2 + 2) - 16;
}
public int getHightAdjustment() {
@@ -168,8 +168,7 @@ public class BookmarkPanel extends ItemPanel {
}
public int getWidth(GuiContainer gui) {
return LayoutManager.getLeftSize(gui) - ( (gui.xSize + gui.width) / 2 + 3 );
return LayoutManager.getLeftSize(gui) - ( (gui.xSize + gui.width) / 2 + 3 ) - 16;
}
}
+1 -4
View File
@@ -105,12 +105,9 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
public static HashMap<Integer, LayoutStyle> layoutStyles = new HashMap<>();
public static boolean ftbUtilsLoaded = false;
public static boolean itemsLoaded = false;
public static void load() {
ftbUtilsLoaded = Loader.isModLoaded("FTBU");
API.addLayoutStyle(0, new LayoutStyleMinecraft());
instance = new LayoutManager();
@@ -142,7 +139,7 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
return gui.width - 3;
}
public static int getLeftSize(GuiContainer gui) {
return getSideWidth(gui) - ((ftbUtilsLoaded || getGamemode() == 2) ? 18 : 0);
return getSideWidth(gui);
}
@Override
+69 -20
View File
@@ -36,7 +36,20 @@ import java.util.List;
public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOverlay, IGuiClientSide, IGuiHandleMouseWheel, IContainerTooltipHandler, INEIGuiHandler
{
private static final int borderPadding = 6;
private static final int buttonWidth = 13;
private static final int buttonHeight = 12;
public ArrayList<? extends IRecipeHandler> currenthandlers = new ArrayList<>();
private static Class gregtechHandler;
static {
try {
gregtechHandler = Class.forName("gregtech.nei.GT_NEI_DefaultHandler");
} catch (ClassNotFoundException e) {
gregtechHandler = null;
}
}
public int page;
public int recipetype;
@@ -47,8 +60,12 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
public GuiButton prevpage;
public GuiButton overlay1;
public GuiButton overlay2;
private GuiButton nexttype;
private GuiButton prevtype;
private final Rectangle area = new Rectangle();
private final GuiRecipeTabs recipeTabs;
private int yShift = 0;
protected GuiRecipe(GuiScreen prevgui) {
super(new ContainerRecipe());
@@ -70,12 +87,17 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
super.initGui();
currenthandlers = getCurrentRecipeHandlers(); // Probably don't comment me out
GuiButton nexttype = new GuiNEIButton(0, width / 2 - 70, (height - ySize) / 2 + 3, 13, 12, "<");
GuiButton prevtype = new GuiNEIButton(1, width / 2 + 57, (height - ySize) / 2 + 3, 13, 12, ">");
nextpage = new GuiNEIButton(2, width / 2 - 70, (height + ySize) / 2 - 18, 13, 12, "<");
prevpage = new GuiNEIButton(3, width / 2 + 57, (height + ySize) / 2 - 18, 13, 12, ">");
overlay1 = new GuiNEIButton(4, width / 2 + 65, (height - ySize) / 2 + 63, 13, 12, "?");
overlay2 = new GuiNEIButton(5, width / 2 + 65, (height - ySize) / 2 + 128, 13, 12, "?");
final int rightButtonX = guiLeft + xSize - borderPadding - buttonWidth;
final int leftButtonX = guiLeft + borderPadding;
nexttype = new GuiNEIButton(0, leftButtonX, (height - ySize) / 2 + 3, buttonWidth, buttonHeight, "<");
prevtype = new GuiNEIButton(1, rightButtonX, (height - ySize) / 2 + 3, buttonWidth, buttonHeight, ">");
nextpage = new GuiNEIButton(2, leftButtonX, (height - ySize) / 2 + 17, buttonWidth, buttonHeight, "<");
prevpage = new GuiNEIButton(3, rightButtonX, (height - ySize) / 2 + 17, buttonWidth, buttonHeight, ">");
overlay1 = new GuiNEIButton(4, width / 2 + 65, (height - ySize) / 2 + 63, buttonWidth, buttonHeight, "?");
overlay2 = new GuiNEIButton(5, width / 2 + 65, (height - ySize) / 2 + 128, buttonWidth, buttonHeight, "?");
buttonList.addAll(Arrays.asList(nexttype, prevtype, nextpage, prevpage, overlay1, overlay2));
@@ -83,9 +105,19 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
nexttype.visible = false;
prevtype.visible = false;
}
checkGregTech();
recipeTabs.initLayout();
refreshPage();
}
private void checkGregTech() {
IRecipeHandler handler = currenthandlers.get(recipetype);
if (gregtechHandler != null && gregtechHandler.isInstance(handler)) {
// Gregtech decided to shift their handler by -8 and draw over shit...
yShift = 6;
} else {
yShift = 0;
}
}
@Override
public void keyTyped(char c, int i) {
@@ -211,6 +243,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
recipetype = 0;
page = 0;
recipeTabs.calcPageNumber();
checkGregTech();
}
private void overlayRecipe(int recipe) {
@@ -235,19 +268,14 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
area.x = guiLeft - 2;
area.y = guiTop - 4;
final boolean avarita = handler.getClass().toString().contains("fox.spiteful.avaritia.compat.nei.");
if (avarita) {
area.width = 256;
area.height = 208;
}
calcArea(handler);
checkGregTech();
boolean multiplepages = handler.numRecipes() > handler.recipiesPerPage();
nextpage.visible = multiplepages;
prevpage.visible = multiplepages;
nextpage.enabled = prevpage.enabled = multiplepages;
if(firstGui != null) {
overlay1.yPosition = (height - ySize) / 2 + (handler.recipiesPerPage() == 2 ? 63 : 128);
overlay1.yPosition = (height - ySize) / 2 + 17 + (handler.recipiesPerPage() == 2 ? 63 : 128);
overlay1.visible = handler.hasOverlay(firstGui, firstGui.inventorySlots, page * handler.recipiesPerPage());
overlay2.visible = handler.recipiesPerPage() == 2 && page * handler.recipiesPerPage() + 1 < handler.numRecipes() &&
handler.hasOverlay(firstGui, firstGui.inventorySlots, page * handler.recipiesPerPage() + 1);
@@ -258,6 +286,14 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
recipeTabs.refreshPage();
}
private void calcArea(IRecipeHandler handler) {
if ( handler.getClass().toString().contains("fox.spiteful.avaritia.compat.nei.")) {
// Handle avarita's oversized handler area
area.width = 256;
area.height = 208;
}
}
private void refreshSlots() {
slotcontainer.inventorySlots.clear();
IRecipeHandler recipehandler = currenthandlers.get(recipetype);
@@ -284,12 +320,12 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
IRecipeHandler recipehandler = currenthandlers.get(recipetype);
String s = recipehandler.getRecipeName();
fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0x404040);
fontRendererObj.drawStringWithShadow(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 5, 0xffffff);
s = NEIClientUtils.translate("recipe.page", page + 1, (currenthandlers.get(recipetype).numRecipes() - 1) / recipehandler.recipiesPerPage() + 1);
fontRendererObj.drawString(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, ySize - 16, 0x404040);
fontRendererObj.drawStringWithShadow(s, (xSize - fontRendererObj.getStringWidth(s)) / 2, 19, 0xffffff);
GL11.glPushMatrix();
GL11.glTranslatef(5, 16, 0);
GL11.glTranslatef(5, 32 + yShift, 0);
for (int i = page * recipehandler.recipiesPerPage(); i < recipehandler.numRecipes() && i < (page + 1) * recipehandler.recipiesPerPage(); i++) {
recipehandler.drawForeground(i);
GL11.glTranslatef(0, 65, 0);
@@ -305,6 +341,19 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
drawRect(guiLeft + borderPadding + buttonWidth - 1,
nexttype.yPosition,
guiLeft + xSize - borderPadding - buttonWidth,
nexttype.yPosition + buttonHeight,
0x30000000);
drawRect(guiLeft + borderPadding + buttonWidth - 1,
nextpage.yPosition,
guiLeft + xSize - borderPadding - buttonWidth,
nextpage.yPosition + buttonHeight,
0x30000000);
if (NEIClientConfig.areJEIStyleTabsVisible()) {
RenderHelper.enableGUIStandardItemLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
@@ -313,7 +362,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
}
GL11.glPushMatrix();
GL11.glTranslatef(j + 5, k + 16, 0);
GL11.glTranslatef(j + 5, k + 32 + yShift, 0);
IRecipeHandler recipehandler = currenthandlers.get(recipetype);
for (int i = page * recipehandler.recipiesPerPage(); i < recipehandler.numRecipes() && i < (page + 1) * recipehandler.recipiesPerPage(); i++) {
recipehandler.drawBackground(i);
@@ -336,7 +385,7 @@ public abstract class GuiRecipe extends GuiContainer implements IGuiContainerOve
}
public Point getRecipePosition(int recipe) {
return new Point(5, 16 + (recipe % currenthandlers.get(recipetype).recipiesPerPage()) * 65);
return new Point(5, 32 + yShift + (recipe % currenthandlers.get(recipetype).recipiesPerPage()) * 65);
}
@Override
@@ -102,7 +102,7 @@ public class GuiRecipeTabs {
};
prevTab.w = 8;
prevTab.h = tabHeight - 4;
prevTab.x = area.x - prevTab.w;
prevTab.x = area.x - prevTab.w + 1;
prevTab.y = area.y + 2;
buttons.add(prevTab);
@@ -121,7 +121,7 @@ public class GuiRecipeTabs {
};
nextTab.w = prevTab.w;
nextTab.h = prevTab.h;
nextTab.x = area.x + area.width;
nextTab.x = area.x + area.width - 1;
nextTab.y = prevTab.y;
buttons.add(nextTab);
}