Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PORT]Health Analyzer update #925

Merged
merged 6 commits into from
Nov 21, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.MedicalScanner;
using Content.Shared.Backmen.Targeting;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.GameObjects;

namespace Content.Client.HealthAnalyzer.UI
{
Expand All @@ -17,10 +18,13 @@ public HealthAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owne
protected override void Open()
{
base.Open();

_window = this.CreateWindow<HealthAnalyzerWindow>();

_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
_window = new HealthAnalyzerWindow
{
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OnClose += Close;
_window.OnBodyPartSelected += SendBodyPartMessage;
_window.OpenCentered();
Comment on lines +21 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null check for EntityManager

The EntMan usage could potentially throw a null reference exception. Consider adding a null check or using the null-conditional operator.

 _window = new HealthAnalyzerWindow
 {
-    Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
+    Title = EntMan?.GetComponent<MetaDataComponent>(Owner)?.EntityName ?? "Health Analyzer",
 };
📝 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
_window = new HealthAnalyzerWindow
{
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName,
};
_window.OnClose += Close;
_window.OnBodyPartSelected += SendBodyPartMessage;
_window.OpenCentered();
_window = new HealthAnalyzerWindow
{
Title = EntMan?.GetComponent<MetaDataComponent>(Owner)?.EntityName ?? "Health Analyzer",
};
_window.OnClose += Close;
_window.OnBodyPartSelected += SendBodyPartMessage;
_window.OpenCentered();

}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand All @@ -33,5 +37,22 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message)

_window.Populate(cast);
}

private void SendBodyPartMessage(TargetBodyPart? part, EntityUid target) => SendMessage(new HealthAnalyzerPartMessage(EntMan.GetNetEntity(target), part ?? null));

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

if (_window != null)
{
_window.OnClose -= Close;
_window.OnBodyPartSelected -= SendBodyPartMessage;
}

_window?.Dispose();
}
}
}
222 changes: 196 additions & 26 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<controls:FancyWindow
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
MaxHeight="525"
MinWidth="300">
MinWidth="350">
<ScrollContainer
Margin="5 5 5 5"
ReturnMeasure="True"
Expand All @@ -13,45 +13,215 @@
Orientation="Vertical">
<Label
Name="NoPatientDataText"
Text="{Loc health-analyzer-window-no-patient-data-text}" />

Text="{Loc health-analyzer-window-no-patient-data-text}"/>
<Button Name="ReturnButton"
Text="{Loc 'health-analyzer-window-return-button-text'}"
Margin="0 0 0 10"
HorizontalExpand="False"/>
<BoxContainer
Name="PatientDataContainer"
Margin="0 0 0 5"
Orientation="Vertical">
<BoxContainer Orientation="Horizontal" Margin="0 0 0 5">
<SpriteView OverrideDirection="South" Scale="2 2" Name="SpriteView" Access="Public" SetSize="64 64" />
<TextureRect Name="NoDataTex" Access="Public" SetSize="64 64" Visible="false" Stretch="KeepAspectCentered" TexturePath="/Textures/Interface/Misc/health_analyzer_out_of_range.png"/>
<BoxContainer Margin="5 0 0 0" Orientation="Vertical" VerticalAlignment="Top">
<RichTextLabel Name="NameLabel" SetWidth="150" />
<Label Name="SpeciesLabel" VerticalAlignment="Top" StyleClasses="LabelSubText" />
<BoxContainer Orientation="Horizontal"
Margin="0 0 0 5">
<PanelContainer>
<SpriteView OverrideDirection="South"
Scale="2.5 2.5"
Name="SpriteView"
Access="Public"
SetSize="96 96"/>
<PanelContainer
Name="PartView"
SetSize="57 96"
Margin="18 0 0 0"
VerticalAlignment="Center"
HorizontalAlignment="Left">
<PanelContainer
SetSize="15 33"
Margin="4 0 0 0"
HorizontalAlignment="Left">
<TextureButton
Name="RightArmButton"
MinSize="15 25"
StyleClasses="TargetDollButtonRightArm"
VerticalAlignment="Top">
</TextureButton>
<TextureButton
Name="RightHandButton"
MinSize="15 15"
VerticalAlignment="Bottom"
StyleClasses="TargetDollButtonRightHand">
</TextureButton>
</PanelContainer>
<PanelContainer
SetSize="43 75"
Margin="0 0 0 0"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextureButton
Name="HeadButton"
MinSize="28 23"
VerticalAlignment="Top"
HorizontalAlignment="Center"
StyleClasses="TargetDollButtonHead">
<!--<PanelContainer
SetSize="15 15"
Margin="0 9 0 0"
HorizontalAlignment="Center">
<TextureButton
Name="EyesButton"
MinSize="15 9"
VerticalAlignment="Top"
StyleClasses="TargetDollButtonEyes">
<TextureRect
TexturePath="/Textures/Interface/Targeting/Doll/eyes.png"
Stretch="KeepAspectCentered"
SetSize="15 9"/>
</TextureButton>
<TextureButton
Name="MouthButton"
SetSize="9 6"
VerticalAlignment="Bottom"
StyleClasses="TargetDollButtonMouth">
<TextureRect
TexturePath="/Textures/Interface/Targeting/Doll/mouth.png"
Stretch="KeepAspectCentered"
SetSize="9 6"/>
</TextureButton>
</PanelContainer>-->
</TextureButton>
<TextureButton
Name="ChestButton"
SetSize="28 30"
Margin="0 18 0 0"
VerticalAlignment="Top"
HorizontalAlignment="Center"
StyleClasses="TargetDollButtonChest">
</TextureButton>
<PanelContainer
MinSize="38 35"
VerticalAlignment="Bottom"
HorizontalAlignment="Center">
<TextureButton
Name="GroinButton"
MinSize="28 15"
VerticalAlignment="Top"
HorizontalAlignment="Center"
StyleClasses="TargetDollButtonGroin">
</TextureButton>
<PanelContainer
MinSize="20 30"
VerticalAlignment="Bottom"
HorizontalAlignment="Right">
<TextureButton
Name="LeftLegButton"
MinSize="15 28"
VerticalAlignment="Top"
HorizontalAlignment="Left"
StyleClasses="TargetDollButtonLeftLeg">
</TextureButton>
<TextureButton
Name="LeftFootButton"
MinSize="20 10"
VerticalAlignment="Bottom"
StyleClasses="TargetDollButtonLeftFoot">
</TextureButton>
</PanelContainer>
<PanelContainer
MinSize="20 30"
VerticalAlignment="Bottom"
HorizontalAlignment="Left">
<TextureButton
Name="RightLegButton"
MinSize="15 28"
VerticalAlignment="Top"
HorizontalAlignment="Right"
StyleClasses="TargetDollButtonRightLeg">
</TextureButton>
<TextureButton
Name="RightFootButton"
MinSize="20 10"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
StyleClasses="TargetDollButtonRightFoot">
</TextureButton>
</PanelContainer>
</PanelContainer>
</PanelContainer>
<PanelContainer
SetSize="15 33"
Margin="0 0 4 0"
HorizontalAlignment="Right">
<TextureButton
Name="LeftArmButton"
MinSize="15 25"
StyleClasses="TargetDollButtonLeftArm"
VerticalAlignment="Top">
</TextureButton>
<TextureButton
Name="LeftHandButton"
MinSize="15 15"
VerticalAlignment="Bottom"
StyleClasses="TargetDollButtonLeftHand">
</TextureButton>
</PanelContainer>
</PanelContainer>
</PanelContainer>
<TextureRect Name="NoDataTex"
Access="Public"
SetSize="64 64"
Visible="false"
Stretch="KeepAspectCentered"
TexturePath="/Textures/Interface/Misc/health_analyzer_out_of_range.png"/>
<BoxContainer Margin="5 0 0 0"
Orientation="Vertical"
VerticalAlignment="Top">
<RichTextLabel Name="NameLabel"
SetWidth="150"/>
<Label Name="SpeciesLabel"
VerticalAlignment="Top"
StyleClasses="LabelSubText"/>
<Label Name="PartNameLabel"
VerticalAlignment="Bottom"
StyleClasses="LabelSubText"/>
</BoxContainer>
<Label Margin="0 0 5 0" HorizontalExpand="True" HorizontalAlignment="Right" VerticalExpand="True"
VerticalAlignment="Top" Name="ScanModeLabel"
Text="{Loc 'health-analyzer-window-entity-unknown-text'}" />
<Label Margin="0 0 5 0"
HorizontalExpand="True"
HorizontalAlignment="Right"
VerticalExpand="True"
VerticalAlignment="Top"
Name="ScanModeLabel"
Text="{Loc 'health-analyzer-window-entity-unknown-text'}"/>
</BoxContainer>

<PanelContainer StyleClasses="LowDivider" />
<PanelContainer StyleClasses="LowDivider"/>

<GridContainer Margin="0 5 0 0" Columns="2">
<Label Text="{Loc 'health-analyzer-window-entity-status-text'}" />
<Label Name="StatusLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-temperature-text'}" />
<Label Name="TemperatureLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-blood-level-text'}" />
<Label Name="BloodLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-damage-total-text'}" />
<Label Name="DamageLabel" />
<GridContainer Margin="0 5 0 0"
Columns="2">
<Label Text="{Loc 'health-analyzer-window-entity-status-text'}"/>
<Label Name="StatusLabel"/>
<Label Text="{Loc 'health-analyzer-window-entity-temperature-text'}"/>
<Label Name="TemperatureLabel"/>
<Label Text="{Loc 'health-analyzer-window-entity-blood-level-text'}"/>
<Label Name="BloodLabel"/>
<Label Text="{Loc 'health-analyzer-window-entity-damage-total-text'}"/>
<Label Name="DamageLabel"/>
</GridContainer>
</BoxContainer>

<PanelContainer Name="AlertsDivider" Visible="False" StyleClasses="LowDivider" />
<PanelContainer Name="AlertsDivider"
Visible="False"
StyleClasses="LowDivider"/>

<BoxContainer Name="AlertsContainer" Visible="False" Margin="0 5" Orientation="Vertical" HorizontalAlignment="Center">
<BoxContainer Name="AlertsContainer"
Visible="False"
Margin="0 5"
Orientation="Vertical"
HorizontalAlignment="Center">

</BoxContainer>

<PanelContainer StyleClasses="LowDivider" />
<PanelContainer StyleClasses="LowDivider"/>

<BoxContainer
Name="GroupsContainer"
Expand Down
Loading
Loading