Makeclass cleaned up
This commit is contained in:
@@ -109,13 +109,18 @@ void TextGame::do_menu_command(const StringVec &cmd) {
|
||||
|
||||
void TextGame::do_choose_command(const StringVec &cmd) {
|
||||
int64_t index;
|
||||
if (cmd.size() == 2) {
|
||||
index = util::strtoint(cmd[1], -1);
|
||||
if (cmd.size() == 1) {
|
||||
index = util::strtoint(cmd[0], -1);
|
||||
} else {
|
||||
std::cerr << "c command (choose) expects a menu line number" << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cerr << "Choose command (index " << index << ") not implemented yet." << std::endl;
|
||||
const Gui::EltVec &elts = gui_.elts();
|
||||
if ((index < 0) || (index >= int(elts.size()))) {
|
||||
std::cerr << "No menu item #" << index << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cerr << "Choosing menu item: " << elts[index].id() << std::endl;
|
||||
}
|
||||
|
||||
void TextGame::do_snapshot_command(const StringVec &cmd) {
|
||||
@@ -143,14 +148,13 @@ void TextGame::do_quit_command(const StringVec &cmd) {
|
||||
}
|
||||
|
||||
void TextGame::do_command(const StringVec &words) {
|
||||
switch (words[0][0]) {
|
||||
case 'v': do_view_command(words); break;
|
||||
case 'm': do_menu_command(words); break;
|
||||
case 'c': do_choose_command(words); break;
|
||||
case 'q': do_quit_command(words); break;
|
||||
case 's': do_snapshot_command(words); break;
|
||||
case 'r': do_rollback_command(words); break;
|
||||
default:
|
||||
if (words[0] == "v") do_view_command(words);
|
||||
else if (words[0] == "m") do_menu_command(words);
|
||||
else if (words[0] == "q") do_quit_command(words);
|
||||
else if (words[0] == "s") do_snapshot_command(words);
|
||||
else if (words[0] == "r") do_rollback_command(words);
|
||||
else if (util::validinteger(words[0])) do_choose_command(words);
|
||||
else {
|
||||
std::cerr << "Unknown command: " << words[0] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user