Files
tbd-station-14/Content.Client/GameObjects/Components/Research/ResearchConsoleBoundUserInterface.cs
Víctor Aguilera Puerto ba8b495ec0 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
2019-09-03 22:51:19 +02:00

81 lines
2.7 KiB
C#

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();
}
}
}