Economy (#403)
* nasrano * Add station budget & salary * Initial balance * Vending machine UI * Pricing for vending machines * Finish economy * Eftpos * Finish eftpos * Put eftpos into lockers * Vending machine prices * Small fixes * Fix atm UI * Add atms to maps * fix * reset * Add PDA program * Maps again --------- Co-authored-by: Mona Hmiza <> Co-authored-by: rhailrake <49613070+rhailrake@users.noreply.github.com>
This commit is contained in:
@@ -2,13 +2,14 @@ using Content.Client.VendingMachines.UI;
|
||||
using Content.Shared.VendingMachines;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using System.Linq;
|
||||
using Content.Client.White.Economy.Ui;
|
||||
|
||||
namespace Content.Client.VendingMachines
|
||||
{
|
||||
public sealed class VendingMachineBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private VendingMachineMenu? _menu;
|
||||
private VendingMenu? _menu; // WD EDIT
|
||||
|
||||
[ViewVariables]
|
||||
private List<VendingMachineInventoryEntry> _cachedInventory = new();
|
||||
@@ -26,15 +27,18 @@ namespace Content.Client.VendingMachines
|
||||
|
||||
var vendingMachineSys = EntMan.System<VendingMachineSystem>();
|
||||
|
||||
_cachedInventory = vendingMachineSys.GetAllInventory(Owner);
|
||||
// WD EDIT START
|
||||
var component = EntMan.GetComponent<VendingMachineComponent>(Owner);
|
||||
_cachedInventory = vendingMachineSys.GetAllInventory(Owner, component);
|
||||
|
||||
_menu = new VendingMachineMenu { Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName };
|
||||
_menu = new VendingMenu { Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName };
|
||||
|
||||
_menu.OnClose += Close;
|
||||
_menu.OnItemSelected += OnItemSelected;
|
||||
_menu.OnSearchChanged += OnSearchChanged;
|
||||
_menu.OnWithdraw += SendMessage;
|
||||
// WD EDIT END
|
||||
|
||||
_menu.Populate(_cachedInventory, out _cachedFilteredIndex);
|
||||
_menu.Populate(_cachedInventory, component.PriceMultiplier, component.Credits);
|
||||
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
@@ -48,21 +52,23 @@ namespace Content.Client.VendingMachines
|
||||
|
||||
_cachedInventory = newState.Inventory;
|
||||
|
||||
_menu?.Populate(_cachedInventory, out _cachedFilteredIndex, _menu.SearchBar.Text);
|
||||
_menu?.Populate(_cachedInventory, newState.PriceMultiplier, newState.Credits);
|
||||
}
|
||||
|
||||
private void OnItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||
// WD EDIT START
|
||||
private void OnItemSelected(int index)
|
||||
{
|
||||
if (_cachedInventory.Count == 0)
|
||||
return;
|
||||
|
||||
var selectedItem = _cachedInventory.ElementAtOrDefault(_cachedFilteredIndex.ElementAtOrDefault(args.ItemIndex));
|
||||
var selectedItem = _cachedInventory.ElementAtOrDefault(index);
|
||||
|
||||
if (selectedItem == null)
|
||||
return;
|
||||
|
||||
SendMessage(new VendingMachineEjectMessage(selectedItem.Type, selectedItem.ID));
|
||||
}
|
||||
// WD EDIT END
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
@@ -80,7 +86,7 @@ namespace Content.Client.VendingMachines
|
||||
|
||||
private void OnSearchChanged(string? filter)
|
||||
{
|
||||
_menu?.Populate(_cachedInventory, out _cachedFilteredIndex, filter);
|
||||
//_menu?.Populate(_cachedInventory, out _cachedFilteredIndex, filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user