wip move to new uniffi language binding

This commit is contained in:
Vinzenz Schroeter 2024-11-12 18:27:04 +01:00
parent f7a5d8f823
commit 53cbdd8440
30 changed files with 211 additions and 187 deletions

View file

@ -17,7 +17,7 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer, IDisposable
private readonly MapService _mapService;
private readonly ILogger<SendToServicePointDisplay> _logger;
private readonly PlayerServer _players;
private readonly Cp437Grid _scoresBuffer;
private readonly CharGrid _scoresBuffer;
private readonly TimeSpan _minFrameTime;
private readonly IOptionsMonitor<HostConfiguration> _options;
@ -42,13 +42,13 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer, IDisposable
var localIp = GetLocalIPv4(displayConfig.Value).Split('.');
Debug.Assert(localIp.Length == 4);
_scoresBuffer = new Cp437Grid(12, 20);
_scoresBuffer = new CharGrid(12, 20);
_scoresBuffer[00] = "== TANKS! ==";
_scoresBuffer[01] = "-- scores --";
_scoresBuffer[17] = "-- join --";
_scoresBuffer[18] = string.Join('.', localIp[..2]);
_scoresBuffer[19] = string.Join('.', localIp[2..]);
_scoresBuffer.SetRow(00, "== TANKS! ==");
_scoresBuffer.SetRow(01, "-- scores --");
_scoresBuffer.SetRow(17, "-- join --");
_scoresBuffer.SetRow(18, string.Join('.', localIp[..2]));
_scoresBuffer.SetRow(19, string.Join('.', localIp[2..]));
}
public async Task OnFrameDoneAsync(GamePixelGrid gamePixelGrid, Bitmap observerPixels)
@ -66,9 +66,8 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer, IDisposable
try
{
_displayConnection.Send(Command.BitmapLinearWin(0, 0, observerPixels.Clone(), CompressionCode.Lzma)
.IntoPacket());
_displayConnection.Send(Command.Cp437Data(MapService.TilesPerRow, 0, _scoresBuffer.Clone()).IntoPacket());
_displayConnection.Send(Command.BitmapLinearWin(0, 0, observerPixels, CompressionCode.Lzma));
_displayConnection.Send(Command.Cp437Data(MapService.TilesPerRow, 0, _scoresBuffer.ToCp437()));
}
catch (SocketException ex)
{
@ -95,14 +94,14 @@ internal sealed class SendToServicePointDisplay : IFrameConsumer, IDisposable
var name = p.Name[..nameLength];
var spaces = new string(' ', ScoresWidth - score.Length - nameLength);
_scoresBuffer[row] = name + spaces + score;
_scoresBuffer.SetRow(row, name + spaces + score);
row++;
}
for (; row < 16; row++)
_scoresBuffer[row] = string.Empty;
_scoresBuffer.SetRow(row, new string(' ', ScoresWidth));
_scoresBuffer[16] = _mapService.Current.Name[..(Math.Min(ScoresWidth, _mapService.Current.Name.Length) - 1)];
_scoresBuffer.SetRow(16, _mapService.Current.Name[..(Math.Min(ScoresWidth, _mapService.Current.Name.Length) - 1)]);
}
private static string GetLocalIPv4(DisplayConfiguration configuration)