--- /dev/null
+<Control xmlns="https://spacestation14.io">
+ <BoxContainer Orientation="Vertical" Margin="5">
+ <Label Name="RecordName" StyleClasses="LabelBig"/>
+ <Label Name="Age"/>
+ <Label Name="Title"/>
+ <Label Name="Job"/>
+ <Label Name="Species"/>
+ <Label Name="Gender"/>
+ <Label Name="Fingerprint"/>
+ <Label Name="Dna"/>
+ <Button Visible="False" Name="DeleteButton" Text="{Loc 'general-station-record-console-delete'}"/>
+ </BoxContainer>
+</Control>
--- /dev/null
+using Content.Shared.StationRecords;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.StationRecords;
+
+[GenerateTypedNameReferences]
+public sealed partial class GeneralRecord : Control
+{
+ public Action<uint>? OnDeletePressed;
+ public GeneralRecord(GeneralStationRecord record, bool canDelete, uint? id)
+ {
+ RobustXamlLoader.Load(this);
+ RecordName.Text = record.Name;
+ Age.Text = Loc.GetString("general-station-record-console-record-age", ("age", record.Age.ToString()));
+ Title.Text = Loc.GetString("general-station-record-console-record-title",
+ ("job", Loc.GetString(record.JobTitle)));
+ Species.Text = Loc.GetString("general-station-record-console-record-species", ("species", record.Species));
+ Gender.Text = Loc.GetString("general-station-record-console-record-gender",
+ ("gender", record.Gender.ToString()));
+ Fingerprint.Text = Loc.GetString("general-station-record-console-record-fingerprint",
+ ("fingerprint", record.Fingerprint ?? Loc.GetString("generic-not-available-shorthand")));
+ Dna.Text = Loc.GetString("general-station-record-console-record-dna",
+ ("dna", record.DNA ?? Loc.GetString("generic-not-available-shorthand")));
+
+ if (canDelete && id != null )
+ {
+ DeleteButton.Visible = true;
+ DeleteButton.OnPressed += _ => OnDeletePressed?.Invoke(id.Value);
+ }
+ }
+}
SendMessage(new SelectStationRecord(key));
_window.OnFiltersChanged += (type, filterValue) =>
SendMessage(new SetStationRecordFilter(type, filterValue));
+ _window.OnDeleted += id => SendMessage(new DeleteStationRecord(id));
_window.OnClose += Close;
_window.OpenCentered();
</BoxContainer>
<BoxContainer Orientation="Vertical" Margin="5">
<Label Name="RecordContainerStatus" Visible="False" Text="{Loc 'general-station-record-console-select-record-info'}"/>
- <BoxContainer Name="RecordContainer" Orientation="Vertical" />
+ <Control Name="RecordContainer" Visible="False"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
using Content.Shared.StationRecords;
using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
public Action<uint?>? OnKeySelected;
public Action<StationRecordFilterType, string>? OnFiltersChanged;
+ public Action<uint>? OnDeleted;
private bool _isPopulating;
RecordContainerStatus.Text = state.SelectedKey == null
? Loc.GetString("general-station-record-console-no-record-found")
: Loc.GetString("general-station-record-console-select-record-info");
- PopulateRecordContainer(state.Record);
+ PopulateRecordContainer(state.Record, state.CanDeleteEntries, state.SelectedKey);
}
else
{
- RecordContainer.DisposeAllChildren();
RecordContainer.RemoveAllChildren();
}
}
RecordListing.SortItemsByText();
}
- private void PopulateRecordContainer(GeneralStationRecord record)
+ private void PopulateRecordContainer(GeneralStationRecord record, bool enableDelete, uint? id)
{
- RecordContainer.DisposeAllChildren();
RecordContainer.RemoveAllChildren();
- // sure
- var recordControls = new Control[]
- {
- new Label()
- {
- Text = record.Name,
- StyleClasses = { "LabelBig" }
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-age", ("age", record.Age.ToString()))
-
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-title", ("job", Loc.GetString(record.JobTitle)))
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-species", ("species", record.Species))
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-gender", ("gender", record.Gender.ToString()))
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-fingerprint", ("fingerprint", record.Fingerprint ?? Loc.GetString("generic-not-available-shorthand")))
- },
- new Label()
- {
- Text = Loc.GetString("general-station-record-console-record-dna", ("dna", record.DNA ?? Loc.GetString("generic-not-available-shorthand")))
- }
- };
+ var newRecord = new GeneralRecord(record, enableDelete, id);
+ newRecord.OnDeletePressed = OnDeleted;
- foreach (var control in recordControls)
- {
- RecordContainer.AddChild(control);
- }
+ RecordContainer.AddChild(newRecord);
}
private void FilterListingOfRecords(string text = "")
{
return Loc.GetString($"general-station-record-{type.ToString().ToLower()}-filter");
}
+
}
/// </summary>
[DataField]
public StationRecordsFilter? Filter;
+
+ /// <summary>
+ /// Whether this Records Console is able to delete entries.
+ /// </summary>
+ [DataField]
+ public bool CanDeleteEntries;
}
subs.Event<BoundUIOpenedEvent>(UpdateUserInterface);
subs.Event<SelectStationRecord>(OnKeySelected);
subs.Event<SetStationRecordFilter>(OnFiltersChanged);
+ subs.Event<DeleteStationRecord>(OnRecordDelete);
});
}
+ private void OnRecordDelete(Entity<GeneralStationRecordConsoleComponent> ent, ref DeleteStationRecord args)
+ {
+ if (!ent.Comp.CanDeleteEntries)
+ return;
+
+ var owning = _station.GetOwningStation(ent.Owner);
+
+ if (owning != null)
+ _stationRecords.RemoveRecord(new StationRecordKey(args.Id, owning.Value));
+ UpdateUserInterface(ent); // Apparently an event does not get raised for this.
+ }
+
private void UpdateUserInterface<T>(Entity<GeneralStationRecordConsoleComponent> ent, ref T args)
{
UpdateUserInterface(ent);
case 0:
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, new GeneralStationRecordConsoleState());
return;
- case 1:
- console.ActiveKey = listing.Keys.First();
+ default:
+ if (console.ActiveKey == null)
+ console.ActiveKey = listing.Keys.First();
break;
}
var key = new StationRecordKey(id, owningStation.Value);
_stationRecords.TryGetRecord<GeneralStationRecord>(key, out var record, stationRecords);
- GeneralStationRecordConsoleState newState = new(id, record, listing, console.Filter);
+ GeneralStationRecordConsoleState newState = new(id, record, listing, console.Filter, ent.Comp.CanDeleteEntries);
_ui.SetUiState(uid, GeneralStationRecordConsoleKey.Key, newState);
}
}
public readonly GeneralStationRecord? Record;
public readonly Dictionary<uint, string>? RecordListing;
public readonly StationRecordsFilter? Filter;
+ public readonly bool CanDeleteEntries;
- public GeneralStationRecordConsoleState(uint? key, GeneralStationRecord? record,
- Dictionary<uint, string>? recordListing, StationRecordsFilter? newFilter)
+ public GeneralStationRecordConsoleState(uint? key,
+ GeneralStationRecord? record,
+ Dictionary<uint, string>? recordListing,
+ StationRecordsFilter? newFilter,
+ bool canDeleteEntries)
{
SelectedKey = key;
Record = record;
RecordListing = recordListing;
Filter = newFilter;
+ CanDeleteEntries = canDeleteEntries;
}
- public GeneralStationRecordConsoleState() : this(null, null, null, null)
+ public GeneralStationRecordConsoleState() : this(null, null, null, null, false)
{
}
SelectedKey = selectedKey;
}
}
+
+
+[Serializable, NetSerializable]
+public sealed class DeleteStationRecord : BoundUserInterfaceMessage
+{
+ public DeleteStationRecord(uint id)
+ {
+ Id = id;
+ }
+
+ public readonly uint Id;
+}
general-station-record-dna-filter = DNA
general-station-record-console-search-records = Search
general-station-record-console-reset-filters = Reset
+general-station-record-console-delete = Delete
- type: CargoOrderConsole
- type: CrewMonitoringConsole
- type: GeneralStationRecordConsole
+ canDeleteEntries: true
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: CrewMonitor