def __init__(self, theMap, isHost): super(Model, self).__init__() self.theMap = theMap self.openEditor = False self.sendNetMessage = False self.starting = False self.bg = pygame.Surface(SCREEN_SIZE) self.bg.fill(CHARACTER_SELECT_BG_COLOR) self.group = CharacterPanelGroup(self.theMap.numOfCharactersPerTeam()) self.currSelected = None x = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[0] y = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[1] self.selectionBorder = pygame.Surface((x, y)) self.selectionBorder.fill(CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR) tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE) tempRect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECT_GROUP_FROM_TOP tempRect.centerx = SCREEN_SIZE[0] / 2 self.clientPanel = PlayerPanel(tempRect, "Client", self.group.num) tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE) tempRect.bottom = self.clientPanel.rect.top - CHARACTER_SELECT_GROUP_SPACING tempRect.centerx = SCREEN_SIZE[0] / 2 self.hostPanel = PlayerPanel(tempRect, "Host", self.group.num) if isHost: self.myPanel = self.hostPanel self.theirPanel = self.clientPanel else: self.myPanel = self.clientPanel self.theirPanel = self.hostPanel tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE) tempRect.left = self.myPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING tempRect.top = self.myPanel.rect.top self.readyButton = Button(tempRect, "Ready") if isHost: tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE) tempRect.left = self.theirPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING tempRect.top = self.theirPanel.rect.top self.startButton = Button(tempRect, "Start") else: self.startButton = None x = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[0] y = (CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[1] self.selectionBorderButton = pygame.Surface((x, y)) self.selectionBorderButton.fill(CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR) self.loadingImage = INTERFACE_GRAPHICS[9] self.loadingRect = Rect((0, 0), self.loadingImage.get_size()) self.loadingRect.center = (SCREEN_SIZE[0] / 2, SCREEN_SIZE[1] / 2)
def __init__(self, num): self.num = num numOfCols = int(math.ceil(float(num) / float(CHARACTER_SELECT_PANELS_PER_COL))) numOfPanelsInCol = [] for i in range(numOfCols): numOfPanelsInCol.append(0) count = 0 currCol = 0 while count < num: numOfPanelsInCol[currCol] += 1 count += 1 currCol += 1 if currCol == numOfCols: currCol = 0 self.characterPanels = [] for i in range(len(numOfPanelsInCol)): colMid = (SCREEN_SIZE[0] / (len(numOfPanelsInCol) + 1)) * (i + 1) for j in range(numOfPanelsInCol[i]): rect = Rect((0, 0), CHARACTER_SELECT_PANEL_SIZE) rect.centerx = colMid rect.top = CHARACTER_SELECT_GROUP_FROM_TOP + ( (CHARACTER_SELECT_PANEL_SIZE[1] + CHARACTER_SELECT_GROUP_SPACING) * j ) self.characterPanels.append(CharacterPanel(rect, None))
def __init__(self, num): self.num = num numOfCols = int( math.ceil(float(num) / float(CHARACTER_SELECT_PANELS_PER_COL))) numOfPanelsInCol = [] for i in range(numOfCols): numOfPanelsInCol.append(0) count = 0 currCol = 0 while count < num: numOfPanelsInCol[currCol] += 1 count += 1 currCol += 1 if currCol == numOfCols: currCol = 0 self.characterPanels = [] for i in range(len(numOfPanelsInCol)): colMid = (SCREEN_SIZE[0] / (len(numOfPanelsInCol) + 1)) * (i + 1) for j in range(numOfPanelsInCol[i]): rect = Rect((0, 0), CHARACTER_SELECT_PANEL_SIZE) rect.centerx = colMid rect.top = (CHARACTER_SELECT_GROUP_FROM_TOP + ((CHARACTER_SELECT_PANEL_SIZE[1] + CHARACTER_SELECT_GROUP_SPACING) * j)) self.characterPanels.append(CharacterPanel(rect, None))
def createButtons(self, itemWidth, marginWidth, spacingWidth, items, itemMatrix): self.buttons = [] for row in range(itemMatrix[1]): for col in range(itemMatrix[0]): itemIndex = (itemMatrix[0] * row) + col if (itemIndex >= len(items)): return item = items[itemIndex] xPos = (itemWidth * col) + (spacingWidth * (col)) + marginWidth yPos = (itemWidth * row) + (spacingWidth * (row)) + marginWidth rect = Rect((xPos, yPos), (itemWidth, itemWidth)) if (isinstance(item, mapchar.MapChar)): images = [] icons = [item.images[0][0], item.images[1][0]] for i in range(len(icons)): icon = icons[i] iconRect = Rect((0, 0), icon.get_size()) iconRect.centerx = (rect.width / 2) iconRect.centery = (rect.height / 2) surface = pygame.Surface(rect.size) surface.fill(CHARACTER_SELECTION_DIALOG_BUTTON_COLOR) surface.blit(icon, iconRect.topleft) images.append(surface) self.buttons.append( DetailDialogButton(rect, images[0], images[1], item))
def createButtons(self, itemWidth, marginWidth, spacingWidth, items, itemMatrix): self.buttons = [] for row in range(itemMatrix[1]): for col in range(itemMatrix[0]): itemIndex = (itemMatrix[0] * row) + col if (itemIndex >= len(items)): return item = items[itemIndex] xPos = (itemWidth * col) + (spacingWidth * (col)) + marginWidth yPos = (itemWidth * row) + (spacingWidth * (row)) + marginWidth rect = Rect((xPos, yPos), (itemWidth, itemWidth)) if (isinstance(item, mapchar.MapChar)): images = [] icons = [item.images[0][0], item.images[1][0]] for i in range(len(icons)): icon = icons[i] iconRect = Rect((0, 0), icon.get_size()) iconRect.centerx = (rect.width / 2) iconRect.centery = (rect.height / 2) surface = pygame.Surface(rect.size) surface.fill(CHARACTER_SELECTION_DIALOG_BUTTON_COLOR) surface.blit(icon, iconRect.topleft) images.append(surface) self.buttons.append(DetailDialogButton(rect, images[0], images[1], item))
def selectMap(self, map, wasRandom): self.mapPanel.setData(MapData(map, wasRandom)) numOfCharacterSlots = 0 if not map is None: numOfCharacterSlots = len(map.startingPoints[0]) self.characterPanels = [] for i in range(2): xMid = (SCREEN_SIZE[0] / 4) * (1 + (i * 2)) yMid = SCREEN_SIZE[1] / 2 if (numOfCharacterSlots % 2 == 0): numToDisplaceFromCenter = (numOfCharacterSlots / 2) - 1 yMid -= (CHARACTER_SELECTION_PANEL_SPACING / 2) + (CHARACTER_SELECTION_PANEL_SIZE[1] / 2) else: numToDisplaceFromCenter = int(numOfCharacterSlots / 2) yMid -= ( CHARACTER_SELECTION_PANEL_SPACING + CHARACTER_SELECTION_PANEL_SIZE[1]) * numToDisplaceFromCenter for j in range(numOfCharacterSlots): rect = Rect((0, 0), CHARACTER_SELECTION_PANEL_SIZE) rect.centerx = xMid rect.centery = yMid + ((CHARACTER_SELECTION_PANEL_SPACING + CHARACTER_SELECTION_PANEL_SIZE[1]) * j) self.characterPanels.append( Panel(i, (self.playerNum == i), rect)) rect = rect = Rect((0, 0), READY_PANEL_SIZE) rect.centerx = xMid rect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECTION_PANEL_SPACING readyPanel = Panel(i, (self.playerNum == i), rect) readyPanel.faceUp = True readyPanel.setData(ReadyData(False)) self.readyPanels[i] = readyPanel self.subScreen = 0
def createGoPanel(self): if (self.playerNum == 0 and (not self.readyPanels[0] is None and self.readyPanels[0].data.value == True) and (not self.readyPanels[1] is None and self.readyPanels[1].data.value == True)): rect = Rect((0,0), GO_PANEL_SIZE) rect.centerx = SCREEN_SIZE[0] / 2 rect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECTION_PANEL_SPACING goPanel = Panel(0, True, rect) goPanel.setData(GoData()) self.goPanel = goPanel
def selectMap(self, map, wasRandom): self.mapPanel.setData(MapData(map, wasRandom)) numOfCharacterSlots = 0 if not map is None: numOfCharacterSlots = len(map.startingPoints[0]) self.characterPanels = [] for i in range(2): xMid = (SCREEN_SIZE[0] / 4) * (1 + (i * 2)) yMid = SCREEN_SIZE[1] / 2 if (numOfCharacterSlots % 2 == 0): numToDisplaceFromCenter = (numOfCharacterSlots / 2) - 1 yMid -= (CHARACTER_SELECTION_PANEL_SPACING / 2) + (CHARACTER_SELECTION_PANEL_SIZE[1] / 2) else: numToDisplaceFromCenter = int(numOfCharacterSlots / 2) yMid -= (CHARACTER_SELECTION_PANEL_SPACING + CHARACTER_SELECTION_PANEL_SIZE[1]) * numToDisplaceFromCenter for j in range(numOfCharacterSlots): rect = Rect((0,0), CHARACTER_SELECTION_PANEL_SIZE) rect.centerx = xMid rect.centery = yMid + ((CHARACTER_SELECTION_PANEL_SPACING + CHARACTER_SELECTION_PANEL_SIZE[1]) * j) self.characterPanels.append(Panel(i, (self.playerNum == i), rect)) rect = rect = Rect((0,0), READY_PANEL_SIZE) rect.centerx = xMid rect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECTION_PANEL_SPACING readyPanel = Panel(i, (self.playerNum == i), rect) readyPanel.faceUp = True readyPanel.setData(ReadyData(False)) self.readyPanels[i] = readyPanel self.subScreen = 0
def createGoPanel(self): if (self.playerNum == 0 and (not self.readyPanels[0] is None and self.readyPanels[0].data.value == True) and (not self.readyPanels[1] is None and self.readyPanels[1].data.value == True)): rect = Rect((0, 0), GO_PANEL_SIZE) rect.centerx = SCREEN_SIZE[0] / 2 rect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECTION_PANEL_SPACING goPanel = Panel(0, True, rect) goPanel.setData(GoData()) self.goPanel = goPanel
def __init__(self, theMap, isHost): super(Model, self).__init__() self.theMap = theMap self.openEditor = False self.sendNetMessage = False self.starting = False self.bg = pygame.Surface(SCREEN_SIZE) self.bg.fill(CHARACTER_SELECT_BG_COLOR) self.group = CharacterPanelGroup(self.theMap.numOfCharactersPerTeam()) self.currSelected = None x = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[0]) y = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_PANEL_SIZE[1]) self.selectionBorder = pygame.Surface((x, y)) self.selectionBorder.fill( CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR) tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE) tempRect.bottom = SCREEN_SIZE[1] - CHARACTER_SELECT_GROUP_FROM_TOP tempRect.centerx = SCREEN_SIZE[0] / 2 self.clientPanel = PlayerPanel(tempRect, "Client", self.group.num) tempRect = Rect((0, 0), CHARACTER_SELECT_PLAYER_SIZE) tempRect.bottom = (self.clientPanel.rect.top - CHARACTER_SELECT_GROUP_SPACING) tempRect.centerx = SCREEN_SIZE[0] / 2 self.hostPanel = PlayerPanel(tempRect, "Host", self.group.num) if isHost: self.myPanel = self.hostPanel self.theirPanel = self.clientPanel else: self.myPanel = self.clientPanel self.theirPanel = self.hostPanel tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE) tempRect.left = self.myPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING tempRect.top = self.myPanel.rect.top self.readyButton = Button(tempRect, "Ready") if isHost: tempRect = Rect((0, 0), CHARACTER_SELECT_BUTTON_SIZE) tempRect.left = (self.theirPanel.rect.right + CHARACTER_SELECT_GROUP_SPACING) tempRect.top = self.theirPanel.rect.top self.startButton = Button(tempRect, "Start") else: self.startButton = None x = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[0]) y = ((CHARACTER_SELECT_PANEL_SELECTION_BORDER_WIDTH * 2) + CHARACTER_SELECT_BUTTON_SIZE[1]) self.selectionBorderButton = pygame.Surface((x, y)) self.selectionBorderButton.fill( CHARACTER_SELECT_PANEL_SELECTION_BORDER_COLOR) self.loadingImage = INTERFACE_GRAPHICS[9] self.loadingRect = Rect((0, 0), self.loadingImage.get_size()) self.loadingRect.center = (SCREEN_SIZE[0] / 2, SCREEN_SIZE[1] / 2)
def update(self): if (self.redraw): #Draw Panel Surface if (self.data is None or (isinstance(self.data, ReadyData) and self.data.value == False)): paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_OFF paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_OFF else: paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_ON paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_ON colorBase = paletteBase[self.team] colorDecor = paletteDecor[self.team] self.image = pygame.Surface(self.rect.size) self.image.fill(colorBase) showFront = self.faceUp or self.isOwner if (showFront): decorMargin = CHARACTER_SELECT_PANEL_FACE_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_FACE_DECOR_WIDTH else: decorMargin = CHARACTER_SELECT_PANEL_BACK_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_BACK_DECOR_WIDTH decorOuter = pygame.Surface((self.rect.width - (decorMargin * 2), self.rect.height - (decorMargin * 2))) decorOuter.fill(colorDecor) decorInner = pygame.Surface( (decorOuter.get_size()[0] - (decorWidth * 2), decorOuter.get_size()[1] - (decorWidth * 2))) decorInner.fill(colorBase) if (not showFront): margins = CHARACTER_SELECT_PANEL_BACK_CIRCLE_MARGINS ovalRect = Rect((margins[0], margins[1]), (decorInner.get_size()[0] - (margins[0] * 2), decorInner.get_size()[1] - (margins[1] * 2))) pygame.draw.ellipse(decorInner, colorDecor, ovalRect) decorOuter.blit(decorInner, (decorWidth, decorWidth)) self.image.blit(decorOuter, (decorMargin, decorMargin)) #Fill Data fillRect = Rect( ((decorWidth + decorMargin), (decorWidth + decorMargin)), decorInner.get_size()) if isinstance(self.data, mapchar.MapChar): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect( self.data.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) speciesImage = self.data.getSmallImage() speciesRect = Rect((0, 0), speciesImage.get_size()) speciesRect.right = tRect.right speciesRect.centery = self.rect.height / 2 self.image.blit(speciesImage, speciesRect.topleft) elif isinstance(self.data, MapData): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect( self.data.map.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) if self.data.wasRandom: image = RANDOM_ICON rect = Rect((0, 0), image.get_size()) rect.right = fillRect.right rect.centery = fillRect.centery self.image.blit(image, rect.topleft) elif isinstance(self.data, ReadyData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery if self.data.value: color = READY_PANEL_FONT_COLOR_TRUE text = "READY" else: color = READY_PANEL_FONT_COLOR_FALSE text = "PREPARING..." text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) if isinstance(self.data, GoData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0, 0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery color = READY_PANEL_FONT_COLOR_TRUE text = "GO!" text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) self.redraw = False
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 update(self): if (self.redraw): #Draw Panel Surface if (self.data is None or (isinstance(self.data, ReadyData) and self.data.value == False)): paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_OFF paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_OFF else: paletteBase = CHARACTER_SELECT_PANEL_BASE_COLORS_ON paletteDecor = CHARACTER_SELECT_PANEL_DECOR_COLORS_ON colorBase = paletteBase[self.team] colorDecor = paletteDecor[self.team] self.image = pygame.Surface(self.rect.size) self.image.fill(colorBase) showFront = self.faceUp or self.isOwner if (showFront): decorMargin = CHARACTER_SELECT_PANEL_FACE_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_FACE_DECOR_WIDTH else: decorMargin = CHARACTER_SELECT_PANEL_BACK_DECOR_MARGIN decorWidth = CHARACTER_SELECT_PANEL_BACK_DECOR_WIDTH decorOuter = pygame.Surface((self.rect.width - (decorMargin * 2), self.rect.height - (decorMargin * 2))) decorOuter.fill(colorDecor) decorInner = pygame.Surface((decorOuter.get_size()[0] - (decorWidth * 2), decorOuter.get_size()[1] - (decorWidth * 2))) decorInner.fill(colorBase) if (not showFront): margins = CHARACTER_SELECT_PANEL_BACK_CIRCLE_MARGINS ovalRect = Rect((margins[0], margins[1]), (decorInner.get_size()[0] - (margins[0] * 2), decorInner.get_size()[1] - (margins[1] * 2))) pygame.draw.ellipse(decorInner, colorDecor, ovalRect) decorOuter.blit(decorInner, (decorWidth, decorWidth)) self.image.blit(decorOuter, (decorMargin, decorMargin)) #Fill Data fillRect = Rect(((decorWidth + decorMargin), (decorWidth + decorMargin)), decorInner.get_size()) if isinstance(self.data, mapchar.MapChar): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect(self.data.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) speciesImage = self.data.getSmallImage() speciesRect = Rect((0, 0), speciesImage.get_size()) speciesRect.right = tRect.right speciesRect.centery = self.rect.height / 2 self.image.blit(speciesImage, speciesRect.topleft) elif isinstance(self.data, MapData): font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery text = textrect.render_textrect(self.data.map.name, font, tRect, CHARACTER_SELECTION_FONT_COLOR, ALMOST_BLACK, 0, True) self.image.blit(text, tRect.topleft) if self.data.wasRandom: image = RANDOM_ICON rect = Rect((0,0), image.get_size()) rect.right = fillRect.right rect.centery = fillRect.centery self.image.blit(image, rect.topleft) elif isinstance(self.data, ReadyData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery if self.data.value: color = READY_PANEL_FONT_COLOR_TRUE text = "READY" else: color = READY_PANEL_FONT_COLOR_FALSE text = "PREPARING..." text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) if isinstance(self.data, GoData): font = CHARACTER_SELECTION_CAPTION_FONT font = CHARACTER_SELECTION_CAPTION_FONT textHeight = font.get_linesize() + 2 tRect = Rect((0,0), (fillRect.width - 10, textHeight)) tRect.centerx = fillRect.centerx tRect.centery = fillRect.centery color = READY_PANEL_FONT_COLOR_TRUE text = "GO!" text = textrect.render_textrect(text, font, tRect, color, ALMOST_BLACK, 1, True) self.image.blit(text, tRect.topleft) self.redraw = False
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