Search in sources :

Example 1 with GuiTable

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);
}
Also used : TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) TableDataSourceSupplied(ivorius.reccomplex.gui.table.datasource.TableDataSourceSupplied) TableCell(ivorius.reccomplex.gui.table.cell.TableCell) WeightedItemCollectionRegistry(ivorius.reccomplex.world.storage.loot.WeightedItemCollectionRegistry) GuiTable(ivorius.reccomplex.gui.table.GuiTable) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) RCGuiHandler(ivorius.reccomplex.gui.RCGuiHandler) GenericItemCollection(ivorius.reccomplex.world.storage.loot.GenericItemCollection) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) GuiValidityStateIndicator(ivorius.reccomplex.gui.GuiValidityStateIndicator) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TableElementSaveDirectory(ivorius.reccomplex.gui.TableElementSaveDirectory) TableCellMultiBuilder(ivorius.reccomplex.gui.table.cell.TableCellMultiBuilder) TableCellString(ivorius.reccomplex.gui.table.cell.TableCellString) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) GenericItemCollectionRegistry(ivorius.reccomplex.world.storage.loot.GenericItemCollectionRegistry) TableDataSourceExpression(ivorius.reccomplex.gui.TableDataSourceExpression) Nonnull(javax.annotation.Nonnull) TableCellString(ivorius.reccomplex.gui.table.cell.TableCellString)

Example 2 with GuiTable

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);
}
Also used : TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) TableDataSourceMazePathList(ivorius.reccomplex.gui.worldscripts.mazegenerator.TableDataSourceMazePathList) TableCellTitle(ivorius.reccomplex.gui.table.cell.TableCellTitle) TableCell(ivorius.reccomplex.gui.table.cell.TableCell) ivorius.reccomplex.world.gen.feature.structure.generic.maze(ivorius.reccomplex.world.gen.feature.structure.generic.maze) GuiTable(ivorius.reccomplex.gui.table.GuiTable) TableCellBoolean(ivorius.reccomplex.gui.table.cell.TableCellBoolean) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) TextFormatting(net.minecraft.util.text.TextFormatting) Set(java.util.Set) TableDataSourcePreloaded(ivorius.reccomplex.gui.table.datasource.TableDataSourcePreloaded) Selection(ivorius.reccomplex.world.gen.feature.structure.generic.Selection) Collectors(java.util.stream.Collectors) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) TitledCell(ivorius.reccomplex.gui.table.cell.TitledCell) List(java.util.List) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) MazeRuleConnectAll(ivorius.reccomplex.world.gen.feature.structure.generic.maze.rules.saved.MazeRuleConnectAll) Nonnull(javax.annotation.Nonnull) Collections(java.util.Collections) TableCellBoolean(ivorius.reccomplex.gui.table.cell.TableCellBoolean) Set(java.util.Set) TableCellTitle(ivorius.reccomplex.gui.table.cell.TableCellTitle) TableDataSourceMazePathList(ivorius.reccomplex.gui.worldscripts.mazegenerator.TableDataSourceMazePathList) List(java.util.List)

Example 3 with GuiTable

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;
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IntStream(java.util.stream.IntStream) WeightedBlockState(ivorius.reccomplex.world.gen.feature.structure.generic.WeightedBlockState) GuiTable(ivorius.reccomplex.gui.table.GuiTable) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) NBTBase(net.minecraft.nbt.NBTBase) TextFormatting(net.minecraft.util.text.TextFormatting) ivorius.reccomplex.gui.table.cell(ivorius.reccomplex.gui.table.cell) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) List(java.util.List) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) Nonnull(javax.annotation.Nonnull) Collections(java.util.Collections) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 4 with GuiTable

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;
}
Also used : GuiTable(ivorius.reccomplex.gui.table.GuiTable)

Aggregations

GuiTable (ivorius.reccomplex.gui.table.GuiTable)4 TableDelegate (ivorius.reccomplex.gui.table.TableDelegate)3 TableNavigator (ivorius.reccomplex.gui.table.TableNavigator)3 TableDataSourceSegmented (ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented)3 Nonnull (javax.annotation.Nonnull)3 IvTranslations (ivorius.ivtoolkit.tools.IvTranslations)2 TableCell (ivorius.reccomplex.gui.table.cell.TableCell)2 TitledCell (ivorius.reccomplex.gui.table.cell.TitledCell)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 TextFormatting (net.minecraft.util.text.TextFormatting)2 RecurrentComplex (ivorius.reccomplex.RecurrentComplex)1 GuiValidityStateIndicator (ivorius.reccomplex.gui.GuiValidityStateIndicator)1 RCGuiHandler (ivorius.reccomplex.gui.RCGuiHandler)1 TableDataSourceExpression (ivorius.reccomplex.gui.TableDataSourceExpression)1 TableElementSaveDirectory (ivorius.reccomplex.gui.TableElementSaveDirectory)1 ivorius.reccomplex.gui.table.cell (ivorius.reccomplex.gui.table.cell)1 TableCellBoolean (ivorius.reccomplex.gui.table.cell.TableCellBoolean)1 TableCellMultiBuilder (ivorius.reccomplex.gui.table.cell.TableCellMultiBuilder)1