private IMaterialDistributionSettings currentDistributionSettingsProvider(IGraphicsGrid grid, ShortPoint2D position) { if (currentTab != null) { if (grid.getPlayerIdAt(position.x, position.y) >= 0) { return grid.getPartitionData(position.x, position.y).getPartitionSettings().getDistributionSettings(currentTab.materialButton.getMaterial()); } } return null; }
private void updatePositions() { IPartitionData data = getPartitonData(); if (data == null) { setOrder(null); removeAll(); } else { EMaterialType[] newOrder = new EMaterialType[EMaterialType.DROPPABLE_MATERIALS.length]; BitSet materialsAccepted = new BitSet(); for (int i = 0; i < newOrder.length; i++) { // FIXME: Synchronize! newOrder[i] = data.getPartitionSettings().getMaterialTypeForPriority(i); } IStockSettings stockSettings = data.getPartitionSettings().getStockSettings(); for (EMaterialType materialType : EMaterialType.DROPPABLE_MATERIALS) { materialsAccepted.set(materialType.ordinal, stockSettings.isAccepted(materialType)); } setOrder(newOrder); for (EMaterialType material : newOrder) { SelectionManagedMaterialButton button = buttons[material.ordinal]; AnimatablePosition position = positions[material.ordinal]; button.setDotColor(getColor(materialsAccepted, button)); removeChild(button); addChild(button, position.getX(), position.getY(), position.getX() + BUTTON_WIDTH, position.getY() + BUTTON_HEIGHT); } } }