I have already written these 2 routines which create a board and pieces on it. Yet you can send me the 4-in-line GUI.Karlo Bala wrote:
I have somewhere GUI for 4-in-line game. It is not totally finished, but it has graphic. If you want I can mail it to you
Now I need to find out how to check for (and eventually install) a chess font programmatically.
Code: Select all
void DrawChessPiece(CHESSGUI *ChsGUI, UINT32 Colors[], Graphics::TBitmap *Bitmap1, int X, int Y, int xx, int yy,
int nPieceNr, int nSqColour, int nPieceColour, TImage *Image1, char *FontName, bool bMainBoard)
{
DWORD nPieceColor, nSqColor;
char *ch[] = { "*", "p", "n", "b", "r", "q", "k" };
//
Bitmap1->Width = 2*xx; Bitmap1->Height = 2*yy;
Bitmap1->Canvas->Pen->Color = 0x00000000;
Bitmap1->Canvas->Font->Height = 2*yy;
Bitmap1->Canvas->Brush->Style = bsSolid;
if (bMainBoard) { if (nPieceColour) nPieceColor = Colors[2]; else nPieceColor = Colors[3]; }
if (!bMainBoard) { if (nPieceColour) nPieceColor = Colors[6]; else nPieceColor = Colors[7]; }
Bitmap1->Canvas->Brush->Color = nPieceColor;
Bitmap1->Canvas->Font->Name = FontName;
Bitmap1->Canvas->TextOut(0, 0, ch[nPieceNr]);
if (bMainBoard) { if (nSqColour) nSqColor = Colors[0]; else nSqColor = Colors[1]; }
if (!bMainBoard) { if (nSqColour) nSqColor = Colors[4]; else nSqColor = Colors[5]; }
Bitmap1->Canvas->Brush->Color = nSqColor;
Bitmap1->Canvas->FloodFill(1, 1, nPieceColor, fsSurface);
StretchBlt(Image1->Canvas->Handle, X, Y, xx, yy, Bitmap1->Canvas->Handle, 0, 0, 2*xx, 2*yy, SRCCOPY);
}
void CreatePieces(CHESSGUI *ChsGUI, UINT32 Colors[], bool bMainBoard, TImage *Image1)
{
int x, y, x1, y1, xx, yy, x3, y3, px, py, nCnt;
int nPieceNr, nSquareColour, nPieceColour;
struct { int x1, y1, nPieceNr, nSquareColour, nPieceColour; } pp[] = {
{ 0, 0, 0, 1, 1 }, { 2, 0, 0, 1, 1 }, { 4, 0, 0, 1, 1 }, { 6, 0, 0, 1, 1 },
{ 1, 0, 0, 0, 0 }, { 3, 0, 0, 0, 0 }, { 5, 0, 0, 0, 0 }, { 7, 0, 0, 0, 0 },
{ 0, 1, 1, 0, 0 }, { 0, 2, 1, 1, 0 }, { 0, 3, 1, 0, 1 }, { 0, 4, 1, 1, 1 },
{ 1, 1, 2, 1, 0 }, { 1, 2, 2, 0, 0 }, { 1, 3, 2, 1, 1 }, { 1, 4, 2, 0, 1 },
{ 2, 1, 3, 0, 0 }, { 2, 2, 3, 1, 0 }, { 2, 3, 3, 0, 1 }, { 2, 4, 3, 1, 1 },
{ 3, 1, 4, 1, 0 }, { 3, 2, 4, 0, 0 }, { 3, 3, 4, 1, 1 }, { 3, 4, 4, 0, 1 },
{ 4, 1, 5, 0, 0 }, { 4, 2, 5, 1, 0 }, { 4, 3, 5, 0, 1 }, { 4, 4, 5, 1, 1 },
{ 5, 1, 6, 1, 0 }, { 5, 2, 6, 0, 0 }, { 5, 3, 6, 1, 1 }, { 5, 4, 6, 0, 1 },
{ 0, 5, 0, 0, 1 }, { 2, 5, 0, 0, 1 }, { 4, 5, 0, 0, 1 }, { 6, 5, 0, 0, 1 },
{ 1, 5, 0, 1, 0 }, { 3, 5, 0, 1, 0 }, { 5, 5, 0, 1, 0 }, { 7, 5, 0, 1, 0 },
{ 0, 6, 0, 1, 1 }, { 2, 6, 0, 1, 1 }, { 4, 6, 0, 1, 1 }, { 6, 6, 0, 1, 1 },
{ 1, 6, 0, 0, 0 }, { 3, 6, 0, 0, 0 }, { 5, 6, 0, 0, 0 }, { 7, 6, 0, 0, 0 }
};
Graphics::TBitmap *Bitmap1;
char FontName[32];
//
Bitmap1 = new Graphics::TBitmap();
xx = yy = Image1->Width/8;
strcpy(FontName, "Chess Merida"); // strcpy(FontName, "Chess Cases");
Image1->AutoSize = false; Image1->Stretch = true;
Image1->Canvas->Brush->Color = clBtnFace;
Image1->Canvas->FillRect(Image1->ClientRect);
nCnt = (sizeof(pp)/sizeof(pp[0]));
for (int i=0; i < nCnt; i++) {
DrawChessPiece(ChsGUI, Colors, Bitmap1, pp[i].x1*xx, pp[i].y1*yy, xx, yy,
pp[i].nPieceNr, pp[i].nSquareColour, pp[i].nPieceColour, Image1, FontName, bMainBoard);
}
//
Image1->Repaint(); Image1->Update();
delete Bitmap1;
}
mgemuh[@]yahoo{.}com