From 9f4ea5d9d65607cc1563ea493b5a989862c4aefe Mon Sep 17 00:00:00 2001 From: YannickMG Date: Thu, 23 Dec 2021 17:40:28 -0500 Subject: Tooltip rework (#13) * Draft for unified build script * Update gradle, build script and streamline dependencies * Fixed string typos Fixed VisualProspecting vein name missing whitespace * Several dimension name fixes: - Handle tooltip display for individual recipes when multiple are visible - Don't hide the background when tooltip is shown - Tooltip trigger area more precise - Dimension names appear in progression order both in abbreviated and tooltip forms - Customizable dimension name tooltip max line count * Removed some dead code Especially asteroid handling separate from vein handling There's more still to remove * Javadoc for StringPaddingHack class Also comment cleanup * Fixed more misnamed dimensions Co-authored-by: Johann Bernhardt --- .../pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java | 9 +- .../gtneioreplugin/plugin/NEIPluginConfig.java | 5 - .../gwyog/gtneioreplugin/plugin/PluginBase.java | 16 +- .../plugin/gregtech5/PluginGT5AsteroidStat.java | 143 ----------------- .../plugin/gregtech5/PluginGT5Base.java | 111 +++++++++---- .../plugin/gregtech5/PluginGT5SmallOreStat.java | 42 ++--- .../plugin/gregtech5/PluginGT5VeinStat.java | 60 ++++--- .../gwyog/gtneioreplugin/util/DimensionHelper.java | 174 ++++++++++++--------- .../gwyog/gtneioreplugin/util/GT5CFGHelper.java | 20 +-- .../gtneioreplugin/util/StringPaddingHack.java | 129 +++++++++++++++ src/main/resources/META-INF/gtneioreplugin_at.cfg | 5 + .../assets/gtneioreplugin/lang/en_US.lang | 22 +-- 12 files changed, 387 insertions(+), 349 deletions(-) delete mode 100644 src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5AsteroidStat.java create mode 100644 src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java create mode 100644 src/main/resources/META-INF/gtneioreplugin_at.cfg (limited to 'src') diff --git a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java index 28ecd5063c..7b52bd44c6 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/GTNEIOrePlugin.java @@ -10,8 +10,6 @@ import org.apache.logging.log4j.Logger; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; -import java.util.HashSet; - @Mod(modid = GTNEIOrePlugin.MODID, name = GTNEIOrePlugin.NAME, version = GTNEIOrePlugin.VERSION, dependencies = "required-after:gregtech;required-after:NotEnoughItems") public class GTNEIOrePlugin { public static final String MODID = "GRADLETOKEN_MODID"; @@ -21,9 +19,8 @@ public class GTNEIOrePlugin { public static boolean csv = false; public static String CSVname; public static String CSVnameSmall; - public static HashSet OreV = new HashSet(); - public static boolean hideBackground = true; public static boolean toolTips = true; + public static int maxTooltipLines = 11; @Mod.Instance(MODID) public static GTNEIOrePlugin instance; @@ -33,8 +30,8 @@ public class GTNEIOrePlugin { csv = c.tConfig.getBoolean("print csv", "ALL", false, "princsv, you need apache commons collections to be injected in the minecraft jar."); CSVname = c.tConfig.getString("CSV_name", "ALL", event.getModConfigurationDirectory() + "/GTNH-Oresheet.csv", "rename the oresheet here, it will appear in /config"); CSVnameSmall= c.tConfig.getString("CSV_name_for_Small_Ore_Sheet", "ALL", event.getModConfigurationDirectory() + "/GTNH-Small-Ores-Sheet.csv", "rename the oresheet here, it will appear in /config"); - hideBackground = c.tConfig.getBoolean("Hide Background", "ALL", true, "Hides the Background when the tooltip for the Dimensions is rendered"); - toolTips = c.tConfig.getBoolean("DimTooltip", "ALL", true, "Activates Dimensison Tooltips"); + toolTips = c.tConfig.getBoolean("DimTooltip", "ALL", true, "Activates Dimension Tooltips"); + maxTooltipLines = c.tConfig.getInt("MaxToolTipLines", "ALL", 11, 1, Integer.MAX_VALUE, "Maximum number of lines the dimension names tooltip can have before it wraps around."); c.save(); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java index 8283b3b263..ee76cff2d2 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/NEIPluginConfig.java @@ -6,8 +6,6 @@ import pers.gwyog.gtneioreplugin.GTNEIOrePlugin; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat; -//import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5AsteroidStat; - public class NEIPluginConfig implements IConfigureNEI { @Override @@ -23,12 +21,9 @@ public class NEIPluginConfig implements IConfigureNEI { @Override public void loadConfig() { PluginGT5VeinStat pluginVeinStat = new PluginGT5VeinStat(); - //PluginGT5AsteroidStat pluginAsteriodStat = new PluginGT5AsteroidStat(); PluginGT5SmallOreStat pluginSmallOreStat = new PluginGT5SmallOreStat(); API.registerRecipeHandler(pluginVeinStat); API.registerUsageHandler(pluginVeinStat); - //API.registerRecipeHandler(pluginAsteriodStat); - //API.registerUsageHandler(pluginAsteriodStat); API.registerRecipeHandler(pluginSmallOreStat); API.registerUsageHandler(pluginSmallOreStat); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java index 9186eddcbd..da3947fee8 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/PluginBase.java @@ -7,7 +7,7 @@ import net.minecraft.util.EnumChatFormatting; import java.awt.*; -public class PluginBase extends TemplateRecipeHandler { +public abstract class PluginBase extends TemplateRecipeHandler { @Override public int recipiesPerPage() { @@ -30,19 +30,7 @@ public class PluginBase extends TemplateRecipeHandler { transferRects.add(new RecipeTransferRect(new Rectangle(getGuiWidth() - stringLength - 3, 5, stringLength, 9), getOutputId())); } - public String getOutputId() { - return null; - } - - public String getWorldNameTranslated(boolean genOverworld) { - String worldNameTranslated = ""; - if (genOverworld) { - if (!worldNameTranslated.isEmpty()) - worldNameTranslated += ", "; - worldNameTranslated += I18n.format("gtnop.world.overworld.name"); - } - return worldNameTranslated; - } + public abstract String getOutputId(); public int getGuiWidth() { return 166; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5AsteroidStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5AsteroidStat.java deleted file mode 100644 index b6c676dc70..0000000000 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5AsteroidStat.java +++ /dev/null @@ -1,143 +0,0 @@ -/*package pers.gwyog.gtneioreplugin.plugin.gregtech5; - -import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; - -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler.RecipeTransferRect; -import gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import pers.gwyog.gtneioreplugin.plugin.gregtech5.PluginGT5VeinStat.CachedVeinStatRecipe; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; -import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; - -public class PluginGT5AsteroidStat extends PluginGT5Base { - - public class CachedAsteroidStatRecipe extends CachedRecipe { - public String veinName; - public PositionedStack positionedStackPrimary; - public PositionedStack positionedStackSecondary; - public PositionedStack positionedStackBetween; - public PositionedStack positionedStackSporadic; - - public CachedAsteroidStatRecipe(String veinName, ItemStack stackListPrimary, ItemStack stackListSecondary, - ItemStack stackListBetween, ItemStack stackListSporadic) { - this.veinName = veinName; - positionedStackPrimary = new PositionedStack(stackListPrimary, 2, 0); - positionedStackSecondary = new PositionedStack(stackListSecondary, 22, 0); - positionedStackBetween = new PositionedStack(stackListBetween, 42, 0); - positionedStackSporadic = new PositionedStack(stackListSporadic, 62, 0); - } - - @Override - public List getIngredients() { - List ingredientsList = new ArrayList(); - ingredientsList.add(positionedStackPrimary); - ingredientsList.add(positionedStackSecondary); - ingredientsList.add(positionedStackBetween); - ingredientsList.add(positionedStackSporadic); - return ingredientsList; - } - - @Override - public PositionedStack getResult() { - return null; - } - - } - - @Override - public void drawExtras(int recipe) { - CachedAsteroidStatRecipe crecipe = (CachedAsteroidStatRecipe) this.arecipes.get(recipe); - OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedAsteroidName(oreLayer.veinName), 2, 18, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidPrimary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.Meta[0])), 2, 31, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSecondary") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.Meta[1])), 2, 44, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidBetween") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.Meta[2])), 2, 57, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.asteroidSporadic") + ": " + GT_LanguageManager.getTranslation(getGTOreUnlocalizedName(oreLayer.Meta[3])), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreLayer.genEndAsteroid, oreLayer.genGCAsteroid), 2, 83, 0x404040, false); - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth()-3, 5, 0x404040, false); - } - - public String getWorldNameTranslated(boolean genEndAsteroid, boolean genGCAsteroid) { - String worldNameTranslatedAsteroid = ""; - if (genEndAsteroid) { - if (!worldNameTranslatedAsteroid.isEmpty()) - worldNameTranslatedAsteroid += ", "; - worldNameTranslatedAsteroid += I18n.format("gtnop.world.end.name"); - } - if (genGCAsteroid) { - if (!worldNameTranslatedAsteroid.isEmpty()) - worldNameTranslatedAsteroid += ", "; - worldNameTranslatedAsteroid += I18n.format("gtnop.world.asteroid.name"); - } - return worldNameTranslatedAsteroid; - } - - public String getLocalizedAsteroidName(String unlocalizedName) { - if (unlocalizedName.startsWith("ore.mix.custom.")) - return I18n.format("gtnop.ore.custom.name") + I18n.format("gtnop.ore.asteroid.name") + unlocalizedName.substring(15); - else - return I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.asteroid.name"); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOutputId())) { - OreLayerWrapper oreLayerWrapper; - for (String veinName: GT5OreLayerHelper.mapOreLayerWrapper.keySet()) { - oreLayerWrapper = GT5OreLayerHelper.mapOreLayerWrapper.get(veinName); - if (oreLayerWrapper.genEndAsteroid || oreLayerWrapper.genGCAsteroid) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[0]+2000); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[1]+2000); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[2]+2000); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, oreLayerWrapper.Meta[3]+2000); - this.arecipes.add(new CachedAsteroidStatRecipe(veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - else - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack stack) { - if (stack.getUnlocalizedName().startsWith("gt.blockores")) { - if (stack.getItemDamage()>16000) { - super.loadCraftingRecipes(stack); - return; - } - short baseMeta = (short)(stack.getItemDamage() % 1000); - for (OreLayerWrapper worldGen: GT5OreLayerHelper.mapOreLayerWrapper.values()) { - if (worldGen.Meta[0] == baseMeta || worldGen.Meta[1] == baseMeta || worldGen.Meta[2] == baseMeta || worldGen.Meta[3] == baseMeta) { - if (worldGen.genEndAsteroid || worldGen.genGCAsteroid) { - ItemStack stackPrimary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[0]+2000); - ItemStack stackSecondary = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[1]+2000); - ItemStack stackBetween = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[2]+2000); - ItemStack stackSporadic = new ItemStack(GregTech_API.sBlockOres1, 1, worldGen.Meta[3]+2000); - this.arecipes.add(new CachedAsteroidStatRecipe(worldGen.veinName, stackPrimary, stackSecondary, stackBetween, stackSporadic)); - } - } - } - } - else - super.loadCraftingRecipes(stack); - } - - @Override - public String getOutputId() { - return "GTOrePluginAsteroid"; - } - - @Override - public String getRecipeName() { - return I18n.format("gtnop.gui.asteroidStat.name"); - } -} -*/ \ No newline at end of file diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java index 00107e12c1..6bc9db3e2c 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java @@ -1,37 +1,28 @@ package pers.gwyog.gtneioreplugin.plugin.gregtech5; import codechicken.lib.gui.GuiDraw; +import codechicken.nei.guihook.GuiContainerManager; +import codechicken.nei.recipe.GuiRecipe; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.util.GT_LanguageManager; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.plugin.PluginBase; import pers.gwyog.gtneioreplugin.util.DimensionHelper; +import java.awt.Point; +import java.awt.Rectangle; import java.util.List; -import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.hideBackground; import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.toolTips; -public class PluginGT5Base extends PluginBase { - - protected boolean ttDisplayed = false; +public abstract class PluginGT5Base extends PluginBase { protected static String getLocalizedNameForItem(Materials aMaterial, String aFormat) { return String.format(aFormat.replace("%s", "%temp").replace("%material", "%s"), aMaterial.mLocalizedName).replace("%temp", "%s"); } - protected static int calculateMaxW(List L) { - int w = 0; - FontRenderer font = GuiDraw.fontRenderer; - for (int i = 0; i < L.size(); ++i) { - String s = (String) L.get(i); - w = Math.max(font.getStringWidth(s), w); - } - return w; - } - protected static String getLocalizedNameForItem(String aFormat, int aMaterialID) { if (aMaterialID >= 0 && aMaterialID < 1000) { Materials aMaterial = GregTech_API.sGeneratedMaterials[aMaterialID]; @@ -54,25 +45,51 @@ public class PluginGT5Base extends PluginBase { return "gt.blockores." + index + ".name"; } - protected void drawToolTip(String sDimNames) { - if (toolTips) { - ttDisplayed = false; - if (GuiDraw.getMousePosition().y > (int) (Minecraft.getMinecraft().currentScreen.height * 0.6f) && GuiDraw.getMousePosition().y < (int) (Minecraft.getMinecraft().currentScreen.height * 0.8f)) { - List dims = DimensionHelper.convertCondensedStringToToolTip(sDimNames); - int w = calculateMaxW(dims); - int x = GuiDraw.getMousePosition().x > Minecraft.getMinecraft().currentScreen.width / 2 ? this.getGuiWidth() - w - 8 : 0; - if (dims.size() > 10) { - List dims2 = dims.subList(11, dims.size()); - int w2 = calculateMaxW(dims2); - dims = dims.subList(0, 11); - w = calculateMaxW(dims); - GuiDraw.drawMultilineTip(x == 0 ? 16 + w : x - (w2 + 8), 108 - (dims.size() * 8), dims2); - } - GuiDraw.drawMultilineTip(x, 108 - (dims.size() * 8), dims); - - ttDisplayed = hideBackground; + /** + * Add lines to the current tooltip if appropriate + * + * @param gui An instance of the currentscreen + * @param currenttip The current tooltip, will contain item name and info + * @param recipe The recipe index being handled + * @return The modified tooltip. DO NOT return null + */ + @Override + public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + if (toolTips && GuiContainerManager.shouldShowTooltip(gui) && currenttip.size() == 0) { + String dimNames = getDimensionNames(recipe); + Rectangle dimRect = getDimensionNamesRect(gui, recipe , dimNames); + Point mousePos = GuiDraw.getMousePosition(); + + + if (dimRect.contains(mousePos.x, mousePos.y)) { + List dims = DimensionHelper.convertCondensedStringToToolTip(dimNames); + currenttip.addAll(dims); } } + + return super.handleTooltip(gui, currenttip, recipe); + } + + /** + * The dimension names for a given recipe index + * + * @param The recipe index being handled + * @return A CSV string of dimension name abbreviations + */ + protected abstract String getDimensionNames(int recipe); + + /** + * Produce a rectangle covering the area of displayed dimension names + * + * @param gui An instance of the currentscreen + * @param recipe The recipe index being handled + * @param dimNames Dimension names to produce a rectangle for + * @return Rectangle area of dimension names + */ + protected Rectangle getDimensionNamesRect(GuiRecipe gui, int recipe, String dimNames) { + int height = dimNames.length() > 70 ? 30 : (dimNames.length() > 36 ? 20 : 10); + Point offset = gui.getRecipePosition(recipe); + return new Rectangle(gui.guiLeft + offset.x + 2, gui.guiTop + offset.y + 110, gui.xSize - 9, height ); } protected int getMaximumMaterialIndex(short meta, boolean smallOre) { @@ -85,4 +102,32 @@ public class PluginGT5Base extends PluginBase { return 5; } + /** + * Draw the dimension header and the dimension names over up to 3 lines + * + * @param dimNames A CSV string of dimension name abbreviations + */ + protected void drawDimNames(String dimNames) { + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); + + if (dimNames.length() > 36) { + GuiDraw.drawString(I18n.format("") + dimNames.substring(0, 36), 2, 110, 0x404040, false); + if (dimNames.length() > 70) { + GuiDraw.drawString(I18n.format("") + dimNames.substring(36, 70), 2, 120, 0x404040, false); + GuiDraw.drawString(I18n.format("") + dimNames.substring(70, dimNames.length() - 1), 2, 130, 0x404040, false); + } else + { + GuiDraw.drawString(I18n.format("") + dimNames.substring(36, dimNames.length() - 1), 2, 120, 0x404040, false); + } + } else{ + GuiDraw.drawString(I18n.format("") + dimNames.substring(0, dimNames.length() - 1), 2, 110, 0x404040, false); + } + } + + /** + * Draw the "see all recipes" transfer label + */ + protected void drawSeeAllRecipesLabel() { + GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); + } } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java index 4a8e2174e3..70346889e9 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5SmallOreStat.java @@ -7,7 +7,6 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper; import pers.gwyog.gtneioreplugin.util.GT5OreSmallHelper.OreSmallWrapper; @@ -22,25 +21,15 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); String sDimNames = GT5OreSmallHelper.bufferedDims.get(oreSmall); GuiDraw.drawString(I18n.format("gtnop.gui.nei.oreName") + ": " + getGTOreLocalizedName((short) (oreSmall.oreMeta + 16000)), 2, 18, 0x404040, false); - drawToolTip(sDimNames); - if (!ttDisplayed) { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreSmall.worldGenHeightRange, 2, 31, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.amount") + ": " + oreSmall.amountPerChunk, 2, 44, 0x404040, false); - // GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": " + getWorldNameTranslated(oreSmall.genOverworld, oreSmall.genNether, oreSmall.genEnd, oreSmall.genMoon, oreSmall.genMars), 2, 57, 0x404040, false); - // if (GT5OreSmallHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreSmall.restrictBiome), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 83 + getRestrictBiomeOffset(), 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 110, 0x404040, false); - if (sDimNames.length() > 36) { - GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, 36), 2, 120, 0x404040, false); - if (sDimNames.length() > 70) { - GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, 70), 2, 130, 0x404040, false); - GuiDraw.drawString(I18n.format("") + sDimNames.substring(70, sDimNames.length() - 1), 2, 140, 0x404040, false); - } else - GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, sDimNames.length() - 1), 2, 130, 0x404040, false); - } else - GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, sDimNames.length() - 1), 2, 120, 0x404040, false); - } - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); + + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreSmall.worldGenHeightRange, 2, 31, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.amount") + ": " + oreSmall.amountPerChunk, 2, 44, 0x404040, false); + // if (GT5OreSmallHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreSmall.restrictBiome), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.chanceDrops") + ": ", 2, 83 + getRestrictBiomeOffset(), 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); + + drawDimNames(sDimNames); + drawSeeAllRecipesLabel(); } public int getRestrictBiomeOffset() { @@ -104,6 +93,19 @@ public class PluginGT5SmallOreStat extends PluginGT5Base { return I18n.format("gtnop.gui.smallOreStat.name"); } + /** + * The dimension names for a given recipe identifier + * + * @param recipe identifier + * @return A CSV string of dimension name abbreviations + */ + @Override + protected String getDimensionNames(int recipe) { + CachedOreSmallRecipe crecipe = (CachedOreSmallRecipe) this.arecipes.get(recipe); + OreSmallWrapper oreSmall = GT5OreSmallHelper.mapOreSmallWrapper.get(crecipe.oreGenName); + return GT5OreSmallHelper.bufferedDims.get(oreSmall); + } + public class CachedOreSmallRecipe extends CachedRecipe { public String oreGenName; public PositionedStack positionedStackOreSmall; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java index c288aa72ca..8f8a01ef0a 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java @@ -6,7 +6,6 @@ import cpw.mods.fml.common.Loader; import gregtech.api.GregTech_API; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper; import pers.gwyog.gtneioreplugin.util.GT5OreLayerHelper.OreLayerWrapper; @@ -17,6 +16,7 @@ import java.util.Set; public class PluginGT5VeinStat extends PluginGT5Base { + // Unused public static String[] getLocalizedVeinName(OreLayerWrapper oreLayer) { String unlocalizedName = oreLayer.veinName; if (unlocalizedName.startsWith("ore.mix.custom.")) @@ -25,6 +25,7 @@ public class PluginGT5VeinStat extends PluginGT5Base { return new String[]{I18n.format("gtnop." + unlocalizedName) + I18n.format("gtnop.ore.vein.name")}; } + // Unused public static String coustomVeinRenamer(OreLayerWrapper oreLayer) { Set s = new HashSet(); for (int i = 0; i < 4; i++) @@ -58,6 +59,7 @@ public class PluginGT5VeinStat extends PluginGT5Base { return weightedChance; }*/ + // Unused public static String[] get_Cnames(OreLayerWrapper oreLayer) { String[] splt = coustomVeinRenamer(oreLayer).split("\\s"); @@ -167,18 +169,8 @@ public class PluginGT5VeinStat extends PluginGT5Base { String sDimNames = GT5OreLayerHelper.bufferedDims.get(oreLayer); - /*if (getLocalizedVeinName(oreLayer).length>1) { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getLocalizedVeinName(oreLayer)[0], 2, 20, 0x404040, false); - if (getLocalizedVeinName(oreLayer).length>2) { - GuiDraw.drawString(I18n.format(getLocalizedVeinName(oreLayer)[1]), 2, 30, 0x404040, false); - GuiDraw.drawString(I18n.format(getLocalizedVeinName(oreLayer)[2]), 2, 40, 0x404040, false); - } - else - GuiDraw.drawString(I18n.format(getLocalizedVeinName(oreLayer)[1]), 2, 30, 0x404040, false); - } - else*/ if(Loader.isModLoaded("visualprospecting")) { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + I18n.format(oreLayer.veinName) + "" + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + I18n.format(oreLayer.veinName) + " " + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); } else { if (getGTOreLocalizedName(oreLayer.Meta[0]).contains("Ore")) @@ -188,34 +180,23 @@ public class PluginGT5VeinStat extends PluginGT5Base { else GuiDraw.drawString(I18n.format("gtnop.gui.nei.veinName") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]) + " " + I18n.format("gtnop.gui.nei.vein"), 2, 20, 0x404040, false); } - - drawToolTip(sDimNames); - if (!ttDisplayed) { - GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]), 2, 50, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[1]), 2, 60, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.primaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[0]), 2, 50, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[2]), 2, 70, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.secondaryOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[1]), 2, 60, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[3]), 2, 80, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.betweenOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[2]), 2, 70, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 90, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.sporadicOre") + ": " + getGTOreLocalizedName(oreLayer.Meta[3]), 2, 80, 0x404040, false); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + Integer.toString(oreLayer.randomWeight), 100, 90, 0x404040, false); + GuiDraw.drawString(I18n.format("gtnop.gui.nei.genHeight") + ": " + oreLayer.worldGenHeightRange, 2, 90, 0x404040, false); + + GuiDraw.drawString(I18n.format("gtnop.gui.nei.weightedChance") + ": " + Integer.toString(oreLayer.randomWeight), 100, 90, 0x404040, false); + + drawDimNames(sDimNames); - GuiDraw.drawString(I18n.format("gtnop.gui.nei.worldNames") + ": ", 2, 100, 0x404040, false); - if (sDimNames.length() > 36) { - GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, 36), 2, 110, 0x404040, false); - if (sDimNames.length() > 70) { - GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, 70), 2, 120, 0x404040, false); - GuiDraw.drawString(I18n.format("") + sDimNames.substring(70, sDimNames.length() - 1), 2, 130, 0x404040, false); - } else - GuiDraw.drawString(I18n.format("") + sDimNames.substring(36, sDimNames.length() - 1), 2, 120, 0x404040, false); - } else - GuiDraw.drawString(I18n.format("") + sDimNames.substring(0, sDimNames.length() - 1), 2, 110, 0x404040, false); - } //if (GT5OreLayerHelper.restrictBiomeSupport) GuiDraw.drawString(I18n.format("gtnop.gui.nei.restrictBiome") + ": " + getBiomeTranslated(oreLayer.restrictBiome), 2, 122, 0x404040, false); - GuiDraw.drawStringR(EnumChatFormatting.BOLD + I18n.format("gtnop.gui.nei.seeAll"), getGuiWidth() - 3, 5, 0x404040, false); + drawSeeAllRecipesLabel(); } @Override @@ -227,6 +208,19 @@ public class PluginGT5VeinStat extends PluginGT5Base { public String getRecipeName() { return I18n.format("gtnop.gui.veinStat.name"); } + + /** + * The dimension names for a given recipe identifier + * + * @param recipe identifier + * @return A CSV string of dimension name abbreviations + */ + @Override + protected String getDimensionNames(int recipe) { + CachedVeinStatRecipe crecipe = (CachedVeinStatRecipe) this.arecipes.get(recipe); + OreLayerWrapper oreLayer = GT5OreLayerHelper.mapOreLayerWrapper.get(crecipe.veinName); + return GT5OreLayerHelper.bufferedDims.get(oreLayer); + } public class CachedVeinStatRecipe extends CachedRecipe { public String veinName; diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java index 427d8a8be8..fb422ed074 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/DimensionHelper.java @@ -5,84 +5,104 @@ import java.util.HashMap; import java.util.List; import net.minecraft.client.resources.I18n; +import static pers.gwyog.gtneioreplugin.GTNEIOrePlugin.maxTooltipLines; + public class DimensionHelper { public static String[] DimName = { + // Non GC dimensions in progression order instead of alphabetical + "Overworld", + "Nether", + "Twilight", + "TheEnd", + "Vanilla_EndAsteroids", "EndAsteroid", + // T1 "GalacticraftCore_Moon", - "GalacticraftMars_Asteroids", + // T2 + "GalaxySpace_Deimos", "GalacticraftMars_Mars", - "GalaxySpace_BarnardC", - "GalaxySpace_BarnardE", - "GalaxySpace_BarnardF", + "GalaxySpace_Phobos", + // T3 + "GalacticraftMars_Asteroids", "GalaxySpace_Callisto", - "GalaxySpace_CentauriA", "GalaxySpace_Ceres", - "GalaxySpace_Deimos", - "GalaxySpace_Enceladus", "GalaxySpace_Europa", "GalaxySpace_Ganymede", - "GalaxySpace_Haumea", + // T4 "GalaxySpace_Io", - "GalaxySpace_Kuiperbelt", - "GalaxySpace_MakeMake", "GalaxySpace_Mercury", + "GalaxySpace_Venus", + // T5 + "GalaxySpace_Enceladus", "GalaxySpace_Miranda", "GalaxySpace_Oberon", - "GalaxySpace_Phobos", - "GalaxySpace_Pluto", - "GalaxySpace_Proteus", - "GalaxySpace_TcetiE", "GalaxySpace_Titan", + // T6 + "GalaxySpace_Proteus", "GalaxySpace_Triton", + // T7 + "GalaxySpace_Haumea", + "GalaxySpace_Kuiperbelt", + "GalaxySpace_MakeMake", + "GalaxySpace_Pluto", + // T8 + "GalaxySpace_BarnardC", + "GalaxySpace_BarnardE", + "GalaxySpace_BarnardF", + "GalaxySpace_CentauriA", + "GalaxySpace_TcetiE", + "Underdark", "GalaxySpace_VegaB", - "GalaxySpace_Venus", - "Nether", - "Overworld", - "TheEnd", - "Vanilla_EndAsteroids", - "Twilight", - "Underdark" }; public static String[] DimNameDisplayed = - {// first 2 letters if one word else 1 letter of every word, execpt capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA - "EA", - "Mo", - "As", - "Ma", - "BC", - "BE", - "BF", - "Ca", - "CA", - "Ce", - "De", - "En", - "Eu", - "Ga", - "Ha", - "Io", - "KB", - "MM", - "Me", - "Mi", - "Ob", - "Ph", - "Pl", - "Pr", - "TE", - "Ti", - "Tr", - "VB", - "Ve", - "Ne", - "Ow", - "EN",//End = EN bc En = Encalus - "VA", - "TF", - "DD" + {// first 2 letters if one word else 1 letter of every word, except capital letter in name, then 1rst + capital Moon = Mo, BarnardC = BC, EndAsteroid = EA + // Non GC dimensions in progression order instead of alphabetical + "Ow", // Overworld + "Ne", // Nether + "TF", // Twilight + "EN", // TheEnd because En = Encalus + "VA", // Vanilla_EndAsteroids + "EA", // EndAsteroid + // T1 + "Mo", // GalacticraftCore_Moon + // T2 + "De", // GalaxySpace_Deimos + "Ma", // GalacticraftMars_Mars + "Ph", // GalaxySpace_Phobos + // T3 + "As", // GalacticraftMars_Asteroids + "Ca", // GalaxySpace_Callisto + "Ce", // GalaxySpace_Ceres + "Eu", // GalaxySpace_Europa + "Ga", // GalaxySpace_Ganymede + // T4 + "Io", // GalaxySpace_Io + "Me", // GalaxySpace_Mercury + "Ve", // GalaxySpace_Venus + // T5 + "En", // GalaxySpace_Enceladus + "Mi", // GalaxySpace_Miranda + "Ob", // GalaxySpace_Oberon + "Ti", // GalaxySpace_Titan + // T6 + "Pr", // GalaxySpace_Proteus + "Tr", // GalaxySpace_Triton + // T7 + "Ha", // GalaxySpace_Haumea + "KB", // GalaxySpace_Kuiperbelt + "MM", // GalaxySpace_MakeMake + "Pl", // GalaxySpace_Pluto + // T8 + "BC", // GalaxySpace_BarnardC + "BE", // GalaxySpace_BarnardE + "BF", // GalaxySpace_BarnardF + "CB", // GalaxySpace_CentauriA is actually αCentauri Bb + "TE", // GalaxySpace_TcetiE + "DD", // Underdark + "VB", // GalaxySpace_VegaB }; private static HashMap> tooltipBuffer = new HashMap<>(); @@ -99,49 +119,49 @@ public class DimensionHelper { s = I18n.format("gtnop.world." + k); switch (k) { case "Moon": - s = s + " (T1)"; + s = "T1: " + s; break; + case "Deimos": case "Mars": case "Phobos": - case "Deimos": - s = s + " (T2)"; + s = "T2: " + s; break; case "Asteroids": + case "Callisto": case "Ceres": case "Europa": case "Ganymede": - case "Callisto": - s = s + " (T3)"; + s = "T3: " + s; break; case "Io": - case "Venus": case "Mercury": - s = s + " (T4)"; + case "Venus": + s = "T4: " + s; break; case "Enceladus": - case "Titan": case "Miranda": case "Oberon": - s = s + " (T5)"; + case "Titan": + s = "T5: " + s; break; case "Proteus": case "Triton": - s = s + " (T6)"; + s = "T6: " + s; break; - case "Pluto": - case "Kuiperbelt": case "Haumea": + case "Kuiperbelt": case "MakeMake": - s = s + " (T7)"; + case "Pluto": + s = "T7: " + s; break; - case "Underdark": - case "CentauriA": - case "VegaB": case "BarnardC": case "BarnardE": case "BarnardF": + case "CentauriA": case "TcetiE": - s = s + " (T8)"; + case "Underdark": + case "VegaB": + s = "T8: " + s; break; } @@ -149,6 +169,12 @@ public class DimensionHelper { } } } + + if (dims.length > maxTooltipLines ) { + dims = StringPaddingHack.stringsToSpacedColumns( + dims, dims.length / maxTooltipLines + (dims.length % maxTooltipLines == 0 ? 0 : 1) , 2); + } + return Arrays.asList(dims); } diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java index 00260020da..94b826808f 100644 --- a/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/GT5CFGHelper.java @@ -48,9 +48,9 @@ public class GT5CFGHelper { rawboolsset.add(st); } rawbools = new ArrayList(rawboolsset); - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i); - for (int j = 0; j < DimensionHelper.DimName.length; j++) { + for (int j = 0; j < DimensionHelper.DimName.length; j++) { + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i); if (st.contains(DimensionHelper.DimName[j])) if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); @@ -59,7 +59,7 @@ public class GT5CFGHelper { } ret = ret.trim(); if (ret.equals("") || ret.equals(" ")) - ret = "Not aviable in any Galactic Dim!"; + ret = "Not available in any Galactic Dim!"; return ret; } @@ -73,7 +73,7 @@ public class GT5CFGHelper { int buffer = (int) (0.1 * Runtime.getRuntime().freeMemory()); if (buffer > F.length()) buffer = (int) F.length(); - //allocate 10% of free memory for read-in-buffer, if there is less than filesize memory aviable + //allocate 10% of free memory for read-in-buffer, if there is less than filesize memory available //FMLLog.info("GT_CFG_found[0]"); FileReader in = new FileReader(F); //FMLLog.info("FileReader created"); @@ -154,17 +154,17 @@ public class GT5CFGHelper { HashSet rawboolsset = new HashSet(); if (!rawbools.isEmpty()) { - //remove dublicats + //remove dublicates for (int i = 0; i < rawbools.size(); i++) { st = rawbools.get(i).replace("B:", "").replace("_true", "").replace("_false", "").replaceAll(" ", "").replaceAll("\"", ""); rawboolsset.add(st); } rawbools = new ArrayList(rawboolsset); //filter for dims set to true - for (int i = 0; i < rawbools.size(); i++) { - st = rawbools.get(i); + for (int j = 0; j < DimensionHelper.DimName.length; j++) { //FMLLog.info("RawBools:"+st); - for (int j = 0; j < DimensionHelper.DimName.length; j++) { + for (int i = 0; i < rawbools.size(); i++) { + st = rawbools.get(i); if (st.contains(DimensionHelper.DimName[j])) if (st.contains("=true")) ret = (ret + DimensionHelper.DimNameDisplayed[j] + ","); @@ -174,7 +174,7 @@ public class GT5CFGHelper { ret = ret.trim(); //FMLLog.info("ret:"+ret); if (ret.equals("") || ret.equals(" ")) - ret = "Not aviable in any Galactic Dim!"; + ret = "Not available in any Galactic Dim!"; return ret; } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java new file mode 100644 index 0000000000..d4c340a9be --- /dev/null +++ b/src/main/java/pers/gwyog/gtneioreplugin/util/StringPaddingHack.java @@ -0,0 +1,129 @@ +package pers.gwyog.gtneioreplugin.util; +import java.util.Arrays; + +import com.google.common.base.Strings; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; + +public class StringPaddingHack { + private static final int SPACE_WIDTH = 4; + private static final int BOLD_SPACE_WIDTH = 5; + + /** + * 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 + */ + 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)); + } + if (numColumns > 1) { + int sliceSize = strings.length / numColumns; + int remainder = strings.length % numColumns; + String[][] columns = new String[numColumns][]; + int totalExtra = 0; + + // Arrange all strings into their proper columns so that the list of strings wraps through all columns + for (int i = 0; i < numColumns; i++) { + int extra = 0; + if (remainder > 0) { + remainder--; + extra = 1; + } + 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++) { + 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[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 + */ + public static String[] padStrings(String[] strings, int minExtraSpaces) { + int[] widths = getStringWidths(strings); + 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; + int numBoldSpacesToAdd = (SPACE_WIDTH - mod) % SPACE_WIDTH; + + // Keep track of the number of spaces added to the longest string + if (widths[i] > maxUnPaddedStrLength) { + numSpacesAddedToLongestString = numBoldSpacesToAdd; + maxUnPaddedStrLength = widths[i]; + } + + strings[i] += "§l" + Strings.repeat(" ", numBoldSpacesToAdd ) + "§r"; + widths[i] += numBoldSpacesToAdd * BOLD_SPACE_WIDTH; + + // Keep track of the current widest string we currently have + if (widths[i] > maxPaddedStrLength) { + 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; + } + + // Add required spaces to equalize length of all strings to at least the target width + for (int i = 0; i < strings.length; i++) { + int numSpacesToAdd = (maxPaddedStrLength - widths[i]) / SPACE_WIDTH; + strings[i] += Strings.repeat(" ", numSpacesToAdd); + widths[i] += numSpacesToAdd * SPACE_WIDTH; + } + + return strings; + } + + /** + * Returns an array of font widths for the given array of strings + * + * @param strList Array of strings + * @return Array of font widths + */ + protected static int[] getStringWidths(String[] strList) { + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + int[] widths = new int[strList.length]; + for (int i = 0; i < strList.length; ++i) { + widths[i] = font.getStringWidth(strList[i]); + } + return widths; + } +} diff --git a/src/main/resources/META-INF/gtneioreplugin_at.cfg b/src/main/resources/META-INF/gtneioreplugin_at.cfg new file mode 100644 index 0000000000..efa5067287 --- /dev/null +++ b/src/main/resources/META-INF/gtneioreplugin_at.cfg @@ -0,0 +1,5 @@ +# GT NEI Ore Plugin Access Transformer configuration file +public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize +public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize +public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft +public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop \ No newline at end of file diff --git a/src/main/resources/assets/gtneioreplugin/lang/en_US.lang b/src/main/resources/assets/gtneioreplugin/lang/en_US.lang index b770cea7cb..ec8c8a9681 100644 --- a/src/main/resources/assets/gtneioreplugin/lang/en_US.lang +++ b/src/main/resources/assets/gtneioreplugin/lang/en_US.lang @@ -37,10 +37,10 @@ gtnop.nei.genPositionInfo=In the center of each chunk # world names gtnop.world.Overworld=Overworld gtnop.world.Nether=Nether -gtnop.world.TheEnd=TheEnd -gtnop.world.Twilight=Twilight Forrest +gtnop.world.TheEnd=The End +gtnop.world.Twilight=Twilight Forest gtnop.world.EndAsteroid=Far End Asteroids -gtnop.world.Vanilla EndAsteroids=Vanilla EndAsteroids +gtnop.world.Vanilla EndAsteroids=Vanilla End Asteroids gtnop.world.Moon=Moon gtnop.world.Mars=Mars gtnop.world.Phobos=Phobos @@ -60,15 +60,15 @@ gtnop.world.Oberon=Oberon gtnop.world.Proteus=Proteus gtnop.world.Triton=Triton gtnop.world.Pluto=Pluto -gtnop.world.Kuiperbelt=Kuiperbelt +gtnop.world.Kuiperbelt=Kuiper Belt gtnop.world.Haumea=Haumea -gtnop.world.MakeMake=MakeMake -gtnop.world.CentauriA=αCentauriBb -gtnop.world.VegaB=VegaB -gtnop.world.BarnardC=BarnardC -gtnop.world.BarnardE=BarnardE -gtnop.world.BarnardF=BarnardF -gtnop.world.TcetiE=TcetiE +gtnop.world.MakeMake=Makemake +gtnop.world.CentauriA=α Centauri Bb +gtnop.world.VegaB=Vega B +gtnop.world.BarnardC=Barnard C +gtnop.world.BarnardE=Barnard E +gtnop.world.BarnardF=Barnard F +gtnop.world.TcetiE=T Ceti E gtnop.world.Underdark=Deep Dark -- cgit