Search in sources :

Example 1 with WorkOrderChangeMessage

use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.

the class WindowWorkOrderPage method updatePriority.

/**
 * On Button click update the priority.
 *
 * @param button the clicked button.
 */
private void updatePriority(@NotNull final Button button) {
    final int id = Integer.parseInt(button.getParent().findPaneOfTypeByID("hiddenId", Text.class).getTextAsString());
    final String buttonLabel = button.getID();
    for (int i = 0; i < workOrders.size(); i++) {
        final IWorkOrderView workOrder = workOrders.get(i);
        if (workOrder.getId() == id) {
            if (buttonLabel.equals(BUTTON_UP) && i > 0) {
                workOrder.setPriority(workOrders.get(i - 1).getPriority() + 1);
                Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
            } else if (buttonLabel.equals(BUTTON_DOWN) && i <= workOrders.size()) {
                workOrder.setPriority(workOrders.get(i + 1).getPriority() - 1);
                Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
            }
            sortWorkOrders();
            window.findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class).refreshElementPanes();
            return;
        }
    }
}
Also used : IWorkOrderView(com.minecolonies.api.colony.workorders.IWorkOrderView) ScrollingList(com.ldtteam.blockout.views.ScrollingList) WorkOrderChangeMessage(com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage)

Example 2 with WorkOrderChangeMessage

use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.

the class WorkOrderModuleWindow method selectWorkOrder.

/**
 * On click select the clicked work order.
 *
 * @param button the clicked button.
 */
private void selectWorkOrder(@NotNull final Button button) {
    final int row = workOrdersList.getListElementIndexByPane(button);
    final IWorkOrderView view = workOrders.get(row);
    if (view.getClaimedBy().equals(buildingView.getPosition())) {
        view.setClaimedBy(buildingView.getPosition());
        Network.getNetwork().sendToServer(new WorkOrderChangeMessage(buildingView, view.getId(), true, 0));
    } else {
        Network.getNetwork().sendToServer(new BuilderSelectWorkOrderMessage(buildingView, view.getId()));
    }
}
Also used : BuilderSelectWorkOrderMessage(com.minecolonies.coremod.network.messages.server.colony.building.builder.BuilderSelectWorkOrderMessage) IWorkOrderView(com.minecolonies.api.colony.workorders.IWorkOrderView) WorkOrderChangeMessage(com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage)

Example 3 with WorkOrderChangeMessage

use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.

the class WindowWorkOrderPage method deleteWorkOrder.

/**
 * On Button click remove the workOrder.
 *
 * @param button the clicked button.
 */
private void deleteWorkOrder(@NotNull final Button button) {
    final int id = Integer.parseInt(button.getParent().findPaneOfTypeByID("hiddenId", Text.class).getTextAsString());
    for (int i = 0; i < workOrders.size(); i++) {
        if (workOrders.get(i).getId() == id) {
            workOrders.remove(i);
            break;
        }
    }
    Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, true, 0));
    window.findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class).refreshElementPanes();
}
Also used : ScrollingList(com.ldtteam.blockout.views.ScrollingList) WorkOrderChangeMessage(com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage)

Example 4 with WorkOrderChangeMessage

use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by ldtteam.

the class WorkOrderModuleWindow method selectWorkOrder.

/**
 * On click select the clicked work order.
 *
 * @param button the clicked button.
 */
private void selectWorkOrder(@NotNull final Button button) {
    final int row = workOrdersList.getListElementIndexByPane(button);
    final WorkOrderView view = workOrders.get(row);
    if (view.getClaimedBy().equals(buildingView.getPosition())) {
        view.setClaimedBy(buildingView.getPosition());
        Network.getNetwork().sendToServer(new WorkOrderChangeMessage(buildingView, view.getId(), true, 0));
    } else {
        Network.getNetwork().sendToServer(new BuilderSelectWorkOrderMessage(buildingView, view.getId()));
    }
}
Also used : WorkOrderView(com.minecolonies.api.colony.workorders.WorkOrderView) BuilderSelectWorkOrderMessage(com.minecolonies.coremod.network.messages.server.colony.building.builder.BuilderSelectWorkOrderMessage) WorkOrderChangeMessage(com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage)

Aggregations

WorkOrderChangeMessage (com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage)4 ScrollingList (com.ldtteam.blockout.views.ScrollingList)2 IWorkOrderView (com.minecolonies.api.colony.workorders.IWorkOrderView)2 BuilderSelectWorkOrderMessage (com.minecolonies.coremod.network.messages.server.colony.building.builder.BuilderSelectWorkOrderMessage)2 WorkOrderView (com.minecolonies.api.colony.workorders.WorkOrderView)1