@@ -8,44 +8,51 @@ void draw_main_screen() {
88 int rows , cols ;
99 getmaxyx (stdscr , rows , cols );
1010
11- // 화면 중앙 계산
11+ // 더 큰 메인 윈도우 크기
1212 int main_height = 25 ;
1313 int main_width = 80 ;
1414 int start_y = (rows - main_height ) / 2 ;
1515 int start_x = (cols - main_width ) / 2 ;
1616
17- // stdscr에 직접 그리기
17+ WINDOW * main_win = newwin (main_height , main_width , start_y , start_x );
18+ werase (main_win ); // 윈도우만 지우기
19+
1820 // ASCII 아트 제목
19- attron ( A_BOLD );
20- mvprintw ( start_y + 2 , start_x + (main_width - 51 ) / 2 , " ██████╗██╗ ██╗███████╗███████╗███████╗ ██████╗" );
21- mvprintw ( start_y + 3 , start_x + (main_width - 51 ) / 2 , "██╔════╝██║ ██║██╔════╝██╔════╝██╔════╝ ██╔═══╝" );
22- mvprintw ( start_y + 4 , start_x + (main_width - 51 ) / 2 , "██║ ███████║█████╗ ███████╗███████╗ ██║ " );
23- mvprintw ( start_y + 5 , start_x + (main_width - 51 ) / 2 , "██║ ██╔══██║██╔══╝ ╚════██║╚════██║ ██║ " );
24- mvprintw ( start_y + 6 , start_x + (main_width - 51 ) / 2 , "╚██████╗██║ ██║███████╗███████║███████║██╗╚██████╗" );
25- mvprintw ( start_y + 7 , start_x + (main_width - 51 ) / 2 , " ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═════╝" );
26- attroff ( A_BOLD );
21+ wattron ( main_win , A_BOLD );
22+ mvwprintw ( main_win , 2 , (main_width - 51 ) / 2 , " ██████╗██╗ ██╗███████╗███████╗███████╗ ██████╗" );
23+ mvwprintw ( main_win , 3 , (main_width - 51 ) / 2 , "██╔════╝██║ ██║██╔════╝██╔════╝██╔════╝ ██╔═══╝" );
24+ mvwprintw ( main_win , 4 , (main_width - 51 ) / 2 , "██║ ███████║█████╗ ███████╗███████╗ ██║ " );
25+ mvwprintw ( main_win , 5 , (main_width - 51 ) / 2 , "██║ ██╔══██║██╔══╝ ╚════██║╚════██║ ██║ " );
26+ mvwprintw ( main_win , 6 , (main_width - 51 ) / 2 , "╚██████╗██║ ██║███████╗███████║███████║██╗╚██████╗" );
27+ mvwprintw ( main_win , 7 , (main_width - 51 ) / 2 , " ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝╚═╝ ╚═════╝" );
28+ wattroff ( main_win , A_BOLD );
2729
2830 // 부제목
29- attron ( A_ITALIC );
30- mvprintw ( start_y + 9 , start_x + (main_width - 16 ) / 2 , "MULTIPLAYER GAME" );
31- attroff ( A_ITALIC );
31+ wattron ( main_win , A_ITALIC );
32+ mvwprintw ( main_win , 9 , (main_width - 16 ) / 2 , "MULTIPLAYER GAME" );
33+ wattroff ( main_win , A_ITALIC );
3234
3335 // 장식선
34- attron ( COLOR_PAIR (COLOR_PAIR_BORDER ));
35- mvprintw ( start_y + 11 , start_x + (main_width - 60 ) / 2 , "═══════════════════════════════════════════════════════════" );
36- attroff ( COLOR_PAIR (COLOR_PAIR_BORDER ));
36+ wattron ( main_win , COLOR_PAIR (COLOR_PAIR_BORDER ));
37+ mvwprintw ( main_win , 11 , (main_width - 60 ) / 2 , "═══════════════════════════════════════════════════════════" );
38+ wattroff ( main_win , COLOR_PAIR (COLOR_PAIR_BORDER ));
3739
3840 // 메뉴 항목들
39- attron ( A_BOLD );
40- mvprintw ( start_y + 14 , start_x + (main_width - 18 ) / 2 , "1. Start New Game" );
41- mvprintw ( start_y + 16 , start_x + (main_width - 18 ) / 2 , "2. Replay " );
42- mvprintw ( start_y + 18 , start_x + (main_width - 18 ) / 2 , "3. Exit " );
43- attroff ( A_BOLD );
41+ wattron ( main_win , A_BOLD );
42+ mvwprintw ( main_win , 14 , (main_width - 18 ) / 2 , "1. Start New Game" );
43+ mvwprintw ( main_win , 16 , (main_width - 18 ) / 2 , "2. Replay " );
44+ mvwprintw ( main_win , 18 , (main_width - 18 ) / 2 , "3. Exit " );
45+ wattroff ( main_win , A_BOLD );
4446
4547 // 하단 장식
46- attron (COLOR_PAIR (COLOR_PAIR_BORDER ));
47- mvprintw (start_y + 21 , start_x + (main_width - 60 ) / 2 , "═══════════════════════════════════════════════════════════" );
48- attroff (COLOR_PAIR (COLOR_PAIR_BORDER ));
48+ wattron (main_win , COLOR_PAIR (COLOR_PAIR_BORDER ));
49+ mvwprintw (main_win , 21 , (main_width - 60 ) / 2 , "═══════════════════════════════════════════════════════════" );
50+ wattroff (main_win , COLOR_PAIR (COLOR_PAIR_BORDER ));
51+
52+ // 윈도우 내용을 stdscr에 복사한 후 윈도우 삭제
53+ // 이렇게 하면 delwin() 후에도 내용이 stdscr에 남아있음
54+ copywin (main_win , stdscr , 0 , 0 , start_y , start_x , start_y + main_height - 1 , start_x + main_width - 1 , 0 );
55+ delwin (main_win ); // 윈도우 메모리 해제
4956
5057 // 연결 상태 표시
5158 draw_connection_status ();
0 commit comments