Skip to content

Commit

Permalink
Merge PR #157 Upstream говна
Browse files Browse the repository at this point in the history
  • Loading branch information
EndrAnimet authored Dec 13, 2024
2 parents d9a5b6a + d248d81 commit cf34054
Show file tree
Hide file tree
Showing 227 changed files with 73,700 additions and 30,656 deletions.
24 changes: 21 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,36 @@
# C# code
/Content.*/ @DeltaV-Station/maintainers

# Any assets
/Resources/ @DeltaV-Station/maintainers

# Server config files
/Resources/ConfigPresets/ @MilonPL

# YML files
/Resources/*.yml @DeltaV-Station/yaml-maintainers
/Resources/**/*.yml @DeltaV-Station/yaml-maintainers

# Sprites
/Resources/Textures/ @IamVelcroboy
/Resources/Textures/ @DeltaV-Station/direction

# Lobby art and music - automatically direction issues since its immediately visible to players
/Resources/Audio/Lobby/ @DeltaV-Station/game-directors
/Resources/Textures/LobbyScreens/ @DeltaV-Station/game-directors
/Resources/Audio/Lobby/ @DeltaV-Station/direction
/Resources/Textures/LobbyScreens/ @DeltaV-Station/direction

# Maps
/Resources/Maps/ @DeltaV-Station/maptainers
/Resources/Prototypes/Maps/ @DeltaV-Station/maptainers
/Content.IntegrationTests/Tests/PostMapInitTest.cs @DeltaV-Station/maptainers

# Server rules
/Resources/ServerInfo/Guidebook/DeltaV/Rules/ @DeltaV-Station/head-administrators

# Tools and scripts
/Tools/ @deltanedas @MilonPL

# Workflows, codeowners, templates, etc.
/.github/ @deltanedas @MilonPL

# Standalone files in the root repo
/* @deltanedas
9 changes: 4 additions & 5 deletions Content.Client/DeltaV/AACTablet/UI/AACBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Content.Shared.DeltaV.AACTablet;
using Content.Shared.DeltaV.QuickPhrase;
using Robust.Shared.Prototypes;

namespace Content.Client.DeltaV.AACTablet.UI;

public sealed class AACBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

[ViewVariables]
private AACWindow? _window;

Expand All @@ -18,21 +17,21 @@ protected override void Open()
{
base.Open();
_window?.Close();
_window = new AACWindow(this, _prototypeManager);
_window = new AACWindow();
_window.OpenCentered();

_window.PhraseButtonPressed += OnPhraseButtonPressed;
_window.OnClose += Close;
}

private void OnPhraseButtonPressed(string phraseId)
private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId)
{
SendMessage(new AACTabletSendPhraseMessage(phraseId));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Dispose();
_window?.Orphan();
}
}
2 changes: 1 addition & 1 deletion Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
MinSize="540 300">
<ScrollContainer HScrollEnabled="False" Name="WindowBody">
</ScrollContainer>
</controls:FancyWindow>
</controls:FancyWindow>
54 changes: 22 additions & 32 deletions Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ namespace Content.Client.DeltaV.AACTablet.UI;
[GenerateTypedNameReferences]
public sealed partial class AACWindow : FancyWindow
{
private IPrototypeManager _prototypeManager;
public event Action<string>? PhraseButtonPressed;
[Dependency] private readonly IPrototypeManager _prototype = default!;
public event Action<ProtoId<QuickPhrasePrototype>>? PhraseButtonPressed;

public AACWindow(AACBoundUserInterface ui, IPrototypeManager prototypeManager)
private const float SpaceWidth = 10f;
private const float ParentWidth = 540f;
private const int ColumnCount = 4;

private const int ButtonWidth =
(int)((ParentWidth - SpaceWidth * 2) / ColumnCount - SpaceWidth * ((ColumnCount - 1f) / ColumnCount));

public AACWindow()
{
RobustXamlLoader.Load(this);
_prototypeManager = prototypeManager;
PopulateGui(ui);
IoCManager.InjectDependencies(this);
PopulateGui();
}

private void PopulateGui(AACBoundUserInterface ui)
private void PopulateGui()
{
var loc = IoCManager.Resolve<ILocalizationManager>();
var phrases = _prototypeManager.EnumeratePrototypes<QuickPhrasePrototype>().ToList();
var phrases = _prototype.EnumeratePrototypes<QuickPhrasePrototype>().ToList();

// take ALL phrases and turn them into tabs and groups, so the buttons are sorted and tabbed
var sortedTabs = phrases
Expand All @@ -38,7 +44,7 @@ private void PopulateGui(AACBoundUserInterface ui)
.OrderBy(gg => gg.Key)
.ToDictionary(
gg => gg.Key,
gg => gg.OrderBy(p => loc.GetString(p.Text)).ToList()
gg => gg.OrderBy(p => Loc.GetString(p.Text)).ToList()
)
);

Expand All @@ -49,11 +55,10 @@ private void PopulateGui(AACBoundUserInterface ui)
private TabContainer CreateTabContainer(Dictionary<string, Dictionary<string, List<QuickPhrasePrototype>>> sortedTabs)
{
var tabContainer = new TabContainer();
var loc = IoCManager.Resolve<ILocalizationManager>();

foreach (var tab in sortedTabs)
{
var tabName = loc.GetString(tab.Key);
var tabName = Loc.GetString(tab.Key);
var boxContainer = CreateBoxContainerForTab(tab.Value);
tabContainer.AddChild(boxContainer);
tabContainer.SetTabTitle(tabContainer.ChildCount - 1, tabName);
Expand All @@ -64,7 +69,7 @@ private TabContainer CreateTabContainer(Dictionary<string, Dictionary<string, Li

private BoxContainer CreateBoxContainerForTab(Dictionary<string, List<QuickPhrasePrototype>> groups)
{
var boxContainer = new BoxContainer()
var boxContainer = new BoxContainer
{
HorizontalExpand = true,
Orientation = BoxContainer.LayoutOrientation.Vertical
Expand All @@ -81,7 +86,7 @@ private BoxContainer CreateBoxContainerForTab(Dictionary<string, List<QuickPhras
return boxContainer;
}

private Label CreateHeaderForGroup(string groupName)
private static Label CreateHeaderForGroup(string groupName)
{
var header = new Label
{
Expand All @@ -96,13 +101,12 @@ private Label CreateHeaderForGroup(string groupName)

private GridContainer CreateButtonContainerForGroup(List<QuickPhrasePrototype> phrases)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
var buttonContainer = CreateButtonContainer();
foreach (var phrase in phrases)
{
var text = loc.GetString(phrase.Text);
var text = Loc.GetString(phrase.Text);
var button = CreatePhraseButton(text, phrase.StyleClass);
button.OnPressed += _ => OnPhraseButtonPressed(phrase.ID);
button.OnPressed += _ => OnPhraseButtonPressed(new ProtoId<QuickPhrasePrototype>(phrase.ID));
buttonContainer.AddChild(button);
}
return buttonContainer;
Expand All @@ -121,11 +125,10 @@ private static GridContainer CreateButtonContainer()

private static Button CreatePhraseButton(string text, string styleClass)
{
var buttonWidth = GetButtonWidth();
var phraseButton = new Button
{
Access = AccessLevel.Public,
MaxSize = new Vector2(buttonWidth, buttonWidth),
MaxSize = new Vector2(ButtonWidth, ButtonWidth),
ClipText = false,
HorizontalExpand = true,
StyleClasses = { styleClass }
Expand All @@ -142,20 +145,7 @@ private static Button CreatePhraseButton(string text, string styleClass)
return phraseButton;
}

private static int GetButtonWidth()
{
var spaceWidth = 10;
var parentWidth = 540;
var columnCount = 4;

var paddingSize = spaceWidth * 2;
var gutterScale = (columnCount - 1) / columnCount;
var columnWidth = (parentWidth - paddingSize) / columnCount;
var buttonWidth = columnWidth - spaceWidth * gutterScale;
return buttonWidth;
}

private void OnPhraseButtonPressed(string phraseId)
private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId)
{
PhraseButtonPressed?.Invoke(phraseId);
}
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/DeltaV/Silicons/Laws/SlavedBorgSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.DeltaV.Silicons.Laws;

namespace Content.Client.DeltaV.Silicons.Laws;

public sealed class SlavedBorgSystem : SharedSlavedBorgSystem;
5 changes: 5 additions & 0 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ await server.WaitPost(() =>
if (protoId == "MobHumanSpaceNinja")
continue;

// TODO fix tests properly upstream
// Fails due to audio components made when making anouncements
if (protoId == "StandardNanotrasenStation")
continue;

var count = server.EntMan.EntityCount;
var clientCount = client.EntMan.EntityCount;
EntityUid uid = default;
Expand Down
40 changes: 24 additions & 16 deletions Content.Server.Database/SnakeCaseNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ConventionSet ModifyConventions(ConventionSet conventionSet)
}
}

public class SnakeCaseConvention :
public partial class SnakeCaseConvention :
IEntityTypeAddedConvention,
IEntityTypeAnnotationChangedConvention,
IPropertyAddedConvention,
Expand All @@ -99,22 +99,27 @@ public SnakeCaseConvention() {}

public static string RewriteName(string name)
{
var regex = new Regex("[A-Z]+", RegexOptions.Compiled);
return regex.Replace(
name,
(Match match) => {
if (match.Index == 0 && (match.Value == "FK" || match.Value == "PK" || match.Value == "IX")) {
return match.Value;
return UpperCaseLocator()
.Replace(
name,
(Match match) => {
if (match.Index == 0 && (match.Value == "FK" || match.Value == "PK" || match.Value == "IX")) {
return match.Value;
}
if (match.Value == "HWI")
return (match.Index == 0 ? "" : "_") + "hwi";
if (match.Index == 0)
return match.Value.ToLower();
if (match.Length > 1)
return $"_{match.Value[..^1].ToLower()}_{match.Value[^1..^0].ToLower()}";

// Do not add a _ if there is already one before this. This happens with owned entities.
if (name[match.Index - 1] == '_')
return match.Value.ToLower();

return "_" + match.Value.ToLower();
}
if (match.Value == "HWI")
return (match.Index == 0 ? "" : "_") + "hwi";
if (match.Index == 0)
return match.Value.ToLower();
if (match.Length > 1)
return $"_{match.Value[..^1].ToLower()}_{match.Value[^1..^0].ToLower()}";
return "_" + match.Value.ToLower();
}
);
);
}

public virtual void ProcessEntityTypeAdded(
Expand Down Expand Up @@ -332,5 +337,8 @@ private static void RewriteColumnName(IConventionPropertyBuilder propertyBuilder
}
}
}

[GeneratedRegex("[A-Z]+", RegexOptions.Compiled)]
private static partial Regex UpperCaseLocator();
}
}
71 changes: 25 additions & 46 deletions Content.Server/Administration/Commands/RoleBanListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Linq;
using System.Text;
using Content.Server.Administration.BanList;
using Content.Server.EUI;
using Content.Server.Database;
using Content.Shared.Administration;
using Robust.Server.Player;
Expand All @@ -10,6 +12,12 @@ namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.Ban)]
public sealed class RoleBanListCommand : IConsoleCommand
{
[Dependency] private readonly IServerDbManager _dbManager = default!;

[Dependency] private readonly EuiManager _eui = default!;

[Dependency] private readonly IPlayerLocator _locator = default!;

public string Command => "rolebanlist";
public string Description => Loc.GetString("cmd-rolebanlist-desc");
public string Help => Loc.GetString("cmd-rolebanlist-help");
Expand All @@ -29,66 +37,37 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var dbMan = IoCManager.Resolve<IServerDbManager>();

var target = args[0];
var data = await _locator.LookupIdByNameOrIdAsync(args[0]);

var locator = IoCManager.Resolve<IPlayerLocator>();
var located = await locator.LookupIdByNameOrIdAsync(target);
if (located == null)
if (data == null)
{
shell.WriteError("Unable to find a player with that name or id.");
return;
}

var targetUid = located.UserId;
var targetHWid = located.LastHWId;
var targetAddress = located.LastAddress;

var bans = await dbMan.GetServerRoleBansAsync(targetAddress, targetUid, targetHWid, includeUnbanned);

if (bans.Count == 0)
if (shell.Player is not { } player)
{
shell.WriteLine("That user has no bans in their record.");
return;
}

var bansString = new StringBuilder("Bans in record:\n");
var bans = await _dbManager.GetServerRoleBansAsync(data.LastAddress, data.UserId, data.LastHWId, includeUnbanned);

var first = true;
foreach (var ban in bans)
{
if (!first)
bansString.Append("\n\n");
else
first = false;

bansString
.Append("Ban ID: ")
.Append(ban.Id)
.Append('\n')
.Append("Role: ")
.Append(ban.Role)
.Append('\n')
.Append("Banned on ")
.Append(ban.BanTime);

if (ban.ExpirationTime != null)
if (bans.Count == 0)
{
bansString
.Append(" until ")
.Append(ban.ExpirationTime.Value);
shell.WriteLine("That user has no bans in their record.");
return;
}

bansString
.Append('\n');

bansString
.Append("Reason: ")
.Append(ban.Reason);
foreach (var ban in bans)
{
var msg = $"ID: {ban.Id}: Role: {ban.Role} Reason: {ban.Reason}";
shell.WriteLine(msg);
}
return;
}

shell.WriteLine(bansString.ToString());
var ui = new BanListEui();
_eui.OpenEui(ui, player);
await ui.ChangeBanListPlayer(data.UserId);

}

public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
Expand Down
Loading

0 comments on commit cf34054

Please sign in to comment.