updated some CofhLib Files trying to fix text rendering, still not working

This commit is contained in:
modmuss50 2015-06-17 11:24:41 +01:00
parent 74525d260a
commit d8e6e88797
3 changed files with 1029 additions and 1171 deletions

View file

@ -48,13 +48,14 @@ public class GuiIDSU extends GuiBase {
@Override @Override
public void initGui() { public void initGui() {
super.initGui(); super.initGui();
this.buttonList.clear(); // this.buttonList.clear();
int k = (this.width - this.xSize) / 2; // int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2; // int l = (this.height - this.ySize) / 2;
this.buttonList.add(new GuiButton(0, k + 96, l + 8, 18, 20, "++")); // this.buttonList.add(new GuiButton(0, k + 96, l + 8, 18, 20, "++"));
this.buttonList.add(new GuiButton(1, k + 96, l + 8 + 22, 18, 20, "+")); // this.buttonList.add(new GuiButton(1, k + 96, l + 8 + 22, 18, 20, "+"));
this.buttonList.add(new GuiButton(2, k + 96, l + 8 + (22*2), 18, 20, "-")); // this.buttonList.add(new GuiButton(2, k + 96, l + 8 + (22*2), 18, 20, "-"));
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--")); // this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--"));
listBox = new ElementListBox(this, 20, 20, 60, 60); listBox = new ElementListBox(this, 20, 20, 60, 60);
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
listBox.add(new ListBoxElementText("Name " + i)); listBox.add(new ListBoxElementText("Name " + i));

View file

@ -1,6 +1,9 @@
package techreborn.cofhLib.gui; package techreborn.cofhLib.gui;
import techreborn.cofhLib.audio.SoundBase;
import techreborn.cofhLib.gui.element.ElementBase;
import techreborn.cofhLib.gui.element.TabBase; import techreborn.cofhLib.gui.element.TabBase;
import techreborn.cofhLib.gui.slot.SlotFalseCopy;
import techreborn.cofhLib.render.RenderHelper; import techreborn.cofhLib.render.RenderHelper;
import techreborn.cofhLib.util.helpers.StringHelper; import techreborn.cofhLib.util.helpers.StringHelper;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
@ -29,8 +32,7 @@ import java.util.List;
* *
* @author King Lemming * @author King Lemming
*/ */
public abstract class GuiBase extends GuiContainer public abstract class GuiBase extends GuiContainer {
{
public static final SoundHandler guiSoundManager = FMLClientHandler.instance().getClient().getSoundHandler(); public static final SoundHandler guiSoundManager = FMLClientHandler.instance().getClient().getSoundHandler();
@ -45,33 +47,29 @@ public abstract class GuiBase extends GuiContainer
protected ResourceLocation texture; protected ResourceLocation texture;
public ArrayList<TabBase> tabs = new ArrayList<TabBase>(); public ArrayList<TabBase> tabs = new ArrayList<TabBase>();
protected ArrayList<techreborn.cofhLib.gui.element.ElementBase> elements = new ArrayList<techreborn.cofhLib.gui.element.ElementBase>(); protected ArrayList<ElementBase> elements = new ArrayList<ElementBase>();
protected List<String> tooltip = new LinkedList<String>(); protected List<String> tooltip = new LinkedList<String>();
protected boolean tooltips = true; protected boolean tooltips = true;
public static void playSound(String name, float volume, float pitch) public static void playSound(String name, float volume, float pitch) {
{
guiSoundManager.playSound(new techreborn.cofhLib.audio.SoundBase(name, volume, pitch)); guiSoundManager.playSound(new SoundBase(name, volume, pitch));
} }
public GuiBase(Container container) public GuiBase(Container container) {
{
super(container); super(container);
} }
public GuiBase(Container container, ResourceLocation texture) public GuiBase(Container container, ResourceLocation texture) {
{
super(container); super(container);
this.texture = texture; this.texture = texture;
} }
@Override @Override
public void initGui() public void initGui() {
{
super.initGui(); super.initGui();
tabs.clear(); tabs.clear();
@ -79,15 +77,13 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
public void drawScreen(int x, int y, float partialTick) public void drawScreen(int x, int y, float partialTick) {
{
updateElementInformation(); updateElementInformation();
super.drawScreen(x, y, partialTick); super.drawScreen(x, y, partialTick);
if (tooltips && mc.thePlayer.inventory.getItemStack() == null) if (tooltips && mc.thePlayer.inventory.getItemStack() == null) {
{
addTooltips(tooltip); addTooltips(tooltip);
drawTooltip(tooltip); drawTooltip(tooltip);
} }
@ -98,15 +94,12 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(int x, int y) protected void drawGuiContainerForegroundLayer(int x, int y) {
{
if (drawTitle) if (drawTitle) {
{
fontRendererObj.drawString(StringHelper.localize(name), getCenteredOffset(StringHelper.localize(name)), 6, 0x404040); fontRendererObj.drawString(StringHelper.localize(name), getCenteredOffset(StringHelper.localize(name)), 6, 0x404040);
} }
if (drawInventory) if (drawInventory) {
{
fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 3, 0x404040); fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 3, 0x404040);
} }
drawElements(0, true); drawElements(0, true);
@ -114,8 +107,7 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int x, int y) protected void drawGuiContainerBackgroundLayer(float partialTick, int x, int y) {
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
bindTexture(texture); bindTexture(texture);
@ -132,18 +124,14 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void keyTyped(char characterTyped, int keyPressed) protected void keyTyped(char characterTyped, int keyPressed) {
{
for (int i = elements.size(); i-- > 0; ) for (int i = elements.size(); i-- > 0;) {
{ ElementBase c = elements.get(i);
techreborn.cofhLib.gui.element.ElementBase c = elements.get(i); if (!c.isVisible() || !c.isEnabled()) {
if (!c.isVisible() || !c.isEnabled())
{
continue; continue;
} }
if (c.onKeyTyped(characterTyped, keyPressed)) if (c.onKeyTyped(characterTyped, keyPressed)) {
{
return; return;
} }
} }
@ -151,8 +139,7 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
public void handleMouseInput() public void handleMouseInput() {
{
int x = Mouse.getEventX() * width / mc.displayWidth; int x = Mouse.getEventX() * width / mc.displayWidth;
int y = height - Mouse.getEventY() * height / mc.displayHeight - 1; int y = height - Mouse.getEventY() * height / mc.displayHeight - 1;
@ -162,24 +149,19 @@ public abstract class GuiBase extends GuiContainer
int wheelMovement = Mouse.getEventDWheel(); int wheelMovement = Mouse.getEventDWheel();
if (wheelMovement != 0) if (wheelMovement != 0) {
{ for (int i = elements.size(); i-- > 0;) {
for (int i = elements.size(); i-- > 0; ) ElementBase c = elements.get(i);
{ if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX, mouseY)) {
techreborn.cofhLib.gui.element.ElementBase c = elements.get(i);
if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX, mouseY))
{
continue; continue;
} }
if (c.onMouseWheel(mouseX, mouseY, wheelMovement)) if (c.onMouseWheel(mouseX, mouseY, wheelMovement)) {
{
return; return;
} }
} }
TabBase tab = getTabAtPosition(mouseX, mouseY); TabBase tab = getTabAtPosition(mouseX, mouseY);
if (tab != null && tab.onMouseWheel(mouseX, mouseY, wheelMovement)) if (tab != null && tab.onMouseWheel(mouseX, mouseY, wheelMovement)) {
{
return; return;
} }
} }
@ -187,37 +169,29 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void mouseClicked(int mX, int mY, int mouseButton) protected void mouseClicked(int mX, int mY, int mouseButton) {
{
mX -= guiLeft; mX -= guiLeft;
mY -= guiTop; mY -= guiTop;
for (int i = elements.size(); i-- > 0; ) for (int i = elements.size(); i-- > 0;) {
{ ElementBase c = elements.get(i);
techreborn.cofhLib.gui.element.ElementBase c = elements.get(i); if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mX, mY)) {
if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mX, mY))
{
continue; continue;
} }
if (c.onMousePressed(mX, mY, mouseButton)) if (c.onMousePressed(mX, mY, mouseButton)) {
{
return; return;
} }
} }
TabBase tab = getTabAtPosition(mX, mY); TabBase tab = getTabAtPosition(mX, mY);
if (tab != null) if (tab != null) {
{
int tMx = mX; int tMx = mX;
if (!tab.onMousePressed(tMx, mY, mouseButton)) if (!tab.onMousePressed(tMx, mY, mouseButton)) {
{ for (int i = tabs.size(); i-- > 0;) {
for (int i = tabs.size(); i-- > 0; )
{
TabBase other = tabs.get(i); TabBase other = tabs.get(i);
if (other != tab && other.open && other.side == tab.side) if (other != tab && other.open && other.side == tab.side) {
{
other.toggleOpen(); other.toggleOpen();
} }
} }
@ -229,12 +203,10 @@ public abstract class GuiBase extends GuiContainer
mX += guiLeft; mX += guiLeft;
mY += guiTop; mY += guiTop;
if (tab != null) if (tab != null) {
{ switch (tab.side) {
switch (tab.side)
{
case TabBase.LEFT: case TabBase.LEFT:
guiLeft -= tab.currentWidth; // guiLeft -= tab.currentWidth;
break; break;
case TabBase.RIGHT: case TabBase.RIGHT:
xSize += tab.currentWidth; xSize += tab.currentWidth;
@ -242,12 +214,10 @@ public abstract class GuiBase extends GuiContainer
} }
} }
super.mouseClicked(mX, mY, mouseButton); super.mouseClicked(mX, mY, mouseButton);
if (tab != null) if (tab != null) {
{ switch (tab.side) {
switch (tab.side)
{
case TabBase.LEFT: case TabBase.LEFT:
guiLeft += tab.currentWidth; // guiLeft += tab.currentWidth;
break; break;
case TabBase.RIGHT: case TabBase.RIGHT:
xSize -= tab.currentWidth; xSize -= tab.currentWidth;
@ -257,19 +227,15 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void mouseMovedOrUp(int mX, int mY, int mouseButton) protected void mouseMovedOrUp(int mX, int mY, int mouseButton) {
{
mX -= guiLeft; mX -= guiLeft;
mY -= guiTop; mY -= guiTop;
if (mouseButton >= 0 && mouseButton <= 2) if (mouseButton >= 0 && mouseButton <= 2) { // 0:left, 1:right, 2: middle
{ // 0:left, 1:right, 2: middle for (int i = elements.size(); i-- > 0;) {
for (int i = elements.size(); i-- > 0; ) ElementBase c = elements.get(i);
{ if (!c.isVisible() || !c.isEnabled()) { // no bounds checking on mouseUp events
techreborn.cofhLib.gui.element.ElementBase c = elements.get(i);
if (!c.isVisible() || !c.isEnabled())
{ // no bounds checking on mouseUp events
continue; continue;
} }
c.onMouseReleased(mX, mY); c.onMouseReleased(mX, mY);
@ -282,44 +248,35 @@ public abstract class GuiBase extends GuiContainer
} }
@Override @Override
protected void mouseClickMove(int mX, int mY, int lastClick, long timeSinceClick) protected void mouseClickMove(int mX, int mY, int lastClick, long timeSinceClick) {
{
Slot slot = getSlotAtPosition(mX, mY); Slot slot = getSlotAtPosition(mX, mY);
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
if (this.field_147007_t && slot != null && itemstack != null && slot instanceof techreborn.cofhLib.gui.slot.SlotFalseCopy) if (this.field_147007_t && slot != null && itemstack != null && slot instanceof SlotFalseCopy) {
{ if (lastIndex != slot.slotNumber) {
if (lastIndex != slot.slotNumber)
{
lastIndex = slot.slotNumber; lastIndex = slot.slotNumber;
this.handleMouseClick(slot, slot.slotNumber, 0, 0); this.handleMouseClick(slot, slot.slotNumber, 0, 0);
} }
} } else {
else
{
lastIndex = -1; lastIndex = -1;
super.mouseClickMove(mX, mY, lastClick, timeSinceClick); super.mouseClickMove(mX, mY, lastClick, timeSinceClick);
} }
} }
public Slot getSlotAtPosition(int xCoord, int yCoord) public Slot getSlotAtPosition(int xCoord, int yCoord) {
{
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) {
{
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(k); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(k);
if (this.isMouseOverSlot(slot, xCoord, yCoord)) if (this.isMouseOverSlot(slot, xCoord, yCoord)) {
{
return slot; return slot;
} }
} }
return null; return null;
} }
public boolean isMouseOverSlot(Slot theSlot, int xCoord, int yCoord) public boolean isMouseOverSlot(Slot theSlot, int xCoord, int yCoord) {
{
return this.func_146978_c(theSlot.xDisplayPosition, theSlot.yDisplayPosition, 16, 16, xCoord, yCoord); return this.func_146978_c(theSlot.xDisplayPosition, theSlot.yDisplayPosition, 16, 16, xCoord, yCoord);
} }
@ -327,27 +284,19 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Draws the elements for this GUI. * Draws the elements for this GUI.
*/ */
protected void drawElements(float partialTick, boolean foreground) protected void drawElements(float partialTick, boolean foreground) {
{
if (foreground) if (foreground) {
{ for (int i = 0; i < elements.size(); i++) {
for (int i = 0; i < elements.size(); i++) ElementBase element = elements.get(i);
{ if (element.isVisible()) {
techreborn.cofhLib.gui.element.ElementBase element = elements.get(i);
if (element.isVisible())
{
element.drawForeground(mouseX, mouseY); element.drawForeground(mouseX, mouseY);
} }
} }
} } else {
else for (int i = 0; i < elements.size(); i++) {
{ ElementBase element = elements.get(i);
for (int i = 0; i < elements.size(); i++) if (element.isVisible()) {
{
techreborn.cofhLib.gui.element.ElementBase element = elements.get(i);
if (element.isVisible())
{
element.drawBackground(mouseX, mouseY, partialTick); element.drawBackground(mouseX, mouseY, partialTick);
} }
} }
@ -357,131 +306,121 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Draws the tabs for this GUI. Handles Tab open/close animation. * Draws the tabs for this GUI. Handles Tab open/close animation.
*/ */
protected void drawTabs(float partialTick, boolean foreground) protected void drawTabs(float partialTick, boolean foreground) {
{
if (foreground)
{
return;
}
int yPosRight = 4; int yPosRight = 4;
int yPosLeft = 4; int yPosLeft = 4;
for (int i = 0; i < tabs.size(); i++) if (foreground) {
{ for (int i = 0; i < tabs.size(); i++) {
TabBase tab = tabs.get(i); TabBase tab = tabs.get(i);
tab.update(); tab.update();
if (!tab.isVisible()) if (!tab.isVisible()) {
{
continue; continue;
} }
if (tab.side == TabBase.LEFT) if (tab.side == TabBase.LEFT) {
{ tab.drawForeground(mouseX, mouseY);
tab.draw(0, yPosLeft);
yPosLeft += tab.currentHeight; yPosLeft += tab.currentHeight;
} } else {
else tab.drawForeground(mouseX, mouseY);
{
tab.draw(xSize, yPosRight);
yPosRight += tab.currentHeight; yPosRight += tab.currentHeight;
} }
} }
} else {
for (int i = 0; i < tabs.size(); i++) {
TabBase tab = tabs.get(i);
tab.update();
if (!tab.isVisible()) {
continue;
}
if (tab.side == TabBase.LEFT) {
tab.setPosition(0, yPosLeft);
tab.drawBackground(mouseX, mouseY, partialTick);
yPosLeft += tab.currentHeight;
} else {
tab.setPosition(xSize, yPosRight);
tab.drawBackground(mouseX, mouseY, partialTick);
yPosRight += tab.currentHeight;
}
}
}
} }
/** /**
* Called by NEI if installed * Called by NEI if installed
*/ */
// @Override // @Override
public List<String> handleTooltip(int mousex, int mousey, List<String> tooltip) public List<String> handleTooltip(int mousex, int mousey, List<String> tooltip) {
{
if (mc.thePlayer.inventory.getItemStack() == null) if (mc.thePlayer.inventory.getItemStack() == null) {
{
addTooltips(tooltip); addTooltips(tooltip);
} }
return tooltip; return tooltip;
} }
public void addTooltips(List<String> tooltip) public void addTooltips(List<String> tooltip) {
{
TabBase tab = getTabAtPosition(mouseX, mouseY); TabBase tab = getTabAtPosition(mouseX, mouseY);
if (tab != null) if (tab != null) {
{
tab.addTooltip(tooltip); tab.addTooltip(tooltip);
} }
techreborn.cofhLib.gui.element.ElementBase element = getElementAtPosition(mouseX, mouseY); ElementBase element = getElementAtPosition(mouseX, mouseY);
if (element != null) if (element != null && element.isVisible()) {
{
element.addTooltip(tooltip); element.addTooltip(tooltip);
} }
} }
/* ELEMENTS */ /* ELEMENTS */
public techreborn.cofhLib.gui.element.ElementBase addElement(techreborn.cofhLib.gui.element.ElementBase element) public ElementBase addElement(ElementBase element) {
{
elements.add(element); elements.add(element);
return element; return element;
} }
public TabBase addTab(TabBase tab) public TabBase addTab(TabBase tab) {
{
int yOffset = 4; int yOffset = 4;
for (int i = 0; i < tabs.size(); i++) for (int i = 0; i < tabs.size(); i++) {
{ if (tabs.get(i).side == tab.side && tabs.get(i).isVisible()) {
if (tabs.get(i).side == tab.side && tabs.get(i).isVisible())
{
yOffset += tabs.get(i).currentHeight; yOffset += tabs.get(i).currentHeight;
} }
} }
tab.setPosition(tab.side == TabBase.LEFT ? 0 : xSize, yOffset); tab.setPosition(tab.side == TabBase.LEFT ? 0 : xSize, yOffset);
tabs.add(tab); tabs.add(tab);
if (TabTracker.getOpenedLeftTab() != null && tab.getClass().equals(TabTracker.getOpenedLeftTab())) if (TabTracker.getOpenedLeftTab() != null && tab.getClass().equals(TabTracker.getOpenedLeftTab())) {
{
tab.setFullyOpen(); tab.setFullyOpen();
} } else if (TabTracker.getOpenedRightTab() != null && tab.getClass().equals(TabTracker.getOpenedRightTab())) {
else if (TabTracker.getOpenedRightTab() != null && tab.getClass().equals(TabTracker.getOpenedRightTab()))
{
tab.setFullyOpen(); tab.setFullyOpen();
} }
return tab; return tab;
} }
protected techreborn.cofhLib.gui.element.ElementBase getElementAtPosition(int mX, int mY) protected ElementBase getElementAtPosition(int mX, int mY) {
{
for (int i = elements.size(); i-- > 0; ) for (int i = elements.size(); i-- > 0;) {
{ ElementBase element = elements.get(i);
techreborn.cofhLib.gui.element.ElementBase element = elements.get(i); if (element.intersectsWith(mX, mY)) {
if (element.intersectsWith(mX, mY))
{
return element; return element;
} }
} }
return null; return null;
} }
protected TabBase getTabAtPosition(int mX, int mY) protected TabBase getTabAtPosition(int mX, int mY) {
{
int xShift = 0; int xShift = 0;
int yShift = 4; int yShift = 4;
for (int i = 0; i < tabs.size(); i++) for (int i = 0; i < tabs.size(); i++) {
{
TabBase tab = tabs.get(i); TabBase tab = tabs.get(i);
if (!tab.isVisible() || tab.side == TabBase.RIGHT) if (!tab.isVisible() || tab.side == TabBase.RIGHT) {
{
continue; continue;
} }
tab.setCurrentShift(xShift, yShift); tab.setCurrentShift(xShift, yShift);
if (tab.intersectsWith(mX, mY, xShift, yShift)) if (tab.intersectsWith(mX, mY, xShift, yShift)) {
{
return tab; return tab;
} }
yShift += tab.currentHeight; yShift += tab.currentHeight;
@ -490,16 +429,13 @@ public abstract class GuiBase extends GuiContainer
xShift = xSize; xShift = xSize;
yShift = 4; yShift = 4;
for (int i = 0; i < tabs.size(); i++) for (int i = 0; i < tabs.size(); i++) {
{
TabBase tab = tabs.get(i); TabBase tab = tabs.get(i);
if (!tab.isVisible() || tab.side == TabBase.LEFT) if (!tab.isVisible() || tab.side == TabBase.LEFT) {
{
continue; continue;
} }
tab.setCurrentShift(xShift, yShift); tab.setCurrentShift(xShift, yShift);
if (tab.intersectsWith(mX, mY, xShift, yShift)) if (tab.intersectsWith(mX, mY, xShift, yShift)) {
{
return tab; return tab;
} }
yShift += tab.currentHeight; yShift += tab.currentHeight;
@ -507,32 +443,26 @@ public abstract class GuiBase extends GuiContainer
return null; return null;
} }
protected final void updateElements() protected final void updateElements() {
{
for (int i = elements.size(); i-- > 0; ) for (int i = elements.size(); i-- > 0;) {
{ ElementBase c = elements.get(i);
techreborn.cofhLib.gui.element.ElementBase c = elements.get(i); if (c.isVisible() && c.isEnabled()) {
if (c.isVisible() && c.isEnabled())
{
c.update(mouseX, mouseY); c.update(mouseX, mouseY);
} }
} }
} }
protected void updateElementInformation() protected void updateElementInformation() {
{
} }
public void handleElementButtonClick(String buttonName, int mouseButton) public void handleElementButtonClick(String buttonName, int mouseButton) {
{
} }
/* HELPERS */ /* HELPERS */
public void bindTexture(ResourceLocation texture) public void bindTexture(ResourceLocation texture) {
{
mc.renderEngine.bindTexture(texture); mc.renderEngine.bindTexture(texture);
} }
@ -540,8 +470,7 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Abstract method to retrieve icons by name from a registry. You must override this if you use any of the String methods below. * Abstract method to retrieve icons by name from a registry. You must override this if you use any of the String methods below.
*/ */
public IIcon getIcon(String name) public IIcon getIcon(String name) {
{
return null; return null;
} }
@ -549,14 +478,12 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Essentially a placeholder method for tabs to use should they need to draw a button. * Essentially a placeholder method for tabs to use should they need to draw a button.
*/ */
public void drawButton(IIcon icon, int x, int y, int spriteSheet, int mode) public void drawButton(IIcon icon, int x, int y, int spriteSheet, int mode) {
{
drawIcon(icon, x, y, spriteSheet); drawIcon(icon, x, y, spriteSheet);
} }
public void drawButton(String iconName, int x, int y, int spriteSheet, int mode) public void drawButton(String iconName, int x, int y, int spriteSheet, int mode) {
{
drawButton(getIcon(iconName), x, y, spriteSheet, mode); drawButton(getIcon(iconName), x, y, spriteSheet, mode);
} }
@ -564,11 +491,9 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Simple method used to draw a fluid of arbitrary size. * Simple method used to draw a fluid of arbitrary size.
*/ */
public void drawFluid(int x, int y, FluidStack fluid, int width, int height) public void drawFluid(int x, int y, FluidStack fluid, int width, int height) {
{
if (fluid == null || fluid.getFluid() == null) if (fluid == null || fluid.getFluid() == null) {
{
return; return;
} }
RenderHelper.setBlockTextureSheet(); RenderHelper.setBlockTextureSheet();
@ -577,8 +502,7 @@ public abstract class GuiBase extends GuiContainer
drawTiledTexture(x, y, fluid.getFluid().getIcon(fluid), width, height); drawTiledTexture(x, y, fluid.getFluid().getIcon(fluid), width, height);
} }
public void drawTiledTexture(int x, int y, IIcon icon, int width, int height) public void drawTiledTexture(int x, int y, IIcon icon, int width, int height) {
{
int i = 0; int i = 0;
int j = 0; int j = 0;
@ -586,10 +510,8 @@ public abstract class GuiBase extends GuiContainer
int drawHeight = 0; int drawHeight = 0;
int drawWidth = 0; int drawWidth = 0;
for (i = 0; i < width; i += 16) for (i = 0; i < width; i += 16) {
{ for (j = 0; j < height; j += 16) {
for (j = 0; j < height; j += 16)
{
drawWidth = Math.min(width - i, 16); drawWidth = Math.min(width - i, 16);
drawHeight = Math.min(height - j, 16); drawHeight = Math.min(height - j, 16);
drawScaledTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight); drawScaledTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight);
@ -598,54 +520,42 @@ public abstract class GuiBase extends GuiContainer
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
} }
public void drawIcon(IIcon icon, int x, int y, int spriteSheet) public void drawIcon(IIcon icon, int x, int y, int spriteSheet) {
{
if (spriteSheet == 0) if (spriteSheet == 0) {
{
RenderHelper.setBlockTextureSheet(); RenderHelper.setBlockTextureSheet();
} } else {
else
{
RenderHelper.setItemTextureSheet(); RenderHelper.setItemTextureSheet();
} }
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
drawTexturedModelRectFromIcon(x, y, icon, 16, 16); drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
} }
public void drawColorIcon(IIcon icon, int x, int y, int spriteSheet) public void drawColorIcon(IIcon icon, int x, int y, int spriteSheet) {
{
if (spriteSheet == 0) if (spriteSheet == 0) {
{
RenderHelper.setBlockTextureSheet(); RenderHelper.setBlockTextureSheet();
} } else {
else
{
RenderHelper.setItemTextureSheet(); RenderHelper.setItemTextureSheet();
} }
drawTexturedModelRectFromIcon(x, y, icon, 16, 16); drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
} }
public void drawIcon(String iconName, int x, int y, int spriteSheet) public void drawIcon(String iconName, int x, int y, int spriteSheet) {
{
drawIcon(getIcon(iconName), x, y, spriteSheet); drawIcon(getIcon(iconName), x, y, spriteSheet);
} }
public void drawSizedModalRect(int x1, int y1, int x2, int y2, int color) public void drawSizedModalRect(int x1, int y1, int x2, int y2, int color) {
{
int temp; int temp;
if (x1 < x2) if (x1 < x2) {
{
temp = x1; temp = x1;
x1 = x2; x1 = x2;
x2 = temp; x2 = temp;
} }
if (y1 < y2) if (y1 < y2) {
{
temp = y1; temp = y1;
y1 = y2; y1 = y2;
y2 = temp; y2 = temp;
@ -670,19 +580,16 @@ public abstract class GuiBase extends GuiContainer
GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_BLEND);
} }
public void drawSizedRect(int x1, int y1, int x2, int y2, int color) public void drawSizedRect(int x1, int y1, int x2, int y2, int color) {
{
int temp; int temp;
if (x1 < x2) if (x1 < x2) {
{
temp = x1; temp = x1;
x1 = x2; x1 = x2;
x2 = temp; x2 = temp;
} }
if (y1 < y2) if (y1 < y2) {
{
temp = y1; temp = y1;
y1 = y2; y1 = y2;
y2 = temp; y2 = temp;
@ -704,8 +611,7 @@ public abstract class GuiBase extends GuiContainer
GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_TEXTURE_2D);
} }
public void drawSizedTexturedModalRect(int x, int y, int u, int v, int width, int height, float texW, float texH) public void drawSizedTexturedModalRect(int x, int y, int u, int v, int width, int height, float texW, float texH) {
{
float texU = 1 / texW; float texU = 1 / texW;
float texV = 1 / texH; float texV = 1 / texH;
@ -718,11 +624,9 @@ public abstract class GuiBase extends GuiContainer
tessellator.draw(); tessellator.draw();
} }
public void drawScaledTexturedModelRectFromIcon(int x, int y, IIcon icon, int width, int height) public void drawScaledTexturedModelRectFromIcon(int x, int y, IIcon icon, int width, int height) {
{
if (icon == null) if (icon == null) {
{
return; return;
} }
double minU = icon.getMinU(); double minU = icon.getMinU();
@ -739,19 +643,16 @@ public abstract class GuiBase extends GuiContainer
tessellator.draw(); tessellator.draw();
} }
public void drawTooltip(List<String> list) public void drawTooltip(List<String> list) {
{
drawTooltipHoveringText(list, mouseX + guiLeft, mouseY + guiTop, fontRendererObj); drawTooltipHoveringText(list, mouseX + guiLeft, mouseY + guiTop, fontRendererObj);
tooltip.clear(); tooltip.clear();
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
protected void drawTooltipHoveringText(List list, int x, int y, FontRenderer font) protected void drawTooltipHoveringText(List list, int x, int y, FontRenderer font) {
{
if (list == null || list.isEmpty()) if (list == null || list.isEmpty()) {
{
return; return;
} }
GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glDisable(GL12.GL_RESCALE_NORMAL);
@ -760,13 +661,11 @@ public abstract class GuiBase extends GuiContainer
int k = 0; int k = 0;
Iterator iterator = list.iterator(); Iterator iterator = list.iterator();
while (iterator.hasNext()) while (iterator.hasNext()) {
{
String s = (String) iterator.next(); String s = (String) iterator.next();
int l = font.getStringWidth(s); int l = font.getStringWidth(s);
if (l > k) if (l > k) {
{
k = l; k = l;
} }
} }
@ -774,16 +673,13 @@ public abstract class GuiBase extends GuiContainer
int j1 = y - 12; int j1 = y - 12;
int k1 = 8; int k1 = 8;
if (list.size() > 1) if (list.size() > 1) {
{
k1 += 2 + (list.size() - 1) * 10; k1 += 2 + (list.size() - 1) * 10;
} }
if (i1 + k > this.width) if (i1 + k > this.width) {
{
i1 -= 28 + k; i1 -= 28 + k;
} }
if (j1 + k1 + 6 > this.height) if (j1 + k1 + 6 > this.height) {
{
j1 = this.height - k1 - 6; j1 = this.height - k1 - 6;
} }
this.zLevel = 300.0F; this.zLevel = 300.0F;
@ -801,13 +697,11 @@ public abstract class GuiBase extends GuiContainer
this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2); this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2); this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);
for (int k2 = 0; k2 < list.size(); ++k2) for (int k2 = 0; k2 < list.size(); ++k2) {
{
String s1 = (String) list.get(k2); String s1 = (String) list.get(k2);
font.drawStringWithShadow(s1, i1, j1, -1); font.drawStringWithShadow(s1, i1, j1, -1);
if (k2 == 0) if (k2 == 0) {
{
j1 += 2; j1 += 2;
} }
j1 += 10; j1 += 10;
@ -822,56 +716,47 @@ public abstract class GuiBase extends GuiContainer
/** /**
* Passthrough method for tab use. * Passthrough method for tab use.
*/ */
public void mouseClicked(int mouseButton) public void mouseClicked(int mouseButton) {
{
super.mouseClicked(guiLeft + mouseX, guiTop + mouseY, mouseButton); super.mouseClicked(guiLeft + mouseX, guiTop + mouseY, mouseButton);
} }
public FontRenderer getFontRenderer() public FontRenderer getFontRenderer() {
{
return fontRendererObj; return fontRendererObj;
} }
protected int getCenteredOffset(String string) protected int getCenteredOffset(String string) {
{
return this.getCenteredOffset(string, xSize); return this.getCenteredOffset(string, xSize);
} }
protected int getCenteredOffset(String string, int xWidth) protected int getCenteredOffset(String string, int xWidth) {
{
return (xWidth - fontRendererObj.getStringWidth(string)) / 2; return (xWidth - fontRendererObj.getStringWidth(string)) / 2;
} }
public int getGuiLeft() public int getGuiLeft() {
{
return guiLeft; return guiLeft;
} }
public int getGuiTop() public int getGuiTop() {
{
return guiTop; return guiTop;
} }
public int getMouseX() public int getMouseX() {
{
return mouseX; return mouseX;
} }
public int getMouseY() public int getMouseY() {
{
return mouseY; return mouseY;
} }
public void overlayRecipe() public void overlayRecipe() {
{
} }

View file

@ -1,178 +1,188 @@
package techreborn.cofhLib.gui.element; package techreborn.cofhLib.gui.element;
import techreborn.cofhLib.gui.GuiBase;
import techreborn.cofhLib.gui.GuiColor;
import techreborn.cofhLib.gui.element.listbox.IListBoxElement;
import techreborn.cofhLib.util.helpers.StringHelper; import techreborn.cofhLib.util.helpers.StringHelper;
import org.lwjgl.opengl.GL11; import static org.lwjgl.opengl.GL11.*;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
public class ElementListBox extends ElementBase public class ElementListBox extends ElementBase {
{
public int borderColor = new techreborn.cofhLib.gui.GuiColor(120, 120, 120, 255).getColor(); public int borderColor = new GuiColor(120, 120, 120, 255).getColor();
public int backgroundColor = new techreborn.cofhLib.gui.GuiColor(0, 0, 0, 255).getColor(); public int backgroundColor = new GuiColor(0, 0, 0, 255).getColor();
public int selectedLineColor = new techreborn.cofhLib.gui.GuiColor(0, 0, 0, 255).getColor(); public int selectedLineColor = new GuiColor(0, 0, 0, 255).getColor();
public int textColor = new techreborn.cofhLib.gui.GuiColor(150, 150, 150, 255).getColor(); public int textColor = new GuiColor(150, 150, 150, 255).getColor();
public int selectedTextColor = new techreborn.cofhLib.gui.GuiColor(255, 255, 255, 255).getColor(); public int selectedTextColor = new GuiColor(255, 255, 255, 255).getColor();
private final int _marginTop = 2; private final int _marginTop = 2;
private final int _marginLeft = 2; private final int _marginLeft = 2;
private final int _marginRight = 2; private final int _marginRight = 2;
private final int _marginBottom = 2; private final int _marginBottom = 2;
private final List<techreborn.cofhLib.gui.element.listbox.IListBoxElement> _elements = new LinkedList<techreborn.cofhLib.gui.element.listbox.IListBoxElement>(); private final List<IListBoxElement> _elements = new LinkedList<IListBoxElement>();
private int _firstIndexDisplayed; private int _firstIndexDisplayed;
private int _selectedIndex; private int _selectedIndex;
private int scrollHoriz; private int scrollHoriz;
public ElementListBox(techreborn.cofhLib.gui.GuiBase containerScreen, int x, int y, int width, int height) public ElementListBox(GuiBase containerScreen, int x, int y, int width, int height) {
{
super(containerScreen, x, y, width, height); super(containerScreen, x, y, width, height);
} }
public void add(techreborn.cofhLib.gui.element.listbox.IListBoxElement element) public void add(IListBoxElement element) {
{
_elements.add(element); _elements.add(element);
} }
public void add(Collection<? extends techreborn.cofhLib.gui.element.listbox.IListBoxElement> elements) public void add(Collection<? extends IListBoxElement> elements) {
{
_elements.addAll(elements); _elements.addAll(elements);
} }
public void remove(techreborn.cofhLib.gui.element.listbox.IListBoxElement element) public void remove(IListBoxElement element) {
{
_elements.remove(element); _elements.remove(element);
} }
public void removeAt(int index) public void removeAt(int index) {
{
_elements.remove(index); _elements.remove(index);
} }
public int getInternalWidth() public void removeAll() {
{
_elements.clear();
}
public int getInternalWidth() {
int width = 0; int width = 0;
for (int i = 0; i < _elements.size(); i++) for (int i = 0; i < _elements.size(); i++) {
{
width = Math.max(_elements.get(i).getWidth(), width); width = Math.max(_elements.get(i).getWidth(), width);
} }
return width; return width;
} }
public int getInternalHeight() public int getInternalHeight() {
{
int height = 0; int height = 0;
for (int i = 0; i < _elements.size(); i++) for (int i = 0; i < _elements.size(); i++) {
{
height += _elements.get(i).getHeight(); height += _elements.get(i).getHeight();
} }
return height; return height;
} }
public int getContentWidth() public int getContentWidth() {
{
return sizeX - _marginLeft - _marginRight; return sizeX - _marginLeft - _marginRight;
} }
public int getContentHeight() public int getContentHeight() {
{
return sizeY - _marginTop - _marginBottom; return sizeY - _marginTop - _marginBottom;
} }
public int getContentTop() public int getContentTop() {
{
return posY + _marginTop; return posY + _marginTop;
} }
public int getContentLeft() public int getContentLeft() {
{
return posX + _marginLeft; return posX + _marginLeft;
} }
public final int getContentBottom() public final int getContentBottom() {
{
return getContentTop() + getContentHeight(); return getContentTop() + getContentHeight();
} }
public final int getContentRight() public final int getContentRight() {
{
return getContentLeft() + getContentWidth(); return getContentLeft() + getContentWidth();
} }
public ElementListBox setTextColor(Number textColor, Number selectedTextColor) {
if (textColor != null) {
this.textColor = textColor.intValue();
}
if (selectedTextColor != null) {
this.selectedTextColor = selectedTextColor.intValue();
}
return this;
}
public ElementListBox setSelectionColor(Number selectedLineColor) {
if (selectedLineColor != null) {
this.selectedLineColor = selectedLineColor.intValue();
}
return this;
}
public ElementListBox setBackgroundColor(Number backgroundColor, Number borderColor) {
if (backgroundColor != null) {
this.backgroundColor = backgroundColor.intValue();
}
if (borderColor != null) {
this.borderColor = borderColor.intValue();
}
return this;
}
@Override @Override
public void drawBackground(int mouseX, int mouseY, float gameTicks) public void drawBackground(int mouseX, int mouseY, float gameTicks) {
{
drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor);
drawModalRect(posX, posY, posX + sizeX, posY + sizeY, backgroundColor); drawModalRect(posX, posY, posX + sizeX, posY + sizeY, backgroundColor);
} }
@Override @Override
public void drawForeground(int mouseX, int mouseY) public void drawForeground(int mouseX, int mouseY) {
{
int heightDrawn = 0; int heightDrawn = 0;
int nextElement = _firstIndexDisplayed; int nextElement = _firstIndexDisplayed;
GL11.glDisable(GL11.GL_LIGHTING); glPushMatrix();
GL11.glPushMatrix(); glDisable(GL_LIGHTING);
GL11.glEnable(GL11.GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);
drawStencil(getContentLeft(), getContentTop(), getContentRight(), getContentBottom(), 1); drawStencil(getContentLeft(), getContentTop(), getContentRight(), getContentBottom(), 1);
GL11.glTranslated(-scrollHoriz, 0, 0); glTranslated(-scrollHoriz, 0, 0);
int e = _elements.size(); int e = _elements.size();
while (nextElement < e && heightDrawn <= getContentHeight()) while (nextElement < e && heightDrawn <= getContentHeight()) {
{ if (nextElement == _selectedIndex) {
if (nextElement == _selectedIndex)
{
_elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, selectedLineColor, selectedTextColor); _elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, selectedLineColor, selectedTextColor);
} } else {
else
{
_elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, backgroundColor, textColor); _elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, backgroundColor, textColor);
} }
heightDrawn += _elements.get(nextElement).getHeight(); heightDrawn += _elements.get(nextElement).getHeight();
nextElement++; nextElement++;
} }
glDisable(GL_STENCIL_TEST);
GL11.glDisable(GL11.GL_STENCIL_TEST); glPopMatrix();
GL11.glPopMatrix();
} }
@Override @Override
public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) {
{
int heightChecked = 0; int heightChecked = 0;
for (int i = _firstIndexDisplayed; i < _elements.size(); i++) for (int i = _firstIndexDisplayed; i < _elements.size(); i++) {
{ if (heightChecked > getContentHeight()) {
if (heightChecked > getContentHeight())
{
break; break;
} }
int elementHeight = _elements.get(i).getHeight(); int elementHeight = _elements.get(i).getHeight();
if (getContentTop() + heightChecked <= mouseY && getContentTop() + heightChecked + elementHeight >= mouseY) if (getContentTop() + heightChecked <= mouseY && getContentTop() + heightChecked + elementHeight >= mouseY) {
{
setSelectedIndex(i); setSelectedIndex(i);
onElementClicked(_elements.get(i)); onElementClicked(_elements.get(i));
break; break;
@ -183,184 +193,146 @@ public class ElementListBox extends ElementBase
} }
@Override @Override
public boolean onMouseWheel(int mouseX, int mouseY, int movement) public boolean onMouseWheel(int mouseX, int mouseY, int movement) {
{
if (StringHelper.isControlKeyDown()) if (StringHelper.isControlKeyDown()) {
{ if (movement > 0) {
if (movement > 0)
{
scrollLeft(); scrollLeft();
} } else if (movement < 0) {
else if (movement < 0)
{
scrollRight(); scrollRight();
} }
} } else {
else if (movement > 0) {
{
if (movement > 0)
{
scrollUp(); scrollUp();
} } else if (movement < 0) {
else if (movement < 0)
{
scrollDown(); scrollDown();
} }
} }
return true; return true;
} }
public void scrollDown() public void scrollDown() {
{
int heightDisplayed = 0; int heightDisplayed = 0;
int elementsDisplayed = 0; int elementsDisplayed = 0;
for (int i = _firstIndexDisplayed; i < _elements.size(); i++) for (int i = _firstIndexDisplayed; i < _elements.size(); i++) {
{ if (heightDisplayed + _elements.get(i).getHeight() > sizeY) {
if (heightDisplayed + _elements.get(i).getHeight() > sizeY)
{
break; break;
} }
heightDisplayed += _elements.get(i).getHeight(); heightDisplayed += _elements.get(i).getHeight();
elementsDisplayed++; elementsDisplayed++;
} }
if (_firstIndexDisplayed + elementsDisplayed < _elements.size()) {
if (_firstIndexDisplayed + elementsDisplayed < _elements.size())
{
_firstIndexDisplayed++; _firstIndexDisplayed++;
} }
onScrollV(_firstIndexDisplayed); onScrollV(_firstIndexDisplayed);
} }
public void scrollUp() public void scrollUp() {
{
if (_firstIndexDisplayed > 0) if (_firstIndexDisplayed > 0) {
{
_firstIndexDisplayed--; _firstIndexDisplayed--;
} }
onScrollV(_firstIndexDisplayed); onScrollV(_firstIndexDisplayed);
} }
public void scrollLeft() public void scrollLeft() {
{
scrollHoriz = Math.max(scrollHoriz - 15, 0); scrollHoriz = Math.max(scrollHoriz - 15, 0);
onScrollH(scrollHoriz); onScrollH(scrollHoriz);
} }
public void scrollRight() public void scrollRight() {
{
scrollHoriz = Math.min(scrollHoriz + 15, getLastScrollPositionH()); scrollHoriz = Math.min(scrollHoriz + 15, getLastScrollPositionH());
onScrollH(scrollHoriz); onScrollH(scrollHoriz);
} }
public int getLastScrollPosition() public int getLastScrollPosition() {
{
int position = _elements.size() - 1; int position = _elements.size() - 1;
int heightUsed = _elements.get(position).getHeight(); int heightUsed = _elements.get(position).getHeight();
while (position > 0 && heightUsed < sizeY) while (position > 0 && heightUsed < sizeY) {
{
position--; position--;
heightUsed += _elements.get(position).getHeight(); heightUsed += _elements.get(position).getHeight();
} }
return position + 1; return position + 1;
} }
public int getLastScrollPositionH() public int getLastScrollPositionH() {
{
return Math.max(getInternalWidth() - getContentWidth(), 0); return Math.max(getInternalWidth() - getContentWidth(), 0);
} }
public int getSelectedIndex() public int getSelectedIndex() {
{
return _selectedIndex; return _selectedIndex;
} }
public int getIndexOf(Object value) public int getIndexOf(Object value) {
{
for (int i = 0; i < _elements.size(); i++) for (int i = 0; i < _elements.size(); i++) {
{ if (_elements.get(i).getValue().equals(value)) {
if (_elements.get(i).getValue().equals(value))
{
return i; return i;
} }
} }
return -1; return -1;
} }
public techreborn.cofhLib.gui.element.listbox.IListBoxElement getSelectedElement() public IListBoxElement getSelectedElement() {
{
if (_selectedIndex == -1 || _selectedIndex == _elements.size()) {
return null;
}
return _elements.get(_selectedIndex); return _elements.get(_selectedIndex);
} }
public void setSelectedIndex(int index) public void setSelectedIndex(int index) {
{
if (index >= 0 && index < _elements.size() && index != _selectedIndex) if (index >= -1 && index != _selectedIndex && index < _elements.size()) {
{
_selectedIndex = index; _selectedIndex = index;
onSelectionChanged(_selectedIndex, getSelectedElement()); onSelectionChanged(_selectedIndex, getSelectedElement());
} }
} }
public techreborn.cofhLib.gui.element.listbox.IListBoxElement getElement(int index) public IListBoxElement getElement(int index) {
{
return _elements.get(index); return _elements.get(index);
} }
public int getElementCount() public int getElementCount() {
{
return _elements.size(); return _elements.size();
} }
public void scrollToV(int index) public void scrollToV(int index) {
{
if (index >= 0 && index < _elements.size()) if (index >= 0 && index < _elements.size()) {
{
_firstIndexDisplayed = index; _firstIndexDisplayed = index;
} }
} }
public void scrollToH(int index) public void scrollToH(int index) {
{
if (index >= 0 && index <= getLastScrollPositionH()) if (index >= 0 && index <= getLastScrollPositionH()) {
{
scrollHoriz = index; scrollHoriz = index;
} }
} }
protected void onElementClicked(techreborn.cofhLib.gui.element.listbox.IListBoxElement element) protected void onElementClicked(IListBoxElement element) {
{
} }
protected void onScrollV(int newStartIndex) protected void onScrollV(int newStartIndex) {
{
} }
protected void onScrollH(int newStartIndex) protected void onScrollH(int newStartIndex) {
{
} }
protected void onSelectionChanged(int newIndex, techreborn.cofhLib.gui.element.listbox.IListBoxElement newElement) protected void onSelectionChanged(int newIndex, IListBoxElement newElement) {
{
} }