def __init__(self, isHost): super(Model, self).__init__() self.bgs = [ scrollingbackground.ScrollingBackground(Rect( (0, 0), SCREEN_SIZE), CHARACTER_SELECT_BG_SKY, [0, 0]), scrollingbackground.ScrollingBackground( Rect((0, SCREEN_SIZE[1] - CHARACTER_SELECT_BG_MOUNTAINS_FAR.get_size()[1] - 70), SCREEN_SIZE), CHARACTER_SELECT_BG_MOUNTAINS_FAR, [-0.3, 0]), scrollingbackground.ScrollingBackground( Rect((0, SCREEN_SIZE[1] - CHARACTER_SELECT_BG_MOUNTAINS_NEAR.get_size()[1]), SCREEN_SIZE), CHARACTER_SELECT_BG_MOUNTAINS_NEAR, [-0.8, 0]) ] self.starting = False self.map = None self.netMessage = None self.subScreen = 0 if isHost: self.playerNum = 0 else: self.playerNum = 1 #Create Map-selection Panel rect = Rect((0, 0), CHARACTER_SELECTION_PANEL_SIZE) rect.centerx = SCREEN_SIZE[0] / 2 rect.top = CHARACTER_SELECTION_PANEL_SPACING self.mapPanel = Panel(0, isHost, rect) self.characterPanels = [] tempRect = Rect((50, 50), (200, 0)) menuOptions = [] for map in gamemap.getMapList(): menuOptions.append(map.name + " (" + str(len(map.startingPoints[0])) + ")") menuOptions.append("<RANDOM>") self.mapMenu = minimenu.MiniMenu(tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.mapMenu.center(ENTIRE_SCREEN, True, True) #Create Species Selection Menu speciesClasses = [(mapchar.Hare, hare.Hare), (mapchar.Cat, cat.Cat)] speciesList = [] for speciesClassGroup in speciesClasses: mapClass = speciesClassGroup[0] battleClass = speciesClassGroup[1] speciesList.append(mapClass(self.playerNum, battleClass())) self.speciesDialog = DetailDialog(SPECIES_SELECTION_DIALOG_SLOT_SIZE, SPECIES_SELECTION_DIALOG_MARGIN, SPECIES_SELECTION_DIALOG_SPACING, speciesList, [4, 2]) self.currCharacterPanel = None self.readyPanels = [None, None] self.goPanel = None
def __init__(self, isHost): super(Model, self).__init__() self.bgs = [scrollingbackground.ScrollingBackground(Rect((0, 0), SCREEN_SIZE), CHARACTER_SELECT_BG_SKY, [0, 0]), scrollingbackground.ScrollingBackground(Rect((0, SCREEN_SIZE[1] - CHARACTER_SELECT_BG_MOUNTAINS_FAR.get_size()[1] - 70), SCREEN_SIZE), CHARACTER_SELECT_BG_MOUNTAINS_FAR, [-0.3, 0]), scrollingbackground.ScrollingBackground(Rect((0, SCREEN_SIZE[1] - CHARACTER_SELECT_BG_MOUNTAINS_NEAR.get_size()[1]), SCREEN_SIZE), CHARACTER_SELECT_BG_MOUNTAINS_NEAR, [-0.8, 0]) ] self.starting = False self.map = None self.netMessage = None self.subScreen = 0 if isHost: self.playerNum = 0 else: self.playerNum = 1 #Create Map-selection Panel rect = Rect((0,0), CHARACTER_SELECTION_PANEL_SIZE) rect.centerx = SCREEN_SIZE[0] / 2 rect.top = CHARACTER_SELECTION_PANEL_SPACING self.mapPanel = Panel(0, isHost, rect) self.characterPanels = [] tempRect = Rect( (50, 50), (200, 0) ) menuOptions = [] for map in gamemap.getMapList(): menuOptions.append(map.name + " (" + str(len(map.startingPoints[0])) + ")") menuOptions.append("<RANDOM>") self.mapMenu = minimenu.MiniMenu(tempRect, menuOptions, MAIN_MENU_FONT, MAIN_MENU_COLOR_ON, MAIN_MENU_COLOR_OFF, MAIN_MENU_COLOR_BG) self.mapMenu.center(ENTIRE_SCREEN, True, True) #Create Species Selection Menu speciesClasses = [(mapchar.Hare, hare.Hare), (mapchar.Cat, cat.Cat)] speciesList = [] for speciesClassGroup in speciesClasses: mapClass = speciesClassGroup[0] battleClass = speciesClassGroup[1] speciesList.append(mapClass(self.playerNum, battleClass())) self.speciesDialog = DetailDialog(SPECIES_SELECTION_DIALOG_SLOT_SIZE, SPECIES_SELECTION_DIALOG_MARGIN, SPECIES_SELECTION_DIALOG_SPACING, speciesList, [4, 2] ) self.currCharacterPanel = None self.readyPanels = [None, None] self.goPanel = None
def click(self): #No dialogs if self.subScreen == 0: if self.mapPanel.selected: self.subScreen = 1 #Map Sub-screen elif not self.readyPanels[ self.playerNum] is None and self.readyPanels[ self.playerNum].selected: self.readyPanels[self.playerNum].setData(ReadyData(True)) self.sendReadyMessage() self.subScreen = 10 self.createGoPanel() else: charPanel = None for panel in self.characterPanels: if panel.selected: charPanel = panel break if not charPanel is None: self.currCharacterPanel = charPanel self.subScreen = 2 #Map Selection Dialog elif self.subScreen == 1: mapSel = self.mapMenu.value() if (not self.mapMenu.noSelection) and (not mapSel is None): mapSel -= 1 maps = gamemap.getMapList() if (mapSel >= 0) and (mapSel < len(maps)): wasRandom = False else: wasRandom = True mapSel = random.randrange(len(maps)) map = maps[mapSel] self.selectMap(map, wasRandom) if wasRandom: wasRandomChar = "r" else: wasRandomChar = "s" self.netMessage = "m" + wasRandomChar + "{0:02d}".format( map.num) #Species Selection Dialog elif self.subScreen == 2: data = self.speciesDialog.getSelectedData() if not data is None: self.currCharacterPanel.setData(data) self.subScreen = 0 self.sendCharacterMessage() #Readied elif self.subScreen == 10: if not self.goPanel is None and self.goPanel.selected: self.starting = True self.netMessage = "s---" elif not self.readyPanels[ self.playerNum] is None and self.readyPanels[ self.playerNum].selected: self.readyPanels[self.playerNum].setData(ReadyData(False)) self.sendReadyMessage() self.subScreen = 0 self.goPanel = None
def click(self): #No dialogs if self.subScreen == 0: if self.mapPanel.selected: self.subScreen = 1 #Map Sub-screen elif not self.readyPanels[self.playerNum] is None and self.readyPanels[self.playerNum].selected: self.readyPanels[self.playerNum].setData(ReadyData(True)) self.sendReadyMessage() self.subScreen = 10 self.createGoPanel() else: charPanel = None for panel in self.characterPanels: if panel.selected: charPanel = panel break if not charPanel is None: self.currCharacterPanel = charPanel self.subScreen = 2 #Map Selection Dialog elif self.subScreen == 1: mapSel = self.mapMenu.value() if (not self.mapMenu.noSelection) and (not mapSel is None): mapSel -= 1 maps = gamemap.getMapList() if (mapSel >= 0) and (mapSel < len(maps)): wasRandom = False else: wasRandom = True mapSel = random.randrange(len(maps)) map = maps[mapSel] self.selectMap(map, wasRandom) if wasRandom: wasRandomChar = "r" else: wasRandomChar = "s" self.netMessage = "m" + wasRandomChar + "{0:02d}".format(map.num) #Species Selection Dialog elif self.subScreen == 2: data = self.speciesDialog.getSelectedData() if not data is None: self.currCharacterPanel.setData(data) self.subScreen = 0 self.sendCharacterMessage() #Readied elif self.subScreen == 10: if not self.goPanel is None and self.goPanel.selected: self.starting = True self.netMessage = "s---" elif not self.readyPanels[self.playerNum] is None and self.readyPanels[self.playerNum].selected: self.readyPanels[self.playerNum].setData(ReadyData(False)) self.sendReadyMessage() self.subScreen = 0 self.goPanel = None