diff --git a/MODSRC/vazkii/botania/client/core/handler/ClientTickHandler.java b/MODSRC/vazkii/botania/client/core/handler/ClientTickHandler.java index 12cf2a006..7618ec38f 100644 --- a/MODSRC/vazkii/botania/client/core/handler/ClientTickHandler.java +++ b/MODSRC/vazkii/botania/client/core/handler/ClientTickHandler.java @@ -23,11 +23,13 @@ import vazkii.botania.api.mana.IManaCollector; import vazkii.botania.api.mana.TileSignature; import vazkii.botania.client.core.handler.LightningHandler.LightningBolt; import vazkii.botania.client.gui.lexicon.GuiLexicon; +import vazkii.botania.common.core.handler.ConfigHandler; import vazkii.botania.common.core.handler.ManaNetworkHandler; import vazkii.botania.common.item.ItemTwigWand; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Type; public class ClientTickHandler { @@ -37,8 +39,8 @@ public class ClientTickHandler { public static int ticksInGame = 0; @SubscribeEvent - public void tickEnd(ClientTickEvent event) { - if(event.phase == Phase.END && event.type == Type.CLIENT) { + public void clientTickEnd(ClientTickEvent event) { + if(event.phase == Phase.END) { LightningBolt.update(); if(Minecraft.getMinecraft().theWorld == null) @@ -83,6 +85,12 @@ public class ClientTickHandler { } } } + + @SubscribeEvent + public void renderTickEnd(RenderTickEvent event) { + if(event.phase == Phase.END && ConfigHandler.baublesInventoryButton) + InventoryBaublesButtonHandler.renderBaublesIcon(); + } public static void notifyPageChange() { if(pageFlipTicks == 0) diff --git a/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java b/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java new file mode 100644 index 000000000..d19acb044 --- /dev/null +++ b/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java @@ -0,0 +1,92 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 11, 2014, 2:27:15 AM (GMT)] + */ +package vazkii.botania.client.core.handler; + +import java.util.Arrays; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiContainerCreative; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import vazkii.botania.client.lib.LibResources; +import baubles.client.gui.GuiPlayerExpanded; + +public final class InventoryBaublesButtonHandler { + + static ResourceLocation icon = new ResourceLocation(LibResources.GUI_BAUBLES); + static boolean mouseDown = false; + + public static void renderBaublesIcon() { + Minecraft mc = Minecraft.getMinecraft(); + if(mc.currentScreen != null && (mc.currentScreen instanceof GuiInventory || mc.currentScreen instanceof GuiContainerCreative || mc.currentScreen instanceof GuiPlayerExpanded)) { + boolean creative = mc.currentScreen instanceof GuiContainerCreative; + boolean baubles = mc.currentScreen instanceof GuiPlayerExpanded; + + ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); + int x = res.getScaledWidth() / 2 - 19; + int y = res.getScaledHeight() / 2 - 75; + + if(creative) { + GuiContainerCreative container = (GuiContainerCreative) mc.currentScreen; + if(container.func_147056_g() == CreativeTabs.tabInventory.getTabIndex()) { + x -= 26; + y += 13; + } else return; + } + + RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1F, 1F, 1F, 1F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + mc.renderEngine.bindTexture(icon); + Tessellator tess = Tessellator.instance; + + tess.startDrawingQuads(); + tess.addVertexWithUV(x * 2, y * 2 + 16, 0, 0, 1); + tess.addVertexWithUV(x * 2 + 16, y * 2 + 16, 0, 1, 1); + tess.addVertexWithUV(x * 2 + 16, y * 2, 0, 1, 0); + tess.addVertexWithUV(x * 2, y * 2, 0, 0, 0); + tess.draw(); + + GL11.glScalef(2F, 2F, 2F); + GL11.glDisable(GL11.GL_BLEND); + + int mouseX = Mouse.getX() * res.getScaledWidth() / mc.displayWidth; + int mouseY = res.getScaledHeight() - Mouse.getY() * res.getScaledHeight() / mc.displayHeight; + + if(mouseX >= x && mouseX < x + 8 && mouseY >= y && mouseY < y + 8) { + vazkii.botania.client.core.helper.RenderHelper.renderTooltip(mouseX, mouseY, Arrays.asList(EnumChatFormatting.LIGHT_PURPLE + StatCollector.translateToLocal(baubles ? "botaniamisc.openInv" : "botaniamisc.openBaubles"))); + + if(Mouse.isButtonDown(0) && !mouseDown) { + mc.displayGuiScreen(baubles ? new GuiInventory(mc.thePlayer) : new GuiPlayerExpanded(mc.thePlayer)); + mouseDown = true; + } + } + } + + if(mouseDown && !Mouse.isButtonDown(0)) + mouseDown = false; + } + +} diff --git a/MODSRC/vazkii/botania/client/lib/LibResources.java b/MODSRC/vazkii/botania/client/lib/LibResources.java index 4faf63d9d..b8e3eb26f 100644 --- a/MODSRC/vazkii/botania/client/lib/LibResources.java +++ b/MODSRC/vazkii/botania/client/lib/LibResources.java @@ -28,6 +28,7 @@ public final class LibResources { public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png"; public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png"; + public static final String GUI_BAUBLES = PREFIX_GUI + "baubles.png"; public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png"; public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png"; public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png"; diff --git a/MODSRC/vazkii/botania/common/core/handler/ConfigHandler.java b/MODSRC/vazkii/botania/common/core/handler/ConfigHandler.java index a14061e47..b96f68661 100644 --- a/MODSRC/vazkii/botania/common/core/handler/ConfigHandler.java +++ b/MODSRC/vazkii/botania/common/core/handler/ConfigHandler.java @@ -37,6 +37,7 @@ public final class ConfigHandler { public static boolean elfPortalParticlesEnabled = true; public static boolean matrixMode = false; public static boolean referencesEnabled = true; + public static boolean baublesInventoryButton = true; public static boolean versionCheckEnabled = true; public static int spreaderPositionShift = 1; @@ -108,6 +109,9 @@ public final class ConfigHandler { desc = "Set to false to disable the references in flower tooltips. (You monster D:)"; referencesEnabled = loadPropBool("references.enabled", desc, referencesEnabled); + desc = "Set to false to disable the inventory button to open the Baubles menu."; + baublesInventoryButton = loadPropBool("baublesButton.enabled", desc, baublesInventoryButton); + desc = "Set to false to disable checking and alerting when new Botania versions come out."; versionCheckEnabled = loadPropBool("versionChecking.enabled", desc, versionCheckEnabled); diff --git a/MODSRC/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java b/MODSRC/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java index d8cb9ce61..710d7f5c9 100644 --- a/MODSRC/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java +++ b/MODSRC/vazkii/botania/common/lexicon/page/PageManaInfusionRecipe.java @@ -83,7 +83,22 @@ public class PageManaInfusionRecipe extends PageRecipe { String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 105, 0x66000000); - HUDHandler.renderManaBar(gui.getLeft() + gui.getWidth() / 2 - 50, gui.getTop() + 115, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / 10); + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 115; + + if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) + ratio = 1; + + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / ratio); + + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(ratioString, x + 100 - font.getStringWidth(ratioString), y + 5, 0x50000000); + font.setUnicodeFlag(unicode); + GL11.glDisable(GL11.GL_BLEND); render.bindTexture(manaInfusionOverlay); diff --git a/MODSRC/vazkii/botania/common/lexicon/page/PageRuneRecipe.java b/MODSRC/vazkii/botania/common/lexicon/page/PageRuneRecipe.java index b302697ff..2c5218f60 100644 --- a/MODSRC/vazkii/botania/common/lexicon/page/PageRuneRecipe.java +++ b/MODSRC/vazkii/botania/common/lexicon/page/PageRuneRecipe.java @@ -50,10 +50,23 @@ public class PageRuneRecipe extends PagePetalRecipe { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); String manaUsage = StatCollector.translateToLocal("botaniamisc.manaUsage"); - font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 120, 0x66000000); + font.drawString(manaUsage, gui.getLeft() + gui.getWidth() / 2 - font.getStringWidth(manaUsage) / 2, gui.getTop() + 115, 0x66000000); - HUDHandler.renderManaBar(gui.getLeft() + gui.getWidth() / 2 - 50, gui.getTop() + 130, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / 10); - GL11.glDisable(GL11.GL_BLEND); + int ratio = 10; + int x = gui.getLeft() + gui.getWidth() / 2 - 50; + int y = gui.getTop() + 125; + + if(mx > x + 1 && mx <= x + 101 && my > y - 14 && my <= y + 11) + ratio = 1; + + HUDHandler.renderManaBar(x, y, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / ratio); + + String ratioString = String.format(StatCollector.translateToLocal("botaniamisc.ratio"), ratio); + + boolean unicode = font.getUnicodeFlag(); + font.setUnicodeFlag(true); + font.drawString(ratioString, x + 100 - font.getStringWidth(ratioString), y + 5, 0x50000000); + font.setUnicodeFlag(unicode); GL11.glDisable(GL11.GL_BLEND); } } diff --git a/resources/assets/botania/lang/en_US.lang b/resources/assets/botania/lang/en_US.lang index 90ea5fa87..6f94b2e10 100644 --- a/resources/assets/botania/lang/en_US.lang +++ b/resources/assets/botania/lang/en_US.lang @@ -41,6 +41,9 @@ botaniamisc.bookmark=Bookmark #%s botaniamisc.clickToSee=Click to read botaniamisc.shiftToRemove=Shift-click to remove botaniamisc.clickToAdd=Click to add a Bookmark here +botaniamisc.ratio=%s:1 Ratio +botaniamisc.openBaubles=Baubles Inventory +botaniamisc.openInv=Normal Inventory # COLORS botania.color0=White @@ -88,6 +91,7 @@ pylonModel.old=Use Old Pylon Model elfPortal.particles.enabled=Enable Portal Particles matrixMode.enabled=Enable Matrix Mode references.enabled=Enable Tooltip References +baublesButton.enabled=Baubles Button Enabled shaders.enabled=Enable Shader Usage spreader.posShift=Spreader Pos Shift versionChecking.enabled=Enable Version Checking diff --git a/resources/assets/botania/textures/gui/baubles.png b/resources/assets/botania/textures/gui/baubles.png new file mode 100644 index 000000000..c88345c1d Binary files /dev/null and b/resources/assets/botania/textures/gui/baubles.png differ