Search in sources :

Example 1 with TableCellButton

use of ivorius.reccomplex.gui.table.cell.TableCellButton in project RecurrentComplex by Ivorforce.

the class TableDataSourceMazePath method cellForIndexInSegment.

@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
    if (segment == 1) {
        TableCellEnum.Option<EnumFacing>[] optionList = TableDirections.getDirectionOptions(EnumFacing.VALUES);
        TableCellEnum<EnumFacing> cell = new TableCellEnum<>("side", directionFromPath(mazePath), optionList);
        cell.addPropertyConsumer(val -> {
            SavedMazePathConnection path = pathFromDirection(val, mazePath.sourceRoom.getCoordinates());
            mazePath.pathDimension = path.path.pathDimension;
            mazePath.pathGoesUp = path.path.pathGoesUp;
            tableDelegate.reloadData();
        });
        return new TitledCell(IvTranslations.get("reccomplex.generationInfo.mazeComponent.path.side"), cell);
    } else if (segment == 2) {
        invertableButton = new TableCellButton("actions", "inverse", IvTranslations.get("reccomplex.generationInfo.mazeComponent.path.invert"), isInvertable());
        invertableButton.addAction(() -> {
            mazePath.set(mazePath.inverse());
            source.room = mazePath.sourceRoom;
            tableDelegate.reloadData();
        });
        return new TitledCell(invertableButton);
    }
    return super.cellForIndexInSegment(table, index, segment);
}
Also used : TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) EnumFacing(net.minecraft.util.EnumFacing) SavedMazePathConnection(ivorius.reccomplex.world.gen.feature.structure.generic.maze.SavedMazePathConnection) TableCellEnum(ivorius.reccomplex.gui.table.cell.TableCellEnum) TableCellButton(ivorius.reccomplex.gui.table.cell.TableCellButton)

Example 2 with TableCellButton

use of ivorius.reccomplex.gui.table.cell.TableCellButton in project RecurrentComplex by Ivorforce.

the class TableCells method edit.

@Nonnull
public static TableCellButton edit(boolean enabled, TableNavigator navigator, TableDelegate tableDelegate, Supplier<TableDataSource> table) {
    TableCellButton edit = new TableCellButton(null, "edit", IvTranslations.get("reccomplex.gui.edit"), enabled) {

        @Override
        public void draw(GuiTable screen, int mouseX, int mouseY, float partialTicks) {
            super.draw(screen, mouseX, mouseY, partialTicks);
            int color = 0xe0e0e0;
            if (!this.enabled)
                color = 0xa0a0a0;
            else if (this.button != null && this.button.isMouseOver())
                color = 0xffffa0;
            String right = "...";
            int rightWidth = getFontRenderer().getStringWidth(right);
            getFontRenderer().drawString(right, bounds().getMaxX() - 8 - rightWidth, bounds().getCenterY() - 4, color, true);
        }
    };
    edit.addAction(() -> navigator.pushTable(new GuiTable(tableDelegate, table.get())));
    return edit;
}
Also used : TableCellButton(ivorius.reccomplex.gui.table.cell.TableCellButton) Nonnull(javax.annotation.Nonnull)

Aggregations

TableCellButton (ivorius.reccomplex.gui.table.cell.TableCellButton)2 TableCellEnum (ivorius.reccomplex.gui.table.cell.TableCellEnum)1 TitledCell (ivorius.reccomplex.gui.table.cell.TitledCell)1 SavedMazePathConnection (ivorius.reccomplex.world.gen.feature.structure.generic.maze.SavedMazePathConnection)1 Nonnull (javax.annotation.Nonnull)1 EnumFacing (net.minecraft.util.EnumFacing)1