Advertisement
Momir

ČAH v0.1.2

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