#ifndef MENU_H_3F6E62B3 #define MENU_H_3F6E62B3 #include #include #include #include class Game; enum class MenuType { Command, Slider }; struct MenuItem { MenuType type = MenuType::Command; std::string text; std::function activationFunction; bool playSfx = true; int value = 0; int maxValue = 0; std::function selectionChanged; }; class MenuBuilder { public: MenuBuilder& Command(std::string text) { result_.type = MenuType::Command; result_.text = std::move(text); return *this; } MenuBuilder& ActivationFunction(std::function val) { result_.activationFunction = std::move(val); return *this; } MenuBuilder& SkipSoundEffect() { result_.playSfx = false; return *this; } MenuBuilder& Slider(std::string text) { result_.type = MenuType::Slider; result_.text = std::move(text); return *this; } MenuBuilder& InitialValue(int value) { result_.value = value; return *this; } MenuBuilder& MaxValue(int mv) { result_.maxValue = mv; return *this; } MenuBuilder& SelectionChangedFunction(std::function val) { result_.selectionChanged = std::move(val); return *this; } MenuItem Build() const { return result_; } private: MenuItem result_; }; class Menu { public: explicit Menu(const std::vector& builders); const std::vector& getItems() const { return items_; } std::vector& getItems() { return items_; } int getCursorPosition() const { return cursor_; } void moveCursorUp(); void moveCursorDown(); private: std::vector items_; int cursor_ = 0; }; #endif /* end of include guard: MENU_H_3F6E62B3 */