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);
}
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;
}
Aggregations