human.AddFunction(ContentKeyFunctions.OpenInventoryMenu);
human.AddFunction(ContentKeyFunctions.SmartEquipBackpack);
human.AddFunction(ContentKeyFunctions.SmartEquipBelt);
+ human.AddFunction(ContentKeyFunctions.OpenBackpack);
+ human.AddFunction(ContentKeyFunctions.OpenBelt);
human.AddFunction(ContentKeyFunctions.MouseMiddle);
human.AddFunction(ContentKeyFunctions.ArcadeUp);
human.AddFunction(ContentKeyFunctions.ArcadeDown);
AddHeader("ui-options-header-interaction-adv");
AddButton(ContentKeyFunctions.SmartEquipBackpack);
AddButton(ContentKeyFunctions.SmartEquipBelt);
+ AddButton(ContentKeyFunctions.OpenBackpack);
+ AddButton(ContentKeyFunctions.OpenBelt);
AddButton(ContentKeyFunctions.ThrowItemInHand);
AddButton(ContentKeyFunctions.TryPullObject);
AddButton(ContentKeyFunctions.MovePulledObject);
_storage = _entManager.System<StorageSystem>();
}
- protected override void Open()
- {
- base.Open();
-
- if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
- _storage.OpenStorageUI(Owner, comp);
- }
-
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
- _storage.CloseStorageUI(Owner);
+ _storage.CloseStorageWindow(Owner);
+ }
+
+ protected override void ReceiveMessage(BoundUserInterfaceMessage message)
+ {
+ base.ReceiveMessage(message);
+
+ if (message is StorageModifyWindowMessage)
+ {
+ if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
+ _storage.OpenStorageWindow((Owner, comp));
+ }
}
}
StorageUpdated?.Invoke((entity, entity.Comp));
}
- public void OpenStorageUI(EntityUid uid, StorageComponent component)
+ public void OpenStorageWindow(Entity<StorageComponent> entity)
{
- if (_openStorages.Contains((uid, component)))
+ if (_openStorages.Contains(entity))
+ {
+ if (_openStorages.LastOrDefault() == entity)
+ {
+ CloseStorageWindow((entity, entity.Comp));
+ }
+ else
+ {
+ var storages = new ValueList<Entity<StorageComponent>>(_openStorages);
+ var reverseStorages = storages.Reverse();
+
+ foreach (var storageEnt in reverseStorages)
+ {
+ if (storageEnt == entity)
+ break;
+
+ CloseStorageBoundUserInterface(storageEnt.Owner);
+ _openStorages.Remove(entity);
+ }
+ }
return;
+ }
- ClearNonParentStorages(uid);
- _openStorages.Add((uid, component));
+ ClearNonParentStorages(entity);
+ _openStorages.Add(entity);
Entity<StorageComponent>? last = _openStorages.LastOrDefault();
StorageOrderChanged?.Invoke(last);
}
- public void CloseStorageUI(Entity<StorageComponent?> entity)
+ public void CloseStorageWindow(Entity<StorageComponent?> entity)
{
if (!Resolve(entity, ref entity.Comp))
return;
private void OnShutdown(Entity<StorageComponent> ent, ref ComponentShutdown args)
{
- CloseStorageUI((ent, ent.Comp));
+ CloseStorageWindow((ent, ent.Comp));
}
/// <inheritdoc />
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Timing;
-using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Storage.Controls;
{
Close();
};
+ exitButton.OnKeyBindDown += args =>
+ {
+ // it just makes sense...
+ if (!args.Handled && args.Function == ContentKeyFunctions.ActivateItemInWorld)
+ {
+ Close();
+ args.Handle();
+ }
+ };
var exitContainer = new BoxContainer
{
Children =
if (StorageEntity == null)
return;
- _entity.System<StorageSystem>().CloseStorageUI(StorageEntity.Value);
+ _entity.System<StorageSystem>().CloseStorageWindow(StorageEntity.Value);
}
}
using Content.Shared.Explosion;
using Content.Shared.Ghost;
using Content.Shared.Hands;
+using Content.Shared.Input;
+using Content.Shared.Inventory;
using Content.Shared.Lock;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Timing;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
+using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
{
[Dependency] private readonly IAdminManager _admin = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
+ [Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
SubscribeLocalEvent<StorageComponent, BeforeExplodeEvent>(OnExploded);
SubscribeLocalEvent<StorageFillComponent, MapInitEvent>(OnStorageFillMapInit);
+
+ CommandBinds.Builder
+ .Bind(ContentKeyFunctions.OpenBackpack, InputCmdHandler.FromDelegate(HandleOpenBackpack))
+ .Bind(ContentKeyFunctions.OpenBelt, InputCmdHandler.FromDelegate(HandleOpenBelt))
+ .Register<StorageSystem>();
}
private void AddUiVerb(EntityUid uid, StorageComponent component, GetVerbsEvent<ActivationVerb> args)
/// <param name="entity">The entity to open the UI for</param>
public override void OpenStorageUI(EntityUid uid, EntityUid entity, StorageComponent? storageComp = null, bool silent = false)
{
- if (!Resolve(uid, ref storageComp) || !TryComp(entity, out ActorComponent? player))
+ if (!Resolve(uid, ref storageComp, false) || !TryComp(entity, out ActorComponent? player))
return;
// prevent spamming bag open / honkerton honk sound
Log.Debug($"Storage (UID {uid}) \"used\" by player session (UID {player.PlayerSession.AttachedEntity}).");
var bui = _uiSystem.GetUiOrNull(uid, StorageComponent.StorageUiKey.Key);
- if (bui != null)
- _uiSystem.OpenUi(bui, player.PlayerSession);
+ if (bui == null)
+ return;
+ _uiSystem.OpenUi(bui, player.PlayerSession);
+ _uiSystem.SendUiMessage(bui, new StorageModifyWindowMessage());
}
/// <inheritdoc />
}
}
}
+
+ private void HandleOpenBackpack(ICommonSession? session)
+ {
+ HandleOpenSlotUI(session, "back");
+ }
+
+ private void HandleOpenBelt(ICommonSession? session)
+ {
+ HandleOpenSlotUI(session, "belt");
+ }
+
+ private void HandleOpenSlotUI(ICommonSession? session, string slot)
+ {
+ if (session is not { } playerSession)
+ return;
+
+ if (playerSession.AttachedEntity is not {Valid: true} playerEnt || !Exists(playerEnt))
+ return;
+
+ if (!_inventory.TryGetSlotEntity(playerEnt, slot, out var storageEnt))
+ return;
+
+ if (!ActionBlocker.CanInteract(playerEnt, storageEnt))
+ return;
+
+ OpenStorageUI(storageEnt.Value, playerEnt);
+ }
}
public static readonly BoundKeyFunction OpenInventoryMenu = "OpenInventoryMenu";
public static readonly BoundKeyFunction SmartEquipBackpack = "SmartEquipBackpack";
public static readonly BoundKeyFunction SmartEquipBelt = "SmartEquipBelt";
+ public static readonly BoundKeyFunction OpenBackpack = "OpenBackpack";
+ public static readonly BoundKeyFunction OpenBelt = "OpenBelt";
public static readonly BoundKeyFunction OpenAHelp = "OpenAHelp";
public static readonly BoundKeyFunction SwapHands = "SwapHands";
public static readonly BoundKeyFunction MoveStoredItem = "MoveStoredItem";
[Dependency] protected readonly SharedItemSystem ItemSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedHandsSystem _sharedHandsSystem = default!;
- [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
+ [Dependency] protected readonly ActionBlockerSystem ActionBlocker = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] protected readonly SharedAudioSystem Audio = default!;
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
return;
}
- if (!_actionBlockerSystem.CanInteract(player, entity) || !storageComp.Container.Contains(entity))
+ if (!ActionBlocker.CanInteract(player, entity) || !storageComp.Container.Contains(entity))
return;
// Does the player have hands?
return;
}
- if (!_actionBlockerSystem.CanInteract(player, itemEnt))
+ if (!ActionBlocker.CanInteract(player, itemEnt))
return;
TrySetItemStorageLocation((itemEnt, null), (storageEnt, storageComp), msg.Location);
return;
}
- if (!_actionBlockerSystem.CanInteract(player, itemEnt) || !_sharedHandsSystem.IsHolding(player, itemEnt, out _))
+ if (!ActionBlocker.CanInteract(player, itemEnt) || !_sharedHandsSystem.IsHolding(player, itemEnt, out _))
return;
InsertAt((storageEnt, storageComp), (itemEnt, null), msg.Location, out _, player, stackAutomatically: false);
}
}
+ /// <summary>
+ /// An extra BUI message that either opens, closes, or focuses the storage window based on context.
+ /// </summary>
+ [Serializable, NetSerializable]
+ public sealed class StorageModifyWindowMessage : BoundUserInterfaceMessage
+ {
+
+ }
+
[NetSerializable]
[Serializable]
public enum StorageVisuals : byte
ui-options-function-smart-equip-backpack = Smart-equip to backpack
ui-options-function-smart-equip-belt = Smart-equip to belt
+ui-options-function-open-backpack = Open backpack
+ui-options-function-open-belt = Open belt
ui-options-function-throw-item-in-hand = Throw item
ui-options-function-try-pull-object = Pull object
ui-options-function-move-pulled-object = Move pulled object
type: State
key: E
mod1: Shift
+- function: OpenBackpack
+ type: State
+ key: V
+- function: OpenBelt
+ type: State
+ key: V
+ mod1: Shift
- function: ShowDebugConsole
type: State
key: Tilde