From 7c00af18febf6c0b833c7633b4fb60a9a1bb93af Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:50:41 -0400 Subject: Code Clean Up (#2) * intellij code clean up * optimize imports * format * intellij suggestions * fix empty catch issues --- .../notenoughupdates/options/NEUConfigEditor.java | 526 +++++++++++---------- 1 file changed, 264 insertions(+), 262 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index 8e5edef1..f4702761 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -24,25 +24,26 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; import java.awt.*; import java.net.URI; -import java.util.*; import java.util.List; +import java.util.*; + +import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; public class NEUConfigEditor extends GuiElement { public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config); - private static final ResourceLocation[] socialsIco = new ResourceLocation[] { + private static final ResourceLocation[] socialsIco = new ResourceLocation[]{ DISCORD, GITHUB, TWITTER, YOUTUBE, PATREON }; - private static final String[] socialsLink = new String[] { + private static final String[] socialsLink = new String[]{ "https://discord.gg/moulberry", "https://github.com/Moulberry/NotEnoughUpdates", "https://twitter.com/moulberry/", @@ -59,16 +60,16 @@ public class NEUConfigEditor extends GuiElement { private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); - private LinkedHashMap processedConfig; - private TreeMap> searchOptionMap = new TreeMap<>(); - private HashMap categoryForOption = new HashMap<>(); + private final LinkedHashMap processedConfig; + private final TreeMap> searchOptionMap = new TreeMap<>(); + private final HashMap categoryForOption = new HashMap<>(); private Set searchedCategories = null; private Map> searchedAccordions = null; private Set searchedOptions = null; - private LerpingInteger minimumSearchSize = new LerpingInteger(0, 150); - private GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0); + private final LerpingInteger minimumSearchSize = new LerpingInteger(0, 150); + private final GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0); public NEUConfigEditor(Config config) { this(config, null); @@ -78,36 +79,36 @@ public class NEUConfigEditor extends GuiElement { this.openedMillis = System.currentTimeMillis(); this.processedConfig = ConfigProcessor.create(config); - for(ConfigProcessor.ProcessedCategory category : processedConfig.values()) { - for(ConfigProcessor.ProcessedOption option : category.options.values()) { + for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { + for (ConfigProcessor.ProcessedOption option : category.options.values()) { categoryForOption.put(option, category); String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc; combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); - for(String word : combined.split("[ _]")) { - searchOptionMap.computeIfAbsent(word, k->new HashSet<>()).add(option); + for (String word : combined.split("[ _]")) { + searchOptionMap.computeIfAbsent(word, k -> new HashSet<>()).add(option); } } } - if(categoryOpen != null) { - for(Map.Entry category : processedConfig.entrySet()) { - if(category.getValue().name.equalsIgnoreCase(categoryOpen)) { + if (categoryOpen != null) { + for (Map.Entry category : processedConfig.entrySet()) { + if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { selectedCategory = category.getKey(); break; } } - if(selectedCategory == null) { - for(Map.Entry category : processedConfig.entrySet()) { - if(category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { + if (selectedCategory == null) { + for (Map.Entry category : processedConfig.entrySet()) { + if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { selectedCategory = category.getKey(); break; } } } - if(selectedCategory == null) { - for(Map.Entry category : processedConfig.entrySet()) { - if(category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { + if (selectedCategory == null) { + for (Map.Entry category : processedConfig.entrySet()) { + if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { selectedCategory = category.getKey(); break; } @@ -120,26 +121,26 @@ public class NEUConfigEditor extends GuiElement { private LinkedHashMap getCurrentConfigEditing() { LinkedHashMap newMap = new LinkedHashMap<>(processedConfig); - if(searchedCategories != null) newMap.values().retainAll(searchedCategories); + if (searchedCategories != null) newMap.values().retainAll(searchedCategories); return newMap; } private LinkedHashMap getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) { LinkedHashMap newMap = new LinkedHashMap<>(cat.options); - if(searchedOptions != null) { + if (searchedOptions != null) { Set retain = new HashSet<>(); retain.addAll(searchedOptions); - if(searchedAccordions != null) { + if (searchedAccordions != null) { Set visibleAccordions = searchedAccordions.get(cat); - if(visibleAccordions != null && !visibleAccordions.isEmpty()) { - for(ConfigProcessor.ProcessedOption option : newMap.values()) { - if(option.editor instanceof GuiOptionEditorAccordion) { - int accordionId = ((GuiOptionEditorAccordion)option.editor).getAccordionId(); + if (visibleAccordions != null && !visibleAccordions.isEmpty()) { + for (ConfigProcessor.ProcessedOption option : newMap.values()) { + if (option.editor instanceof GuiOptionEditorAccordion) { + int accordionId = ((GuiOptionEditorAccordion) option.editor).getAccordionId(); - if(visibleAccordions.contains(accordionId)) { + if (visibleAccordions.contains(accordionId)) { retain.add(option); } } @@ -172,12 +173,12 @@ public class NEUConfigEditor extends GuiElement { searchedOptions = null; searchedAccordions = null; - if(!search.isEmpty()) { + if (!search.isEmpty()) { searchedCategories = new HashSet<>(); searchedAccordions = new HashMap<>(); - for(String word : search.split(" ")) { - if(word.trim().isEmpty()) continue; + for (String word : search.split(" ")) { + if (word.trim().isEmpty()) continue; Set options = new HashSet<>(); @@ -186,8 +187,8 @@ public class NEUConfigEditor extends GuiElement { map.values().forEach(options::addAll); - if(!options.isEmpty()) { - if(searchedOptions == null) { + if (!options.isEmpty()) { + if (searchedOptions == null) { searchedOptions = new HashSet<>(options); } else { searchedOptions.retainAll(options); @@ -195,15 +196,15 @@ public class NEUConfigEditor extends GuiElement { } } - if(searchedOptions == null) { - searchedOptions = new HashSet<>(); + if (searchedOptions == null) { + searchedOptions = new HashSet<>(); } else { - for(ConfigProcessor.ProcessedOption option : searchedOptions) { + for (ConfigProcessor.ProcessedOption option : searchedOptions) { ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option); - if(cat == null) continue; + if (cat == null) continue; searchedCategories.add(cat); - searchedAccordions.computeIfAbsent(cat, k->new HashSet<>()).add(option.accordionId); + searchedAccordions.computeIfAbsent(cat, k -> new HashSet<>()).add(option.accordionId); } } } @@ -224,232 +225,232 @@ public class NEUConfigEditor extends GuiElement { int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - float opacityFactor = LerpUtils.sigmoidZeroOne(delta/500f); + float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); RenderUtils.drawGradientRect(0, 0, 0, width, height, - (int)(0x80*opacityFactor) << 24 | 0x101010, - (int)(0x90*opacityFactor) << 24 | 0x101010); + (int) (0x80 * opacityFactor) << 24 | 0x101010, + (int) (0x90 * opacityFactor) << 24 | 0x101010); - int xSize = Math.min(scaledResolution.getScaledWidth()-100/scaledResolution.getScaleFactor(), 500); - int ySize = Math.min(scaledResolution.getScaledHeight()-100/scaledResolution.getScaleFactor(), 400); + int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400); - int x = (scaledResolution.getScaledWidth() - xSize)/2; - int y = (scaledResolution.getScaledHeight() - ySize)/2; + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); int openingXSize = xSize; int openingYSize = ySize; - if(delta < 150) { - openingXSize = (int)(delta*xSize/150); + if (delta < 150) { + openingXSize = (int) (delta * xSize / 150); openingYSize = 5; - } else if(delta < 300) { - openingYSize = 5 + (int)(delta-150)*(ySize-5)/150; + } else if (delta < 300) { + openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; } RenderUtils.drawFloatingRectDark( - (scaledResolution.getScaledWidth() - openingXSize)/2, - (scaledResolution.getScaledHeight() - openingYSize)/2, + (scaledResolution.getScaledWidth() - openingXSize) / 2, + (scaledResolution.getScaledHeight() - openingYSize) / 2, openingXSize, openingYSize); GlScissorStack.clear(); - GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize)/2, - (scaledResolution.getScaledHeight() - openingYSize)/2, - (scaledResolution.getScaledWidth() + openingXSize)/2, - (scaledResolution.getScaledHeight() + openingYSize)/2, scaledResolution); + GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize) / 2, + (scaledResolution.getScaledHeight() - openingYSize) / 2, + (scaledResolution.getScaledWidth() + openingXSize) / 2, + (scaledResolution.getScaledHeight() + openingYSize) / 2, scaledResolution); - RenderUtils.drawFloatingRectDark(x+5, y+5, xSize-10, 20, false); + RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - TextRenderUtils.drawStringCenteredScaledMaxWidth("NotEnoughUpdates by "+EnumChatFormatting.DARK_PURPLE+"Moulberry", - fr, x+xSize/2, y+15, false, 200, 0xa0a0a0); - - RenderUtils.drawFloatingRectDark(x+4, y+49-20, - 140, ySize-54+20, false); - - int innerPadding = 20/adjScaleFactor; - int innerLeft = x+4+innerPadding; - int innerRight = x+144-innerPadding; - int innerTop = y+49+innerPadding; - int innerBottom = y+ySize-5-innerPadding; - Gui.drawRect(innerLeft, innerTop, innerLeft+1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft+1, innerTop, innerRight, innerTop+1, 0xff08080E); //Top - Gui.drawRect(innerRight-1, innerTop+1, innerRight, innerBottom, 0xff28282E); //Right - Gui.drawRect(innerLeft+1, innerBottom-1, innerRight-1, innerBottom, 0xff28282E); //Bottom - Gui.drawRect(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, 0x6008080E); //Middle - - GlScissorStack.push(0, innerTop+1, scaledResolution.getScaledWidth(), - innerBottom-1, scaledResolution); + TextRenderUtils.drawStringCenteredScaledMaxWidth("NotEnoughUpdates by " + EnumChatFormatting.DARK_PURPLE + "Moulberry", + fr, x + xSize / 2, y + 15, false, 200, 0xa0a0a0); + + RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, + 140, ySize - 54 + 20, false); + + int innerPadding = 20 / adjScaleFactor; + int innerLeft = x + 4 + innerPadding; + int innerRight = x + 144 - innerPadding; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff28282E); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff28282E); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle + + GlScissorStack.push(0, innerTop + 1, scaledResolution.getScaledWidth(), + innerBottom - 1, scaledResolution); float catBarSize = 1; int catY = -categoryScroll.getValue(); LinkedHashMap currentConfigEditing = getCurrentConfigEditing(); - for(Map.Entry entry : currentConfigEditing.entrySet()) { + for (Map.Entry entry : currentConfigEditing.entrySet()) { String selectedCategory = getSelectedCategory(); - if(selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { + if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { setSelectedCategory(entry.getKey()); } String catName = entry.getValue().name; - if(entry.getKey().equals(getSelectedCategory())) { + if (entry.getKey().equals(getSelectedCategory())) { catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName; } else { catName = EnumChatFormatting.GRAY + catName; } TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, - fr, x+75, y+70+catY, false, 100, -1); + fr, x + 75, y + 70 + catY, false, 100, -1); catY += 15; - if(catY > 0) { - catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+categoryScroll.getValue())); + if (catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue())); } } - float catBarStart = categoryScroll.getValue() / (float)(catY + categoryScroll.getValue()); - float catBarEnd = catBarStart+catBarSize; - if(catBarEnd > 1) { + float catBarStart = categoryScroll.getValue() / (float) (catY + categoryScroll.getValue()); + float catBarEnd = catBarStart + catBarSize; + if (catBarEnd > 1) { catBarEnd = 1; - if(categoryScroll.getTarget()/(float)(catY + categoryScroll.getValue())+catBarSize < 1) { + if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { int target = optionsScroll.getTarget(); - categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue()))); + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); categoryScroll.setTarget(target); } else { - categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue()))); + categoryScroll.setValue((int) Math.ceil((catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); } } - int catDist = innerBottom-innerTop-12; - Gui.drawRect(innerLeft+2, innerTop+5, innerLeft+7, innerBottom-5, 0xff101010); - Gui.drawRect(innerLeft+3, innerTop+6+(int)(catDist*catBarStart), innerLeft+6, - innerTop+6+(int)(catDist*catBarEnd), 0xff303030); + int catDist = innerBottom - innerTop - 12; + Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010); + Gui.drawRect(innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), innerLeft + 6, + innerTop + 6 + (int) (catDist * catBarEnd), 0xff303030); GlScissorStack.pop(scaledResolution); TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", - fr, x+75, y+44, false, 120, 0xa368ef); + fr, x + 75, y + 44, false, 120, 0xa368ef); - RenderUtils.drawFloatingRectDark(x+149, y+29, xSize-154, ySize-34, false); + RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false); - innerLeft = x+149+innerPadding; - innerRight =x+xSize-5-innerPadding; - innerBottom = y+ySize-5-innerPadding; + innerLeft = x + 149 + innerPadding; + innerRight = x + xSize - 5 - innerPadding; + innerBottom = y + ySize - 5 - innerPadding; Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_ICON); GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(innerRight-20, innerTop-(20+innerPadding)/2-9, 18, 18, GL11.GL_NEAREST); + Utils.drawTexturedRect(innerRight - 20, innerTop - (20 + innerPadding) / 2 - 9, 18, 18, GL11.GL_NEAREST); minimumSearchSize.tick(); boolean shouldShow = !searchField.getText().trim().isEmpty() || searchField.getFocus(); - if(shouldShow && minimumSearchSize.getTarget() < 30) { + if (shouldShow && minimumSearchSize.getTarget() < 30) { minimumSearchSize.setTarget(30); minimumSearchSize.resetTimer(); - } else if(!shouldShow && minimumSearchSize.getTarget() > 0) { + } else if (!shouldShow && minimumSearchSize.getTarget() > 0) { minimumSearchSize.setTarget(0); minimumSearchSize.resetTimer(); } int rightStuffLen = 20; - if(minimumSearchSize.getValue() > 1) { - int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10; - if(!shouldShow) strLen = 0; + if (minimumSearchSize.getValue() > 1) { + int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10; + if (!shouldShow) strLen = 0; int len = Math.max(strLen, minimumSearchSize.getValue()); searchField.setSize(len, 18); - searchField.render(innerRight-25-len, innerTop-(20+innerPadding)/2-9); + searchField.render(innerRight - 25 - len, innerTop - (20 + innerPadding) / 2 - 9); rightStuffLen += 5 + len; } - if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); TextRenderUtils.drawStringScaledMaxWidth(cat.desc, - fr, innerLeft+5, y+40, true, innerRight-innerLeft-rightStuffLen-10, 0xb0b0b0); + fr, innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0); } - Gui.drawRect(innerLeft, innerTop, innerLeft+1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft+1, innerTop, innerRight, innerTop+1, 0xff08080E); //Top - Gui.drawRect(innerRight-1, innerTop+1, innerRight, innerBottom, 0xff303036); //Right - Gui.drawRect(innerLeft+1, innerBottom-1, innerRight-1, innerBottom, 0xff303036); //Bottom - Gui.drawRect(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, 0x6008080E); //Middle + Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left + Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top + Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff303036); //Right + Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff303036); //Bottom + Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle - GlScissorStack.push(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, scaledResolution); + GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution); float barSize = 1; int optionY = -optionsScroll.getValue(); - if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - int optionWidthDefault = innerRight-innerLeft-20; + int optionWidthDefault = innerRight - innerLeft - 20; GlStateManager.enableDepth(); HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { continue; } int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { + if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { + if (accordion.getToggled()) { int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; } activeAccordions.put(accordion.getAccordionId(), accordionDepth); } } int optionHeight = editor.getHeight(); - if(innerTop+5+optionY+optionHeight > innerTop+1 && innerTop+5+optionY < innerBottom-1) { - editor.render((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth); + if (innerTop + 5 + optionY + optionHeight > innerTop + 1 && innerTop + 5 + optionY < innerBottom - 1) { + editor.render((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth); } optionY += optionHeight + 5; } GlStateManager.disableDepth(); - if(optionY > 0) { - barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5+optionsScroll.getValue())); + if (optionY > 0) { + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue())); } } GlScissorStack.pop(scaledResolution); GL11.glDisable(GL11.GL_SCISSOR_TEST); - if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { + if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { int optionYOverlay = -optionsScroll.getValue(); ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - int optionWidthDefault = innerRight-innerLeft-20; + int optionWidthDefault = innerRight - innerLeft - 20; GlStateManager.translate(0, 0, 10); GlStateManager.enableDepth(); HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { continue; } int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { + if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { + if (accordion.getToggled()) { int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; } activeAccordions.put(accordion.getAccordionId(), accordionDepth); } } int optionHeight = editor.getHeight(); - if(innerTop+5+optionYOverlay+optionHeight > innerTop+1 && innerTop+5+optionYOverlay < innerBottom-1) { - editor.renderOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionYOverlay, optionWidth); + if (innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && innerTop + 5 + optionYOverlay < innerBottom - 1) { + editor.renderOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionYOverlay, optionWidth); } optionYOverlay += optionHeight + 5; } @@ -458,37 +459,37 @@ public class NEUConfigEditor extends GuiElement { } GL11.glEnable(GL11.GL_SCISSOR_TEST); - float barStart = optionsScroll.getValue() / (float)(optionY + optionsScroll.getValue()); - float barEnd = barStart+barSize; - if(barEnd > 1) { + float barStart = optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue()); + float barEnd = barStart + barSize; + if (barEnd > 1) { barEnd = 1; - if(optionsScroll.getTarget()/(float)(optionY + optionsScroll.getValue())+barSize < 1) { + if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { int target = optionsScroll.getTarget(); - optionsScroll.setValue((int)Math.ceil((optionY+5+optionsScroll.getValue())-barSize*(optionY+5+optionsScroll.getValue()))); + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); optionsScroll.setTarget(target); } else { - optionsScroll.setValue((int)Math.ceil((optionY+5+optionsScroll.getValue())-barSize*(optionY+5+optionsScroll.getValue()))); + optionsScroll.setValue((int) Math.ceil((optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); } } - int dist = innerBottom-innerTop-12; - Gui.drawRect(innerRight-10, innerTop+5, innerRight-5, innerBottom-5, 0xff101010); - Gui.drawRect(innerRight-9, innerTop+6+(int)(dist*barStart), innerRight-6, innerTop+6+(int)(dist*barEnd), 0xff303030); + int dist = innerBottom - innerTop - 12; + Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010); + Gui.drawRect(innerRight - 9, innerTop + 6 + (int) (dist * barStart), innerRight - 6, innerTop + 6 + (int) (dist * barEnd), 0xff303030); - for(int socialIndex=0; socialIndex= socialLeft && mouseX <= socialLeft+16 && - mouseY >= y+6 && mouseY <= y+23) { - tooltipToDisplay = Lists.newArrayList(EnumChatFormatting.YELLOW+"Go to: "+EnumChatFormatting.RESET+socialsLink[socialIndex]); + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && + mouseY >= y + 6 && mouseY <= y + 23) { + tooltipToDisplay = Lists.newArrayList(EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); } } GlScissorStack.clear(); - if(tooltipToDisplay != null) { + if (tooltipToDisplay != null) { TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); } @@ -500,128 +501,128 @@ public class NEUConfigEditor extends GuiElement { int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); - int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500); - int ySize = Math.min(height-100/scaledResolution.getScaleFactor(), 400); + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); + int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400); - int x = (scaledResolution.getScaledWidth() - xSize)/2; - int y = (scaledResolution.getScaledHeight() - ySize)/2; + int x = (scaledResolution.getScaledWidth() - xSize) / 2; + int y = (scaledResolution.getScaledHeight() - ySize) / 2; int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - int innerPadding = 20/adjScaleFactor; - int innerTop = y+49+innerPadding; - int innerBottom = y+ySize-5-innerPadding; - int innerLeft = x+149+innerPadding; - int innerRight = x+xSize-5-innerPadding; + int innerPadding = 20 / adjScaleFactor; + int innerTop = y + 49 + innerPadding; + int innerBottom = y + ySize - 5 - innerPadding; + int innerLeft = x + 149 + innerPadding; + int innerRight = x + xSize - 5 - innerPadding; - if(Mouse.getEventButtonState()) { - searchField.setFocus(mouseX >= innerRight-20 && mouseX <= innerRight-2 && - mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9); + if (Mouse.getEventButtonState()) { + searchField.setFocus(mouseX >= innerRight - 20 && mouseX <= innerRight - 2 && + mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9); - if(minimumSearchSize.getValue() > 1) { - int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10; + if (minimumSearchSize.getValue() > 1) { + int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10; int len = Math.max(strLen, minimumSearchSize.getValue()); - if(mouseX >= innerRight-25-len && mouseX <= innerRight-25 && - mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9) { + if (mouseX >= innerRight - 25 - len && mouseX <= innerRight - 25 && + mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9) { String old = searchField.getText(); searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - if(!searchField.getText().equals(old)) search(); + if (!searchField.getText().equals(old)) search(); } } } int dWheel = Mouse.getEventDWheel(); - if(mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { - if(dWheel < 0) { + if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { + if (dWheel < 0) { dWheel = -1; } - if(dWheel > 0) { + if (dWheel > 0) { dWheel = 1; } - if(mouseX < innerLeft) { - int newTarget = categoryScroll.getTarget() - dWheel*30; - if(newTarget < 0) { + if (mouseX < innerLeft) { + int newTarget = categoryScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { newTarget = 0; } float catBarSize = 1; int catY = -newTarget; - for(Map.Entry entry : getCurrentConfigEditing().entrySet()) { - if(getSelectedCategory() == null) { + for (Map.Entry entry : getCurrentConfigEditing().entrySet()) { + if (getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } catY += 15; - if(catY > 0) { - catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+newTarget)); + if (catY > 0) { + catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); } } - int barMax = (int)Math.floor((catY+5+newTarget)-catBarSize*(catY+5+newTarget)); - if(newTarget > barMax) { + int barMax = (int) Math.floor((catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget)); + if (newTarget > barMax) { newTarget = barMax; } categoryScroll.resetTimer(); categoryScroll.setTarget(newTarget); } else { - int newTarget = optionsScroll.getTarget() - dWheel*30; - if(newTarget < 0) { + int newTarget = optionsScroll.getTarget() - dWheel * 30; + if (newTarget < 0) { newTarget = 0; } float barSize = 1; int optionY = -newTarget; - if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { continue; } } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { + if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { + if (accordion.getToggled()) { int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; } activeAccordions.put(accordion.getAccordionId(), accordionDepth); } } optionY += editor.getHeight() + 5; - if(optionY > 0) { - barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5 + newTarget)); + if (optionY > 0) { + barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget)); } } } - int barMax = (int)Math.floor((optionY+5+newTarget)-barSize*(optionY+5+newTarget)); - if(newTarget > barMax) { + int barMax = (int) Math.floor((optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget)); + if (newTarget > barMax) { newTarget = barMax; } - optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5*Math.abs(newTarget - optionsScroll.getValue())))); + optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue())))); optionsScroll.resetTimer(); optionsScroll.setTarget(newTarget); } - } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if(getCurrentConfigEditing() != null) { + } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { + if (getCurrentConfigEditing() != null) { int catY = -categoryScroll.getValue(); - for(Map.Entry entry : getCurrentConfigEditing().entrySet()) { - if(getSelectedCategory() == null) { + for (Map.Entry entry : getCurrentConfigEditing().entrySet()) { + if (getSelectedCategory() == null) { setSelectedCategory(entry.getKey()); } - if(mouseX >= x+5 && mouseX <= x+145 && - mouseY >= y+70+catY-7 && mouseY <= y+70+catY+7) { + if (mouseX >= x + 5 && mouseX <= x + 145 && + mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) { setSelectedCategory(entry.getKey()); return true; } @@ -629,86 +630,87 @@ public class NEUConfigEditor extends GuiElement { } } - for(int socialIndex=0; socialIndex= socialLeft && mouseX <= socialLeft+16 && - mouseY >= y+6 && mouseY <= y+23) { + if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && + mouseY >= y + 6 && mouseY <= y + 23) { try { Desktop.getDesktop().browse(new URI(socialsLink[socialIndex])); - } catch(Exception ignored) {} + } catch (Exception ignored) {} return true; } } } int optionY = -optionsScroll.getValue(); - if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidthDefault = innerRight-innerLeft-20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + int optionWidthDefault = innerRight - innerLeft - 20; + ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); + HashMap activeAccordions = new HashMap<>(); + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { continue; } int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { + if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { + if (accordion.getToggled()) { int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; } activeAccordions.put(accordion.getAccordionId(), accordionDepth); } } - if(editor.mouseInputOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { + if (editor.mouseInputOverlay((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; } } - if(mouseX > innerLeft && mouseX < innerRight && + if (mouseX > innerLeft && mouseX < innerRight && mouseY > innerTop && mouseY < innerBottom) { optionY = -optionsScroll.getValue(); - if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidthDefault = innerRight-innerLeft-20; + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + int optionWidthDefault = innerRight - innerLeft - 20; ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { int optionWidth = optionWidthDefault; - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { - continue; + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { + continue; + } + int accordionDepth = activeAccordions.get(option.accordionId); + optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); } - int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1); - } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { - int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (editor instanceof GuiOptionEditorAccordion) { + GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; + if (accordion.getToggled()) { + int accordionDepth = 0; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; + } + activeAccordions.put(accordion.getAccordionId(), accordionDepth); } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); } - } - if(editor.mouseInput((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) { + if (editor.mouseInput((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) { return true; } optionY += editor.getHeight() + 5; @@ -723,47 +725,47 @@ public class NEUConfigEditor extends GuiElement { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); - int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500); + int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - int innerPadding = 20/adjScaleFactor; - int innerWidth = xSize-154-innerPadding*2; + int innerPadding = 20 / adjScaleFactor; + int innerWidth = xSize - 154 - innerPadding * 2; - if(Keyboard.getEventKeyState()) { + if (Keyboard.getEventKeyState()) { Keyboard.enableRepeatEvents(true); String old = searchField.getText(); searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(searchField.getText(), innerWidth/2-20)); + searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(searchField.getText(), innerWidth / 2 - 20)); - if(!searchField.getText().equals(old)) search(); + if (!searchField.getText().equals(old)) search(); } - if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { + if (getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); HashMap activeAccordions = new HashMap<>(); - for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - if(option.accordionId >= 0) { - if(!activeAccordions.containsKey(option.accordionId)) { + for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { + if (option.accordionId >= 0) { + if (!activeAccordions.containsKey(option.accordionId)) { continue; } } GuiOptionEditor editor = option.editor; - if(editor == null) { + if (editor == null) { continue; } - if(editor instanceof GuiOptionEditorAccordion) { + if (editor instanceof GuiOptionEditorAccordion) { GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if(accordion.getToggled()) { + if (accordion.getToggled()) { int accordionDepth = 0; - if(option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId)+1; + if (option.accordionId >= 0) { + accordionDepth = activeAccordions.get(option.accordionId) + 1; } activeAccordions.put(accordion.getAccordionId(), accordionDepth); } } - if(editor.keyboardInput()) { + if (editor.keyboardInput()) { return true; } } -- cgit From c37dab7e54654c033bfff63461490bac6c86f6c7 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Sat, 13 Nov 2021 11:50:32 +0100 Subject: Changing Patreon to Twitch - bcs moul bad (#24) * Changing Patreon to Twitch * Change Icon again --- .../io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index f4702761..67e61114 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -41,14 +41,14 @@ public class NEUConfigEditor extends GuiElement { GITHUB, TWITTER, YOUTUBE, - PATREON + TWITCH }; private static final String[] socialsLink = new String[]{ "https://discord.gg/moulberry", "https://github.com/Moulberry/NotEnoughUpdates", "https://twitter.com/moulberry/", "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw", - "https://patreon.com/moulberry" + "https://www.twitch.tv/moulberry2" }; private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png"); -- cgit From ea3ec354ba3bb5b4ac64b8032816b8e4c407f099 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 28 Dec 2021 00:49:28 -0500 Subject: more code clean up (#38) --- .../io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index 67e61114..da94d1e1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -33,7 +33,6 @@ import java.util.*; import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; public class NEUConfigEditor extends GuiElement { - public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config); private static final ResourceLocation[] socialsIco = new ResourceLocation[]{ -- cgit From 593b2c8c1078d0bf40d08d3f100afb8f947da422 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Sun, 30 Jan 2022 14:21:24 +0100 Subject: Added patreon back and made so settings look better (#72) * Added patreon back * Make settings look better --- .../io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index da94d1e1..41739ece 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -40,6 +40,7 @@ public class NEUConfigEditor extends GuiElement { GITHUB, TWITTER, YOUTUBE, + PATREON, TWITCH }; private static final String[] socialsLink = new String[]{ @@ -47,6 +48,7 @@ public class NEUConfigEditor extends GuiElement { "https://github.com/Moulberry/NotEnoughUpdates", "https://twitter.com/moulberry/", "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw", + "https://patreon.com/moulberry", "https://www.twitch.tv/moulberry2" }; -- cgit From b09f774d422263ce15b97d6d0804beddf856176d Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sun, 27 Feb 2022 11:53:57 -0500 Subject: feat: improve formating :) --- .../notenoughupdates/options/NEUConfigEditor.java | 1540 ++++++++++---------- 1 file changed, 799 insertions(+), 741 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index 41739ece..6681a994 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -33,745 +33,803 @@ import java.util.*; import static io.github.moulberry.notenoughupdates.util.GuiTextures.*; public class NEUConfigEditor extends GuiElement { - public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config); - - private static final ResourceLocation[] socialsIco = new ResourceLocation[]{ - DISCORD, - GITHUB, - TWITTER, - YOUTUBE, - PATREON, - TWITCH - }; - private static final String[] socialsLink = new String[]{ - "https://discord.gg/moulberry", - "https://github.com/Moulberry/NotEnoughUpdates", - "https://twitter.com/moulberry/", - "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw", - "https://patreon.com/moulberry", - "https://www.twitch.tv/moulberry2" - }; - - private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png"); - - private final long openedMillis; - - private String selectedCategory = null; - - private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); - private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); - - private final LinkedHashMap processedConfig; - private final TreeMap> searchOptionMap = new TreeMap<>(); - private final HashMap categoryForOption = new HashMap<>(); - - private Set searchedCategories = null; - private Map> searchedAccordions = null; - private Set searchedOptions = null; - - private final LerpingInteger minimumSearchSize = new LerpingInteger(0, 150); - private final GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0); - - public NEUConfigEditor(Config config) { - this(config, null); - } - - public NEUConfigEditor(Config config, String categoryOpen) { - this.openedMillis = System.currentTimeMillis(); - this.processedConfig = ConfigProcessor.create(config); - - for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { - for (ConfigProcessor.ProcessedOption option : category.options.values()) { - categoryForOption.put(option, category); - - String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc; - combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); - for (String word : combined.split("[ _]")) { - searchOptionMap.computeIfAbsent(word, k -> new HashSet<>()).add(option); - } - } - } - - if (categoryOpen != null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { - selectedCategory = category.getKey(); - break; - } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { - selectedCategory = category.getKey(); - break; - } - } - } - if (selectedCategory == null) { - for (Map.Entry category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { - selectedCategory = category.getKey(); - break; - } - } - } - } - - editor = this; - } - - private LinkedHashMap getCurrentConfigEditing(