Build 0.20.9.0

This commit is contained in:
Markus Isberg
2022-12-01 21:59:53 +02:00
parent df805574c4
commit 31d2dc658e
66 changed files with 953 additions and 505 deletions
@@ -10,8 +10,6 @@ namespace Barotrauma
{
partial class GameScreen : Screen
{
public override bool IsEditor => GameMain.GameSession?.GameMode is TestGameMode;
private RenderTarget2D renderTargetBackground;
private RenderTarget2D renderTarget;
private RenderTarget2D renderTargetWater;
@@ -47,7 +47,14 @@ namespace Barotrauma
private GUITextBox serverNameBox, passwordBox, maxPlayersBox;
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaBox;
private GUIDropDown serverExecutableDropdown;
private readonly GUIButton joinServerButton, hostServerButton, steamWorkshopButton;
private readonly GUIButton joinServerButton, hostServerButton;
private readonly GUIFrame modsButtonContainer;
private readonly GUIButton modsButton, modUpdatesButton;
private Task<IReadOnlyList<Steamworks.Ugc.Item>> modUpdateTask;
private float modUpdateTimer = 0.0f;
private const float ModUpdateInterval = 60.0f;
private readonly GameMain game;
private GUIImage playstyleBanner;
@@ -268,15 +275,29 @@ namespace Barotrauma
RelativeSpacing = 0.035f
};
#if USE_STEAM
steamWorkshopButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), TextManager.Get("settingstab.mods"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
modsButtonContainer = new GUIFrame(new RectTransform(Vector2.One, customizeList.RectTransform),
style: null);
modsButton = new GUIButton(new RectTransform(Vector2.One, modsButtonContainer.RectTransform),
TextManager.Get("settingstab.mods"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
ForceUpperCase = ForceUpperCase.Yes,
Enabled = true,
UserData = Tab.SteamWorkshop,
OnClicked = SelectTab
};
#endif
modUpdatesButton = new GUIButton(new RectTransform(Vector2.One * 0.95f, modsButtonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight),
style: "GUIUpdateButton")
{
ToolTip = TextManager.Get("ModUpdatesAvailable"),
OnClicked = (_, _) =>
{
BulkDownloader.PrepareUpdates();
return false;
},
Visible = false
};
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), TextManager.Get("SubEditorButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
@@ -525,6 +546,8 @@ namespace Barotrauma
#region Selection
public override void Select()
{
ResetModUpdateButton();
if (WorkshopItemsToUpdate.Any())
{
while (WorkshopItemsToUpdate.TryDequeue(out ulong workshopId))
@@ -711,6 +734,13 @@ namespace Barotrauma
}
#endregion
public void ResetModUpdateButton()
{
modUpdateTask = null;
modUpdateTimer = 0;
modUpdatesButton.Visible = false;
}
public void QuickStart(bool fixedSeed = false, Identifier sub = default, float difficulty = 50, LevelGenerationParams levelGenerationParams = null)
{
if (fixedSeed)
@@ -930,15 +960,32 @@ namespace Barotrauma
public override void Update(double deltaTime)
{
#if !DEBUG && USE_STEAM
modUpdateTimer -= (float)deltaTime;
if (modUpdateTimer <= 0.0f && modUpdateTask is not { IsCompleted: false })
{
modUpdateTask = BulkDownloader.GetItemsThatNeedUpdating();
modUpdateTimer = ModUpdateInterval;
}
if (GameSettings.CurrentConfig.UseSteamMatchmaking)
{
hostServerButton.Enabled = Steam.SteamManager.IsInitialized;
}
steamWorkshopButton.Enabled = Steam.SteamManager.IsInitialized;
#elif USE_STEAM
steamWorkshopButton.Enabled = true;
#endif
if (modUpdateTask is { IsCompletedSuccessfully: true })
{
modUpdatesButton.Visible = modUpdateTask.Result.Count > 0;
}
if (modUpdatesButton.Visible)
{
var modButtonLabelSize =
modsButton.Font.MeasureString(modsButton.Text).ToPoint()
+ new Point(GUI.IntScale(25));
modUpdatesButton.RectTransform.AbsoluteOffset =
(modButtonLabelSize.X, modsButton.Rect.Height / 2 - modUpdatesButton.Rect.Height / 2);
}
switch (selectedTab)
{
case Tab.NewGame:
@@ -103,6 +103,10 @@ namespace Barotrauma
public GUIFrame JobPreferenceContainer;
public GUIListBox JobList;
private Identifier micIconStyle;
private float micCheckTimer;
const float MicCheckInterval = 1.0f;
private float autoRestartTimer;
//persistent characterinfo provided by the server
@@ -2656,27 +2660,9 @@ namespace Barotrauma
public override void Update(double deltaTime)
{
base.Update(deltaTime);
if (GameMain.Client == null) { return; }
Identifier currMicStyle = micIcon.Style.Element.NameAsIdentifier();
Identifier targetMicStyle = "GUIMicrophoneEnabled".ToIdentifier();
var voipCaptureDeviceNames = VoipCapture.CaptureDeviceNames;
if (voipCaptureDeviceNames.Count == 0)
{
targetMicStyle = "GUIMicrophoneUnavailable".ToIdentifier();
}
else if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.Disabled)
{
targetMicStyle = "GUIMicrophoneDisabled".ToIdentifier();
}
if (targetMicStyle != currMicStyle)
{
GUIStyle.Apply(micIcon, targetMicStyle);
}
UpdateMicIcon((float)deltaTime);
foreach (GUIComponent child in PlayerList.Content.Children)
{
@@ -2738,6 +2724,35 @@ namespace Barotrauma
if (!mouseRect.Contains(PlayerInput.MousePosition)) { jobVariantTooltip = null; }
}
}
private void UpdateMicIcon(float deltaTime)
{
micCheckTimer -= deltaTime;
if (micCheckTimer > 0.0f) { return; }
Identifier newMicIconStyle = "GUIMicrophoneEnabled".ToIdentifier();
if (GameSettings.CurrentConfig.Audio.VoiceSetting == VoiceMode.Disabled)
{
newMicIconStyle = "GUIMicrophoneDisabled".ToIdentifier();
}
else
{
var voipCaptureDeviceNames = VoipCapture.GetCaptureDeviceNames();
if (voipCaptureDeviceNames.Count == 0)
{
newMicIconStyle = "GUIMicrophoneUnavailable".ToIdentifier();
}
}
if (newMicIconStyle != micIconStyle)
{
micIconStyle = newMicIconStyle;
GUIStyle.Apply(micIcon, newMicIconStyle);
}
micCheckTimer = MicCheckInterval;
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
{
graphics.Clear(Color.Black);
@@ -354,9 +354,24 @@ namespace Barotrauma
ToolTip = RichString.Rich(TextManager.Get("SaveSubButton") + "‖color:125,125,125‖\nCtrl + S‖color:end‖"),
OnClicked = (btn, data) =>
{
#if DEBUG
if (ContentPackageManager.EnabledPackages.All.Any(cp => cp != ContentPackageManager.VanillaCorePackage && cp.Files.Any(f => f is not BaseSubFile)))
{
var msgBox = new GUIMessageBox("DEBUG-ONLY WARNING", "You currently have some mods enabled. Are you sure you want to save the submarine? If the mods override any vanilla content, saving the submarine may cause unintended changes.",
new LocalizedString[] { "Yes, I know what I'm doing", "Cancel" });
msgBox.Buttons[0].OnClicked = (btn, data) =>
{
msgBox.Close();
loadFrame = null;
CreateSaveScreen();
return true;
};
msgBox.Buttons[1].OnClicked += msgBox.Close;
return false;
}
#endif
loadFrame = null;
CreateSaveScreen();
return true;
}
};
@@ -3096,7 +3111,7 @@ namespace Barotrauma
return false;
}
private void SnapToGrid()
private static void SnapToGrid()
{
// First move components
foreach (MapEntity e in MapEntity.SelectedList)
@@ -3109,6 +3124,10 @@ namespace Barotrauma
var wire = item.GetComponent<Wire>();
if (wire != null) { continue; }
item.Move(offset);
if (item.GetComponent<Door>()?.LinkedGap is Gap linkedGap)
{
linkedGap.Move(item.Position - linkedGap.Position);
}
}
else if (e is Structure structure)
{
@@ -3133,7 +3152,7 @@ namespace Barotrauma
}
}
private IEnumerable<SubmarineInfo> GetLoadableSubs()
private static IEnumerable<SubmarineInfo> GetLoadableSubs()
{
string downloadFolder = Path.GetFullPath(SaveUtil.SubmarineDownloadFolder);
return SubmarineInfo.SavedSubmarines.Where(s
@@ -3520,9 +3539,18 @@ namespace Barotrauma
public void LoadSub(SubmarineInfo info)
{
Submarine.Unload();
var selectedSub = new Submarine(info);
MainSub = selectedSub;
MainSub.UpdateTransform(interpolate: false);
Submarine selectedSub = null;
try
{
selectedSub = new Submarine(info);
MainSub = selectedSub;
MainSub.UpdateTransform(interpolate: false);
}
catch (Exception e)
{
DebugConsole.ThrowError("Failed to load the submarine. The submarine file might be corrupted.", e);
return;
}
ClearUndoBuffer();
CreateDummyCharacter();