Fix board UI coordinates when playing black

This commit is contained in:
Sebastian Lague 2023-07-22 13:40:05 +02:00
parent 1e33246f21
commit 39e6a868be
2 changed files with 27 additions and 22 deletions

View file

@ -6,17 +6,20 @@ namespace ChessChallenge.Application
{ {
public const string Version = "1.1"; public const string Version = "1.1";
// Game settings
public const int GameDurationMilliseconds = 60 * 1000; public const int GameDurationMilliseconds = 60 * 1000;
public const float MinMoveDelay = 0; public const float MinMoveDelay = 0;
public static readonly bool RunBotsOnSeparateThread = true; public static readonly bool RunBotsOnSeparateThread = true;
public const int MaxTokenCount = 1024; // Display settings
public const bool DisplayBoardCoordinates = true;
public const LogType MessagesToLog = LogType.All;
public static readonly Vector2 ScreenSizeSmall = new(1280, 720); public static readonly Vector2 ScreenSizeSmall = new(1280, 720);
public static readonly Vector2 ScreenSizeBig = new(1920, 1080); public static readonly Vector2 ScreenSizeBig = new(1920, 1080);
// Other settings
public const int MaxTokenCount = 1024;
public const LogType MessagesToLog = LogType.All;
public enum LogType public enum LogType
{ {
None, None,

View file

@ -3,6 +3,7 @@ using Raylib_cs;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using static ChessChallenge.Application.UIHelper;
namespace ChessChallenge.Application namespace ChessChallenge.Application
{ {
@ -276,9 +277,6 @@ namespace ChessChallenge.Application
} }
UIHelper.DrawText(timeText, timePos, fontSize, fontSpacing, textCol, UIHelper.AlignH.Right); UIHelper.DrawText(timeText, timePos, fontSize, fontSpacing, textCol, UIHelper.AlignH.Right);
} }
//Raylib.DrawText()
} }
public void ResetSquareColours(bool keepPrevMoveHighlight = false) public void ResetSquareColours(bool keepPrevMoveHighlight = false)
@ -319,21 +317,25 @@ namespace ChessChallenge.Application
DrawPiece(piece, new Vector2((int)pos.X, (int)pos.Y), alpha); DrawPiece(piece, new Vector2((int)pos.X, (int)pos.Y), alpha);
} }
if (Settings.DisplayBoardCoordinates)
{
int textSize = 25; int textSize = 25;
float xpadding = 5f, ypadding = 2f; float xpadding = 5f;
Color otherColor = coord.IsLightSquare() ? theme.DarkCoordCol : theme.LightCoordCol; float ypadding = 2f;
if (rank == 0) { Color coordNameCol = coord.IsLightSquare() ? theme.DarkCoordCol : theme.LightCoordCol;
string fileLetter = "abcdefgh"[file].ToString();
UIHelper.DrawText(fileLetter, if (rank == (whitePerspective ? 0 : 7))
pos + new Vector2(xpadding, squareSize - ypadding), {
textSize, 123, otherColor, string fileName = BoardHelper.fileNames[file] + "";
UIHelper.AlignH.Left, UIHelper.AlignV.Bottom); 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);
} }
if (file == 7) {
UIHelper.DrawText((rank + 1).ToString(),
pos + new Vector2(squareSize - xpadding, ypadding),
textSize, 123, otherColor,
UIHelper.AlignH.Right, UIHelper.AlignV.Top);
} }
} }