Esempio n. 1
0
    def createItemMenu(self, combatantIndex):

        # Construct the menu
        itemMenu = PartyMenu.PartyMenu("Item", "Use an item.", combatantIndex)
        inv = self.partyManager.getInventory()

        # Add all items
        loot = inv.getAvailableLoot()
        items = []
        for l in loot:
            items += [
                MenuItem.MenuItem(
                    l,
                    inv.getItemDescription(l) + " (" +
                    str(inv.getItemCount(l)) + " left)")
            ]

        # Add a confirm option
        items += [
            MenuItem.MenuItem("confirm",
                              "Go back to the party management menu.")
        ]

        # Set options
        itemMenu.setOptions(items)
        itemMenu.topRight()

        return itemMenu
Esempio n. 2
0
    def createWeaponMenu(self, combatantIndex):

        weaponMenu = PartyMenu.PartyMenu("Weapon", "Select a weapon.",
                                         combatantIndex)

        # Create options
        weaponOptions = []
        for weaponName in self.partyManager.getInventory().getAvailableWeapons(
        ):

            weapon = self.partyManager.getInventory().getWeapon(weaponName)

            # Create a tooltip with the stats
            toolTip = self.partyManager.getInventory().getItemDescription(
                weaponName) + '\n'
            toolTip += weapon.getStatsAsString()

            weaponOptions += [MenuItem.MenuItem(weaponName, toolTip)]

        # Add a confirm option
        weaponOptions += [
            MenuItem.MenuItem("confirm",
                              "Go back to the party management menu.")
        ]

        weaponMenu.setOptions(weaponOptions)
        weaponMenu.topRight()

        return weaponMenu
Esempio n. 3
0
 def newClicked(self):
    form = AddForm()
    
    self.holdOpen = True
    form.exec_()
    self.checkMouse()
    self.holdOpen = False
    
    if form.accepted:
       item = MenuItem()
       item.name = form.name
       item.command = form.command
       item.working = form.working
       item.folder = form.folder
       item.icon = form.icon
       item.findIcon()
       
       clicked = self.getClicked()
       if clicked:
          parent = clicked.item.parent
       elif self.leftList.mouseOver:
          if self.currentItem != None:
             parent = self.currentItem.parent
          else:
             parent = None
       else:
          parent = self.currentItem
       item.parent = parent
       
       self.menuItems.append(item)
       self.refresh()
Esempio n. 4
0
def read_load_Table_Info():
    readFile = open("config.txt", "r")
    rawData = readFile.readlines()
    # reads each line as string & then
    #   returns a list with the read lines
    readFile.close()

    bufferTables = []
    list1 = []  # temp list to strip the data off \n [ ] '
    for i in rawData:
        i = i.splitlines()  # removes \n from the list
        list1.append(i)

    for item in list1:
        item = str(item)
        item = item.strip('[]\'')  # list [,] &'
        item = item.split(' ')
        item[0] = int(item[0])
        item[1] = int(item[1])  # convert price from str to int
        #menu.append(item)
        #print( item )
        bufT = MenuItem.Table(item[0], item[1], mainMenu)  #create the menuitem
        bufferTables.append(bufT)
    #print("List of Menu:", menu)
    return bufferTables
Esempio n. 5
0
    def __init__(self, screen, menuItems, font):
        pygame.init()
        self.screen = screen
        self.width = self.screen.get_rect().width
        self.height = self.screen.get_rect().height
        self.font = font
        self.title = font.render("Capture the Honey", 1, (218, 165, 32))
        #X position of title
        self.titleX = (self.width / 2) - ((self.title.get_rect().width) / 2)
        #Hornet icon in title screen
        self.hornet, self.hornetRect = loader.load_image('TitleBee.png', -1)
        #Position of bee sprite in title screen
        hornetX = (self.width / 2) - (self.hornet.get_rect().width / 2) + 50
        hornetY = ((self.height / 2) +
                   (self.hornet.get_rect().height / 2)) - 200
        self.center = (hornetX, hornetY)

        self.clock = pygame.time.Clock()
        #Holds menu choices
        self.items = []
        #Adding choices to self.items
        for index, item in enumerate(menuItems):
            menuItem = MenuItem.MenuItem(item, font, 0, 0)

            x = (self.width / 2) - (menuItem.itemWidth / 2)
            totalHeight = len(menuItems) * menuItem.itemHeight
            y = (self.height / 2) - (totalHeight / 2) + (index *
                                                         menuItem.itemHeight)
            menuItem.setPos(x, y)

            self.items.append(menuItem)
Esempio n. 6
0
class TestMenu(unittest.TestCase):
    def test_choose(self):
        def test_func():
            pass

    menu = Menu([
        MenuItem(1, 'Test', test_func)
    ])
    output = menu.choose(1)
    self.assertEqual(output, 'kacsa')
Esempio n. 7
0
def newMenuItem(restaurant_id):
    restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one()
    if request.method == 'POST':
        newItem = MenuItem(name=request.form['name'], description=request.form[
                           'description'], price=request.form['price'], course=request.form['course'], restaurant_id=restaurant_id)
        session.add(newItem)
        session.commit()
        flash('New Menu %s Item Successfully Created' % (newItem.name))
        return redirect(url_for('showMenu', restaurant_id=restaurant_id))
    else:
        return render_template('newmenuitem.html', restaurant_id=restaurant_id)
Esempio n. 8
0
    def __init__(self, screen, items, funcs, font='Assets/armalite.ttf', font_size=100,
                 font_color=RED, img='Assets/tanks.jpg'):
        self.screen = screen
        self.scr_width = self.screen.get_rect().width
        self.scr_height = self.screen.get_rect().height
        self.img = pygame.image.load(img)
        self.clock = pygame.time.Clock()
        self.funcs = funcs
        self.items = []

        for index, item in enumerate(items):
            menu_item = MenuItem(item, font, font_size, font_color)
            height_text = len(items) * menu_item.height
            position_x = (self.scr_width / 2) - (menu_item.width / 2)
            position_y = (self.scr_height / 2) - (height_text / 2) + \
                         ((index * 2) + index * menu_item.height)
            menu_item.set_position(position_x, position_y)
            self.items.append(menu_item)

        self.mouse_is_visible = True
        self.cur_item = None
Esempio n. 9
0
    def buildItemMenu(self):

        inv = self.partyManager.getInventory()
        loot = inv.getAvailableLoot()
        items = []
        for lootItem in loot:
            items += [
                MenuItem.MenuItem(
                    lootItem,
                    inv.getItemDescription(lootItem) + " (" +
                    str(inv.getItemCount(lootItem)) + " left)")
            ]
        self.itemMenu.setOptions(items)
        self.itemMenu.leftBottom()
Esempio n. 10
0
def read_load_Menu():
    readFile = open("menu.txt", "r")  # to read lines as string
    rawData = readFile.readlines()
    readFile.close()

    m = []
    list1 = []  # temp list to strip the data off \n [ ] '
    menu = MenuItem.Menu(m)
    for i in rawData:
        i = i.splitlines()  # removes \n from the list
        list1.append(i)

    for item in list1:
        item = str(item)
        item = item.strip('[]\'')  # list [,] &'
        item = item.split(' ')
        item[2] = float(item[2])  # convert price from str to float
        #menu.append(item)
        bufMI = MenuItem.MenuItem(item[0], item[1],
                                  item[2])  #create the menuitem
        menu.addItem(bufMI)
    #print("List of Menu:", menu)
    return menu
Esempio n. 11
0
    def __init__(self):

        # Stuff for sounds
        self.cacheManager = annchienta.getCacheManager()
        self.audioManager = annchienta.getAudioManager()
        self.soundClickRev = self.cacheManager.getSound(
            'sounds/click-reverse.ogg')
        self.soundClickNeg = self.cacheManager.getSound(
            'sounds/click-negative.ogg')
        self.soundClickPos = self.cacheManager.getSound(
            'sounds/click-positive.ogg')
        self.soundClickNeu = self.cacheManager.getSound(
            'sounds/click-neutral.ogg')
        self.soundSave = self.cacheManager.getSound('sounds/save.ogg')

        # General references
        self.mapManager = annchienta.getMapManager()
        self.inputManager = annchienta.getInputManager()
        self.partyManager = PartyManager.getPartyManager()

        self.menu = Menu.Menu("In-Game Menu", "Select action.")

        options = []

        # An option that does nothing.
        options += [
            MenuItem.MenuItem("continue", "Close menu and continue playing.")
        ]

        # A submenu for party management.
        options += [MenuItem.MenuItem("party", "Change equipment, heal...")]

        # An option to quit.
        options += [MenuItem.MenuItem("quit", "Stop playing.")]

        self.menu.setOptions(options)
        self.menu.top()
Esempio n. 12
0
def read_load_table_updated():
    readConfig = open("config.txt", 'r')
    data = readConfig.readlines()
    readConfig.close()
    tbl = []

    for i in range(len(data)):
        oneLine = data[i].strip('\n')
        oneLine = oneLine.strip(" ")
        oneLine = oneLine.split(" ")
        #     print(oneLine)
        tbl.append(MenuItem.Table(int(oneLine[0]), int(oneLine[1]), []))
        # tbl[oneLine[0]] = int(oneLine[1])

    return tbl
Esempio n. 13
0
    def buildMenu(self):

        self.menu = Menu.Menu(self.name, "Select an action.")
        subs = []
        for action in self.actions:

            # Create a decription first
            description = action.getDescription()
            if action.getCost() > 0:
                description += " (" + str(action.getCost()) + "MP)"

            menuItem = MenuItem.MenuItem(action.getName(), description)
            if action.getCost() > self.getMp():
                menuItem.setEnabled(False)
            added = False

            for sub in subs:
                if sub.name == action.getCategory():
                    sub.options += [menuItem]
                    added = True

            if not added:
                if action.category == "top":
                    subs += [menuItem]
                else:
                    newsub = Menu.Menu(action.getCategory())
                    newsub.options += [menuItem]
                    subs += [newsub]

        self.itemMenu = Menu.Menu("item", "Use items.")
        subs += [self.itemMenu]
        self.buildItemMenu()

        # set options and align
        self.menu.setOptions(subs)
        self.menu.leftBottom()
Esempio n. 14
0
#sceneManager.fade( 255, 255, 255, 2000 )

# Load a title background.
titleBackground = annchienta.Surface("images/storyline/title.png")

running = True
while running and inputManager.isRunning():

    videoManager.clear()
    videoManager.drawSurface(titleBackground, 0, 0)
    videoManager.flip()
    videoManager.flip()

    menu = Menu.Menu("Main Menu", "I love my girlfriend.")
    options = [
        MenuItem.MenuItem("new", "Start a new game."),
        MenuItem.MenuItem("load", "Continue from the last save point."),
        MenuItem.MenuItem(
            "video size",
            "Change the video size. (Experimental)\n(A larger size might slow down or crash the game.)"
        ),
        MenuItem.MenuItem("quit", "Leave this great game.")
    ]
    menu.setOptions(options)
    menu.leftBottom()
    menuItem = menu.pop(None)

    if menuItem is not None:

        if menuItem.getName() == "quit":
Esempio n. 15
0
    def partyManagement(self):

        partyManagementMenu = PartyMenu.PartyMenu("party management",
                                                  "Manage your party.")

        # Set options...
        partyOptions = []
        partyOptions += [
            MenuItem.MenuItem("weapon", "Change party member weapon.")
        ]
        partyOptions += [
            MenuItem.MenuItem("item", "Use an item on this party member.")
        ]
        partyOptions += [MenuItem.MenuItem("confirm", "Quit this menu.")]
        partyManagementMenu.setOptions(partyOptions)

        # Top right corner
        partyManagementMenu.topRight()

        popping = True
        while popping and self.inputManager.isRunning():

            menuItem = partyManagementMenu.pop()

            # The user canceled
            if menuItem is None:
                popping = False

            else:

                if menuItem.getName() == "weapon":

                    # Construct a weapon menu
                    weaponMenu = self.createWeaponMenu(
                        partyManagementMenu.combatantIndex)
                    weaponPopping = True

                    while weaponPopping and self.inputManager.isRunning():

                        w = weaponMenu.pop()
                        if w is not None:
                            if w.name != "confirm":
                                # Remove old weapon from combatant and add it back to inventory
                                self.partyManager.getInventory().addItem(
                                    self.partyManager.team[
                                        weaponMenu.combatantIndex].weapon.name)
                                # Set new weapon
                                self.partyManager.team[
                                    weaponMenu.combatantIndex].setWeapon(
                                        w.name)
                                # Remove new weapon from inventory
                                self.partyManager.getInventory().removeItem(
                                    w.name)
                                # Create a new weaponmenu
                                weaponMenu = self.createWeaponMenu(
                                    weaponMenu.combatantIndex)
                            else:
                                weaponPopping = False
                        else:
                            weaponPopping = False

                    # Update combatant
                    partyManagementMenu.combatantIndex = weaponMenu.combatantIndex

                elif menuItem.getName() == "item":

                    # Create an item menu to choose from.
                    itemMenu = self.createItemMenu(
                        partyManagementMenu.combatantIndex)

                    # Get a shortcut to the inventory
                    inv = self.partyManager.getInventory()

                    itemPopping = True

                    while itemPopping and self.inputManager.isRunning():

                        # Choose item
                        item = itemMenu.pop()
                        if item is not None:
                            if item.name != "confirm":
                                inv.useItemOn(
                                    item.name, self.partyManager.team[
                                        itemMenu.combatantIndex])
                                itemMenu = self.createItemMenu(
                                    itemMenu.combatantIndex)
                            else:
                                itemPopping = False
                        else:
                            itemPopping = False

                    # Update combatant
                    partyManagementMenu.combatantIndex = itemMenu.combatantIndex

                elif menuItem.getName() == "confirm":
                    popping = False
Esempio n. 16
0
import PartyManager
import SceneManager

cacheManager = annchienta.getCacheManager()
sound = cacheManager.getSound('sounds/crystal.ogg')

audioManager = annchienta.getAudioManager()
audioManager.playSound( sound )

partyManager = PartyManager.getPartyManager()
partyManager.heal()

sceneManager = SceneManager.getSceneManager()

sceneManager.initDialog( [annchienta.getActiveObject(), annchienta.getPassiveObject()] )
sceneManager.text("Your health was restored!")

menu = Menu.Menu("Save menu.", "Save your game.")
options = [ MenuItem.MenuItem("save", "Save your progress."), MenuItem.MenuItem("cancel", "Return to the game.") ]
menu.setOptions( options )
menu.top()

ans = menu.pop()
if ans is not None:
    if ans.name == "save":
        path = os.path.join(os.path.expanduser("~"), ".fall-of-imiryn/save.xml")
        partyManager.save(path)
        sceneManager.text("The progress in your travels has been recorded.")

sceneManager.quitDialog()
Esempio n. 17
0
def create_menu():
    root = processorMenu.MenuItem(None, "root", "Main menu", False)
    # region Main menu
    # region item_1 ("Add matrices" menu)
    item_1 = processorMenu.MenuItem(root, "1", "1. Add matrices", True)
    # endregion
    # region item_2 ("Multiply matrix by a constant" menu)
    item_2 = processorMenu.MenuItem(root, "2",
                                    "2. Multiply matrix by a constant", True)
    # endregion
    # region item_3 ("Multiply matrices" menu)
    item_3 = processorMenu.MenuItem(root, "3", "3. Multiply matrices", True)
    # endregion
    # region item_4 ("Transpose matrix" menu)
    item_4 = processorMenu.MenuItem(root, "4", "4. Transpose matrix", False)
    item_4_1 = processorMenu.MenuItem(item_4, "4_1", "1. Main diagonal", True)
    item_4_2 = processorMenu.MenuItem(item_4, "4_2", "2. Side diagonal", True)
    item_4_3 = processorMenu.MenuItem(item_4, "4_3", "3. Vertical line", True)
    item_4_4 = processorMenu.MenuItem(item_4, "4_4", "4. Horizontal line",
                                      True)
    # endregion
    # region item_5 ("Calculate a determinant")
    item_5 = processorMenu.MenuItem(root, "5", "5. Calculate a determinant",
                                    True)
    # endregion
    # region item_6 ("Inverse matrix")
    item_6 = processorMenu.MenuItem(root, "6", "6. Inverse matrix", True)
    # endregion
    # region item_0
    item_0 = processorMenu.MenuItem(root, "0", "0. Exit", True)
    # endregion

    # region Menu relations
    root.set_nodes(item_1, item_2, item_3, item_4, item_5, item_6, item_0)
    item_4.set_nodes(item_4_1, item_4_2, item_4_3, item_4_4)
    # endregion

    return root
Esempio n. 18
0
 def buildMenu(self):
    for i in self.menus:
       currMenu = MenuItem()
       currMenu.name = i.name
       currMenu.folder = True
       if i.parent != None:
          currMenu.parent = i.parent.menuItem
       i.menuItem = currMenu
       self.menuItems.append(currMenu)
       for key, value in self.desktopEntries.items():
          if i.include(key, value.categories, 'Or', i.logic['Or']) and not value.noDisplay:
             newItem = MenuItem()
             newItem.parent = currMenu
             newItem.name = value.name
             newItem.command = value.command
             newItem.working = value.working
             newItem.icon = value.icon
             newItem.imported = True
             self.menuItems.append(newItem)
Esempio n. 19
0
def create_menu():
    root = toolMenu.MenuItem(None, "root", "Main menu", False)
    # region Main menu
    # region item_1 (Add flashcard menu)
    item_1 = toolMenu.MenuItem(root, "1", "1. Add flashcards", False)
    item_1_1 = toolMenu.MenuItem(item_1, "1_1", "1. Add a new flashcard", True)
    item_1_2 = toolMenu.MenuItem(item_1, "1_2", "2. Exit", True)
    # endregion
    # region item_2 (Practice flashcards menu)
    item_2 = toolMenu.MenuItem(root, "2", "2. Practice flashcards", True)
    item_2_y = toolMenu.MenuItem(item_2, "2_y", 'press "y" to see the answer:', True)
    item_2_n = toolMenu.MenuItem(item_2, "2_n", 'press "n" to skip:', True)
    # region Item_2_yn (Check answer menu)
    item_2_yn_y = toolMenu.MenuItem(item_2_y, "2_yn_y", 'press "y" if your answer is correct:', True)
    item_2_yn_n = toolMenu.MenuItem(item_2_y, "2_yn_n", 'press "n" if your answer is wrong:', True)
    # end region
    item_2_u = toolMenu.MenuItem(item_2, "2_u", 'press "u" to update:', False)
    # region Item_2_u (Update flashcard menu)
    item_2_u_d = toolMenu.MenuItem(item_2_u, "2_u_d", 'press "d" to delete the flashcard:', True)
    item_2_u_e = toolMenu.MenuItem(item_2_u, "2_u_e", 'press "e" to edit the flashcard:', True)
    # endregion
    # end region
    # endregion
    # endregion
    # region item_3 (Exit)
    item_3 = toolMenu.MenuItem(root, "3", "3. Exit", True)
    # endregion

    # region Menu relations
    # region root (Main menu relations)
    root.set_nodes(item_1, item_2, item_3)
    # endregion)
    # region item_1 (Add flashcards menu relationships)
    item_1.set_nodes(item_1_1, item_1_2)
    # endregion
    # region item_2 (Practice flashcards menu relationships)
    item_2.set_nodes(item_2_y, item_2_n, item_2_u)
    item_2_y.set_nodes(item_2_yn_y, item_2_yn_n)
    item_2_n.set_nodes(item_2_yn_y, item_2_yn_n)
    # region item_2_u (Update flashcard menu relationships)
    item_2_u.set_nodes(item_2_u_d, item_2_u_e)
    # endregion
    # endregion
    # endregion

    return root
Esempio n. 20
0
 def addItem(self, name, description, vegetarian, price):
     menuItem = MenuItem.MenuItem(name, description, vegetarian, price)
     self._menuItems.append(menuItem)
Esempio n. 21
0
 def addItem(self, name, description, vegetarian, price):
     if len(self._menuItems) >= self._maxItems:
         print("Sorry, menu is full! Can't add item to menu")
     else:
         menuItem = MenuItem.MenuItem(name, description, vegetarian, price)
         self._menuItems.append(menuItem)
Esempio n. 22
0
 def addItem(self, name, description, vegetarian, price):
     menuItem = MenuItem.MenuItem(name, description, vegetarian, price)
     self._menuItems[menuItem.name] = menuItem
Esempio n. 23
0
import MenuItem

# creating the dummy menu

# drinks
water = MenuItem.MenuItem("free water", 0.00)
coca_cola = MenuItem.MenuItem("coke", 1.00)
sprite = MenuItem.MenuItem("sprite", 1.00)
sweet_tea = MenuItem.MenuItem("sweet tea", 1.00)
punch = MenuItem.MenuItem("punch", 1.00)

# food
bread = MenuItem.MenuItem("starter bread", 0.00)
pizza = MenuItem.MenuItem("pizza", 5.00)
lasagna = MenuItem.MenuItem("lasagna", 5.00)
hamburger = MenuItem.MenuItem("hamburger", 5.00)
cheese_burger = MenuItem.MenuItem("cheese burger", 5.00)
steak = MenuItem.MenuItem("steak", 5.00)