From c29ef2426cdc7dbbdf504b1798205bb9711e6d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolaj=20=C3=98sterby=20Jensen?= Date: Tue, 22 Oct 2024 22:21:53 +0200 Subject: [PATCH] Formatting --- RLBotCS/ManagerTools/Rendering.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/RLBotCS/ManagerTools/Rendering.cs b/RLBotCS/ManagerTools/Rendering.cs index 8f50798..4fb9e1f 100644 --- a/RLBotCS/ManagerTools/Rendering.cs +++ b/RLBotCS/ManagerTools/Rendering.cs @@ -2,7 +2,6 @@ using Bridge.Controller; using Bridge.State; using Bridge.TCP; -using Microsoft.Extensions.Primitives; using rlbot.flat; using RLBotCS.Conversion; using Color = System.Drawing.Color; @@ -17,7 +16,7 @@ public class Rendering(TcpMessenger tcpMessenger) public const int ResolutionHeightPixels = 1080; public const int FontWidthPixels = 10; public const int FontHeightPixels = 20; - + private readonly RenderingSender _renderingSender = new(tcpMessenger); private readonly Dictionary>> _clientRenderTracker = []; @@ -85,17 +84,20 @@ private ushort RenderItem(RenderTypeUnion renderItem, GameState gameState) => private ushort SendRect2D(Rect2DT rect2Dt) { // Move rect left/up when width/height is negative - var adjustedX = !rect2Dt.Centered && rect2Dt.Width < 0 ? rect2Dt.X - rect2Dt.Width : rect2Dt.X; - var adjustedY = !rect2Dt.Centered && rect2Dt.Height < 0 ? rect2Dt.Y - rect2Dt.Height : rect2Dt.X; - + var adjustedX = + !rect2Dt.Centered && rect2Dt.Width < 0 ? rect2Dt.X - rect2Dt.Width : rect2Dt.X; + var adjustedY = + !rect2Dt.Centered && rect2Dt.Height < 0 ? rect2Dt.Y - rect2Dt.Height : rect2Dt.X; + // Fake a filled rectangle using a string with colored background var (text, scale) = MakeFakeRectangleString( - (int)Math.Abs(rect2Dt.Width * ResolutionWidthPixels), - (int)Math.Abs(rect2Dt.Height * ResolutionHeightPixels)); - + (int)Math.Abs(rect2Dt.Width * ResolutionWidthPixels), + (int)Math.Abs(rect2Dt.Height * ResolutionHeightPixels) + ); + var hAlign = rect2Dt.Centered ? TextHAlign.Center : TextHAlign.Left; var vAlign = rect2Dt.Centered ? TextHAlign.Center : TextHAlign.Left; - + return _renderingSender.AddText2D( text, adjustedX, @@ -112,9 +114,10 @@ private ushort SendRect3D(Rect3DT rect3Dt, GameState gameState) { // Fake a filled rectangle using a string with colored background var (text, scale) = MakeFakeRectangleString( - (int)Math.Abs(rect3Dt.Width * ResolutionWidthPixels), - (int)Math.Abs(rect3Dt.Height * ResolutionHeightPixels)); - + (int)Math.Abs(rect3Dt.Width * ResolutionWidthPixels), + (int)Math.Abs(rect3Dt.Height * ResolutionHeightPixels) + ); + return _renderingSender.AddText3D( text, FlatToModel.ToRenderAnchor(rect3Dt.Anchor, gameState), @@ -151,7 +154,7 @@ int Gcd(int a, int b) // We use the greatest common divisor to simplify the fraction (width/height) // minimizing the characters needed for the rectangle. int gcd = Gcd(width, height); - int cols = (width / gcd) * (FontHeightPixels / FontWidthPixels); + int cols = (width / gcd) * (FontHeightPixels / FontWidthPixels); int rows = height / gcd; StringBuilder str = new StringBuilder(cols * rows + rows);