Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TxtAdv/Main_Menu.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
110 lines (94 sloc)
2.68 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ncurses.h> | |
#include <string> | |
#include "Main_Menu.h" | |
#include "InformationPage.h" | |
#include <iostream> | |
using namespace std; | |
void InformationPage(); | |
void Main_Menu() | |
{ | |
initscr(); | |
noecho(); | |
cbreak(); | |
int selection = 0; | |
int yMax, xMax; | |
getmaxyx(stdscr, yMax, xMax); | |
WINDOW * titlewin = newwin(10, xMax-54, yMax-40, 50); | |
// box(titlewin, 3, 3); | |
//wborder(titlewin,0,0,0,0); | |
mvwprintw(titlewin, 2, 1, "_______________________________________"); | |
mvwprintw(titlewin, 3, 1, " _____ _____ _____ _____ _____ "); | |
mvwprintw(titlewin, 4, 1, "|__ | | | | __ | | __| | __|"); | |
mvwprintw(titlewin, 5, 1, "| __| | | | | -| | (__ (__ "); | |
mvwprintw(titlewin, 6, 1, "|_____| |_____| |__|__| |_____| |_____|"); | |
mvwprintw(titlewin, 7, 1, "_______________________________________"); | |
mvwprintw(titlewin, 8, 1, " "); | |
refresh(); | |
wrefresh(titlewin); | |
WINDOW * menuwin = newwin(5, xMax-36, yMax-10, 25); | |
box(menuwin, 3, 0); | |
refresh(); | |
wrefresh(menuwin); | |
keypad(menuwin, true); | |
string choices[3] = {"START GAME ", | |
"INFORMATION ", | |
"EXIT GAME"}; | |
int choice; | |
int highlight = 0; | |
while(1) | |
{ | |
for(int i = 0; i < 3; i++) | |
{ | |
if(i == highlight) | |
wattron(menuwin, A_REVERSE); | |
mvwprintw(menuwin, i+1, 60, choices[i].c_str()); | |
wattroff(menuwin, A_REVERSE); | |
} | |
choice = wgetch(menuwin); | |
switch(choice) | |
{ | |
case KEY_UP: | |
highlight--; | |
if(highlight == -1) | |
highlight = 2; | |
break; | |
case KEY_DOWN: | |
highlight++; | |
if(highlight == 3) | |
highlight = 0; | |
break; | |
case 10: | |
selection = highlight + 1; | |
break; | |
default: | |
refresh(); | |
break; | |
} | |
if (selection != 0) | |
{ | |
if (selection == 1) | |
{ | |
break; | |
} | |
if (selection == 2) | |
{ | |
//clear(); | |
refresh(); | |
wrefresh(titlewin); | |
endwin(); | |
InformationPage(); | |
} | |
if (selection == 3) | |
{ | |
endwin(); | |
exit(0); | |
} | |
selection = 0; | |
} | |
} | |
clear(); | |
refresh(); | |
wrefresh(titlewin); | |
endwin(); | |
} | |
//Made by Chris with edits by Callum |