-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guns shoot on drop, Smart Fridge & Flags from Corvax-Next (#987)
* Cringe fridge try 2(#177) * SmartCringe * JustCringe * [Port] Flags (#156) Флаги разных государств * Электрический стул. (#148) * ExeCute * fix? * nope * fix: formatting - remove useless comments - if statement in OnSignalRecieved() should be handled in switch-case - Logger class shouldn't be used in logging, there is sawmills for this - Remove unnecessary methods * some more shit * wrong author --------- Co-authored-by: JerryImMouse <[email protected]> * [Port] Случайные выстрелы при падении оружия (#147) * FireOnDrop * whoopsy * Port TapeRecorder (#129) * some fixes * Update lathe.yml * Revert "Update lathe.yml" This reverts commit df65820. * Revert "some fixes" This reverts commit 97187a6. * Revert "Port TapeRecorder (#129)" This reverts commit d7cc749. * Revert "Электрический стул. (#148)" This reverts commit 657b154. * raz * Update RobustToolbox * Fix --------- Co-authored-by: Kill_Me_I_Noobs <[email protected]> Co-authored-by: PuroSlavKing <[email protected]> Co-authored-by: JerryImMouse <[email protected]> Co-authored-by: Rouden <[email protected]> Co-authored-by: Roudenn <[email protected]>
- Loading branch information
1 parent
89bcf75
commit 5d35a3e
Showing
41 changed files
with
927 additions
and
20 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Content.Client/Backmen/Medical/SmartFridge/SmartFridgeBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Input; | ||
using System.Linq; | ||
using Content.Shared.Backmen.Medical.SmartFridge; | ||
using SmartFridgeMenu = Content.Client.Backmen.Medical.SmartFridge.UI.SmartFridgeMenu; | ||
|
||
namespace Content.Client.Backmen.Medical.SmartFridge; | ||
|
||
public sealed class SmartFridgeBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) | ||
{ | ||
[ViewVariables] | ||
private SmartFridgeMenu? _menu; | ||
|
||
[ViewVariables] | ||
private List<SmartFridgeInventoryItem> _cachedInventory = []; | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_menu = this.CreateWindow<SmartFridgeMenu>(); | ||
_menu.OpenCenteredLeft(); | ||
_menu.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName; | ||
_menu.OnItemSelected += OnItemSelected; | ||
Refresh(); | ||
} | ||
|
||
public void Refresh() | ||
{ | ||
var system = EntMan.System<SmartFridgeSystem>(); | ||
_cachedInventory = system.GetInventoryClient(Owner); | ||
|
||
_menu?.Populate(_cachedInventory); | ||
} | ||
|
||
private void OnItemSelected(GUIBoundKeyEventArgs args, ListData data) | ||
{ | ||
if (args.Function != EngineKeyFunctions.UIClick) | ||
return; | ||
|
||
if (data is not VendorItemsListData { ItemIndex: var itemIndex }) | ||
return; | ||
|
||
if (_cachedInventory.Count == 0) | ||
return; | ||
|
||
var selectedItem = _cachedInventory.ElementAtOrDefault(itemIndex); | ||
|
||
if (selectedItem == null) | ||
return; | ||
|
||
SendMessage(new SmartFridgeEjectMessage(selectedItem.StorageSlotId)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Content.Client/Backmen/Medical/SmartFridge/SmartFridgeSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Content.Shared.Backmen.Medical.SmartFridge; | ||
using SmartFridgeComponent = Content.Shared.Backmen.Medical.SmartFridge.SmartFridgeComponent; | ||
|
||
namespace Content.Client.Backmen.Medical.SmartFridge; | ||
|
||
public sealed class SmartFridgeSystem : SharedSmartFridgeSystem | ||
{ | ||
[Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SmartFridgeComponent, AfterAutoHandleStateEvent>(OnVendingAfterState); | ||
} | ||
|
||
private void OnVendingAfterState(EntityUid uid, SmartFridgeComponent component, ref AfterAutoHandleStateEvent args) | ||
{ | ||
if (_uiSystem.TryGetOpenUi<SmartFridgeBoundUserInterface>(uid, SmartFridgeUiKey.Key, out var bui)) | ||
{ | ||
bui.Refresh(); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Content.Client/Backmen/Medical/SmartFridge/UI/SmartFridgeMenu.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<controls:FancyWindow | ||
xmlns="https://spacestation14.io" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls" | ||
MinSize="350,300" | ||
SetSize="400,400" | ||
Title="{Loc 'smart-fridge-title'}"> | ||
|
||
<PanelContainer StyleClasses="WindowPanel"> | ||
<BoxContainer Name="MainContainer" Orientation="Vertical" Margin="10"> | ||
<BoxContainer Orientation="Vertical" Margin="0 0 0 8"> | ||
<Label Text="{Loc 'smart-fridge-search'}:" Margin="0 0 0 5" HorizontalAlignment="Center"/> | ||
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True"/> | ||
</BoxContainer> | ||
|
||
<PanelContainer StyleClasses="WindowPanelInner" Margin="0 0 0 8" VerticalExpand="True"> | ||
<BoxContainer Orientation="Vertical" Name="ContentPanel" Margin="10" VerticalExpand="True"> | ||
<co:SearchListContainer Name="VendingContents" VerticalExpand="True"/> | ||
<Label Name="OutOfStockLabel" | ||
Text="{Loc 'vending-machine-component-try-eject-out-of-stock'}" | ||
Margin="4" | ||
HorizontalExpand="True" | ||
HorizontalAlignment="Center" | ||
Visible="False"/> | ||
</BoxContainer> | ||
</PanelContainer> | ||
|
||
<PanelContainer StyleClasses="LowDivider" Margin="0 8 0 0"/> | ||
<BoxContainer Orientation="Horizontal" Margin="0 4 0 0" VerticalAlignment="Bottom"> | ||
<Label Text="{Loc 'vending-machine-flavor-left'}" StyleClasses="WindowFooterText" Margin="0 0 10 0"/> | ||
<Label Text="{Loc 'vending-machine-flavor-right'}" StyleClasses="WindowFooterText" | ||
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0"/> | ||
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered" | ||
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="24 24"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</controls:FancyWindow> |
84 changes: 84 additions & 0 deletions
84
Content.Client/Backmen/Medical/SmartFridge/UI/SmartFridgeMenu.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Client.VendingMachines.UI; | ||
using Content.Shared.Backmen.Medical.SmartFridge; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Client.AutoGenerated; | ||
|
||
namespace Content.Client.Backmen.Medical.SmartFridge.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class SmartFridgeMenu : FancyWindow | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
||
private readonly Dictionary<EntProtoId, EntityUid> _dummies = []; | ||
|
||
public event Action<GUIBoundKeyEventArgs, ListData>? OnItemSelected; | ||
|
||
public SmartFridgeMenu() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
VendingContents.SearchBar = SearchBar; | ||
VendingContents.DataFilterCondition += DataFilterCondition; | ||
VendingContents.GenerateItem += GenerateButton; | ||
VendingContents.ItemKeyBindDown += (args, data) => OnItemSelected?.Invoke(args, data); | ||
} | ||
|
||
private static bool DataFilterCondition(string filter, ListData data) | ||
{ | ||
if (data is not VendorItemsListData { ItemText: var text }) | ||
return false; | ||
|
||
return string.IsNullOrEmpty(filter) || text.Contains(filter, StringComparison.CurrentCultureIgnoreCase); | ||
} | ||
|
||
private void GenerateButton(ListData data, ListContainerButton button) | ||
{ | ||
if (data is not VendorItemsListData { ItemProtoID: var protoId, ItemText: var text }) | ||
return; | ||
|
||
button.AddChild(new VendingMachineItem(protoId, text)); | ||
button.ToolTip = text; | ||
} | ||
|
||
public void Populate(List<SmartFridgeInventoryItem> inventory) | ||
{ | ||
if (inventory.Count == 0) | ||
{ | ||
SearchBar.Visible = false; | ||
VendingContents.Visible = false; | ||
OutOfStockLabel.Visible = true; | ||
return; | ||
} | ||
|
||
SearchBar.Visible = true; | ||
VendingContents.Visible = true; | ||
OutOfStockLabel.Visible = false; | ||
|
||
var listData = new List<VendorItemsListData>(); | ||
|
||
for (var i = 0; i < inventory.Count; i++) | ||
{ | ||
var entry = inventory[i]; | ||
|
||
if (!_prototypeManager.TryIndex(entry.Id, out var prototype)) | ||
continue; | ||
|
||
if (!_dummies.TryGetValue(entry.Id, out var dummy)) | ||
{ | ||
dummy = _entityManager.Spawn(entry.Id); | ||
_dummies.Add(entry.Id, dummy); | ||
} | ||
|
||
var itemText = $"{entry.ItemName} [{entry.Quantity}]"; | ||
listData.Add(new VendorItemsListData(prototype.ID, itemText, i)); | ||
} | ||
|
||
VendingContents.PopulateList(listData); | ||
} | ||
} |
Oops, something went wrong.