diff options
author | YannickMG <yannickmg@gmail.com> | 2022-07-06 15:35:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 20:35:36 +0100 |
commit | 7836eea57a199661e1ac4b41d9ae678e62588ee2 (patch) | |
tree | ed9c71b33553fcdc58b52664b1efb3dbe4e3cb45 /src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java | |
parent | 1cb11f470f296eb4db63174f7e58b17c7af7000d (diff) | |
download | GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.gz GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.tar.bz2 GT5-Unofficial-7836eea57a199661e1ac4b41d9ae678e62588ee2.zip |
Enhanced NEI discoverability (#17)
* Removed unused code
* Addressed IDE warnings
* Refactored PluginGT5VeinStat::loadCraftingRecipes for readability
* Refactored PluginGT5VeinStat::drawExtras for readability
* Added OreVeinLayer class for the concept of ore layer
* Updated buildscript
* Ran spotlessApply
* Addressed some trivial IDE warnings
* Load both Small Ores and regular Ores when either is queried.
* Refactored PluginGT5SmallOreStat::loadCraftingRecipes for readability
* Refactored PluginGT5SmallOreStat::drawExtras for readability
Diffstat (limited to 'src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java')
-rw-r--r-- | src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java index d4c340a9be..20e524ec41 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java @@ -1,8 +1,7 @@ package pers.gwyog.gtneioreplugin.util; -import java.util.Arrays; import com.google.common.base.Strings; - +import java.util.Arrays; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -13,15 +12,16 @@ public class StringPaddingHack { /** * Given a list of strings, arrange them into the requested number of columns with the specified spacing. * Up to 3 additional spaces might be added between columns because this function relies on quirky font behaviors. - * + * * @param strings List of strings to wrap into columns * @param numColumns Number of columns, minimum of 1 * @param minColumnSpacing Minimum amount of extra spaces between columns. - * @return + * @return strings wrapped into columns */ public static String[] stringsToSpacedColumns(String[] strings, int numColumns, int minColumnSpacing) { if (numColumns < 1) { - throw new IllegalArgumentException(String.format("Argument numColumns must be 1 or higher, got value %d", numColumns)); + throw new IllegalArgumentException( + String.format("Argument numColumns must be 1 or higher, got value %d", numColumns)); } if (numColumns > 1) { int sliceSize = strings.length / numColumns; @@ -36,37 +36,37 @@ public class StringPaddingHack { remainder--; extra = 1; } - columns[i] = Arrays.copyOfRange(strings, (sliceSize * i) + totalExtra, (sliceSize * (i + 1) + totalExtra + extra)); + columns[i] = Arrays.copyOfRange( + strings, (sliceSize * i) + totalExtra, (sliceSize * (i + 1) + totalExtra + extra)); totalExtra += extra; } // Add extra padding to all but the last columns to align the text - for(int i = 0; i < numColumns - 1; i++) { + for (int i = 0; i < numColumns - 1; i++) { columns[i] = padStrings(columns[i], minColumnSpacing); } - + // Concatenate all columns into the final result - strings = columns[0]; - for (int i = 0; i < sliceSize; i++ ) { - for (int j = 1; j < numColumns; j++ ) { + strings = columns[0]; + for (int i = 0; i < sliceSize; i++) { + for (int j = 1; j < numColumns; j++) { strings[i] += columns[j][i]; } } } - + return strings; } - /** * Pads strings with spaces so that they are of equal length and adds to * that the number of spaces specified and up to 3 if minExtraSpaces is * below 3. Added spaces might be bold. - * + * * Relies on the quirk of bold space characters being 1 pixel wider than * regular space characters in the default font renderer. - * + * * @param strings List of strings * @param minExtraSpaces The minimum number of extra spaces to add * @return List of strings padded with spaces to an equal length @@ -76,7 +76,7 @@ public class StringPaddingHack { int maxUnPaddedStrLength = 0; int numSpacesAddedToLongestString = 0; int maxPaddedStrLength = 0; - + // Making string width a multiple of 4 by adding bold spaces of width 5 for (int i = 0; i < strings.length; i++) { int mod = widths[i] % SPACE_WIDTH; @@ -88,7 +88,7 @@ public class StringPaddingHack { maxUnPaddedStrLength = widths[i]; } - strings[i] += "§l" + Strings.repeat(" ", numBoldSpacesToAdd ) + "§r"; + strings[i] += "§l" + Strings.repeat(" ", numBoldSpacesToAdd) + "§r"; widths[i] += numBoldSpacesToAdd * BOLD_SPACE_WIDTH; // Keep track of the current widest string we currently have @@ -96,7 +96,7 @@ public class StringPaddingHack { maxPaddedStrLength = widths[i]; } } - + // Make sure we pad at least up to the desired number of spaces from the longest string if (numSpacesAddedToLongestString < minExtraSpaces) { maxPaddedStrLength += (minExtraSpaces - numSpacesAddedToLongestString) * SPACE_WIDTH; @@ -114,7 +114,7 @@ public class StringPaddingHack { /** * Returns an array of font widths for the given array of strings - * + * * @param strList Array of strings * @return Array of font widths */ |