diff options
| author | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
|---|---|---|
| committer | Moulberry <james.jenour@student.scotch.wa.edu.au> | 2020-11-08 17:44:27 +1100 |
| commit | 07403ec86c53f67b94d988b4c01a0afc2fdb2810 (patch) | |
| tree | fba4b3c37b02c42267e03a07453d3941c98fd66d /src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java | |
| parent | fc4143dd3c892b11ae5f427fcecc22044ff98460 (diff) | |
| parent | ec0660e41145d3d9ed479b3e697afddf8ddc8c4c (diff) | |
| download | notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.gz notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.tar.bz2 notenoughupdates-07403ec86c53f67b94d988b4c01a0afc2fdb2810.zip | |
Merge branch 'beta'
uh yeah its pretty necessary guys
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java index 28ecbc8e..633c1c4b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlayPlacements.java @@ -1,12 +1,12 @@ package io.github.moulberry.notenoughupdates; -import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; -import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; -import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroup; -import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating; +import io.github.moulberry.notenoughupdates.mbgui.*; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; import org.lwjgl.util.vector.Vector2f; @@ -22,22 +22,40 @@ public class NEUOverlayPlacements extends GuiScreen { private MBGuiElement clickedElement; private GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default"); + private boolean dropdownMenuShown = false; + @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); drawDefaultBackground(); + /*GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); + GlStateManager.enableBlend(); + + GlStateManager.tryBlendFuncSeparate(775, 769, 1, 0); + GlStateManager.enableAlpha(); + this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);*/ + if(mouseX < 300 && mouseY < 300 && clickedElement != null) { guiButton.yPosition = height - 5 - guiButton.height; } else { guiButton.yPosition = 5; } + EnumChatFormatting GOLD = EnumChatFormatting.GOLD; + guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY); NotEnoughUpdates.INSTANCE.overlay.updateGuiGroupSize(); + drawRect((width-176)/2, (height-166)/2, + (width+176)/2, (height+166)/2, new Color(100, 100, 100, 200).getRGB()); + Utils.drawStringCentered(GOLD+"Inventory", Minecraft.getMinecraft().fontRendererObj, width/2f, height/2f, false, 0); + MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup; + mainGroup.render(0, 0); + GlStateManager.translate(0, 0, 500); for(MBGuiElement element : mainGroup.getChildren()) { MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element); Vector2f position = mainGroup.getChildrenPosition().get(element); @@ -45,7 +63,6 @@ public class NEUOverlayPlacements extends GuiScreen { drawRect((int)position.x, (int)position.y, (int)position.x+element.getWidth(), (int)position.y+element.getHeight(), new Color(100, 100, 100, 200).getRGB()); - switch(anchorPoint.anchorPoint) { case TOPLEFT: case TOPRIGHT: @@ -84,13 +101,23 @@ public class NEUOverlayPlacements extends GuiScreen { break; } + + if(anchorPoint.inventoryRelative) { + Utils.drawStringCentered(GOLD+"Inv-Relative", Minecraft.getMinecraft().fontRendererObj, + position.x+element.getWidth()*0.5f, position.y+element.getHeight()*0.5f, false, 0); + } } + GlStateManager.translate(0, 0, -500); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); + + if(mouseButton != 0 && mouseButton != 1) return; + MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup; + int index=0; for(MBGuiElement element : mainGroup.getChildren()) { MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element); Vector2f position = mainGroup.getChildrenPosition().get(element); @@ -104,22 +131,31 @@ public class NEUOverlayPlacements extends GuiScreen { clickedAnchorX = (int)anchorPoint.offset.x; clickedAnchorY = (int)anchorPoint.offset.y; } else { - float anchorX = (width-element.getWidth()) * anchorPoint.anchorPoint.x + anchorPoint.offset.x; - float anchorY = (height-element.getHeight()) * anchorPoint.anchorPoint.y + anchorPoint.offset.y; - - MBAnchorPoint.AnchorPoint[] vals = MBAnchorPoint.AnchorPoint.values(); - anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal()+1)%vals.length]; - - float screenX = (width-element.getWidth()) * anchorPoint.anchorPoint.x; - float screenY = (height-element.getHeight()) * anchorPoint.anchorPoint.y; - anchorPoint.offset.x = anchorX - screenX; - anchorPoint.offset.y = anchorY - screenY; - - mainGroup.recalculate(); + if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + anchorPoint.inventoryRelative = !anchorPoint.inventoryRelative; + } else { + MBAnchorPoint.AnchorPoint[] vals = MBAnchorPoint.AnchorPoint.values(); + anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal()+1)%vals.length]; + + mainGroup.recalculate(); + + anchorPoint.offset.x += position.x - mainGroup.getChildrenPosition().get(element).x; + anchorPoint.offset.y += position.y - mainGroup.getChildrenPosition().get(element).y; + + mainGroup.recalculate(); + + if(index == 0) { + NotEnoughUpdates.INSTANCE.manager.config.overlaySearchBar.value = anchorPoint.toString(); + } else if(index == 1) { + NotEnoughUpdates.INSTANCE.manager.config.overlayQuickCommand.value = anchorPoint.toString(); + } + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} + } } return; } } + index++; } if(guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) { @@ -173,7 +209,7 @@ public class NEUOverlayPlacements extends GuiScreen { } index++; } - + try { MBDeserializer.serializeAndSave(mainGroup, "overlay"); } catch(Exception e) {} mainGroup.recalculate(); } } |
