mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 05:50:44 -05:00
Add GUI Component to Bundle Loading (!140)
This gives users feedback that the game is currently loading bundles, which prevents confusion when a large amount of them are being loaded and the game is "seemingly" infinitely loading. The implementation is very bare bones, feel free to modify it to your liking if you want it to use a more fancy user interface. I went for clarity (black background, white text). With the standard `OnGUI` skin it's very hard to discern the text. Tested on 1440p and 1080p. ![image](/attachments/31a818d6-d101-4e5d-a2c5-541c8b48ba71) Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: SPT/Modules#140 Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
7cf8a0c057
commit
d9747c16cc
@ -78,6 +78,9 @@ namespace SPT.Custom.Patches
|
|||||||
|
|
||||||
var bundles = (IEasyBundle[])Array.CreateInstance(EasyBundleHelper.Type, bundleNames.Length);
|
var bundles = (IEasyBundle[])Array.CreateInstance(EasyBundleHelper.Type, bundleNames.Length);
|
||||||
|
|
||||||
|
var bundleUtils = BundleUtils.Create();
|
||||||
|
bundleUtils.Init(bundleNames.Length);
|
||||||
|
|
||||||
for (var i = 0; i < bundleNames.Length; i++)
|
for (var i = 0; i < bundleNames.Length; i++)
|
||||||
{
|
{
|
||||||
var key = bundleNames[i];
|
var key = bundleNames[i];
|
||||||
@ -86,6 +89,8 @@ namespace SPT.Custom.Patches
|
|||||||
// acquire external bundle
|
// acquire external bundle
|
||||||
if (BundleManager.Bundles.TryGetValue(key, out var bundleInfo))
|
if (BundleManager.Bundles.TryGetValue(key, out var bundleInfo))
|
||||||
{
|
{
|
||||||
|
bundleUtils.SetProgress(i, bundleInfo.FileName);
|
||||||
|
|
||||||
// we need base path without file extension
|
// we need base path without file extension
|
||||||
path = BundleManager.GetBundlePath(bundleInfo);
|
path = BundleManager.GetBundlePath(bundleInfo);
|
||||||
|
|
||||||
@ -107,6 +112,8 @@ namespace SPT.Custom.Patches
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bundleUtils.Dispose();
|
||||||
|
|
||||||
// create dependency graph
|
// create dependency graph
|
||||||
instance.Manifest = manifest;
|
instance.Manifest = manifest;
|
||||||
_bundlesField.SetValue(instance, bundles);
|
_bundlesField.SetValue(instance, bundles);
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
<Reference Include="UnityEngine.AssetBundleModule" HintPath="..\Shared\Managed\UnityEngine.AssetBundleModule.dll" Private="False" />
|
<Reference Include="UnityEngine.AssetBundleModule" HintPath="..\Shared\Managed\UnityEngine.AssetBundleModule.dll" Private="False" />
|
||||||
<Reference Include="UnityEngine.AudioModule" HintPath="..\Shared\Managed\UnityEngine.AudioModule.dll" Private="False" />
|
<Reference Include="UnityEngine.AudioModule" HintPath="..\Shared\Managed\UnityEngine.AudioModule.dll" Private="False" />
|
||||||
<Reference Include="UnityEngine.CoreModule" HintPath="..\Shared\Managed\UnityEngine.CoreModule.dll" Private="False" />
|
<Reference Include="UnityEngine.CoreModule" HintPath="..\Shared\Managed\UnityEngine.CoreModule.dll" Private="False" />
|
||||||
|
<Reference Include="UnityEngine.IMGUIModule" HintPath="..\Shared\Managed\UnityEngine.IMGUIModule.dll" />
|
||||||
<Reference Include="UnityEngine.ParticleSystemModule" HintPath="..\Shared\Managed\UnityEngine.ParticleSystemModule.dll" Private="false" />
|
<Reference Include="UnityEngine.ParticleSystemModule" HintPath="..\Shared\Managed\UnityEngine.ParticleSystemModule.dll" Private="false" />
|
||||||
<Reference Include="UnityEngine.PhysicsModule" HintPath="..\Shared\Managed\UnityEngine.PhysicsModule.dll" Private="False" />
|
<Reference Include="UnityEngine.PhysicsModule" HintPath="..\Shared\Managed\UnityEngine.PhysicsModule.dll" Private="False" />
|
||||||
|
<Reference Include="UnityEngine.TextRenderingModule" HintPath="..\Shared\Managed\UnityEngine.TextRenderingModule.dll" />
|
||||||
<Reference Include="UnityEngine.UI" HintPath="..\Shared\Managed\UnityEngine.UI.dll" Private="False" />
|
<Reference Include="UnityEngine.UI" HintPath="..\Shared\Managed\UnityEngine.UI.dll" Private="False" />
|
||||||
<Reference Include="UnityEngine.UIModule" HintPath="..\Shared\Managed\UnityEngine.UIModule.dll" Private="False" />
|
<Reference Include="UnityEngine.UIModule" HintPath="..\Shared\Managed\UnityEngine.UIModule.dll" Private="False" />
|
||||||
<Reference Include="Unity.ScriptableBuildPipeline" HintPath="..\Shared\Managed\Unity.ScriptableBuildPipeline.dll" Private="False" />
|
<Reference Include="Unity.ScriptableBuildPipeline" HintPath="..\Shared\Managed\Unity.ScriptableBuildPipeline.dll" Private="False" />
|
||||||
|
57
project/SPT.Custom/Utils/BundleUtils.cs
Normal file
57
project/SPT.Custom/Utils/BundleUtils.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace SPT.Custom.Utils
|
||||||
|
{
|
||||||
|
public class BundleUtils : MonoBehaviour
|
||||||
|
{
|
||||||
|
private GameObject rootObject;
|
||||||
|
private int current;
|
||||||
|
private int maximum;
|
||||||
|
private string bundleName;
|
||||||
|
private Texture2D bgTexture;
|
||||||
|
|
||||||
|
public static BundleUtils Create()
|
||||||
|
{
|
||||||
|
GameObject bundleUtilsObject = new GameObject("BundleUtilsObject");
|
||||||
|
BundleUtils bundleUtils = bundleUtilsObject.AddComponent<BundleUtils>();
|
||||||
|
bundleUtils.rootObject = bundleUtilsObject;
|
||||||
|
bundleUtils.current = 0;
|
||||||
|
bundleUtils.maximum = 0;
|
||||||
|
bundleUtils.enabled = true;
|
||||||
|
bundleUtils.bgTexture = new Texture2D(2, 2);
|
||||||
|
return bundleUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(int length)
|
||||||
|
{
|
||||||
|
maximum = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetProgress(int progress, string fileName)
|
||||||
|
{
|
||||||
|
current = progress;
|
||||||
|
bundleName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Destroy(rootObject);
|
||||||
|
Destroy(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnGUI()
|
||||||
|
{
|
||||||
|
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
|
||||||
|
GUI.skin.window.alignment = TextAnchor.MiddleCenter;
|
||||||
|
GUI.skin.window.normal.background = bgTexture;
|
||||||
|
GUI.backgroundColor = Color.black;
|
||||||
|
GUI.Window(0, new Rect((Screen.width / 2) - 200, (Screen.height / 2) + 200, 500, 80), DrawWindow, "Bundle Loading");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawWindow(int windowId)
|
||||||
|
{
|
||||||
|
GUI.Label(new Rect(0, 35, 500, 20), $"Loading bundle: {current} / {maximum}");
|
||||||
|
GUI.Label(new Rect(0, 50, 500, 20), bundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user