10 juin 2019, 14:14
package fr.kraniax.moreutilities.gui;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fr.kraniax.moreutilities.Reference;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.ResourceLocation;


public class CalculatorGui extends GuiScreen {
		
	
	private static int guiWidth = 138;
	private static int guiHeight = 256;

	private GuiButton one, two, three, four, five, six, seven, eight, nine, ten;

	@Override
	public void drawScreen(int x, int y, float ticks) {
		
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
		this.drawDefaultBackground();
		this.mc.renderEngine.bindTexture(new ResourceLocation(Reference.MODID + ":textures/gui/background.png"));
		this.drawTexturedModalRect(getScaledWidth(), getScaledHeight(), 0, 0, guiWidth, guiHeight);
		super.drawScreen(x, y, ticks);

	}
	
	@Override
	public void initGui() { 

		buttonList.clear();
		buttonList.add(one = new GuiButton(0,getScaledWidth() ,guiHeight/3,40,20, "1"));
		buttonList.add(two = new GuiButton(1,getScaledWidth() + guiWidth/2 ,guiHeight/3,40,20, "2"));
		buttonList.add(three = new GuiButton(2,getScaledWidth() + guiWidth ,guiHeight/3,40,20, "3"));
//		buttonList.add(four = new GuiButton(3,getScaledWidth() ,guiHeight/3,50,20, "4"));
//		buttonList.add(five = new GuiButton(4,getScaledWidth() ,guiHeight/3,50,20, "5"));
//		buttonList.add(six = new GuiButton(5,getScaledWidth() ,guiHeight/3,50,20, "6"));
//		buttonList.add(seven = new GuiButton(6,getScaledWidth() ,guiHeight/3,50,20, "7"));
//		buttonList.add(eight = new GuiButton(7,getScaledWidth() ,guiHeight/3,50,20, "8"));
//		buttonList.add(nine = new GuiButton(8,getScaledWidth() ,guiHeight/3,50,20, "9"));
//		buttonList.add(ten = new GuiButton(9,getScaledWidth() ,guiHeight/3,50,20, "0"));
//		super.initGui();
	}
	
	
	public static int getScaledWidth() {
		ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
		int guiX =(sr.getScaledWidth() - guiWidth) / 2;
		return guiX;

	}
	
	public static int getScaledHeight() {
		ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
		int guiY = (sr.getScaledHeight() + guiHeight) / 22;
		return guiY;

	}

}