mirror of
https://gitlab.acidiclight.dev/sociallydistant/sociallydistant.git
synced 2025-01-22 17:41:49 -05:00
Fix race condition caused by Unity being weird
This commit is contained in:
parent
db3afdef34
commit
c0e6922dd4
2 changed files with 18 additions and 17 deletions
|
@ -17,6 +17,7 @@ using UnityEngine.UI;
|
|||
using UnityExtensions;
|
||||
using Utility;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace UI.Shell
|
||||
{
|
||||
|
@ -70,10 +71,9 @@ namespace UI.Shell
|
|||
gameManager.UriManager.RegisterSchema("shell", new ShellUriSchemeHandler(this));
|
||||
|
||||
this.UpdateUserDisplay();
|
||||
await this.toolManager.StartFirstTool();
|
||||
Show();
|
||||
}
|
||||
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
gameManager.UriManager.UnregisterSchema("web");
|
||||
|
@ -82,9 +82,15 @@ namespace UI.Shell
|
|||
Hide();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
private async void Start()
|
||||
{
|
||||
// Prevents a race condition since OnEnable is async
|
||||
while (loginProcess == null)
|
||||
await Task.Yield();
|
||||
|
||||
this.currentWorkspace = playerHolder.Value.UiManager.WindowManager.DefineWorkspace(this.workspaceArea);
|
||||
|
||||
await toolManager.StartFirstTool();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -32,34 +32,29 @@ namespace UI.Windowing
|
|||
private TabbedTool? currentTool;
|
||||
private ITile tile;
|
||||
private GameManager gameManager = null!;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Awake()
|
||||
{
|
||||
gameManager = GameManager.Instance;
|
||||
|
||||
|
||||
this.AssertAllFieldsAreSerialized(typeof(TabbedToolManager));
|
||||
this.MustGetComponent(out tile);
|
||||
this.MustGetComponentInParent(out shell);
|
||||
this.tile.WindowClosed += OnTileClosed;
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
this.tools.Clear();
|
||||
|
||||
|
||||
// Really cursed bullshit linq code that I'd never get CAUGHT DEAD writing for trixel...
|
||||
// that makes the terminal always show up first no matter what.
|
||||
this.tools.AddRange(this.gameManager.AvailableTools
|
||||
.OrderByDescending(x=>x.Equals(terminal))
|
||||
.ThenBy(x=>x.Program.WindowTitle)
|
||||
.Select(x=>new TabbedTool(x, shell)));
|
||||
.OrderByDescending(x => x.Equals(terminal))
|
||||
.ThenBy(x => x.Program.WindowTitle)
|
||||
.Select(x => new TabbedTool(x, shell)));
|
||||
|
||||
this.BuildDock();
|
||||
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
private void BuildDock()
|
||||
|
@ -81,7 +76,7 @@ namespace UI.Windowing
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MustGetToolGui<T>(out T behaviour) where T : MonoBehaviour
|
||||
{
|
||||
if (this.tile.ActiveContent is not RectTransformContentPanel contentPanel)
|
||||
|
|
Loading…
Reference in a new issue