use of ivorius.reccomplex.gui.table.GuiTable in project RecurrentComplex by Ivorforce.
the class TableDataSourceItemCollectionComponent method cellForIndexInSegment.
@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
if (segment == 0) {
TableCellString cell = new TableCellString(null, key);
cell.setShowsValidityState(true);
cell.setValidityState(currentKeyState());
cell.addPropertyConsumer(val -> {
key = val;
cell.setValidityState(currentKeyState());
});
return new TitledCell(IvTranslations.get("reccomplex.gui.inventorygen.componentid"), cell).withTitleTooltip(IvTranslations.formatLines("reccomplex.gui.inventorygen.componentid.tooltip"));
} else if (segment == 2) {
TableCellString cell = new TableCellString(null, component.inventoryGeneratorID);
cell.setShowsValidityState(true);
cell.setValidityState(currentGroupIDState());
cell.addPropertyConsumer(val -> {
component.inventoryGeneratorID = val;
cell.setValidityState(currentGroupIDState());
});
return new TitledCell(IvTranslations.get("reccomplex.gui.inventorygen.groupid"), cell).withTitleTooltip(IvTranslations.formatLines("reccomplex.gui.inventorygen.groupid.tooltip"));
}
return super.cellForIndexInSegment(table, index, segment);
}
use of ivorius.reccomplex.gui.table.GuiTable in project RecurrentComplex by Ivorforce.
the class TableDataSourceMazeRuleConnectAll method cellForIndexInSegment.
@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
if (segment == 0) {
TableCellBoolean preventCell = new TableCellBoolean("prevent", rule.preventConnection, TextFormatting.GOLD + IvTranslations.get("reccomplex.mazerule.connect.prevent"), TextFormatting.GREEN + IvTranslations.get("reccomplex.mazerule.connect.prevent"));
preventCell.addPropertyConsumer(val -> rule.preventConnection = val);
return new TitledCell(preventCell);
} else if (segment == 2) {
TableCellBoolean cell = new TableCellBoolean("additive", rule.additive, TextFormatting.GREEN + IvTranslations.get("reccomplex.mazerule.connectall.additive"), TextFormatting.GOLD + IvTranslations.get("reccomplex.mazerule.connectall.subtractive"));
cell.addPropertyConsumer(val -> {
rule.additive = val;
tableDelegate.reloadData();
});
return new TitledCell(cell);
} else if (segment == 4) {
return new TitledCell(new TableCellTitle("", IvTranslations.get("reccomplex.mazerule.connectall.preview")));
} else if (segment == 5) {
ConnectorFactory factory = new ConnectorFactory();
Set<Connector> blockedConnections = Collections.singleton(factory.get(ConnectorStrategy.DEFAULT_WALL));
List<SavedMazePath> exitPaths = MazeRuleConnectAll.getPaths(rule.exits, expected, blockedConnections, factory).collect(Collectors.toList());
return new TitledCell(new TableCellTitle("", exitPaths.get(index).toString()));
}
return super.cellForIndexInSegment(table, index, segment);
}
use of ivorius.reccomplex.gui.table.GuiTable in project RecurrentComplex by Ivorforce.
the class TableDataSourceNBTTagCompound method cellForIndexInSegment.
@Override
public TableCell cellForIndexInSegment(GuiTable table, int index, int segment) {
if (segment == 0) {
TableCellButton load = new TableCellButton(null, "toString", "->", Collections.singletonList("Convert to String (slightly lossy)"), true);
TableCellButton perform = new TableCellButton(null, "fromString", "O", Collections.singletonList("Load from String"), false);
TableCellString cell = new TableCellString("tileEntityInfo", "");
cell.addPropertyConsumer(val -> perform.setEnabled(WeightedBlockState.tryParse(val) != null));
// FromGuiCommandBlock
cell.setMaxStringLength(32500);
load.addAction(() -> {
cell.setPropertyValue(nbt.toString());
perform.setEnabled(true);
});
perform.addAction(() -> {
NBTTagCompound other = WeightedBlockState.tryParse(cell.getPropertyValue());
if (other != null) {
nbt.getKeySet().clear();
other.getKeySet().forEach(s -> nbt.setTag(s, other.getTag(s)));
resetSortedKeys();
delegate.reloadData();
}
});
TableCellMulti multi = new TableCellMulti(load, cell, perform);
multi.setSize(0, 0.1f);
multi.setSize(2, 0.1f);
return new TitledCell("As String", multi);
} else if (segment == 1 || segment == 3) {
return new TableCellPresetAction(null, IntStream.range(0, 12).mapToObj((id) -> TableDataSourceNBT.addButton(id, n -> {
nbt.setTag("", n);
sortedKeys.removeIf(s -> s.equals(""));
sortedKeys.add(segment == 1 ? 0 : sortedKeys.size(), "");
delegate.reloadData();
})).collect(Collectors.toList()));
} else {
String key = sortedKeys.get(index);
String[] nextKey = new String[] { key };
NBTBase cellNBT = nbt.getTag(key);
TableCell nbtCell = TableDataSourceNBT.cell(cellNBT, delegate, navigator);
TableCellString keyCell = new TableCellString(null, key);
TableCellButton setKeyCell = new TableCellButton(null, "setKey", "O", Collections.singletonList("Set Key"), false);
setKeyCell.addAction(() -> {
sortedKeys.set(index, nextKey[0]);
// If there was a previous entry
sortedKeys.subList(index + 1, sortedKeys.size()).remove(nextKey[0]);
sortedKeys.subList(0, index).remove(nextKey[0]);
nbt.removeTag(key);
nbt.setTag(nextKey[0], cellNBT);
delegate.reloadData();
});
keyCell.addPropertyConsumer(value -> {
nextKey[0] = value;
setKeyCell.setEnabled(true);
});
TableCellButton deleteCell = new TableCellButton(null, null, TextFormatting.RED + "-");
deleteCell.addAction(() -> {
sortedKeys.remove(key);
nbt.removeTag(key);
delegate.reloadData();
});
TableCellMulti multi = new TableCellMulti(keyCell, setKeyCell, nbtCell, deleteCell);
multi.setSize(1, 0.2f);
multi.setSize(3, 0.2f);
return multi;
}
}
use of ivorius.reccomplex.gui.table.GuiTable in project RecurrentComplex by Ivorforce.
the class GuiScreenEditTable method setDataSource.
public GuiTable setDataSource(T dataSource, Consumer<T> saver) {
this.saver = saver;
GuiTable table = new GuiTable(this, this.t = dataSource);
setTable(table);
return table;
}
Aggregations