|
5 | 5 | #include "ansi_escapes.h" |
6 | 6 | #include "lig 4.h" |
7 | 7 |
|
8 | | -#ifdef _WIN32 |
9 | | -#define windows |
10 | | -#include <Windows.h> |
11 | | -#include <Wincon.h> |
12 | | -#include <ConsoleApi2.h> |
13 | | - |
14 | 8 | extern void setupConsole(void); |
15 | 9 | extern void restoreConsoleMode(void); |
16 | 10 | extern void restoreConsole(void); |
17 | 11 |
|
18 | | -#endif //define to just compile windows code |
19 | | - |
20 | | -#ifdef __APPLE__ |
21 | | -#include "TargetConditionals.h" |
22 | | -#if TARGET_OS_SIMULATOR |
23 | | -# pragma message("You're compiling in the Xcode (OS_SIMULATOR), some terminal interaction may not work\n"); |
24 | | -#elif TARGET_OS_IPHONE |
25 | | -# pragma message("You're compiling in the iPhone, some terminal interaction may not work\n"); |
26 | | -#elif TARGET_OS_MAC |
27 | | -# pragma message("You're compiling in the Mac OS X, some terminal interaction may not work\n"); |
28 | | -#else |
29 | | -# pragma message("You're compiling in a Unknown Apple platform, some terminal interaction may not work") |
30 | | -#endif |
31 | | -# pragma message("If you run into problems, cut the #define linux from the code under the __APPLE__ definition\n"); |
32 | | -#define linux |
33 | | -#include <sys/ioctl.h> |
34 | | -#include <unistd.h> |
35 | | -#endif // Define linux headers on apple devices. No guarantee of work. |
36 | | - |
37 | | -#ifndef __linux__ |
38 | | -#ifndef __APPLE__ |
39 | | -#ifndef _WIN32 |
40 | | - |
41 | | - |
42 | | - |
43 | | -#define unknonwOS |
44 | | -#define linux |
45 | | -# pragma message("Compiling in a Unknown system (or even on UNIX based system)\n") |
46 | | -# pragma message("Using some linux terminal interation. So some terminal interations and ANSI escapes may not work\n") |
47 | | -# pragma message("If you run into problems, cut the #define linux from the code under the unknowSO definition\n") |
48 | | -#endif // !_WIN32 |
49 | | - |
50 | | -#endif // !__APPLE__ |
51 | | - |
52 | | -#endif // Define linux headers on other OS's. No guarantee of work. |
53 | | - |
54 | | -#ifdef __linux__ |
55 | | -#ifdef linux |
56 | | -#pragma message("You're compiling with Linux support. Make sure to activate the code and headers defined to run at linux, as it's marked as comment") |
57 | | -#endif |
58 | | -#infdef linux |
59 | | -#define linux |
60 | | -#pragma message("You're compiling on Linux. Make sure to activate the code defined and headers to run at linux, as it's marked as comment") |
61 | | -//#include <sys/ioctl.h> |
62 | | -//#include <unistd.h> |
63 | | -#endif //define to just compile linux code |
64 | | - |
65 | 12 | extern void supergridTied(char supergrid[37][98]); |
66 | 13 | extern bool minimaxTie(int grid[6][7], int nextplayer); |
67 | 14 | extern Move minimaxPlay(int grid[6][7], int nextplayer); |
@@ -361,72 +308,30 @@ int main(int argc, char** argv) |
361 | 308 | Move playerMove; |
362 | 309 | Win winVerifyerReturn; |
363 | 310 | Move winCoordinates[4]; |
364 | | - bool isMaximazed = false; |
365 | | - bool legacyMode = true; |
366 | | - |
367 | 311 | //used to freeze the program instead of getchar |
368 | 312 | char trashCan[10]; |
369 | 313 |
|
370 | | - setupConsole(); |
371 | | - setBackgroundColorRGB(20, 20, 20); |
372 | | - restoreConsole(); |
373 | | - printf("Você vai precisar maximizar a janela do console para poder jogar\n"); |
374 | | - |
375 | | - // Windows mode |
376 | | - #ifdef windows |
377 | | - while (1) { |
378 | | - CONSOLE_SCREEN_BUFFER_INFO csbi; |
379 | | - int columns, rows; |
380 | | - |
381 | | - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); |
382 | | - columns = csbi.srWindow.Right - csbi.srWindow.Left + 1; |
383 | | - rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; |
384 | | - |
385 | | - if (rows < 41 || columns < 101) |
386 | | - { |
387 | | - printf("A janela não está no tamanha adequado! Tente aumenta-la ou maximizá-la\n"); |
388 | | - printf("Caso você não consiga aumentar mais digite \'n\'\n"); |
389 | | - fgets(trashCan, 5, stdin); |
390 | | - if (trashCan[0] == 'n') |
391 | | - { |
392 | | - printf("Ok. Rodando no modo legacy\n"); |
393 | | - legacyMode = true; |
394 | | - break; |
395 | | - } |
396 | | - } |
397 | | - |
398 | | - if (rows > 40 && columns > 100) |
399 | | - { |
400 | | - legacyMode = false; |
401 | | - break; |
402 | | - } |
403 | | - } |
404 | | - #endif |
405 | | - |
406 | | - // Linux mode |
407 | | - /*#ifdef linux |
408 | | - while (1) |
409 | 314 | { |
410 | | - struct winsize w; |
411 | | - ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); |
| 315 | + int windowSize[2]; |
| 316 | + setupConsole(); |
| 317 | + moveTo(999, 999); |
| 318 | + getCursorPosition(&windowSize[0], &windowSize[1]); |
| 319 | + moveTo(0, 0); |
412 | 320 |
|
413 | | - if (w.ws_row < 41 && w.ws_col < 101) |
| 321 | + while (windowSize[0] < 41 || windowSize[1] < 101) |
414 | 322 | { |
415 | | - printf("A janela não está no tamanha adequado! Tente aumenta-la ou maximizá-la\n"); |
416 | | - printf("Caso você não consiga aumentar mais digite \'n\'"); |
417 | | - fgets(trashCan, 5, stdin); |
418 | | - if (trashCan[0] == 'n') |
419 | | - { |
420 | | - printf("Ok. Rodando no modo legacy"); |
421 | | - legacyMode = true; |
422 | | - break; |
423 | | - } |
| 323 | + puts("You'll need to expand the windows to play"); |
| 324 | + moveTo(999, 999); |
| 325 | + getCursorPosition(&windowSize[0], &windowSize[1]); |
| 326 | + moveTo(0, 0); |
424 | 327 | } |
425 | | -
|
426 | | - if (w.ws_row > 40 && w.ws_col > 100) |
427 | | - break; |
| 328 | + clearScreenToBottom(); |
| 329 | + restoreConsoleMode(); |
428 | 330 | } |
429 | | - #endif*/ |
| 331 | + |
| 332 | + setupConsole(); |
| 333 | + setBackgroundColorRGB(20, 20, 20); |
| 334 | + restoreConsole(); |
430 | 335 |
|
431 | 336 | printf("Gostaria de jogar o modo: 1- Singleplayer ou 2- Multiplayer\n"); |
432 | 337 | fgets(trashCan, 5, stdin); |
@@ -456,16 +361,6 @@ int main(int argc, char** argv) |
456 | 361 | setupConsole(); |
457 | 362 | setBackgroundColorRGB(20, 20, 20); |
458 | 363 |
|
459 | | - if (legacyMode == false) |
460 | | - { |
461 | | - moveTo(0, 0); |
462 | | - clearScreenToBottom(); |
463 | | - moveTo(0, 0); |
464 | | - } |
465 | | - |
466 | | - else |
467 | | - clearScreen(); |
468 | | - |
469 | 364 | supergridPrinter(supergrid, grid, winCoordinates); |
470 | 365 | restoreConsoleMode(); |
471 | 366 | printf("Jogue jogador %i\n", player); |
|
0 commit comments