Search in sources :

Example 6 with Pane

use of com.ldtteam.blockout.Pane in project Structurize by ldtteam.

the class ScrollingGroup method adjustChild.

@Override
public void adjustChild(final Pane child) {
    int childY = 0;
    if (children.size() >= 2) {
        final Pane lastChild = children.get(children.size() - 2);
        childY = lastChild.getY() + lastChild.getHeight();
    }
    child.setPosition(0, childY);
    child.setSize(getInteriorWidth(), child.getHeight());
}
Also used : Pane(com.ldtteam.blockout.Pane)

Example 7 with Pane

use of com.ldtteam.blockout.Pane in project Structurize by ldtteam.

the class ScrollingListContainer method refreshElementPanes.

/**
 * Creates, deletes, and updates existing Panes for elements in the list based on the DataProvider.
 *
 * @param dataProvider   data provider object, shouldn't be null.
 * @param listNodeParams the xml parameters for this pane.
 */
public void refreshElementPanes(final ScrollingList.DataProvider dataProvider, final PaneParams listNodeParams, final int height) {
    final int numElements = (dataProvider != null) ? dataProvider.getElementCount() : 0;
    if (dataProvider != null) {
        for (int i = 0; i < numElements; ++i) {
            final Pane child;
            if (listElementHeight * i + listElementHeight >= scrollY && listElementHeight * i <= scrollY + height) {
                if (i < children.size()) {
                    child = children.get(i);
                } else {
                    child = Loader.createFromPaneParams(listNodeParams, this);
                    if (child == null) {
                        continue;
                    }
                    if (i == 0) {
                        listElementHeight = child.getHeight();
                    }
                }
                child.setPosition(0, i * listElementHeight);
                dataProvider.updateElement(i, child);
            }
        }
    }
    while (children.size() > numElements) {
        removeChild(children.get(numElements));
    }
    setContentHeight(numElements * listElementHeight);
}
Also used : Pane(com.ldtteam.blockout.Pane)

Example 8 with Pane

use of com.ldtteam.blockout.Pane in project Structurize by ldtteam.

the class Group method removeChild.

@Override
public void removeChild(@NotNull final Pane child) {
    super.removeChild(child);
    final int formerChildY = child.getY();
    final int formerChildHeight = child.getHeight();
    for (@NotNull final Pane c : children) {
        if (c.getY() > formerChildY) {
            c.moveBy(0, -formerChildHeight);
        }
    }
}
Also used : NotNull(org.jetbrains.annotations.NotNull) Pane(com.ldtteam.blockout.Pane)

Example 9 with Pane

use of com.ldtteam.blockout.Pane in project Structurize by ldtteam.

the class Group method adjustChild.

@Override
public void adjustChild(@NotNull final Pane child) {
    int childX = child.getX();
    int childY = spacing;
    int childWidth = child.getWidth();
    final int childHeight = child.getHeight();
    // Adjust for horizontal size and alignment
    if (childWidth < 0) {
        childWidth = getInteriorWidth();
    } else if (child.getAlignment().isRightAligned()) {
        childX = (getInteriorWidth() - childWidth) - childX;
    } else if (child.getAlignment().isHorizontalCentered()) {
        childX = ((getInteriorWidth() - childWidth) / 2) + childX;
    }
    for (@NotNull final Pane c : children) {
        if (c == child) {
            break;
        }
        childY = c.getY() + c.getHeight() + spacing;
    }
    child.setSize(childWidth, childHeight);
    child.setPosition(childX, childY);
}
Also used : NotNull(org.jetbrains.annotations.NotNull) Pane(com.ldtteam.blockout.Pane)

Example 10 with Pane

use of com.ldtteam.blockout.Pane in project minecolonies by ldtteam.

the class WindowPostBox method requestClicked.

/**
 * Action executed when request is clicked.
 *
 * @param button the clicked button.
 */
private void requestClicked(final Button button) {
    final int row = stackList.getListElementIndexByPane(button);
    final ItemStack stack = allItems.get(row);
    int qty = stack.getMaxStackSize();
    for (final Pane child : button.getParent().getChildren()) {
        if (child.getID().equals(INPUT_QTY)) {
            try {
                qty = Integer.parseInt(((TextField) child).getText());
            } catch (final NumberFormatException ex) {
            // Be quiet about it.
            }
        }
    }
    Network.getNetwork().sendToServer(new PostBoxRequestMessage(buildingView, stack.copy(), qty, deliverAvailable));
}
Also used : PostBoxRequestMessage(com.minecolonies.coremod.network.messages.server.colony.building.postbox.PostBoxRequestMessage) TextField(com.ldtteam.blockout.controls.TextField) ItemStack(net.minecraft.item.ItemStack) Pane(com.ldtteam.blockout.Pane)

Aggregations

Pane (com.ldtteam.blockout.Pane)64 ScrollingList (com.ldtteam.blockout.views.ScrollingList)40 Text (com.ldtteam.blockout.controls.Text)26 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)25 ICitizenDataView (com.minecolonies.api.colony.ICitizenDataView)20 ItemStack (net.minecraft.item.ItemStack)13 Button (com.ldtteam.blockout.controls.Button)10 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)10 NotNull (org.jetbrains.annotations.NotNull)9 WorkerBuildingModuleView (com.minecolonies.coremod.colony.buildings.moduleviews.WorkerBuildingModuleView)8 ArrayList (java.util.ArrayList)8 ItemStorage (com.minecolonies.api.crafting.ItemStorage)6 Tuple (com.minecolonies.api.util.Tuple)6 BlockPos (net.minecraft.util.math.BlockPos)6 List (java.util.List)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Skill (com.minecolonies.api.entity.citizen.Skill)4 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)4 MarkBuildingDirtyMessage (com.minecolonies.coremod.network.messages.server.colony.building.MarkBuildingDirtyMessage)4 TileEntity (net.minecraft.tileentity.TileEntity)4