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;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace Content.Client.Research
|
||||
public LatheBoundUserInterface Owner { get; set; }
|
||||
|
||||
[ViewVariables]
|
||||
private ItemList QueueList;
|
||||
private Label NameLabel;
|
||||
private Label Description;
|
||||
private TextureRect Icon;
|
||||
private readonly ItemList _queueList;
|
||||
private readonly Label _nameLabel;
|
||||
private readonly Label _description;
|
||||
private readonly TextureRect _icon;
|
||||
|
||||
public LatheQueueMenu()
|
||||
{
|
||||
@@ -54,7 +54,7 @@ namespace Content.Client.Research
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
};
|
||||
|
||||
Icon = new TextureRect()
|
||||
_icon = new TextureRect()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 2,
|
||||
@@ -66,13 +66,13 @@ namespace Content.Client.Research
|
||||
SizeFlagsStretchRatio = 3,
|
||||
};
|
||||
|
||||
NameLabel = new Label()
|
||||
_nameLabel = new Label()
|
||||
{
|
||||
RectClipContent = true,
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
};
|
||||
|
||||
Description = new Label()
|
||||
_description = new Label()
|
||||
{
|
||||
RectClipContent = true,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
@@ -80,7 +80,7 @@ namespace Content.Client.Research
|
||||
|
||||
};
|
||||
|
||||
QueueList = new ItemList()
|
||||
_queueList = new ItemList()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.Fill,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
@@ -88,16 +88,16 @@ namespace Content.Client.Research
|
||||
SelectMode = ItemList.ItemListSelectMode.None
|
||||
};
|
||||
|
||||
vBoxInfo.AddChild(NameLabel);
|
||||
vBoxInfo.AddChild(Description);
|
||||
vBoxInfo.AddChild(_nameLabel);
|
||||
vBoxInfo.AddChild(_description);
|
||||
|
||||
hBox.AddChild(Icon);
|
||||
hBox.AddChild(_icon);
|
||||
hBox.AddChild(vBoxInfo);
|
||||
|
||||
descMargin.AddChild(hBox);
|
||||
|
||||
vBox.AddChild(descMargin);
|
||||
vBox.AddChild(QueueList);
|
||||
vBox.AddChild(_queueList);
|
||||
|
||||
margin.AddChild(vBox);
|
||||
|
||||
@@ -108,27 +108,27 @@ namespace Content.Client.Research
|
||||
|
||||
public void SetInfo(LatheRecipePrototype recipe)
|
||||
{
|
||||
Icon.Texture = recipe.Icon.Frame0();
|
||||
_icon.Texture = recipe.Icon.Frame0();
|
||||
if (recipe.Name != null)
|
||||
NameLabel.Text = recipe.Name;
|
||||
_nameLabel.Text = recipe.Name;
|
||||
if (recipe.Description != null)
|
||||
Description.Text = recipe.Description;
|
||||
_description.Text = recipe.Description;
|
||||
}
|
||||
|
||||
public void ClearInfo()
|
||||
{
|
||||
Icon.Texture = Texture.Transparent;
|
||||
NameLabel.Text = "-------";
|
||||
Description.Text = "Not producing anything.";
|
||||
_icon.Texture = Texture.Transparent;
|
||||
_nameLabel.Text = "-------";
|
||||
_description.Text = "Not producing anything.";
|
||||
}
|
||||
|
||||
public void PopulateList()
|
||||
{
|
||||
QueueList.Clear();
|
||||
_queueList.Clear();
|
||||
var idx = 1;
|
||||
foreach (var recipe in Owner.QueuedRecipes)
|
||||
{
|
||||
QueueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0());
|
||||
_queueList.AddItem($"{idx}. {recipe.Name}", recipe.Icon.Frame0());
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,19 @@ namespace Content.Client.Research
|
||||
|
||||
protected override Vector2? CustomSize => (800, 400);
|
||||
|
||||
private List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
private List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
private List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
private readonly List<TechnologyPrototype> _unlockedTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
private readonly List<TechnologyPrototype> _unlockableTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
private readonly List<TechnologyPrototype> _futureTechnologyPrototypes = new List<TechnologyPrototype>();
|
||||
|
||||
private Label _pointLabel;
|
||||
private Label _pointsPerSecondLabel;
|
||||
private Label _technologyName;
|
||||
private Label _technologyDescription;
|
||||
private Label _technologyRequirements;
|
||||
private TextureRect _technologyIcon;
|
||||
private ItemList _unlockedTechnologies;
|
||||
private ItemList _unlockableTechnologies;
|
||||
private ItemList _futureTechnologies;
|
||||
private readonly Label _pointLabel;
|
||||
private readonly Label _pointsPerSecondLabel;
|
||||
private readonly Label _technologyName;
|
||||
private readonly Label _technologyDescription;
|
||||
private readonly Label _technologyRequirements;
|
||||
private readonly TextureRect _technologyIcon;
|
||||
private readonly ItemList _unlockedTechnologies;
|
||||
private readonly ItemList _unlockableTechnologies;
|
||||
private readonly ItemList _futureTechnologies;
|
||||
|
||||
public Button UnlockButton { get; private set; }
|
||||
public Button ServerSelectionButton { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user