Jump to content

Recommended Posts

Posted

When I use a for loop to draw buttons the first ones draw normal and then the rest all draw weird

 

heres the gui class

package com.neg2013.main;

import java.io.IOException;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;

public class GuiServerPicker extends GuiScreen{

int tabWidth = 194;
int tabHeight = 21;

int guiWidth = 247;
int guiHeight = 165;

boolean clicked1 = false;
boolean clicked2 = false;

int id = 0;
GuiButton serverButton;

int serverV = 207;

int ServersOnPage = 6;







@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID, "textures/gui/gui.png"));

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

	GL11.glColor4f(1, 1, 1, 1);

	if(clicked1){
		serverV = 207;//229
	}
	else{
		serverV = 207;
	}


	//the gui
	drawTexturedModalRect(guiX, guiY, 0, 0, guiWidth, guiHeight);




	for(int i = 0; i < ServersOnPage; i++){
	drawTexturedModalRect(guiX + 4 , guiY + 4+ (25 * i), 1, serverV, tabWidth, tabHeight);


	fontRendererObj.drawString( "Server " + (i + 1),              guiX + 4 + 4 , guiY + 4 + 6 + (25 * i),          0X000000);
	}





	//drawDefaultBackground();



	super.drawScreen(mouseX, mouseY, partialTicks);
}//drawScreen




@Override
public void initGui() {

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


	buttonList.clear();
	//buttonList.add(serverButton = new GuiButton(id, guiX, guiY, 194, 21, "ServerTest"));

	super.initGui();
}//initGui

@Override
protected void actionPerformed(GuiButton button) throws IOException {

	switch(button.id){
	case 0:


	break;


	}//switch


	super.actionPerformed(button);
}//acttionPerformed

@Override
protected void keyTyped(char c, int key) throws IOException {

	switch(key){
	case Keyboard.KEY_E:
		Minecraft.getMinecraft().displayGuiScreen(null);
	break;




	}//switch

	super.keyTyped(c, key);
}//keyTyped


//drawTexturedModalRect(guiX + 4, guiY + 4, 1, 229, tabWidth, tabHeight);






@Override
protected void mouseClicked(int x, int y, int mouseButton) throws IOException {

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

	if(guiX + 0 <= x && x <= guiX + 0 + tabWidth && guiY + 0 <= y && y <= guiY + 0 + tabHeight ){
		System.out.println("clicked1");
		clicked1 = true;
		clicked2 = false;
	}




	super.mouseClicked(x, y, mouseButton);
	}//mouseclicked



@Override
public boolean doesGuiPauseGame() {
	return false;
}//doesGuiPauseGame
}//class

 

and this is what it looks like

 

 

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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