diff --git a/Content.Client/Administration/Managers/GamePrototypeLoadManager.cs b/Content.Client/Administration/Managers/GamePrototypeLoadManager.cs new file mode 100644 index 0000000000..15944516a2 --- /dev/null +++ b/Content.Client/Administration/Managers/GamePrototypeLoadManager.cs @@ -0,0 +1,39 @@ +using System; +using Content.Shared.Administration; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Log; +using Robust.Shared.Network; +using Robust.Shared.Prototypes; + +namespace Content.Client.Administration.Managers; + +public class GamePrototypeLoadManager : IGamePrototypeLoadManager +{ + [Dependency] private readonly IClientNetManager _netManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly ILocalizationManager _localizationManager = default!; + + public void Initialize() + { + _netManager.RegisterNetMessage(LoadGamePrototype); + } + + private void LoadGamePrototype(GamePrototypeLoadMessage message) + { + _prototypeManager.LoadString(message.PrototypeData); + _prototypeManager.Resync(); + _localizationManager.ReloadLocalizations(); + GamePrototypeLoaded?.Invoke(); + Logger.InfoS("adminbus", "Loaded adminbus prototype data."); + } + + public void SendGamePrototype(string prototype) + { + var msg = _netManager.CreateNetMessage(); + msg.PrototypeData = prototype; + _netManager.ClientSendMessage(msg); + } + + public event Action? GamePrototypeLoaded; +} diff --git a/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml b/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml index 898a4404a9..3fc51089d7 100644 --- a/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml +++ b/Content.Client/Administration/UI/Tabs/AdminbusTab/AdminbusTab.xaml @@ -8,6 +8,7 @@