Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2023-10-19 12:18:30 -03:00
613 changed files with 22122 additions and 11481 deletions
@@ -112,7 +112,8 @@ namespace Barotrauma
public static LoadingScreen TitleScreen;
private bool loadingScreenOpen;
private CoroutineHandle loadingCoroutine;
private Thread initialLoadingThread;
public bool HasLoaded { get; private set; }
private readonly GameTime fixedTime;
@@ -414,24 +415,21 @@ namespace Barotrauma
WaitForLanguageSelection = GameSettings.CurrentConfig.Language == LanguageIdentifier.None
};
bool canLoadInSeparateThread = true;
loadingCoroutine = CoroutineManager.StartCoroutine(Load(canLoadInSeparateThread), "Load", canLoadInSeparateThread);
initialLoadingThread = new Thread(Load);
initialLoadingThread.Start();
}
public class LoadingException : Exception
private void Load()
{
public LoadingException(Exception e) : base("Loading was interrupted due to an error.", innerException: e)
static void log(string str)
{
if (GameSettings.CurrentConfig.VerboseLogging)
{
DebugConsole.NewMessage(str, Color.Lime);
}
}
}
private IEnumerable<CoroutineStatus> Load(bool isSeparateThread)
{
if (GameSettings.CurrentConfig.VerboseLogging)
{
DebugConsole.NewMessage("LOADING COROUTINE", Color.Lime);
}
log("LOADING COROUTINE");
ContentPackageManager.LoadVanillaFileList();
@@ -441,7 +439,7 @@ namespace Barotrauma
TitleScreen.AvailableLanguages = TextManager.AvailableLanguages.OrderBy(l => l.Value != "english".ToIdentifier()).ThenBy(l => l.Value).ToArray();
while (TitleScreen.WaitForLanguageSelection)
{
yield return CoroutineStatus.Running;
Thread.Sleep((int)(Timing.Step * 1000));
}
ContentPackageManager.VanillaCorePackage.UnloadFilesOfType<TextFile>();
}
@@ -453,25 +451,13 @@ namespace Barotrauma
{
var pendingSplashScreens = TitleScreen.PendingSplashScreens;
float baseVolume = MathHelper.Clamp(GameSettings.CurrentConfig.Audio.SoundVolume * 2.0f, 0.0f, 1.0f);
pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_UTG.webm", baseVolume * 0.5f));
pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_FF.webm", baseVolume));
pendingSplashScreens?.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_Daedalic.webm", baseVolume * 0.1f));
}
//if not loading in a separate thread, wait for the splash screens to finish before continuing the loading
//otherwise the videos will look extremely choppy
if (!isSeparateThread)
{
while (TitleScreen.PlayingSplashScreen || TitleScreen.PendingSplashScreens.Count > 0)
{
yield return CoroutineStatus.Running;
}
pendingSplashScreens.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_UTG.webm", baseVolume * 0.5f));
pendingSplashScreens.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_FF.webm", baseVolume));
pendingSplashScreens.Enqueue(new LoadingScreen.PendingSplashScreen("Content/SplashScreens/Splash_Daedalic.webm", baseVolume * 0.1f));
}
GUI.Init();
yield return CoroutineStatus.Running;
LegacySteamUgcTransition.Prepare();
var contentPackageLoadRoutine = ContentPackageManager.Init();
foreach (var progress in contentPackageLoadRoutine
@@ -479,7 +465,6 @@ namespace Barotrauma
{
const float min = 1f, max = 70f;
TitleScreen.LoadState = MathHelper.Lerp(min, max, progress);
yield return CoroutineStatus.Running;
}
var corePackage = ContentPackageManager.EnabledPackages.Core;
@@ -508,7 +493,6 @@ namespace Barotrauma
TaskPool.Add("InitRelayNetworkAccess", SteamManager.InitRelayNetworkAccess(), (t) => { });
HintManager.Init();
yield return CoroutineStatus.Running;
CoreEntityPrefab.InitCorePrefabs();
GameModePreset.Init();
@@ -516,7 +500,6 @@ namespace Barotrauma
SubmarineInfo.RefreshSavedSubs();
TitleScreen.LoadState = 75.0f;
yield return CoroutineStatus.Running;
GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice);
@@ -524,13 +507,11 @@ namespace Barotrauma
LightManager = new Lights.LightManager(base.GraphicsDevice);
TitleScreen.LoadState = 80.0f;
yield return CoroutineStatus.Running;
MainMenuScreen = new MainMenuScreen(this);
ServerListScreen = new ServerListScreen();
TitleScreen.LoadState = 85.0f;
yield return CoroutineStatus.Running;
#if USE_STEAM
if (SteamManager.IsInitialized)
@@ -556,12 +537,10 @@ namespace Barotrauma
TestScreen = new TestScreen();
TitleScreen.LoadState = 90.0f;
yield return CoroutineStatus.Running;
ParticleEditorScreen = new ParticleEditorScreen();
TitleScreen.LoadState = 95.0f;
yield return CoroutineStatus.Running;
LevelEditorScreen = new LevelEditorScreen();
SpriteEditorScreen = new SpriteEditorScreen();
@@ -569,8 +548,6 @@ namespace Barotrauma
CharacterEditorScreen = new CharacterEditor.CharacterEditorScreen();
CampaignEndScreen = new CampaignEndScreen();
yield return CoroutineStatus.Running;
#if DEBUG
LevelGenerationParams.CheckValidity();
#endif
@@ -586,17 +563,10 @@ namespace Barotrauma
TitleScreen.LoadState = 100.0f;
HasLoaded = true;
if (GameSettings.CurrentConfig.VerboseLogging)
{
DebugConsole.NewMessage("LOADING COROUTINE FINISHED", Color.Lime);
}
log("LOADING COROUTINE FINISHED");
#if CLIENT
LuaCsInstaller.CheckUpdate();
#endif
yield return CoroutineStatus.Success;
}
/// <summary>
@@ -749,11 +719,6 @@ namespace Barotrauma
#endif
Client?.Update((float)Timing.Step);
if (!HasLoaded && !CoroutineManager.IsCoroutineRunning(loadingCoroutine))
{
throw new LoadingException(loadingCoroutine.Exception);
}
}
else if (HasLoaded)
{
@@ -1188,7 +1153,7 @@ namespace Barotrauma
{
waitForKeyHit = waitKeyHit;
loadingScreenOpen = true;
TitleScreen.LoadState = null;
TitleScreen.LoadState = 0f;
return CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
}