Add readonly where it is missing and fix those field names according to their modifiers (#2589)
This commit is contained in:
@@ -16,10 +16,10 @@ namespace Content.Client.Research
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private ItemList Items;
|
||||
private ItemList Materials;
|
||||
private LineEdit AmountLineEdit;
|
||||
private LineEdit SearchBar;
|
||||
private readonly ItemList _items;
|
||||
private readonly ItemList _materials;
|
||||
private readonly LineEdit _amountLineEdit;
|
||||
private readonly LineEdit _searchBar;
|
||||
public Button QueueButton;
|
||||
public Button ServerConnectButton;
|
||||
public Button ServerSyncButton;
|
||||
@@ -27,8 +27,8 @@ namespace Content.Client.Research
|
||||
|
||||
public LatheBoundUserInterface Owner { get; set; }
|
||||
|
||||
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
|
||||
private List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
|
||||
private readonly List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
|
||||
private readonly List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
|
||||
|
||||
public LatheMenu(LatheBoundUserInterface owner = null)
|
||||
{
|
||||
@@ -94,14 +94,14 @@ namespace Content.Client.Research
|
||||
SizeFlagsStretchRatio = 1
|
||||
};
|
||||
|
||||
SearchBar = new LineEdit()
|
||||
_searchBar = new LineEdit()
|
||||
{
|
||||
PlaceHolder = "Search Designs",
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3
|
||||
};
|
||||
|
||||
SearchBar.OnTextChanged += Populate;
|
||||
_searchBar.OnTextChanged += Populate;
|
||||
|
||||
var filterButton = new Button()
|
||||
{
|
||||
@@ -112,25 +112,25 @@ namespace Content.Client.Research
|
||||
Disabled = true,
|
||||
};
|
||||
|
||||
Items = new ItemList()
|
||||
_items = new ItemList()
|
||||
{
|
||||
SizeFlagsStretchRatio = 8,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SelectMode = ItemList.ItemListSelectMode.Button,
|
||||
};
|
||||
|
||||
Items.OnItemSelected += ItemSelected;
|
||||
_items.OnItemSelected += ItemSelected;
|
||||
|
||||
AmountLineEdit = new LineEdit()
|
||||
_amountLineEdit = new LineEdit()
|
||||
{
|
||||
PlaceHolder = "Amount",
|
||||
Text = "1",
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
|
||||
AmountLineEdit.OnTextChanged += PopulateDisabled;
|
||||
_amountLineEdit.OnTextChanged += PopulateDisabled;
|
||||
|
||||
Materials = new ItemList()
|
||||
_materials = new ItemList()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 3
|
||||
@@ -145,14 +145,14 @@ namespace Content.Client.Research
|
||||
}
|
||||
hBoxButtons.AddChild(QueueButton);
|
||||
|
||||
hBoxFilter.AddChild(SearchBar);
|
||||
hBoxFilter.AddChild(_searchBar);
|
||||
hBoxFilter.AddChild(filterButton);
|
||||
|
||||
vBox.AddChild(hBoxButtons);
|
||||
vBox.AddChild(hBoxFilter);
|
||||
vBox.AddChild(Items);
|
||||
vBox.AddChild(AmountLineEdit);
|
||||
vBox.AddChild(Materials);
|
||||
vBox.AddChild(_items);
|
||||
vBox.AddChild(_amountLineEdit);
|
||||
vBox.AddChild(_materials);
|
||||
|
||||
margin.AddChild(vBox);
|
||||
|
||||
@@ -161,20 +161,20 @@ namespace Content.Client.Research
|
||||
|
||||
public void ItemSelected(ItemList.ItemListSelectedEventArgs args)
|
||||
{
|
||||
int.TryParse(AmountLineEdit.Text, out var quantity);
|
||||
int.TryParse(_amountLineEdit.Text, out var quantity);
|
||||
if (quantity <= 0) quantity = 1;
|
||||
Owner.Queue(_shownRecipes[args.ItemIndex], quantity);
|
||||
}
|
||||
|
||||
public void PopulateMaterials()
|
||||
{
|
||||
Materials.Clear();
|
||||
_materials.Clear();
|
||||
|
||||
foreach (var (id, amount) in Owner.Storage)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(id, out MaterialPrototype materialPrototype)) continue;
|
||||
var material = materialPrototype.Material;
|
||||
Materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false);
|
||||
_materials.AddItem($"{material.Name} {amount} cm³", material.Icon.Frame0(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,12 +183,12 @@ namespace Content.Client.Research
|
||||
/// </summary>
|
||||
public void PopulateDisabled()
|
||||
{
|
||||
int.TryParse(AmountLineEdit.Text, out var quantity);
|
||||
int.TryParse(_amountLineEdit.Text, out var quantity);
|
||||
if (quantity <= 0) quantity = 1;
|
||||
for (var i = 0; i < _shownRecipes.Count; i++)
|
||||
{
|
||||
var prototype = _shownRecipes[i];
|
||||
Items[i].Disabled = !Owner.Lathe.CanProduce(prototype, quantity);
|
||||
_items[i].Disabled = !Owner.Lathe.CanProduce(prototype, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,10 +203,10 @@ namespace Content.Client.Research
|
||||
/// </summary>
|
||||
public void PopulateList()
|
||||
{
|
||||
Items.Clear();
|
||||
_items.Clear();
|
||||
foreach (var prototype in _shownRecipes)
|
||||
{
|
||||
Items.AddItem(prototype.Name, prototype.Icon.Frame0());
|
||||
_items.AddItem(prototype.Name, prototype.Icon.Frame0());
|
||||
}
|
||||
|
||||
PopulateDisabled();
|
||||
@@ -221,9 +221,9 @@ namespace Content.Client.Research
|
||||
|
||||
foreach (var prototype in Owner.Database)
|
||||
{
|
||||
if (SearchBar.Text.Trim().Length != 0)
|
||||
if (_searchBar.Text.Trim().Length != 0)
|
||||
{
|
||||
if (prototype.Name.ToLowerInvariant().Contains(SearchBar.Text.Trim().ToLowerInvariant()))
|
||||
if (prototype.Name.ToLowerInvariant().Contains(_searchBar.Text.Trim().ToLowerInvariant()))
|
||||
_shownRecipes.Add(prototype);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user