Merge remote-tracking branch 'upstream/master' into ed-23-02-2025-upstream
# Conflicts: # Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs # Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml
This commit is contained in:
@@ -175,7 +175,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
|
||||
UIHelper.DiscordRelayChanged(_discordRelayActive);
|
||||
|
||||
UIHelper.SendMessageAction = (userId, textMessage, playSound) => _bwoinkSystem?.Send(userId, textMessage, playSound);
|
||||
UIHelper.SendMessageAction = (userId, textMessage, playSound, adminOnly) => _bwoinkSystem?.Send(userId, textMessage, playSound, adminOnly);
|
||||
UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
|
||||
UIHelper.OnClose += () => { SetAHelpPressed(false); };
|
||||
UIHelper.OnOpen += () => { SetAHelpPressed(true); };
|
||||
@@ -324,7 +324,7 @@ public interface IAHelpUIHandler : IDisposable
|
||||
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
|
||||
public event Action OnClose;
|
||||
public event Action OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
}
|
||||
public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
@@ -408,7 +408,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -462,7 +462,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
|
||||
return existingPanel;
|
||||
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true));
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true, Window?.Bwoink.AdminOnly.Pressed ?? false));
|
||||
existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
|
||||
existingPanel.Visible = false;
|
||||
if (!Control!.BwoinkArea.Children.Contains(existingPanel))
|
||||
@@ -548,7 +548,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -561,7 +561,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
{
|
||||
if (_window is { Disposed: false })
|
||||
return;
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true));
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
|
||||
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
|
||||
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
|
||||
_window = new DefaultWindow()
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -190,6 +191,26 @@ public sealed class StorageWindow : BaseWindow
|
||||
BuildGridRepresentation();
|
||||
}
|
||||
|
||||
private void CloseParent()
|
||||
{
|
||||
if (StorageEntity == null)
|
||||
return;
|
||||
|
||||
var containerSystem = _entity.System<SharedContainerSystem>();
|
||||
var uiSystem = _entity.System<UserInterfaceSystem>();
|
||||
|
||||
if (containerSystem.TryGetContainingContainer(StorageEntity.Value, out var container) &&
|
||||
_entity.TryGetComponent(container.Owner, out StorageComponent? storage) &&
|
||||
storage.Container.Contains(StorageEntity.Value) &&
|
||||
uiSystem
|
||||
.TryGetOpenUi<StorageBoundUserInterface>(container.Owner,
|
||||
StorageComponent.StorageUiKey.Key,
|
||||
out var parentBui))
|
||||
{
|
||||
parentBui.CloseWindow(Position);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildGridRepresentation()
|
||||
{
|
||||
if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var comp) || comp.Grid.Count == 0)
|
||||
@@ -212,7 +233,9 @@ public sealed class StorageWindow : BaseWindow
|
||||
};
|
||||
exitButton.OnPressed += _ =>
|
||||
{
|
||||
// Close ourselves and all parent BUIs.
|
||||
Close();
|
||||
CloseParent();
|
||||
};
|
||||
exitButton.OnKeyBindDown += args =>
|
||||
{
|
||||
@@ -220,6 +243,7 @@ public sealed class StorageWindow : BaseWindow
|
||||
if (!args.Handled && args.Function == ContentKeyFunctions.ActivateItemInWorld)
|
||||
{
|
||||
Close();
|
||||
CloseParent();
|
||||
args.Handle();
|
||||
}
|
||||
};
|
||||
@@ -258,7 +282,8 @@ public sealed class StorageWindow : BaseWindow
|
||||
var containerSystem = _entity.System<SharedContainerSystem>();
|
||||
|
||||
if (containerSystem.TryGetContainingContainer(StorageEntity.Value, out var container) &&
|
||||
_entity.TryGetComponent(container.Owner, out StorageComponent? storage))
|
||||
_entity.TryGetComponent(container.Owner, out StorageComponent? storage) &&
|
||||
storage.Container.Contains(StorageEntity.Value))
|
||||
{
|
||||
Close();
|
||||
|
||||
@@ -267,7 +292,7 @@ public sealed class StorageWindow : BaseWindow
|
||||
StorageComponent.StorageUiKey.Key,
|
||||
out var parentBui))
|
||||
{
|
||||
parentBui.Show();
|
||||
parentBui.Show(Position);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -412,6 +437,8 @@ public sealed class StorageWindow : BaseWindow
|
||||
{
|
||||
if (storageComp.StoredItems.TryGetValue(ent, out var updated))
|
||||
{
|
||||
data.Control.Marked = IsMarked(ent);
|
||||
|
||||
if (data.Loc.Equals(updated))
|
||||
{
|
||||
DebugTools.Assert(data.Control.Location == updated);
|
||||
@@ -450,12 +477,7 @@ public sealed class StorageWindow : BaseWindow
|
||||
var gridPiece = new ItemGridPiece((ent, itemEntComponent), loc, _entity)
|
||||
{
|
||||
MinSize = size,
|
||||
Marked = _contained.IndexOf(ent) switch
|
||||
{
|
||||
0 => ItemGridPieceMarks.First,
|
||||
1 => ItemGridPieceMarks.Second,
|
||||
_ => null,
|
||||
}
|
||||
Marked = IsMarked(ent),
|
||||
};
|
||||
gridPiece.OnPiecePressed += OnPiecePressed;
|
||||
gridPiece.OnPieceUnpressed += OnPieceUnpressed;
|
||||
@@ -467,6 +489,16 @@ public sealed class StorageWindow : BaseWindow
|
||||
}
|
||||
}
|
||||
|
||||
private ItemGridPieceMarks? IsMarked(EntityUid uid)
|
||||
{
|
||||
return _contained.IndexOf(uid) switch
|
||||
{
|
||||
0 => ItemGridPieceMarks.First,
|
||||
1 => ItemGridPieceMarks.Second,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
@@ -486,8 +518,9 @@ public sealed class StorageWindow : BaseWindow
|
||||
{
|
||||
if (StorageEntity != null && _entity.System<StorageSystem>().NestedStorage)
|
||||
{
|
||||
// If parent container nests us then show back button
|
||||
if (containerSystem.TryGetContainingContainer(StorageEntity.Value, out var container) &&
|
||||
_entity.HasComponent<StorageComponent>(container.Owner))
|
||||
_entity.TryGetComponent(container.Owner, out StorageComponent? storageComp) && storageComp.Container.Contains(StorageEntity.Value))
|
||||
{
|
||||
_backButton.Visible = true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using Content.Shared.CCVar;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
@@ -37,6 +38,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
|
||||
[Dependency] private readonly IInputManager _input = default!;
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[UISystemDependency] private readonly StorageSystem _storage = default!;
|
||||
[UISystemDependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
|
||||
private readonly DragDropHelper<ItemGridPiece> _menuDragHelper;
|
||||
|
||||
@@ -59,39 +61,11 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
UIManager.OnScreenChanged += OnScreenChange;
|
||||
|
||||
_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
|
||||
_configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
|
||||
_configuration.OnValueChanged(CCVars.StorageWindowTitle, OnStorageWindowTitle, true);
|
||||
}
|
||||
|
||||
private void OnScreenChange((UIScreen? Old, UIScreen? New) obj)
|
||||
{
|
||||
// Handle reconnects with hotbargui.
|
||||
|
||||
// Essentially HotbarGui / the screen gets loaded AFTER gamestates at the moment (because clientgameticker manually changes it via event)
|
||||
// and changing this may be a massive change.
|
||||
// So instead we'll just manually reload it for now.
|
||||
if (!StaticStorageUIEnabled ||
|
||||
obj.New == null ||
|
||||
!EntityManager.TryGetComponent(_player.LocalEntity, out UserInterfaceUserComponent? userComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// UISystemDependency not injected at this point so do it the old fashion way, I love ordering issues.
|
||||
var uiSystem = EntityManager.System<SharedUserInterfaceSystem>();
|
||||
|
||||
foreach (var bui in uiSystem.GetActorUis((_player.LocalEntity.Value, userComp)))
|
||||
{
|
||||
if (!uiSystem.TryGetOpenUi<StorageBoundUserInterface>(bui.Entity, StorageComponent.StorageUiKey.Key, out var storageBui))
|
||||
continue;
|
||||
|
||||
storageBui.ReOpen();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStorageWindowTitle(bool obj)
|
||||
{
|
||||
WindowTitle = obj;
|
||||
@@ -107,7 +81,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
|
||||
StaticStorageUIEnabled = obj;
|
||||
}
|
||||
|
||||
public StorageWindow CreateStorageWindow(EntityUid uid)
|
||||
public StorageWindow CreateStorageWindow(StorageBoundUserInterface sBui)
|
||||
{
|
||||
var window = new StorageWindow();
|
||||
window.MouseFilter = Control.MouseFilterMode.Pass;
|
||||
@@ -127,9 +101,25 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
|
||||
}
|
||||
else
|
||||
{
|
||||
window.OpenCenteredLeft();
|
||||
// Open at parent position if it's open.
|
||||
if (_ui.TryGetOpenUi<StorageBoundUserInterface>(EntityManager.GetComponent<TransformComponent>(sBui.Owner).ParentUid,
|
||||
StorageComponent.StorageUiKey.Key, out var bui) && bui.Position != null)
|
||||
{
|
||||
window.Open(bui.Position.Value);
|
||||
}
|
||||
// Open at the saved position if it exists.
|
||||
else if (_ui.TryGetPosition(sBui.Owner, StorageComponent.StorageUiKey.Key, out var pos))
|
||||
{
|
||||
window.Open(pos);
|
||||
}
|
||||
// Open at the default position.
|
||||
else
|
||||
{
|
||||
window.OpenCenteredLeft();
|
||||
}
|
||||
}
|
||||
|
||||
_ui.RegisterControl(sBui, window);
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user