Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Content.Client/Research/UI/MiniTechnologyCardControl.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Control xmlns="https://spacestation14.io">
<Control xmlns="https://spacestation14.io">
<BoxContainer Orientation="Horizontal">
<PanelContainer Name="Background"
Access="Public"
Expand All @@ -19,7 +19,7 @@
HorizontalExpand="False"
VerticalExpand="False"
Margin="1"
TextureScale="0.5 0.5"/>
TextureScale="1 1" /><!-- Tech Tree Change -->
<Control MinWidth="5"/>
<RichTextLabel Name="NameLabel" StyleClasses="LabelSubText" VerticalAlignment="Center"/>
</BoxContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 Aiden <aiden@djkraz.com>
// SPDX-FileCopyrightText: 2025 FaDeOkno <143940725+FaDeOkno@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 FaDeOkno <logkedr18@gmail.com>
// SPDX-FileCopyrightText: 2025 coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

using System.Linq;
using Content.Shared._Goobstation.Research;
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;

namespace Content.Client._Goobstation.Research.UI;

[UsedImplicitly]
public sealed class FancyResearchConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private FancyResearchConsoleMenu? _consoleMenu; // Goobstation R&D Console rework - ResearchConsoleMenu -> FancyResearchConsoleMenu

public FancyResearchConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

var owner = Owner;

_consoleMenu = this.CreateWindow<FancyResearchConsoleMenu>(); // Goobstation R&D Console rework - ResearchConsoleMenu -> FancyResearchConsoleMenu
_consoleMenu.SetEntity(owner);
_consoleMenu.OnClose += () => _consoleMenu = null;

_consoleMenu.OnTechnologyCardPressed += id =>
{
SendMessage(new ConsoleUnlockTechnologyMessage(id));
};

_consoleMenu.OnServerButtonPressed += () =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
}

public override void OnProtoReload(PrototypesReloadedEventArgs args)
{
base.OnProtoReload(args);

if (!args.WasModified<TechnologyPrototype>())
return;

if (State is not ResearchConsoleBoundInterfaceState rState)
return;

_consoleMenu?.UpdatePanels(rState.Researches);
_consoleMenu?.UpdateInformationPanel(rState.Points);
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not ResearchConsoleBoundInterfaceState castState)
return;

// Goobstation checks added
// Thats for avoiding refresh spam when only points are updated
if (_consoleMenu == null)
return;
if (!_consoleMenu.List.SequenceEqual(castState.Researches))
_consoleMenu.UpdatePanels(castState.Researches);
if (_consoleMenu.Points != castState.Points)
_consoleMenu.UpdateInformationPanel(castState.Points);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>

SPDX-License-Identifier: AGPL-3.0-or-later
-->

<LayoutContainer xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:goob="clr-namespace:Content.Client._Goobstation.Research.UI"
Margin="5"
HorizontalExpand="False">
<BoxContainer Orientation="Vertical" SetSize="80 80">
<PanelContainer VerticalExpand="True"
HorizontalExpand="True"
Name="Panel">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#162031"
BorderColor="#4972A1"
BorderThickness="2"/>
</PanelContainer.PanelOverride>
<goob:DrawButton Name="Button"
Access="Public"
ModulateSelfOverride="#00000000"
HorizontalExpand="True"/>
<TextureRect
Name="ResearchDisplay"
TextureScale="2 2"
SetSize="64 64"
Stretch="KeepAspectCentered">
</TextureRect>
</PanelContainer>
</BoxContainer>
</LayoutContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 Aiden <aiden@djkraz.com>
// SPDX-FileCopyrightText: 2025 FaDeOkno <143940725+FaDeOkno@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 FaDeOkno <logkedr18@gmail.com>
// SPDX-FileCopyrightText: 2025 coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
// SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

using Content.Shared._Goobstation.Research;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._Goobstation.Research.UI;

[GenerateTypedNameReferences]
public sealed partial class FancyResearchConsoleItem : LayoutContainer
{
// Public fields
public TechnologyPrototype Prototype;
public Action<TechnologyPrototype, ResearchAvailability>? SelectAction;
public ResearchAvailability Availability;

// Some visuals
public static readonly Color DefaultColor = Color.FromHex("#141F2F");
public static readonly Color DefaultBorderColor = Color.FromHex("#4972A1");
public static readonly Color DefaultHoveredColor = Color.FromHex("#4972A1");

public Color Color = DefaultColor;
public Color BorderColor = DefaultBorderColor;
public Color HoveredColor = DefaultHoveredColor;

Comment on lines +28 to +36
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Nome do campo colide com o tipo Color, causando erro de compilação

Ao declarar public Color Color = …, o identificador Color passa a se referir ao campo, escondendo o tipo Color no restante da classe. Linhas 50-56 que usam Color.DarkOliveGreen, etc., deixam de compilar.

-    public Color Color = DefaultColor;
-    public Color BorderColor = DefaultBorderColor;
-    public Color HoveredColor = DefaultHoveredColor;
+    public Color BaseColor       = DefaultColor;
+    public Color BaseBorderColor = DefaultBorderColor;
+    public Color HoveredColor    = DefaultHoveredColor;

Altere também as demais referências (BaseColor, BaseBorderColor) dentro da classe.

public FancyResearchConsoleItem(TechnologyPrototype proto, SpriteSystem sprite, ResearchAvailability availability)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

Availability = availability;
Prototype = proto;

ResearchDisplay.Texture = sprite.Frame0(proto.Icon);
Button.OnPressed += Selected;
Button.OnDrawModeChanged += UpdateColor;

(Color, HoveredColor, BorderColor) = availability switch
{
ResearchAvailability.Researched => (Color.DarkOliveGreen, Color.PaleGreen, Color.LimeGreen),
ResearchAvailability.Available => (Color.FromHex("#7c7d2a"), Color.FromHex("#ecfa52"), Color.FromHex("#e8fa25")),
ResearchAvailability.PrereqsMet => (Color.FromHex("#6b572f"), Color.FromHex("#fad398"), Color.FromHex("#cca031")),
ResearchAvailability.Unavailable => (Color.DarkRed, Color.PaleVioletRed, Color.Crimson),
_ => (Color.DarkRed, Color.PaleVioletRed, Color.Crimson)
};

UpdateColor();
}

private void UpdateColor()
{
var panel = (StyleBoxFlat) Panel.PanelOverride!;
panel.BackgroundColor = Button.IsHovered ? HoveredColor : Color;

panel.BorderColor = BorderColor;
}

protected override void ExitedTree()
{
base.ExitedTree();

Button.OnPressed -= Selected;
}

Comment on lines +69 to +75
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Cancelar registro do evento OnDrawModeChanged ao sair da árvore

ExitedTree() remove apenas o handler de OnPressed, mas deixa o de OnDrawModeChanged pendurado, gerando vazamento de memória e exceções quando o botão for recolorido depois do controle destruído.

-        Button.OnPressed -= Selected;
+        Button.OnPressed         -= Selected;
+        Button.OnDrawModeChanged -= UpdateColor;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
protected override void ExitedTree()
{
base.ExitedTree();
Button.OnPressed -= Selected;
}
protected override void ExitedTree()
{
base.ExitedTree();
Button.OnPressed -= Selected;
Button.OnDrawModeChanged -= UpdateColor;
}

private void Selected(BaseButton.ButtonEventArgs args)
{
SelectAction?.Invoke(Prototype, Availability);
}
}

public sealed class DrawButton : Button
{
public event Action? OnDrawModeChanged;

public DrawButton()
{
}

protected override void DrawModeChanged()
{
OnDrawModeChanged?.Invoke();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!--
SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>

SPDX-License-Identifier: AGPL-3.0-or-later
-->

<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls;assembly=Content.Client"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls;assembly=Content.Client"
xmlns:goob="clr-namespace:Content.Client._Goobstation.Research.UI"
Title="{Loc 'research-console-menu-title'}"
SetSize="1260 850">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="False"
MinHeight="60"
Margin="10">
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ResearchAmountLabel"/>
<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" VerticalExpand="True" HorizontalAlignment="Right">
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" MinHeight="40"/>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
SizeFlagsStretchRatio="3"
Margin="0 0 0 10">
<PanelContainer Name="ResearchesContainer" VerticalExpand="True" HorizontalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />
</PanelContainer.PanelOverride>
<AnimatedTextureRect Name="StaticSprite"
HorizontalExpand="True"
VerticalExpand="True">
<goob:ResearchesContainerPanel
HorizontalExpand="True"
VerticalExpand="True"
Name="DragContainer"
MouseFilter="Pass"
RectClipContent="True">
<!-- There lives all of technologies -->
</goob:ResearchesContainerPanel>
</AnimatedTextureRect>
<Button Name="RecenterButton" Text="{Loc 'research-console-menu-recenter-button'}" MinHeight="40" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="5 -5"/>
</PanelContainer>
</BoxContainer>
<PanelContainer SizeFlagsStretchRatio="2">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<BoxContainer Name="InfoContainer"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
SizeFlagsStretchRatio="1"
Margin="0"/>
</PanelContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Loading
Loading