Search in sources :

Example 1 with ClientSchematicLoader

use of com.simibubi.create.content.schematics.ClientSchematicLoader in project Create by Creators-of-Create.

the class SchematicTableScreen method init.

@Override
protected void init() {
    setWindowSize(background.width, background.height + 4 + AllGuiTextures.PLAYER_INVENTORY.height);
    setWindowOffset(-11, 8);
    super.init();
    CreateClient.SCHEMATIC_SENDER.refresh();
    List<Component> availableSchematics = CreateClient.SCHEMATIC_SENDER.getAvailableSchematics();
    int x = leftPos;
    int y = topPos;
    schematicsLabel = new Label(x + 49, y + 26, TextComponent.EMPTY).withShadow();
    schematicsLabel.text = TextComponent.EMPTY;
    if (!availableSchematics.isEmpty()) {
        schematicsArea = new SelectionScrollInput(x + 45, y + 21, 139, 18).forOptions(availableSchematics).titled(availableSchematicsTitle.plainCopy()).writingTo(schematicsLabel);
        addRenderableWidget(schematicsArea);
        addRenderableWidget(schematicsLabel);
    }
    confirmButton = new IconButton(x + 44, y + 56, AllIcons.I_CONFIRM);
    confirmButton.withCallback(() -> {
        if (menu.canWrite() && schematicsArea != null) {
            ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
            lastChasingProgress = chasingProgress = progress = 0;
            List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
            Component schematic = availableSchematics1.get(schematicsArea.getState());
            schematicSender.startNewUpload(schematic.getContents());
        }
    });
    folderButton = new IconButton(x + 21, y + 21, AllIcons.I_OPEN_FOLDER);
    folderButton.withCallback(() -> {
        Util.getPlatform().openFile(Paths.get("schematics/").toFile());
    });
    folderButton.setToolTip(folder);
    refreshButton = new IconButton(x + 207, y + 21, AllIcons.I_REFRESH);
    refreshButton.withCallback(() -> {
        ClientSchematicLoader schematicSender = CreateClient.SCHEMATIC_SENDER;
        schematicSender.refresh();
        List<Component> availableSchematics1 = schematicSender.getAvailableSchematics();
        removeWidget(schematicsArea);
        if (!availableSchematics1.isEmpty()) {
            schematicsArea = new SelectionScrollInput(leftPos + 45, topPos + 21, 139, 18).forOptions(availableSchematics1).titled(availableSchematicsTitle.plainCopy()).writingTo(schematicsLabel);
            schematicsArea.onChanged();
            addRenderableWidget(schematicsArea);
        } else {
            schematicsArea = null;
            schematicsLabel.text = TextComponent.EMPTY;
        }
    });
    refreshButton.setToolTip(refresh);
    addRenderableWidget(confirmButton);
    addRenderableWidget(folderButton);
    addRenderableWidget(refreshButton);
    extraAreas = ImmutableList.of(new Rect2i(x + background.width, y + background.height - 40, 48, 48), new Rect2i(refreshButton.x, refreshButton.y, refreshButton.getWidth(), refreshButton.getHeight()));
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IconButton(com.simibubi.create.foundation.gui.widget.IconButton) ClientSchematicLoader(com.simibubi.create.content.schematics.ClientSchematicLoader) Label(com.simibubi.create.foundation.gui.widget.Label) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) SelectionScrollInput(com.simibubi.create.foundation.gui.widget.SelectionScrollInput)

Aggregations

ClientSchematicLoader (com.simibubi.create.content.schematics.ClientSchematicLoader)1 IconButton (com.simibubi.create.foundation.gui.widget.IconButton)1 Label (com.simibubi.create.foundation.gui.widget.Label)1 SelectionScrollInput (com.simibubi.create.foundation.gui.widget.SelectionScrollInput)1 Rect2i (net.minecraft.client.renderer.Rect2i)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1