Skip to content

Commit

Permalink
Merge pull request space-syndicate#1839 from space-syndicate/upstream…
Browse files Browse the repository at this point in the history
…-sync

Upstream sync
  • Loading branch information
Morb0 authored Feb 3, 2024
2 parents a762071 + 3c59240 commit 09f08ef
Show file tree
Hide file tree
Showing 500 changed files with 18,186 additions and 43,931 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/close-master-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Close PR's on master

on:
pull_request_target:
types: [ opened, ready_for_review ]

jobs:
run:
runs-on: ubuntu-latest
if: ${{github.head_ref == 'master' || github.head_ref == 'main' || github.head_ref == 'develop'}}

steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: "Thank you for contributing to the Space Station 14 repository. Unfortunately, it looks like you submitted your pull request from the master branch. We suggest you follow [our git usage documentation](https://docs.spacestation14.com/en/general-development/setup/git-for-the-ss14-developer.html) \n\n You can move your current work from the master branch to another branch by doing `git branch <branch_name` and resetting the master branch."

# If you prefer to just comment on the pr and not close it, uncomment the bellow and comment the above

# - uses: actions/github-script@v7
# with:
# script: |
# github.rest.issues.createComment({
# issue_number: ${{ github.event.number }},
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: "Thank you for contributing to the Space Station 14 repository. Unfortunately, it looks like you submitted your pull request from the master branch. We suggest you follow [our git usage documentation](https://docs.spacestation14.com/en/general-development/setup/git-for-the-ss14-developer.html) \n\n You can move your current work from the master branch to another branch by doing `git branch <branch_name` and resetting the master branch. \n\n This pr won't be automatically closed. However, a maintainer may close it for this reason."
# })
2 changes: 1 addition & 1 deletion .run/Content Server+Client.run.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<component name="ProjectRunConfigurationManager">
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Content Server+Client" type="CompoundRunConfigurationType">
<toRun name="Content.Client" type="DotNetProject" />
<toRun name="Content.Server" type="DotNetProject" />
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeMana

foreach (var job in jobs)
{
if (!job.SetPreference)
if (!job.OverrideConsoleVisibility.GetValueOrDefault(job.SetPreference))
{
continue;
}
Expand Down
154 changes: 11 additions & 143 deletions Content.Client/Administration/QuickDialogSystem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System.Linq;
using Content.Client.UserInterface.Controls;
using Content.Shared.Administration;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;

namespace Content.Client.Administration;

// mfw they ported input() from BYOND

/// <summary>
/// This handles the client portion of quick dialogs.
/// </summary>
Expand All @@ -21,149 +16,22 @@ public override void Initialize()

private void OpenDialog(QuickDialogOpenEvent ev)
{
var window = new FancyWindow()
{
Title = ev.Title
};

var entryContainer = new BoxContainer()
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
Margin = new Thickness(8),
};

var promptsDict = new Dictionary<string, LineEdit>();

for (var index = 0; index < ev.Prompts.Count; index++)
{
var entry = ev.Prompts[index];
var entryBox = new BoxContainer()
{
Orientation = BoxContainer.LayoutOrientation.Horizontal
};

entryBox.AddChild(new Label { Text = entry.Prompt, HorizontalExpand = true, SizeFlagsStretchRatio = 0.5f });
var edit = new LineEdit() { HorizontalExpand = true };
entryBox.AddChild(edit);
switch (entry.Type)
{
case QuickDialogEntryType.Integer:
edit.IsValid += VerifyInt;
edit.PlaceHolder = Loc.GetString("quick-dialog-ui-integer");
break;
case QuickDialogEntryType.Float:
edit.IsValid += VerifyFloat;
edit.PlaceHolder = Loc.GetString("quick-dialog-ui-float");
break;
case QuickDialogEntryType.ShortText:
edit.IsValid += VerifyShortText;
edit.PlaceHolder = Loc.GetString("quick-dialog-ui-short-text");
break;
case QuickDialogEntryType.LongText:
edit.IsValid += VerifyLongText;
edit.PlaceHolder = Loc.GetString("quick-dialog-ui-long-text");
break;
default:
throw new ArgumentOutOfRangeException();
}

promptsDict.Add(entry.FieldId, edit);
entryContainer.AddChild(entryBox);

if (index == ev.Prompts.Count - 1)
{
// Last text box gets enter confirmation.
// Only the last so you don't accidentally confirm early.
edit.OnTextEntered += _ => Confirm();
}
}
var ok = (ev.Buttons & QuickDialogButtonFlag.OkButton) != 0;
var cancel = (ev.Buttons & QuickDialogButtonFlag.CancelButton) != 0;
var window = new DialogWindow(ev.Title, ev.Prompts, ok: ok, cancel: cancel);

var buttonsBox = new BoxContainer()
window.OnConfirmed += responses =>
{
Orientation = BoxContainer.LayoutOrientation.Horizontal,
HorizontalAlignment = Control.HAlignment.Center,
};

var alreadyReplied = false;

if ((ev.Buttons & QuickDialogButtonFlag.OkButton) != 0)
{
var okButton = new Button()
{
Text = Loc.GetString("quick-dialog-ui-ok"),
};

okButton.OnPressed += _ => Confirm();

buttonsBox.AddChild(okButton);
}

if ((ev.Buttons & QuickDialogButtonFlag.OkButton) != 0)
{
var cancelButton = new Button()
{
Text = Loc.GetString("quick-dialog-ui-cancel"),
};

cancelButton.OnPressed += _ =>
{
RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId,
new(),
QuickDialogButtonFlag.CancelButton));
alreadyReplied = true;
window.Close();
};

buttonsBox.AddChild(cancelButton);
}

window.OnClose += () =>
{
if (!alreadyReplied)
{
RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId,
new(),
QuickDialogButtonFlag.CancelButton));
}
RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId,
responses,
QuickDialogButtonFlag.OkButton));
};

entryContainer.AddChild(buttonsBox);

window.ContentsContainer.AddChild(entryContainer);

window.MinWidth *= 2; // Just double it.

window.OpenCentered();

return;

void Confirm()
window.OnCancelled += () =>
{
RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId,
promptsDict.Select(x => (x.Key, x.Value.Text)).ToDictionary(x => x.Key, x => x.Text),
QuickDialogButtonFlag.OkButton));
alreadyReplied = true;
window.Close();
}
}

private bool VerifyInt(string input)
{
return int.TryParse(input, out var _);
}

private bool VerifyFloat(string input)
{
return float.TryParse(input, out var _);
}

private bool VerifyShortText(string input)
{
return input.Length <= 100;
}

private bool VerifyLongText(string input)
{
return input.Length <= 2000;
new(),
QuickDialogButtonFlag.CancelButton));
};
}
}
42 changes: 32 additions & 10 deletions Content.Client/Antag/AntagStatusIconSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Shared.Ghost;
using Content.Shared.Antag;
using Content.Shared.Revolutionary.Components;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Content.Shared.Zombies;
using Robust.Client.Player;
using Robust.Shared.Prototypes;

Expand All @@ -9,24 +11,44 @@ namespace Content.Client.Antag;
/// <summary>
/// Used for assigning specified icons for antags.
/// </summary>
public abstract class AntagStatusIconSystem<T> : SharedStatusIconSystem
where T : IComponent
public sealed class AntagStatusIconSystem : SharedStatusIconSystem
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevolutionaryComponent, GetStatusIconsEvent>(GetRevIcon);
SubscribeLocalEvent<ZombieComponent, GetStatusIconsEvent>(GetIcon);
SubscribeLocalEvent<HeadRevolutionaryComponent, GetStatusIconsEvent>(GetIcon);
}

/// <summary>
/// Will check if the local player has the same component as the one who called it and give the status icon.
/// Adds a Status Icon on an entity if the player is supposed to see it.
/// </summary>
/// <param name="antagStatusIcon">The status icon that your antag uses</param>
/// <param name="args">The GetStatusIcon event.</param>
protected virtual void GetStatusIcon(string antagStatusIcon, ref GetStatusIconsEvent args)
private void GetIcon<T>(EntityUid uid, T comp, ref GetStatusIconsEvent ev) where T: IAntagStatusIconComponent
{
var ent = _player.LocalPlayer?.ControlledEntity;
var ent = _player.LocalSession?.AttachedEntity;

var canEv = new CanDisplayStatusIconsEvent(ent);
RaiseLocalEvent(uid, ref canEv);

if (!canEv.Cancelled)
ev.StatusIcons.Add(_prototype.Index(comp.StatusIcon));
}

if (!HasComp<T>(ent) && !HasComp<GhostComponent>(ent))

/// <summary>
/// Adds the Rev Icon on an entity if the player is supposed to see it. This additional function is needed to deal
/// with a special case where if someone is a head rev we only want to display the headrev icon.
/// </summary>
private void GetRevIcon(EntityUid uid, RevolutionaryComponent comp, ref GetStatusIconsEvent ev)
{
if (HasComp<HeadRevolutionaryComponent>(uid))
return;

args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(antagStatusIcon));
GetIcon(uid, comp, ref ev);

}
}
8 changes: 8 additions & 0 deletions Content.Client/Atmos/EntitySystems/FirestarterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Atmos.EntitySystems;

namespace Content.Client.Atmos.EntitySystems;

public sealed class FirestarterSystem : SharedFirestarterSystem
{

}
2 changes: 1 addition & 1 deletion Content.Client/Atmos/UI/GasAnalyzerBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override void Open()

_window = new GasAnalyzerWindow();
_window.OnClose += OnClose;
_window.OpenCentered();
_window.OpenCenteredLeft();
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Botany/Components/ProduceComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Botany.Components;

namespace Content.Client.Botany.Components;

[RegisterComponent]
public sealed partial class ProduceComponent : SharedProduceComponent
{
}
8 changes: 8 additions & 0 deletions Content.Client/Botany/Components/SeedComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Botany.Components;

namespace Content.Client.Botany.Components;

[RegisterComponent]
public sealed partial class SeedComponent : SharedSeedComponent
{
}
4 changes: 0 additions & 4 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.Rotation;
using Content.Shared.Vehicle.Components;
using Robust.Client.GameObjects;

namespace Content.Client.Buckle;
Expand All @@ -26,9 +25,6 @@ private void OnBuckleAfterAutoHandleState(EntityUid uid, BuckleComponent compone
if (!TryComp<SpriteComponent>(uid, out var ownerSprite))
return;

if (HasComp<VehicleComponent>(component.LastEntityBuckledTo))
return;

// Adjust draw depth when the chair faces north so that the seat back is drawn over the player.
// Reset the draw depth when rotated in any other direction.
// TODO when ECSing, make this a visualizer
Expand Down
25 changes: 25 additions & 0 deletions Content.Client/Camera/CameraRecoilSystem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
using System.Numerics;
using Content.Shared.Camera;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;

namespace Content.Client.Camera;

public sealed class CameraRecoilSystem : SharedCameraRecoilSystem
{
[Dependency] private readonly IConfigurationManager _configManager = default!;

protected float Intensity;

public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<CameraKickEvent>(OnCameraKick);

_configManager.OnValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged, true);
}

public override void Shutdown()
{
base.Shutdown();

_configManager.UnsubValueChanged(CCVars.ScreenShakeIntensity, OnCvarChanged);
}

private void OnCvarChanged(float value)
{
Intensity = value;
}

private void OnCameraKick(CameraKickEvent ev)
Expand All @@ -18,9 +38,14 @@ private void OnCameraKick(CameraKickEvent ev)

public override void KickCamera(EntityUid uid, Vector2 recoil, CameraRecoilComponent? component = null)
{
if (Intensity == 0)
return;

if (!Resolve(uid, ref component, false))
return;

recoil *= Intensity;

// Use really bad math to "dampen" kicks when we're already kicked.
var existing = component.CurrentKick.Length();
var dampen = existing / KickMagnitudeMax;
Expand Down
Loading

0 comments on commit 09f08ef

Please sign in to comment.