Skip to content

Commit

Permalink
lots of fixes 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Peptide90 committed Nov 11, 2024
1 parent 0f8be8e commit c1861c3
Show file tree
Hide file tree
Showing 26 changed files with 34 additions and 494 deletions.
20 changes: 1 addition & 19 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
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.Player;
using Robust.Client.UserInterface;
using Robust.Shared.Player;
using Robust.Shared.Timing;

namespace Content.Client.Ghost
{
Expand All @@ -19,19 +14,6 @@ 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 @@ -205,4 +187,4 @@ public void ReturnToRound()
RaiseNetworkEvent(msg);
}
}
}
}
2 changes: 0 additions & 2 deletions Content.Client/LateJoin/LateJoinGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
using Content.Client.Lobby;
using Content.Client.UserInterface.Controls;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Preferences;
using Content.Shared.CCVar;
using Content.Shared.Customization.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.StatusIcon;
using Microsoft.Win32.SafeHandles;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.CCVar;
using Content.Shared.Customization.Systems;
using Content.Shared.Players.JobWhitelist;
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.Player;
using Robust.Shared.Prototypes;
using Content.Shared.Preferences; // Nuclear 14
using Robust.Shared.Utility;

namespace Content.Client.Players.PlayTimeTracking;
Expand All @@ -24,7 +21,6 @@ public sealed partial class JobRequirementsManager : ISharedPlaytimeManager
[Dependency] private readonly IClientNetManager _net = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IPrototypeManager _prototypes = default!;
[Dependency] private readonly IClientPreferencesManager _clientPreferences = default!; // Nuclear 14

private readonly Dictionary<string, TimeSpan> _roles = new();
private readonly List<string> _roleBans = new();
Expand Down
126 changes: 0 additions & 126 deletions Content.Client/ShortConstruction/UI/ShortConstructionMenuBUI.cs

This file was deleted.

44 changes: 4 additions & 40 deletions Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
using Content.Client._NF.Respawn;
using Content.Client.Gameplay;
using Content.Client.Gameplay;
using Content.Client.Ghost;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Ghost.Widgets;
using Content.Shared.Ghost;
using Content.Shared._NF.CCVar;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Configuration;
using Robust.Shared.Console;

namespace Content.Client.UserInterface.Systems.Ghost;

// TODO hud refactor BEFORE MERGE fix ghost gui being too far up
public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSystem>, IOnSystemChanged<RespawnSystem>
public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSystem>
{
[Dependency] private readonly IEntityNetworkManager _net = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;

[UISystemDependency] private readonly GhostSystem? _system = default;
[UISystemDependency] private readonly RespawnSystem? _respawn = default;

private GhostGui? Gui => UIManager.GetActiveUIWidgetOrNull<GhostGui>();

Expand Down Expand Up @@ -63,11 +56,6 @@ public void OnSystemUnloaded(GhostSystem system)
system.GhostRoleCountUpdated -= OnRoleCountUpdated;
}

private void UpdateRespawn(TimeSpan? timeOfDeath)
{
Gui?.UpdateRespawn(timeOfDeath);
}

public void UpdateGui()
{
if (Gui == null)
Expand All @@ -76,10 +64,7 @@ public void UpdateGui()
}

Gui.Visible = _system?.IsGhost ?? false;
Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody,
_respawn?.RespawnResetTime,
_cfg.GetCVar(NF14CVars.RespawnTime)
);
Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody);
}

private void OnPlayerRemoved(GhostComponent component)
Expand Down Expand Up @@ -141,18 +126,12 @@ public void LoadGui()
Gui.ReturnToBodyPressed += ReturnToBody;
Gui.GhostRolesPressed += GhostRolesPressed;
Gui.TargetWindow.WarpClicked += OnWarpClicked;
Gui.GhostRespawnPressed += GuiOnGhostRespawnPressed;
Gui.TargetWindow.OnGhostnadoClicked += OnGhostnadoClicked;
Gui.ReturnToRoundPressed += ReturnToRound;

UpdateGui();
}

private void GuiOnGhostRespawnPressed()
{
_consoleHost.ExecuteCommand("ghostrespawn");
}

public void UnloadGui()
{
if (Gui == null)
Expand Down Expand Up @@ -188,19 +167,4 @@ private void GhostRolesPressed()
{
_system?.OpenGhostRoles();
}

public void OnSystemLoaded(RespawnSystem system)
{
system.RespawnReseted += OnRespawnReseted;
}

public void OnSystemUnloaded(RespawnSystem system)
{
system.RespawnReseted -= OnRespawnReseted;
}

private void OnRespawnReseted()
{
UpdateGui();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Ghost.Controls;
using Content.Shared._NF.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;

namespace Content.Client.UserInterface.Systems.Ghost.Widgets;

[GenerateTypedNameReferences]
public sealed partial class GhostGui : UIWidget
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;

private TimeSpan? _timeOfDeath;
private float _minTimeToRespawn;

public GhostTargetWindow TargetWindow { get; }
public GhostRespawnRulesWindow RulesWindow { get; }

public event Action? GhostRespawnPressed;

public event Action? RequestWarpsPressed;
public event Action? ReturnToBodyPressed;
Expand All @@ -33,23 +21,13 @@ public GhostGui()
RobustXamlLoader.Load(this);

TargetWindow = new GhostTargetWindow();
RulesWindow = new GhostRespawnRulesWindow();

MouseFilter = MouseFilterMode.Ignore;

RulesWindow.RespawnButton.OnPressed += _ => GhostRespawnPressed?.Invoke();

GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
ReturnToRound.OnPressed += _ => ReturnToRoundPressed?.Invoke();
GhostRespawnButton.OnPressed += _ => RulesWindow.OpenCentered();
}

public void UpdateRespawn(TimeSpan? todd)
{
_timeOfDeath = todd;
_minTimeToRespawn = _configurationManager.GetCVar(NF14CVars.RespawnTime);
}

public void Hide()
Expand All @@ -61,8 +39,6 @@ public void Hide()
public void Update(int? roles, bool? canReturnToBody)
{
ReturnToBodyButton.Disabled = !canReturnToBody ?? true;
_timeOfDeath = timeOfDeath;
_minTimeToRespawn = minTimeToRespawn;

if (roles != null)
{
Expand All @@ -80,28 +56,6 @@ public void Update(int? roles, bool? canReturnToBody)
TargetWindow.Populate();
}

protected override void FrameUpdate(FrameEventArgs args)
{
if (_timeOfDeath is null)
{
GhostRespawnButton.Text = Loc.GetString("ghost-gui-respawn-button-allowed");
GhostRespawnButton.Disabled = false;
return;
}

var delta = (_minTimeToRespawn - _gameTiming.CurTime.Subtract(_timeOfDeath.Value).TotalSeconds);
if (delta <= 0)
{
GhostRespawnButton.Text = Loc.GetString("ghost-gui-respawn-button-allowed");
GhostRespawnButton.Disabled = false;
}
else
{
GhostRespawnButton.Text = Loc.GetString("ghost-gui-respawn-button-denied", ("time", $"{delta:f1}"));
GhostRespawnButton.Disabled = true;
}
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Expand Down
Loading

0 comments on commit c1861c3

Please sign in to comment.