Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change functionality of cancel route to reduce route #1568

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions Source/WOLF/WOLF/GUI/WOLF_GuiManageTransfers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,38 @@ protected override void DrawWindowContents(int windowId)
GUILayout.BeginHorizontal();
if (GUILayout.Button(UIHelper.deleteSymbol, UIHelper.buttonStyle, GUILayout.Width(22), GUILayout.Height(22)))
{
var result = _selectedRoute.RemoveResource(resource.Key, resource.Value);
if (result is BrokenNegotiationResult)
var amount = resource.Value;
foreach (var destinationResource in _selectedRoute.DestinationDepot.GetResources())
{
foreach (var brokenResource in (result as BrokenNegotiationResult).BrokenDependencies)
if (destinationResource.ResourceName == resource.Key)
{
Messenger.DisplayMessage(string.Format(CANNOT_CANCEL_TRANSFER_MESSAGE, brokenResource));
if (destinationResource.Incoming - destinationResource.Outgoing < amount)
{
amount = destinationResource.Incoming - destinationResource.Outgoing;
}
break;
}
}
else if (result is FailedNegotiationResult)
if (amount <= 0)
{
foreach (var missingResource in (result as FailedNegotiationResult).MissingResources)
Messenger.DisplayMessage(string.Format(CANNOT_CANCEL_TRANSFER_MESSAGE, resource.Key));
}
else
{
var result = _selectedRoute.RemoveResource(resource.Key, amount);
if (result is BrokenNegotiationResult)
{
foreach (var brokenResource in (result as BrokenNegotiationResult).BrokenDependencies)
{
Messenger.DisplayMessage(string.Format(CANNOT_CANCEL_TRANSFER_MESSAGE, brokenResource));
}
}
else if (result is FailedNegotiationResult)
{
Messenger.DisplayMessage(string.Format("Could not add {0} back to origin depot. This is probably a bug.", missingResource.Key));
foreach (var missingResource in (result as FailedNegotiationResult).MissingResources)
{
Messenger.DisplayMessage(string.Format("Could not add {0} back to origin depot. This is probably a bug.", missingResource.Key));
}
}
}
}
Expand Down