Release v0.1.0

This commit is contained in:
nikit3s
2026-09-26 21:51:08 +03:00
parent 1975c1ceff
commit 7ac8c78d8b
12 changed files with 317 additions and 52 deletions
+32 -7
View File
@@ -239,6 +239,8 @@ namespace SbLauncher
readonly DispatcherTimer _saveTimer = new DispatcherTimer();
readonly DispatcherTimer _logTimer = new DispatcherTimer();
readonly ConcurrentQueue<string> _pendingLog = new ConcurrentQueue<string>();
readonly object _logGate = new object();
static readonly Regex AnsiEscape = new Regex(@"\x1B\[[0-9;]*[A-Za-z]", RegexOptions.Compiled);
int _pendingLogCount, _adapterRefreshVersion, _ipVersion;
bool _connecting, _checking, _pinging, _editingProfiles;
List<AdapterInfo> _adapterSnapshot = new List<AdapterInfo>();
@@ -271,6 +273,7 @@ namespace SbLauncher
_logTimer.Start();
ConnectCommand = new RelayCommand(delegate { ToggleConnect(); });
ClearLogCommand = new RelayCommand(delegate { ClearLog(); });
PingAllCommand = new RelayCommand(delegate { PingAll(); });
KillStrayCommand = new RelayCommand(delegate { KillStray(); });
OpenFolderCommand = new RelayCommand(delegate { OpenFolder(); });
@@ -285,6 +288,7 @@ namespace SbLauncher
}
public ICommand ConnectCommand { get; private set; }
public ICommand ClearLogCommand { get; private set; }
public ICommand PingAllCommand { get; private set; }
public ICommand KillStrayCommand { get; private set; }
public ICommand OpenFolderCommand { get; private set; }
@@ -304,6 +308,7 @@ namespace SbLauncher
public string ConnectionPhase { get { return _connectionPhase; } set { _connectionPhase = value; Raise(); } }
public bool IsConnected { get { return _runner.IsRunning; } }
public string LogText { get { return _log; } set { _log = value; Raise(); } }
public Brush LogBrush { get { return Theme.Res("LogText"); } }
public string ImportStatus { get { return _importStatus; } set { _importStatus = value; Raise(); } }
public bool IsBusy { get { return _busy; } set { _busy = value; Raise(); } }
@@ -463,6 +468,7 @@ namespace SbLauncher
if (ThemeApplier != null) ThemeApplier(_theme);
Raise("ThemeName"); Raise("ThemeGlyph");
Raise("StatusBrush");
Raise("LogBrush");
Raise("TabLogBrush"); Raise("TabSettingsBrush");
Raise("PrivateKeyHintBrush"); Raise("LocalAddressHintBrush"); Raise("AdapterHintBrush");
foreach (ServerVm s in Servers) s.RefreshBrushes();
@@ -1005,13 +1011,29 @@ namespace SbLauncher
public void AppendLog(string line)
{
if (line == null) line = "";
if (line.IndexOf('\x1b') >= 0) line = AnsiEscape.Replace(line, "");
string stamped = DateTime.Now.ToString("HH:mm:ss", CultureInfo.InvariantCulture) + " " + line;
_pendingLog.Enqueue(stamped);
if (Interlocked.Increment(ref _pendingLogCount) > 2000)
lock (_logGate)
{
_pendingLog.Enqueue(stamped);
if (++_pendingLogCount > 2000)
{
string discarded;
if (_pendingLog.TryDequeue(out discarded)) --_pendingLogCount;
}
}
}
public void ClearLog()
{
lock (_logGate)
{
string discarded;
if (_pendingLog.TryDequeue(out discarded)) Interlocked.Decrement(ref _pendingLogCount);
while (_pendingLog.TryDequeue(out discarded)) { }
_pendingLogCount = 0;
}
LogText = "";
}
void FlushLog()
@@ -1019,11 +1041,14 @@ namespace SbLauncher
StringBuilder batch = new StringBuilder();
string line;
int n = 0;
while (n++ < 200 && _pendingLog.TryDequeue(out line))
lock (_logGate)
{
Interlocked.Decrement(ref _pendingLogCount);
if (batch.Length > 0) batch.AppendLine();
batch.Append(line);
while (n++ < 200 && _pendingLog.TryDequeue(out line))
{
--_pendingLogCount;
if (batch.Length > 0) batch.AppendLine();
batch.Append(line);
}
}
if (batch.Length == 0) return;
string old = LogText;