Added scrollable description override to content in GuiModList

This commit is contained in:
Chicken-Bomes committed 2014-07-25 14:41:37 +10:00
1 parent e332467293
commit 07451771aa
7 files changed
+205 -82

No files matched your search

+32 -30
View File
@@ -12,63 +12,65 @@ public class GuiCCButton extends GuiWidget
public String actionCommand;
private boolean isEnabled = true;
public boolean visible = true;
public GuiCCButton(int x, int y, int width, int height, String text)
{
public GuiCCButton(int x, int y, int width, int height, String text) {
super(x, y, width, height);
this.text = text;
}
public void setText(String s)
{
public void setText(String s) {
text = s;
}
public boolean isEnabled()
{
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean b)
{
public void setEnabled(boolean b) {
isEnabled = b;
}
@Override
public void mouseClicked(int x, int y, int button)
{
if(isEnabled && pointInside(x, y) && actionCommand != null)
{
public void mouseClicked(int x, int y, int button) {
if (isEnabled && pointInside(x, y) && actionCommand != null) {
sendAction(actionCommand, button);
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
}
}
@Override
public void draw(int mousex, int mousey, float frame)
{
if(!visible)
public void draw(int mousex, int mousey, float frame) {
if (!visible)
return;
renderEngine.bindTexture(guiTex);
drawButtonTex(mousex, mousey);
if(text != null)
drawText(mousex, mousey);
}
public void drawButtonTex(int mousex, int mousey) {
GL11.glColor4f(1, 1, 1, 1);
boolean mouseover = pointInside(mousex, mousey);
int state = !isEnabled ? 0 : mouseover ? 2 : 1;
renderEngine.bindTexture(guiTex);
int state = getButtonTex(mousex, mousey);
drawTexturedModalRect(x, y, 0, 46 + state * 20, width / 2, height / 2);//top left
drawTexturedModalRect(x + width / 2, y, 200 - width / 2, 46 + state * 20, width / 2, height / 2);//top right
drawTexturedModalRect(x, y + height / 2, 0, 46 + state * 20 + 20 - height / 2, width / 2, height / 2);//bottom left
drawTexturedModalRect(x + width / 2, y + height / 2, 200 - width / 2, 46 + state * 20 + 20 - height / 2, width / 2, height / 2);//bottom right
}
public int getButtonTex(int mousex, int mousey) {
return !isEnabled ? 0 : pointInside(mousex, mousey) ? 2 : 1;
}
public void drawText(int mousex, int mousey) {
drawCenteredString(fontRenderer, text, x + width / 2, y + (height - 8) / 2, getTextColour(mousex, mousey));
}
public int getTextColour(int mousex, int mousey)
{
public int getTextColour(int mousex, int mousey) {
return !isEnabled ? 0xFFA0A0A0 : pointInside(mousex, mousey) ? 0xFFFFFFA0 : 0xFFE0E0E0;
}
public GuiCCButton setActionCommand(String string)
{
public GuiCCButton setActionCommand(String string) {
actionCommand = string;
return this;
}
+26 -17
View File
@@ -11,51 +11,56 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
{
{
public ArrayList<GuiWidget> widgets = new ArrayList<GuiWidget>();
public int xSize, ySize, guiTop, guiLeft;
public GuiScreenWidget()
{
this(176, 166);
}
public GuiScreenWidget(int xSize, int ySize)
{
super();
this.xSize = xSize;
this.ySize = ySize;
}
@Override
public void initGui()
{
guiTop = (height - ySize) / 2;
guiLeft = (width - xSize) / 2;
if(!widgets.isEmpty())
resize();
}
public void reset()
{
initGui();
widgets.clear();
initGui();
addWidgets();
resize();
}
@Override
public void setWorldAndResolution(Minecraft mc, int i, int j)
{
boolean init = this.mc == null;
super.setWorldAndResolution(mc, i, j);
if(init)
if(init) {
addWidgets();
resize();
}
}
public void add(GuiWidget widget)
{
widgets.add(widget);
widget.onAdded(this);
}
@Override
public void drawScreen(int mousex, int mousey, float f)
{
@@ -66,11 +71,11 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
drawForeground();
GL11.glTranslated(-guiLeft, -guiTop, 0);
}
public void drawBackground()
{
}
public void drawForeground()
{
}
@@ -82,7 +87,7 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
for(GuiWidget widget : widgets)
widget.mouseClicked(x-guiLeft, y-guiTop, button);
}
@Override
protected void mouseMovedOrUp(int x, int y, int button)
{
@@ -90,7 +95,7 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
for(GuiWidget widget : widgets)
widget.mouseMovedOrUp(x-guiLeft, y-guiTop, button);
}
@Override
protected void mouseClickMove(int x, int y, int button, long time)
{
@@ -98,7 +103,7 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
for(GuiWidget widget : widgets)
widget.mouseDragged(x-guiLeft, y-guiTop, button, time);
}
@Override
public void updateScreen()
{
@@ -107,13 +112,13 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
for(GuiWidget widget : widgets)
widget.update();
}
@Override
public void keyTyped(char c, int keycode)
{
super.keyTyped(c, keycode);
for(GuiWidget widget : widgets)
widget.keyTyped(c, keycode);
widget.keyTyped(c, keycode);
}
@Override
@@ -135,6 +140,10 @@ public class GuiScreenWidget extends GuiScreen implements IGuiActionListener
{
}
public void resize()
{
}
public void addWidgets()
{
}