Skip to content

Commit

Permalink
Merge pull request #17 from Vault-Overseers/master
Browse files Browse the repository at this point in the history
up
  • Loading branch information
Vonsant authored Jul 18, 2024
2 parents 55bc73e + faa9001 commit 80c36f0
Show file tree
Hide file tree
Showing 779 changed files with 30,461 additions and 3,224,488 deletions.
20 changes: 19 additions & 1 deletion Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using Content.Client._NF.Respawn;
using Content.Client.Movement.Systems;
using Content.Client.UserInterface.Systems.Ghost.Widgets;
using Content.Shared.Actions;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Client.Ghost
{
Expand All @@ -15,6 +20,19 @@ public sealed class GhostSystem : SharedGhostSystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly RespawnSystem _respawn = default!;

public override void Update(float frameTime)
{
foreach (var ghost in EntityManager.EntityQuery<GhostComponent, MindComponent>(true))
{
var ui = _uiManager.GetActiveUIWidgetOrNull<GhostGui>();
if (ui != null && Player != null)
ui.UpdateRespawn(_respawn.RespawnResetTime);
}
}

public int AvailableGhostRoleCount { get; private set; }

Expand Down Expand Up @@ -182,4 +200,4 @@ public void ToggleGhostVisibility()
GhostVisibility = !GhostVisibility;
}
}
}
}
46 changes: 43 additions & 3 deletions Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System.Diagnostics.CodeAnalysis;
using System.Text; // Nuclear 14
using Content.Shared.CCVar;
using Content.Shared.Players;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Roles;
using Content.Shared._NC.Roles; // Nuclear 14
using Robust.Client;
using Robust.Client.Player;
using Content.Client.Preferences; // Nuclear 14
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Content.Shared.Preferences; // Nuclear 14
using Robust.Shared.Utility;

namespace Content.Client.Players.PlayTimeTracking;
Expand All @@ -20,6 +24,7 @@ public sealed partial class JobRequirementsManager
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
[Dependency] private readonly IClientPreferencesManager _clientPreferences = default!; // Nuclear 14

public readonly Dictionary<string, TimeSpan> PlayTimes = new();
private readonly List<string> _roleBans = new();
Expand Down Expand Up @@ -81,6 +86,7 @@ private void RxPlayTime(MsgPlayTime message)

public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessage? reason)
{
var reasonBuilder = new StringBuilder(); // Nuclear 14
reason = null;

if (_roleBans.Contains($"Job:{job.ID}"))
Expand All @@ -93,8 +99,44 @@ public bool IsAllowed(JobPrototype job, [NotNullWhen(false)] out FormattedMessag
if (player == null)
return true;

return CheckRoleTime(job.Requirements, out reason);
// Nuclear 14 start
if (job.JobBlockForSpecies != null)
{
if (_clientPreferences?.Preferences == null)
return true;

var nameSpecie = ((HumanoidCharacterProfile)_clientPreferences.Preferences.SelectedCharacter!).Species;
var first = true;

foreach (var jobBlockForSpecie in job.JobBlockForSpecies)
{
string? speciesReason;
if (JobBlockForSpecies.TryRequirementMet(jobBlockForSpecie, nameSpecie, out speciesReason))
continue;

if (!first)
reasonBuilder.Append('\n');
first = false;
reasonBuilder.AppendLine(speciesReason);
}
}

if (!CheckRoleTime(job.Requirements, out var timeReason))
{
if (reasonBuilder.Length > 0)
reasonBuilder.Append('\n');
reasonBuilder.Append(timeReason!.ToMarkup());
}

if (reasonBuilder.Length > 0)
{
reason = FormattedMessage.FromMarkup(reasonBuilder.ToString());
return false;
}

return true;
}
// Nuclear 14 end

public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(false)] out FormattedMessage? reason, string? localePrefix = "role-timer-")
{
Expand Down Expand Up @@ -133,6 +175,4 @@ public IEnumerable<KeyValuePair<string, TimeSpan>> FetchPlaytimeByRoles()
}
}
}


}
15 changes: 15 additions & 0 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Content.Shared.Traits;
using Content.Shared._NC; // Nuclear 14
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -953,6 +954,7 @@ private void SetGender(Gender newGender)
private void SetSpecies(string newSpecies)
{
Profile = Profile?.WithSpecies(newSpecies);
Save(); // Nuclear 14
OnSkinColorOnValueChanged(); // Species may have special color prefs, make sure to update it.
CMarkings.SetSpecies(newSpecies); // Repopulate the markings tab as well.
UpdateSexControls(); // update sex for new species
Expand All @@ -961,6 +963,7 @@ private void SetSpecies(string newSpecies)
UpdateWidthControls();
UpdateWeight();
RebuildSpriteView(); // they might have different inv so we need a new dummy
UpdateJobPriorities(); // Nuclear 14
UpdateSpeciesGuidebookIcon();
IsDirty = true;
_needUpdatePreview = true;
Expand Down Expand Up @@ -1433,8 +1436,20 @@ private void UpdateJobPriorities()
{
foreach (var prioritySelector in _jobPriorities)
{
prioritySelector.UnlockRequirements(); // Nuclear 14
var jobId = prioritySelector.Proto.ID;

// Nuclear 14 start
if (!_requirements.IsAllowed(prioritySelector.Proto, out var reason))
{
prioritySelector.LockRequirements(reason);
if (Profile != null)
{
Profile = Profile.WithJobPriority(jobId, JobPriority.Never);
}
}
// Nuclear 14 start

var priority = Profile?.JobPriorities.GetValueOrDefault(jobId, JobPriority.Never) ?? JobPriority.Never;

prioritySelector.Priority = priority;
Expand Down
39 changes: 39 additions & 0 deletions Content.Client/UndecidedLoadout/UndecidedLoadoutBackpackMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'undecided-loadout-window-title'}"
MinSize="700 700">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<!-- First Informational panel -->
<Label Text="{Loc 'undecided-loadout-window-description'}" Margin="5 5"/>
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
<Label Name="SelectedSets" Text="{Loc 'undecided-loadout-window-selected'}" Margin="5 5"/>

<!-- Second sets panel -->
<PanelContainer Margin="5 5">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#050505" />
</PanelContainer.PanelOverride>
<ScrollContainer
HScrollEnabled="False"
MinSize="0 600"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
<BoxContainer Name="SetsGrid" Orientation="Vertical" MinSize="460 200">
<!-- Sets is filled by code -->

</BoxContainer>
</ScrollContainer>
</PanelContainer>

<!-- Third approve button panel -->
<PanelContainer Margin="10">
<Button Name="ApproveButton"
Text="{Loc 'undecided-loadout-window-approve-button'}"
Margin="0 5"
Access="Public"
HorizontalAlignment ="Right"
StyleClasses="OpenRight"/>
</PanelContainer>
</BoxContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Content.Client.UserInterface.Controls;
using Content.Shared.UndecidedLoadout;
using Content.Client.UndecidedLoadout;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.UndecidedLoadout;

[GenerateTypedNameReferences]
public sealed partial class UndecidedLoadoutBackpackMenu : FancyWindow
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
private readonly SpriteSystem _spriteSystem;

private readonly UndecidedLoadoutBackpackBoundUserInterface _owner;

public UndecidedLoadoutBackpackMenu(UndecidedLoadoutBackpackBoundUserInterface owner)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _sysMan.GetEntitySystem<SpriteSystem>();

_owner = owner;

ApproveButton.OnButtonDown += (args) =>
{
_owner.SendApprove();
};
}

public void UpdateState(UndecidedLoadoutBackpackBoundUserInterfaceState state)
{
SetsGrid.RemoveAllChildren();
int count = 0;
int selectedNumber = 0;
foreach (var set in state.Sets)
{
var child = new UndecidedLoadoutBackpackSet(set.Value, _spriteSystem);

child.SetButton.OnButtonDown += (args) =>
{
_owner.SendChangeSelected(set.Key);
};

SetsGrid.AddChild(child);

count++;

if (set.Value.Selected)
selectedNumber++;
}

SelectedSets.Text = Loc.GetString("undecided-loadout-window-selected", ("selectedCount", selectedNumber), ("maxCount", state.MaxSelectedSets));
ApproveButton.Disabled = selectedNumber == state.MaxSelectedSets ? false : true;
}
}
23 changes: 23 additions & 0 deletions Content.Client/UndecidedLoadout/UndecidedLoadoutBackpackSet.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Control xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
<!-- Name and button -->
<PanelContainer Margin="5 5 0 5">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#18211b" />
</PanelContainer.PanelOverride>
<BoxContainer Orientation="Vertical" HorizontalExpand="True">
<GridContainer Margin="5" Columns="2" MinSize="600 0">
<Label Name="SetName" Text="Set" StyleClasses="StatusFieldTitle"></Label>
<Button Margin="0 10" Name="SetButton" Text="Select" StyleClasses="OpenRight" Access="Public" HorizontalAlignment="Right"/>
</GridContainer>
<controls:HLine Color="#404040" Thickness="1" Margin="0 5"/>
<!-- Icon and Description -->
<GridContainer Margin="0 5" Columns="2">
<TextureRect Name="Icon" Margin="10" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="64 64"/>
<Label Name="SetDescription" Text="Description"></Label>
</GridContainer>
</BoxContainer>
</PanelContainer>
</Control>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Shared.UndecidedLoadout;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.UndecidedLoadout;

[UsedImplicitly]
public sealed class UndecidedLoadoutBackpackBoundUserInterface : BoundUserInterface
{
private UndecidedLoadoutBackpackMenu? _window;

public UndecidedLoadoutBackpackBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { }

protected override void Open()
{
base.Open();

_window = new UndecidedLoadoutBackpackMenu(this);
_window.OnClose += Close;
_window.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

if (_window != null)
_window.OnClose -= Close;

_window?.Dispose();
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not UndecidedLoadoutBackpackBoundUserInterfaceState current)
return;

_window?.UpdateState(current);
}

public void SendChangeSelected(int setNumber)
{
SendMessage(new UndecidedLoadoutBackpackChangeSetMessage(setNumber));
}

public void SendApprove()
{
SendMessage(new UndecidedLoadoutBackpackApproveMessage());
}
}
22 changes: 22 additions & 0 deletions Content.Client/UndecidedLoadout/UndecidedLoadoutSet.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Content.Shared.UndecidedLoadout;
using Robust.Client.GameObjects;

namespace Content.Client.UndecidedLoadout;

[GenerateTypedNameReferences]
public sealed partial class UndecidedLoadoutBackpackSet : Control
{
public UndecidedLoadoutBackpackSet(UndecidedLoadoutBackpackSetInfo set, SpriteSystem spriteSystem)
{
RobustXamlLoader.Load(this);

Icon.Texture = spriteSystem.Frame0(set.Sprite);
SetName.Text = Loc.GetString(set.Name);
SetDescription.Text = Loc.GetString(set.Description);
SetButton.Text = Loc.GetString(set.Selected ? "undecided-loadout-button-deselect" : "undecided-loadout-button-select");
SetButton.ModulateSelfOverride = set.Selected ? new Color(40, 84, 35) : new Color(68, 75, 103);
}
}
Loading

0 comments on commit 80c36f0

Please sign in to comment.