Unstable 0.17.3.0

This commit is contained in:
Juan Pablo Arce
2022-03-22 14:44:12 -03:00
parent cefac171f5
commit 4206f6db42
100 changed files with 1380 additions and 655 deletions
@@ -89,23 +89,22 @@ namespace Barotrauma.Steam
return (fileCount, byteCount);
}
private void DeselectPublishedItem()
{
var deselectCarrier = selfModsList.Parent.FindChild(c => c.UserData is ActionCarrier { Id: var id } && id == "deselect");
Action? deselectAction = deselectCarrier.UserData is ActionCarrier { Action: var action }
? action
: null;
deselectAction?.Invoke();
SelectTab(Tab.Publish);
}
private void PopulatePublishTab(ItemOrPackage itemOrPackage, GUIFrame parentFrame)
{
ContentPackageManager.LocalPackages.Refresh();
ContentPackageManager.WorkshopPackages.Refresh();
var deselectCarrier = selfModsList.Parent.FindChild(c => c.UserData is ActionCarrier { Id: var id } && id == "deselect");
Action? deselectAction = deselectCarrier.UserData is ActionCarrier { Action: var action }
? action
: null;
void deselectItem()
{
deselectAction?.Invoke();
SelectTab(Tab.Publish);
}
parentFrame.ClearChildren();
GUILayoutGroup mainLayout = new GUILayoutGroup(new RectTransform(Vector2.One, parentFrame.RectTransform),
childAnchor: Anchor.TopCenter);
@@ -146,7 +145,7 @@ namespace Barotrauma.Steam
{
OnClicked = (button, o) =>
{
deselectItem();
DeselectPublishedItem();
return false;
}
};
@@ -334,7 +333,7 @@ namespace Barotrauma.Steam
t =>
{
confirmDeletion.Close();
deselectItem();
DeselectPublishedItem();
});
return false;
};
@@ -364,24 +363,10 @@ namespace Barotrauma.Steam
return false;
};
var coroutineEval = subcoroutine(messageBox.Text, messageBox);
var coroutineEval = subcoroutine(messageBox.Text, messageBox).GetEnumerator();
while (true)
{
bool moveNext = true;
try
{
moveNext = coroutineEval.GetEnumerator().MoveNext();
}
catch (Exception e)
{
DebugConsole.ThrowError($"{e.Message} {e.StackTrace.CleanupStackTrace()}");
messageBox.Close();
}
if (!moveNext)
{
messageBox.Close();
}
var status = coroutineEval.GetEnumerator().Current;
var status = coroutineEval.Current;
if (messageBox.Closed)
{
yield return CoroutineStatus.Success;
@@ -397,6 +382,20 @@ namespace Barotrauma.Steam
{
yield return status;
}
bool moveNext = true;
try
{
moveNext = coroutineEval.MoveNext();
}
catch (Exception e)
{
DebugConsole.ThrowError($"{e.Message} {e.StackTrace.CleanupStackTrace()}");
messageBox.Close();
}
if (!moveNext)
{
messageBox.Close();
}
}
}
@@ -408,26 +407,9 @@ namespace Barotrauma.Steam
{
if (!SteamManager.Workshop.CanBeInstalled(workshopItem))
{
//Must download!
while (!SteamManager.Workshop.CanBeInstalled(workshopItem))
{
bool shouldForceInstall = workshopItem.IsInstalled
&& Directory.Exists(workshopItem.Directory)
&& !SteamManager.Workshop.IsItemDirectoryUpToDate(workshopItem);
shouldForceInstall |= workshopItem is
{ IsDownloading: false, IsDownloadPending: false, IsInstalled: false };
if (shouldForceInstall)
{
SteamManager.Workshop.ForceRedownload(workshopItem);
}
currentStepText.Text = TextManager.GetWithVariable("PublishPopupDownload", "[percentage]", Percentage(workshopItem.DownloadAmount));
yield return new WaitForSeconds(0.5f);
}
}
else
{
SteamManager.Workshop.DownloadModThenEnqueueInstall(workshopItem);
SteamManager.Workshop.NukeDownload(workshopItem);
}
SteamManager.Workshop.DownloadModThenEnqueueInstall(workshopItem);
TaskPool.Add($"Install {workshopItem.Title}",
SteamManager.Workshop.WaitForInstall(workshopItem),
(t) =>
@@ -436,7 +418,9 @@ namespace Barotrauma.Steam
});
while (!ContentPackageManager.WorkshopPackages.Any(p => p.SteamWorkshopId == workshopItem.Id))
{
currentStepText.Text = TextManager.Get("PublishPopupInstall");
currentStepText.Text = SteamManager.Workshop.CanBeInstalled(workshopItem)
? TextManager.Get("PublishPopupInstall")
: TextManager.GetWithVariable("PublishPopupDownload", "[percentage]", Percentage(workshopItem.DownloadAmount));
yield return new WaitForSeconds(0.5f);
}
@@ -457,7 +441,6 @@ namespace Barotrauma.Steam
currentStepText.Text = TextManager.Get("PublishPopupCreateLocal");
yield return new WaitForSeconds(0.5f);
}
PopulatePublishTab(workshopItem, parentFrame);
yield return CoroutineStatus.Success;
@@ -500,7 +483,10 @@ namespace Barotrauma.Steam
editor.SubmitAsync(),
t =>
{
t.TryGetResult(out result);
if (t.TryGetResult(out Steamworks.Ugc.PublishResult publishResult))
{
result = publishResult;
}
resultException = t.Exception?.GetInnermost();
});
currentStepText.Text = TextManager.Get("PublishPopupSubmit");
@@ -523,6 +509,14 @@ namespace Barotrauma.Steam
$"exception was {downloadTask.Exception?.GetInnermost()?.ToString().CleanupStackTrace() ?? "[NULL]"}");
}
ContentPackage? pkgToNuke
= ContentPackageManager.WorkshopPackages.FirstOrDefault(p => p.SteamWorkshopId == resultId);
if (pkgToNuke != null)
{
Directory.Delete(pkgToNuke.Dir, recursive: true);
ContentPackageManager.WorkshopPackages.Refresh();
}
bool installed = false;
TaskPool.Add(
"InstallNewlyPublished",
@@ -541,9 +535,11 @@ namespace Barotrauma.Steam
{
SteamWorkshopId = resultId
};
localModProject.DiscardHashAndInstallTime();
localModProject.Save(localPackage.Path);
ContentPackageManager.ReloadContentPackage(localPackage);
ContentPackageManager.WorkshopPackages.Refresh();
DeselectPublishedItem();
if (result.Value.NeedsWorkshopAgreement)
{
@@ -207,6 +207,11 @@ namespace Barotrauma.Steam
}
string newPath = $"{ContentPackage.LocalModsDir}/{sanitizedName}";
if (File.Exists(newPath) || Directory.Exists(newPath))
{
newPath += $"_{contentPackage.SteamWorkshopId}";
}
if (File.Exists(newPath) || Directory.Exists(newPath))
{
throw new Exception($"{newPath} already exists");