Grid inventory fixes (#22161)

* Gridinv fixes

* eek

* oh yeah this too

* eek
This commit is contained in:
Nemanja
2023-12-05 18:38:10 -05:00
committed by GitHub
parent 000ac6f63d
commit 9ca84ac3fb
10 changed files with 136 additions and 46 deletions

View File

@@ -22,6 +22,7 @@
</BoxContainer> </BoxContainer>
<CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" /> <CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" />
<CheckBox Name="ShowCombatModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-combat-mode-indicators'}" /> <CheckBox Name="ShowCombatModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-combat-mode-indicators'}" />
<CheckBox Name="OpaqueStorageWindowCheckBox" Text="{Loc 'ui-options-opaque-storage-window'}" />
<CheckBox Name="ShowLoocAboveHeadCheckBox" Text="{Loc 'ui-options-show-looc-on-head'}" /> <CheckBox Name="ShowLoocAboveHeadCheckBox" Text="{Loc 'ui-options-show-looc-on-head'}" />
<CheckBox Name="FancySpeechBubblesCheckBox" Text="{Loc 'ui-options-fancy-speech'}" /> <CheckBox Name="FancySpeechBubblesCheckBox" Text="{Loc 'ui-options-fancy-speech'}" />
<CheckBox Name="FancyNameBackgroundsCheckBox" Text="{Loc 'ui-options-fancy-name-background'}" /> <CheckBox Name="FancyNameBackgroundsCheckBox" Text="{Loc 'ui-options-fancy-name-background'}" />

View File

@@ -103,6 +103,8 @@ namespace Content.Client.Options.UI.Tabs
ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled; ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled;
ShowCombatModeIndicatorsCheckBox.OnToggled += OnCheckBoxToggled; ShowCombatModeIndicatorsCheckBox.OnToggled += OnCheckBoxToggled;
OpaqueStorageWindowCheckBox.OnToggled += OnCheckBoxToggled;
ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled; ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
FancySpeechBubblesCheckBox.OnToggled += OnCheckBoxToggled; FancySpeechBubblesCheckBox.OnToggled += OnCheckBoxToggled;
FancyNameBackgroundsCheckBox.OnToggled += OnCheckBoxToggled; FancyNameBackgroundsCheckBox.OnToggled += OnCheckBoxToggled;
@@ -124,6 +126,7 @@ namespace Content.Client.Options.UI.Tabs
FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible); FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible);
ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow); ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow);
ShowCombatModeIndicatorsCheckBox.Pressed = _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow); ShowCombatModeIndicatorsCheckBox.Pressed = _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
OpaqueStorageWindowCheckBox.Pressed = _cfg.GetCVar(CCVars.OpaqueStorageWindow);
ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow); ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow);
FancySpeechBubblesCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableFancyBubbles); FancySpeechBubblesCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
FancyNameBackgroundsCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatFancyNameBackground); FancyNameBackgroundsCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatFancyNameBackground);
@@ -174,6 +177,7 @@ namespace Content.Client.Options.UI.Tabs
_cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed); _cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed);
_cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed); _cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed);
_cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed); _cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed);
_cfg.SetCVar(CCVars.OpaqueStorageWindow, OpaqueStorageWindowCheckBox.Pressed);
_cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed); _cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox.Pressed); _cfg.SetCVar(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox.Pressed); _cfg.SetCVar(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox.Pressed);
@@ -214,6 +218,7 @@ namespace Content.Client.Options.UI.Tabs
var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality); var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow); var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow);
var isCombatModeIndicatorsSame = ShowCombatModeIndicatorsCheckBox.Pressed == _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow); var isCombatModeIndicatorsSame = ShowCombatModeIndicatorsCheckBox.Pressed == _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
var isOpaqueStorageWindow = OpaqueStorageWindowCheckBox.Pressed == _cfg.GetCVar(CCVars.OpaqueStorageWindow);
var isLoocShowSame = ShowLoocAboveHeadCheckBox.Pressed == _cfg.GetCVar(CCVars.LoocAboveHeadShow); var isLoocShowSame = ShowLoocAboveHeadCheckBox.Pressed == _cfg.GetCVar(CCVars.LoocAboveHeadShow);
var isFancyChatSame = FancySpeechBubblesCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableFancyBubbles); var isFancyChatSame = FancySpeechBubblesCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
var isFancyBackgroundSame = FancyNameBackgroundsCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatFancyNameBackground); var isFancyBackgroundSame = FancyNameBackgroundsCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatFancyNameBackground);
@@ -233,6 +238,7 @@ namespace Content.Client.Options.UI.Tabs
isHudThemeSame && isHudThemeSame &&
isShowHeldItemSame && isShowHeldItemSame &&
isCombatModeIndicatorsSame && isCombatModeIndicatorsSame &&
isOpaqueStorageWindow &&
isLoocShowSame && isLoocShowSame &&
isFancyChatSame && isFancyChatSame &&
isFancyBackgroundSame && isFancyBackgroundSame &&

View File

@@ -1,9 +1,7 @@
using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Client.Items.Systems; using Content.Client.Items.Systems;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
@@ -12,8 +10,7 @@ namespace Content.Client.UserInterface.Systems.Storage.Controls;
public sealed class ItemGridPiece : Control public sealed class ItemGridPiece : Control
{ {
private readonly ItemSystem _itemSystem; private readonly IEntityManager _entityManager;
private readonly SpriteSystem _spriteSystem;
private readonly StorageUIController _storageController; private readonly StorageUIController _storageController;
private readonly List<(Texture, Vector2)> _texturesPositions = new(); private readonly List<(Texture, Vector2)> _texturesPositions = new();
@@ -49,8 +46,7 @@ public sealed class ItemGridPiece : Control
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
_itemSystem = entityManager.System<ItemSystem>(); _entityManager = entityManager;
_spriteSystem = entityManager.System<SpriteSystem>();
_storageController = UserInterfaceManager.GetUIController<StorageUIController>(); _storageController = UserInterfaceManager.GetUIController<StorageUIController>();
Entity = entity.Owner; Entity = entity.Owner;
@@ -81,10 +77,17 @@ public sealed class ItemGridPiece : Control
{ {
base.Draw(handle); base.Draw(handle);
// really just an "oh shit" catch.
if (!_entityManager.EntityExists(Entity))
{
Dispose();
return;
}
if (_storageController.IsDragging && _storageController.CurrentlyDragging == this) if (_storageController.IsDragging && _storageController.CurrentlyDragging == this)
return; return;
var adjustedShape = _itemSystem.GetAdjustedItemShape((Entity, null), Location.Rotation, Vector2i.Zero); var adjustedShape = _entityManager.System<ItemSystem>().GetAdjustedItemShape((Entity, null), Location.Rotation, Vector2i.Zero);
var boundingGrid = adjustedShape.GetBoundingBox(); var boundingGrid = adjustedShape.GetBoundingBox();
var size = _centerTexture!.Size * 2 * UIScale; var size = _centerTexture!.Size * 2 * UIScale;
@@ -130,7 +133,7 @@ public sealed class ItemGridPiece : Control
var iconOffset = new Vector2((boundingGrid.Width + 1) * size.X , var iconOffset = new Vector2((boundingGrid.Width + 1) * size.X ,
(boundingGrid.Height + 1) * size.Y); (boundingGrid.Height + 1) * size.Y);
_spriteSystem.ForceUpdate(Entity); _entityManager.System<SpriteSystem>().ForceUpdate(Entity);
handle.DrawEntity(Entity, handle.DrawEntity(Entity,
PixelPosition + iconOffset, PixelPosition + iconOffset,
Vector2.One * 2 * UIScale, Vector2.One * 2 * UIScale,

View File

@@ -34,6 +34,10 @@ public sealed class StorageContainer : BaseWindow
private Texture? _emptyTexture; private Texture? _emptyTexture;
private readonly string _blockedTexturePath = "Storage/tile_blocked"; private readonly string _blockedTexturePath = "Storage/tile_blocked";
private Texture? _blockedTexture; private Texture? _blockedTexture;
private readonly string _emptyOpaqueTexturePath = "Storage/tile_empty_opaque";
private Texture? _emptyOpaqueTexture;
private readonly string _blockedOpaqueTexturePath = "Storage/tile_blocked_opaque";
private Texture? _blockedOpaqueTexture;
private readonly string _exitTexturePath = "Storage/exit"; private readonly string _exitTexturePath = "Storage/exit";
private Texture? _exitTexture; private Texture? _exitTexture;
private readonly string _backTexturePath = "Storage/back"; private readonly string _backTexturePath = "Storage/back";
@@ -109,6 +113,8 @@ public sealed class StorageContainer : BaseWindow
_emptyTexture = Theme.ResolveTextureOrNull(_emptyTexturePath)?.Texture; _emptyTexture = Theme.ResolveTextureOrNull(_emptyTexturePath)?.Texture;
_blockedTexture = Theme.ResolveTextureOrNull(_blockedTexturePath)?.Texture; _blockedTexture = Theme.ResolveTextureOrNull(_blockedTexturePath)?.Texture;
_emptyOpaqueTexture = Theme.ResolveTextureOrNull(_emptyOpaqueTexturePath)?.Texture;
_blockedOpaqueTexture = Theme.ResolveTextureOrNull(_blockedOpaqueTexturePath)?.Texture;
_exitTexture = Theme.ResolveTextureOrNull(_exitTexturePath)?.Texture; _exitTexture = Theme.ResolveTextureOrNull(_exitTexturePath)?.Texture;
_backTexture = Theme.ResolveTextureOrNull(_backTexturePath)?.Texture; _backTexture = Theme.ResolveTextureOrNull(_backTexturePath)?.Texture;
_sidebarTopTexture = Theme.ResolveTextureOrNull(_sidebarTopTexturePath)?.Texture; _sidebarTopTexture = Theme.ResolveTextureOrNull(_sidebarTopTexturePath)?.Texture;
@@ -124,35 +130,17 @@ public sealed class StorageContainer : BaseWindow
if (entity == null) if (entity == null)
return; return;
BuildGridRepresentation(entity.Value); BuildGridRepresentation();
} }
private void BuildGridRepresentation(Entity<StorageComponent> entity) private void BuildGridRepresentation()
{ {
var comp = entity.Comp; if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var comp) || !comp.Grid.Any())
if (!comp.Grid.Any())
return; return;
var boundingGrid = comp.Grid.GetBoundingBox(); var boundingGrid = comp.Grid.GetBoundingBox();
_backgroundGrid.Children.Clear(); BuildBackground();
_backgroundGrid.Rows = boundingGrid.Height + 1;
_backgroundGrid.Columns = boundingGrid.Width + 1;
for (var y = boundingGrid.Bottom; y <= boundingGrid.Top; y++)
{
for (var x = boundingGrid.Left; x <= boundingGrid.Right; x++)
{
var texture = comp.Grid.Contains(x, y)
? _emptyTexture
: _blockedTexture;
_backgroundGrid.AddChild(new TextureRect
{
Texture = texture,
TextureScale = new Vector2(2, 2)
});
}
}
#region Sidebar #region Sidebar
_sidebar.Children.Clear(); _sidebar.Children.Clear();
@@ -209,6 +197,40 @@ public sealed class StorageContainer : BaseWindow
BuildItemPieces(); BuildItemPieces();
} }
public void BuildBackground()
{
if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var comp) || !comp.Grid.Any())
return;
var boundingGrid = comp.Grid.GetBoundingBox();
var emptyTexture = _storageController.OpaqueStorageWindow
? _emptyOpaqueTexture
: _emptyTexture;
var blockedTexture = _storageController.OpaqueStorageWindow
? _blockedOpaqueTexture
: _blockedTexture;
_backgroundGrid.Children.Clear();
_backgroundGrid.Rows = boundingGrid.Height + 1;
_backgroundGrid.Columns = boundingGrid.Width + 1;
for (var y = boundingGrid.Bottom; y <= boundingGrid.Top; y++)
{
for (var x = boundingGrid.Left; x <= boundingGrid.Right; x++)
{
var texture = comp.Grid.Contains(x, y)
? emptyTexture
: blockedTexture;
_backgroundGrid.AddChild(new TextureRect
{
Texture = texture,
TextureScale = new Vector2(2, 2)
});
}
}
}
public void BuildItemPieces() public void BuildItemPieces()
{ {
if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var storageComp)) if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var storageComp))
@@ -320,7 +342,7 @@ public sealed class StorageContainer : BaseWindow
origin, origin,
currentLocation.Rotation); currentLocation.Rotation);
var validColor = usingInHand ? Color.Goldenrod : Color.Green; var validColor = usingInHand ? Color.Goldenrod : Color.FromHex("#1E8000");
for (var y = itemBounding.Bottom; y <= itemBounding.Top; y++) for (var y = itemBounding.Bottom; y <= itemBounding.Top; y++)
{ {
@@ -328,7 +350,7 @@ public sealed class StorageContainer : BaseWindow
{ {
if (TryGetBackgroundCell(x, y, out var cell) && itemShape.Contains(x, y)) if (TryGetBackgroundCell(x, y, out var cell) && itemShape.Contains(x, y))
{ {
cell.ModulateSelfOverride = validLocation ? validColor : Color.Red; cell.ModulateSelfOverride = validLocation ? validColor : Color.FromHex("#B40046");
} }
} }
} }

View File

@@ -38,6 +38,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
public ItemGridPiece? DraggingGhost; public ItemGridPiece? DraggingGhost;
public Angle DraggingRotation = Angle.Zero; public Angle DraggingRotation = Angle.Zero;
public bool StaticStorageUIEnabled; public bool StaticStorageUIEnabled;
public bool OpaqueStorageWindow;
public bool IsDragging => _menuDragHelper.IsDragging; public bool IsDragging => _menuDragHelper.IsDragging;
public ItemGridPiece? CurrentlyDragging => _menuDragHelper.Dragged; public ItemGridPiece? CurrentlyDragging => _menuDragHelper.Dragged;
@@ -52,6 +53,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
base.Initialize(); base.Initialize();
_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true); _configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
_configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
} }
public void OnSystemLoaded(StorageSystem system) public void OnSystemLoaded(StorageSystem system)
@@ -80,7 +82,13 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
if (nullEnt is not null) if (nullEnt is not null)
{ {
if (_lastContainerPosition == null) // center it if we knock it off screen somehow.
if (!StaticStorageUIEnabled &&
(_lastContainerPosition == null ||
_lastContainerPosition.Value.X < 0 ||
_lastContainerPosition.Value.Y < 0 ||
_lastContainerPosition.Value.X > _ui.WindowRoot.Width ||
_lastContainerPosition.Value.Y > _ui.WindowRoot.Height))
{ {
_container.OpenCenteredAt(new Vector2(0.5f, 0.75f)); _container.OpenCenteredAt(new Vector2(0.5f, 0.75f));
} }
@@ -88,8 +96,11 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
{ {
_container.Open(); _container.Open();
if (!StaticStorageUIEnabled) var pos = !StaticStorageUIEnabled && _lastContainerPosition != null
LayoutContainer.SetPosition(_container, _lastContainerPosition.Value); ? _lastContainerPosition.Value
: Vector2.Zero;
LayoutContainer.SetPosition(_container, pos);
} }
if (StaticStorageUIEnabled) if (StaticStorageUIEnabled)
@@ -98,6 +109,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
_container.Orphan(); _container.Orphan();
Hotbar?.StorageContainer.AddChild(_container); Hotbar?.StorageContainer.AddChild(_container);
} }
_lastContainerPosition = _container.GlobalPosition;
} }
else else
{ {
@@ -112,6 +124,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
return; return;
StaticStorageUIEnabled = obj; StaticStorageUIEnabled = obj;
_lastContainerPosition = null;
if (_container == null) if (_container == null)
return; return;
@@ -123,12 +136,22 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
if (StaticStorageUIEnabled) if (StaticStorageUIEnabled)
{ {
Hotbar?.StorageContainer.AddChild(_container); Hotbar?.StorageContainer.AddChild(_container);
_lastContainerPosition = null;
} }
else else
{ {
_ui.WindowRoot.AddChild(_container); _ui.WindowRoot.AddChild(_container);
} }
if (_entity.TryGetComponent<StorageComponent>(_container.StorageEntity, out var comp))
OnStorageOrderChanged((_container.StorageEntity.Value, comp));
}
private void OnOpaqueWindowChanged(bool obj)
{
if (OpaqueStorageWindow == obj)
return;
OpaqueStorageWindow = obj;
_container?.BuildBackground();
} }
/// One might ask, Hey Emo, why are you parsing raw keyboard input just to rotate a rectangle? /// One might ask, Hey Emo, why are you parsing raw keyboard input just to rotate a rectangle?
@@ -321,7 +344,7 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
_menuDragHelper.Update(args.DeltaSeconds); _menuDragHelper.Update(args.DeltaSeconds);
if (!StaticStorageUIEnabled && _container?.Parent != null) if (!StaticStorageUIEnabled && _container?.Parent != null && _lastContainerPosition != null)
_lastContainerPosition = _container.GlobalPosition; _lastContainerPosition = _container.GlobalPosition;
} }
} }

View File

@@ -1661,12 +1661,22 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> ToggleWalk = public static readonly CVarDef<bool> ToggleWalk =
CVarDef.Create("control.toggle_walk", false, CVar.CLIENTONLY | CVar.ARCHIVE); CVarDef.Create("control.toggle_walk", false, CVar.CLIENTONLY | CVar.ARCHIVE);
/*
* STORAGE
*/
/// <summary> /// <summary>
/// Whether or not the storage UI is static and bound to the hotbar, or unbound and allowed to be dragged anywhere. /// Whether or not the storage UI is static and bound to the hotbar, or unbound and allowed to be dragged anywhere.
/// </summary> /// </summary>
public static readonly CVarDef<bool> StaticStorageUI = public static readonly CVarDef<bool> StaticStorageUI =
CVarDef.Create("control.static_storage_ui", true, CVar.CLIENTONLY | CVar.ARCHIVE); CVarDef.Create("control.static_storage_ui", true, CVar.CLIENTONLY | CVar.ARCHIVE);
/// <summary>
/// Whether or not the storage window uses a transparent or opaque sprite.
/// </summary>
public static readonly CVarDef<bool> OpaqueStorageWindow =
CVarDef.Create("control.opaque_storage_background", false, CVar.CLIENTONLY | CVar.ARCHIVE);
/* /*
* UPDATE * UPDATE
*/ */

View File

@@ -407,7 +407,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (!_actionBlockerSystem.CanInteract(player, itemEnt) || !_sharedHandsSystem.IsHolding(player, itemEnt, out _)) if (!_actionBlockerSystem.CanInteract(player, itemEnt) || !_sharedHandsSystem.IsHolding(player, itemEnt, out _))
return; return;
InsertAt((storageEnt, storageComp), (itemEnt, null), msg.Location, out _, player); InsertAt((storageEnt, storageComp), (itemEnt, null), msg.Location, out _, player, stackAutomatically: false);
} }
private void OnBoundUIOpen(EntityUid uid, StorageComponent storageComp, BoundUIOpenedEvent args) private void OnBoundUIOpen(EntityUid uid, StorageComponent storageComp, BoundUIOpenedEvent args)
@@ -465,7 +465,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId) if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId)
return; return;
if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true)) if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true, includeContainerChecks: false))
args.Cancel(); args.Cancel();
} }
@@ -534,7 +534,8 @@ public abstract class SharedStorageSystem : EntitySystem
StorageComponent? storageComp = null, StorageComponent? storageComp = null,
ItemComponent? item = null, ItemComponent? item = null,
bool ignoreStacks = false, bool ignoreStacks = false,
bool ignoreLocation = false) bool ignoreLocation = false,
bool includeContainerChecks = true)
{ {
if (!Resolve(uid, ref storageComp) || !Resolve(insertEnt, ref item, false)) if (!Resolve(uid, ref storageComp) || !Resolve(insertEnt, ref item, false))
{ {
@@ -591,6 +592,12 @@ public abstract class SharedStorageSystem : EntitySystem
} }
} }
if (includeContainerChecks && !_containerSystem.CanInsert(insertEnt, storageComp.Container))
{
reason = null;
return false;
}
reason = null; reason = null;
return true; return true;
} }
@@ -606,7 +613,8 @@ public abstract class SharedStorageSystem : EntitySystem
ItemStorageLocation location, ItemStorageLocation location,
out EntityUid? stackedEntity, out EntityUid? stackedEntity,
EntityUid? user = null, EntityUid? user = null,
bool playSound = true) bool playSound = true,
bool stackAutomatically = true)
{ {
stackedEntity = null; stackedEntity = null;
if (!Resolve(uid, ref uid.Comp)) if (!Resolve(uid, ref uid.Comp))
@@ -617,7 +625,21 @@ public abstract class SharedStorageSystem : EntitySystem
uid.Comp.StoredItems[GetNetEntity(insertEnt)] = location; uid.Comp.StoredItems[GetNetEntity(insertEnt)] = location;
Dirty(uid, uid.Comp); Dirty(uid, uid.Comp);
return Insert(uid, insertEnt, out stackedEntity, out _, user: user, storageComp: uid.Comp, playSound: playSound);
if (Insert(uid,
insertEnt,
out stackedEntity,
out _,
user: user,
storageComp: uid.Comp,
playSound: playSound,
stackAutomatically: stackAutomatically))
{
return true;
}
uid.Comp.StoredItems.Remove(GetNetEntity(insertEnt));
return false;
} }
/// <summary> /// <summary>
@@ -631,9 +653,10 @@ public abstract class SharedStorageSystem : EntitySystem
out EntityUid? stackedEntity, out EntityUid? stackedEntity,
EntityUid? user = null, EntityUid? user = null,
StorageComponent? storageComp = null, StorageComponent? storageComp = null,
bool playSound = true) bool playSound = true,
bool stackAutomatically = true)
{ {
return Insert(uid, insertEnt, out stackedEntity, out _, user: user, storageComp: storageComp, playSound: playSound); return Insert(uid, insertEnt, out stackedEntity, out _, user: user, storageComp: storageComp, playSound: playSound, stackAutomatically: stackAutomatically);
} }
/// <summary> /// <summary>
@@ -648,7 +671,8 @@ public abstract class SharedStorageSystem : EntitySystem
out string? reason, out string? reason,
EntityUid? user = null, EntityUid? user = null,
StorageComponent? storageComp = null, StorageComponent? storageComp = null,
bool playSound = true) bool playSound = true,
bool stackAutomatically = true)
{ {
stackedEntity = null; stackedEntity = null;
reason = null; reason = null;
@@ -665,7 +689,7 @@ public abstract class SharedStorageSystem : EntitySystem
* For now we just treat items as always being the same size regardless of stack count. * For now we just treat items as always being the same size regardless of stack count.
*/ */
if (!_stackQuery.TryGetComponent(insertEnt, out var insertStack)) if (!stackAutomatically || !_stackQuery.TryGetComponent(insertEnt, out var insertStack))
{ {
if (!_containerSystem.Insert(insertEnt, storageComp.Container)) if (!_containerSystem.Insert(insertEnt, storageComp.Container))
return false; return false;

View File

@@ -29,6 +29,7 @@ ui-options-volume-percent = { TOSTRING($volume, "P0") }
ui-options-show-held-item = Show held item next to cursor? ui-options-show-held-item = Show held item next to cursor?
ui-options-show-combat-mode-indicators = Show combat mode indicators with cursor? ui-options-show-combat-mode-indicators = Show combat mode indicators with cursor?
ui-options-opaque-storage-window = Enable opaque storage window?
ui-options-show-looc-on-head = Show LOOC chat above characters head? ui-options-show-looc-on-head = Show LOOC chat above characters head?
ui-options-fancy-speech = Show names in speech bubbles? ui-options-fancy-speech = Show names in speech bubbles?
ui-options-fancy-name-background = Add background to speech bubble names? ui-options-fancy-name-background = Add background to speech bubble names?

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B