Merge remote-tracking branch 'WD-core/master' into upstream-core

This commit is contained in:
BIGZi0348
2024-12-14 22:13:35 +03:00
30 changed files with 384 additions and 52 deletions

View File

@@ -1,4 +1,7 @@
<DefaultWindow xmlns="https://spacestation14.io">
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:style="clr-namespace:Content.Client.Stylesheets">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Name="CreditsLabel" HorizontalExpand="True"/>
@@ -7,6 +10,9 @@
Text="{Loc 'store-ui-default-withdraw-text'}"
HorizontalAlignment="Right"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="4 4" Access="Public"/>
</BoxContainer>
<PanelContainer StyleClasses="HighDivider" />
<Label
Name="OutOfStockLabel"

View File

@@ -16,12 +16,13 @@ public sealed partial class VendingMenu : DefaultWindow
public event Action<int>? OnItemSelected;
public Action<VendingMachineWithdrawMessage>? OnWithdraw;
public string filter = "";
public VendingMenu()
{
MinSize = SetSize = new Vector2(250, 150);
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
// SearchBar.OnTextChanged += UpdateFilter;
}
/// <summary>
@@ -38,7 +39,7 @@ public sealed partial class VendingMenu : DefaultWindow
return;
OnWithdraw?.Invoke(new VendingMachineWithdrawMessage());
};
VendingContents.RemoveAllChildren();
if (inventory.Count == 0)
{
@@ -67,13 +68,15 @@ public sealed partial class VendingMenu : DefaultWindow
if (itemName.Length > longestEntry.Length)
longestEntry = itemName;
var price = (int)(entry.Price * priceMultiplier);
var price = (int) (entry.Price * priceMultiplier);
var vendingItem = new VendingItem($"{itemName} [{entry.Amount}]", price > 0 ? $"{price} \u00a2" : "выдать", icon);
var j = i;
vendingItem.VendingItemBuyButton.OnPressed += _ => { OnItemSelected?.Invoke(j); };
VendingContents.AddChild(vendingItem);
if (filter == "" || (prototype?.Name?.Contains(filter) == true))
VendingContents.AddChild(vendingItem);
}
SetSizeAfterUpdate(longestEntry.Length);
@@ -84,4 +87,4 @@ public sealed partial class VendingMenu : DefaultWindow
SetSize = new Vector2(Math.Clamp((longestEntryLength + 10) * 12, 250, 700),
Math.Clamp(VendingContents.ChildCount * 50, 150, 400));
}
}
}