package pathgame.gameplay.menu; import java.util.function.BiConsumer; import java.util.function.Consumer; import pathgame.gameplay.Gamestate; import pathgame.gameplay.Level; /** * A container for holding everything about a menu button * * @author julia */ public class MenuButton { private final String name; private final BiConsumer r; /** * Contructor initializing a menu button * * @param name the name of the button to be shown to the player * @param r function that is executed when pressed on the button */ public MenuButton(String name, BiConsumer r) { this.name = name; this.r = r; } /** * Contructor initializing a menu button * * @param name the name of the button to be shown to the player * @param r function that is executed when pressed on the button */ public MenuButton(String name, Consumer r) { this(name, (gamestate, level) -> r.accept(gamestate)); } /** * Returns the name of the button * * @return the name of the button */ public String getName() { return name; } /** * runs the button function * * @param gamestate the gamestate * @param level the current level */ public void run(Gamestate gamestate, Level level) { r.accept(gamestate, level); } }