Skip to content

Commit

Permalink
Merge branch 'master' into 24-10-02-borg-type-switching
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Oct 19, 2024
2 parents e0212f9 + 109e0bc commit 810d840
Show file tree
Hide file tree
Showing 357 changed files with 7,415 additions and 3,757 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/Resources/engineCommandPerms.yml @moonheart08 @Chief-Engineer
/Resources/clientCommandPerms.yml @moonheart08 @Chief-Engineer

/Resources/Prototypes/Maps/ @Emisse
/Resources/Prototypes/Maps/** @Emisse

/Resources/Prototypes/Body/ @DrSmugleaf # suffering
/Resources/Prototypes/Entities/Mobs/Player/ @DrSmugleaf
Expand Down
9 changes: 9 additions & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Client.DebugMon;
using Content.Client.Eui;
using Content.Client.Fullscreen;
using Content.Client.GameTicking.Managers;
using Content.Client.GhostKick;
using Content.Client.Guidebook;
using Content.Client.Input;
Expand Down Expand Up @@ -70,6 +71,7 @@ public sealed class EntryPoint : GameClient
[Dependency] private readonly IReplayLoadManager _replayLoad = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly DebugMonitorManager _debugMonitorManager = default!;
[Dependency] private readonly TitleWindowManager _titleWindowManager = default!;

public override void Init()
{
Expand Down Expand Up @@ -139,6 +141,12 @@ public override void Init()
_configManager.SetCVar("interface.resolutionAutoScaleMinimum", 0.5f);
}

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

public override void PostInit()
{
base.PostInit();
Expand All @@ -159,6 +167,7 @@ public override void PostInit()
_userInterfaceManager.SetDefaultTheme("SS14DefaultTheme");
_userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
_documentParsingManager.Initialize();
_titleWindowManager.Initialize();

_baseClient.RunLevelChanged += (_, args) =>
{
Expand Down
62 changes: 62 additions & 0 deletions Content.Client/GameTicking/Managers/TitleWindowManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Content.Shared.CCVar;
using Robust.Client;
using Robust.Client.Graphics;
using Robust.Shared;
using Robust.Shared.Configuration;

namespace Content.Client.GameTicking.Managers;

public sealed class TitleWindowManager
{
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameController _gameController = default!;

public void Initialize()
{
_cfg.OnValueChanged(CVars.GameHostName, OnHostnameChange, true);
_cfg.OnValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange, true);

_client.RunLevelChanged += OnRunLevelChangedChange;
}

public void Shutdown()
{
_cfg.UnsubValueChanged(CVars.GameHostName, OnHostnameChange);
_cfg.UnsubValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange);
}

private void OnHostnameChange(string hostname)
{
var defaultWindowTitle = _gameController.GameTitle();

// Since the game assumes the server name is MyServer and that GameHostnameInTitlebar CCVar is true by default
// Lets just... not show anything. This also is used to revert back to just the game title on disconnect.
if (_client.RunLevel == ClientRunLevel.Initialize)
{
_clyde.SetWindowTitle(defaultWindowTitle);
return;
}

if (_cfg.GetCVar(CCVars.GameHostnameInTitlebar))
// If you really dislike the dash I guess change it here
_clyde.SetWindowTitle(hostname + " - " + defaultWindowTitle);
else
_clyde.SetWindowTitle(defaultWindowTitle);
}

// Clients by default assume game.hostname_in_titlebar is true
// but we need to clear it as soon as we join and actually receive the servers preference on this.
// This will ensure we rerun OnHostnameChange and set the correct title bar name.
private void OnHostnameTitleChange(bool colonthree)
{
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
}

// This is just used we can rerun the hostname change function when we disconnect to revert back to just the games title.
private void OnRunLevelChangedChange(object? sender, RunLevelChangedEventArgs runLevelChangedEventArgs)
{
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
}
}
4 changes: 2 additions & 2 deletions Content.Client/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public void ReloadHandButtons()
OnPlayerHandsAdded?.Invoke(hands);
}

public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null)
public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null, bool log = true)
{
base.DoDrop(uid, hand, doDropInteraction, hands);
base.DoDrop(uid, hand, doDropInteraction, hands, log);

if (TryComp(hand.HeldEntity, out SpriteComponent? sprite))
sprite.RenderOrder = EntityManager.CurrentTick.Value;
Expand Down
11 changes: 1 addition & 10 deletions Content.Client/Info/PlaytimeStats/PlaytimeStatsEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,10 @@ public PlaytimeStatsEntry(string role, TimeSpan playtime, StyleBox styleBox)

RoleLabel.Text = role;
Playtime = playtime; // store the TimeSpan value directly
PlaytimeLabel.Text = ConvertTimeSpanToHoursMinutes(playtime); // convert to string for display
PlaytimeLabel.Text = playtime.ToString(Loc.GetString("ui-playtime-time-format")); // convert to string for display
BackgroundColorPanel.PanelOverride = styleBox;
}

private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan)
{
var hours = (int)timeSpan.TotalHours;
var minutes = timeSpan.Minutes;

var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes));
return formattedTimeLoc;
}

public void UpdateShading(StyleBoxFlat styleBox)
{
BackgroundColorPanel.PanelOverride = styleBox;
Expand Down
11 changes: 1 addition & 10 deletions Content.Client/Info/PlaytimeStats/PlaytimeStatsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void PopulatePlaytimeData()
{
var overallPlaytime = _jobRequirementsManager.FetchOverallPlaytime();

var formattedPlaytime = ConvertTimeSpanToHoursMinutes(overallPlaytime);
var formattedPlaytime = overallPlaytime.ToString(Loc.GetString("ui-playtime-time-format"));
OverallPlaytimeLabel.Text = Loc.GetString("ui-playtime-overall", ("time", formattedPlaytime));

var rolePlaytimes = _jobRequirementsManager.FetchPlaytimeByRoles();
Expand Down Expand Up @@ -134,13 +134,4 @@ private void AddRolePlaytimeEntryToTable(string role, string playtimeString)
_sawmill.Error($"The provided playtime string '{playtimeString}' is not in the correct format.");
}
}

private static string ConvertTimeSpanToHoursMinutes(TimeSpan timeSpan)
{
var hours = (int) timeSpan.TotalHours;
var minutes = timeSpan.Minutes;

var formattedTimeLoc = Loc.GetString("ui-playtime-time-format", ("hours", hours), ("minutes", minutes));
return formattedTimeLoc;
}
}
2 changes: 2 additions & 0 deletions Content.Client/IoC/ClientContentIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Client.DebugMon;
using Content.Client.Eui;
using Content.Client.Fullscreen;
using Content.Client.GameTicking.Managers;
using Content.Client.GhostKick;
using Content.Client.Guidebook;
using Content.Client.Launcher;
Expand Down Expand Up @@ -57,6 +58,7 @@ public static void Register()
collection.Register<DebugMonitorManager>();
collection.Register<PlayerRateLimitManager>();
collection.Register<SharedPlayerRateLimitManager, PlayerRateLimitManager>();
collection.Register<TitleWindowManager>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@ private void ClientOnRunLevelChanged(object? sender, RunLevelChangedEventArgs e)
{
// Reset on disconnect, just in case.
_roles.Clear();
_jobWhitelists.Clear();
_roleBans.Clear();
}
}

private void RxRoleBans(MsgRoleBans message)
{
_sawmill.Debug($"Received roleban info containing {message.Bans.Count} entries.");

if (_roleBans.Equals(message.Bans))
return;

_roleBans.Clear();
_roleBans.AddRange(message.Bans);
Updated?.Invoke();
Expand Down
13 changes: 11 additions & 2 deletions Content.Client/Power/APC/ApcBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using Content.Client.Power.APC.UI;
using Content.Client.Power.APC.UI;
using Content.Shared.Access.Systems;
using Content.Shared.APC;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Shared.Player;

namespace Content.Client.Power.APC
{
Expand All @@ -22,6 +23,14 @@ protected override void Open()
_menu = this.CreateWindow<ApcMenu>();
_menu.SetEntity(Owner);
_menu.OnBreaker += BreakerPressed;

var hasAccess = false;
if (PlayerManager.LocalEntity != null)
{
var accessReader = EntMan.System<AccessReaderSystem>();
hasAccess = accessReader.IsAllowed((EntityUid)PlayerManager.LocalEntity, Owner);
}
_menu?.SetAccessEnabled(hasAccess);
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
30 changes: 17 additions & 13 deletions Content.Client/Power/APC/UI/ApcMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Robust.Client.AutoGenerated;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.XAML;
using Robust.Client.GameObjects;
using Robust.Shared.IoC;
Expand Down Expand Up @@ -36,19 +36,9 @@ public void UpdateState(BoundUserInterfaceState state)
{
var castState = (ApcBoundInterfaceState) state;

if (BreakerButton != null)
if (!BreakerButton.Disabled)
{
if(castState.HasAccess == false)
{
BreakerButton.Disabled = true;
BreakerButton.ToolTip = Loc.GetString("apc-component-insufficient-access");
}
else
{
BreakerButton.Disabled = false;
BreakerButton.ToolTip = null;
BreakerButton.Pressed = castState.MainBreaker;
}
BreakerButton.Pressed = castState.MainBreaker;
}

if (PowerLabel != null)
Expand Down Expand Up @@ -86,6 +76,20 @@ public void UpdateState(BoundUserInterfaceState state)
}
}

public void SetAccessEnabled(bool hasAccess)
{
if(hasAccess)
{
BreakerButton.Disabled = false;
BreakerButton.ToolTip = null;
}
else
{
BreakerButton.Disabled = true;
BreakerButton.ToolTip = Loc.GetString("apc-component-insufficient-access");
}
}

private void UpdateChargeBarColor(float charge)
{
if (ChargeBar == null)
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls"
MinHeight="210">
<BoxContainer Name="MainContainer" Orientation="Vertical">
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="4 4"/>
<co:SearchListContainer Name="VendingContents" VerticalExpand="True" Margin="4 4"/>
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly MapSystem _map = default!;

private EntityQuery<TransformComponent> _xformQuery;

Expand Down Expand Up @@ -109,11 +110,11 @@ public override void Update(float frameTime)

if (MapManager.TryFindGridAt(mousePos, out var gridUid, out _))
{
coordinates = EntityCoordinates.FromMap(gridUid, mousePos, TransformSystem, EntityManager);
coordinates = TransformSystem.ToCoordinates(gridUid, mousePos);
}
else
{
coordinates = EntityCoordinates.FromMap(MapManager.GetMapEntityId(mousePos.MapId), mousePos, TransformSystem, EntityManager);
coordinates = TransformSystem.ToCoordinates(_map.GetMap(mousePos.MapId), mousePos);
}

// Heavy attack.
Expand Down
32 changes: 30 additions & 2 deletions Content.IntegrationTests/Pair/TestPair.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,41 @@ public async Task WaitClientCommand(string cmd, int numTicks = 10)
/// <summary>
/// Retrieve all entity prototypes that have some component.
/// </summary>
public List<EntityPrototype> GetPrototypesWithComponent<T>(
public List<(EntityPrototype, T)> GetPrototypesWithComponent<T>(
HashSet<string>? ignored = null,
bool ignoreAbstract = true,
bool ignoreTestPrototypes = true)
where T : IComponent
{
var id = Server.ResolveDependency<IComponentFactory>().GetComponentName(typeof(T));
var list = new List<(EntityPrototype, T)>();
foreach (var proto in Server.ProtoMan.EnumeratePrototypes<EntityPrototype>())
{
if (ignored != null && ignored.Contains(proto.ID))
continue;

if (ignoreAbstract && proto.Abstract)
continue;

if (ignoreTestPrototypes && IsTestPrototype(proto))
continue;

if (proto.Components.TryGetComponent(id, out var cmp))
list.Add((proto, (T)cmp));
}

return list;
}

/// <summary>
/// Retrieve all entity prototypes that have some component.
/// </summary>
public List<EntityPrototype> GetPrototypesWithComponent(Type type,
HashSet<string>? ignored = null,
bool ignoreAbstract = true,
bool ignoreTestPrototypes = true)
{
var id = Server.ResolveDependency<IComponentFactory>().GetComponentName(type);
var list = new List<EntityPrototype>();
foreach (var proto in Server.ProtoMan.EnumeratePrototypes<EntityPrototype>())
{
Expand All @@ -127,7 +155,7 @@ public List<EntityPrototype> GetPrototypesWithComponent<T>(
continue;

if (proto.Components.ContainsKey(id))
list.Add(proto);
list.Add((proto));
}

return list;
Expand Down
Loading

0 comments on commit 810d840

Please sign in to comment.