private bool DrawPopupContents(int windowId, object parameter)
{
ResourcePartMap clickedPart = (ResourcePartMap)parameter;
List <ResourcePartMap> parts = clickedPart.isSelected ?
EnumerateSelectedParts().ToList() : new List <ResourcePartMap>(1)
{
clickedPart
};
bool canPump = true, allHighlighted = true, guiChanged = false;
foreach (ResourcePartMap part in parts)
{
canPump &= part.resource.TransferMode == ResourceTransferMode.PUMP;
allHighlighted &= part.isHighlighted;
}
bool highlight = GUILayout.Toggle(allHighlighted, "Highlight", popupButtonStyle);
if (highlight != allHighlighted)
{
foreach (ResourcePartMap part in parts)
{
if (!highlight && part.isHighlighted && !part.isSelected)
{
part.part.SetHighlightDefault();
}
part.isHighlighted = highlight;
}
guiChanged = true;
}
if (controller.IsPrelaunch() && parts.Count == 1) // only allow editing when a single part is selected
{
newAmount = clickedPart.resource.Amount;
PopupWindow.Draw("Edit", windowPos, DrawEditPopupContents, popupButtonStyle, clickedPart);
}
if (canPump && isControllable)
{
TransferDirection direction = clickedPart.direction;
bool?toggleChange = null; // how a toggle was changed, if at all
foreach (ResourcePartMap part in parts)
{
if (part.direction != direction)
{
direction = TransferDirection.VARIOUS;
break;
}
}
DrawPopupToggle(TransferDirection.NONE, "Stop", ref direction, ref toggleChange);
DrawPopupToggle(TransferDirection.IN, "Transfer In", ref direction, ref toggleChange);
DrawPopupToggle(TransferDirection.OUT, "Transfer Out", ref direction, ref toggleChange);
DrawPopupToggle(TransferDirection.BALANCE, "Balance", ref direction, ref toggleChange);
if (settings.ShowDump)
{
DrawPopupToggle(TransferDirection.DUMP, "Dump", ref direction, ref toggleChange);
}
DrawPopupToggle(TransferDirection.LOCKED, "Lock", ref direction, ref toggleChange);
if (toggleChange.HasValue)
{
foreach (ResourcePartMap part in parts)
{
if (!toggleChange.Value) // if the user turned a direction off...
{
if (part.direction == direction)
{
if (direction == TransferDirection.LOCKED)
{
part.resource.Locked = false;
}
part.direction = TransferDirection.NONE;
}
}
else if (part.direction != direction)
{
if (direction == TransferDirection.LOCKED)
{
part.resource.Locked = true;
}
part.direction = direction;
}
}
guiChanged = true;
}
}
return(guiChanged);
}