-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
169 lines (131 loc) · 3.89 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include"system.h"
#include"interactive.h"
#include"verbose.h"
#include"game.h"
int main(void){ // ajustar responsividade
extern Point *ps;
setlocale(LC_ALL, "portuguese");
//start lib ncurses
initscr();
noecho(); // nao exibe o valor da tecla apertada
cbreak(); // encerrar com ctrl+c
if(!has_colors()){
endwin();
printf("Error: Terminal nao suporta cores\n");
return 1;
}
start_color();
/*
* COLOR_PAIR(N)
* COLOR_BLACK 0
* COLOR_RED 1
* COLOR_GREEN 2
* COLOR_YELLOW 3
* COLOR_BLUE 4
* COLOR_MAGENTA 5
* COLOR_CYAN 6
* COLOR_WHITE 7
*/
// paleta
init_pair(1, COLOR_GREEN, COLOR_BLACK);
init_pair(2, COLOR_MAGENTA, COLOR_BLACK);
init_pair(3, COLOR_WHITE, COLOR_BLACK);
init_pair(4, COLOR_YELLOW, COLOR_BLACK);
ps = NULL;
int height, width, start_x, start_y, xmax, ymax;
// int x, y, xbeg, ybeg, xmax, ymax;
// getyx(stdscr, y, x);
// getbegyx(stdscr, ybeg, xbeg);
getmaxyx(stdscr, ymax, xmax);
if(ymax <= 100 && xmax <= 100){
endwin();
printf("terminal muito pequeno, máxime seu terminal\n");
return 1;
}
height = 20;
width = 150;
start_x = 6;
start_y = 8;
WINDOW *win_menu = newwin(6, xmax-12, ymax-8, 5);
WINDOW *win_content = newwin(height, width, start_y, start_x);
int tabuleiro[][10] = {
//0 1 2 3 4 5 6 7 8 9
{ 0, 0,-1,-1, 0, 0, 0, 0, 0, 0}, // 0
{ 0,-1, 0, 0, 0,-1, 0,-1,-1,-1}, // 1
{ 0, 0, 0,-1, 0, 0, 0,-1, 0,-1}, // 2
{-1,-1, 0,-1, 0,-1, 0, 0, 0, 0}, // 3
{-1, 0, 0, 0,-1, 0, 0, 0,-1, 0}, // 4
{ 0, 0, 0,-1,-1,-1,-1, 0, 0,-1}, // 5
{-1, 0, 0, 0, 0, 0, 0, 0,-1,-1}, // 6
{ 0, 0,-1, 0, 0,-1, 0, 0, 0, 0}, // 7
{ 0, 0, 0,-1,-1,-1, 0, 0,-1, 0}, // 8
{-1,-1, 0, 0, 0, 0,-1, 0, 0, 0} // 9
};
char *choices[] = {"1 - Interativo", "2 - Verboso", "3 - Game (beta)"};
keypad(win_menu, 1);
/*
* A_NORMAL
* A_STANDOUT
* A_REVERSE
* A_BLINK
* A_DIM
* A_BOLD
* A_PROTECT
* A_INVIS
* A_ALTCHARSET
* A_CHARTEXT
*/
refresh();
attron(A_REVERSE);
printw(" ctrl+c para sair ");
attroff(A_REVERSE);
attron(COLOR_PAIR(2));
welcome(xmax/2 - 45, ymax/2 - 10);
attroff(COLOR_PAIR(2));
// MENU
box(win_menu, 0, 0);
refresh();
wrefresh(win_menu);
int op = menu(win_menu, choices);
// END MENU
switch(op){
case 0 : // MODO INTERATIVO
mvprintw(ymax/2 - 20, xmax/2 - 10, "Modo Interativo");
refresh();
box(win_content, 0, 0);
wrefresh(win_content);
searchPath(win_content, tabuleiro, 10, 10);
wprintw(win_content, "\n");
Print(win_content, ps);
wrefresh(win_content);
break;
case 1: // MODO VERBOSO
mvprintw(ymax/2 - 20, xmax/2 - 10, "Modo Verboso");
refresh();
box(win_content, 0, 0);
wrefresh(win_content);
searchPathVerbose(win_content, tabuleiro, 10, 10);
wprintw(win_content, "\n");
Print(win_content,ps);
wrefresh(win_content);
break;
case 2: // MODO GAME
mvprintw(ymax/2 - 20, xmax/2 - 10, "Modo Game");
refresh();
box(win_content, 0, 0);
wrefresh(win_content);
gameTab(win_content, tabuleiro);
break;
default:
mvprintw(ymax/2 - 5, xmax/2 - 5, "Valor Incorreto");
}
attron(A_BLINK);
attron(A_BOLD);
mvprintw(ymax-3, xmax-45, " Created by: Rubens Santos <z1ron> ");
refresh();
attroff(A_BOLD);
attroff(A_BLINK);
getch();
endwin(); // finish lib ncurses
return 0;
}