</BoxContainer>
<CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" />
<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="FancySpeechBubblesCheckBox" Text="{Loc 'ui-options-fancy-speech'}" />
<CheckBox Name="FancyNameBackgroundsCheckBox" Text="{Loc 'ui-options-fancy-name-background'}" />
ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled;
ShowCombatModeIndicatorsCheckBox.OnToggled += OnCheckBoxToggled;
+ OpaqueStorageWindowCheckBox.OnToggled += OnCheckBoxToggled;
+ ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
FancySpeechBubblesCheckBox.OnToggled += OnCheckBoxToggled;
FancyNameBackgroundsCheckBox.OnToggled += OnCheckBoxToggled;
FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible);
ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow);
ShowCombatModeIndicatorsCheckBox.Pressed = _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
+ OpaqueStorageWindowCheckBox.Pressed = _cfg.GetCVar(CCVars.OpaqueStorageWindow);
ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow);
FancySpeechBubblesCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
FancyNameBackgroundsCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatFancyNameBackground);
_cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed);
_cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed);
_cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed);
+ _cfg.SetCVar(CCVars.OpaqueStorageWindow, OpaqueStorageWindowCheckBox.Pressed);
_cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox.Pressed);
var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow);
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 isFancyChatSame = FancySpeechBubblesCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
var isFancyBackgroundSame = FancyNameBackgroundsCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatFancyNameBackground);
isHudThemeSame &&
isShowHeldItemSame &&
isCombatModeIndicatorsSame &&
+ isOpaqueStorageWindow &&
isLoocShowSame &&
isFancyChatSame &&
isFancyBackgroundSame &&
-using System.Linq;
using System.Numerics;
using Content.Client.Items.Systems;
using Content.Shared.Item;
using Content.Shared.Storage;
-using Content.Shared.Storage.EntitySystems;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
public sealed class ItemGridPiece : Control
{
- private readonly ItemSystem _itemSystem;
- private readonly SpriteSystem _spriteSystem;
+ private readonly IEntityManager _entityManager;
private readonly StorageUIController _storageController;
private readonly List<(Texture, Vector2)> _texturesPositions = new();
{
IoCManager.InjectDependencies(this);
- _itemSystem = entityManager.System<ItemSystem>();
- _spriteSystem = entityManager.System<SpriteSystem>();
+ _entityManager = entityManager;
_storageController = UserInterfaceManager.GetUIController<StorageUIController>();
Entity = entity.Owner;
{
base.Draw(handle);
+ // really just an "oh shit" catch.
+ if (!_entityManager.EntityExists(Entity))
+ {
+ Dispose();
+ return;
+ }
+
if (_storageController.IsDragging && _storageController.CurrentlyDragging == this)
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 size = _centerTexture!.Size * 2 * UIScale;
var iconOffset = new Vector2((boundingGrid.Width + 1) * size.X ,
(boundingGrid.Height + 1) * size.Y);
- _spriteSystem.ForceUpdate(Entity);
+ _entityManager.System<SpriteSystem>().ForceUpdate(Entity);
handle.DrawEntity(Entity,
PixelPosition + iconOffset,
Vector2.One * 2 * UIScale,
private Texture? _emptyTexture;
private readonly string _blockedTexturePath = "Storage/tile_blocked";
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 Texture? _exitTexture;
private readonly string _backTexturePath = "Storage/back";
_emptyTexture = Theme.ResolveTextureOrNull(_emptyTexturePath)?.Texture;
_blockedTexture = Theme.ResolveTextureOrNull(_blockedTexturePath)?.Texture;
+ _emptyOpaqueTexture = Theme.ResolveTextureOrNull(_emptyOpaqueTexturePath)?.Texture;
+ _blockedOpaqueTexture = Theme.ResolveTextureOrNull(_blockedOpaqueTexturePath)?.Texture;
_exitTexture = Theme.ResolveTextureOrNull(_exitTexturePath)?.Texture;
_backTexture = Theme.ResolveTextureOrNull(_backTexturePath)?.Texture;
_sidebarTopTexture = Theme.ResolveTextureOrNull(_sidebarTopTexturePath)?.Texture;
if (entity == null)
return;
- BuildGridRepresentation(entity.Value);
+ BuildGridRepresentation();
}
- private void BuildGridRepresentation(Entity<StorageComponent> entity)
+ private void BuildGridRepresentation()
{
- var comp = entity.Comp;
- if (!comp.Grid.Any())
+ if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var comp) || !comp.Grid.Any())
return;
var boundingGrid = comp.Grid.GetBoundingBox();
- _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)
- });
- }
- }
+ BuildBackground();
#region Sidebar
_sidebar.Children.Clear();
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()
{
if (!_entity.TryGetComponent<StorageComponent>(StorageEntity, out var storageComp))
origin,
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++)
{
{
if (TryGetBackgroundCell(x, y, out var cell) && itemShape.Contains(x, y))
{
- cell.ModulateSelfOverride = validLocation ? validColor : Color.Red;
+ cell.ModulateSelfOverride = validLocation ? validColor : Color.FromHex("#B40046");
}
}
}
public ItemGridPiece? DraggingGhost;
public Angle DraggingRotation = Angle.Zero;
public bool StaticStorageUIEnabled;
+ public bool OpaqueStorageWindow;
public bool IsDragging => _menuDragHelper.IsDragging;
public ItemGridPiece? CurrentlyDragging => _menuDragHelper.Dragged;
base.Initialize();
_configuration.OnValueChanged(CCVars.StaticStorageUI, OnStaticStorageChanged, true);
+ _configuration.OnValueChanged(CCVars.OpaqueStorageWindow, OnOpaqueWindowChanged, true);
}
public void OnSystemLoaded(StorageSystem system)
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.Open();
- if (!StaticStorageUIEnabled)
- LayoutContainer.SetPosition(_container, _lastContainerPosition.Value);
+ var pos = !StaticStorageUIEnabled && _lastContainerPosition != null
+ ? _lastContainerPosition.Value
+ : Vector2.Zero;
+
+ LayoutContainer.SetPosition(_container, pos);
}
if (StaticStorageUIEnabled)
_container.Orphan();
Hotbar?.StorageContainer.AddChild(_container);
}
+ _lastContainerPosition = _container.GlobalPosition;
}
else
{
return;
StaticStorageUIEnabled = obj;
+ _lastContainerPosition = null;
if (_container == null)
return;
if (StaticStorageUIEnabled)
{
Hotbar?.StorageContainer.AddChild(_container);
- _lastContainerPosition = null;
}
else
{
_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?
_menuDragHelper.Update(args.DeltaSeconds);
- if (!StaticStorageUIEnabled && _container?.Parent != null)
+ if (!StaticStorageUIEnabled && _container?.Parent != null && _lastContainerPosition != null)
_lastContainerPosition = _container.GlobalPosition;
}
}
public static readonly CVarDef<bool> ToggleWalk =
CVarDef.Create("control.toggle_walk", false, CVar.CLIENTONLY | CVar.ARCHIVE);
+ /*
+ * STORAGE
+ */
+
/// <summary>
/// Whether or not the storage UI is static and bound to the hotbar, or unbound and allowed to be dragged anywhere.
/// </summary>
public static readonly CVarDef<bool> StaticStorageUI =
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
*/
if (!_actionBlockerSystem.CanInteract(player, itemEnt) || !_sharedHandsSystem.IsHolding(player, itemEnt, out _))
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)
if (args.Cancelled || args.Container.ID != StorageComponent.ContainerId)
return;
- if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true))
+ if (!CanInsert(uid, args.EntityUid, out _, component, ignoreStacks: true, includeContainerChecks: false))
args.Cancel();
}
StorageComponent? storageComp = null,
ItemComponent? item = null,
bool ignoreStacks = false,
- bool ignoreLocation = false)
+ bool ignoreLocation = false,
+ bool includeContainerChecks = true)
{
if (!Resolve(uid, ref storageComp) || !Resolve(insertEnt, ref item, false))
{
}
}
+ if (includeContainerChecks && !_containerSystem.CanInsert(insertEnt, storageComp.Container))
+ {
+ reason = null;
+ return false;
+ }
+
reason = null;
return true;
}
ItemStorageLocation location,
out EntityUid? stackedEntity,
EntityUid? user = null,
- bool playSound = true)
+ bool playSound = true,
+ bool stackAutomatically = true)
{
stackedEntity = null;
if (!Resolve(uid, ref uid.Comp))
uid.Comp.StoredItems[GetNetEntity(insertEnt)] = location;
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>
out EntityUid? stackedEntity,
EntityUid? user = 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>
out string? reason,
EntityUid? user = null,
StorageComponent? storageComp = null,
- bool playSound = true)
+ bool playSound = true,
+ bool stackAutomatically = true)
{
stackedEntity = null;
reason = null;
* 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))
return false;
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-opaque-storage-window = Enable opaque storage window?
ui-options-show-looc-on-head = Show LOOC chat above characters head?
ui-options-fancy-speech = Show names in speech bubbles?
ui-options-fancy-name-background = Add background to speech bubble names?