Skip to content

Commit

Permalink
Merge pull request #112 from SS14-Classic/Update-11/25/2024
Browse files Browse the repository at this point in the history
Update 11/25/2024
  • Loading branch information
VMSolidus authored Dec 6, 2024
2 parents 0e212b8 + 1b1f629 commit fff32a9
Show file tree
Hide file tree
Showing 426 changed files with 127,594 additions and 1,969 deletions.
26 changes: 13 additions & 13 deletions Content.Client/Access/UI/AccessOverriderWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototype
{
if (!prototypeManager.TryIndex(access, out var accessLevel))
{
logMill.Error($"Unable to find accesslevel for {access}");
logMill.Error($"Unable to find access level for {access}");
continue;
}

Expand Down Expand Up @@ -66,11 +66,11 @@ public void UpdateState(AccessOverriderBoundUserInterfaceState state)

if (state.MissingPrivilegesList != null && state.MissingPrivilegesList.Any())
{
List<string> missingPrivileges = new List<string>();
var missingPrivileges = new List<string>();

foreach (string tag in state.MissingPrivilegesList)
{
string privilege = Loc.GetString(_prototypeManager.Index<AccessLevelPrototype>(tag)?.Name ?? "generic-unknown");
var privilege = Loc.GetString(_prototypeManager.Index<AccessLevelPrototype>(tag)?.Name ?? "generic-unknown");
missingPrivileges.Add(privilege);
}

Expand All @@ -83,20 +83,20 @@ public void UpdateState(AccessOverriderBoundUserInterfaceState state)
foreach (var (accessName, button) in _accessButtons)
{
button.Disabled = !interfaceEnabled;
if (interfaceEnabled)
{
button.Pressed = state.TargetAccessReaderIdAccessList?.Contains(accessName) ?? false;
button.Disabled = (!state.AllowedModifyAccessList?.Contains(accessName)) ?? true;
}
if (!interfaceEnabled)
return;

button.Pressed = state.TargetAccessReaderIdAccessList?.Contains<ProtoId<AccessLevelPrototype>>(accessName) ?? false;
button.Disabled = (!state.AllowedModifyAccessList?.Contains<ProtoId<AccessLevelPrototype>>(accessName)) ?? true;
}
}

private void SubmitData()
{
private void SubmitData() =>
_owner.SubmitData(

// Iterate over the buttons dictionary, filter by `Pressed`, only get key from the key/value pair
_accessButtons.Where(x => x.Value.Pressed).Select(x => new ProtoId<AccessLevelPrototype>(x.Key)).ToList());
}
_accessButtons.Where(x => x.Value.Pressed)
.Select(x => new ProtoId<AccessLevelPrototype>(x.Key))
.ToList()
);
}
}
51 changes: 51 additions & 0 deletions Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public sealed partial class AtmosAlertsComputerWindow : FancyWindow
{
private readonly IEntityManager _entManager;
private readonly SpriteSystem _spriteSystem;
private readonly SharedNavMapSystem _navMapSystem;

private EntityUid? _owner;
private NetEntity? _trackedEntity;
Expand All @@ -49,6 +50,7 @@ public AtmosAlertsComputerWindow(AtmosAlertsComputerBoundUserInterface userInter
RobustXamlLoader.Load(this);
_entManager = IoCManager.Resolve<IEntityManager>();
_spriteSystem = _entManager.System<SpriteSystem>();
_navMapSystem = _entManager.System<SharedNavMapSystem>();

// Pass the owner to nav map
_owner = owner;
Expand Down Expand Up @@ -181,6 +183,9 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
// Add tracked entities to the nav map
foreach (var device in console.AtmosDevices)
{
if (!device.NetEntity.Valid)
continue;

if (!NavMap.Visible)
continue;

Expand Down Expand Up @@ -272,6 +277,34 @@ public void UpdateUI(EntityCoordinates? consoleCoords, AtmosAlertsComputerEntry[
else
MasterTabContainer.SetTabTitle(0, Loc.GetString("atmos-alerts-window-tab-alerts", ("value", activeAlarmCount)));

// Update sensor regions
NavMap.RegionOverlays.Clear();
var prioritizedRegionOverlays = new Dictionary<NavMapRegionOverlay, int>();

if (_owner != null &&
_entManager.TryGetComponent<TransformComponent>(_owner, out var xform) &&
_entManager.TryGetComponent<NavMapComponent>(xform.GridUid, out var navMap))
{
var regionOverlays = _navMapSystem.GetNavMapRegionOverlays(_owner.Value, navMap, AtmosAlertsComputerUiKey.Key);

foreach (var (regionOwner, regionOverlay) in regionOverlays)
{
var alarmState = GetAlarmState(regionOwner);

if (!TryGetSensorRegionColor(regionOwner, alarmState, out var regionColor))
continue;

regionOverlay.Color = regionColor;

var priority = (_trackedEntity == regionOwner) ? 999 : (int)alarmState;
prioritizedRegionOverlays.Add(regionOverlay, priority);
}

// Sort overlays according to their priority
var sortedOverlays = prioritizedRegionOverlays.OrderBy(x => x.Value).Select(x => x.Key).ToList();
NavMap.RegionOverlays = sortedOverlays;
}

// Auto-scroll re-enable
if (_autoScrollAwaitsUpdate)
{
Expand Down Expand Up @@ -300,6 +333,24 @@ private void AddTrackedEntityToNavMap(AtmosAlertsDeviceNavMapData metaData, Atmo
NavMap.TrackedEntities[metaData.NetEntity] = blip;
}

private bool TryGetSensorRegionColor(NetEntity regionOwner, AtmosAlarmType alarmState, out Color color)
{
color = Color.White;

var blip = GetBlipTexture(alarmState);

if (blip == null)
return false;

// Color the region based on alarm state and entity tracking
color = blip.Value.Item2 * new Color(154, 154, 154);

if (_trackedEntity != null && _trackedEntity != regionOwner)
color *= Color.DimGray;

return true;
}

private void UpdateUIEntry(AtmosAlertsComputerEntry entry, int index, Control table, AtmosAlertsComputerComponent console, AtmosAlertsFocusDeviceData? focusData = null)
{
// Make new UI entry if required
Expand Down
9 changes: 6 additions & 3 deletions Content.Client/Chat/UI/EmotesMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Numerics;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech;
using Content.Shared.Whitelist;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
Expand All @@ -19,6 +20,7 @@ public sealed partial class EmotesMenu : RadialMenu
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;

private readonly SpriteSystem _spriteSystem;
private readonly EntityWhitelistSystem _whitelistSystem;

public event Action<ProtoId<EmotePrototype>>? OnPlayEmote;

Expand All @@ -28,6 +30,7 @@ public EmotesMenu()
RobustXamlLoader.Load(this);

_spriteSystem = _entManager.System<SpriteSystem>();
_whitelistSystem = _entManager.System<EntityWhitelistSystem>();

var main = FindControl<RadialContainer>("Main");

Expand All @@ -37,8 +40,8 @@ public EmotesMenu()
var player = _playerManager.LocalSession?.AttachedEntity;
if (emote.Category == EmoteCategory.Invalid ||
emote.ChatTriggers.Count == 0 ||
!(player.HasValue && (emote.Whitelist?.IsValid(player.Value, _entManager) ?? true)) ||
(emote.Blacklist?.IsValid(player.Value, _entManager) ?? false))
!(player.HasValue && _whitelistSystem.IsWhitelistPassOrNull(emote.Whitelist, player.Value)) ||
_whitelistSystem.IsBlacklistPass(emote.Blacklist, player.Value))
continue;

if (!emote.Available &&
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
};
bufferHBox.AddChild(bufferVol);

foreach (var (reagent, quantity) in state.BufferReagents)
foreach (var (reagent, quantity) in state.BufferReagents.OrderBy(x => x.Reagent.Prototype))
{
// Try to get the prototype for the given reagent. This gives us its name.
_prototypeManager.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
Expand Down
6 changes: 5 additions & 1 deletion Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Tag;
using Content.Shared.Whitelist;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Placement;
Expand All @@ -23,13 +24,15 @@ namespace Content.Client.Construction.UI
/// </summary>
internal sealed class ConstructionMenuPresenter : IDisposable
{
[Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

private readonly IConstructionMenuView _constructionView;
private readonly EntityWhitelistSystem _whitelistSystem;

private ConstructionSystem? _constructionSystem;
private ConstructionPrototype? _selected;
Expand Down Expand Up @@ -78,6 +81,7 @@ public ConstructionMenuPresenter()
// This is a lot easier than a factory
IoCManager.InjectDependencies(this);
_constructionView = new ConstructionMenu();
_whitelistSystem = _entManager.System<EntityWhitelistSystem>();

// This is required so that if we load after the system is initialized, we can bind to it immediately
if (_systemManager.TryGetEntitySystem<ConstructionSystem>(out var constructionSystem))
Expand Down Expand Up @@ -157,7 +161,7 @@ private void OnViewPopulateRecipes(object? sender, (string search, string catago

if (_playerManager.LocalSession == null
|| _playerManager.LocalEntity == null
|| (recipe.EntityWhitelist != null && !recipe.EntityWhitelist.IsValid(_playerManager.LocalEntity.Value)))
|| _whitelistSystem.IsWhitelistFail(recipe.EntityWhitelist, _playerManager.LocalEntity.Value))
continue;

if (!string.IsNullOrEmpty(search))
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Guidebook/GuidebookSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControl

public void FakeClientActivateInWorld(EntityUid activated)
{
var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated);
var activateMsg = new ActivateInWorldEvent(GetGuidebookUser(), activated, true);
RaiseLocalEvent(activated, activateMsg);
}

Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Lobby/UI/LoadoutPreferenceSelector.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,21 @@ public LoadoutPreferenceSelector(LoadoutPrototype loadout, JobPrototype highJob,

// Manage the info button
void UpdateGuidebook() => GuidebookButton.Visible =
prototypeManager.HasIndex<GuideEntryPrototype>(DefaultLoadoutInfoGuidebook + Loadout.ID);
prototypeManager.HasIndex<GuideEntryPrototype>(loadout.GuideEntry);
UpdateGuidebook();
prototypeManager.PrototypesReloaded += _ => UpdateGuidebook();

GuidebookButton.OnPressed += _ =>
{
if (!prototypeManager.TryIndex<GuideEntryPrototype>(DefaultLoadoutInfoGuidebook, out var guideRoot))
if (!prototypeManager.TryIndex<GuideEntryPrototype>(loadout.GuideEntry, out var guideRoot))
return;

var guidebookController = UserInterfaceManager.GetUIController<GuidebookUIController>();
//TODO: Don't close the guidebook if its already open, just go to the correct page
guidebookController.ToggleGuidebook(
new Dictionary<string, GuideEntry> { { DefaultLoadoutInfoGuidebook, guideRoot } },
new Dictionary<string, GuideEntry> { { loadout.GuideEntry, guideRoot } },
includeChildren: true,
selected: DefaultLoadoutInfoGuidebook + Loadout.ID);
selected: loadout.GuideEntry);
};

// Create a checkbox to get the loadout
Expand Down
Loading

0 comments on commit fff32a9

Please sign in to comment.