Adds Research, unlockable technologies, Protolathes... (#264)

* Work on Research so far
More work on UI...
Fix ResearchClient and Protolathe UI stuff.
Fix infinite select -> request state -> select -> ... loop
Add UI to ResearchClient, etc.
Technology Database states, and a bit of work on the research console ui
A bit of work on Research Console UI
Protolathe sync
Stuff that actually does things
Protolathe databases yay
Alright got my motivation back
Yeah, no. It's almost 3 AM already
Fix serialization bug again
More work on stuff
Stuff
Adds files for most new components/systems.

* Protolathes actually work now

* Research. Just Research.

* Adds icons from Eris.

* Address reviews

* Change LatheMenu resize behaviour

* Update Content.Client/GameObjects/Components/Research/ResearchConsoleBoundUserInterface.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Update Content.Client/Research/ResearchConsoleMenu.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Move IoC Resolve out of for loop

* Address review

* Localize stuff
This commit is contained in:
Víctor Aguilera Puerto
2019-09-03 22:51:19 +02:00
committed by Pieter-Jan Briers
parent b62fb4a318
commit ba8b495ec0
61 changed files with 1884 additions and 23 deletions

View File

@@ -100,6 +100,9 @@ namespace Content.Client
"PlayerInputMover",
"Computer",
"AsteroidRock",
"ResearchServer",
"ResearchPointSource",
"ResearchClient",
"IdCard",
"Access",
"AccessReader",
@@ -110,8 +113,10 @@ namespace Content.Client
factory.RegisterIgnore(ignoreName);
}
factory.Register<SharedResearchConsoleComponent>();
factory.Register<SharedLatheComponent>();
factory.Register<SharedSpawnPointComponent>();
factory.Register<SolutionComponent>();
factory.Register<SharedVendingMachineComponent>();

View File

@@ -23,7 +23,7 @@ namespace Content.Client.GameObjects.Components.Research
public MaterialStorageComponent Storage { get; private set; }
public SharedLatheComponent Lathe { get; private set; }
public LatheDatabaseComponent Database { get; private set; }
public SharedLatheDatabaseComponent Database { get; private set; }
[ViewVariables]
public Queue<LatheRecipePrototype> QueuedRecipes => _queuedRecipes;
@@ -41,13 +41,15 @@ namespace Content.Client.GameObjects.Components.Research
if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent storage)
|| !Owner.Owner.TryGetComponent(out SharedLatheComponent lathe)
|| !Owner.Owner.TryGetComponent(out LatheDatabaseComponent database)) return;
|| !Owner.Owner.TryGetComponent(out SharedLatheDatabaseComponent database)) return;
Storage = storage;
Lathe = lathe;
Database = database;
menu = new LatheMenu {Owner = this};
menu = new LatheMenu(this);
queueMenu = new LatheQueueMenu { Owner = this };
menu.OnClose += Close;
@@ -57,6 +59,16 @@ namespace Content.Client.GameObjects.Components.Research
menu.QueueButton.OnPressed += (args) => { queueMenu.OpenCentered(); };
menu.ServerConnectButton.OnPressed += (args) =>
{
SendMessage(new SharedLatheComponent.LatheServerSelectionMessage());
};
menu.ServerSyncButton.OnPressed += (args) =>
{
SendMessage(new SharedLatheComponent.LatheServerSyncMessage());
};
storage.OnMaterialStorageChanged += menu.PopulateDisabled;
storage.OnMaterialStorageChanged += menu.PopulateMaterials;
@@ -74,10 +86,10 @@ namespace Content.Client.GameObjects.Components.Research
{
case SharedLatheComponent.LatheProducingRecipeMessage msg:
if (!_prototypeManager.TryIndex(msg.ID, out LatheRecipePrototype recipe)) break;
queueMenu.SetInfo(recipe);
queueMenu?.SetInfo(recipe);
break;
case SharedLatheComponent.LatheStoppedProducingRecipeMessage msg:
queueMenu.ClearInfo();
queueMenu?.ClearInfo();
break;
case SharedLatheComponent.LatheFullQueueMessage msg:
_queuedRecipes.Clear();
@@ -86,7 +98,7 @@ namespace Content.Client.GameObjects.Components.Research
if (!_prototypeManager.TryIndex(id, out LatheRecipePrototype recipePrototype)) break;
_queuedRecipes.Enqueue(recipePrototype);
}
queueMenu.PopulateList();
queueMenu?.PopulateList();
break;
}
}

View File

@@ -0,0 +1,38 @@
using System;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Client.GameObjects.Components.Research
{
[RegisterComponent]
[ComponentReference(typeof(SharedLatheDatabaseComponent))]
public class ProtolatheDatabaseComponent : SharedProtolatheDatabaseComponent
{
#pragma warning disable CS0649
[Dependency]
private IPrototypeManager _prototypeManager;
#pragma warning restore
/// <summary>
/// Invoked when the database gets updated.
/// </summary>
public event Action OnDatabaseUpdated;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is ProtolatheDatabaseState state)) return;
Clear();
foreach (var ID in state.Recipes)
{
if(!_prototypeManager.TryIndex(ID, out LatheRecipePrototype recipe)) continue;
AddRecipe(recipe);
}
OnDatabaseUpdated?.Invoke();
}
}
}

View File

@@ -0,0 +1,46 @@
using Content.Shared.GameObjects.Components.Research;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects.Components.UserInterface;
namespace Content.Client.GameObjects.Components.Research
{
public class ResearchClientBoundUserInterface : BoundUserInterface
{
private ResearchClientServerSelectionMenu _menu;
public ResearchClientBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
SendMessage(new SharedResearchClientComponent.ResearchClientSyncMessage());
}
protected override void Open()
{
base.Open();
_menu = new ResearchClientServerSelectionMenu() { Owner = this };
_menu.OnClose += Close;
_menu.OpenCentered();
}
public void SelectServer(int serverId)
{
SendMessage(new SharedResearchClientComponent.ResearchClientServerSelectedMessage(serverId));
}
public void DeselectServer()
{
SendMessage(new SharedResearchClientComponent.ResearchClientServerDeselectedMessage());
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (!(state is SharedResearchClientComponent.ResearchClientBoundInterfaceState rstate)) return;
_menu.Populate(rstate.ServerCount, rstate.ServerNames, rstate.ServerIds, rstate.SelectedServerId);
}
}
}

View File

@@ -0,0 +1,86 @@
using System;
using Content.Shared.GameObjects.Components.Research;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Research
{
public class ResearchClientServerSelectionMenu : SS14Window
{
private ItemList _servers;
private int _serverCount = 0;
private string[] _serverNames = new string[]{};
private int[] _serverIds = new int[]{};
private int _selectedServerId = -1;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (300, 300);
public ResearchClientBoundUserInterface Owner { get; set; }
public ResearchClientServerSelectionMenu()
{
IoCManager.InjectDependencies(this);
Title = _localizationManager.GetString("Research Server Selection");
_servers = new ItemList() {SelectMode = ItemList.ItemListSelectMode.Single};
_servers.OnItemSelected += OnItemSelected;
_servers.OnItemDeselected += OnItemDeselected;
var margin = new MarginContainer()
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand,
MarginTop = 5f,
MarginLeft = 5f,
MarginRight = -5f,
MarginBottom = -5f,
};
margin.AddChild(_servers);
Contents.AddChild(margin);
}
public void OnItemSelected(ItemList.ItemListSelectedEventArgs itemListSelectedEventArgs)
{
Owner.SelectServer(_serverIds[itemListSelectedEventArgs.ItemIndex]);
}
public void OnItemDeselected(ItemList.ItemListDeselectedEventArgs itemListDeselectedEventArgs)
{
Owner.DeselectServer();
}
public void Populate(int serverCount, string[] serverNames, int[] serverIds, int selectedServerId)
{
_serverCount = serverCount;
_serverNames = serverNames;
_serverIds = serverIds;
_selectedServerId = selectedServerId;
// Disable so we can select the new selected server without triggering a new sync request.
_servers.OnItemSelected -= OnItemSelected;
_servers.OnItemDeselected -= OnItemDeselected;
_servers.Clear();
for (var i = 0; i < _serverCount; i++)
{
var id = _serverIds[i];
_servers.AddItem($"ID: {id} || {_serverNames[i]}");
if(id == _selectedServerId)
_servers.Select(i);
}
_servers.OnItemSelected += OnItemSelected;
_servers.OnItemDeselected += OnItemDeselected;
}
}
}

View File

@@ -0,0 +1,80 @@
using Content.Client.Research;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.Log;
namespace Content.Client.GameObjects.Components.Research
{
public class ResearchConsoleBoundUserInterface : BoundUserInterface
{
public int Points { get; private set; } = 0;
public int PointsPerSecond { get; private set; } = 0;
private ResearchConsoleMenu _consoleMenu;
private TechnologyDatabaseComponent TechnologyDatabase;
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
SendMessage(new SharedResearchConsoleComponent.ConsoleServerSyncMessage());
}
protected override void Open()
{
base.Open();
if (!Owner.Owner.TryGetComponent(out TechnologyDatabase)) return;
_consoleMenu = new ResearchConsoleMenu(this);
_consoleMenu.ServerSyncButton.OnPressed += (args) =>
{
SendMessage(new SharedResearchConsoleComponent.ConsoleServerSyncMessage());
};
_consoleMenu.ServerSelectionButton.OnPressed += (args) =>
{
SendMessage(new SharedResearchConsoleComponent.ConsoleServerSelectionMessage());
};
_consoleMenu.UnlockButton.OnPressed += (args) =>
{
SendMessage(new SharedResearchConsoleComponent.ConsoleUnlockTechnologyMessage(_consoleMenu.TechnologySelected.ID));
};
_consoleMenu.OpenCentered();
TechnologyDatabase.OnDatabaseUpdated += _consoleMenu.Populate;
}
public bool IsTechnologyUnlocked(TechnologyPrototype technology)
{
return TechnologyDatabase.IsTechnologyUnlocked(technology);
}
public bool CanUnlockTechnology(TechnologyPrototype technology)
{
return TechnologyDatabase.CanUnlockTechnology(technology);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
var castState = (SharedResearchConsoleComponent.ResearchConsoleBoundInterfaceState)state;
Points = castState.Points;
PointsPerSecond = castState.PointsPerSecond;
// We update the user interface here.
_consoleMenu?.PopulatePoints();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
_consoleMenu?.Dispose();
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using SixLabors.ImageSharp.Processing;
namespace Content.Client.GameObjects.Components.Research
{
[RegisterComponent]
public class TechnologyDatabaseComponent : SharedTechnologyDatabaseComponent
{
/// <summary>
/// Event called when the database is updated.
/// </summary>
public event Action OnDatabaseUpdated;
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
{
base.HandleComponentState(curState, nextState);
if (!(curState is TechnologyDatabaseState state)) return;
_technologies.Clear();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var techID in state.Technologies)
{
if (!protoManager.TryIndex(techID, out TechnologyPrototype technology)) continue;
_technologies.Add(technology);
}
OnDatabaseUpdated?.Invoke();
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Content.Client.GameObjects.Components.Research;
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Materials;
using Content.Shared.Research;
using Robust.Client.UserInterface;
@@ -25,6 +26,8 @@ namespace Content.Client.Research
private LineEdit AmountLineEdit;
private LineEdit SearchBar;
public Button QueueButton;
public Button ServerConnectButton;
public Button ServerSyncButton;
protected override Vector2? CustomSize => (300, 450);
public LatheBoundUserInterface Owner { get; set; }
@@ -32,10 +35,12 @@ namespace Content.Client.Research
private List<LatheRecipePrototype> _recipes = new List<LatheRecipePrototype>();
private List<LatheRecipePrototype> _shownRecipes = new List<LatheRecipePrototype>();
public LatheMenu()
public LatheMenu(LatheBoundUserInterface owner = null)
{
IoCManager.InjectDependencies(this);
Owner = owner;
Title = "Lathe Menu";
var margin = new MarginContainer()
@@ -69,7 +74,23 @@ namespace Content.Client.Research
{
Text = "Queue",
TextAlign = Button.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsStretchRatio = 1,
};
ServerConnectButton = new Button()
{
Text = "Server list",
TextAlign = Button.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsStretchRatio = 1,
};
ServerSyncButton = new Button()
{
Text = "Sync",
TextAlign = Button.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsStretchRatio = 1,
};
@@ -101,7 +122,7 @@ namespace Content.Client.Research
{
Text = "Filter",
TextAlign = Button.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsStretchRatio = 1,
Disabled = true,
};
@@ -130,6 +151,12 @@ namespace Content.Client.Research
};
hBoxButtons.AddChild(spacer);
if (Owner?.Database is ProtolatheDatabaseComponent database)
{
hBoxButtons.AddChild(ServerConnectButton);
hBoxButtons.AddChild(ServerSyncButton);
database.OnDatabaseUpdated += Populate;
}
hBoxButtons.AddChild(QueueButton);
hBoxFilter.AddChild(SearchBar);

View File

@@ -0,0 +1,316 @@
using System.Collections.Generic;
using Content.Client.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.Research
{
public class ResearchConsoleMenu : SS14Window
{
public ResearchConsoleBoundUserInterface Owner { get; set; }
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 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;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public Button UnlockButton { get; private set; }
public Button ServerSelectionButton { get; private set; }
public Button ServerSyncButton { get; private set; }
public TechnologyPrototype TechnologySelected;
public ResearchConsoleMenu(ResearchConsoleBoundUserInterface owner = null)
{
IoCManager.InjectDependencies(this);
Title = _localizationManager.GetString("R&D Console");
Owner = owner;
_unlockedTechnologies = new ItemList()
{
SelectMode = ItemList.ItemListSelectMode.Single,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
};
_unlockedTechnologies.OnItemSelected += UnlockedTechnologySelected;
_unlockableTechnologies = new ItemList()
{
SelectMode = ItemList.ItemListSelectMode.Single,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
};
_unlockableTechnologies.OnItemSelected += UnlockableTechnologySelected;
_futureTechnologies = new ItemList()
{
SelectMode = ItemList.ItemListSelectMode.Single,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
};
_futureTechnologies.OnItemSelected += FutureTechnologySelected;
var vbox = new VBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
};
var hboxTechnologies = new HBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 2,
SeparationOverride = 10,
};
var hboxSelected = new HBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1
};
var vboxPoints = new VBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
};
var vboxTechInfo = new VBoxContainer()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 3,
};
_pointLabel = new Label() { Text = _localizationManager.GetString("Research Points") + ": 0" };
_pointsPerSecondLabel = new Label() { Text = _localizationManager.GetString("Points per Second") + ": 0" };
var vboxPointsButtons = new VBoxContainer()
{
Align = BoxContainer.AlignMode.End,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
};
ServerSelectionButton = new Button() { Text = _localizationManager.GetString("Server list") };
ServerSyncButton = new Button() { Text = _localizationManager.GetString("Sync")};
UnlockButton = new Button() { Text = _localizationManager.GetString("Unlock"), Disabled = true };
vboxPointsButtons.AddChild(ServerSelectionButton);
vboxPointsButtons.AddChild(ServerSyncButton);
vboxPointsButtons.AddChild(UnlockButton);
vboxPoints.AddChild(_pointLabel);
vboxPoints.AddChild(_pointsPerSecondLabel);
vboxPoints.AddChild(vboxPointsButtons);
_technologyIcon = new TextureRect()
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
Stretch = TextureRect.StretchMode.KeepAspectCentered,
};
_technologyName = new Label();
_technologyDescription = new Label();
_technologyRequirements = new Label();
vboxTechInfo.AddChild(_technologyName);
vboxTechInfo.AddChild(_technologyDescription);
vboxTechInfo.AddChild(_technologyRequirements);
hboxSelected.AddChild(_technologyIcon);
hboxSelected.AddChild(vboxTechInfo);
hboxSelected.AddChild(vboxPoints);
hboxTechnologies.AddChild(_unlockedTechnologies);
hboxTechnologies.AddChild(_unlockableTechnologies);
hboxTechnologies.AddChild(_futureTechnologies);
vbox.AddChild(hboxTechnologies);
vbox.AddChild(hboxSelected);
Contents.AddChild(vbox);
UnlockButton.OnPressed += (args) =>
{
CleanSelectedTechnology();
};
Populate();
}
/// <summary>
/// Cleans the selected technology controls to blank.
/// </summary>
private void CleanSelectedTechnology()
{
UnlockButton.Disabled = true;
_technologyIcon.Texture = Texture.Transparent;
_technologyName.Text = "";
_technologyDescription.Text = "";
_technologyRequirements.Text = "";
}
/// <summary>
/// Called when an unlocked technology is selected.
/// </summary>
private void UnlockedTechnologySelected(ItemList.ItemListSelectedEventArgs obj)
{
TechnologySelected = _unlockedTechnologyPrototypes[obj.ItemIndex];
_unlockedTechnologies.Unselect(obj.ItemIndex);
UnlockButton.Disabled = true;
PopulateSelectedTechnology();
}
/// <summary>
/// Called when an unlockable technology is selected.
/// </summary>
private void UnlockableTechnologySelected(ItemList.ItemListSelectedEventArgs obj)
{
TechnologySelected = _unlockableTechnologyPrototypes[obj.ItemIndex];
_unlockableTechnologies.Unselect(obj.ItemIndex);
UnlockButton.Disabled = Owner.Points < TechnologySelected.RequiredPoints;
PopulateSelectedTechnology();
}
/// <summary>
/// Called when a future technology is selected
/// </summary>
private void FutureTechnologySelected(ItemList.ItemListSelectedEventArgs obj)
{
TechnologySelected = _futureTechnologyPrototypes[obj.ItemIndex];
_futureTechnologies.Unselect(obj.ItemIndex);
UnlockButton.Disabled = true;
PopulateSelectedTechnology();
}
/// <summary>
/// Populate all technologies in the ItemLists.
/// </summary>
public void PopulateItemLists()
{
_unlockedTechnologies.Clear();
_unlockableTechnologies.Clear();
_futureTechnologies.Clear();
_unlockedTechnologyPrototypes.Clear();
_unlockableTechnologyPrototypes.Clear();
_futureTechnologyPrototypes.Clear();
var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
// For now, we retrieve all technologies. In the future, this should be changed.
foreach (var tech in prototypeMan.EnumeratePrototypes<TechnologyPrototype>())
{
if (Owner.IsTechnologyUnlocked(tech))
{
_unlockedTechnologies.AddItem(tech.Name, tech.Icon.Frame0());
_unlockedTechnologyPrototypes.Add(tech);
}
else if (Owner.CanUnlockTechnology(tech))
{
_unlockableTechnologies.AddItem(tech.Name, tech.Icon.Frame0());
_unlockableTechnologyPrototypes.Add(tech);
}
else
{
_futureTechnologies.AddItem(tech.Name, tech.Icon.Frame0());;
_futureTechnologyPrototypes.Add(tech);
}
}
}
/// <summary>
/// Fills the selected technology controls with details.
/// </summary>
public void PopulateSelectedTechnology()
{
if (TechnologySelected == null)
{
_technologyName.Text = "";
_technologyDescription.Text = "";
_technologyRequirements.Text = "";
return;
}
_technologyIcon.Texture = TechnologySelected.Icon.Frame0();
_technologyName.Text = TechnologySelected.Name;
_technologyDescription.Text = TechnologySelected.Description+$"\n{TechnologySelected.RequiredPoints} " + _localizationManager.GetString("research points");
_technologyRequirements.Text = _localizationManager.GetString("No technology requirements.");
var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
for (var i = 0; i < TechnologySelected.RequiredTechnologies.Count; i++)
{
var requiredId = TechnologySelected.RequiredTechnologies[i];
if (!prototypeMan.TryIndex(requiredId, out TechnologyPrototype prototype)) continue;
if (i == 0)
_technologyRequirements.Text = _localizationManager.GetString("Requires") + $": {prototype.Name}";
else
_technologyRequirements.Text += $", {prototype.Name}";
}
}
/// <summary>
/// Updates the research point labels.
/// </summary>
public void PopulatePoints()
{
_pointLabel.Text = _localizationManager.GetString("Research Points") + $": {Owner.Points}";
_pointsPerSecondLabel.Text = _localizationManager.GetString("Points per second") + $": {Owner.PointsPerSecond}";
}
/// <summary>
/// Updates the whole user interface.
/// </summary>
public void Populate()
{
PopulatePoints();
PopulateSelectedTechnology();
PopulateItemLists();
}
}
}