Files
OldThink/Content.Client/Computer/ComputerBoundUserInterface.cs

94 lines
2.7 KiB
C#
Raw Permalink Normal View History

using Robust.Client.GameObjects;
using Robust.Client.UserInterface.CustomControls;
2021-10-28 13:19:38 +02:00
namespace Content.Client.Computer
{
/// <summary>
/// ComputerBoundUserInterface shunts all sorts of responsibilities that are in the BoundUserInterface for architectural reasons into the Window.
/// NOTE: Despite the name, ComputerBoundUserInterface does not and will not care about things like power.
/// </summary>
[Virtual]
public class ComputerBoundUserInterface<TWindow, TState> : ComputerBoundUserInterfaceBase where TWindow : BaseWindow, IComputerWindow<TState>, new() where TState : BoundUserInterfaceState
{
[Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!;
2023-07-08 09:02:17 -07:00
[ViewVariables]
private TWindow? _window;
protected override void Open()
{
base.Open();
_window = (TWindow) _dynamicTypeFactory.CreateInstance(typeof(TWindow));
_window.SetupComputerWindow(this);
_window.OnClose += Close;
_window.OpenCentered();
}
// Alas, this constructor has to be copied to the subclass. :(
2023-07-08 09:02:17 -07:00
public ComputerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null)
{
return;
}
_window.UpdateState((TState) state);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Dispose();
}
}
Adds the thermo-electric generator (#18840) * Basic TEG start. Connects via node group. * Basic TEG test map * Sensor monitoring basics, TEG circulator flow * Basic power generation (it doesn't work) * More sensor monitoring work * Battery (SMES) monitoring system. * Sensor monitoring fixes Make it work properly when mapped. * Test map improvements * Revise TEG power output mechanism. Now uses a fixed supplier with a custom ramping system. * TEG test map fixes * Make air alarms and pumps open UI on activate. * Clean up thermo machines power switch. Removed separate Enabled bool from the component that always matched the power receiver's state. This enables adding a PowerSwitch component to give us alt click/verb menu. * TEG but now fancy * Make sensor monitoring console obviously WiP to mappers. * Vending machine sound, because of course. * Terrible, terrible graph background color * Examine improvements for the TEG. * Account for electrical power when equalizing gas mixtures. * Get rid of the TegCirculatorArrow logic. Use TimedDespawn instead. The "no show in right-click menuu" goes into a new general-purpose component. Thanks Julian. * Put big notice of "not ready, here's why" on the sensor monitoring console. * TryGetComponent -> TryComp * Lol there's a HideContextMenu tag * Test fixes * Guidebook for TEG Fixed rotation on GuideEntityEmbed not working correctly. Added Margin property to GuideEntityEmbed * Make TEG power bar default to invisible. So it doesn't appear in the guidebook and spawn menu.
2023-08-12 22:41:55 +02:00
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
_window?.ReceiveMessage(message);
}
}
/// <summary>
/// This class is to avoid a lot of &lt;&gt; being written when we just want to refer to SendMessage.
/// We could instead qualify a lot of generics even further, but that is a waste of time.
/// </summary>
[Virtual]
public class ComputerBoundUserInterfaceBase : BoundUserInterface
{
2023-07-08 09:02:17 -07:00
public ComputerBoundUserInterfaceBase(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
2021-10-28 13:19:38 +02:00
public new void SendMessage(BoundUserInterfaceMessage msg)
{
base.SendMessage(msg);
}
}
public interface IComputerWindow<TState>
{
2023-07-08 09:02:17 -07:00
void SetupComputerWindow(ComputerBoundUserInterfaceBase cb)
{
}
void UpdateState(TState state)
{
}
Adds the thermo-electric generator (#18840) * Basic TEG start. Connects via node group. * Basic TEG test map * Sensor monitoring basics, TEG circulator flow * Basic power generation (it doesn't work) * More sensor monitoring work * Battery (SMES) monitoring system. * Sensor monitoring fixes Make it work properly when mapped. * Test map improvements * Revise TEG power output mechanism. Now uses a fixed supplier with a custom ramping system. * TEG test map fixes * Make air alarms and pumps open UI on activate. * Clean up thermo machines power switch. Removed separate Enabled bool from the component that always matched the power receiver's state. This enables adding a PowerSwitch component to give us alt click/verb menu. * TEG but now fancy * Make sensor monitoring console obviously WiP to mappers. * Vending machine sound, because of course. * Terrible, terrible graph background color * Examine improvements for the TEG. * Account for electrical power when equalizing gas mixtures. * Get rid of the TegCirculatorArrow logic. Use TimedDespawn instead. The "no show in right-click menuu" goes into a new general-purpose component. Thanks Julian. * Put big notice of "not ready, here's why" on the sensor monitoring console. * TryGetComponent -> TryComp * Lol there's a HideContextMenu tag * Test fixes * Guidebook for TEG Fixed rotation on GuideEntityEmbed not working correctly. Added Margin property to GuideEntityEmbed * Make TEG power bar default to invisible. So it doesn't appear in the guidebook and spawn menu.
2023-08-12 22:41:55 +02:00
void ReceiveMessage(BoundUserInterfaceMessage message)
{
}
}
}