diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2021-10-16 15:50:41 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-16 15:50:41 -0400 |
| commit | 7c00af18febf6c0b833c7633b4fb60a9a1bb93af (patch) | |
| tree | f02de145362d6a1399651ade4a130d565d7f0ba3 /src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java | |
| parent | b11742988dec635b5c5da7c2363803cbfafb37b1 (diff) | |
| download | notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.gz notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.tar.bz2 notenoughupdates-7c00af18febf6c0b833c7633b4fb60a9a1bb93af.zip | |
Code Clean Up (#2)
* intellij code clean up
* optimize imports
* format
* intellij suggestions
* fix empty catch issues
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java | 103 |
1 files changed, 54 insertions, 49 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java index 995ed5e3..83e0a4b0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java @@ -1,7 +1,10 @@ package io.github.moulberry.notenoughupdates.miscgui; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.mbgui.*; +import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; +import io.github.moulberry.notenoughupdates.mbgui.MBDeserializer; +import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; +import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; @@ -21,9 +24,9 @@ public class NEUOverlayPlacements extends GuiScreen { private int clickedAnchorX; private int clickedAnchorY; private MBGuiElement clickedElement; - private GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default"); + private final GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default"); - private boolean dropdownMenuShown = false; + private final boolean dropdownMenuShown = false; @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { @@ -38,7 +41,7 @@ public class NEUOverlayPlacements extends GuiScreen { GlStateManager.enableAlpha(); this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);*/ - if(mouseX < 300 && mouseY < 300 && clickedElement != null) { + if (mouseX < 300 && mouseY < 300 && clickedElement != null) { guiButton.yPosition = height - 5 - guiButton.height; } else { guiButton.yPosition = 5; @@ -50,62 +53,62 @@ public class NEUOverlayPlacements extends GuiScreen { 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); + 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()) { + for (MBGuiElement element : mainGroup.getChildren()) { MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element); Vector2f position = mainGroup.getChildrenPosition().get(element); - drawRect((int)position.x, (int)position.y, - (int)position.x+element.getWidth(), (int)position.y+element.getHeight(), new Color(100, 100, 100, 200).getRGB()); + 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) { + switch (anchorPoint.anchorPoint) { case TOPLEFT: case TOPRIGHT: case BOTLEFT: case BOTRIGHT: - drawRect((int)(position.x+element.getWidth()*anchorPoint.anchorPoint.x*0.9f), - (int)(position.y+element.getHeight()*anchorPoint.anchorPoint.y*0.9f), - (int)(position.x+element.getWidth()*anchorPoint.anchorPoint.x*0.9f+element.getWidth()*0.1f), - (int)(position.y+element.getHeight()*anchorPoint.anchorPoint.y*0.9f+element.getHeight()*0.1f), + drawRect((int) (position.x + element.getWidth() * anchorPoint.anchorPoint.x * 0.9f), + (int) (position.y + element.getHeight() * anchorPoint.anchorPoint.y * 0.9f), + (int) (position.x + element.getWidth() * anchorPoint.anchorPoint.x * 0.9f + element.getWidth() * 0.1f), + (int) (position.y + element.getHeight() * anchorPoint.anchorPoint.y * 0.9f + element.getHeight() * 0.1f), new Color(200, 200, 200, 100).getRGB()); break; case TOPMID: - drawRect((int)position.x, (int)position.y, - (int)position.x+element.getWidth(), (int)(position.y+element.getHeight()*0.1f), + drawRect((int) position.x, (int) position.y, + (int) position.x + element.getWidth(), (int) (position.y + element.getHeight() * 0.1f), new Color(200, 200, 200, 100).getRGB()); break; case MIDLEFT: - drawRect((int)position.x, (int)position.y, - (int)(position.x+element.getWidth()*0.1f), (int)position.y+element.getHeight(), + drawRect((int) position.x, (int) position.y, + (int) (position.x + element.getWidth() * 0.1f), (int) position.y + element.getHeight(), new Color(200, 200, 200, 100).getRGB()); break; case MIDRIGHT: - drawRect((int)(position.x+element.getWidth()*0.9f), (int)position.y, - (int)position.x+element.getWidth(), (int)position.y+element.getHeight(), + drawRect((int) (position.x + element.getWidth() * 0.9f), (int) position.y, + (int) position.x + element.getWidth(), (int) position.y + element.getHeight(), new Color(200, 200, 200, 100).getRGB()); break; case BOTMID: - drawRect((int)position.x, (int)(position.y+element.getHeight()*0.9f), - (int)position.x+element.getWidth(), (int)position.y+element.getHeight(), + drawRect((int) position.x, (int) (position.y + element.getHeight() * 0.9f), + (int) position.x + element.getWidth(), (int) position.y + element.getHeight(), new Color(200, 200, 200, 100).getRGB()); break; case MIDMID: - drawRect((int)(position.x+element.getWidth()*0.45f), (int)(position.y+element.getHeight()*0.45f), - (int)(position.x+element.getWidth()*0.55f), (int)(position.y+element.getHeight()*0.55f), + drawRect((int) (position.x + element.getWidth() * 0.45f), (int) (position.y + element.getHeight() * 0.45f), + (int) (position.x + element.getWidth() * 0.55f), (int) (position.y + element.getHeight() * 0.55f), new Color(200, 200, 200, 100).getRGB()); 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); + 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); @@ -115,28 +118,28 @@ public class NEUOverlayPlacements extends GuiScreen { protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); - if(mouseButton != 0 && mouseButton != 1) return; + if (mouseButton != 0 && mouseButton != 1) return; MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup; - int index=0; - for(MBGuiElement element : mainGroup.getChildren()) { + int index = 0; + for (MBGuiElement element : mainGroup.getChildren()) { MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element); Vector2f position = mainGroup.getChildrenPosition().get(element); - if(mouseX > position.x && mouseX < position.x + element.getWidth()) { - if(mouseY > position.y && mouseY < position.y + element.getHeight()) { - if(mouseButton == 0) { + if (mouseX > position.x && mouseX < position.x + element.getWidth()) { + if (mouseY > position.y && mouseY < position.y + element.getHeight()) { + if (mouseButton == 0) { clickedElement = element; clickedX = mouseX; clickedY = mouseY; - clickedAnchorX = (int)anchorPoint.offset.x; - clickedAnchorY = (int)anchorPoint.offset.y; + clickedAnchorX = (int) anchorPoint.offset.x; + clickedAnchorY = (int) anchorPoint.offset.y; } else { - if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + 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]; + anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal() + 1) % vals.length]; mainGroup.recalculate(); @@ -145,9 +148,9 @@ public class NEUOverlayPlacements extends GuiScreen { mainGroup.recalculate(); - if(index == 0) { + if (index == 0) { NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString(); - } else if(index == 1) { + } else if (index == 1) { NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString(); } } @@ -158,7 +161,7 @@ public class NEUOverlayPlacements extends GuiScreen { index++; } - if(guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) { + if (guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) { NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = ""; NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = ""; NotEnoughUpdates.INSTANCE.overlay.resetAnchors(false); @@ -176,14 +179,14 @@ public class NEUOverlayPlacements extends GuiScreen { @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - if(clickedElement != null) { + if (clickedElement != null) { MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup; MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(clickedElement); - if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { int dX = mouseX - clickedX; int dY = mouseY - clickedY; - if(Math.abs(dX) > Math.abs(dY)) { + if (Math.abs(dX) > Math.abs(dY)) { anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX; anchorPoint.offset.y = clickedAnchorY; } else { @@ -196,18 +199,20 @@ public class NEUOverlayPlacements extends GuiScreen { } int index = 0; - for(MBGuiElement element : mainGroup.getChildren()) { - if(element == clickedElement) { - if(index == 0) { + for (MBGuiElement element : mainGroup.getChildren()) { + if (element == clickedElement) { + if (index == 0) { NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString(); - } else if(index == 1) { + } else if (index == 1) { NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString(); } break; } index++; } - try { MBDeserializer.serializeAndSave(mainGroup, "overlay"); } catch(Exception e) {} + try { + MBDeserializer.serializeAndSave(mainGroup, "overlay"); + } catch (Exception ignored) {} mainGroup.recalculate(); } } |
