Show rules on first connection (#5715)
* Implement showing rules on first connection * Clean up RulesManager * Change changelog and rules unread to use CVars * Fix missing change * Rename InfoWindow to RulesAndInfoWindow * Change default server.id to unknown * Fix invalid file contents and getting CVar
This commit is contained in:
@@ -4,6 +4,8 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.CCVar;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -18,11 +20,9 @@ namespace Content.Client.Changelog
|
||||
{
|
||||
public sealed class ChangelogManager
|
||||
{
|
||||
// If you fork SS14, change this to have the changelog "last seen" date stored separately.
|
||||
public const string ForkId = "Wizards";
|
||||
|
||||
[Dependency] private readonly IResourceManager _resource = default!;
|
||||
[Dependency] private readonly ISerializationManager _serialization = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
|
||||
public bool NewChangelogEntries { get; private set; }
|
||||
public int LastReadId { get; private set; }
|
||||
@@ -43,7 +43,7 @@ namespace Content.Client.Changelog
|
||||
NewChangelogEntries = false;
|
||||
NewChangelogEntriesChanged?.Invoke();
|
||||
|
||||
using var file = _resource.UserData.Create(new ResourcePath($"/changelog_last_seen_{ForkId}"));
|
||||
using var file = _resource.UserData.Create(new ResourcePath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}"));
|
||||
using var sw = new StreamWriter(file);
|
||||
|
||||
sw.Write(MaxId.ToString());
|
||||
@@ -61,7 +61,7 @@ namespace Content.Client.Changelog
|
||||
|
||||
MaxId = changelog.Max(c => c.Id);
|
||||
|
||||
var path = new ResourcePath($"/changelog_last_seen_{ForkId}");
|
||||
var path = new ResourcePath($"/changelog_last_seen_{_configManager.GetCVar(CCVars.ServerId)}");
|
||||
if (_resource.UserData.Exists(path))
|
||||
{
|
||||
LastReadId = int.Parse(_resource.UserData.ReadAllText(path));
|
||||
|
||||
Reference in New Issue
Block a user