Posted November 27, 201410 yr I am trying to make an Scaling UI Hud Element, I want it so scale with the screen size but i haven't gotten an clue how to, ive looked online but all i found was code that would change the size of the picture but it would be black and would tile, this is the code i have package com.callumcarmicheal.galacticfrontier.gui; import java.awt.Color; import org.lwjgl.opengl.GL11; import com.callumcarmicheal.galacticfrontier.init.ModInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; public class Logo extends GuiScreen { public ResourceLocation TEXTURE = new ResourceLocation(ModInfo.Mod_ID, "textures/gui/base.png"); TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; private static GuiIngame gig = new GuiIngame(Minecraft.getMinecraft()); FontRenderer fontRender; ScaledResolution scale; public void renderLogoText(RenderGameOverlayEvent event) { GL11.glDisable(GL11.GL_LIGHTING); fontRender = Minecraft.getMinecraft().fontRenderer; scale = new ScaledResolution( Minecraft.getMinecraft().getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight ); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); int width = scale.getScaledWidth(); int height = scale.getScaledHeight(); int posX = 1; int posY = 1; int sizeX = 176; int sizeY = 88; this.drawTexturedModalRect(posX, posY, 0,0, sizeX, sizeY); String Version = "Developer Edition"; drawText("§fGlactical Frontier", 1, true); drawText("§b(§2" + Version + "§b)", 2, true); drawText("§fPress §4Enter §fto §aContinue", 2, 7, true); //GL11.glEnable(GL11.GL_LIGHTING); } public void drawText(String text, int WidthOffset, int Line, boolean Shaddow) { fontRender.drawString( text, 10 * WidthOffset, 10 * Line, Color.white.getRGB(), true); } public void drawText(String text, int Line, boolean Shaddow) { fontRender.drawString( text, 10, 10 * Line, Color.white.getRGB(), true); } } This is the image i have for the base.png: http://i.imgur.com/LxK33.png
November 27, 201410 yr Author I forgot to add, i have it called in another class package com.callumcarmicheal.galacticfrontier.render; import com.callumcarmicheal.galacticfrontier.gui.Logo; import com.callumcarmicheal.galacticfrontier.init.GalacticFrontier; import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.RenderGameOverlayEvent; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; public class Init { Logo logo = new Logo(); @SubscribeEvent public void onRenderTick(RenderTickEvent event) { renderTick.tick(event); GalacticFrontier.logger.info("renderTick"); } @SubscribeEvent(priority = EventPriority.NORMAL) public void overlayRender(RenderGameOverlayEvent event) { logo.renderLogoText(event); } } also i had it extentending guiscreen because i was using an example code but i deleted it, it was the guiBuffBar on the wiki.
November 27, 201410 yr Author Oh ok, thanks for sending the link i will look over it right now, thanks!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.