Example #1
0
    def buildMenu(self,
                  drink_list,
                  drink_options,
                  alcoholic_drinks_enabled=False):
        # create a new main menu
        m = Menu("Main Menu")

        # add drink options
        drink_opts = []
        for d in drink_list:
            # check if allowed by admin button
            if alcoholic_drinks_enabled == False:
                # check if the drink has alcohol
                if d["alcoholic"] == False:  # -----!!!!-----
                    drink_opts.append(
                        MenuItem('drink', d["name"],
                                 {"ingredients": d["ingredients"]
                                  }))  # -----!!!!-----
            else:
                drink_opts.append(
                    MenuItem('drink', d["name"],
                             {"ingredients": d["ingredients"]}))

        configuration_menu = Menu("Configure")

        # add pump configuration options
        pump_opts = []
        for p in sorted(self.pump_configuration.keys()):
            config = Menu(self.pump_configuration[p]["name"])
            # add fluid options for each pump
            for opt in drink_options:
                # star the selected option
                selected = "*" if opt["value"] == self.pump_configuration[p][
                    "value"] else ""
                config.addOption(
                    MenuItem('pump_selection', opt["name"], {
                        "key": p,
                        "value": opt["value"],
                        "name": opt["name"]
                    }))
            # add a back button so the user can return without modifying
            config.addOption(Back("Back"))
            config.setParent(configuration_menu)
            pump_opts.append(config)

        # add pump menus to the configuration menu
        configuration_menu.addOptions(pump_opts)
        # add a back button to the configuration menu
        configuration_menu.addOption(Back("Back"))
        # adds an option that cleans all pumps to the configuration menu
        configuration_menu.addOption(MenuItem('clean', 'Clean'))
        configuration_menu.setParent(m)

        m.addOptions(drink_opts)
        m.addOption(configuration_menu)
        # create a menu context
        self.menuContext = MenuContext(m, self)
Example #2
0
    def buildMenu(self, drink_list, drink_options):
        # create a new main menu
        m = Menu("Main Menu")

        # create a drinks menu
        drinks_menu = Menu("Drinks")

        # add drink options
        drink_opts = []
        for o in drink_options:
            drink_opts.append(
                MenuItem(
                    'drink',
                    o["name"],
                    {
                        "ingredients": {o["value"]: 1},
                        "strong": o["alcohol"],
                        "ice": 0
                    }
                )
            )
        for d in drink_list:
            try:
                drink_opts.append(
                    MenuItem(
                        'drink',
                        d["name"],
                        {
                            "ingredients": d["ingredients"],
                            "strong": d["strong"],
                            "add": d["add"],
                            "ice": d["ice"]
                        }
                    )
                )
            except KeyError:
                drink_opts.append(
                    MenuItem(
                        'drink',
                        d["name"],
                        {
                            "ingredients": d["ingredients"],
                            "strong": d["strong"],
                            "ice": d["ice"]
                        }
                    )
                )
        configuration_menu = Menu("Configure")

        # add pump configuration options
        pump_opts = []
        for p in sorted(self.pump_configuration.keys()):
            config = Menu(self.pump_configuration[p]["name"])
            # add fluid options for each pump
            for opt in drink_options:
                config.addOption(
                    MenuItem(
                        'pump_selection',
                        opt["name"],
                        {"key": p, "value": opt["value"], "name": opt["name"]}
                        )
                    )
            config.setParent(configuration_menu)
            pump_opts.append(config)

        # add pump menus to the configuration menu
        configuration_menu.addOptions(pump_opts)

        # adds an option that cleans all pumps to the configuration menu
        configuration_menu.addOption(MenuItem('clean', 'Clean'))
        configuration_menu.setParent(m)

        drinks_menu.addOptions(drink_opts)
        drinks_menu.setParent(m)
        self.filterDrinks(drinks_menu)

        m.addOption(drinks_menu)
        m.addOption(configuration_menu)

        # create a menu context
        self.menuContext = MenuContext(m, self, self.lcdLayer)