Table of Contents

Class PlayerHistoryViewModel

Namespace
McServerLauncher.ViewModels
Assembly
McServerLauncher.dll

The Players tab's history: everyone who has been on this server, and each one's profile.

public sealed class PlayerHistoryViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Inheritance
PlayerHistoryViewModel
Implements
Inherited Members

Remarks

The store is opened the first time it is needed, not when the view model is built: a view model built for a test, or for a server nobody opens, must not start writing into the user's app data.

Recording happens on the thread the server's output arrives on, so writing a line to disk never holds up the console on the UI thread.

Constructors

PlayerHistoryViewModel(ServerViewModel)

public PlayerHistoryViewModel(ServerViewModel server)

Parameters

server ServerViewModel

Properties

Details

[ExcludeFromCodeCoverage]
public PlayerDetailsViewModel? Details { get; set; }

Property Value

PlayerDetailsViewModel

HasDetails

public bool HasDetails { get; }

Property Value

bool

IsDisabled

Whether the history is switched off in the settings, so the tab can say so.

public bool IsDisabled { get; }

Property Value

bool

IsImporting

[ExcludeFromCodeCoverage]
public bool IsImporting { get; set; }

Property Value

bool

OpenCommand

Gets an IRelayCommand<T> instance wrapping Open(PlayerRowViewModel).

[ExcludeFromCodeCoverage]
public IRelayCommand<PlayerRowViewModel?> OpenCommand { get; }

Property Value

IRelayCommand<PlayerRowViewModel>

Rows

One Reset per rebuild instead of one notification per player: the list is emptied and refilled whole, and every name in between is a state nobody needs to see.

public BulkObservableCollection<PlayerRowViewModel> Rows { get; }

Property Value

BulkObservableCollection<PlayerRowViewModel>
[ExcludeFromCodeCoverage]
public string Search { get; set; }

Property Value

string

Methods

EnsureLoaded()

Builds the list the first time the Players tab is actually shown.

public void EnsureLoaded()

Remarks

Until then nothing here is rebuilt, however much the server talks. Every running server used to rebuild its whole list on every join and every leave, selected or not, visible or not — a copy of every record, a sort, and a notification per row, for a tab that in most sessions is never opened at all.

OnServerLine(string, IReadOnlySet<string>)

Records a line of the server's output, if it is about a player. Called on the output's thread.

public void OnServerLine(string line, IReadOnlySet<string> online)

Parameters

line string
online IReadOnlySet<string>

OnServerStopped()

The server stopped: whoever was still on it has left, whatever the log said.

public void OnServerStopped()

OnSettingsChanged()

The settings changed: the limits may be tighter now, and the tab may need to say it is off.

public void OnSettingsChanged()

Refresh()

Rebuilds the list: everyone in the history, everyone the server itself remembers (usercache.json), and whoever is on right now. Connected first, then by last seen.

public void Refresh()

RequestRefresh()

Asks for a rebuild: soon, once, and only if there is a list on screen to be wrong.

public void RequestRefresh()

Remarks

Ten players joining at once is one rebuild, not ten. If the tab has never been opened there is nothing to rebuild: EnsureLoaded() reads the current state when it is.

Shutdown()

Stops the pending rebuild, if any. Mirrors nothing else: there is nothing to start.

public void Shutdown()

Start()

Once per run of the app: drops what the settings no longer allow, and imports the server's old logs if that was never done. In the background, since a server with years of logs takes a moment.

public void Start()