Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-06-21 21:53:12 +03:00
103 changed files with 2092 additions and 340 deletions

View File

@@ -13,6 +13,7 @@ namespace Content.Client.Access.UI;
public sealed partial class AccessLevelControl : GridContainer
{
public readonly Dictionary<ProtoId<AccessLevelPrototype>, Button> ButtonsList = new();
public readonly List<Dictionary<ProtoId<AccessLevelPrototype>, Button>> ButtonGroups = new ();
public AccessLevelControl()
{
@@ -39,6 +40,61 @@ public sealed partial class AccessLevelControl : GridContainer
}
}
public void PopulateForConsole(List<List<ProtoId<AccessLevelPrototype>>> accessLevels, IPrototypeManager prototypeManager)
{
var departmentColors = new List<String> // Colors from StyleNano.cs
{
"ButtonColorCommandDepartment",
"ButtonColorSecurityDepartment",
"ButtonColorMedicalDepartment",
"ButtonColorEngineeringDepartment",
"ButtonColorResearchingDepartment",
"ButtonColorCargoDepartment",
"ButtonColorServiceDepartment"
};
var currentColorIndex = 0;
foreach (var department in accessLevels)
{
Dictionary<ProtoId<AccessLevelPrototype>, Button> buttons = new();
foreach (var access in department)
{
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,
};
newButton.AddStyleClass(departmentColors[currentColorIndex]);
buttons.Add(accessLevel.ID, newButton);
}
ButtonGroups.Add(buttons);
currentColorIndex++;
}
}
public void UpdateStateConsole(
List<ProtoId<AccessLevelPrototype>> pressedList,
List<ProtoId<AccessLevelPrototype>>? enabledList = null)
{
foreach (var department in ButtonGroups)
{
foreach (var (accessName, button) in department)
{
button.Pressed = pressedList.Contains(accessName);
button.Disabled = !(enabledList?.Contains(accessName) ?? true);
}
}
}
public void UpdateState(
List<ProtoId<AccessLevelPrototype>> pressedList,
List<ProtoId<AccessLevelPrototype>>? enabledList = null)

View File

@@ -23,15 +23,15 @@ namespace Content.Client.Access.UI
protected override void Open()
{
base.Open();
List<ProtoId<AccessLevelPrototype>> accessLevels;
List<List<ProtoId<AccessLevelPrototype>>> accessLevels;
if (EntMan.TryGetComponent<IdCardConsoleComponent>(Owner, out var idCard))
{
accessLevels = idCard.AccessLevels;
accessLevels = idCard.AccessLevelsConsole;
}
else
{
accessLevels = new List<ProtoId<AccessLevelPrototype>>();
accessLevels = new List<List<ProtoId<AccessLevelPrototype>>>();
_idCardConsoleSystem.Log.Error($"No IdCardConsole component found for {EntMan.ToPrettyString(Owner)}!");
}

View File

@@ -26,16 +26,13 @@
<Button Name="JobTitleSaveButton" Text="{Loc 'id-card-console-window-save-button'}" Disabled="True" />
</GridContainer>
<Control MinSize="0 8" />
<GridContainer Columns="2">
<Label Text="{Loc 'id-card-console-window-job-selection-label'}" />
<OptionButton Name="JobPresetOptionButton" />
</GridContainer>
<Control Name="AccessLevelControlContainer" />
<GridContainer Name="AccessLevelControlContainer" Columns="7" HorizontalExpand="True" HorizontalAlignment="Center" >
<!-- WD EDIT -->
</GridContainer>
<GridContainer Name="CurrentJobIcon" Columns="2">
<Label Text="Текущая выбранная иконка для роли: " />
</GridContainer>
<GridContainer Name="JobIconsGrid" Columns="10" HorizontalAlignment="Center">
<GridContainer Name="JobIconsGrid" HorizontalAlignment="Center">
<!-- Job icon buttons are generated in the code -->
</GridContainer>
<!-- WD EDIT END -->

View File

@@ -24,9 +24,11 @@ namespace Content.Client.Access.UI
private readonly IdCardConsoleBoundUserInterface _owner;
private AccessLevelControl _accessButtons = new();
private GridContainer _grid = default!;
private readonly AccessLevelControl _groupAccessButtons = new();
private readonly Dictionary<string, TextureButton> _jobIconButtons = new(); //WD-EDIT
private readonly List<string> _jobPrototypeIds = new();
private string _newJob = "";
private string? _lastFullName;
private string? _lastJobTitle;
@@ -36,7 +38,7 @@ namespace Content.Client.Access.UI
public IdCardConsoleWindow(
IdCardConsoleBoundUserInterface owner,
IPrototypeManager prototypeManager,
List<ProtoId<AccessLevelPrototype>> accessLevels)
List<List<ProtoId<AccessLevelPrototype>>> accessLevels)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
@@ -59,30 +61,27 @@ namespace Content.Client.Access.UI
JobTitleSaveButton.OnPressed += _ => SubmitData();
var jobs = _prototypeManager.EnumeratePrototypes<JobPrototype>().ToList();
jobs.Sort((x, y) => string.Compare(x.LocalizedName, y.LocalizedName, StringComparison.CurrentCulture));
_groupAccessButtons.PopulateForConsole(accessLevels, prototypeManager);
foreach (var job in jobs)
foreach (var department in _groupAccessButtons.ButtonGroups)
{
if (!job.OverrideConsoleVisibility.GetValueOrDefault(job.SetPreference))
var departmentGrid = new GridContainer {};
foreach (var button in department.Values)
{
continue;
departmentGrid.AddChild(button);
}
_jobPrototypeIds.Add(job.ID);
JobPresetOptionButton.AddItem(Loc.GetString(job.Name), _jobPrototypeIds.Count - 1);
AccessLevelControlContainer.AddChild(departmentGrid);
}
JobPresetOptionButton.OnItemSelected += SelectJobPreset;
_accessButtons.Populate(accessLevels, prototypeManager);
AccessLevelControlContainer.AddChild(_accessButtons);
foreach (var (id, button) in _accessButtons.ButtonsList)
foreach (var department in _groupAccessButtons.ButtonGroups)
{
button.OnPressed += _ => SubmitData();
foreach (var button in department.Values)
{
button.OnPressed += _ => SubmitData();
}
}
//WD-EDIT
if (!_entityManager.TryGetComponent<IdCardConsoleComponent>(owner.Owner, out var idConsoleComponent))
return;
@@ -92,72 +91,89 @@ namespace Content.Client.Access.UI
if (rsi == null)
return;
foreach (var jobIcon in idConsoleComponent.JobIcons)
foreach (var department in idConsoleComponent.JobIcons)
{
var newButton = new TextureButton
_grid = new GridContainer
{
TextureNormal = rsi.RSI.TryGetState(jobIcon, out var state) ? state.Frame0
: rsi.RSI.TryGetState("CustomId", out var customState) ? customState.Frame0
: null,
Scale = new Vector2(5, 5)
Columns = department.Count
};
_jobIconButtons.Add(jobIcon, newButton);
newButton.OnPressed += _ =>
foreach (var jobIcon in department)
{
_lastJobIcon = "JobIcon" + jobIcon;
SubmitData();
};
var newButton = new TextureButton
{
TextureNormal = rsi.RSI.TryGetState(jobIcon, out var state) ? state.Frame0
: rsi.RSI.TryGetState("CustomId", out var customState) ? customState.Frame0
: null,
Scale = new Vector2(5, 5)
};
JobIconsGrid.AddChild(newButton);
_jobIconButtons.TryAdd(jobIcon, newButton);
newButton.OnPressed += _ =>
{
SelectJobPreset(jobIcon);
_newJob = jobIcon;
_lastJobIcon = "JobIcon" + jobIcon;
SubmitData();
};
_grid.AddChild(newButton);
}
JobIconsGrid.AddChild(_grid);
}
//WD-EDIT
}
private void ClearAllAccess()
{
foreach (var button in _accessButtons.ButtonsList.Values)
foreach (var group in _groupAccessButtons.ButtonGroups)
{
if (button.Pressed)
foreach (var button in group.Values)
{
button.Pressed = false;
if (button.Pressed)
{
button.Pressed = false;
}
}
}
}
private void SelectJobPreset(OptionButton.ItemSelectedEventArgs args)
private void SelectJobPreset(string jobName)
{
if (!_prototypeManager.TryIndex(_jobPrototypeIds[args.Id], out JobPrototype? job))
if (!_prototypeManager.TryIndex(jobName, out JobPrototype? job))
{
return;
}
JobTitleLineEdit.Text = Loc.GetString(job.Name);
args.Button.SelectId(args.Id);
ClearAllAccess();
// this is a sussy way to do this
foreach (var access in job.Access)
{
if (_accessButtons.ButtonsList.TryGetValue(access, out var button) && !button.Disabled)
foreach (var group in _groupAccessButtons.ButtonGroups)
{
button.Pressed = true;
if (group.TryGetValue(access, out var button) && !button.Disabled)
{
button.Pressed = true;
}
}
}
foreach (var group in job.AccessGroups)
{
if (!_prototypeManager.TryIndex(group, out AccessGroupPrototype? groupPrototype))
{
continue;
}
foreach (var access in groupPrototype.Tags)
{
if (_accessButtons.ButtonsList.TryGetValue(access, out var button) && !button.Disabled)
foreach (var buttonGroup in _groupAccessButtons.ButtonGroups)
{
button.Pressed = true;
if (buttonGroup.TryGetValue(access, out var button) && !button.Disabled)
button.Pressed = true;
}
}
}
@@ -204,19 +220,12 @@ namespace Content.Client.Access.UI
JobTitleSaveButton.Disabled = !interfaceEnabled || !jobTitleDirty;
JobPresetOptionButton.Disabled = !interfaceEnabled;
_accessButtons.UpdateState(state.TargetIdAccessList?.ToList() ??
new List<ProtoId<AccessLevelPrototype>>(),
_groupAccessButtons.UpdateStateConsole(state.TargetIdAccessList?.ToList() ??
new List<ProtoId<AccessLevelPrototype>>(),
state.AllowedModifyAccessList?.ToList() ??
new List<ProtoId<AccessLevelPrototype>>());
var jobIndex = _jobPrototypeIds.IndexOf(state.TargetIdJobPrototype);
if (jobIndex >= 0)
{
JobPresetOptionButton.SelectId(jobIndex);
}
//WD-EDIT
if (_resource.TryGetResource(new ResPath("/Textures/Interface/Misc/job_icons.rsi"), out RSIResource? rsi))
{
@@ -234,7 +243,6 @@ namespace Content.Client.Access.UI
: rsi.RSI.TryGetState("CustomId", out var customState)
? customState.Frame0
: null,
TextureScale = new Vector2(4, 4)
};
@@ -256,15 +264,18 @@ namespace Content.Client.Access.UI
private void SubmitData()
{
// Don't send this if it isn't dirty.
var jobProtoDirty = _lastJobProto != null &&
_jobPrototypeIds[JobPresetOptionButton.SelectedId] != _lastJobProto;
var jobProtoDirty = _lastJobProto != null && _newJob != _lastJobProto;
_owner.SubmitData(
FullNameLineEdit.Text,
JobTitleLineEdit.Text,
// Iterate over the buttons dictionary, filter by `Pressed`, only get key from the key/value pair
_accessButtons.ButtonsList.Where(x => x.Value.Pressed).Select(x => x.Key).ToList(),
jobProtoDirty ? _jobPrototypeIds[JobPresetOptionButton.SelectedId] : string.Empty,
_groupAccessButtons.ButtonGroups
.SelectMany(dict => dict)
.Where(x => x.Value.Pressed)
.Select(x => x.Key)
.ToList(),
jobProtoDirty ? _newJob : string.Empty,
_lastJobIcon);
}
}

View File

@@ -0,0 +1,19 @@
using Content.Shared.Clothing.Components;
using Robust.Client.Physics;
namespace Content.Client.Clothing.Systems;
public sealed partial class PilotedByClothingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PilotedByClothingComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
}
private void OnUpdatePredicted(Entity<PilotedByClothingComponent> entity, ref UpdateIsPredictedEvent args)
{
args.BlockPrediction = true;
}
}

View File

@@ -1,5 +1,4 @@
using Content.Client.Wires.Visualizers;
using Content.Shared.Doors;
using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
using Robust.Client.Animations;
@@ -17,7 +16,7 @@ public sealed class AirlockSystem : SharedAirlockSystem
SubscribeLocalEvent<AirlockComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<AirlockComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private void OnComponentStartup(EntityUid uid, AirlockComponent comp, ComponentStartup args)
{
// Has to be on component startup because we don't know what order components initialize in and running this before DoorComponent inits _will_ crash.
@@ -113,6 +112,7 @@ public sealed class AirlockSystem : SharedAirlockSystem
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible);
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseBolted, boltedVisible);
if (comp.EmergencyAccessLayer)
{
args.Sprite.LayerSetVisible(

View File

@@ -0,0 +1,31 @@
using Content.Client.GameTicking.Managers;
using Content.Shared.Administration;
using Content.Shared.GameTicking;
using Robust.Shared.Console;
using Robust.Shared.Network;
namespace Content.Client.GameTicking.Commands
{
[AnyCommand]
public sealed class ShowManifestCommand : IConsoleCommand
{
[Dependency] private readonly IEntitySystemManager _entitySystem = default!;
public string Command => "showmanifest";
public string Description => "Shows round end summary window";
public string Help => "Usage: showmanifest";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var ticker = _entitySystem.GetEntitySystem<ClientGameTicker>();
var window = ticker._window;
if (!ticker.IsGameStarted && window != null)
{
window.OpenCentered();
return;
}
shell.WriteLine("You can't open manifest right now");
}
}
}

View File

@@ -23,7 +23,7 @@ namespace Content.Client.GameTicking.Managers
/// <summary>
/// The current round-end window. Could be used to support re-opening the window after closing it.
/// </summary>
private RoundEndSummaryWindow? _window;
public RoundEndSummaryWindow? _window;
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }

View File

@@ -158,6 +158,16 @@ namespace Content.Client.Stylesheets
public const string StyleClassButtonColorGreen = "ButtonColorGreen";
public const string StyleClassButtonColorPurple = "ButtonColorPurple";
// WD - HoP console
public static readonly Color ButtonColorCommand = Color.FromHex("#436BAD");
public static readonly Color ButtonColorSecurity = Color.FromHex("#BF5454");
public static readonly Color ButtonColorMedical = Color.FromHex("#4494C8");
public static readonly Color ButtonColorEngineering = Color.FromHex("#FDA55E");
public static readonly Color ButtonColorCargo = Color.FromHex("#9E6A34");
public static readonly Color ButtonColorResearching = Color.FromHex("#984EB4");
public static readonly Color ButtonColorService = Color.FromHex("#40A166");
public override Stylesheet Stylesheet { get; }
public StyleNano(IResourceCache resCache) : base(resCache)
@@ -1340,6 +1350,55 @@ namespace Content.Client.Stylesheets
{
new StyleProperty(Label.StylePropertyFont, notoSansDisplayBold14),
}),
// WD - HoP conlose
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorCommand),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorSecurity),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorMedical),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorEngineering),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorService),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorResearching),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorCargo),
}),
// NanoHeading
@@ -1576,6 +1635,44 @@ namespace Content.Client.Stylesheets
.Prop(Control.StylePropertyModulateSelf, ButtonColorHoveredRed),
// ---
// WD - HoP console
Element<Button>().Class("ButtonColorCommandDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorCommand),
Element<Button>().Class("ButtonColorCommandDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorCommand),
Element<Button>().Class("ButtonColorSecurityDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorSecurity),
Element<Button>().Class("ButtonColorSecurityDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorSecurity),
Element<Button>().Class("ButtonColorMedicalDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorMedical),
Element<Button>().Class("ButtonColorMedicalDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorMedical),
Element<Button>().Class("ButtonColorEngineeringDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorEngineering),
Element<Button>().Class("ButtonColorEngineeringDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorEngineering),
Element<Button>().Class("ButtonColorResearchingDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorResearching),
Element<Button>().Class("ButtonColorResearchingDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorResearching),
Element<Button>().Class("ButtonColorServiceDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorService),
Element<Button>().Class("ButtonColorServiceDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorService),
Element<Button>().Class("ButtonColorCargoDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorCargo),
Element<Button>().Class("ButtonColorCargoDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorCargo),
// ---
// Green Button ---
Element<Button>().Class("ButtonColorGreen")
.Prop(Control.StylePropertyModulateSelf, ButtonColorGoodDefault),

View File

@@ -339,9 +339,9 @@ public sealed partial class GunSystem : SharedGunSystem
}
Lights.SetEnabled(uid, true, light);
Lights.SetRadius(uid, 2f, light);
Lights.SetRadius(uid, 1.4f, light);
Lights.SetColor(uid, Color.FromHex("#cc8e2b"), light);
Lights.SetEnergy(uid, 5f, light);
Lights.SetEnergy(uid, 0.7f, light);
var animTwo = new Animation()
{

View File

@@ -18,6 +18,7 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
args.Sprite.LayerSetVisible(ModuleVisualState.HandGuardModule, false);
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, false);
args.Sprite.LayerSetVisible(ModuleVisualState.AimModule, false);
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.HandGuardModule, out var handguardModule, args.Component) && handguardModule.Length != 0 && handguardModule != "none")
{
@@ -31,6 +32,12 @@ public sealed partial class WeaponModulesVisuals : VisualizerSystem<WeaponModule
args.Sprite.LayerSetVisible(ModuleVisualState.BarrelModule, true);
}
if (AppearanceSystem.TryGetData<string>(uid, ModuleVisualState.AimModule, out var aimModule, args.Component) && aimModule.Length != 0 && aimModule != "none")
{
args.Sprite.LayerSetState(ModuleVisualState.AimModule, aimModule);
args.Sprite.LayerSetVisible(ModuleVisualState.AimModule, true);
}
if (AppearanceSystem.TryGetData(uid, Modules.Light, out var data, args.Component))
{
if (TryComp<PointLightComponent>(uid, out var pointLightComponent))