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";
// 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,

View file

@ -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);
}
}
}