Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Menu::mainSelection(int& state, string firstOption, string secondOption)
- {
- string name;
- int option = 1;
- char choice = 'w';
- if (state == 0)
- {
- title();
- }
- showOptions(option, firstOption, secondOption);
- bool condition = true, insideCondition = true, showCondition = true;
- while (condition)
- {
- if (listen.isEmpty())
- {
- listen.charInput(choice);
- if (static_cast <int>(choice) == -32)
- {
- if (state == 0)
- {
- title();
- }
- arrowSupport(option, firstOption, secondOption);
- }
- else
- {
- switch (choice)
- {
- case 'w':
- case 'W':
- option--;
- if (state == 0)
- {
- title();
- }
- else if (state == 4)
- {
- choice = showCondition ? 'w' : 27;
- }
- showOptions(option, firstOption, secondOption);
- break;
- case 's':
- case 'S':
- option++;
- if (state == 0)
- {
- title();
- }
- else if (state == 4)
- {
- choice = showCondition ? 's' : 27;
- }
- showOptions(option, firstOption, secondOption);
- break;
- case ' ':
- if (option == 1)
- {
- condition = false;
- say.clearScreen();
- if (state == 1)
- {
- mapSelection();
- }
- else if (state == 2)
- {
- levels.game("map1.txt");
- mapEnd();
- }
- else if (state == 3)
- {
- showResults("Name:", "Full name results:", false, numberName.mapAccess(), fullName.mapAccess());
- }
- else if (state == 4)
- {
- if (insideCondition)
- {
- say.communique("Enter your name: ");
- listen.stringInput(name);
- addScore(true, name, levels.getScore());
- insideCondition = false;
- say.clearScreen();
- }
- say.communique("Your name is: " + name);
- say.communique("Your result is: " + std::to_string(levels.getScore()));
- fullName.saveScoreToFile(fullName.mapAccess(), "String");
- }
- showOptions(option, firstOption, secondOption);
- }
- else if (option == 2)
- {
- say.clearScreen();
- if (state == 0)
- {
- exit(0);
- }
- else if (state == 1)
- {
- showScore();
- }
- else if (state == 2)
- {
- levels.game("map2.txt");
- mapEnd();
- }
- else if (state == 3)
- {
- showResults("Id:", "Number results:", true, numberName.mapAccess(), fullName.mapAccess());
- }
- else if (state == 4)
- {
- if (insideCondition)
- {
- name = std::to_string(numberName.size() + 1);
- addScore(false, name, levels.getScore());
- insideCondition = false;
- }
- say.clearScreen();
- say.communique("Your number is: " + name);
- say.communique("Your result is: " + std::to_string(levels.getScore()));
- numberName.saveScoreToFile(numberName.mapAccess(), "Int");
- }
- showOptions(option, firstOption, secondOption);
- }
- showCondition = false;
- break;
- case 27:
- if (state == 1)
- {
- say.clearScreen();
- state = 0;
- startScreen();
- }
- else if (state == 2 || state == 3 || state == 4)
- {
- say.clearScreen();
- mainMenu();
- }
- break;
- default:
- break;
- }
- }
- }
- }
- say.clearScreen();
- }
- void Menu::startScreen()
- {
- int option = 0;
- mainSelection(option, "Start Game", "Close Game");
- }
- void Menu::mainMenu()
- {
- int option = 1;
- mainSelection(option, "Chose Map", "Show Score");
- }
- void Menu::mapSelection()
- {
- int option = 2;
- mainSelection(option, "First Map", "Second Map");
- }
- void Menu::showScore()
- {
- int option = 3;
- mainSelection(option, "Show number results", "Show full name results");
- }
- void Menu::mapEnd()
- {
- int option = 4;
- mainSelection(option, "Enter name", "Wait for number");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement