diff --git a/Content.Client/CartridgeLoader/Cartridges/NavigatorUi.cs b/Content.Client/CartridgeLoader/Cartridges/NavigatorUi.cs new file mode 100644 index 0000000000..5b5e1e3e62 --- /dev/null +++ b/Content.Client/CartridgeLoader/Cartridges/NavigatorUi.cs @@ -0,0 +1,32 @@ +using Content.Client.UserInterface.Fragments; +using Content.Shared.CartridgeLoader.Cartridges; +using Robust.Client.UserInterface; + +namespace Content.Client.CartridgeLoader.Cartridges; + +public sealed partial class NavigatorUi : UIFragment +{ + private NavigatorUiFragment? _fragment; + private IEntityManager? _entManager; + + public override Control GetUIFragmentRoot() + { + return _fragment!; + } + + public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner) + { + _entManager = IoCManager.Resolve(); + _fragment = new NavigatorUiFragment(); + _fragment.Setup(fragmentOwner); + } + + public override void UpdateState(BoundUserInterfaceState state) + { + if (state is not NavigatorUiState navigatorState || _entManager == null) + return; + + var mapUid = _entManager.GetEntity(navigatorState.MapUid); + _fragment?.UpdateState(mapUid, navigatorState.StationName); + } +} diff --git a/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml new file mode 100644 index 0000000000..99ee610e4b --- /dev/null +++ b/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml.cs new file mode 100644 index 0000000000..58ca071a45 --- /dev/null +++ b/Content.Client/CartridgeLoader/Cartridges/NavigatorUiFragment.xaml.cs @@ -0,0 +1,38 @@ +using Content.Client.Pinpointer.UI; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.CartridgeLoader.Cartridges; + +[GenerateTypedNameReferences] +public sealed partial class NavigatorUiFragment : BoxContainer +{ + public NavMapControl? NavMap; + + public NavigatorUiFragment() + { + RobustXamlLoader.Load(this); + } + + public void Setup(EntityUid? owner) + { + NavMap = new NavMapControl(); + NavMap.Owner = owner; + NavMap.HorizontalExpand = true; + NavMap.VerticalExpand = true; + + NavMapContainer.AddChild(NavMap); + } + + public void UpdateState(EntityUid? mapUid, string stationName) + { + StationNameLabel.Text = stationName; + + if (NavMap != null && mapUid != null) + { + NavMap.MapUid = mapUid; + } + } +} diff --git a/Content.Client/Pinpointer/UI/NavMapControl.cs b/Content.Client/Pinpointer/UI/NavMapControl.cs index b774b7d8b5..b033c493d9 100644 --- a/Content.Client/Pinpointer/UI/NavMapControl.cs +++ b/Content.Client/Pinpointer/UI/NavMapControl.cs @@ -135,7 +135,7 @@ public partial class NavMapControl : MapGridControl }, VerticalExpand = false, HorizontalExpand = true, - SetWidth = 650f, + //SetWidth = 650f, Sunrise-Edit Children = { new BoxContainer() diff --git a/Content.Client/Pinpointer/UI/StationMapWindow.xaml b/Content.Client/Pinpointer/UI/StationMapWindow.xaml index c79fc8f9e7..659a6bec31 100644 --- a/Content.Client/Pinpointer/UI/StationMapWindow.xaml +++ b/Content.Client/Pinpointer/UI/StationMapWindow.xaml @@ -13,8 +13,8 @@ - - + + diff --git a/Content.Client/UserInterface/Controls/MapGridControl.xaml.cs b/Content.Client/UserInterface/Controls/MapGridControl.xaml.cs index a10155f3e8..39d0f1ba47 100644 --- a/Content.Client/UserInterface/Controls/MapGridControl.xaml.cs +++ b/Content.Client/UserInterface/Controls/MapGridControl.xaml.cs @@ -1,4 +1,5 @@ using System.Numerics; +using System.Text.RegularExpressions; using Robust.Client.AutoGenerated; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; @@ -85,7 +86,7 @@ public partial class MapGridControl : LayoutContainer { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - SetSize = new Vector2(SizeFull, SizeFull); + MinSize = new Vector2(MathF.Round(SizeFull / 2f), MathF.Round(SizeFull / 2f)); // Sunrise-Edit RectClipContent = true; MouseFilter = MouseFilterMode.Stop; ActualRadarRange = WorldRange; diff --git a/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeComponent.cs b/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeComponent.cs new file mode 100644 index 0000000000..d944f089f9 --- /dev/null +++ b/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Server.CartridgeLoader.Cartridges; + +[RegisterComponent] +public sealed partial class NavigatorCartridgeComponent : Component +{ +} \ No newline at end of file diff --git a/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeSystem.cs b/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeSystem.cs new file mode 100644 index 0000000000..8dfa09cf4c --- /dev/null +++ b/Content.Server/CartridgeLoader/Cartridges/NavigatorCartridgeSystem.cs @@ -0,0 +1,66 @@ +using Content.Server.Station.Systems; +using Content.Shared.CartridgeLoader; +using Content.Shared.CartridgeLoader.Cartridges; +using Content.Shared.Station.Components; +using Robust.Shared.Map; +using System.Linq; + +namespace Content.Server.CartridgeLoader.Cartridges; + +public sealed class NavigatorCartridgeSystem : EntitySystem +{ + [Dependency] private readonly CartridgeLoaderSystem _cartridgeLoader = default!; + [Dependency] private readonly StationSystem _stationSystem = default!; + [Dependency] private readonly IMapManager _mapManager = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnUiMessage); + SubscribeLocalEvent(OnUiReady); + } + + /// + /// The ui messages received here get wrapped by a CartridgeMessageEvent and are relayed from the + /// + /// + /// The cartridge specific ui message event needs to inherit from the CartridgeMessageEvent + /// + private void OnUiMessage(EntityUid uid, NavigatorCartridgeComponent component, CartridgeMessageEvent args) + { + UpdateUiState(uid, GetEntity(args.LoaderUid), component); + } + + /// + /// This gets called when the ui fragment needs to be updated for the first time after activating + /// + private void OnUiReady(EntityUid uid, NavigatorCartridgeComponent component, CartridgeUiReadyEvent args) + { + UpdateUiState(uid, args.Loader, component); + } + + private void UpdateUiState(EntityUid uid, EntityUid loaderUid, NavigatorCartridgeComponent? component) + { + if (!Resolve(uid, ref component)) + return; + + var owningStation = _stationSystem.GetOwningStation(loaderUid); + var stationName = "Unknown Station"; + NetEntity? mapUid = null; + + if (owningStation != null && TryComp(owningStation.Value, out var metaData)) + { + stationName = metaData.EntityName; + + // Try to get the station's primary grid for the map + if (TryComp(owningStation.Value, out var stationData) && stationData.Grids.Count > 0) + { + // Get the first grid as the map reference and convert to NetEntity + mapUid = GetNetEntity(stationData.Grids.First()); + } + } + + var state = new NavigatorUiState(mapUid, stationName); + _cartridgeLoader.UpdateCartridgeUiState(loaderUid, state); + } +} \ No newline at end of file diff --git a/Content.Shared/CartridgeLoader/Cartridges/NavigatorUiState.cs b/Content.Shared/CartridgeLoader/Cartridges/NavigatorUiState.cs new file mode 100644 index 0000000000..a58fabdbb1 --- /dev/null +++ b/Content.Shared/CartridgeLoader/Cartridges/NavigatorUiState.cs @@ -0,0 +1,16 @@ +using Robust.Shared.Serialization; + +namespace Content.Shared.CartridgeLoader.Cartridges; + +[Serializable, NetSerializable] +public sealed class NavigatorUiState : BoundUserInterfaceState +{ + public NetEntity? MapUid; + public string StationName; + + public NavigatorUiState(NetEntity? mapUid, string stationName) + { + MapUid = mapUid; + StationName = stationName; + } +} \ No newline at end of file diff --git a/Resources/Locale/en-US/_prototypes/entities/objects/devices/cartridges.ftl b/Resources/Locale/en-US/_prototypes/entities/objects/devices/cartridges.ftl index b393e6507a..64d84d94a0 100644 --- a/Resources/Locale/en-US/_prototypes/entities/objects/devices/cartridges.ftl +++ b/Resources/Locale/en-US/_prototypes/entities/objects/devices/cartridges.ftl @@ -16,3 +16,5 @@ ent-MedTekCartridge = MedTek cartridge .desc = A program that provides medical diagnostic tools. ent-AstroNavCartridge = AstroNav cartridge .desc = A program for navigation that provides GPS coordinates. +ent-NavigatorCartridge = navigator cartridge + .desc = A program for viewing the station map for navigation purposes. diff --git a/Resources/Locale/en-US/_strings/cartridge-loader/cartridges.ftl b/Resources/Locale/en-US/_strings/cartridge-loader/cartridges.ftl index 6621c000a3..54a28ea66d 100644 --- a/Resources/Locale/en-US/_strings/cartridge-loader/cartridges.ftl +++ b/Resources/Locale/en-US/_strings/cartridge-loader/cartridges.ftl @@ -27,6 +27,9 @@ log-probe-printout-entry = #{$number} / {$time} / {$accessor} astro-nav-program-name = AstroNav +navigator-program-name = Navigator +navigator-cartridge-loading = Loading map... + med-tek-program-name = MedTek # NanoTask cartridge diff --git a/Resources/Locale/ru-RU/_prototypes/entities/objects/devices/cartridges.ftl b/Resources/Locale/ru-RU/_prototypes/entities/objects/devices/cartridges.ftl index f31a940e68..4cf28b1fe4 100644 --- a/Resources/Locale/ru-RU/_prototypes/entities/objects/devices/cartridges.ftl +++ b/Resources/Locale/ru-RU/_prototypes/entities/objects/devices/cartridges.ftl @@ -16,3 +16,5 @@ ent-MedTekCartridge = картридж МедТек .desc = Программа, предоставляющая инструменты для медицинской диагностики. ent-AstroNavCartridge = Картридж АстроНав .desc = Программа для навигации, предоставляющая GPS-координаты. +ent-NavigatorCartridge = картридж навигатора + .desc = Программа для просмотра карты станции в целях навигации. diff --git a/Resources/Locale/ru-RU/_strings/cartridge-loader/cartridges.ftl b/Resources/Locale/ru-RU/_strings/cartridge-loader/cartridges.ftl index 66f72e40fb..9e37ecc289 100644 --- a/Resources/Locale/ru-RU/_strings/cartridge-loader/cartridges.ftl +++ b/Resources/Locale/ru-RU/_strings/cartridge-loader/cartridges.ftl @@ -21,6 +21,10 @@ log-probe-printout-device = Просканированное устройств log-probe-printout-header = Последние логи: log-probe-printout-entry = #{ $number } / { $time } / { $accessor } astro-nav-program-name = АстроНав + +navigator-program-name = Навигатор +navigator-cartridge-loading = Загрузка карты... + med-tek-program-name = МедТек # Wanted list cartridge wanted-list-program-name = Список разыскиваемых diff --git a/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml b/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml index 494bda50d1..2269f89bd8 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/cartridges.yml @@ -173,3 +173,24 @@ sprite: Objects/Devices/gps.rsi state: icon - type: AstroNavCartridge + +- type: entity + parent: BaseItem + id: NavigatorCartridge + name: navigator cartridge + description: A program for viewing the station map for navigation purposes. + components: + - type: Sprite + sprite: Objects/Devices/cartridge.rsi + state: cart-nav + - type: Icon + sprite: Objects/Devices/cartridge.rsi + state: cart-nav + - type: UIFragment + ui: !type:NavigatorUi + - type: Cartridge + programName: navigator-program-name + icon: + sprite: Structures/Wallmounts/signs.rsi + state: space + - type: NavigatorCartridge diff --git a/Resources/Prototypes/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/Entities/Objects/Devices/pda.yml index 2d27bc3be4..f8c510142c 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/pda.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/pda.yml @@ -83,6 +83,7 @@ - NotekeeperCartridge - NanoTaskCartridge - NewsReaderCartridge + - NavigatorCartridge cartridgeSlot: priority: -1 name: device-pda-slot-component-slot-name-cartridge @@ -154,6 +155,7 @@ - NotekeeperCartridge - NanoTaskCartridge - NewsReaderCartridge + - NavigatorCartridge - WantedListCartridge - type: entity @@ -168,6 +170,7 @@ - NotekeeperCartridge - NanoTaskCartridge - NewsReaderCartridge + - NavigatorCartridge - MedTekCartridge - type: entity