Momir

ČAH v0.1.1

May 9th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.69 KB | None | 0 0
  1. #define _WIN32_WINNT 0x0600
  2. #define STRICT
  3. #include <dos.h>
  4. #include <dir.h>
  5. #include <iostream>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #include <io.h>
  10. #include <shlwapi.h>
  11. #include <fcntl.h>
  12. #include <unistd.h>
  13. #include <windows.h>
  14. #include <cwchar>
  15. #include <winreg.h>
  16. #include <Wincon.h>
  17. #define _O_U16TEXT  0x20000
  18. #define _O_U8TEXT   0x40000
  19. #define SVETLO 0
  20. #define TAMNO 1
  21. #define SIVO 2
  22. #define BELO 0
  23. #define CRNO 1
  24. #define NEUTRALNO 0
  25. #define IZABRANO 1
  26. #define NAPADNUTO 2
  27. #define TOP L"♜ "
  28. #define KONJ L"♞ "
  29. #define LOVAC L"♝ "
  30. #define KRALJICA L"♛ "
  31. #define KRALJ L"♚ "
  32. #define PIJUN L"♟ "
  33. #define PRAZNO L"  "
  34. #define TACKA L""  // ● ꞏ ⚫
  35. using namespace std;
  36.  
  37. typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX
  38. {
  39.     ULONG      cbSize;
  40.     COORD      dwSize;
  41.     COORD      dwCursorPosition;
  42.     WORD       wAttributes;
  43.     SMALL_RECT srWindow;
  44.     COORD      dwMaximumWindowSize;
  45.     WORD       wPopupAttributes;
  46.     BOOL       bFullscreenSupported;
  47.     COLORREF   ColorTable[16];
  48. } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
  49.  
  50. typedef struct _CONSOLE_FONT_INFOEX
  51. {
  52.     ULONG cbSize;
  53.     DWORD nFont;
  54.     COORD dwFontSize;
  55.     UINT  FontFamily;
  56.     UINT  FontWeight;
  57.     WCHAR FaceName[LF_FACESIZE];
  58. } CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
  59.  
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. BOOL WINAPI SetCurrentConsoleFontEx(HANDLE hConsoleOutput, BOOL bMaximumWindow, PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67.  
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71. BOOL WINAPI GetConsoleScreenBufferInfoEx(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75.  
  76. #ifdef __cplusplus
  77. extern "C" {
  78. #endif
  79. BOOL WINAPI SetConsoleScreenBufferInfoEx(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83.  
  84. void SakriKursor();
  85. void ObrisiEkran();
  86. void gotoxy(int x, int y);
  87. int UcitajKlik(int &x, int &y);
  88. void CentrirajKonzolu();
  89.  
  90. short boja = SVETLO;
  91.  
  92. typedef struct
  93. {
  94.     short bojaPolja;
  95.     short stanjePolja;
  96.     wchar_t figura[10];
  97.     short bojaFigure;
  98.  
  99. } Polje;
  100.  
  101. void PodesiVelicinu(int i);
  102. void PodesiKonzolu();
  103. void PodesiKonzolu2();
  104. void NapraviTablu(Polje tabla[8][8]);
  105. void OdstampajTablu(Polje tabla[8][8]);
  106.  
  107. void ObrisiKonzoluPodesavanja()
  108. {
  109.     RegDeleteKeyA(HKEY_CURRENT_USER, "Console\\C:_Program Files (x86)_CodeBlocks_cb_console_runner.exe");
  110.     RegDeleteKeyA(HKEY_CURRENT_USER, "Console\\");
  111.     RegDeleteKeyA(HKEY_CURRENT_USER, "Console");
  112. }
  113.  
  114. void OdstampajKonzolu()
  115. {
  116.     // gear 
  117.  
  118.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  119.     _setmode(_fileno(stdout), _O_U8TEXT);
  120.  
  121.     if(boja == SVETLO)
  122.         SetConsoleTextAttribute(console, 45);
  123.     else if(boja == TAMNO)
  124.         SetConsoleTextAttribute(console, 93);
  125.     else if(boja == SIVO)
  126.         SetConsoleTextAttribute(console, 141);
  127.  
  128.     wprintf(L""); // save
  129.  
  130.     if(boja == SVETLO)
  131.         SetConsoleTextAttribute(console, 46);
  132.     else if(boja == TAMNO)
  133.         SetConsoleTextAttribute(console, 94);
  134.     else if(boja == SIVO)
  135.         SetConsoleTextAttribute(console, 142);
  136.  
  137.     wprintf(L""); // open
  138.  
  139.     if(boja == SVETLO)
  140.         SetConsoleTextAttribute(console, 44);
  141.     else if(boja == TAMNO)
  142.         SetConsoleTextAttribute(console, 92);
  143.     else if(boja == SIVO)
  144.         SetConsoleTextAttribute(console, 140);
  145.  
  146.     wprintf(L""); // restart      
  147.  
  148.     if(boja == SVETLO)
  149.         SetConsoleTextAttribute(console, 36);
  150.     else if(boja == TAMNO)
  151.         SetConsoleTextAttribute(console, 87);
  152.     else if(boja == SIVO)
  153.         SetConsoleTextAttribute(console, 138);
  154.  
  155.     wprintf(L""); // color
  156.     wprintf(L""); // resize
  157.  
  158. //    if(boja == SVETLO)
  159. //        SetConsoleTextAttribute(console, 43);
  160. //    else if(boja == TAMNO)
  161. //        SetConsoleTextAttribute(console, 91);
  162. //    else if(boja == SIVO)
  163. //        SetConsoleTextAttribute(console, 139);
  164.  
  165.     wprintf(L""); // back
  166.     wprintf(L"                    "); // space
  167.  
  168.     if(boja == SVETLO)
  169.         SetConsoleTextAttribute(console, 47);
  170.     else if(boja == TAMNO)
  171.         SetConsoleTextAttribute(console, 95);
  172.     else if(boja == SIVO)
  173.         SetConsoleTextAttribute(console, 143);
  174.  
  175.     wprintf(L""); // info
  176.  
  177.     if(boja == SVETLO)
  178.         SetConsoleTextAttribute(console, 44);
  179.     else if(boja == TAMNO)
  180.         SetConsoleTextAttribute(console, 92);
  181.     else if(boja == SIVO)
  182.         SetConsoleTextAttribute(console, 140);
  183.  
  184.     wprintf(L"\n"); // quit
  185.  
  186.     if(boja == SVETLO)
  187.         SetConsoleTextAttribute(console, 36);
  188.     else if(boja == TAMNO)
  189.         SetConsoleTextAttribute(console, 87);
  190.     else if(boja == SIVO)
  191.         SetConsoleTextAttribute(console, 138);
  192.  
  193.     wprintf(L"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
  194.  
  195.     gotoxy(28, 2);
  196.     wprintf(L"┏━━━━━┓ ");
  197.     gotoxy(28, 3);
  198.     wprintf(L"┃     ┃ ");
  199.     gotoxy(28, 4);
  200.     wprintf(L"┃     ┃ ");
  201.     gotoxy(28, 5);
  202.     wprintf(L"┃     ┃ ");
  203.     gotoxy(28, 6);
  204.     wprintf(L"┃     ┃ ");
  205.     gotoxy(28, 7);
  206.     wprintf(L"┃     ┃ ");
  207.     gotoxy(28, 8);
  208.     wprintf(L"┃     ┃ ");
  209.     gotoxy(28, 9);
  210.     wprintf(L"┃     ┃ ");
  211.     gotoxy(28, 10);
  212.     wprintf(L"┃     ┃ ");
  213.     gotoxy(28, 11);
  214.     wprintf(L"┗━━━━━┛ ");
  215.  
  216.     gotoxy(0, 2);
  217.     wprintf(L"┏━━━━━┓ \n");
  218.     wprintf(L"┃     ┃ \n");
  219.     wprintf(L"┃     ┃ \n");
  220.     wprintf(L"┃     ┃ \n");
  221.     wprintf(L"┃     ┃ \n");
  222.     wprintf(L"┃     ┃ \n");
  223.     wprintf(L"┃     ┃ \n");
  224.     wprintf(L"┃     ┃ \n");
  225.     wprintf(L"┃     ┃ \n");
  226.     wprintf(L"┗━━━━━┛ \n");
  227.  
  228.     gotoxy(0, 12);
  229.     wprintf(L"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ \n");
  230.     wprintf(L"┃                                 ┃ \n");
  231.     wprintf(L"┃                                 ┃ \n");
  232.     wprintf(L"┃                                 ┃ \n");
  233.     wprintf(L"┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ");
  234.  
  235.     if(boja == SVETLO)
  236.         SetConsoleTextAttribute(console, 85);
  237.     else if(boja == TAMNO)
  238.         SetConsoleTextAttribute(console, 102);
  239.     else if(boja == SIVO)
  240.         SetConsoleTextAttribute(console, 153);
  241.  
  242.     gotoxy(2, 13);
  243.     wprintf(L"████████████████████████████████\n");
  244.     gotoxy(2, 14);
  245.     wprintf(L"████████████████████████████████\n");
  246.     gotoxy(2, 15);
  247.     wprintf(L"████████████████████████████████\n");
  248.  
  249.     gotoxy(2, 3);
  250.     wprintf(L"████\n");
  251.     gotoxy(2, 4);
  252.     wprintf(L"████\n");
  253.     gotoxy(2, 5);
  254.     wprintf(L"████\n");
  255.     gotoxy(2, 6);
  256.     wprintf(L"████\n");
  257.     gotoxy(2, 7);
  258.     wprintf(L"████\n");
  259.     gotoxy(2, 8);
  260.     wprintf(L"████\n");
  261.     gotoxy(2, 9);
  262.     wprintf(L"████\n");
  263.     gotoxy(2, 10);
  264.     wprintf(L"████\n");
  265.  
  266.     gotoxy(30, 3);
  267.     wprintf(L"████\n");
  268.     gotoxy(30, 4);
  269.     wprintf(L"████\n");
  270.     gotoxy(30, 5);
  271.     wprintf(L"████\n");
  272.     gotoxy(30, 6);
  273.     wprintf(L"████\n");
  274.     gotoxy(30, 7);
  275.     wprintf(L"████\n");
  276.     gotoxy(30, 8);
  277.     wprintf(L"████\n");
  278.     gotoxy(30, 9);
  279.     wprintf(L"████\n");
  280.     gotoxy(30, 10);
  281.     wprintf(L"████\n");
  282.  
  283.     if(boja == SVETLO)
  284.         SetConsoleTextAttribute(console, 68);
  285.     else if(boja == TAMNO)
  286.         SetConsoleTextAttribute(console, 119);
  287.     else if(boja == SIVO)
  288.         SetConsoleTextAttribute(console, 170);
  289.  
  290.     gotoxy(8, 2);
  291.     wprintf(L"████████████████████");
  292.     gotoxy(8, 3);
  293.     wprintf(L"██");
  294.     gotoxy(8, 4);
  295.     wprintf(L"██");
  296.     gotoxy(8, 5);
  297.     wprintf(L"██");
  298.     gotoxy(8, 6);
  299.     wprintf(L"██");
  300.     gotoxy(8, 7);
  301.     wprintf(L"██");
  302.     gotoxy(8, 8);
  303.     wprintf(L"██");
  304.     gotoxy(8, 9);
  305.     wprintf(L"██");
  306.     gotoxy(8, 10);
  307.     wprintf(L"██");
  308.     gotoxy(26, 3);
  309.     wprintf(L"██");
  310.     gotoxy(26, 4);
  311.     wprintf(L"██");
  312.     gotoxy(26, 5);
  313.     wprintf(L"██");
  314.     gotoxy(26, 6);
  315.     wprintf(L"██");
  316.     gotoxy(26, 7);
  317.     wprintf(L"██");
  318.     gotoxy(26, 8);
  319.     wprintf(L"██");
  320.     gotoxy(26, 9);
  321.     wprintf(L"██");
  322.     gotoxy(26, 10);
  323.     wprintf(L"██");
  324.     void PodesiKonzolu2();
  325.     gotoxy(8, 11);
  326.     wprintf(L"████████████████████");
  327.  
  328. }
  329.  
  330. int main()
  331. {
  332.     Polje tabla[8][8];
  333.     NapraviTablu(tabla);
  334.  
  335.     ObrisiKonzoluPodesavanja();
  336.     PodesiKonzolu();
  337.     CentrirajKonzolu();
  338.     PodesiKonzolu2();
  339.     OdstampajKonzolu();
  340.     OdstampajTablu(tabla);
  341.  
  342.  
  343. //    for(int i=1; i<50; i++)
  344. //    {
  345. //        PodesiVelicinu(i);
  346. //        Sleep(300);
  347. //    }
  348.  
  349.  
  350. //    int x, y;
  351. //    int i = 0, j = 0;
  352. //
  353. //
  354. //
  355. //
  356. //    while(1)
  357. //    {
  358. //        SakriKursor();
  359. //        //ObrisiEkran();
  360. //        UcitajKlik(x, y);
  361. ////        gotoxy(x,y);
  362. //        //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 238);
  363. ////        _setmode(_fileno(stdout), _O_U8TEXT);
  364. ////        wprintf(L"█");//}
  365. //        //system("cls");
  366. //
  367. //        gotoxy(3, 4);
  368. //        printf("1");
  369. //        gotoxy(8, 10);
  370. //        printf("2");
  371. //        gotoxy(12, 3);
  372. //        printf("3");
  373. //        gotoxy(17, 6);
  374. //        printf("4");
  375. //
  376. //        gotoxy(0, 0);
  377. //        printf("             ", x, y);
  378. //        gotoxy(0, 0);
  379. //        printf("%d , %d", x, y);  //}
  380. //        gotoxy(i, 1);
  381. //
  382. //        if(x == 3 && y == 4)
  383. //            printf("a");
  384. //
  385. //        if(x == 8 && y == 10)
  386. //            printf("b");
  387. //
  388. //        if(x == 12 && y == 3)
  389. //            printf("c");
  390. //
  391. //        if(x == 17 && y == 6)
  392. //            printf("d");
  393. //
  394. //        i++;
  395. //    }
  396.  
  397. //_setmode(_fileno(stdout), _O_U16TEXT);
  398. //wprintf(L"\x265B\x265B\x265B\x265B\n");
  399. //wprintf(L"    ");
  400.  
  401. //#ifdef _WIN32
  402. //    _setmode(_fileno(stdout), 0x00020000);
  403. //#else
  404. //    setlocale(LC_CTYPE, "");
  405. //#endif
  406. //    PrintTopRow(Black);
  407. //    PrintPawns(Black);
  408. //    fputws(L"\n\n\n\n", stdout);
  409. //    PrintPawns(White);
  410. //    PrintTopRow(White);
  411.  
  412.  
  413.     SakriKursor();
  414.     ObrisiKonzoluPodesavanja();
  415.     Sleep(999999999);
  416.  
  417.     return 0;
  418. }
  419.  
  420. void NapraviTablu(Polje tabla[8][8])
  421. {
  422.     for(int i = 0; i < 8; i++)
  423.         for(int j = 0; j < 8; j++)
  424.         {
  425.             tabla[i][j].stanjePolja = NEUTRALNO;
  426.  
  427.             if((i + j) % 2 == 0)
  428.                 tabla[i][j].bojaPolja = BELO;
  429.             else
  430.                 tabla[i][j].bojaPolja = CRNO;
  431.         }
  432.  
  433.     for(int i = 0; i < 2; i++)
  434.         for(int j = 0; j < 8; j++)
  435.         {
  436.             tabla[i][j].bojaFigure = CRNO;
  437.             tabla[i + 6][j].bojaFigure = BELO;
  438.         }
  439.  
  440.     for(int j = 0; j < 8; j++)
  441.     {
  442.         wcscpy(tabla[1][j].figura, PIJUN);
  443.         wcscpy(tabla[6][j].figura, PIJUN);
  444.     }
  445.  
  446.     wcscpy(tabla[0][0].figura, TOP);
  447.     wcscpy(tabla[0][7].figura, TOP);
  448.     wcscpy(tabla[7][0].figura, TOP);
  449.     wcscpy(tabla[7][7].figura, TOP);
  450.  
  451.     wcscpy(tabla[0][1].figura, KONJ);
  452.     wcscpy(tabla[0][6].figura, KONJ);
  453.     wcscpy(tabla[7][1].figura, KONJ);
  454.     wcscpy(tabla[7][6].figura, KONJ);
  455.  
  456.     wcscpy(tabla[0][2].figura, LOVAC);
  457.     wcscpy(tabla[0][5].figura, LOVAC);
  458.     wcscpy(tabla[7][2].figura, LOVAC);
  459.     wcscpy(tabla[7][5].figura, LOVAC);
  460.  
  461.     wcscpy(tabla[0][3].figura, KRALJICA);
  462.     wcscpy(tabla[7][3].figura, KRALJICA);
  463.  
  464.     wcscpy(tabla[0][4].figura, KRALJ);
  465.     wcscpy(tabla[7][4].figura, KRALJ);
  466.  
  467.     for(int i = 2; i < 6; i++)
  468.         for(int j = 0; j < 8; j++)
  469.         {
  470.             tabla[i][j].bojaFigure = BELO;
  471.             wcscpy(tabla[i][j].figura, PRAZNO);
  472.         }
  473. }
  474.  
  475. void SakriKursor()
  476. {
  477.     HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
  478.     CONSOLE_CURSOR_INFO info;
  479.     info.dwSize = 100;
  480.     info.bVisible = FALSE;
  481.     SetConsoleCursorInfo(consoleHandle, &info);
  482. }
  483.  
  484. void ObrisiEkran()
  485. {
  486.     HANDLE hStdOut;
  487.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  488.     DWORD count;
  489.     DWORD cellCount;
  490.     COORD homeCoords = {0, 0};
  491.  
  492.     hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  493.  
  494.     if (hStdOut == INVALID_HANDLE_VALUE)
  495.         return;
  496.  
  497.     GetConsoleScreenBufferInfo(hStdOut, &csbi);
  498.     cellCount = csbi.dwSize.X * csbi.dwSize.Y;
  499.  
  500.     FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count);
  501.     FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count);
  502.     SetConsoleCursorPosition(hStdOut, homeCoords);
  503. }
  504.  
  505. void gotoxy(int x, int y)
  506. {
  507.     COORD koordinate;
  508.     koordinate.X = x;
  509.     koordinate.Y = y;
  510.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), koordinate);
  511. }
  512.  
  513. int UcitajKlik(int &x, int &y)
  514. {
  515.     DWORD info;
  516.     INPUT_RECORD input;
  517.     HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
  518.     SetConsoleMode(in, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT);
  519.     ReadConsoleInput(in, &input, 1, &info);
  520.  
  521.     if(input.Event.MouseEvent.dwButtonState !=  0x0001)
  522.     {
  523. GOBACK:
  524.         ReadConsoleInput(in, &input, 1, &info);
  525.  
  526.         if(input.Event.MouseEvent.dwButtonState ==  0x0001)
  527.         {
  528.             x = input.Event.MouseEvent.dwMousePosition.X;
  529.             y = input.Event.MouseEvent.dwMousePosition.Y;
  530.         }
  531.         else
  532.             goto GOBACK;
  533.     }
  534.     else
  535.         UcitajKlik(x, y);
  536.  
  537.     return 0;
  538. }
  539.  
  540. void CentrirajKonzolu()
  541. {
  542.     RECT rectClient, rectWindow;
  543.     HWND hWnd = GetConsoleWindow();
  544.     GetClientRect(hWnd, &rectClient);
  545.     GetWindowRect(hWnd, &rectWindow);
  546.     int posx, posy;
  547.     posx = GetSystemMetrics(SM_CXSCREEN) / 2 - (rectWindow.right - rectWindow.left) / 2;
  548.     posy = GetSystemMetrics(SM_CYSCREEN) / 2 - (rectWindow.bottom - rectWindow.top) / 2;
  549.  
  550.     SetWindowPos(GetConsoleWindow(), HWND_TOP, posx, posy, 0, 0, SWP_NOSIZE);
  551. }
  552.  
  553. void PodesiKonzolu()
  554. {
  555.     HWND consoleWindow = GetConsoleWindow();
  556.     SetWindowLong(consoleWindow, GWL_STYLE, GetWindowLong(consoleWindow, GWL_STYLE) & ~WS_MAXIMIZEBOX & ~WS_SIZEBOX);
  557.  
  558.     SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),  ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS);
  559.     SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),  ENABLE_EXTENDED_FLAGS);
  560.  
  561.     _setmode(_fileno(stdout), _O_U8TEXT);
  562.     SetConsoleTitleW(L"ŠAH");
  563.     _setmode(_fileno(stdout), _O_TEXT);
  564.  
  565.     if(boja == SVETLO)
  566.         system("color 23");
  567.     else if(boja == TAMNO)
  568.         system("color 56");
  569.     else if(boja == SIVO)
  570.         system("color 89");
  571.  
  572.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  573.     info.cbSize = sizeof(info);
  574.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  575.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  576.     info.dwSize = {36, 19};
  577.     info.ColorTable[0] = RGB(242, 242, 242);
  578.     info.ColorTable[1] = RGB(10, 10, 10);
  579.     info.ColorTable[2] = RGB(198, 175, 141);
  580.     info.ColorTable[3] = RGB(114, 71, 56);
  581.     info.ColorTable[4] = RGB(50, 31, 26);
  582.     info.ColorTable[5] = RGB(132, 94, 73);
  583.     info.ColorTable[6] = RGB(73, 47, 37);
  584.     info.ColorTable[7] = RGB(22, 11, 4);
  585.     info.ColorTable[8] = RGB(158, 158, 158);
  586.     info.ColorTable[9] = RGB(102, 102, 102);
  587.     info.ColorTable[10] = RGB(43, 43, 43);
  588.     info.ColorTable[11] = RGB(0, 119, 65);
  589.     info.ColorTable[12] = RGB(126, 33, 35);
  590.     info.ColorTable[13] = RGB(10, 10, 130);
  591.     info.ColorTable[14] = RGB(240, 191, 40);
  592.     info.ColorTable[15] = RGB(255, 255, 255);
  593.  
  594.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  595.     PodesiVelicinu(29);
  596.     SakriKursor();
  597. }
  598.  
  599. void PodesiKonzolu2()
  600. {
  601.     _CONSOLE_SCREEN_BUFFER_INFOEX info;
  602.     info.cbSize = sizeof(info);
  603.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  604.     GetConsoleScreenBufferInfoEx(hConsole, &info);
  605.     info.dwSize = {36, 17};
  606.     SetConsoleScreenBufferInfoEx(hConsole, &info);
  607. }
  608.  
  609. void PodesiVelicinu(int i)
  610. {
  611.     CONSOLE_FONT_INFOEX cfi;
  612.     cfi.cbSize = sizeof(cfi);
  613.     cfi.nFont = 0;
  614.     cfi.dwFontSize.X = 0;
  615.     cfi.dwFontSize.Y = i;
  616.     cfi.FontFamily = TMPF_TRUETYPE;
  617.     cfi.FontWeight = FW_NORMAL;
  618.     std::wcscpy(cfi.FaceName, L"MS Gothic");
  619.     SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
  620. }
  621.  
  622. void OdstampajTablu(Polje tabla[8][8])
  623. {
  624.     HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
  625.     _setmode(_fileno(stdout), _O_U8TEXT);
  626.  
  627.     for(int i = 0; i < 8; i++)
  628.         for(int j = 0; j < 8; j++)
  629.         {
  630.             if(tabla[i][j].stanjePolja == IZABRANO && tabla[i][j].bojaFigure == CRNO)
  631.                 SetConsoleTextAttribute(console, 177);
  632.             else if(tabla[i][j].stanjePolja == IZABRANO && tabla[i][j].bojaFigure == BELO)
  633.                 SetConsoleTextAttribute(console, 176);
  634.             else if(tabla[i][j].stanjePolja == NAPADNUTO && tabla[i][j].bojaFigure == CRNO)
  635.                 SetConsoleTextAttribute(console, 193);
  636.             else if(tabla[i][j].stanjePolja == NAPADNUTO && tabla[i][j].bojaFigure == BELO)
  637.                 SetConsoleTextAttribute(console, 192);
  638.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == SVETLO && tabla[i][j].bojaPolja == BELO)
  639.                 SetConsoleTextAttribute(console, 32);
  640.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == SVETLO && tabla[i][j].bojaPolja == BELO)
  641.                 SetConsoleTextAttribute(console, 33);
  642.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == TAMNO && tabla[i][j].bojaPolja == BELO)
  643.                 SetConsoleTextAttribute(console, 80);
  644.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == TAMNO && tabla[i][j].bojaPolja == BELO)
  645.                 SetConsoleTextAttribute(console, 81);
  646.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == SIVO && tabla[i][j].bojaPolja == BELO)
  647.                 SetConsoleTextAttribute(console, 128);
  648.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == SIVO && tabla[i][j].bojaPolja == BELO)
  649.                 SetConsoleTextAttribute(console, 129);
  650.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == SVETLO && tabla[i][j].bojaPolja == CRNO)
  651.                 SetConsoleTextAttribute(console, 48);
  652.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == SVETLO && tabla[i][j].bojaPolja == CRNO)
  653.                 SetConsoleTextAttribute(console, 49);
  654.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == TAMNO && tabla[i][j].bojaPolja == CRNO)
  655.                 SetConsoleTextAttribute(console, 96);
  656.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == TAMNO && tabla[i][j].bojaPolja == CRNO)
  657.                 SetConsoleTextAttribute(console, 97);
  658.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == BELO && boja == SIVO && tabla[i][j].bojaPolja == CRNO)
  659.                 SetConsoleTextAttribute(console, 144);
  660.             else if(tabla[i][j].stanjePolja == NEUTRALNO && tabla[i][j].bojaFigure == CRNO && boja == SIVO && tabla[i][j].bojaPolja == CRNO)
  661.                 SetConsoleTextAttribute(console, 145);
  662.  
  663.             gotoxy(10 + j * 2, 3 + i);
  664.             wprintf(tabla[i][j].figura);
  665.         }
  666. }
Advertisement
Add Comment
Please, Sign In to add comment