示例#1
0
 def InitGame():
     def SetCaffeine(vis):
         graphics.CAFFEINE = vis
     submenu_list = collections.OrderedDict()
     submenu_list['CAFFEINE'] = lambda: SetCaffeine(True)
     submenu_list['Sane'] = lambda: SetCaffeine(False)
     
     main_menu_list = {'Start Game':(lambda : BoardFrame()), 'Menu Skin': submenu_list, 'Exit': (lambda : exit(0))}
     mainMenu = MenuFrame(main_menu_list, GAME_NAME, fontSizeTitle=50, fontSize=30, displayItems = 4)
     stack.append(mainMenu)
示例#2
0
 def _ResolveSelection(self, keySelected, valueSelected):
     if isinstance(valueSelected, dict):
         stack.append(MenuFrame(valueSelected, keySelected, self.position, self.fontSizeTitle, self.fontSize,
                                self.displayItems))
     elif isinstance(valueSelected, StateFrame):
         stack.append(valueSelected)
     elif valueSelected == 'back':
         self.KillSelf()
     else:
         try:
             output = valueSelected()
             self._ResolveSelection(keySelected, output)
         except TypeError:
             if not valueSelected:
                 # what if the option function added a StackFrame? we need to be careful here
                 removeIdx = stack.index(self)
                 while len(stack) > 1 and removeIdx >= 0 and isinstance(stack[removeIdx], MenuFrame):
                     stack[removeIdx].KillSelf()
                     removeIdx -= 1
示例#3
0
 def Show(options, title=None, position = (20, 40), fontSize=16, fontSizeTitle=24, displayItems = None):
     frame = MenuFrame(options, title, position, fontSizeTitle, fontSize, displayItems)
     stack.append(frame)
     return frame
示例#4
0
        if self.empty:
            self.options["A pocketful of wishes"] = 'back'
        else:
            self.options['Back'] = 'back'
        
    def _UseItem(self, creature):
        msg = self.item.Apply(creature, True, self.player, self.npc)
        self._DropItem()
        DialogueFrame(msg).Show()

if __name__ == '__main__':
    import board
    import entity
    import main
    import stateframe

    from stateframe import FrameUpdate, stack

    board = board.Board('test')
    player = entity.Player('hobo', (0,0), board)
    player.AddCreature
    player.AddItem(entity.POSSIBLE_INVENTORY_ITEMS['spiked drink'][0])
    player.AddItem(entity.POSSIBLE_INVENTORY_ITEMS['thunderbird'][0])
    player.AddItem(entity.POSSIBLE_INVENTORY_ITEMS['thunderbird'][0])
    player.AddItem(entity.POSSIBLE_INVENTORY_ITEMS['speed'][0])

    stack.append(InventoryFrame(player))
    win = main.Window('ItemFrame test')
    win.run(FrameUpdate)