Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Implement records saving.

Add an additional column to the database that stores records as JSON.
Currently the serialization logic is not very robust so a future commit
should improve it so it can deal with missing and extra fields in the
database.

* Record editor gui

Implements a record editor tab for HumanoidProfileEditor. In addition,
this improves the robustness of the CharacterRecords deserializer.

* Add imperial units to record editor.

* Remove SecurityClearance from CharacterRecords

* Add up and down buttons to the record entry editor

This lets you select the order that records will appear in game.

* Add system for managing records in game

* Initial viewer UI

Add the record console UI, currently it does not display entries.

* Add entries to the record console

* Clarify record computers.

* Add records viewer to aghost

* Add admin modification ui for character records

* Improve record entry viewer

* Remove contact number record

* Character Records Guidebook Entry

* Change from DefaultWindow to FancyWindow

* Fix compile errors relating to rebase

* Add rich text to record viewer

We support all tags except the heading tag. This is because it looks
very ugly. In addition, we also add a view button to the editor GUI so
you can make sure your rich text works without going into a game.

* Integrate wanted status into security records

* Correctly subscribe to Bui events

* Add comments to records and fix a few minor issues
  • Loading branch information
dffdff2423 authored and Samsterious committed Apr 26, 2024
1 parent 6803e43 commit bf669e4
Show file tree
Hide file tree
Showing 47 changed files with 5,882 additions and 32 deletions.
3 changes: 3 additions & 0 deletions Content.Client/Administration/UI/Tabs/AdminTab/AdminTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:at="clr-namespace:Content.Client.Administration.UI.Tabs.AdminTab"
xmlns:cdAdmin="clr-namespace:Content.Client._CD.Admin.UI"
Margin="4"
MinSize="50 50">
<BoxContainer Orientation="Vertical">
Expand All @@ -16,6 +17,8 @@
<cc:UICommandButton Command="callshuttle" Text="{Loc admin-player-actions-window-shuttle}" WindowType="{x:Type at:AdminShuttleWindow}"/>
<cc:CommandButton Command="adminlogs" Text="{Loc admin-player-actions-window-admin-logs}"/>
<cc:CommandButton Command="faxui" Text="{Loc admin-player-actions-window-admin-fax}"/>
<!-- CD: records purge button -->
<cc:UICommandButton Command="purgecharacterrecords" Text="{Loc admin-player-actions-window-cd-record-purge}" WindowType="{x:Type cdAdmin:ModifyCharacterRecords}"/>
</GridContainer>
</BoxContainer>
</Control>
27 changes: 27 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
using static Robust.Client.UserInterface.Controls.BoxContainer;
using Direction = Robust.Shared.Maths.Direction;

// CD: Records editor imports
using Content.Client._CD.Records.UI;
using Content.Shared._CD.Records;

namespace Content.Client.Preferences.UI
{
public sealed class HighlightedContainer : PanelContainer
Expand Down Expand Up @@ -110,6 +114,9 @@ public sealed partial class HumanoidProfileEditor : Control

private float _defaultHeight = 1f;

// CD: Record editor
private readonly RecordEditorGui _recordsTab;

public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager,
IEntityManager entityManager, IConfigurationManager configurationManager)
{
Expand Down Expand Up @@ -517,6 +524,14 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt

#endregion Markings

#region CosmaticRecords

_recordsTab = new RecordEditorGui(UpdateProfileRecords);
_tabContainer.AddChild(_recordsTab);
_tabContainer.SetTabTitle(_tabContainer.ChildCount - 1, Loc.GetString("humanoid-profile-editor-cd-records-tab"));

#endregion CosmaticRecords

#region FlavorText

if (_configurationManager.GetCVar(CCVars.FlavorText))
Expand Down Expand Up @@ -673,6 +688,15 @@ private void UpdateRoleRequirements()
}
}

// CD: Records editor
private void UpdateProfileRecords(CharacterRecords records)
{
if (Profile is null)
return;
Profile = Profile.WithCDCharacterRecords(records);
IsDirty = true;
}

private void OnFlavorTextChange(string content)
{
if (Profile is null)
Expand Down Expand Up @@ -1220,6 +1244,9 @@ public void UpdateControls()
UpdateCMarkingsFacialHair();
UpdateHeightControls();

// CD: Update record editor
_recordsTab.Update(Profile);

_preferenceUnavailableButton.SelectId((int) Profile.PreferenceUnavailable);
}

Expand Down
14 changes: 14 additions & 0 deletions Content.Client/_CD/Admin/UI/ModifyCharacterRecords.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
Title="{Loc cd-actions-admin-modify-records}"
MinSize="300 300">
<BoxContainer Orientation="Vertical">
<LineEdit Name="EntityEdit" PlaceHolder="Entity" HorizontalExpand="True" />
<OptionButton Name="EntityEntryType" HorizontalExpand="True" />
<LineEdit Name="EntityEntryIndex" PlaceHolder="Index"/>
<BoxContainer Orientation="Horizontal" >
<cc:CommandButton Name="PurgeCommand" Text="{Loc cd-actions-admin-modify-reset}"/>
<cc:CommandButton Name="DelCommand" Text="{Loc cd-actions-admin-modify-del-entry}"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
48 changes: 48 additions & 0 deletions Content.Client/_CD/Admin/UI/ModifyCharacterRecords.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Content.Shared._CD.Records;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._CD.Admin.UI;

[GenerateTypedNameReferences]
public sealed partial class ModifyCharacterRecords : DefaultWindow
{
public ModifyCharacterRecords()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

foreach (var v in Enum.GetValues<CharacterRecordType>())
{
EntityEntryType.AddItem(v.ToString());
}

EntityEntryType.OnItemSelected += args =>
{
EntityEntryType.SelectId(args.Id);
UpdateCommands();
};

EntityEdit.OnTextChanged += _ => UpdateCommands();
EntityEntryIndex.OnTextChanged += _ => UpdateCommands();
}

private void UpdateCommands()
{
if (!int.TryParse(EntityEdit.Text, out var uid))
{
return;
}

if (!int.TryParse(EntityEntryIndex.Text, out var idx))
{
return;
}

var ty = (CharacterRecordType)EntityEntryType.SelectedId;

PurgeCommand.Command = $"purgecharacterrecords {uid}";
DelCommand.Command = $"delrecordentry {uid} {ty.ToString()} {idx}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Content.Shared._CD.Records;
using Content.Shared.CriminalRecords;
using Content.Shared.CriminalRecords.Components;
using Content.Shared.Security;
using Content.Shared.StationRecords;
using JetBrains.Annotations;

namespace Content.Client._CD.Records.UI;

[UsedImplicitly]
public sealed class CharacterRecordConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables] private CharacterRecordViewer? _window;

[Dependency] private readonly EntityManager _entMan = default!;

public CharacterRecordConsoleBoundUserInterface(EntityUid owner, Enum key)
: base(owner, key)
{
}

protected override void UpdateState(BoundUserInterfaceState baseState)
{
base.UpdateState(baseState);
if (baseState is not CharacterRecordConsoleState state)
return;

if (_window?.IsSecurity() ?? false)
{
var comp = EntMan.GetComponent<CriminalRecordsConsoleComponent>(Owner);
_window!.SecurityWantedStatusMaxLength = comp.MaxStringLength;
}

_window?.UpdateState(state);
}

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

_window = new();
_window.OnClose += Close;
_window.OnKeySelected += (ent, stationRecordKey) =>
{
SendMessage(new CharacterRecordConsoleSelectMsg(ent));
// If we are a security records console, we also need to inform the criminal records
// system of our state.
if (_window.IsSecurity() && stationRecordKey != null)
{
SendMessage(new SelectStationRecord(stationRecordKey));
_window.SetSecurityStatusEnabled(true);
}
else
{
// If the user does not have criminal records for some reason, we should not be able
// to set their wanted status
_window.SetSecurityStatusEnabled(false);
}
};

_window.OnFiltersChanged += (ty, txt) =>
{
if (txt == null)
SendMessage(new CharacterRecordsConsoleFilterMsg(null));
else
SendMessage(new CharacterRecordsConsoleFilterMsg(new StationRecordsFilter(ty, txt)));
};

_window.OnSetSecurityStatus += status =>
{
SendMessage(new CriminalRecordChangeStatus(status, null));
};

_window.OnSetWantedStatus += reason =>
{
SendMessage(new CriminalRecordChangeStatus(SecurityStatus.Wanted, reason));
};

_window.OpenCentered();
}

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

_window?.Close();
}
}
135 changes: 135 additions & 0 deletions Content.Client/_CD/Records/UI/CharacterRecordViewer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
MinSize="750 600">
<BoxContainer Orientation="Vertical">
<!-- Search bar -->
<BoxContainer Margin="5 5 5 10" HorizontalExpand="true" VerticalAlignment="Center">
<OptionButton Name="RecordFilterType" MinWidth="200" Margin="0 0 10 0" Visible="False"/>
<!-- Yes, we do steal some localizations, should be fine -->
<LineEdit Name="RecordFiltersValue"
PlaceHolder="{Loc 'general-station-record-for-filter-line-placeholder'}" HorizontalExpand="True"/>
<Button Name="RecordFilters" Text="{Loc 'general-station-record-console-search-records'}"/>
<Button Name="RecordFiltersReset" Text="{Loc 'general-station-record-console-reset-filters'}"/>
</BoxContainer>
<BoxContainer VerticalExpand="True">
<!-- Record listing -->
<BoxContainer Orientation="Vertical" Margin="5" MinWidth="250" MaxWidth="250">
<Label Name="RecordListingStatus" Visible="False" />
<ScrollContainer VerticalExpand="True">
<ItemList Name="RecordListing" />
</ScrollContainer>
</BoxContainer>
<!-- Record box -->
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="5">
<Label Name="RecordContainerStatus" Visible="False" Text="{Loc 'cd-record-viewer-no-record-selected'}"/>
<BoxContainer Name="RecordContainer" Orientation="Vertical" Visible="False" >
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<!-- Common -->
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<Label Name="RecordContainerName" StyleClasses="LabelBig" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-age'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerAge" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-title'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerJob" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-gender'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerGender" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-species'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerSpecies" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-height'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerHeight" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-weight'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerWeight" Align="Right"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-contact-name'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerContactName" Align="Right" />
</BoxContainer>
</BoxContainer>
<!-- Employment -->
<BoxContainer Name="RecordContainerEmployment" Orientation="Vertical" HorizontalExpand="True" Visible="False" >
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-work-authorization'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerWorkAuth" Align="Right" />
</BoxContainer>
</BoxContainer>
<!-- Medical -->
<BoxContainer Name="RecordContainerMedical" Orientation="Vertical" HorizontalExpand="True" Visible="False" >
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-allergies'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerAllergies" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-drug-allergies'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerDrugAllergies" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-postmortem'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerPostmortem" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-med-sex'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerSex" Align="Right" />
</BoxContainer>
</BoxContainer>
<!-- Security -->
<BoxContainer Name="RecordContainerSecurity" Orientation="Vertical" HorizontalExpand="True" Visible="False" >
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-cd-records-identifying-features'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerIdentFeatures" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-sec-fingerprint'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerFingerprint" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<Label Text="{Loc 'cd-character-records-viewer-record-sec-dna'}"/>
<Control HorizontalExpand="True" />
<Label Name="RecordContainerDNA" Align="Right" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" Margin="5 5 5 5">
<Label Text="{Loc 'criminal-records-console-status'}" FontColorOverride="DarkGray"/>
<OptionButton Name="StatusOptionButton"/>
<Control MinWidth="5"/>
<Label Name="RecordContainerWantedReason" Visible="False" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
<!-- Entry viewer -->
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="10" SeparationOverride="5">
<ItemList Name="RecordEntryList" HorizontalExpand="True" MinHeight="200" />
<BoxContainer Orientation="Horizontal">
<Button Name="RecordEntryViewButton" Text="{Loc 'cd-character-records-viewer-view-entry'}"/>
<!-- Admin console entry type selector -->
<OptionButton Name="RecordEntryViewType" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
Loading

0 comments on commit bf669e4

Please sign in to comment.