- 48
- 1
Всем привет.
Крашится игра после открытия настроек в главном меню.
Вот кейсы:
Отрисовка кнопки:
Класс с отрисовкой кнопок:
Крашится игра после открытия настроек в главном меню.
Вот кейсы:
Java:
@Override
protected void actionPerformed(GuiButton button)
{
switch (button.id)
{
case 0:
this.mc.shutdown();
break;
case 1:
this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings));
break;
case 2:
this.serverList.connectToSelected(this);
break;
}
}
Отрисовка кнопки:
Код:
this.buttonList.add(new GuiButtonCrystal(1, 2, this.height - 15 - 20 * 2 - 2, leftWidth, 20, "Настройки"));
Класс с отрисовкой кнопок:
Java:
package test.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public final class GuiButtonCrystal extends GuiButton
{
public GuiButtonCrystal(int id, int x, int y, int width, int height, String text)
{
super(id, x, y, width, height, text);
}
public GuiButtonCrystal(int id, int x, int y, String text)
{
super(id, x, y, text);
}
@Override
public void drawButton(Minecraft mc, int x, int y)
{
if (this.visible)
{
FontRenderer fr = mc.fontRenderer;
boolean changed = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (changed)
{
drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0x90000000);
this.drawCenteredString(fr, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, 0x00FF00);
}
else
{
drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0x60000000);
this.drawCenteredString(fr, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, 0xFFFFFF);
}
this.mouseDragged(mc, x, y);
}
}
}