def __init__(self, pokemon, battle, screen): """ Initialize the Battle Round Controller """ self.pokemon = pokemon self.battle = battle self.action = None entries = [ TextMenuEntry("Fight", self.chooseAttack), TextMenuEntry("Switch", self.switch), TextMenuEntry("Item", None), TextMenuEntry("Run", None) ] self.menu = Menu(entries, columns=2) self.view = ActionMenuWidget(self.menu, self.getWindow().width * .9, self.getWindow().height * .3) screen.setBottomView(self.view) cmds = { commands.UP: self.menu.up, commands.DOWN: self.menu.down, commands.LEFT: self.menu.left, commands.RIGHT: self.menu.right, commands.SELECT: self.menu.enter } PygameController.__init__(self, screen, commands=cmds)
def __init__(self): """ """ self.running = True self.heading = "Key Bindings" self.back = TextMenuEntry("Back", self.quit) self.back.select() self.keyBindings = self.getBoundKeyStrings()
def setUp(self): """ Build the Menu and Entries for the test """ self.menu = Menu() self.firstEntry = TextMenuEntry("1", None) self.secondEntry = TextMenuEntry("2", None) self.thirdEntry = TextMenuEntry("3", None) self.menu.entries = [ self.firstEntry, self.secondEntry, self.thirdEntry ] self.menu.selectEntry()
class OptionsMenu(): """ Class to represent the options menu """ cmdStrings = {commands.EXIT:"Exit", commands.UP:"Up", commands.DOWN:"Down", commands.LEFT:"Left", commands.RIGHT:"Right", commands.SELECT:"Select", commands.CANCEL:"Cancel"} def __init__(self): """ """ self.running = True self.heading = "Key Bindings" self.back = TextMenuEntry("Back", self.quit) self.back.select() self.keyBindings = self.getBoundKeyStrings() def getBoundKeyStrings(self): """ Strings for Bound Keys """ boundKeys = {commands.EXIT:[], commands.UP:[], commands.DOWN:[], commands.LEFT:[], commands.RIGHT:[], commands.SELECT:[], commands.CANCEL:[]} for key in bindings.keyBindings: boundKeys[bindings.keyBindings[key]].append(bindings.keyStrings[key]) commandKeys = [] for cmd in boundKeys: s = "" for binding in boundKeys[cmd]: s += binding if not binding == boundKeys[cmd][-1]: s += ", " commandKeys.append(s) return commandKeys def quit(self, entry): """ Quits the Open Menu """ self.running = False
def __init__(self): """ Builds the Main Menu Controller """ entries = [ TextMenuEntry("Start", self.startGame), TextMenuEntry("Options", self.runOptions), TextMenuEntry("Exit", self.stopRunning) ] self.menu = Menu(entries) screen = MainMenuScreen(self.menu) cmds = { KAO_UP: self.menu.up, KAO_DOWN: self.menu.down, ENDL: self.menu.enter } ConsoleController.__init__(self, screen, commands=cmds)
def __init__(self, currentPlayer): """ Initialize the Mode Menu Controller """ self.currentPlayer = currentPlayer entries = [ TextMenuEntry("Story", self.playStory), TextMenuEntry("Marathon", self.runMarathon), TextMenuEntry("Back", self.stopRunning) ] self.menu = Menu(entries) screen = MainMenuScreen(self.menu, self.currentPlayer) PygameController.__init__(self, screen, commands={ commands.UP: self.menu.up, commands.DOWN: self.menu.down, commands.EXIT: self.stopRunning, commands.SELECT: self.menu.enter })
def __init__(self, pokemon, battle): """ Builds the Action Controller """ self.pokemon = pokemon self.battle = battle self.action = None entries = [TextMenuEntry("Fight", self.chooseAttack), TextMenuEntry("Switch", self.switch), TextMenuEntry("Item", None), TextMenuEntry("Run", None)] self.menu = Menu(entries, columns=2) screen = ActionMenuScreen(self.menu, battle) cmds = {ENDL:self.menu.enter, KAO_UP:self.menu.up, KAO_DOWN:self.menu.down, KAO_RIGHT:self.menu.right, KAO_LEFT:self.menu.left} ConsoleController.__init__(self, screen, commands=cmds)
def __init__(self): """ Initialize the Main Menu Controller """ self.currentPlayer = PlayerFactory.getLastPlayer() entries = [TextMenuEntry("New", self.newGame), TextMenuEntry("Options", self.runOptions), TextMenuEntry("Exit", self.stopRunning)] self.menu = Menu(entries) if self.currentPlayer is not None: continueMenuEntry = TextMenuEntry("Continue", self.continueGame) entries.insert(1, continueMenuEntry) self.menu.down() screen = MainMenuScreen(self.menu, self.currentPlayer) PygameController.__init__(self, screen, commands = {commands.UP:self.menu.up, commands.DOWN:self.menu.down, commands.EXIT:self.stopRunning, commands.SELECT:self.menu.enter})
def __init__(self, lastController): """ Initialize the Zone Menu Controller """ entries = [TextMenuEntry("Exit", self.exitZone)] self.menu = Menu(entries) self.lastController = lastController screen = ZoneMenuScreen(self.menu, lastController.screen) PygameController.__init__(self, screen, commands={ commands.UP: self.menu.up, commands.DOWN: self.menu.down, commands.EXIT: self.stopRunning, commands.SELECT: self.menu.enter })