Skip to content

Commit

Permalink
Merge branch 'master' into screaming_Pain_in_my_soul
Browse files Browse the repository at this point in the history
  • Loading branch information
DebugOk authored Feb 12, 2024
2 parents 61dcf0a + 9611962 commit 55a011e
Show file tree
Hide file tree
Showing 1,121 changed files with 113,073 additions and 68,202 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
26 changes: 16 additions & 10 deletions Content.Client/Audio/BackgroundAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public sealed class BackgroundAudioSystem : EntitySystem
[Dependency] private readonly IStateManager _stateManager = default!;

private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);
private readonly AudioParams _roundEndParams = new(-5f, 1, "Master", 0, 0, 0, false, 0f);

public EntityUid? LobbyStream;
public EntityUid? LobbyMusicStream;
public EntityUid? LobbyRoundRestartAudioStream;

public override void Initialize()
{
Expand Down Expand Up @@ -115,7 +117,7 @@ public void RestartLobbyMusic()

public void StartLobbyMusic()
{
if (LobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
if (LobbyMusicStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
return;

var file = _gameTicker.LobbySong;
Expand All @@ -124,18 +126,21 @@ public void StartLobbyMusic()
return;
}

LobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
LobbyMusicStream = _audio.PlayGlobal(
file,
Filter.Local(),
false,
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume))))?.Entity;
}

private void EndLobbyMusic()
{
LobbyStream = _audio.Stop(LobbyStream);
LobbyMusicStream = _audio.Stop(LobbyMusicStream);
}

private void PlayRestartSound(RoundRestartCleanupEvent ev)
{
if (!_configManager.GetCVar(CCVars.LobbyMusicEnabled))
if (!_configManager.GetCVar(CCVars.RestartSoundsEnabled))
return;

var file = _gameTicker.RestartSound;
Expand All @@ -144,10 +149,11 @@ private void PlayRestartSound(RoundRestartCleanupEvent ev)
return;
}

var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
SharedAudioSystem.GainToVolume(
_configManager.GetCVar(CCVars.LobbyMusicVolume)));

_audio.PlayGlobal(file, Filter.Local(), false, volume);
LobbyRoundRestartAudioStream = _audio.PlayGlobal(
file,
Filter.Local(),
false,
_roundEndParams.WithVolume(_roundEndParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
)?.Entity;
}
}
19 changes: 14 additions & 5 deletions Content.Client/Audio/ContentAudioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,24 @@ private void OnRoundCleanup(RoundRestartCleanupEvent ev)
_fadingOut.Clear();

// Preserve lobby music but everything else should get dumped.
var lobbyStream = EntityManager.System<BackgroundAudioSystem>().LobbyStream;
TryComp(lobbyStream, out AudioComponent? audioComp);
var oldGain = audioComp?.Gain;
var lobbyMusic = EntityManager.System<BackgroundAudioSystem>().LobbyMusicStream;
TryComp(lobbyMusic, out AudioComponent? lobbyMusicComp);
var oldMusicGain = lobbyMusicComp?.Gain;

var restartAudio = EntityManager.System<BackgroundAudioSystem>().LobbyRoundRestartAudioStream;
TryComp(restartAudio, out AudioComponent? restartComp);
var oldAudioGain = restartComp?.Gain;

SilenceAudio();

if (oldGain != null)
if (oldMusicGain != null)
{
Audio.SetGain(lobbyMusic, oldMusicGain.Value, lobbyMusicComp);
}

if (oldAudioGain != null)
{
Audio.SetGain(lobbyStream, oldGain.Value, audioComp);
Audio.SetGain(restartAudio, oldAudioGain.Value, restartComp);
}
}

Expand Down
Loading

0 comments on commit 55a011e

Please sign in to comment.