Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So I'm trying to experiment with GUI's and ran into a brick wall here.

 

public class test_GUIScreen extends GuiScreen
{

int guiWidth = 256; //image is a 256x256 png
int guiHeight = 256;

int guiX = (width-guiWidth)/2; //centering 
int guiY = (height-guiHeight)/2;

GuiButton Test; //unused buton

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
	GL11.glColor4f(1, 1, 1, 1);
	drawDefaultBackground();
	mc.renderEngine.bindTexture(new ResourceLocation("test", "textures/gui/testtex3.png"));
	this.drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);
	super.drawScreen(mouseX, mouseY, partialTicks);
}

@Override
public void initGui()
{
//		buttonList.clear();
//		buttonList.add(Test = new GuiButton(0, guiX+1, guiY+2, 30, 20, "Test"));
	super.initGui();
}

@Override
protected void actionPerformed(GuiButton Button) throws IOException
{
	switch(Button.id)
	{
		case 0:
		case 1:
		case 2:
	}
	super.actionPerformed(Button);
}

@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
	super.mouseClicked(mouseX, mouseY, mouseButton);
}


}

 

This code is making the texture appear in the top left corner of the screen but I need it in the center ???. Can someone please share their insight?  :'( 

 

Is your GUI taking up the full size of the PNG file?

 

The width/height you specify are purely the size of your ACTUAL GUI within the file. So, if you have a 256x256 file, but your drawn GUI is actually only 200x200, it's the 200x200 you need to specify.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.