Skip to content

Commit

Permalink
Merge branch 'master' into Try-to-fix-the-mess-Colin-made
Browse files Browse the repository at this point in the history
Signed-off-by: Debug <[email protected]>
  • Loading branch information
DebugOk authored Oct 8, 2023
2 parents 6fda3e1 + 8339ecc commit 9308446
Show file tree
Hide file tree
Showing 295 changed files with 114,190 additions and 197 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
changelog:
runs-on: ubuntu-latest
runs-on: self-hosted
if: github.event.pull_request.merged == true
permissions:
contents: write
Expand Down
51 changes: 39 additions & 12 deletions Content.Client/Changelog/ChangelogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Content.Shared.CCVar;
using Robust.Shared.Configuration;
Expand All @@ -25,8 +26,8 @@ public sealed partial class ChangelogManager
[Dependency] private readonly IConfigurationManager _configManager = default!;

public bool NewChangelogEntries { get; private set; }
public int LastReadId { get; private set; }
public int MaxId { get; private set; }
public DateTime LastReadTime { get; private set; } // Modified, see EOF
public DateTime MaxTime { get; private set; } // Modified, see EOF

public event Action? NewChangelogEntriesChanged;

Expand All @@ -35,17 +36,17 @@ public sealed partial class ChangelogManager
/// stores the new ID to disk and clears <see cref="NewChangelogEntries"/>.
/// </summary>
/// <remarks>
/// <see cref="LastReadId"/> is NOT cleared
/// <see cref="LastReadTime"/> is NOT cleared
/// since that's used in the changelog menu to show the "since you last read" bar.
/// </remarks>
public void SaveNewReadId()
{
NewChangelogEntries = false;
NewChangelogEntriesChanged?.Invoke();

using var sw = _resource.UserData.OpenWriteText(new ($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}"));
using var sw = _resource.UserData.OpenWriteText(new ($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}_datetime")); // Modified, see EOF

sw.Write(MaxId.ToString());
sw.Write(MaxTime.ToString("O")); // Modified, see EOF
}

public async void Initialize()
Expand All @@ -58,24 +59,46 @@ public async void Initialize()
return;
}

MaxId = changelog.Max(c => c.Id);
MaxTime = changelog.Max(c => c.Time); // Modified, see EOF

var path = new ResPath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}");
if(_resource.UserData.TryReadAllText(path, out var lastReadIdText))
// Begin modified codeblock, see EOF
var path = new ResPath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}_datetime");
if(_resource.UserData.TryReadAllText(path, out var lastReadTimeText))
{
LastReadId = int.Parse(lastReadIdText);
if (Regex.IsMatch(lastReadTimeText,
@"^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$"))
{
LastReadTime = DateTime.ParseExact(lastReadTimeText, "O", CultureInfo.InvariantCulture);
}
}

NewChangelogEntries = LastReadId < MaxId;
NewChangelogEntries = LastReadTime < MaxTime;
// End modified codeblock

NewChangelogEntriesChanged?.Invoke();
}

public Task<List<ChangelogEntry>> LoadChangelog()
// Begin modified codeblock, see EOF
public async Task<List<ChangelogEntry>> LoadChangelog()
{
var paths = _resource.ContentFindFiles("/Changelog/")
.Where(filePath => filePath.Extension == "yml")
.ToArray();

var result = new List<ChangelogEntry>();
foreach (var path in paths)
{
var changelog = await LoadChangelogFile(path);
result = result.Union(changelog).ToList();
}
return result.OrderBy(x => x.Time).ToList();
}

private Task<List<ChangelogEntry>> LoadChangelogFile(ResPath path) // end modified codeblock
{
return Task.Run(() =>
{
var yamlData = _resource.ContentFileReadYaml(new ("/Changelog/Changelog.yml"));
var yamlData = _resource.ContentFileReadYaml(path); // Modified, see EOF

if (yamlData.Documents.Count == 0)
return new List<ChangelogEntry>();
Expand Down Expand Up @@ -126,3 +149,7 @@ public enum ChangelogLineType
}
}
}


// This file was extensively modified to allow for datetime based changelogs instead of relying on IDs.
// This is because our IDs are much lower then Wizdens, and if we use their entries, the server will not properly show new changes
7 changes: 5 additions & 2 deletions Content.Client/Changelog/ChangelogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ private async void PopulateChangelog()
.GroupBy(e => e.Time.ToLocalTime().Date)
.OrderByDescending(c => c.Key);

var hasRead = _changelog.MaxId <= _changelog.LastReadId;
var hasRead = _changelog.MaxTime <= _changelog.LastReadTime; // Modified, see EOF
foreach (var dayEntries in byDay)
{
var day = dayEntries.Key;

var groupedEntries = dayEntries
.GroupBy(c => (c.Author, Read: c.Id <= _changelog.LastReadId))
.GroupBy(c => (c.Author, Read: c.Time <= _changelog.LastReadTime)) // Modified, see EOF
.OrderBy(c => c.Key.Read)
.ThenBy(c => c.Key.Author);

Expand Down Expand Up @@ -203,3 +203,6 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
}
}
}

// This file was extensively modified to allow for datetime based changelogs instead of relying on IDs.
// This is because our IDs are much lower then Wizdens, and if we use their entries, the server will not properly show new changes
48 changes: 48 additions & 0 deletions Content.Client/DeltaV/Hologram/HologramSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Content.Shared.DeltaV.Hologram;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Prototypes;

namespace Content.Client.DeltaV.Hologram;

public sealed class HologramSystem : SharedHologramSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly OccluderSystem _occluder = default!;
[Dependency] private readonly EntityManager _entMan = default!;

private ShaderInstance _shader = default!;

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

_shader = _protoMan.Index<ShaderPrototype>("Hologram").InstanceUnique();
SubscribeLocalEvent<HologramComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<HologramComponent, ComponentStartup>(OnStartup);
}

private void SetShader(EntityUid uid, bool enabled, HologramComponent? component = null, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref component, ref sprite, false))
return;

sprite.PostShader = enabled ? _shader : null;
}

private void OnStartup(EntityUid uid, HologramComponent component, ComponentStartup args)
{
SetShader(uid, true, component);

component.Occludes = _entMan.TryGetComponent<OccluderComponent>(uid, out var occluder) && occluder.Enabled;
if (component.Occludes)
_occluder.SetEnabled(uid, false);
}

private void OnShutdown(EntityUid uid, HologramComponent component, ComponentShutdown args)
{
SetShader(uid, false, component);
if (component.Occludes)
_occluder.SetEnabled(uid, true);
}
}
44 changes: 44 additions & 0 deletions Content.Client/Nyanotrasen/Overlays/DogVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.Abilities;

namespace Content.Client.Nyanotrasen.Overlays;

public sealed partial class DogVisionOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;


public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _dogVisionShader;

public DogVisionOverlay()
{
IoCManager.InjectDependencies(this);
_dogVisionShader = _prototypeManager.Index<ShaderPrototype>("DogVision").Instance().Duplicate();
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
return;
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
return;
if (!_entityManager.HasComponent<DogVisionComponent>(player))
return;

_dogVisionShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);


var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3.Identity);
worldHandle.UseShader(_dogVisionShader);
worldHandle.DrawRect(viewport, Color.White);
}
}
51 changes: 51 additions & 0 deletions Content.Client/Nyanotrasen/Overlays/DogVisionSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Shared.Abilities;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;

namespace Content.Client.Nyanotrasen.Overlays;

public sealed partial class DogVisionSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;

private DogVisionOverlay _overlay = default!;

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

SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit);
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown);

SubscribeLocalEvent<DogVisionComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DogVisionComponent, PlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, PlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, PlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}

private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
_overlayMan.AddOverlay(_overlay);
}

private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
{
_overlayMan.RemoveOverlay(_overlay);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Content.Shared.ReverseEngineering;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.Nyanotrasen.ReverseEngineering;

[UsedImplicitly]
public sealed class ReverseEngineeringMachineBoundUserInterface : BoundUserInterface
{
private ReverseEngineeringMachineMenu? _revMenu;

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

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

_revMenu = new ReverseEngineeringMachineMenu();

_revMenu.OnClose += Close;
_revMenu.OpenCentered();

_revMenu.OnScanButtonPressed += _ =>
{
SendMessage(new ReverseEngineeringMachineScanButtonPressedMessage());
};

_revMenu.OnSafetyButtonToggled += safetyArgs =>
{
SendMessage(new ReverseEngineeringMachineSafetyButtonToggledMessage(safetyArgs.Pressed));
};

_revMenu.OnAutoScanButtonToggled += autoArgs =>
{
SendMessage(new ReverseEngineeringMachineAutoScanButtonToggledMessage(autoArgs.Pressed));
};

_revMenu.OnStopButtonPressed += _ =>
{
SendMessage(new ReverseEngineeringMachineStopButtonPressedMessage());
};

_revMenu.OnEjectButtonPressed += _ =>
{
SendMessage(new ReverseEngineeringMachineEjectButtonPressedMessage());
};
}

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

switch (state)
{
case ReverseEngineeringMachineScanUpdateState msg:
_revMenu?.SetButtonsDisabled(msg);
_revMenu?.UpdateInformationDisplay(msg);
_revMenu?.UpdateProbeTickProgressBar(msg);
break;
}
}

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

if (!disposing)
return;

_revMenu?.Dispose();
}
}

Loading

0 comments on commit 9308446

Please sign in to comment.