use of buildcraft.core.list.ContainerList.WidgetListSlot in project BuildCraft by BuildCraft.
the class GuiList method initGui.
@Override
public void initGui() {
super.initGui();
for (int line = 0; line < container.slots.length; line++) {
WidgetListSlot[] arr = container.slots[line];
for (int slot = 0; slot < arr.length; slot++) {
final WidgetListSlot listSlot = arr[slot];
GuiRectangle rectangle = new GuiRectangle(8 + slot * 18, 32 + line * 34, 16, 16);
IGuiArea phantomSlotArea = rectangle.offset(mainGui.rootElement);
mainGui.shownElements.add(listSlot.new GuiElementPhantomSlot(mainGui, phantomSlotArea) {
@Override
protected boolean shouldDrawHighlight() {
if (listSlot.slotIndex == 0) {
return true;
}
return !GuiList.this.container.lines[listSlot.lineIndex].isOneStackMode();
}
@Override
public void drawBackground(float partialTicks) {
if (!shouldDrawHighlight()) {
ICON_HIGHLIGHT.drawAt(this);
}
}
@Nonnull
@Override
public ItemStack getStack() {
if (shouldDrawHighlight()) {
return super.getStack();
} else {
NonNullList<ItemStack> data = GuiList.this.getExamplesList(listSlot.lineIndex, container.lines[listSlot.lineIndex].getSortingType());
if (data.size() >= listSlot.slotIndex) {
return data.get(listSlot.slotIndex - 1);
} else {
return StackUtil.EMPTY;
}
}
}
@Override
public void onMouseClicked(int button) {
super.onMouseClicked(button);
if (contains(gui.mouse)) {
clearExamplesCache(listSlot.lineIndex);
}
}
});
}
}
buttonList.clear();
for (int sy = 0; sy < ListHandler.HEIGHT; sy++) {
int bOff = sy * BUTTON_COUNT;
int bOffX = this.guiLeft + 8 + ListHandler.WIDTH * 18 - BUTTON_COUNT * 11;
int bOffY = this.guiTop + 32 + sy * 34 + 18;
GuiImageButton buttonPrecise = new GuiImageButton(mainGui, bOff + 0, bOffX, bOffY, 11, TEXTURE_BASE, 176, 16, 176, 28);
buttonPrecise.setToolTip(ToolTip.createLocalized("gui.list.nbt"));
buttonPrecise.setBehaviour(IButtonBehaviour.TOGGLE);
mainGui.shownElements.add(buttonPrecise);
GuiImageButton buttonType = new GuiImageButton(mainGui, bOff + 1, bOffX + 11, bOffY, 11, TEXTURE_BASE, 176, 16, 185, 28);
buttonType.setToolTip(ToolTip.createLocalized("gui.list.metadata"));
buttonType.setBehaviour(IButtonBehaviour.TOGGLE);
mainGui.shownElements.add(buttonType);
GuiImageButton buttonMaterial = new GuiImageButton(mainGui, bOff + 2, bOffX + 22, bOffY, 11, TEXTURE_BASE, 176, 16, 194, 28);
buttonMaterial.setToolTip(ToolTip.createLocalized("gui.list.oredict"));
buttonMaterial.setBehaviour(IButtonBehaviour.TOGGLE);
mainGui.shownElements.add(buttonMaterial);
}
for (IGuiElement elem : mainGui.shownElements) {
if (elem instanceof GuiImageButton) {
GuiImageButton b = (GuiImageButton) elem;
int id = Integer.parseInt(b.id);
int lineId = id / BUTTON_COUNT;
int buttonId = id % BUTTON_COUNT;
if (container.lines[lineId].getOption(buttonId)) {
b.activate();
}
b.registerListener(this);
}
}
textField = new GuiTextField(6, this.fontRenderer, guiLeft + 10, guiTop + 10, 156, 12);
textField.setMaxStringLength(32);
textField.setText(BCCoreItems.list.getName(container.getListItemStack()));
textField.setFocused(false);
}
Aggregations