RND Rework [Death to Techweb] (#16370)

* Techweb rework

* more ui work

* finishing ui

* Finish all the C# logic

* the techs + lathes

* remove old-tech

* mirror-review
This commit is contained in:
Nemanja
2023-05-15 16:17:30 -04:00
committed by GitHub
parent a71d9c8eff
commit 9efc727fe1
51 changed files with 1732 additions and 1401 deletions

View File

@@ -0,0 +1,29 @@
<Control xmlns="https://spacestation14.io">
<BoxContainer Orientation="Horizontal">
<PanelContainer Name="Background"
Access="Public"
StyleClasses="PDABackground"
VerticalExpand="False"
HorizontalExpand="False"
MaxWidth="10"
Margin="0 0 -5 0"/>
<Button Name="Main"
Disabled="True"
HorizontalExpand="True"
VerticalExpand="False"
StyleClasses="ButtonSquare"
Margin="0"
ToolTip="foobar"
TooltipDelay="0.25">
<BoxContainer Orientation="Horizontal" Margin="0">
<TextureRect Name="Texture"
HorizontalExpand="False"
VerticalExpand="False"
Margin="1"
TextureScale="0.5 0.5"/>
<Control MinWidth="5"/>
<RichTextLabel Name="NameLabel" StyleClasses="LabelSubText" VerticalAlignment="Center"/>
</BoxContainer>
</Button>
</BoxContainer>
</Control>

View File

@@ -0,0 +1,24 @@
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Research.UI;
[GenerateTypedNameReferences]
public sealed partial class MiniTechnologyCardControl : Control
{
public MiniTechnologyCardControl(TechnologyPrototype technology, IPrototypeManager prototypeManager, SpriteSystem spriteSys, FormattedMessage description)
{
RobustXamlLoader.Load(this);
var discipline = prototypeManager.Index<TechDisciplinePrototype>(technology.Discipline);
Background.ModulateSelfOverride = discipline.Color;
Texture.Texture = spriteSys.Frame0(technology.Icon);
NameLabel.SetMessage(Loc.GetString(technology.Name));
Main.ToolTip = description.ToString();
}
}

View File

@@ -4,91 +4,63 @@ using Content.Shared.Research.Systems;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.Research.UI
{
[UsedImplicitly]
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
{
public int Points { get; private set; }
public int PointsPerSecond { get; private set; }
private ResearchConsoleMenu? _consoleMenu;
private TechnologyDatabaseComponent? _technologyDatabase;
private readonly IEntityManager _entityManager;
private readonly SharedResearchSystem _research;
namespace Content.Client.Research.UI;
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
[UsedImplicitly]
public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
{
private ResearchConsoleMenu? _consoleMenu;
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
SendMessage(new ConsoleServerSyncMessage());
}
protected override void Open()
{
base.Open();
var owner = Owner.Owner;
_consoleMenu = new ResearchConsoleMenu(owner);
_consoleMenu.OnTechnologyCardPressed += id =>
{
SendMessage(new ConsoleUnlockTechnologyMessage(id));
};
_consoleMenu.OnServerButtonPressed += () =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
_consoleMenu.OnSyncButtonPressed += () =>
{
SendMessage(new ConsoleServerSyncMessage());
_entityManager = IoCManager.Resolve<IEntityManager>();
_research = _entityManager.System<SharedResearchSystem>();
}
};
protected override void Open()
{
base.Open();
_consoleMenu.OnClose += Close;
if (!_entityManager.TryGetComponent(Owner.Owner, out _technologyDatabase))
return;
_consoleMenu.OpenCentered();
}
_consoleMenu = new ResearchConsoleMenu(this);
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_consoleMenu.OnClose += Close;
if (state is not ResearchConsoleBoundInterfaceState castState)
return;
_consoleMenu?.UpdatePanels(castState);
_consoleMenu?.UpdateInformationPanel(castState);
}
_consoleMenu.ServerSyncButton.OnPressed += (_) =>
{
SendMessage(new ConsoleServerSyncMessage());
};
_consoleMenu.ServerSelectionButton.OnPressed += (_) =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
_consoleMenu.UnlockButton.OnPressed += (_) =>
{
if (_consoleMenu.TechnologySelected != null)
{
SendMessage(new ConsoleUnlockTechnologyMessage(_consoleMenu.TechnologySelected.ID));
}
};
_consoleMenu.OpenCentered();
}
public bool IsTechnologyUnlocked(TechnologyPrototype technology)
{
if (_technologyDatabase == null)
return false;
return _research.IsTechnologyUnlocked(_technologyDatabase.Owner, technology, _technologyDatabase);
}
public bool CanUnlockTechnology(TechnologyPrototype technology)
{
if (_technologyDatabase == null)
return false;
return _research.ArePrerequesitesUnlocked(_technologyDatabase.Owner, technology, _technologyDatabase);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
var castState = (ResearchConsoleBoundInterfaceState)state;
Points = castState.Points;
PointsPerSecond = castState.PointsPerSecond;
// We update the user interface here.
_consoleMenu?.PopulatePoints();
_consoleMenu?.Populate();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_consoleMenu?.Dispose();
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_consoleMenu?.Dispose();
}
}

View File

@@ -1,87 +1,101 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'research-console-menu-title'}"
MinSize="800 400"
SetSize="800 400">
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Title="{Loc 'research-console-menu-title'}"
MinSize="625 400"
SetSize="700 550">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="2"
SeparationOverride="10">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<Label Text="{Loc 'research-console-menu-unlocked-technologies-label'}" />
<ItemList Name="UnlockedTechnologies"
SelectMode="Button"
HorizontalExpand="True"
VerticalExpand="True">
<!-- Unlocked technologies are added here by code -->
</ItemList>
VerticalExpand="False"
MinHeight="85"
Margin="10">
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ResearchAmountLabel"/>
<RichTextLabel Name="MainDisciplineLabel"/>
<Control VerticalExpand="True"/>
<BoxContainer Name="TierDisplayContainer" Orientation="Horizontal" HorizontalExpand="True" VerticalAlignment="Bottom"/>
<!-- This is where we put all of the little graphics that display discipline tiers!-->
</BoxContainer>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<Label Text="{Loc 'research-console-menu-unlockable-technologies-label'}" />
<ItemList Name="UnlockableTechnologies"
SelectMode="Button"
HorizontalExpand="True"
VerticalExpand="True">
<!-- Unlockable technologies are added here by code -->
</ItemList>
</BoxContainer>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<Label Text="{Loc 'research-console-menu-future-technologies-label'}" />
<ItemList Name="FutureTechnologies"
SelectMode="Button"
HorizontalExpand="True"
VerticalExpand="True">
<!-- Future technologies are added here by code -->
</ItemList>
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalAlignment="Right">
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" VerticalExpand="True"/>
<Control MinHeight="5"/>
<!--todo is this button even necessary?!-->
<Button Name="SyncButton" Text="{Loc 'research-console-menu-server-sync-button'}" VerticalExpand="True"/>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1">
<TextureRect Name="TechnologyIcon"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1"
Stretch="KeepAspectCentered" />
VerticalExpand="True">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="3">
<Label Name="TechnologyName" />
<Label Name="TechnologyDescription" />
<Label Name="TechnologyRequirements" />
HorizontalExpand="True"
SizeFlagsStretchRatio="2"
Margin="10 0 10 10"
MinWidth="175">
<Label Text="{Loc 'research-console-available-text'}" HorizontalAlignment="Center"/>
<customControls:HSeparator StyleClasses="LowDivider" Margin="0 0 0 10"/>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ScrollContainer
HScrollEnabled="False"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer
Name="AvailableCardsContainer"
Orientation="Vertical"
VerticalExpand="True">
</BoxContainer>
</ScrollContainer>
</PanelContainer>
<Control MinHeight="10"/>
<Label Text="{Loc 'research-console-unlocked-text'}" HorizontalAlignment="Center"/>
<customControls:HSeparator StyleClasses="LowDivider" Margin="0 0 0 10"/>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ScrollContainer
HScrollEnabled="False"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer
Name="UnlockedCardsContainer"
Orientation="Vertical"
VerticalExpand="True">
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1">
<Label Name="PointLabel" />
<Label Name="PointsPerSecondLabel" />
<BoxContainer Orientation="Vertical"
Align="End"
HorizontalExpand="True"
VerticalExpand="True">
<Button Name="ServerSelectionButton"
Access="Public"
Text="{Loc 'research-console-menu-server-selection-button'}" />
<Button Name="ServerSyncButton"
Access="Public"
Text="{Loc 'research-console-menu-server-sync-button'}" />
<Button Name="UnlockButton"
Access="Public"
Disabled="True" />
</BoxContainer>
HorizontalExpand="True"
SizeFlagsStretchRatio="3"
Margin="0 0 10 10">
<PanelContainer VerticalExpand="True" MinSize="0 200">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ScrollContainer
HScrollEnabled="False"
HorizontalExpand="True"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
<BoxContainer
Name="TechnologyCardsContainer"
MinSize="100 256"
Orientation="Vertical"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
</controls:FancyWindow>

View File

@@ -1,195 +1,167 @@
using System.Collections.Generic;
using Content.Client.UserInterface.Controls;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.Utility;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Research.UI
namespace Content.Client.Research.UI;
[GenerateTypedNameReferences]
public sealed partial class ResearchConsoleMenu : FancyWindow
{
[GenerateTypedNameReferences]
public sealed partial class ResearchConsoleMenu : DefaultWindow
public Action<string>? OnTechnologyCardPressed;
public Action? OnServerButtonPressed;
public Action? OnSyncButtonPressed;
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
private readonly TechnologyDatabaseComponent? _technologyDatabase;
private readonly ResearchSystem _research;
private readonly SpriteSystem _sprite;
public readonly EntityUid Entity;
public ResearchConsoleMenu(EntityUid entity)
{
public ResearchConsoleBoundUserInterface Owner { get; }
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
private readonly List<TechnologyPrototype> _unlockedTechnologyPrototypes = new();
private readonly List<TechnologyPrototype> _unlockableTechnologyPrototypes = new();
private readonly List<TechnologyPrototype> _futureTechnologyPrototypes = new();
_research = _entity.System<ResearchSystem>();
_sprite = _entity.System<SpriteSystem>();
Entity = entity;
public TechnologyPrototype? TechnologySelected;
ServerButton.OnPressed += _ => OnServerButtonPressed?.Invoke();
SyncButton.OnPressed += _ => OnSyncButtonPressed?.Invoke();
public ResearchConsoleMenu(ResearchConsoleBoundUserInterface owner)
_entity.TryGetComponent(entity, out _technologyDatabase);
}
public void UpdatePanels(ResearchConsoleBoundInterfaceState state)
{
var allTech = _research.GetAvailableTechnologies(Entity);
AvailableCardsContainer.Children.Clear();
TechnologyCardsContainer.Children.Clear();
UnlockedCardsContainer.Children.Clear();
foreach (var tech in allTech)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
var mini = new MiniTechnologyCardControl(tech, _prototype, _sprite, GetTechnologyDescription(tech, false));
AvailableCardsContainer.AddChild(mini);
}
Owner = owner;
if (_technologyDatabase == null)
return;
UnlockedTechnologies.OnItemSelected += UnlockedTechnologySelected;
UnlockableTechnologies.OnItemSelected += UnlockableTechnologySelected;
FutureTechnologies.OnItemSelected += FutureTechnologySelected;
// i can't figure out the spacing so here you go
TechnologyCardsContainer.AddChild(new Control
{
MinHeight = 10
});
foreach (var techId in _technologyDatabase.CurrentTechnologyCards)
{
var tech = _prototype.Index<TechnologyPrototype>(techId);
var cardControl = new TechnologyCardControl(tech, _prototype, _sprite, GetTechnologyDescription(tech), state.Points);
cardControl.OnPressed += () => OnTechnologyCardPressed?.Invoke(techId);
TechnologyCardsContainer.AddChild(cardControl);
}
PointLabel.Text = Loc.GetString("research-console-menu-research-points-text", ("points", 0));
PointsPerSecondLabel.Text = Loc.GetString("research-console-menu-points-per-second-text", ("pointsPerSecond", 0));
foreach (var unlocked in _technologyDatabase.UnlockedTechnologies)
{
var tech = _prototype.Index<TechnologyPrototype>(unlocked);
var cardControl = new MiniTechnologyCardControl(tech, _prototype, _sprite, GetTechnologyDescription(tech, false));
UnlockedCardsContainer.AddChild(cardControl);
}
}
UnlockButton.Text = Loc.GetString("research-console-menu-server-unlock-button");
public FormattedMessage GetTechnologyDescription(TechnologyPrototype technology, bool includeCost = true)
{
var description = new FormattedMessage();
if (includeCost)
{
description.AddMarkup(Loc.GetString("research-console-cost", ("amount", technology.Cost)));
description.PushNewline();
}
description.AddMarkup(Loc.GetString("research-console-unlocks-list-start"));
foreach (var recipe in technology.RecipeUnlocks)
{
var recipeProto = _prototype.Index<LatheRecipePrototype>(recipe);
description.PushNewline();
description.AddMarkup(Loc.GetString("research-console-unlocks-list-entry",
("name",recipeProto.Name)));
}
foreach (var generic in technology.GenericUnlocks)
{
description.PushNewline();
description.AddMarkup(Loc.GetString("research-console-unlocks-list-entry-generic",
("name", Loc.GetString(generic.UnlockDescription))));
}
UnlockButton.OnPressed += _ =>
return description;
}
public void UpdateInformationPanel(ResearchConsoleBoundInterfaceState state)
{
var amountMsg = new FormattedMessage();
amountMsg.AddMarkup(Loc.GetString("research-console-menu-research-points-text",
("points", state.Points)));
ResearchAmountLabel.SetMessage(amountMsg);
if (_technologyDatabase == null)
return;
var disciplineText = Loc.GetString("research-discipline-none");
var disciplineColor = Color.Gray;
if (_technologyDatabase.MainDiscipline != null)
{
var discipline = _prototype.Index<TechDisciplinePrototype>(_technologyDatabase.MainDiscipline);
disciplineText = Loc.GetString(discipline.Name);
disciplineColor = discipline.Color;
}
var msg = new FormattedMessage();
msg.AddMarkup(Loc.GetString("research-console-menu-main-discipline",
("name", disciplineText), ("color", disciplineColor)));
MainDisciplineLabel.SetMessage(msg);
TierDisplayContainer.Children.Clear();
foreach (var disciplineId in _technologyDatabase.SupportedDisciplines)
{
var discipline = _prototype.Index<TechDisciplinePrototype>(disciplineId);
var tier = _research.GetHighestDisciplineTier(_technologyDatabase, discipline);
// don't show tiers with no available tech
if (tier == 0)
continue;
// i'm building the small-ass control here to spare me some mild annoyance in making a new file
var texture = new TextureRect
{
CleanSelectedTechnology();
TextureScale = ( 2, 2 ),
VerticalAlignment = VAlignment.Center
};
var label = new RichTextLabel();
texture.Texture = _sprite.Frame0(discipline.Icon);
label.SetMessage(Loc.GetString("research-console-tier-info-small", ("tier", tier)));
Populate();
}
/// <summary>
/// Cleans the selected technology controls to blank.
/// </summary>
private void CleanSelectedTechnology()
{
UnlockButton.Disabled = true;
TechnologyIcon.Texture = Texture.Transparent;
TechnologyName.Text = string.Empty;
TechnologyDescription.Text = string.Empty;
TechnologyRequirements.Text = string.Empty;
}
/// <summary>
/// Called when an unlocked technology is selected.
/// </summary>
private void UnlockedTechnologySelected(ItemList.ItemListSelectedEventArgs obj)
{
TechnologySelected = _unlockedTechnologyPrototypes[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];
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];
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>())
var control = new BoxContainer
{
var techName = GetTechName(tech);
if (Owner.IsTechnologyUnlocked(tech))
Children =
{
UnlockedTechnologies.AddItem(techName, tech.Icon.Frame0());
_unlockedTechnologyPrototypes.Add(tech);
texture,
label,
new Control
{
MinWidth = 10
}
}
else if (Owner.CanUnlockTechnology(tech))
{
UnlockableTechnologies.AddItem(techName, tech.Icon.Frame0());
_unlockableTechnologyPrototypes.Add(tech);
}
else
{
FutureTechnologies.AddItem(techName, tech.Icon.Frame0());
_futureTechnologyPrototypes.Add(tech);
}
}
}
private string GetTechName(TechnologyPrototype prototype)
{
if (prototype.Name is { } name)
return Loc.GetString(name);
return prototype.ID;
}
/// <summary>
/// Fills the selected technology controls with details.
/// </summary>
public void PopulateSelectedTechnology()
{
if (TechnologySelected == null)
{
TechnologyName.Text = string.Empty;
TechnologyDescription.Text = string.Empty;
TechnologyRequirements.Text = string.Empty;
return;
}
TechnologyIcon.Texture = TechnologySelected.Icon.Frame0();
TechnologyName.Text = GetTechName(TechnologySelected);
var desc = Loc.GetString(TechnologySelected.Description);
TechnologyDescription.Text = desc + $"\n{TechnologySelected.RequiredPoints} " + Loc.GetString("research-console-menu-research-points-text" ,("points", Owner.Points)).ToLowerInvariant();
TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-none");
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;
var protoName = GetTechName(prototype);
if (i == 0)
TechnologyRequirements.Text = Loc.GetString("research-console-tech-requirements-prototype-name", ("prototypeName", protoName));
else
TechnologyRequirements.Text += $", {protoName}";
}
}
/// <summary>
/// Updates the research point labels.
/// </summary>
public void PopulatePoints()
{
PointLabel.Text = Loc.GetString("research-console-menu-research-points-text", ("points", Owner.Points));
PointsPerSecondLabel.Text = Loc.GetString("research-console-menu-points-per-second-text", ("pointsPerSecond", Owner.PointsPerSecond));
}
/// <summary>
/// Updates the whole user interface.
/// </summary>
public void Populate()
{
PopulatePoints();
PopulateSelectedTechnology();
PopulateItemLists();
};
TierDisplayContainer.AddChild(control);
}
}
}

View File

@@ -0,0 +1,42 @@
<Control xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls">
<BoxContainer Name="MainContainer" Orientation="Vertical" Margin="10 0 10 10">
<PanelContainer Name="Background"
Access="Public"
StyleClasses="PDABackground"
MinHeight="15"
VerticalExpand="False"
HorizontalExpand="True"
Margin="0 0 0 -5"/>
<Button Name="MainButton"
Disabled="True"
HorizontalExpand="True"
VerticalExpand="True"
StyleClasses="ButtonSquare"
Margin="0">
<BoxContainer Orientation="Vertical"
VerticalExpand="True"
Margin="5">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<TextureRect Name="TechnologyTexture"
TextureScale="2 2"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center" Margin="10 0 0 0">
<BoxContainer Orientation="Horizontal">
<Label Name="TechnologyNameLabel" StyleClasses="LabelKeyText" HorizontalExpand="True"/>
<TextureRect Name="DisciplineTexture" TextureScale="2 2" VerticalAlignment="Top" HorizontalAlignment="Right"/>
</BoxContainer>
<customControls:HSeparator StyleClasses="LowDivider" Margin="0 5 0 5"/>
<BoxContainer Orientation="Horizontal">
<RichTextLabel Name="TierLabel" HorizontalAlignment="Left" StyleClasses="LabelSubText" HorizontalExpand="True"/>
<Button Name="ResearchButton" Text="{Loc 'research-console-menu-server-research-button'}"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
<Control MinHeight="5"></Control>
<RichTextLabel Name="UnlocksLabel" HorizontalExpand="True" StyleClasses="LabelSubText"></RichTextLabel>
</BoxContainer>
</Button>
</BoxContainer>
</Control>

View File

@@ -0,0 +1,36 @@
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Client.Research.UI;
[GenerateTypedNameReferences]
public sealed partial class TechnologyCardControl : Control
{
public Action? OnPressed;
public TechnologyCardControl(TechnologyPrototype technology, IPrototypeManager prototypeManager, SpriteSystem spriteSys, FormattedMessage description, int points)
{
RobustXamlLoader.Load(this);
var discipline = prototypeManager.Index<TechDisciplinePrototype>(technology.Discipline);
Background.ModulateSelfOverride = discipline.Color;
DisciplineTexture.Texture = spriteSys.Frame0(discipline.Icon);
TechnologyNameLabel.Text = Loc.GetString(technology.Name);
var message = new FormattedMessage();
message.AddMarkup(Loc.GetString("research-console-tier-discipline-info",
("tier", technology.Tier), ("color", discipline.Color), ("discipline", Loc.GetString(discipline.Name))));
TierLabel.SetMessage(message);
UnlocksLabel.SetMessage(description);
TechnologyTexture.Texture = spriteSys.Frame0(technology.Icon);
ResearchButton.Disabled = points < technology.Cost;
ResearchButton.OnPressed += _ => OnPressed?.Invoke();
}
}