165 lines
6.7 KiB
C++
165 lines
6.7 KiB
C++
#include "menu.h"
|
|
|
|
#include "constants.h"
|
|
|
|
const int NORMAL_CNT = 5;
|
|
const int EXTRA_CNT = 10;
|
|
const int HOR_INCRM = 5;
|
|
|
|
const enum race RACES[EXTRA_CNT] = {
|
|
SHADE, DROW, GOBLIN, VAMPIRE, TROLL,
|
|
MONK, ASSASSIN, MR_GOOSE, BRAWLER, RT_800
|
|
};
|
|
|
|
const position RACE_POS[EXTRA_CNT] = {
|
|
{4, 9}, {4, 11}, {4, 13}, {4, 15}, {4, 17},
|
|
{41, 9}, {41, 11}, {41, 13}, {41, 15}, {41, 17}
|
|
};
|
|
|
|
menu::menu(const feature enabled_features):
|
|
enabled_features{enabled_features},
|
|
curr{0} {}
|
|
|
|
const char *NORMAL_SCREEN =
|
|
"+-----------------------------------------------------------------------------+\
|
|
| ____ ____ _____ _ __ |\
|
|
| / _\\/ _\\\\__ \\/ |/ / |\
|
|
| | / | / / || / |\
|
|
| | \\_ | \\_ _\\ || \\ |\
|
|
| \\____/\\____//____/\\_|\\_\\ |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Choose your race: |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Shade | |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Drow | |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Goblin | |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Vampire | |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Troll | |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
|-----------------------------------------------------------------------------|\
|
|
| |\
|
|
+-----------------------------------------------------------------------------+";
|
|
|
|
const char *EXTRA_SCREEN =
|
|
"+-----------------------------------------------------------------------------+\
|
|
| ____ ____ _____ _ __ |\
|
|
| / _\\/ _\\\\__ \\/ |/ / |\
|
|
| | / | / / || / |\
|
|
| | \\_ | \\_ _\\ || \\ |\
|
|
| \\____/\\____//____/\\_|\\_\\ |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Choose your race: |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Shade | Monk |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Drow | Assassin |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Goblin | Mr. Goose |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Vampire | Tavern Brawler |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| Troll | T-800 |\
|
|
+-----------------------------------------------------------------------------+\
|
|
| |\
|
|
| |\
|
|
| |\
|
|
|-----------------------------------------------------------------------------|\
|
|
| |\
|
|
+-----------------------------------------------------------------------------+";
|
|
|
|
int menu::run(input *in) {
|
|
int limit = enabled_features & FEATURE_EXTRA_STUFF ?
|
|
EXTRA_CNT : NORMAL_CNT;
|
|
|
|
auto cmd = in->get_command();
|
|
|
|
switch (cmd) {
|
|
case game_command::ENTER:
|
|
return RACES[curr];
|
|
|
|
case MOVE_NORTH: {
|
|
if (curr > 0)
|
|
--curr;
|
|
|
|
break;
|
|
}
|
|
|
|
case MOVE_SOUTH: {
|
|
if (curr < limit - 1)
|
|
++curr;
|
|
|
|
break;
|
|
}
|
|
|
|
case MOVE_EAST: {
|
|
if (curr + HOR_INCRM < limit)
|
|
curr += HOR_INCRM;
|
|
|
|
break;
|
|
}
|
|
|
|
case MOVE_WEAT: {
|
|
if (curr - HOR_INCRM >= 0)
|
|
curr -= HOR_INCRM;
|
|
|
|
break;
|
|
}
|
|
|
|
case SELECT_SHADE:
|
|
return SHADE;
|
|
|
|
case SELECT_DROW:
|
|
return DROW;
|
|
|
|
case SELECT_GOBLIN:
|
|
return GOBLIN;
|
|
|
|
case SELECT_TROLL:
|
|
return TROLL;
|
|
|
|
case SELECT_VAMPIRE:
|
|
return VAMPIRE;
|
|
|
|
case GAME_COMMAND_TERMINATE:
|
|
return -2;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
const position MSG_POS = {2, 23};
|
|
const char *MSG_NORMAL =
|
|
"Move with movement commands, 'yes' to confirm, 'q' to quit.";
|
|
const char *MSG_NCURSES =
|
|
"Move with movement commands, press 'e' to confirm, 'q' to quit.";
|
|
const position SEED_POS = {1, 25};
|
|
|
|
void menu::print(output *out, const unsigned int seed) {
|
|
if (enabled_features & FEATURE_EXTRA_STUFF)
|
|
out->print_str({0, 0}, EXTRA_SCREEN);
|
|
else
|
|
out->print_str({0, 0}, NORMAL_SCREEN);
|
|
|
|
if (enabled_features & FEATURE_NCURSES)
|
|
out->print_str(MSG_POS, MSG_NCURSES, COLOR_PAIR(COLOR_YELLOW));
|
|
else
|
|
out->print_str(MSG_POS, MSG_NORMAL, COLOR_PAIR(COLOR_YELLOW));
|
|
|
|
out->print_str(SEED_POS, "Seed: " + std::to_string(seed),
|
|
COLOR_PAIR(COLOR_BLUE));
|
|
|
|
out->print_str(RACE_POS[curr], "->",
|
|
COLOR_PAIR(COLOR_GREEN));
|
|
|
|
}
|