From 02352af3d98c14fa3c4dceb35cdc46812f62f6c7 Mon Sep 17 00:00:00 2001 From: "petrak@" Date: Sat, 22 Jul 2023 00:03:03 -0500 Subject: [PATCH] Render the ranks and files on the edge cells, like Lichess does --- .../src/Framework/Application/UI/BoardTheme.cs | 3 +++ .../src/Framework/Application/UI/BoardUI.cs | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Chess-Challenge/src/Framework/Application/UI/BoardTheme.cs b/Chess-Challenge/src/Framework/Application/UI/BoardTheme.cs index 181a67f..40eb0cb 100644 --- a/Chess-Challenge/src/Framework/Application/UI/BoardTheme.cs +++ b/Chess-Challenge/src/Framework/Application/UI/BoardTheme.cs @@ -23,6 +23,9 @@ namespace ChessChallenge.Application public Color CheckDark = new Color(207, 39, 39, 255); public Color BorderCol = new Color(44, 44, 44, 255); + + public Color LightCoordCol = new Color(255, 240, 220, 255); + public Color DarkCoordCol = new Color(140, 100, 80, 255); } } diff --git a/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs b/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs index c49668d..2c0e558 100644 --- a/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs +++ b/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs @@ -318,6 +318,23 @@ namespace ChessChallenge.Application { DrawPiece(piece, new Vector2((int)pos.X, (int)pos.Y), alpha); } + + int textSize = 25; + float xpadding = 5f, ypadding = 2f; + Color otherColor = coord.IsLightSquare() ? theme.DarkCoordCol : theme.LightCoordCol; + if (rank == 0) { + string fileLetter = "abcdefgh"[file].ToString(); + UIHelper.DrawText(fileLetter, + pos + new Vector2(xpadding, squareSize - ypadding), + textSize, 123, otherColor, + UIHelper.AlignH.Left, UIHelper.AlignV.Bottom); + } + if (file == 7) { + UIHelper.DrawText((rank + 1).ToString(), + pos + new Vector2(squareSize - xpadding, ypadding), + textSize, 123, otherColor, + UIHelper.AlignH.Right, UIHelper.AlignV.Top); + } } Vector2 GetSquarePos(int file, int rank, bool whitePerspective)