From 39e6a868be7d957ce6d613ff47ab8f37d2522593 Mon Sep 17 00:00:00 2001 From: Sebastian Lague Date: Sat, 22 Jul 2023 13:40:05 +0200 Subject: [PATCH] Fix board UI coordinates when playing black --- .../Framework/Application/Core/Settings.cs | 11 ++++-- .../src/Framework/Application/UI/BoardUI.cs | 38 ++++++++++--------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Chess-Challenge/src/Framework/Application/Core/Settings.cs b/Chess-Challenge/src/Framework/Application/Core/Settings.cs index f924ff4..cb4cb7f 100644 --- a/Chess-Challenge/src/Framework/Application/Core/Settings.cs +++ b/Chess-Challenge/src/Framework/Application/Core/Settings.cs @@ -6,17 +6,20 @@ namespace ChessChallenge.Application { public const string Version = "1.1"; + // Game settings public const int GameDurationMilliseconds = 60 * 1000; public const float MinMoveDelay = 0; public static readonly bool RunBotsOnSeparateThread = true; - public const int MaxTokenCount = 1024; - - public const LogType MessagesToLog = LogType.All; - + // Display settings + public const bool DisplayBoardCoordinates = true; public static readonly Vector2 ScreenSizeSmall = new(1280, 720); public static readonly Vector2 ScreenSizeBig = new(1920, 1080); + // Other settings + public const int MaxTokenCount = 1024; + public const LogType MessagesToLog = LogType.All; + public enum LogType { None, diff --git a/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs b/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs index 2c0e558..c68bd5f 100644 --- a/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs +++ b/Chess-Challenge/src/Framework/Application/UI/BoardUI.cs @@ -3,6 +3,7 @@ using Raylib_cs; using System; using System.Collections.Generic; using System.Numerics; +using static ChessChallenge.Application.UIHelper; namespace ChessChallenge.Application { @@ -276,9 +277,6 @@ namespace ChessChallenge.Application } UIHelper.DrawText(timeText, timePos, fontSize, fontSpacing, textCol, UIHelper.AlignH.Right); } - - - //Raylib.DrawText() } public void ResetSquareColours(bool keepPrevMoveHighlight = false) @@ -319,21 +317,25 @@ 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); + if (Settings.DisplayBoardCoordinates) + { + int textSize = 25; + float xpadding = 5f; + float ypadding = 2f; + Color coordNameCol = coord.IsLightSquare() ? theme.DarkCoordCol : theme.LightCoordCol; + + if (rank == (whitePerspective ? 0 : 7)) + { + string fileName = BoardHelper.fileNames[file] + ""; + Vector2 drawPos = pos + new Vector2(xpadding, squareSize - ypadding); + DrawText(fileName, drawPos, textSize, 0, coordNameCol, AlignH.Left, AlignV.Bottom); + } + if (file == (whitePerspective ? 7 : 0)) + { + string rankName = (rank + 1) + ""; + Vector2 drawPos = pos + new Vector2(squareSize - xpadding, ypadding); + DrawText(rankName, drawPos, textSize, 0, coordNameCol, AlignH.Right, AlignV.Top); + } } }