diff --git a/.editorconfig b/.editorconfig index 872a068c7c..58d0d332bb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,7 @@ indent_style = space tab_width = 4 # New line preferences -#end_of_line = crlf +end_of_line = crlf:suggestion insert_final_newline = true trim_trailing_whitespace = true @@ -104,6 +104,7 @@ csharp_preferred_modifier_order = public, private, protected, internal, new, abs # 'using' directive preferences csharp_using_directive_placement = outside_namespace:silent +csharp_style_namespace_declarations = file_scoped:suggestion #### C# Formatting Rules #### diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index a44cac2cd1..877273d764 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -35,14 +35,14 @@ jobs: - name: Install Dependencies run: | - cd "Tools/changelog" + cd "Tools/changelogs" npm install shell: bash continue-on-error: true - name: Generate Changelog run: | - cd "Tools/changelog" + cd "Tools/changelogs" node changelog.js shell: bash continue-on-error: true diff --git a/.github/workflows/prtitlecase.yml b/.github/workflows/prtitlecase.yml new file mode 100644 index 0000000000..b3150dcc7e --- /dev/null +++ b/.github/workflows/prtitlecase.yml @@ -0,0 +1,34 @@ +name: PR Title Case +on: + pull_request_target: + types: [opened, edited, synchronize] + +env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + +jobs: + prtitlecase: + runs-on: ubuntu-latest + steps: + - name: Checkout Master + uses: actions/checkout@v3 + with: + token: ${{ secrets.BOT_TOKEN }} + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Install Dependencies + run: | + cd "Tools/prtitlecase" + npm install + shell: bash + + - name: Change Title + run: | + cd "Tools/prtitlecase" + node index.js + shell: bash diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e0d3ae890..dc6e26cbea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,10 @@ { "omnisharp.analyzeOpenDocumentsOnly": true, - "dotnet.defaultSolution": "SpaceStation14.sln" + "dotnet.defaultSolution": "SpaceStation14.sln", + "json.schemas": [ + { + "fileMatch": [ "**/meta.json" ], + "url": "https://raw.githubusercontent.com/Simple-Station/Einstein-Engines/master/.github/rsi-schema.json" + } + ] } diff --git a/BuildChecker/BuildChecker.csproj b/BuildChecker/BuildChecker.csproj index 63d16fa970..d4f9a41254 100644 --- a/BuildChecker/BuildChecker.csproj +++ b/BuildChecker/BuildChecker.csproj @@ -14,8 +14,6 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild --> - python3 - py -3 {C899FCA4-7037-4E49-ABC2-44DE72487110} .NETFramework, Version=v4.7.2 false @@ -39,7 +37,7 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild bin\DebugOpt\ - + diff --git a/BuildChecker/git_helper.py b/BuildChecker/git_helper.py deleted file mode 100644 index becd4506e8..0000000000 --- a/BuildChecker/git_helper.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python3 -# Installs git hooks, updates them, updates submodules, that kind of thing. - -import subprocess -import sys -import os -import shutil -from pathlib import Path -from typing import List - -SOLUTION_PATH = Path("..") / "SpaceStation14.sln" -# If this doesn't match the saved version we overwrite them all. -CURRENT_HOOKS_VERSION = "2" -QUIET = len(sys.argv) == 2 and sys.argv[1] == "--quiet" - - -def run_command(command: List[str], capture: bool = False) -> subprocess.CompletedProcess: - """ - Runs a command with pretty output. - """ - text = ' '.join(command) - if not QUIET: - print("$ {}".format(text)) - - sys.stdout.flush() - - completed = None - - if capture: - completed = subprocess.run(command, cwd="..", stdout=subprocess.PIPE) - else: - completed = subprocess.run(command, cwd="..") - - if completed.returncode != 0: - print("Error: command exited with code {}!".format(completed.returncode)) - - return completed - - -def update_submodules(): - """ - Updates all submodules. - """ - - if ('GITHUB_ACTIONS' in os.environ): - return - - if os.path.isfile("DISABLE_SUBMODULE_AUTOUPDATE"): - return - - if shutil.which("git") is None: - raise FileNotFoundError("git not found in PATH") - - # If the status doesn't match, force VS to reload the solution. - # status = run_command(["git", "submodule", "status"], capture=True) - run_command(["git", "submodule", "update", "--init", "--recursive"]) - # status2 = run_command(["git", "submodule", "status"], capture=True) - - # Something changed. - # if status.stdout != status2.stdout: - # print("Git submodules changed. Reloading solution.") - # reset_solution() - - -def install_hooks(): - """ - Installs the necessary git hooks into .git/hooks. - """ - - # Read version file. - if os.path.isfile("INSTALLED_HOOKS_VERSION"): - with open("INSTALLED_HOOKS_VERSION", "r") as f: - if f.read() == CURRENT_HOOKS_VERSION: - if not QUIET: - print("No hooks change detected.") - return - - with open("INSTALLED_HOOKS_VERSION", "w") as f: - f.write(CURRENT_HOOKS_VERSION) - - print("Hooks need updating.") - - hooks_target_dir = Path("..")/".git"/"hooks" - hooks_source_dir = Path("hooks") - - # Clear entire tree since we need to kill deleted files too. - for filename in os.listdir(str(hooks_target_dir)): - os.remove(str(hooks_target_dir/filename)) - - for filename in os.listdir(str(hooks_source_dir)): - print("Copying hook {}".format(filename)) - shutil.copy2(str(hooks_source_dir/filename), - str(hooks_target_dir/filename)) - - -def reset_solution(): - """ - Force VS to think the solution has been changed to prompt the user to reload it, thus fixing any load errors. - """ - - with SOLUTION_PATH.open("r") as f: - content = f.read() - - with SOLUTION_PATH.open("w") as f: - f.write(content) - - -if __name__ == '__main__': - install_hooks() - update_submodules() diff --git a/BuildChecker/hooks/post-checkout b/BuildChecker/hooks/post-checkout deleted file mode 100755 index c5662445c2..0000000000 --- a/BuildChecker/hooks/post-checkout +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -gitroot=`git rev-parse --show-toplevel` - -cd "$gitroot/BuildChecker" - -if [[ `uname` == MINGW* || `uname` == CYGWIN* ]]; then - # Windows - py -3 git_helper.py --quiet -else - # Not Windows, so probably some other Unix thing. - python3 git_helper.py --quiet -fi diff --git a/BuildChecker/hooks/post-merge b/BuildChecker/hooks/post-merge deleted file mode 100755 index 85fe61d966..0000000000 --- a/BuildChecker/hooks/post-merge +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Just call post-checkout since it does the same thing. -gitroot=`git rev-parse --show-toplevel` -bash "$gitroot/.git/hooks/post-checkout" diff --git a/Content.Client/Access/AccessOverlay.cs b/Content.Client/Access/AccessOverlay.cs index 2be3d07e90..59c9441036 100644 --- a/Content.Client/Access/AccessOverlay.cs +++ b/Content.Client/Access/AccessOverlay.cs @@ -9,20 +9,20 @@ namespace Content.Client.Access; public sealed class AccessOverlay : Overlay { + private const string TextFontPath = "/Fonts/NotoSans/NotoSans-Regular.ttf"; + private const int TextFontSize = 12; + private readonly IEntityManager _entityManager; - private readonly EntityLookupSystem _lookup; - private readonly SharedTransformSystem _xform; + private readonly SharedTransformSystem _transformSystem; private readonly Font _font; public override OverlaySpace Space => OverlaySpace.ScreenSpace; - public AccessOverlay(IEntityManager entManager, IResourceCache cache, EntityLookupSystem lookup, SharedTransformSystem xform) + public AccessOverlay(IEntityManager entityManager, IResourceCache resourceCache, SharedTransformSystem transformSystem) { - _entityManager = entManager; - _lookup = lookup; - _xform = xform; - - _font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12); + _entityManager = entityManager; + _transformSystem = transformSystem; + _font = resourceCache.GetFont(TextFontPath, TextFontSize); } protected override void Draw(in OverlayDrawArgs args) @@ -30,52 +30,65 @@ protected override void Draw(in OverlayDrawArgs args) if (args.ViewportControl == null) return; - var readerQuery = _entityManager.GetEntityQuery(); - var xformQuery = _entityManager.GetEntityQuery(); - - foreach (var ent in _lookup.GetEntitiesIntersecting(args.MapId, args.WorldAABB, - LookupFlags.Static | LookupFlags.Approximate)) + var textBuffer = new StringBuilder(); + var query = _entityManager.EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var accessReader, out var transform)) { - if (!readerQuery.TryGetComponent(ent, out var reader) || - !xformQuery.TryGetComponent(ent, out var xform)) + textBuffer.Clear(); + + var entityName = _entityManager.ToPrettyString(uid); + textBuffer.AppendLine(entityName.Prototype); + textBuffer.Append("UID: "); + textBuffer.Append(entityName.Uid.Id); + textBuffer.Append(", NUID: "); + textBuffer.Append(entityName.Nuid.Id); + textBuffer.AppendLine(); + + if (!accessReader.Enabled) { + textBuffer.AppendLine("-Disabled"); continue; } - var text = new StringBuilder(); - var index = 0; - var a = $"{_entityManager.ToPrettyString(ent)}"; - text.Append(a); - - foreach (var list in reader.AccessLists) + if (accessReader.AccessLists.Count > 0) { - a = $"Tag {index}"; - text.AppendLine(a); - - foreach (var entry in list) + var groupNumber = 0; + foreach (var accessList in accessReader.AccessLists) { - a = $"- {entry}"; - text.AppendLine(a); + groupNumber++; + foreach (var entry in accessList) + { + textBuffer.Append("+Set "); + textBuffer.Append(groupNumber); + textBuffer.Append(": "); + textBuffer.Append(entry.Id); + textBuffer.AppendLine(); + } } - - index++; } - - string textStr; - - if (text.Length >= 2) + else { - textStr = text.ToString(); - textStr = textStr[..^2]; + textBuffer.AppendLine("+Unrestricted"); } - else + + foreach (var key in accessReader.AccessKeys) { - textStr = ""; + textBuffer.Append("+Key "); + textBuffer.Append(key.OriginStation); + textBuffer.Append(": "); + textBuffer.Append(key.Id); + textBuffer.AppendLine(); } - var screenPos = args.ViewportControl.WorldToScreen(_xform.GetWorldPosition(xform)); + foreach (var tag in accessReader.DenyTags) + { + textBuffer.Append("-Tag "); + textBuffer.AppendLine(tag.Id); + } - args.ScreenHandle.DrawString(_font, screenPos, textStr, Color.Gold); + var accessInfoText = textBuffer.ToString(); + var screenPos = args.ViewportControl.WorldToScreen(_transformSystem.GetWorldPosition(transform)); + args.ScreenHandle.DrawString(_font, screenPos, accessInfoText, Color.Gold); } } } diff --git a/Content.Client/Access/Commands/ShowAccessReadersCommand.cs b/Content.Client/Access/Commands/ShowAccessReadersCommand.cs index 7c804dd969..cb6cb6cf6b 100644 --- a/Content.Client/Access/Commands/ShowAccessReadersCommand.cs +++ b/Content.Client/Access/Commands/ShowAccessReadersCommand.cs @@ -7,8 +7,16 @@ namespace Content.Client.Access.Commands; public sealed class ShowAccessReadersCommand : IConsoleCommand { public string Command => "showaccessreaders"; - public string Description => "Shows all access readers in the viewport"; - public string Help => $"{Command}"; + + public string Description => "Toggles showing access reader permissions on the map"; + public string Help => """ + Overlay Info: + -Disabled | The access reader is disabled + +Unrestricted | The access reader has no restrictions + +Set [Index]: [Tag Name]| A tag in an access set (accessor needs all tags in the set to be allowed by the set) + +Key [StationUid]: [StationRecordKeyId] | A StationRecordKey that is allowed + -Tag [Tag Name] | A tag that is not allowed (takes priority over other allows) + """; public void Execute(IConsoleShell shell, string argStr, string[] args) { var collection = IoCManager.Instance; @@ -26,10 +34,9 @@ public void Execute(IConsoleShell shell, string argStr, string[] args) var entManager = collection.Resolve(); var cache = collection.Resolve(); - var lookup = entManager.System(); var xform = entManager.System(); - overlay.AddOverlay(new AccessOverlay(entManager, cache, lookup, xform)); + overlay.AddOverlay(new AccessOverlay(entManager, cache, xform)); shell.WriteLine($"Set access reader debug overlay to true"); } } diff --git a/Content.Client/Access/UI/AccessLevelControl.xaml b/Content.Client/Access/UI/AccessLevelControl.xaml new file mode 100644 index 0000000000..56968d8983 --- /dev/null +++ b/Content.Client/Access/UI/AccessLevelControl.xaml @@ -0,0 +1,4 @@ + + diff --git a/Content.Client/Access/UI/AccessLevelControl.xaml.cs b/Content.Client/Access/UI/AccessLevelControl.xaml.cs new file mode 100644 index 0000000000..34db80b7af --- /dev/null +++ b/Content.Client/Access/UI/AccessLevelControl.xaml.cs @@ -0,0 +1,52 @@ +using System.Linq; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; +using Content.Shared.Access; +using Content.Shared.Access.Systems; + +namespace Content.Client.Access.UI; + +[GenerateTypedNameReferences] +public sealed partial class AccessLevelControl : GridContainer +{ + public readonly Dictionary, Button> ButtonsList = new(); + + public AccessLevelControl() + { + RobustXamlLoader.Load(this); + } + + public void Populate(List> accessLevels, IPrototypeManager prototypeManager) + { + foreach (var access in accessLevels) + { + if (!prototypeManager.TryIndex(access, out var accessLevel)) + { + Logger.Error($"Unable to find accesslevel for {access}"); + continue; + } + + var newButton = new Button + { + Text = accessLevel.GetAccessLevelName(), + ToggleMode = true, + }; + AddChild(newButton); + ButtonsList.Add(accessLevel.ID, newButton); + } + } + + public void UpdateState( + List> pressedList, + List>? enabledList = null) + { + foreach (var (accessName, button) in ButtonsList) + { + button.Pressed = pressedList.Contains(accessName); + button.Disabled = !(enabledList?.Contains(accessName) ?? true); + } + } +} diff --git a/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs b/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs index 0c23542f79..c1b63dc4d0 100644 --- a/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs +++ b/Content.Client/Access/UI/AccessOverriderBoundUserInterface.cs @@ -64,7 +64,7 @@ protected override void UpdateState(BoundUserInterfaceState state) _window?.UpdateState(castState); } - public void SubmitData(List newAccessList) + public void SubmitData(List> newAccessList) { SendMessage(new WriteToTargetAccessReaderIdMessage(newAccessList)); } diff --git a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs index 2fd0057121..6025c3b551 100644 --- a/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs +++ b/Content.Client/Access/UI/AccessOverriderWindow.xaml.cs @@ -16,7 +16,6 @@ public sealed partial class AccessOverriderWindow : DefaultWindow [Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; - private readonly ISawmill _logMill = default!; private readonly AccessOverriderBoundUserInterface _owner; private readonly Dictionary _accessButtons = new(); @@ -25,7 +24,7 @@ public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototype { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - _logMill = _logManager.GetSawmill(SharedAccessOverriderSystem.Sawmill); + var logMill = _logManager.GetSawmill(SharedAccessOverriderSystem.Sawmill); _owner = owner; @@ -33,13 +32,13 @@ public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototype { if (!prototypeManager.TryIndex(access, out var accessLevel)) { - _logMill.Error($"Unable to find accesslevel for {access}"); + logMill.Error($"Unable to find accesslevel for {access}"); continue; } var newButton = new Button { - Text = GetAccessLevelName(accessLevel), + Text = accessLevel.GetAccessLevelName(), ToggleMode = true, }; @@ -49,14 +48,6 @@ public AccessOverriderWindow(AccessOverriderBoundUserInterface owner, IPrototype } } - private static string GetAccessLevelName(AccessLevelPrototype prototype) - { - if (prototype.Name is { } name) - return Loc.GetString(name); - - return prototype.ID; - } - public void UpdateState(AccessOverriderBoundUserInterfaceState state) { PrivilegedIdLabel.Text = state.PrivilegedIdName; @@ -105,7 +96,7 @@ private void SubmitData() _owner.SubmitData( // Iterate over the buttons dictionary, filter by `Pressed`, only get key from the key/value pair - _accessButtons.Where(x => x.Value.Pressed).Select(x => x.Key).ToList()); + _accessButtons.Where(x => x.Value.Pressed).Select(x => new ProtoId(x.Key)).ToList()); } } } diff --git a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs index 898792aa03..5b7011c195 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -1,5 +1,6 @@ using Content.Shared.Access; using Content.Shared.Access.Components; +using Content.Shared.Access; using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Content.Shared.CrewManifest; @@ -28,7 +29,6 @@ protected override void Open() if (EntMan.TryGetComponent(Owner, out var idCard)) { accessLevels = idCard.AccessLevels; - accessLevels.Sort(); } else { @@ -65,7 +65,7 @@ protected override void UpdateState(BoundUserInterfaceState state) _window?.UpdateState(castState); } - public void SubmitData(string newFullName, string newJobTitle, List newAccessList, string newJobPrototype) + public void SubmitData(string newFullName, string newJobTitle, List> newAccessList, string newJobPrototype) { if (newFullName.Length > MaxFullNameLength) newFullName = newFullName[..MaxFullNameLength]; diff --git a/Content.Client/Access/UI/IdCardConsoleWindow.xaml b/Content.Client/Access/UI/IdCardConsoleWindow.xaml index c29adc8ebd..a2f5f3382b 100644 --- a/Content.Client/Access/UI/IdCardConsoleWindow.xaml +++ b/Content.Client/Access/UI/IdCardConsoleWindow.xaml @@ -30,10 +30,6 @@