Source

zorkish / stages / MainMenuStage.hpp

/*
 * MainMenuStage.hpp
 *
 *  Created on: 19/08/2012
 *      Author: rhys
 */

#ifndef MAINMENUSTAGE_HPP_
#define MAINMENUSTAGE_HPP_

#include "../ActiveStageManager.hpp"
#include "../ZorkishStage.hpp"
#include "AboutStage.hpp"
#include "HallOfFameStage.hpp"
#include "HelpStage.hpp"
#include "SelectAdventureStage.hpp"

class MainMenuStage : public ZorkishStage {
private:
    std::string message;

public:
    MainMenuStage(ZorkishGame& game) : ZorkishStage(game) {};

    virtual Status update(ActiveStageManager& smgr) {
        switch (ZorkishStage::input_int()) {
        case 1:
            smgr.set_next_stage(this->game.select_adventure().get());
            break;
        case 2:
            smgr.set_next_stage(this->game.hall_of_fame().get());
            break;
        case 3:
            smgr.set_next_stage(this->game.help().get());
            break;
        case 4:
            smgr.set_next_stage(this->game.about().get());
            break;
        case 5:
            return GameStage::Status::FINISH;
        default:
            this->message = "Please select a number listed above.";
            break;
        }

        return GameStage::Status::CONTINUE;
    }

    virtual void draw() {
        using std::cout;
        cout << "===ZORKISH===\n";
        cout << "Main Menu:\n";
        cout << "1. Select adventure and play\n";
        cout << "2. Hall of Fame\n";
        cout << "3. Help\n";
        cout << "4. About\n";
        cout << "5. Quit\n\n";
        if (!this->message.empty()) {
            cout << this->message << '\n';
            this->message.clear();
        }
        cout << "Select 1-5: ";
    };
};

#endif /* MAINMENUSTAGE_HPP_ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.