Source

zorkish / 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 (this->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_ */