Skip to content

Commit

Permalink
Merge branch 'space-sunrise:master' into DOUBLE-LANG-FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinary1 authored Jun 7, 2024
2 parents 5813f28 + bdbda62 commit ed26da5
Show file tree
Hide file tree
Showing 1,508 changed files with 966,037 additions and 12,645 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/Content.*/GameTicking/ @moonheart08 @EmoGarbage404
/Resources/ServerInfo/ @moonheart08 @Chief-Engineer
/Resources/ServerInfo/Guidebook/ @moonheart08 @EmoGarbage404
/Resources/ServerInfo/Guidebook/ServerRules/ @Chief-Engineer
/Resources/engineCommandPerms.yml @moonheart08 @Chief-Engineer
/Resources/clientCommandPerms.yml @moonheart08 @Chief-Engineer

Expand All @@ -23,6 +24,7 @@
/Resources/Prototypes/Body/ @DrSmugleaf # suffering
/Resources/Prototypes/Entities/Mobs/Player/ @DrSmugleaf
/Resources/Prototypes/Entities/Mobs/Species/ @DrSmugleaf
/Resources/Prototypes/Guidebook/rules.yml @Chief-Engineer
/Content.*/Body/ @DrSmugleaf
/Content.YAMLLinter @DrSmugleaf
/Content.Shared/Damage/ @DrSmugleaf
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/validate-rgas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup Submodule
run: git submodule update --init
- name: Pull engine updates
uses: space-wizards/[email protected]
- uses: PaulRitter/yaml-schema-validator@v1
with:
schema: RobustToolbox/Schemas/rga.yml
schema: Tools/Schemas/rga.yml
path_pattern: .*attributions.ya?ml$
validators_path: RobustToolbox/Schemas/rga_validators.py
validators_requirements: RobustToolbox/Schemas/rga_requirements.txt
validators_path: Tools/Schemas/rga_validators.py
validators_requirements: Tools/Schemas/rga_requirements.txt
16 changes: 11 additions & 5 deletions Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<Control xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:ot="clr-namespace:Content.Client.Administration.UI.Tabs.ObjectsTab"
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label HorizontalExpand="True" SizeFlagsStretchRatio="0.50"
Text="{Loc Object type:}" />
<LineEdit Name="SearchLineEdit" PlaceHolder="{Loc Search...}" HorizontalExpand="True" SizeFlagsStretchRatio="1"/>
<OptionButton Name="ObjectTypeOptions" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
</BoxContainer>
<cc:HSeparator/>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Vertical" Name="ObjectList">
</BoxContainer>
</ScrollContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<ot:ObjectsTabHeader Name="ListHeader"/>
<cc:HSeparator/>
<co:SearchListContainer Name="SearchList" Access="Public" VerticalExpand="True"/>
</BoxContainer>
</BoxContainer>
</Control>
117 changes: 92 additions & 25 deletions Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Client.Station;
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Map.Components;
Expand All @@ -10,20 +12,20 @@ namespace Content.Client.Administration.UI.Tabs.ObjectsTab;
[GenerateTypedNameReferences]
public sealed partial class ObjectsTab : Control
{
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;

private readonly List<ObjectsTabEntry> _objects = new();
private List<ObjectsTabSelection> _selections = new();
private readonly List<ObjectsTabSelection> _selections = new();
private bool _ascending = false; // Set to false for descending order by default
private ObjectsTabHeader.Header _headerClicked = ObjectsTabHeader.Header.ObjectName;
private readonly Color _altColor = Color.FromHex("#292B38");
private readonly Color _defaultColor = Color.FromHex("#2F2F3B");

public event Action<ObjectsTabEntry, GUIBoundKeyEventArgs>? OnEntryKeyBindDown;
public event Action<GUIBoundKeyEventArgs, ListData>? OnEntryKeyBindDown;

// Listen I could either have like 4 different event subscribers (for map / grid / station changes) and manage their lifetimes in AdminUIController
// OR
// I can do this.
private TimeSpan _updateFrequency = TimeSpan.FromSeconds(2);

private TimeSpan _nextUpdate = TimeSpan.FromSeconds(2);
private readonly TimeSpan _updateFrequency = TimeSpan.FromSeconds(2);
private TimeSpan _nextUpdate;

public ObjectsTab()
{
Expand All @@ -42,6 +44,30 @@ public ObjectsTab()
ObjectTypeOptions.AddItem(Enum.GetName((ObjectsTabSelection)type)!);
}

ListHeader.OnHeaderClicked += HeaderClicked;
SearchList.SearchBar = SearchLineEdit;
SearchList.GenerateItem += GenerateButton;
SearchList.DataFilterCondition += DataFilterCondition;

RefreshObjectList();
// Set initial selection and refresh the list to apply the initial sort order
var defaultSelection = ObjectsTabSelection.Grids;
ObjectTypeOptions.SelectId((int)defaultSelection); // Set the default selection
RefreshObjectList(defaultSelection); // Refresh the list with the default selection

// Initialize the next update time
_nextUpdate = TimeSpan.Zero;
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

if (_timing.CurTime < _nextUpdate)
return;

_nextUpdate = _timing.CurTime + _updateFrequency;

RefreshObjectList();
}

Expand Down Expand Up @@ -81,32 +107,72 @@ private void RefreshObjectList(ObjectsTabSelection selection)
throw new ArgumentOutOfRangeException(nameof(selection), selection, null);
}

foreach (var control in _objects)
entities.Sort((a, b) =>
{
ObjectList.RemoveChild(control);
}
var valueA = GetComparableValue(a, _headerClicked);
var valueB = GetComparableValue(b, _headerClicked);
return _ascending ? Comparer<object>.Default.Compare(valueA, valueB) : Comparer<object>.Default.Compare(valueB, valueA);
});

_objects.Clear();

foreach (var (name, nent) in entities)
var listData = new List<ObjectsListData>();
for (int index = 0; index < entities.Count; index++)
{
var ctrl = new ObjectsTabEntry(name, nent);
_objects.Add(ctrl);
ObjectList.AddChild(ctrl);
ctrl.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(ctrl, args);
var info = entities[index];
listData.Add(new ObjectsListData(info, $"{info.Name} {info.Entity}", index % 2 == 0 ? _altColor : _defaultColor));
}

SearchList.PopulateList(listData);
}

protected override void FrameUpdate(FrameEventArgs args)
private void GenerateButton(ListData data, ListContainerButton button)
{
base.FrameUpdate(args);

if (_timing.CurTime < _nextUpdate)
if (data is not ObjectsListData { Info: var info, BackgroundColor: var backgroundColor })
return;

// I do not care for precision.
_nextUpdate = _timing.CurTime + _updateFrequency;
var entry = new ObjectsTabEntry(info.Name, info.Entity, new StyleBoxFlat { BackgroundColor = backgroundColor });
button.ToolTip = $"{info.Name}, {info.Entity}";

// Add key binding event handler
entry.OnKeyBindDown += args => OnEntryKeyBindDown?.Invoke(args, data);

button.AddChild(entry);
}

private bool DataFilterCondition(string filter, ListData listData)
{
if (listData is not ObjectsListData { FilteringString: var filteringString })
return false;

// If the filter is empty, do not filter out any entries
if (string.IsNullOrEmpty(filter))
return true;

return filteringString.Contains(filter, StringComparison.CurrentCultureIgnoreCase);
}

private object GetComparableValue((string Name, NetEntity Entity) entity, ObjectsTabHeader.Header header)
{
return header switch
{
ObjectsTabHeader.Header.ObjectName => entity.Name,
ObjectsTabHeader.Header.EntityID => entity.Entity.ToString(),
_ => entity.Name
};
}

private void HeaderClicked(ObjectsTabHeader.Header header)
{
if (_headerClicked == header)
{
_ascending = !_ascending;
}
else
{
_headerClicked = header;
_ascending = true;
}

ListHeader.UpdateHeaderSymbols(_headerClicked, _ascending);
RefreshObjectList();
}

Expand All @@ -118,3 +184,4 @@ private enum ObjectsTabSelection
}
}

public record ObjectsListData((string Name, NetEntity Entity) Info, string FilteringString, Color BackgroundColor) : ListData;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ContainerButton xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls">
<PanelContainer Name="BackgroundColorPanel"/>
<PanelContainer xmlns="https://spacestation14.io"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Name="BackgroundColorPanel">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
SeparationOverride="4">
Expand All @@ -14,4 +14,4 @@
HorizontalExpand="True"
ClipText="True"/>
</BoxContainer>
</ContainerButton>
</PanelContainer>
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Administration.UI.Tabs.ObjectsTab;

[GenerateTypedNameReferences]
public sealed partial class ObjectsTabEntry : ContainerButton
public sealed partial class ObjectsTabEntry : PanelContainer
{
public NetEntity AssocEntity;

public ObjectsTabEntry(string name, NetEntity nent)
public ObjectsTabEntry(string name, NetEntity nent, StyleBox styleBox)
{
RobustXamlLoader.Load(this);
AssocEntity = nent;
EIDLabel.Text = nent.ToString();
NameLabel.Text = name;
BackgroundColorPanel.PanelOverride = styleBox;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Control xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
<PanelContainer Name="BackgroundColorPanel" Access="Public"/>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
SeparationOverride="4">
<Label Name="ObjectNameLabel"
SizeFlagsStretchRatio="3"
HorizontalExpand="True"
ClipText="True"
Text="{Loc object-tab-object-name}"
MouseFilter="Pass"/>
<cc:VSeparator/>
<Label Name="EntityIDLabel"
SizeFlagsStretchRatio="3"
HorizontalExpand="True"
ClipText="True"
Text="{Loc object-tab-entity-id}"
MouseFilter="Pass"/>
</BoxContainer>
</Control>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;

namespace Content.Client.Administration.UI.Tabs.ObjectsTab
{
[GenerateTypedNameReferences]
public sealed partial class ObjectsTabHeader : Control
{
public event Action<Header>? OnHeaderClicked;

private const string ArrowUp = "↑";
private const string ArrowDown = "↓";

public ObjectsTabHeader()
{
RobustXamlLoader.Load(this);

ObjectNameLabel.OnKeyBindDown += ObjectNameClicked;
EntityIDLabel.OnKeyBindDown += EntityIDClicked;
}

public Label GetHeader(Header header)
{
return header switch
{
Header.ObjectName => ObjectNameLabel,
Header.EntityID => EntityIDLabel,
_ => throw new ArgumentOutOfRangeException(nameof(header), header, null)
};
}

public void ResetHeaderText()
{
ObjectNameLabel.Text = Loc.GetString("object-tab-object-name");
EntityIDLabel.Text = Loc.GetString("object-tab-entity-id");
}

public void UpdateHeaderSymbols(Header headerClicked, bool ascending)
{
ResetHeaderText();
var arrow = ascending ? ArrowUp : ArrowDown;
GetHeader(headerClicked).Text += $" {arrow}";
}

private void HeaderClicked(GUIBoundKeyEventArgs args, Header header)
{
if (args.Function != EngineKeyFunctions.UIClick)
{
return;
}

OnHeaderClicked?.Invoke(header);
args.Handle();
}

private void ObjectNameClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.ObjectName);
}

private void EntityIDClicked(GUIBoundKeyEventArgs args)
{
HeaderClicked(args, Header.EntityID);
}

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

if (disposing)
{
ObjectNameLabel.OnKeyBindDown -= ObjectNameClicked;
EntityIDLabel.OnKeyBindDown -= EntityIDClicked;
}
}

public enum Header
{
ObjectName,
EntityID
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public PlayerTab()
SearchList.ItemKeyBindDown += (args, data) => OnEntryKeyBindDown?.Invoke(args, data);

RefreshPlayerList(_adminSystem.PlayerList);

}

#region Antag Overlay
Expand Down Expand Up @@ -110,7 +111,9 @@ private void RefreshPlayerList(IReadOnlyList<PlayerInfo> players)
_players = players;
PlayerCount.Text = $"Players: {_playerMan.PlayerCount}";

var sortedPlayers = new List<PlayerInfo>(players);
var filteredPlayers = players.Where(info => _showDisconnected || info.Connected).ToList();

var sortedPlayers = new List<PlayerInfo>(filteredPlayers);
sortedPlayers.Sort(Compare);

UpdateHeaderSymbols();
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Construction/UI/FlatpackCreatorMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True" Margin="10">
<BoxContainer SizeFlagsStretchRatio="2" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Vertical">
<SpriteView Name="MachineSprite" Scale="4 4" HorizontalAlignment="Center" VerticalExpand="True" MinSize="128 128"/>
<EntityPrototypeView Name="MachineSprite" Scale="4 4" HorizontalAlignment="Center" VerticalExpand="True" MinSize="128 128"/>
<RichTextLabel Name="MachineNameLabel" HorizontalAlignment="Center" StyleClasses="LabelKeyText"/>
</BoxContainer>
<Control MinHeight="10"/>
Expand Down
Loading

0 comments on commit ed26da5

Please sign in to comment.