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?
Bazoonkas_Tamagotchi/display.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
72 lines (67 sloc)
2.12 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 <iostream> | |
#include <Windows.h> | |
#include <conio.h> | |
#include <vector> | |
#include <string> | |
#include "arrowDisplay.h" | |
#define KEY_UP 72 | |
#define KEY_DOWN 80 | |
//Inputted a vector of values and will display them in a menu type manner | |
//and return the question they selected | |
std::string Display(std::vector<std::string> values) | |
{ | |
bool entered = false; | |
int arrow = 0; | |
std::string output; | |
//Initilises screen | |
Draw(values, arrow, entered); | |
//Tests to see if any values have been selectd. If not it will continue | |
while (!entered) | |
{ | |
if(_kbhit()) | |
{ | |
//Sees if arrow keys or enter has been pressed and moves arrow up and down | |
char c = _getch(); | |
if (c == 0) | |
{ | |
switch(_getch()) | |
{ | |
//Sees if up arrow has been pressed | |
case KEY_UP: | |
arrow--; | |
if (arrow < 0) | |
{ | |
arrow = values.size()-1; | |
Draw(values, arrow, entered); | |
} | |
else | |
Draw(values, arrow, entered); | |
break; | |
//Sees if down arrow has been pressed | |
case KEY_DOWN: | |
arrow++; | |
if (arrow >= values.size()) | |
{ | |
arrow = 0; | |
Draw(values, arrow, entered); | |
} | |
else | |
Draw(values, arrow, entered); | |
break; | |
} | |
} | |
else | |
switch(c) | |
{ | |
//Sees if enter has been pressed | |
case '\r': | |
entered = true; | |
output = Draw(values, arrow, entered); | |
system("cls"); | |
//cout << "\n " << output << "\n" << endl; | |
break; | |
} | |
} | |
} | |
return output; | |
} |