-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
162 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...rMod.Test/Multiplayer/LoadOverlayPatch.cs → ...tiplayer/MultiplayerStatusOverlayPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/MultiplayerMod/Multiplayer/Commands/Overlay/ShowLoadOverlay.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
src/MultiplayerMod/Multiplayer/UI/Overlays/MultiplayerStatusOverlay.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using JetBrains.Annotations; | ||
using MultiplayerMod.Core.Dependency; | ||
using MultiplayerMod.Core.Events; | ||
using MultiplayerMod.Core.Scheduling; | ||
using MultiplayerMod.ModRuntime.StaticCompatibility; | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace MultiplayerMod.Multiplayer.UI.Overlays; | ||
|
||
public class MultiplayerStatusOverlay { | ||
|
||
public static string Text { | ||
get => overlay?.text ?? ""; | ||
set { | ||
if (overlay == null) | ||
return; | ||
|
||
overlay.text = value; | ||
overlay.textComponent.text = value; | ||
} | ||
} | ||
|
||
private LocText textComponent = null!; | ||
private string text = ""; | ||
|
||
[InjectDependency, UsedImplicitly] | ||
private UnityTaskScheduler scheduler = null!; | ||
|
||
[InjectDependency, UsedImplicitly] | ||
private EventDispatcher events = null!; | ||
|
||
private static MultiplayerStatusOverlay? overlay; | ||
|
||
private MultiplayerStatusOverlay() { | ||
SceneManager.sceneLoaded += OnPostLoadScene; | ||
Dependencies.Get<IDependencyInjector>().Inject(this); | ||
CreateOverlay(); | ||
} | ||
|
||
private void CreateOverlay() { | ||
LoadingOverlay.Load(() => { }); | ||
textComponent = LoadingOverlay.instance.GetComponentInChildren<LocText>(); | ||
textComponent.alignment = TextAlignmentOptions.Top; | ||
textComponent.margin = new Vector4(0, -21.0f, 0, 0); | ||
textComponent.text = text; | ||
|
||
var rect = textComponent.gameObject.GetComponent<RectTransform>(); | ||
rect.sizeDelta = new Vector2(Screen.width, 0); | ||
|
||
var scale = LoadingOverlay.instance.GetComponentInParent<KCanvasScaler>().GetCanvasScale(); | ||
ScreenResize.Instance.OnResize += () => rect.sizeDelta = new Vector2(Screen.width / scale, 0); | ||
} | ||
|
||
private void Dispose() { | ||
SceneManager.sceneLoaded -= OnPostLoadScene; | ||
LoadingOverlay.Clear(); | ||
} | ||
|
||
private void OnPostLoadScene(Scene scene, LoadSceneMode mode) => scheduler.Run(CreateOverlay); | ||
|
||
public static void Show(string text) { | ||
overlay ??= new MultiplayerStatusOverlay(); | ||
Text = text; | ||
} | ||
|
||
public static void Close() { | ||
overlay?.Dispose(); | ||
overlay = null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters