<commit_before>#include <iostream>
#include <iomanip>
#include <vector>
#include <stdio.h>
#include <conio.h>
#include <cstdlib>
#include <string>
#include <time.h>
#include <algorithm>
#include <fstream>
#include <Windows.h>

#include "ConsoleGaming.h"
#include "Menu.h"

using namespace std;

HANDLE consoleHandle;

typedef vector<GameObject>::iterator randomAccess_iterator;
typedef vector<GameObject>::const_iterator const_iterator;
 
// Window constants
const int WindowWidth = 15;
const int WindowHeight = 25;
// Shape
const int ShapeSpeed = 1;
const char ShapeSymbol = static_cast<char>(219);
const char FloorSymbol = '^';
const char WallSymbol = '|';
const char GhostSymbol = static_cast<char>(177);
// Game variables
unsigned long sleepDuration = 250;
// No need to reference the active shape, since it will always be the last shape in the list
vector<vector<GameObject>> shapes;
vector<vector<GameObject>> last2shapes;
bool fullrefresh = true;
bool soundplay;
int score = 0;
 
void Draw();
 
int close(){
        exit(0);
}
 
void hidecursor()//kurzora e grozen
{
        consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
        CONSOLE_CURSOR_INFO info;
        info.dwSize = 100;
        info.bVisible = FALSE;
        SetConsoleCursorInfo(consoleHandle, &info);
}
 
void nobuttons(){
 
        RECT desktop;
        const HWND hDesktop = GetDesktopWindow();//  Get a handle to the desktop window
        GetWindowRect(hDesktop, &desktop); // Get the size of screen to the variable desktop
 
        LONG style;
        HWND ConsoleWindow;
        ConsoleWindow = GetConsoleWindow();
 
        style = GetWindowLong(ConsoleWindow, GWL_STYLE);
        style &= ~(WS_MINIMIZEBOX);
        SetWindowLongPtr(ConsoleWindow, GWL_STYLE, style);
 
        SetWindowPos(ConsoleWindow, NULL, desktop.right / 2 - 128, desktop.bottom / 2 - 260, 0, 0, SWP_FRAMECHANGED |
                SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 
}
 
void adjust_window(){
        //hide cursor
        hidecursor();
        //no minimize and changes the window's postion
        nobuttons();
        //set up the window
        SMALL_RECT rect = { 0, 0, 30, 25 };
        SetConsoleWindowInfo(consoleHandle, TRUE, &rect);
 
        //remove scroll
        CONSOLE_SCREEN_BUFFER_INFO info;
        GetConsoleScreenBufferInfo(consoleHandle, &info);
        COORD new_size =
        {
                info.srWindow.Right - info.srWindow.Left + 1,
                info.srWindow.Bottom - info.srWindow.Top + 1
        };
        SetConsoleScreenBufferSize(consoleHandle, new_size);
}
 
void core();//magiq koqto kazva na kompilotra 4e core sushtestvuva
 
void presspause(){//on LB Mouse up rele
        while (true){
                Sleep(1);//namalq cpu usage s 25% procenta lelz
                if (GetAsyncKeyState(1) == 0){
                        break;
                }
        }
}
 
void Menu(){//start menu
 
 
        POINT pt;//za mouse coord
        HWND consoleWindow = GetConsoleWindow();
        consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
 
 
        //4ertaq header
 
 
        //4ertaq start menu
        Rect start, instr, back, exit, hed;
        start.set_values(30, 70, 200, 100, L"Start");
        hed.set_values(0, 0, 250, 60, L"");//delete header
        start.draw();
        instr.set_values(30, 130, 200, 160, L"Instructions");
        instr.draw();
        exit.set_values(30, 190, 200, 220, L"Exit");
        exit.draw();
        HDC hdc = GetDC(GetConsoleWindow());//magiq koqto mi pravi teskta visible
        header2();//menu.h zalgavie
 
        //sledq za natiskane na buton
        while (true){
                Sleep(1);//namalq cpu usage s 25% procenta
                GetCursorPos(&pt);//kazva na kursora da dava coordinati na mishakta
                ScreenToClient(consoleWindow, &pt);//kazva da gi konveritra s an4alo 0,0 goren lqv ugul na kozolata
 
                if (GetAsyncKeyState(1) && pt.x>start.x1 && pt.x<start.x2&&pt.y<start.y2&&pt.y>start.y1){//lmb down  ...
                        start.invert();
                        presspause();
                        start.drawblack();//triq butonite
                        instr.drawblack();
                        exit.drawblack();
                        hed.drawblack();
                        break;//sushtkod
                }
 
                if (GetAsyncKeyState(1) && pt.x>exit.x1 && pt.x<exit.x2&&pt.y<exit.y2&&pt.y>exit.y1){//lmb down  ...
                        exit.invert();
                        presspause();
                        close();
                }
 
                if (GetAsyncKeyState(1) && pt.x>instr.x1 && pt.x<instr.x2&&pt.y<instr.y2&&pt.y>instr.y1){//lmb down  ...
                        instr.invert();
                        presspause();
                        instr.drawblack();
                        start.drawblack();
                        exit.drawblack();
                        SetConsoleCursorPosition(consoleHandle, { 9, 8 });//za pritnvane posredata
 
 
                        cout << "Controls:" << endl;
                        SetConsoleCursorPosition(consoleHandle, { 9, 9 });
                        cout << "Use A and D to move." << endl;
                        SetConsoleCursorPosition(consoleHandle, { 9, 10 });
                       	cout << "Use S to drop." << endl;
                       	SetConsoleCursorPosition(consoleHandle, { 9, 11 });
                       	cout << "Use SPACEBAR to rotate." << endl;
                       	SetConsoleCursorPosition(consoleHandle, { 9, 13 });
                       	cout << " M - Toggle Sound"<< endl;
                        back.set_values(150, 170, 200, 190, L"Back");
                        back.draw();
                        HDC hdc = GetDC(GetConsoleWindow());//magiq
 
                        while (true){
                                Sleep(1);//namalq cpu usage s 25% procenta lelz
                                GetCursorPos(&pt);
                                ScreenToClient(consoleWindow, &pt);
                                if (GetAsyncKeyState(1) && pt.x>back.x1 && pt.x < back.x2&&pt.y<back.y2&&pt.y>back.y1){//lmb down  ...
                                        back.invert();
                                        presspause();
                                        system("cls");
                                        back.drawblack();
                                        core();
                                        break;//shano magiq
                                }
                        }
 
                }
        }
}
 
void drawPause(){
        Rect pause, line1, line2;//golqmo zeleno kvadr s 2 4erni ivici
        pause.set_values(202, 10, 218, 30, L"");
        pause.draw();
        line1.set_values(206, 14, 208, 26, L"");
        line1.drawblack();<commit_msg>Update Tetris.cpp<commit_after>#include <iostream>
#include <iomanip>
#include <vector>
#include <stdio.h>
#include <conio.h>
#include <cstdlib>
#include <string>
#include <time.h>
#include <algorithm>
#include <fstream>
#include <Windows.h>

#include "ConsoleGaming.h"
#include "Menu.h"

using namespace std;

HANDLE consoleHandle;

typedef vector<GameObject>::iterator randomAccess_iterator;
typedef vector<GameObject>::const_iterator const_iterator;
 
// Window constants
const int WindowWidth = 15;
const int WindowHeight = 25;
// Shape
const int ShapeSpeed = 1;
const char ShapeSymbol = static_cast<char>(219);
const char FloorSymbol = '^';
const char WallSymbol = '|';
const char GhostSymbol = static_cast<char>(177);
// Game variables
unsigned long sleepDuration = 250;
// No need to reference the active shape, since it will always be the last shape in the list
vector<vector<GameObject>> shapes;
vector<vector<GameObject>> last2shapes;
bool fullrefresh = true;
bool soundplay;
int score = 0;
 
void Draw();
 
int close(){
        exit(0);
}
 
void hidecursor()//kurzora e grozen
{
        consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
        CONSOLE_CURSOR_INFO info;
        info.dwSize = 100;
        info.bVisible = FALSE;
        SetConsoleCursorInfo(consoleHandle, &info);
}
 
void nobuttons(){
 
        RECT desktop;
        const HWND hDesktop = GetDesktopWindow();//  Get a handle to the desktop window
        GetWindowRect(hDesktop, &desktop); // Get the size of screen to the variable desktop
 
        LONG style;
        HWND ConsoleWindow;
        ConsoleWindow = GetConsoleWindow();
 
        style = GetWindowLong(ConsoleWindow, GWL_STYLE);
        style &= ~(WS_MINIMIZEBOX);
        SetWindowLongPtr(ConsoleWindow, GWL_STYLE, style);
 
        SetWindowPos(ConsoleWindow, NULL, desktop.right / 2 - 128, desktop.bottom / 2 - 260, 0, 0, SWP_FRAMECHANGED |
                SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
 
}
 
void adjust_window(){
        //hide cursor
        hidecursor();
        //no minimize and changes the window's postion
        nobuttons();
        //set up the window
        SMALL_RECT rect = { 0, 0, 30, 25 };
        SetConsoleWindowInfo(consoleHandle, TRUE, &rect);
 
        //remove scroll
        CONSOLE_SCREEN_BUFFER_INFO info;
        GetConsoleScreenBufferInfo(consoleHandle, &info);
        COORD new_size =
        {
                info.srWindow.Right - info.srWindow.Left + 1,
                info.srWindow.Bottom - info.srWindow.Top + 1
        };
        SetConsoleScreenBufferSize(consoleHandle, new_size);
}
 
void core();//magiq koqto kazva na kompilotra 4e core sushtestvuva
 
void presspause(){//on LB Mouse up rele
        while (true){
                Sleep(1);//namalq cpu usage s 25% procenta lelz
                if (GetAsyncKeyState(1) == 0){
                        break;
                }
        }
}
 
void Menu(){//start menu
 
 
        POINT pt;//za mouse coord
        HWND consoleWindow = GetConsoleWindow();
        consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
 
 
        //4ertaq header
 
 
        //4ertaq start menu
        Rect start, instr, back, exit, hed;
        start.set_values(30, 70, 200, 100, L"Start");
        hed.set_values(0, 0, 250, 60, L"");//delete header
        start.draw();
        instr.set_values(30, 130, 200, 160, L"Instructions");
        instr.draw();
        exit.set_values(30, 190, 200, 220, L"Exit");
        exit.draw();
        HDC hdc = GetDC(GetConsoleWindow());//magiq koqto mi pravi teskta visible
        header2();//menu.h zalgavie
 
        //sledq za natiskane na buton
        while (true){
                Sleep(1);//namalq cpu usage s 25% procenta
                GetCursorPos(&pt);//kazva na kursora da dava coordinati na mishakta
                ScreenToClient(consoleWindow, &pt);//kazva da gi konveritra s an4alo 0,0 goren lqv ugul na kozolata
 
                if (GetAsyncKeyState(1) && pt.x>start.x1 && pt.x<start.x2&&pt.y<start.y2&&pt.y>start.y1){//lmb down  ...
                        start.invert();
                        presspause();
                        start.drawblack();//triq butonite
                        instr.drawblack();
                        exit.drawblack();
                        hed.drawblack();
                        break;//sushtkod
                }
 
                if (GetAsyncKeyState(1) && pt.x>exit.x1 && pt.x<exit.x2&&pt.y<exit.y2&&pt.y>exit.y1){//lmb down  ...
                        exit.invert();
                        presspause();
                        close();
                }
 
                if (GetAsyncKeyState(1) && pt.x>instr.x1 && pt.x<instr.x2&&pt.y<instr.y2&&pt.y>instr.y1){//lmb down  ...
                        instr.invert();
                        presspause();
                        instr.drawblack();
                        start.drawblack();
                        exit.drawblack();
                        SetConsoleCursorPosition(consoleHandle, { 9, 5 });//za pritnvane posredata
 
 
                        cout << "Controls:" << endl;
                        SetConsoleCursorPosition(consoleHandle, { 5, 8 });
                        cout << "Use A and D to move." << endl;
                        SetConsoleCursorPosition(consoleHandle, { 5, 9 });
                        cout << "Use S to drop." << endl;
                        SetConsoleCursorPosition(consoleHandle, { 5, 10 });
                        cout << "Use SPACEBAR to rotate." << endl;
                        SetConsoleCursorPosition(consoleHandle, { 5, 12 });
                        cout << " M - Toggle Sound" << endl;
                        back.set_values(150, 170, 200, 190, L"Back");
                        back.draw();
                        HDC hdc = GetDC(GetConsoleWindow());//magiq
 
                        while (true){
                                Sleep(1);//namalq cpu usage s 25% procenta lelz
                                GetCursorPos(&pt);
                                ScreenToClient(consoleWindow, &pt);
                                if (GetAsyncKeyState(1) && pt.x>back.x1 && pt.x < back.x2&&pt.y<back.y2&&pt.y>back.y1){//lmb down  ...
                                        back.invert();
                                        presspause();
                                        system("cls");
                                        back.drawblack();
                                        core();
                                        break;//shano magiq
                                }
                        }
 
                }
        }
}
 
void drawPause(){
        Rect pause, line1, line2;//golqmo zeleno kvadr s 2 4erni ivici
        pause.set_values(202, 10, 218, 30, L"");
        pause.draw();
        line1.set_values(206, 14, 208, 26, L"");
        line1.drawblack();
{'fraction_non_alphanumeric': 0.1127946127946128, 'fraction_numerical': 0.024227785097350314, 'mean_word_length': 1.598516546215291, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3548188', 'n_tokens_mistral': 4262, 'n_tokens_neox': 3755, 'n_words': 942}