private void OnConnectStateChanged(ClientConnectionState state)
    {
        if (state != ClientConnectionState.Connected)
        {
            return;
        }

        var path      = new ResourcePath($"/rules_last_seen_{_configManager.GetCVar(CCVars.ServerId)}");
        var showRules = true;

        if (_resource.UserData.TryReadAllText(path, out var lastReadTimeText) &&
            DateTime.TryParse(lastReadTimeText, null, DateTimeStyles.AssumeUniversal, out var lastReadTime))
        {
            showRules = lastReadTime < DateTime.UtcNow - TimeSpan.FromDays(60);
        }
        else
        {
            SaveLastReadTime();
        }

        if (showRules)
        {
            OpenRulesAndInfoWindow?.Invoke();
        }
    }
Beispiel #2
0
    private void OnStateChanged(StateChangedEventArgs args)
    {
        if (args.NewState is not(GameScreen or LobbyState))
        {
            return;
        }
        _stateManager.OnStateChanged -= OnStateChanged;

        var path      = new ResourcePath($"/rules_last_seen_{_configManager.GetCVar(CCVars.ServerId)}");
        var showRules = true;

        if (_resource.UserData.TryReadAllText(path, out var lastReadTimeText) &&
            DateTime.TryParse(lastReadTimeText, null, DateTimeStyles.AssumeUniversal, out var lastReadTime))
        {
            showRules = lastReadTime < DateTime.UtcNow - TimeSpan.FromDays(60);
        }
        else
        {
            SaveLastReadTime();
        }

        if (showRules)
        {
            OpenRulesAndInfoWindow?.Invoke();
        }
    }