Unstable 0.17.3.0
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class CameraTransition
|
||||
{
|
||||
public bool Running
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Camera AssignedCamera;
|
||||
private readonly Alignment? cameraStartPos;
|
||||
private readonly Alignment? cameraEndPos;
|
||||
private readonly float? startZoom;
|
||||
private readonly float? endZoom;
|
||||
|
||||
public readonly float WaitDuration;
|
||||
public readonly float PanDuration;
|
||||
public readonly bool FadeOut;
|
||||
public readonly bool LosFadeIn;
|
||||
|
||||
private readonly CoroutineHandle updateCoroutine;
|
||||
|
||||
private Character prevControlled;
|
||||
|
||||
public bool AllowInterrupt = false;
|
||||
public bool RemoveControlFromCharacter = true;
|
||||
|
||||
public CameraTransition(ISpatialEntity targetEntity, Camera cam, Alignment? cameraStartPos, Alignment? cameraEndPos, bool fadeOut = true, bool losFadeIn = false, float waitDuration = 0f, float panDuration = 10.0f, float? startZoom = null, float? endZoom = null)
|
||||
{
|
||||
WaitDuration = waitDuration;
|
||||
PanDuration = panDuration;
|
||||
FadeOut = fadeOut;
|
||||
LosFadeIn = losFadeIn;
|
||||
this.cameraStartPos = cameraStartPos;
|
||||
this.cameraEndPos = cameraEndPos;
|
||||
this.startZoom = startZoom;
|
||||
this.endZoom = endZoom;
|
||||
AssignedCamera = cam;
|
||||
|
||||
if (targetEntity == null) { return; }
|
||||
|
||||
Running = true;
|
||||
CoroutineManager.StopCoroutines("CameraTransition");
|
||||
updateCoroutine = CoroutineManager.StartCoroutine(Update(targetEntity, cam), "CameraTransition");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
CoroutineManager.StopCoroutines(updateCoroutine);
|
||||
Running = false;
|
||||
#if CLIENT
|
||||
if (FadeOut) { GUI.ScreenOverlayColor = Color.TransparentBlack; }
|
||||
if (prevControlled != null && !prevControlled.Removed)
|
||||
{
|
||||
Character.Controlled = prevControlled;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private IEnumerable<CoroutineStatus> Update(ISpatialEntity targetEntity, Camera cam)
|
||||
{
|
||||
if (targetEntity == null || (targetEntity is Entity e && e.Removed)) { yield return CoroutineStatus.Success; }
|
||||
|
||||
prevControlled = Character.Controlled;
|
||||
if (RemoveControlFromCharacter)
|
||||
{
|
||||
#if CLIENT
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
#endif
|
||||
Character.Controlled = null;
|
||||
}
|
||||
cam.TargetPos = Vector2.Zero;
|
||||
|
||||
float startZoom = this.startZoom ?? cam.Zoom;
|
||||
float endZoom = this.endZoom ?? 0.5f;
|
||||
Vector2 initialCameraPos = cam.Position;
|
||||
Vector2? initialTargetPos = targetEntity?.WorldPosition;
|
||||
|
||||
float timer = -WaitDuration;
|
||||
|
||||
while (timer < PanDuration)
|
||||
{
|
||||
float clampedTimer = Math.Max(timer, 0f);
|
||||
|
||||
if (Screen.Selected != GameMain.GameScreen)
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
#if CLIENT
|
||||
if (FadeOut) { GUI.ScreenOverlayColor = Color.TransparentBlack; }
|
||||
#endif
|
||||
Running = false;
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
//switched control to some other character during the transition -> remove control again
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
prevControlled = Character.Controlled;
|
||||
if (RemoveControlFromCharacter)
|
||||
{
|
||||
#if CLIENT
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
#endif
|
||||
Character.Controlled = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevControlled != null && prevControlled.Removed)
|
||||
{
|
||||
prevControlled = null;
|
||||
}
|
||||
#if CLIENT
|
||||
if (AllowInterrupt && PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Escape))
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Vector2 minPos = targetEntity.WorldPosition;
|
||||
Vector2 maxPos = targetEntity.WorldPosition;
|
||||
if (targetEntity is Submarine sub)
|
||||
{
|
||||
minPos = new Vector2(sub.WorldPosition.X - sub.Borders.Width / 2, sub.WorldPosition.Y - sub.Borders.Height / 2);
|
||||
maxPos = new Vector2(sub.WorldPosition.X + sub.Borders.Width / 2, sub.WorldPosition.Y + sub.Borders.Height / 2);
|
||||
}
|
||||
|
||||
Vector2 startPos = cameraStartPos.HasValue ?
|
||||
new Vector2(
|
||||
MathHelper.Lerp(minPos.X, maxPos.X, (cameraStartPos.Value.ToVector2().X + 1.0f) / 2.0f),
|
||||
MathHelper.Lerp(maxPos.Y, minPos.Y, (cameraStartPos.Value.ToVector2().Y + 1.0f) / 2.0f)) :
|
||||
initialCameraPos;
|
||||
if (!cameraStartPos.HasValue && initialTargetPos.HasValue)
|
||||
{
|
||||
startPos += targetEntity.WorldPosition - initialTargetPos.Value;
|
||||
}
|
||||
Vector2 endPos = cameraEndPos.HasValue ?
|
||||
new Vector2(
|
||||
MathHelper.Lerp(minPos.X, maxPos.X, (cameraEndPos.Value.ToVector2().X + 1.0f) / 2.0f),
|
||||
MathHelper.Lerp(maxPos.Y, minPos.Y, (cameraEndPos.Value.ToVector2().Y + 1.0f) / 2.0f)) :
|
||||
prevControlled?.WorldPosition ?? targetEntity.WorldPosition;
|
||||
|
||||
Vector2 cameraPos = Vector2.SmoothStep(startPos, endPos, clampedTimer / PanDuration);
|
||||
cam.Translate(cameraPos - cam.Position);
|
||||
|
||||
#if CLIENT
|
||||
cam.Zoom = MathHelper.SmoothStep(startZoom, endZoom, clampedTimer / PanDuration);
|
||||
if (clampedTimer / PanDuration > 0.9f)
|
||||
{
|
||||
if (FadeOut) { GUI.ScreenOverlayColor = Color.Lerp(Color.TransparentBlack, Color.Black, ((clampedTimer / PanDuration) - 0.9f) * 10.0f); }
|
||||
}
|
||||
if (LosFadeIn && clampedTimer / PanDuration > 0.8f)
|
||||
{
|
||||
GameMain.LightManager.LosAlpha = ((clampedTimer / PanDuration) - 0.8f) * 5.0f;
|
||||
Lights.LightManager.ViewTarget = prevControlled ?? (targetEntity as Entity);
|
||||
GameMain.LightManager.LosEnabled = true;
|
||||
}
|
||||
#endif
|
||||
timer += CoroutineManager.UnscaledDeltaTime;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
Running = false;
|
||||
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
|
||||
#if CLIENT
|
||||
GUI.ScreenOverlayColor = Color.TransparentBlack;
|
||||
GameMain.LightManager.LosEnabled = true;
|
||||
GameMain.LightManager.LosAlpha = 1f;
|
||||
#endif
|
||||
|
||||
if (prevControlled != null && !prevControlled.Removed)
|
||||
{
|
||||
Character.Controlled = prevControlled;
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace Barotrauma
|
||||
targetPos.Y = -targetPos.Y;
|
||||
|
||||
GUI.DrawLine(spriteBatch, pos, targetPos, GUIStyle.Red * 0.5f, 0, 4);
|
||||
if (wallTarget != null)
|
||||
if (wallTarget != null && !IsCoolDownRunning)
|
||||
{
|
||||
Vector2 wallTargetPos = wallTarget.Position;
|
||||
if (wallTarget.Structure.Submarine != null) { wallTargetPos += wallTarget.Structure.Submarine.Position; }
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Barotrauma
|
||||
case TreatmentEventData _:
|
||||
msg.Write(AnimController.Anim == AnimController.Animation.CPR);
|
||||
break;
|
||||
case StatusEventData _:
|
||||
case CharacterStatusEventData _:
|
||||
//do nothing
|
||||
break;
|
||||
case UpdateTalentsEventData _:
|
||||
@@ -343,8 +343,12 @@ namespace Barotrauma
|
||||
if (controlled == this)
|
||||
{
|
||||
Controlled = null;
|
||||
IsRemotePlayer = ownerID > 0;
|
||||
}
|
||||
if (GameMain.Client?.Character == this)
|
||||
{
|
||||
GameMain.Client.Character = null;
|
||||
}
|
||||
IsRemotePlayer = ownerID > 0;
|
||||
}
|
||||
break;
|
||||
case EventType.Status:
|
||||
@@ -371,7 +375,9 @@ namespace Barotrauma
|
||||
if (attackLimbIndex == 255 || Removed) { break; }
|
||||
if (attackLimbIndex >= AnimController.Limbs.Length)
|
||||
{
|
||||
DebugConsole.ThrowError($"Received invalid {(eventType == EventType.SetAttackTarget ? "SetAttackTarget" : "ExecuteAttack")} message. Limb index out of bounds (character: {Name}, limb index: {attackLimbIndex}, limb count: {AnimController.Limbs.Length})");
|
||||
string errorMsg = $"Received invalid {(eventType == EventType.SetAttackTarget ? "SetAttackTarget" : "ExecuteAttack")} message. Limb index out of bounds (character: {Name}, limb index: {attackLimbIndex}, limb count: {AnimController.Limbs.Length})";
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Character.ClientEventRead:AttackLimbOutOfBounds", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
break;
|
||||
}
|
||||
Limb attackLimb = AnimController.Limbs[attackLimbIndex];
|
||||
@@ -380,13 +386,16 @@ namespace Barotrauma
|
||||
if (targetEntity == null && eventType == EventType.SetAttackTarget)
|
||||
{
|
||||
DebugConsole.ThrowError($"Received invalid SetAttackTarget message. Target entity not found (ID {targetEntityID})");
|
||||
GameAnalyticsManager.AddErrorEventOnce("Character.ClientEventRead:TargetNotFound", GameAnalyticsManager.ErrorSeverity.Error, "Received invalid SetAttackTarget message. Target entity not found.");
|
||||
break;
|
||||
}
|
||||
if (targetEntity is Character targetCharacter)
|
||||
if (targetEntity is Character targetCharacter && targetLimbIndex != 255)
|
||||
{
|
||||
if (targetLimbIndex >= targetCharacter.AnimController.Limbs.Length)
|
||||
{
|
||||
DebugConsole.ThrowError($"Received invalid {(eventType == EventType.SetAttackTarget ? "SetAttackTarget" : "ExecuteAttack")} message. Target limb index out of bounds (target character: {targetCharacter.Name}, limb index: {targetLimbIndex}, limb count: {targetCharacter.AnimController.Limbs.Length})");
|
||||
string errorMsgWithoutName = $"Received invalid {(eventType == EventType.SetAttackTarget ? "SetAttackTarget" : "ExecuteAttack")} message. Target limb index out of bounds (target character: {targetCharacter.SpeciesName}, limb index: {targetLimbIndex}, limb count: {targetCharacter.AnimController.Limbs.Length})";
|
||||
GameAnalyticsManager.AddErrorEventOnce("Character.ClientEventRead:TargetLimbOutOfBounds", GameAnalyticsManager.ErrorSeverity.Error, errorMsgWithoutName);
|
||||
break;
|
||||
}
|
||||
targetLimb = targetCharacter.AnimController.Limbs[targetLimbIndex];
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new Character.StatusEventData());
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new Character.CharacterStatusEventData());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+16
-8
@@ -12,22 +12,30 @@ namespace Barotrauma
|
||||
{
|
||||
public sealed partial class PackageSource : ICollection<ContentPackage>
|
||||
{
|
||||
public ContentPackage SaveAndEnableRegularMod(ModProject modProject)
|
||||
public string SaveRegularMod(ModProject modProject)
|
||||
{
|
||||
if (modProject.IsCore) { throw new ArgumentException("ModProject must not be a core package"); }
|
||||
|
||||
//save the content package
|
||||
|
||||
string fileListPath = Path.Combine(directory, ToolBox.RemoveInvalidFileNameChars(modProject.Name), ContentPackage.FileListFileName)
|
||||
.CleanUpPathCrossPlatform(correctFilenameCase: false);
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fileListPath)!);
|
||||
modProject.Save(fileListPath);
|
||||
Refresh(); EnabledPackages.DisableRemovedMods();
|
||||
var newPackage = Regular.First(p => p.Path == fileListPath);
|
||||
|
||||
//enable it
|
||||
EnabledPackages.EnableRegular(newPackage);
|
||||
return fileListPath;
|
||||
}
|
||||
|
||||
return newPackage;
|
||||
public RegularPackage GetRegularModByPath(string fileListPath)
|
||||
{
|
||||
return Regular.First(p => p.Path == fileListPath);
|
||||
}
|
||||
|
||||
public RegularPackage SaveAndEnableRegularMod(ModProject modProject)
|
||||
{
|
||||
string fileListPath = SaveRegularMod(modProject);
|
||||
var package = GetRegularModByPath(fileListPath);
|
||||
EnabledPackages.EnableRegular(package);
|
||||
|
||||
return package;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Barotrauma
|
||||
LoadFont();
|
||||
}
|
||||
|
||||
private void LoadFont()
|
||||
public void LoadFont()
|
||||
{
|
||||
string fontPath = GetFontFilePath(element);
|
||||
uint size = GetFontSize(element);
|
||||
|
||||
@@ -931,7 +931,7 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
private static void EnsureTextDoesntOverflow(string? text, GUITextBlock textBlock, Rectangle bounds, ImmutableArray<GUILayoutGroup>? layoutGroups = null)
|
||||
public static void EnsureTextDoesntOverflow(string? text, GUITextBlock textBlock, Rectangle bounds, ImmutableArray<GUILayoutGroup>? layoutGroups = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) { return; }
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace Barotrauma
|
||||
|
||||
public void AddToGUIUpdateList()
|
||||
{
|
||||
infoFrame?.AddToGUIUpdateList();
|
||||
infoFrame?.AddToGUIUpdateList(order: 1);
|
||||
NetLobbyScreen.JobInfoFrame?.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
@@ -379,8 +379,7 @@ namespace Barotrauma
|
||||
|
||||
private void CreateCrewListFrame(GUIFrame crewFrame)
|
||||
{
|
||||
// FIXME remove TestScreen stuff
|
||||
crew = GameMain.GameSession?.CrewManager?.GetCharacters() ?? new []{ TestScreen.dummyCharacter };
|
||||
crew = GameMain.GameSession?.CrewManager?.GetCharacters() ?? Array.Empty<Character>();
|
||||
teamIDs = crew.Select(c => c.TeamID).Distinct().ToList();
|
||||
|
||||
// Show own team first when there's more than one team
|
||||
@@ -817,7 +816,7 @@ namespace Barotrauma
|
||||
else if (client != null)
|
||||
{
|
||||
GUIComponent preview = CreateClientInfoFrame(background, client, GetPermissionIcon(client));
|
||||
if (GameMain.NetworkMember != null) { GameMain.Client.SelectCrewClient(client, preview); }
|
||||
GameMain.Client?.SelectCrewClient(client, preview);
|
||||
CreateWalletFrame(background, client.Character);
|
||||
}
|
||||
|
||||
@@ -850,17 +849,18 @@ namespace Barotrauma
|
||||
GUILayoutGroup middleLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.66f), walletLayout.RectTransform));
|
||||
GUILayoutGroup salaryTextLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), middleLayout.RectTransform), isHorizontal: true);
|
||||
GUITextBlock salaryTitle = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), salaryTextLayout.RectTransform), TextManager.Get("crewwallet.salary"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomLeft);
|
||||
GUITextBlock rewardBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), salaryTextLayout.RectTransform), TextManager.GetWithVariable("percentageformat", "[value]", GetSharePercentage()), textAlignment: Alignment.BottomRight);
|
||||
GUITextBlock rewardBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), salaryTextLayout.RectTransform), string.Empty, textAlignment: Alignment.BottomRight);
|
||||
GUILayoutGroup sliderLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.5f), middleLayout.RectTransform), isHorizontal: true, childAnchor: Anchor.Center);
|
||||
GUIScrollBar salarySlider = new GUIScrollBar(new RectTransform(new Vector2(0.9f, 1f), sliderLayout.RectTransform), style: "GUISlider", barSize: 0.03f)
|
||||
{
|
||||
Range = Vector2.UnitY,
|
||||
ToolTip = TextManager.Get("crewwallet.salary.tooltip"),
|
||||
Range = new Vector2(0, 1),
|
||||
BarScrollValue = targetWallet.RewardDistribution / 100f,
|
||||
Step = 0.01f,
|
||||
BarSize = 0.1f,
|
||||
OnMoved = (bar, scroll) =>
|
||||
{
|
||||
rewardBlock.Text = TextManager.GetWithVariable("percentageformat", "[value]", GetSharePercentage());
|
||||
SetRewardText((int)(scroll * 100), rewardBlock);
|
||||
return true;
|
||||
},
|
||||
OnReleased = (bar, scroll) =>
|
||||
@@ -871,6 +871,9 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
SetRewardText(targetWallet.RewardDistribution, rewardBlock);
|
||||
|
||||
// @formatter:off
|
||||
GUIScissorComponent scissorComponent = new GUIScissorComponent(new RectTransform(new Vector2(0.85f, 1.25f), walletFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter))
|
||||
{
|
||||
@@ -902,8 +905,11 @@ namespace Barotrauma
|
||||
GUIButton confirmButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1f), centerButtonLayout.RectTransform), TextManager.Get("confirm"), style: "GUIButtonFreeScale") { Enabled = false };
|
||||
GUIButton resetButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1f), centerButtonLayout.RectTransform), TextManager.Get("reset"), style: "GUIButtonFreeScale") { Enabled = false };
|
||||
// @formatter:on
|
||||
ImmutableArray<GUILayoutGroup> layoutGroups = ImmutableArray.Create(transferMenuLayout, paddedTransferMenuLayout, mainLayout, leftLayout, rightLayout);
|
||||
MedicalClinicUI.EnsureTextDoesntOverflow(character.Name, leftName, leftLayout.Rect, layoutGroups);
|
||||
transferMenuButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.2f), walletFrame.RectTransform, Anchor.BottomCenter, Pivot.TopCenter), style: "UIToggleButtonVertical")
|
||||
{
|
||||
ToolTip = TextManager.Get("crewwallet.transfer.tooltip"),
|
||||
OnClicked = (button, o) =>
|
||||
{
|
||||
isTransferMenuOpen = !isTransferMenuOpen;
|
||||
@@ -951,6 +957,8 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
|
||||
MedicalClinicUI.EnsureTextDoesntOverflow(rightName.Text.ToString(), rightName, rightLayout.Rect, layoutGroups);
|
||||
|
||||
if (!hasPermissions)
|
||||
{
|
||||
centerButton.Enabled = centerButton.CanBeFocused = false;
|
||||
@@ -1073,14 +1081,14 @@ namespace Barotrauma
|
||||
Receiver = to.Select(option => option.ID),
|
||||
Amount = amount
|
||||
};
|
||||
IWriteMessage msg = new WriteOnlyMessage().WithHeader(ClientPacketHeader.MONEY);
|
||||
IWriteMessage msg = new WriteOnlyMessage().WithHeader(ClientPacketHeader.TRANSFER_MONEY);
|
||||
transfer.Write(msg);
|
||||
GameMain.Client?.ClientPeer?.Send(msg, DeliveryMethod.Reliable);
|
||||
}
|
||||
|
||||
static void SetRewardDistribution(Character character, int newValue)
|
||||
{
|
||||
INetSerializableStruct transfer = new NetWalletSalaryUpdate
|
||||
INetSerializableStruct transfer = new NetWalletSetSalaryUpdate
|
||||
{
|
||||
Target = character.ID,
|
||||
NewRewardDistribution = newValue
|
||||
@@ -1090,7 +1098,23 @@ namespace Barotrauma
|
||||
GameMain.Client?.ClientPeer?.Send(msg, DeliveryMethod.Reliable);
|
||||
}
|
||||
|
||||
string GetSharePercentage() => Mission.GetRewardShare(targetWallet.RewardDistribution, salaryCrew, Option<int>.None()).Percentage.ToString();
|
||||
void SetRewardText(int value, GUITextBlock block)
|
||||
{
|
||||
var (_, percentage, sum) = Mission.GetRewardShare(value, salaryCrew, Option<int>.None());
|
||||
LocalizedString tooltip = string.Empty;
|
||||
block.TextColor = GUIStyle.TextColorNormal;
|
||||
|
||||
if (sum > 100)
|
||||
{
|
||||
tooltip = TextManager.GetWithVariables("crewwallet.salary.over100toolitp", ("[sum]", $"{(int)sum}"), ("[newvalue]", $"{percentage}"));
|
||||
block.TextColor = GUIStyle.Orange;
|
||||
}
|
||||
|
||||
LocalizedString text = TextManager.GetWithVariable("percentageformat", "[value]", $"{value}");
|
||||
|
||||
block.Text = text;
|
||||
block.ToolTip = RichString.Rich(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private GUIComponent CreateClientInfoFrame(GUIFrame frame, Client client, Sprite permissionIcon = null)
|
||||
|
||||
@@ -63,6 +63,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current personal wallet
|
||||
/// In singleplayer this is the campaign bank and in multiplayer this is the personal wallet
|
||||
/// </summary>
|
||||
public virtual Wallet Wallet => GetWallet();
|
||||
|
||||
public override void ShowStartMessage()
|
||||
|
||||
+1
-1
@@ -914,7 +914,7 @@ namespace Barotrauma
|
||||
WalletInfo info = transaction.Info;
|
||||
switch (transaction.CharacterID)
|
||||
{
|
||||
case Some<ushort> { Value: var charID}:
|
||||
case Some<ushort> { Value: var charID }:
|
||||
{
|
||||
Character targetCharacter = Character.CharacterList?.FirstOrDefault(c => c.ID == charID);
|
||||
if (targetCharacter is null) { break; }
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace Barotrauma
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), RichString.Rich(displayedMission.GetMissionRewardText(Submarine.MainSub)));
|
||||
if (GameMain.IsMultiplayer && Character.Controlled is { } controlled)
|
||||
{
|
||||
var (share, percentage) = Mission.GetRewardShare(controlled.Wallet.RewardDistribution, Mission.GetSalaryEligibleCrew(), Option<int>.Some(reward));
|
||||
var (share, percentage, _) = Mission.GetRewardShare(controlled.Wallet.RewardDistribution, Mission.GetSalaryEligibleCrew().Where(c => c != controlled), Option<int>.Some(reward));
|
||||
if (share > 0)
|
||||
{
|
||||
string shareFormatted = string.Format(CultureInfo.InvariantCulture, "{0:N0}", share);
|
||||
|
||||
@@ -966,7 +966,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (character.HeldItems.Any(i =>
|
||||
i.OwnInventory != null &&
|
||||
(i.OwnInventory.CanBePut(item) || (i.OwnInventory.Capacity == 1 && i.OwnInventory.AllowSwappingContainedItems && i.OwnInventory.Container.CanBeContained(item)))))
|
||||
((i.OwnInventory.CanBePut(item) && allowInventorySwap) || (i.OwnInventory.Capacity == 1 && i.OwnInventory.AllowSwappingContainedItems && i.OwnInventory.Container.CanBeContained(item)))))
|
||||
{
|
||||
return QuickUseAction.PutToEquippedItem;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class ItemLabel : ItemComponent, IDrawableComponent
|
||||
partial class ItemLabel : ItemComponent, IDrawableComponent, IHasExtraTextPickerEntries
|
||||
{
|
||||
private GUITextBlock textBlock;
|
||||
|
||||
@@ -106,7 +108,7 @@ namespace Barotrauma.Items.Components
|
||||
set
|
||||
{
|
||||
scrollable = value;
|
||||
IsActive = value;
|
||||
IsActive = value || parseSpecialTextTagOnStart;
|
||||
TextBlock.Wrap = !scrollable;
|
||||
TextBlock.TextAlignment = scrollable ? Alignment.CenterLeft : Alignment.Center;
|
||||
}
|
||||
@@ -136,6 +138,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetExtraTextPickerEntries()
|
||||
{
|
||||
return SpecialTextTags;
|
||||
}
|
||||
|
||||
private void SetScrollingText()
|
||||
{
|
||||
if (!scrollable) { return; }
|
||||
@@ -174,9 +181,18 @@ namespace Barotrauma.Items.Components
|
||||
scrollIndex = MathHelper.Clamp(scrollIndex, 0, DisplayText.Length);
|
||||
}
|
||||
|
||||
private static readonly string[] SpecialTextTags = new string[] { "[CurrentLocationName]", "[CurrentBiomeName]", "[CurrentSubName]" };
|
||||
private bool parseSpecialTextTagOnStart;
|
||||
private void SetDisplayText(string value)
|
||||
{
|
||||
if (SpecialTextTags.Contains(value))
|
||||
{
|
||||
parseSpecialTextTagOnStart = true;
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
DisplayText = IgnoreLocalization ? value : TextManager.Get(value).Fallback(value);
|
||||
|
||||
TextBlock.Text = DisplayText;
|
||||
if (Screen.Selected == GameMain.SubEditorScreen && Scrollable)
|
||||
{
|
||||
@@ -198,9 +214,37 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
}
|
||||
|
||||
private void ParseSpecialTextTag()
|
||||
{
|
||||
switch (text)
|
||||
{
|
||||
case "[CurrentLocationName]":
|
||||
SetDisplayText(Level.Loaded?.StartLocation?.Name ?? string.Empty);
|
||||
break;
|
||||
case "[CurrentBiomeName]":
|
||||
SetDisplayText(Level.Loaded?.LevelData?.Biome?.DisplayName.Value ?? string.Empty);
|
||||
break;
|
||||
case "[CurrentSubName]":
|
||||
SetDisplayText(item.Submarine?.Info?.DisplayName.Value ?? string.Empty);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (!scrollable) { return; }
|
||||
if (parseSpecialTextTagOnStart)
|
||||
{
|
||||
ParseSpecialTextTag();
|
||||
parseSpecialTextTagOnStart = false;
|
||||
}
|
||||
|
||||
if (!scrollable)
|
||||
{
|
||||
IsActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (scrollingText == null)
|
||||
{
|
||||
@@ -286,5 +330,6 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
Text = msg.ReadString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ namespace Barotrauma.Items.Components
|
||||
[Serialize("0.5,0.5)", IsPropertySaveable.No)]
|
||||
public Vector2 Origin { get; set; } = new Vector2(0.5f, 0.5f);
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No, description: "")]
|
||||
public bool BreakFromMiddle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Vector2 DrawSize
|
||||
{
|
||||
get
|
||||
@@ -124,9 +131,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
int width = (int)(SpriteWidth * snapState);
|
||||
if (width > 0.0f)
|
||||
{
|
||||
DrawRope(spriteBatch, endPos - diff * snapState * 0.5f, endPos, width);
|
||||
DrawRope(spriteBatch, startPos, startPos + diff * snapState * 0.5f, width);
|
||||
{
|
||||
float positionMultiplier = snapState;
|
||||
if (BreakFromMiddle)
|
||||
{
|
||||
positionMultiplier /= 2;
|
||||
DrawRope(spriteBatch, endPos - diff * positionMultiplier, endPos, width);
|
||||
}
|
||||
DrawRope(spriteBatch, startPos, startPos + diff * positionMultiplier, width);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -143,7 +155,7 @@ namespace Barotrauma.Items.Components
|
||||
float depth = Math.Min(item.GetDrawDepth() + (startSprite.Depth - item.Sprite.Depth), 0.999f);
|
||||
startSprite?.Draw(spriteBatch, startPos, SpriteColor, angle, depth: depth);
|
||||
}
|
||||
if (endSprite != null)
|
||||
if (endSprite != null && (!Snapped || BreakFromMiddle))
|
||||
{
|
||||
float depth = Math.Min(item.GetDrawDepth() + (endSprite.Depth - item.Sprite.Depth), 0.999f);
|
||||
endSprite?.Draw(spriteBatch, endPos, SpriteColor, angle, depth: depth);
|
||||
|
||||
@@ -1846,7 +1846,7 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
private void ApplyReceivedState()
|
||||
public void ApplyReceivedState()
|
||||
{
|
||||
if (receivedItemIDs == null || (Owner != null && Owner.Removed)) { return; }
|
||||
|
||||
|
||||
@@ -1198,9 +1198,9 @@ namespace Barotrauma
|
||||
Color color = Color.Gray;
|
||||
if (ic.HasRequiredItems(character, false))
|
||||
{
|
||||
if (ic is Repairable)
|
||||
if (ic is Repairable r)
|
||||
{
|
||||
if (!IsFullCondition) { color = Color.Cyan; }
|
||||
if (r.IsBelowRepairThreshold) { color = Color.Cyan; }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -370,6 +370,7 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
private BallastFloraBranch ReadBranch(IReadMessage msg)
|
||||
{
|
||||
int id = msg.ReadInt32();
|
||||
bool isRootGrowth = msg.ReadBoolean();
|
||||
byte type = (byte)msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
byte sides = (byte)msg.ReadRangedInteger(0b0000, 0b1111);
|
||||
int flowerConfig = msg.ReadRangedInteger(0, 0xFFF);
|
||||
@@ -385,7 +386,8 @@ namespace Barotrauma.MapCreatures.Behavior
|
||||
{
|
||||
ID = id,
|
||||
MaxHealth = maxHealth,
|
||||
Sides = (TileSide) sides
|
||||
Sides = (TileSide) sides,
|
||||
IsRootGrowth = isRootGrowth
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,11 +272,7 @@ namespace Barotrauma
|
||||
|
||||
private GUIComponent CreateEditingHUD()
|
||||
{
|
||||
int width = 500;
|
||||
int height = spawnType == SpawnType.Path ? 80 : 200;
|
||||
int x = GameMain.GraphicsWidth / 2 - width / 2, y = 30;
|
||||
|
||||
editingHUD = new GUIFrame(new RectTransform(new Point(width, height), GUI.Canvas) { ScreenSpaceOffset = new Point(x, y) })
|
||||
editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.15f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) })
|
||||
{
|
||||
UserData = this
|
||||
};
|
||||
@@ -284,7 +280,7 @@ namespace Barotrauma
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.85f), editingHUD.RectTransform, Anchor.Center))
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.05f
|
||||
AbsoluteSpacing = (int)(GUI.Scale * 5)
|
||||
};
|
||||
|
||||
if (spawnType == SpawnType.Path)
|
||||
@@ -418,6 +414,10 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
editingHUD.RectTransform.Resize(new Point(
|
||||
editingHUD.Rect.Width,
|
||||
(int)(paddedFrame.Children.Sum(c => c.Rect.Height + paddedFrame.AbsoluteSpacing) / paddedFrame.RectTransform.RelativeSize.Y)));
|
||||
|
||||
PositionEditingHUD();
|
||||
|
||||
return editingHUD;
|
||||
|
||||
@@ -163,16 +163,11 @@ namespace Barotrauma.Networking
|
||||
|
||||
public static void ChangeCaptureDevice(string deviceName)
|
||||
{
|
||||
var config = GameSettings.CurrentConfig;
|
||||
config.Audio.VoiceCaptureDevice = deviceName;
|
||||
GameSettings.SetCurrentConfig(config);
|
||||
if (Instance == null) { return; }
|
||||
|
||||
if (Instance != null)
|
||||
{
|
||||
UInt16 storedBufferID = Instance.LatestBufferID;
|
||||
Instance.Dispose();
|
||||
Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID);
|
||||
}
|
||||
UInt16 storedBufferID = Instance.LatestBufferID;
|
||||
Instance.Dispose();
|
||||
Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID);
|
||||
}
|
||||
|
||||
IntPtr nativeBuffer;
|
||||
|
||||
@@ -54,7 +54,17 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
else
|
||||
{
|
||||
if (VoipCapture.Instance == null) { VoipCapture.Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID); }
|
||||
try
|
||||
{
|
||||
if (VoipCapture.Instance == null) { VoipCapture.Create(GameSettings.CurrentConfig.Audio.VoiceCaptureDevice, storedBufferID); }
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError($"VoipCature.Create failed: {e.Message} {e.StackTrace.CleanupStackTrace()}");
|
||||
var config = GameSettings.CurrentConfig;
|
||||
config.Audio.VoiceSetting = VoiceMode.Disabled;
|
||||
GameSettings.SetCurrentConfig(config);
|
||||
}
|
||||
if (VoipCapture.Instance == null || VoipCapture.Instance.EnqueuedTotalLength <= 0) { return; }
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -2805,7 +2805,8 @@ namespace Barotrauma.CharacterEditor
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (!character.IsHuman && !string.IsNullOrEmpty(RagdollParams.Texture) && !File.Exists(RagdollParams.Texture))
|
||||
ContentPath texturePath = ContentPath.FromRaw(character.Prefab.ContentPackage, RagdollParams.Texture);
|
||||
if (!character.IsHuman && (texturePath.IsNullOrWhiteSpace() || !File.Exists(texturePath.Value)))
|
||||
{
|
||||
DebugConsole.ThrowError($"Invalid texture path: {RagdollParams.Texture}");
|
||||
return false;
|
||||
|
||||
@@ -248,17 +248,24 @@ namespace Barotrauma
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
//draw characters with deformable limbs last, because they can't be batched into SpriteBatch
|
||||
//pretty hacky way of preventing draw order issues between normal and deformable sprites
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
//backwards order to render the most recently spawned characters in front (characters spawned later have a larger sprite depth)
|
||||
for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
|
||||
DrawDeformed(firstPass: true);
|
||||
DrawDeformed(firstPass: false);
|
||||
|
||||
void DrawDeformed(bool firstPass)
|
||||
{
|
||||
Character c = Character.CharacterList[i];
|
||||
if (!c.IsVisible || c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
|
||||
c.Draw(spriteBatch, Cam);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
//backwards order to render the most recently spawned characters in front (characters spawned later have a larger sprite depth)
|
||||
for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Character c = Character.CharacterList[i];
|
||||
if (!c.IsVisible) { continue; }
|
||||
if (c.Params.DrawLast == firstPass) { continue; }
|
||||
if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
|
||||
c.Draw(spriteBatch, Cam);
|
||||
}
|
||||
spriteBatch.End();
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
Level.Loaded?.DrawFront(spriteBatch, cam);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Barotrauma
|
||||
|
||||
private readonly GUITextBox seedBox;
|
||||
|
||||
private readonly GUITickBox lightingEnabled, cursorLightEnabled, mirrorLevel;
|
||||
private readonly GUITickBox lightingEnabled, cursorLightEnabled, allowInvalidOutpost, mirrorLevel;
|
||||
|
||||
private Sprite editingSprite;
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace Barotrauma
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
SerializeAll();
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.allsaved"), GUIStyle.Green);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -169,6 +170,12 @@ namespace Barotrauma
|
||||
|
||||
mirrorLevel = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.02f), paddedRightPanel.RectTransform), TextManager.Get("mirrorentityx"));
|
||||
|
||||
allowInvalidOutpost = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.025f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("leveleditor.allowinvalidoutpost"))
|
||||
{
|
||||
ToolTip = TextManager.Get("leveleditor.allowinvalidoutpost.tooltip")
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("leveleditor.generate"))
|
||||
{
|
||||
@@ -179,6 +186,7 @@ namespace Barotrauma
|
||||
GameMain.LightManager.ClearLights();
|
||||
LevelData levelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
levelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
levelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
|
||||
Level.Generate(levelData, mirror: mirrorLevel.Selected);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
if (!wasLevelLoaded || Cam.Position.X < 0 || Cam.Position.Y < 0 || Cam.Position.Y > Level.Loaded.Size.X || Cam.Position.Y > Level.Loaded.Size.Y)
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Barotrauma
|
||||
|
||||
private GUITextBox serverNameBox, passwordBox, maxPlayersBox;
|
||||
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaBox;
|
||||
private GUIDropDown serverExecutableDropdown;
|
||||
private readonly GUIButton joinServerButton, hostServerButton, steamWorkshopButton;
|
||||
private readonly GameMain game;
|
||||
|
||||
@@ -557,6 +558,35 @@ namespace Barotrauma
|
||||
GameMain.Instance.ShowCampaignDisclaimer(() => { SelectTab(null, Tab.HostServer); });
|
||||
return true;
|
||||
}
|
||||
|
||||
serverExecutableDropdown.ListBox.Content.Children.ToArray()
|
||||
.Where(c => c.UserData is ServerExecutableFile f && !ContentPackageManager.EnabledPackages.All.Contains(f.ContentPackage))
|
||||
.ForEach(serverExecutableDropdown.ListBox.RemoveChild);
|
||||
var newServerExes
|
||||
= ContentPackageManager.EnabledPackages.All.SelectMany(p => p.GetFiles<ServerExecutableFile>())
|
||||
.Where(f => serverExecutableDropdown.ListBox.Content.Children.None(c => c.UserData == f))
|
||||
.ToArray();
|
||||
foreach (var newServerExe in newServerExes)
|
||||
{
|
||||
serverExecutableDropdown.AddItem($"{newServerExe.ContentPackage.Name} - {Path.GetFileNameWithoutExtension(newServerExe.Path.Value)}", userData: newServerExe);
|
||||
}
|
||||
serverExecutableDropdown.ListBox.Content.Children.ForEach(c =>
|
||||
{
|
||||
c.RectTransform.RelativeSize = (1.0f, c.RectTransform.RelativeSize.Y);
|
||||
c.ForceLayoutRecalculation();
|
||||
});
|
||||
bool serverExePickable = serverExecutableDropdown.ListBox.Content.CountChildren > 1;
|
||||
serverExecutableDropdown.Parent.Visible
|
||||
= serverExePickable;
|
||||
serverExecutableDropdown.Parent.RectTransform.RelativeSize
|
||||
= (1.0f, serverExePickable ? 0.1f : 0.0f);
|
||||
serverExecutableDropdown.Parent.ForceLayoutRecalculation();
|
||||
(serverExecutableDropdown.Parent.Parent as GUILayoutGroup)?.Recalculate();
|
||||
if (serverExecutableDropdown.SelectedComponent is null)
|
||||
{
|
||||
serverExecutableDropdown.Select(0);
|
||||
}
|
||||
|
||||
break;
|
||||
case Tab.Tutorials:
|
||||
if (!GameSettings.CurrentConfig.CampaignDisclaimerShown)
|
||||
@@ -784,7 +814,7 @@ namespace Barotrauma
|
||||
GameMain.ResetNetLobbyScreen();
|
||||
try
|
||||
{
|
||||
string exeName = "DedicatedServer.exe";
|
||||
string exeName = serverExecutableDropdown.SelectedComponent?.UserData is ServerExecutableFile f ? f.Path.Value : "DedicatedServer";
|
||||
|
||||
string arguments = "-name \"" + ToolBox.EscapeCharacters(name) + "\"" +
|
||||
" -public " + isPublicBox.Selected.ToString() +
|
||||
@@ -814,15 +844,20 @@ namespace Barotrauma
|
||||
arguments += " -ownerkey " + ownerKey;
|
||||
}
|
||||
|
||||
string filename = exeName;
|
||||
#if LINUX || OSX
|
||||
filename = "./" + Path.GetFileNameWithoutExtension(exeName);
|
||||
//arguments = ToolBox.EscapeCharacters(arguments);
|
||||
string filename = Path.Combine(
|
||||
Path.GetDirectoryName(exeName),
|
||||
Path.GetFileNameWithoutExtension(exeName));
|
||||
#if WINDOWS
|
||||
filename += ".exe";
|
||||
#else
|
||||
filename = "./" + exeName;
|
||||
#endif
|
||||
|
||||
var processInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = filename,
|
||||
Arguments = arguments,
|
||||
WorkingDirectory = Directory.GetCurrentDirectory(),
|
||||
#if !DEBUG
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
@@ -1184,12 +1219,12 @@ namespace Barotrauma
|
||||
label.RectTransform.MaxSize = serverNameBox.RectTransform.MaxSize;
|
||||
|
||||
var maxPlayersLabel = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform), TextManager.Get("MaxPlayers"), textAlignment: textAlignment);
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(textFieldSize, maxPlayersLabel.RectTransform, Anchor.CenterRight), isHorizontal: true)
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(textFieldSize, maxPlayersLabel.RectTransform, Anchor.CenterRight), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.1f
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton", textAlignment: Alignment.Center)
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIMinusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
UserData = -1,
|
||||
OnClicked = ChangeMaxPlayers
|
||||
@@ -1209,7 +1244,7 @@ namespace Barotrauma
|
||||
currMaxPlayers = (int)MathHelper.Clamp(currMaxPlayers, 1, NetConfig.MaxPlayers);
|
||||
maxPlayersBox.Text = currMaxPlayers.ToString();
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center)
|
||||
new GUIButton(new RectTransform(Vector2.One, buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
UserData = 1,
|
||||
OnClicked = ChangeMaxPlayers
|
||||
@@ -1223,6 +1258,41 @@ namespace Barotrauma
|
||||
};
|
||||
label.RectTransform.MaxSize = passwordBox.RectTransform.MaxSize;
|
||||
|
||||
var serverExecutableLabel = new GUITextBlock(new RectTransform(textLabelSize, parent.RectTransform),
|
||||
TextManager.Get("ServerExecutable"), textAlignment: textAlignment);
|
||||
const string vanillaServerOption = "Vanilla";
|
||||
serverExecutableDropdown
|
||||
= new GUIDropDown(new RectTransform(textFieldSize, serverExecutableLabel.RectTransform, Anchor.CenterRight),
|
||||
vanillaServerOption);
|
||||
var listBoxSize = serverExecutableDropdown.ListBox.RectTransform.RelativeSize;
|
||||
serverExecutableDropdown.ListBox.RectTransform.RelativeSize = new Vector2(listBoxSize.X * 1.5f, listBoxSize.Y);
|
||||
serverExecutableDropdown.AddItem(vanillaServerOption, userData: null);
|
||||
serverExecutableDropdown.OnSelected = (selected, userData) =>
|
||||
{
|
||||
if (userData != null)
|
||||
{
|
||||
var warningBox = new GUIMessageBox(headerText: TextManager.Get("Warning"),
|
||||
text: TextManager.GetWithVariable("ModServerExesAtYourOwnRisk", "[exename]", serverExecutableDropdown.Text),
|
||||
new LocalizedString[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
warningBox.Buttons[0].OnClicked = (_, __) =>
|
||||
{
|
||||
warningBox.Close();
|
||||
return false;
|
||||
};
|
||||
warningBox.Buttons[1].OnClicked = (_, __) =>
|
||||
{
|
||||
serverExecutableDropdown.Select(0);
|
||||
warningBox.Close();
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
serverExecutableDropdown.Text = ToolBox.LimitString(serverExecutableDropdown.Text,
|
||||
serverExecutableDropdown.Font, serverExecutableDropdown.Rect.Width * 8 / 10);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// tickbox upper ---------------
|
||||
|
||||
var tickboxAreaUpper = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, tickBoxSize.Y), parent.RectTransform), isHorizontal: true);
|
||||
@@ -1312,8 +1382,8 @@ namespace Barotrauma
|
||||
{
|
||||
var client = new RestClient(RemoteContentUrl);
|
||||
var request = new RestRequest("MenuContent.xml", Method.GET);
|
||||
client.ExecuteAsync(request, RemoteContentReceived);
|
||||
CoroutineManager.StartCoroutine(WairForRemoteContentReceived());
|
||||
TaskPool.Add("RequestMainMenuRemoteContent", client.ExecuteAsync(request),
|
||||
RemoteContentReceived);
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
@@ -1327,58 +1397,31 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<CoroutineStatus> WairForRemoteContentReceived()
|
||||
private void RemoteContentReceived(Task t)
|
||||
{
|
||||
while (true)
|
||||
try
|
||||
{
|
||||
lock (remoteContentLock)
|
||||
if (!t.TryGetResult(out IRestResponse remoteContentResponse)) { throw new Exception("Task did not return a valid result"); }
|
||||
string xml = remoteContentResponse.Content;
|
||||
int index = xml.IndexOf('<');
|
||||
if (index > 0) { xml = xml.Substring(index, xml.Length - index); }
|
||||
if (!string.IsNullOrWhiteSpace(xml))
|
||||
{
|
||||
if (remoteContentResponse != null) { break; }
|
||||
}
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
lock (remoteContentLock)
|
||||
{
|
||||
if (remoteContentResponse.ResponseStatus != ResponseStatus.Completed || remoteContentResponse.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string xml = remoteContentResponse.Content;
|
||||
int index = xml.IndexOf('<');
|
||||
if (index > 0) { xml = xml.Substring(index, xml.Length - index); }
|
||||
if (!string.IsNullOrWhiteSpace(xml))
|
||||
remoteContentDoc = XDocument.Parse(xml);
|
||||
foreach (var subElement in remoteContentDoc?.Root.Elements())
|
||||
{
|
||||
remoteContentDoc = XDocument.Parse(xml);
|
||||
foreach (var subElement in remoteContentDoc?.Root.Elements())
|
||||
{
|
||||
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
|
||||
}
|
||||
GUIComponent.FromXML(subElement.FromPackage(null), remoteContentContainer.RectTransform);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Reading received remote main menu content failed.", e);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("MainMenuScreen.WairForRemoteContentReceived:Exception", GameAnalyticsManager.ErrorSeverity.Error,
|
||||
"Reading received remote main menu content failed. " + e.Message);
|
||||
}
|
||||
}
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
private readonly object remoteContentLock = new object();
|
||||
private IRestResponse remoteContentResponse;
|
||||
|
||||
private void RemoteContentReceived(IRestResponse response, RestRequestAsyncHandle handle)
|
||||
{
|
||||
lock (remoteContentLock)
|
||||
catch (Exception e)
|
||||
{
|
||||
remoteContentResponse = response;
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Reading received remote main menu content failed.", e);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("MainMenuScreen.RemoteContentReceived:Exception", GameAnalyticsManager.ErrorSeverity.Error,
|
||||
"Reading received remote main menu content failed. " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,19 @@ namespace Barotrauma
|
||||
currentDownload = null;
|
||||
confirmDownload = false;
|
||||
}
|
||||
|
||||
private void DeletePrevDownloads()
|
||||
{
|
||||
if (Directory.Exists(ModReceiver.DownloadFolder))
|
||||
{
|
||||
Directory.Delete(ModReceiver.DownloadFolder, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
DeletePrevDownloads();
|
||||
Reset();
|
||||
|
||||
Frame.ClearChildren();
|
||||
|
||||
@@ -9,11 +9,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
#else
|
||||
using Barotrauma.IO;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -1262,7 +1258,9 @@ namespace Barotrauma
|
||||
}
|
||||
textBlock.Text = ToolBox.LimitString(textBlock.Text, textBlock.Font, textBlock.Rect.Width);
|
||||
|
||||
if (ep.Category == MapEntityCategory.ItemAssembly)
|
||||
if (ep.Category == MapEntityCategory.ItemAssembly
|
||||
&& ep.ContentPackage?.Files.Length == 1
|
||||
&& ContentPackageManager.LocalPackages.Contains(ep.ContentPackage))
|
||||
{
|
||||
var deleteButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), paddedFrame.RectTransform, Anchor.BottomCenter) { MinSize = new Point(0, 20) },
|
||||
TextManager.Get("Delete"), style: "GUIButtonSmall")
|
||||
@@ -2225,9 +2223,7 @@ namespace Barotrauma
|
||||
// gap positions ---------------------
|
||||
|
||||
var gapPositionGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.1f), outpostSettingsContainer.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), gapPositionGroup.RectTransform), TextManager.Get("outpostmodulegappositions"), textAlignment: Alignment.CenterLeft);
|
||||
|
||||
var gapPositionDropDown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1f), gapPositionGroup.RectTransform),
|
||||
text: "", selectMultiple: true);
|
||||
|
||||
@@ -2271,6 +2267,49 @@ namespace Barotrauma
|
||||
};
|
||||
gapPositionGroup.RectTransform.MinSize = new Point(0, gapPositionGroup.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
|
||||
var canAttachToPrevGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.1f), outpostSettingsContainer.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), canAttachToPrevGroup.RectTransform), TextManager.Get("canattachtoprevious"), textAlignment: Alignment.CenterLeft)
|
||||
{
|
||||
ToolTip = TextManager.Get("canattachtoprevious.tooltip")
|
||||
};
|
||||
var canAttachToPrevDropDown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1f), canAttachToPrevGroup.RectTransform),
|
||||
text: "", selectMultiple: true);
|
||||
if (outpostModuleInfo != null)
|
||||
{
|
||||
foreach (var gapPos in Enum.GetValues(typeof(OutpostModuleInfo.GapPosition)))
|
||||
{
|
||||
if ((OutpostModuleInfo.GapPosition)gapPos == OutpostModuleInfo.GapPosition.None) { continue; }
|
||||
canAttachToPrevDropDown.AddItem(TextManager.Capitalize(gapPos.ToString()), gapPos);
|
||||
if (outpostModuleInfo.CanAttachToPrevious.HasFlag((OutpostModuleInfo.GapPosition)gapPos))
|
||||
{
|
||||
canAttachToPrevDropDown.SelectItem(gapPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canAttachToPrevDropDown.OnSelected += (_, __) =>
|
||||
{
|
||||
if (Submarine.MainSub.Info?.OutpostModuleInfo == null) { return false; }
|
||||
Submarine.MainSub.Info.OutpostModuleInfo.CanAttachToPrevious = OutpostModuleInfo.GapPosition.None;
|
||||
if (canAttachToPrevDropDown.SelectedDataMultiple.Any())
|
||||
{
|
||||
List<string> gapPosTexts = new List<string>();
|
||||
foreach (OutpostModuleInfo.GapPosition gapPos in canAttachToPrevDropDown.SelectedDataMultiple)
|
||||
{
|
||||
Submarine.MainSub.Info.OutpostModuleInfo.CanAttachToPrevious |= gapPos;
|
||||
gapPosTexts.Add(TextManager.Capitalize(gapPos.ToString()).Value);
|
||||
}
|
||||
canAttachToPrevDropDown.Text = ToolBox.LimitString(string.Join(", ", gapPosTexts), canAttachToPrevDropDown.Font, canAttachToPrevDropDown.Rect.Width);
|
||||
}
|
||||
else
|
||||
{
|
||||
canAttachToPrevDropDown.Text = ToolBox.LimitString("None", canAttachToPrevDropDown.Font, canAttachToPrevDropDown.Rect.Width);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
canAttachToPrevGroup.RectTransform.MinSize = new Point(0, gapPositionGroup.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
|
||||
|
||||
// -------------------
|
||||
|
||||
var maxModuleCountGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.5f), outpostSettingsContainer.RectTransform), isHorizontal: true)
|
||||
@@ -2583,7 +2622,18 @@ namespace Barotrauma
|
||||
//don't show content packages that only define submarine files
|
||||
//(it doesn't make sense to require another sub to be installed to install this one)
|
||||
if (contentPack.Files.All(f => f is SubmarineFile)) { continue; }
|
||||
if (!contentPacks.Contains(contentPack.Name)) { contentPacks.Add(contentPack.Name); }
|
||||
|
||||
if (!contentPacks.Contains(contentPack.Name))
|
||||
{
|
||||
string altName = contentPack.AltNames.FirstOrDefault(n => contentPacks.Contains(n));
|
||||
if (!string.IsNullOrEmpty(altName))
|
||||
{
|
||||
MainSub.Info.RequiredContentPackages.Remove(altName);
|
||||
MainSub.Info.RequiredContentPackages.Add(contentPack.Name);
|
||||
contentPacks.Remove(altName);
|
||||
}
|
||||
contentPacks.Add(contentPack.Name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string contentPackageName in contentPacks)
|
||||
@@ -2749,11 +2799,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
bool hideInMenus = nameBox.Parent.GetChildByUserData("hideinmenus") is GUITickBox hideInMenusTickBox && hideInMenusTickBox.Selected;
|
||||
#if DEBUG
|
||||
string saveFolder = ItemAssemblyPrefab.VanillaSaveFolder;
|
||||
#else
|
||||
string saveFolder = Path.Combine(ContentPackage.LocalModsDir, nameBox.Text);
|
||||
#endif
|
||||
string filePath = Path.Combine(saveFolder, $"{nameBox.Text}.xml").CleanUpPathCrossPlatform();
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
@@ -2782,26 +2828,26 @@ namespace Barotrauma
|
||||
|
||||
void Save()
|
||||
{
|
||||
XDocument doc = new XDocument(ItemAssemblyPrefab.Save(MapEntity.SelectedList.ToList(), nameBox.Text, descriptionBox.Text, hideInMenus));
|
||||
#if DEBUG
|
||||
doc.Save(filePath);
|
||||
#else
|
||||
doc.SaveSafe(filePath);
|
||||
#endif
|
||||
ContentPackage existingContentPackage = ContentPackageManager.LocalPackages.FirstOrDefault(p => p.Files.Any(f => f.Path == filePath));
|
||||
ContentPackage existingContentPackage = ContentPackageManager.LocalPackages.Regular.FirstOrDefault(p => p.Files.Any(f => f.Path == filePath));
|
||||
if (existingContentPackage == null)
|
||||
{
|
||||
//content package doesn't exist, create one
|
||||
ModProject modProject = new ModProject() { Name = nameBox.Text };
|
||||
var newFile = ModProject.File.FromPath<ItemAssemblyFile>(filePath);
|
||||
var newFile = ModProject.File.FromPath<ItemAssemblyFile>(Path.Combine(ContentPath.ModDirStr, $"{nameBox.Text}.xml"));
|
||||
modProject.AddFile(newFile);
|
||||
ContentPackageManager.LocalPackages.SaveAndEnableRegularMod(modProject);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnqueueForReload(existingContentPackage);
|
||||
string newPackagePath = ContentPackageManager.LocalPackages.SaveRegularMod(modProject);
|
||||
existingContentPackage = ContentPackageManager.LocalPackages.GetRegularModByPath(newPackagePath);
|
||||
}
|
||||
|
||||
XDocument doc = new XDocument(ItemAssemblyPrefab.Save(MapEntity.SelectedList.ToList(), nameBox.Text, descriptionBox.Text, hideInMenus));
|
||||
doc.SaveSafe(filePath);
|
||||
|
||||
var resultPackage = ContentPackageManager.ReloadContentPackage(existingContentPackage) as RegularPackage;
|
||||
if (!ContentPackageManager.EnabledPackages.Regular.Contains(resultPackage))
|
||||
{
|
||||
ContentPackageManager.EnabledPackages.EnableRegular(resultPackage);
|
||||
}
|
||||
|
||||
UpdateEntityList();
|
||||
}
|
||||
|
||||
@@ -2884,11 +2930,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn)
|
||||
{
|
||||
#if DEBUG
|
||||
deleteBtn.Enabled = true;
|
||||
#else
|
||||
deleteBtn.Enabled = userData is SubmarineInfo subInfo && !subInfo.IsVanillaSubmarine();
|
||||
#endif
|
||||
deleteBtn.Enabled = userData is SubmarineInfo subInfo && GetContentPackageIntrinsicallyTiedToSub(subInfo) != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3141,7 +3183,7 @@ namespace Barotrauma
|
||||
ReconstructLayers();
|
||||
}
|
||||
|
||||
private RegularPackage GetContentPackageIntrinsicallyTiedToSub(SubmarineInfo sub)
|
||||
private static RegularPackage GetContentPackageIntrinsicallyTiedToSub(SubmarineInfo sub)
|
||||
{
|
||||
foreach (RegularPackage regularPackage in ContentPackageManager.RegularPackages)
|
||||
{
|
||||
@@ -3171,10 +3213,11 @@ namespace Barotrauma
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(Path.GetDirectoryName(subPackage.Path), true);
|
||||
Directory.Delete(Path.GetDirectoryName(subPackage.Path), recursive: true);
|
||||
ContentPackageManager.LocalPackages.Refresh();
|
||||
ContentPackageManager.EnabledPackages.DisableRemovedMods();
|
||||
|
||||
sub.Dispose();
|
||||
File.Delete(sub.FilePath);
|
||||
SubmarineInfo.RefreshSavedSubs();
|
||||
CreateLoadScreen();
|
||||
}
|
||||
|
||||
@@ -390,13 +390,13 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
GUIComponent propertyField = null;
|
||||
if (value is bool)
|
||||
if (value is bool boolVal)
|
||||
{
|
||||
propertyField = CreateBoolField(entity, property, (bool)value, displayName, toolTip);
|
||||
propertyField = CreateBoolField(entity, property, boolVal, displayName, toolTip);
|
||||
}
|
||||
else if (value is string)
|
||||
else if (value is string stringVal)
|
||||
{
|
||||
propertyField = CreateStringField(entity, property, (string)value, displayName, toolTip);
|
||||
propertyField = CreateStringField(entity, property, stringVal, displayName, toolTip);
|
||||
}
|
||||
else if (value.GetType().IsEnum)
|
||||
{
|
||||
@@ -1277,7 +1277,7 @@ namespace Barotrauma
|
||||
|
||||
public void CreateTextPicker(string textTag, ISerializableEntity entity, SerializableProperty property, GUITextBox textBox)
|
||||
{
|
||||
var msgBox = new GUIMessageBox("", "", new LocalizedString[] { TextManager.Get("Cancel") }, new Vector2(0.2f, 0.5f), new Point(300, 400));
|
||||
var msgBox = new GUIMessageBox("", "", new LocalizedString[] { TextManager.Get("Ok") }, new Vector2(0.2f, 0.5f), new Point(300, 400));
|
||||
msgBox.Buttons[0].OnClicked = msgBox.Close;
|
||||
|
||||
var textList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), msgBox.Content.RectTransform, Anchor.TopCenter))
|
||||
@@ -1307,6 +1307,18 @@ namespace Barotrauma
|
||||
UserData = tagTextPair.Key.ToString()
|
||||
};
|
||||
}
|
||||
|
||||
if (entity is IHasExtraTextPickerEntries hasExtraTextPickerEntries)
|
||||
{
|
||||
foreach (string extraEntry in hasExtraTextPickerEntries.GetExtraTextPickerEntries())
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), textList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
ToolBox.LimitString(extraEntry, GUIStyle.Font, textList.Content.Rect.Width), GUIStyle.Green)
|
||||
{
|
||||
UserData = extraEntry
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TrySendNetworkUpdate(ISerializableEntity entity, SerializableProperty property)
|
||||
@@ -1445,4 +1457,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this interface to insert extra entires to the text pickers created for the SerializableEntityEditors of the entity
|
||||
/// </summary>
|
||||
interface IHasExtraTextPickerEntries
|
||||
{
|
||||
public IEnumerable<string> GetExtraTextPickerEntries();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user