def __init__(self, screen_size, actor_list, color=None): border_gap = 50 box_size = pygame.Rect(border_gap, border_gap, screen_size[0] - border_gap * 2, screen_size[1] - border_gap * 2) Box.__init__(self, box_size, color) self.actor_list = actor_list self.options = SelectBox(box_bounds=pygame.Rect( (box_size.width / 3) * 2, box_size.top, box_size.width / 3 - border_gap, box_size.height - border_gap * 2), color=(80, 80, 150)) self.options.options = [{ "NAME": "Stats", "ACT": "PASS" }, { "NAME": "Order", "ACT": "PASS" }, { "NAME": "Items", "ACT": "PASS" }, { "NAME": "Save", "ACT": "SAVE" }, { "NAME": "Exit", "ACT": "EXIT" }] self.options.open()
def draw(self, screen): if self.visible: if self.background: screen.blit(self.background, (0, 0)) self.overlay.fill(self.color) if self.portrait: portrait_offset = 150 + self.space self.overlay.blit(self.portrait, (self.space, (self.inner_box.height - 150) / 2)) else: portrait_offset = 0 # text i = 0 for text in self.text: if i < 5: text_offset = self.font_size * 1.3 * i self.overlay.blit( self.font.render(text, True, self.white), (portrait_offset + self.space, (self.inner_box.height - 150) / 2 + text_offset)) i += 1 if self.choice: self.overlay.fill(self.white, self.choice_box) self.overlay.fill(self.color, self.choice_inner_box) self.overlay.blit(self.font.render("Yes", True, self.white), (self.choice_inner_box.left + self.space, self.choice_inner_box.top + self.space)) self.overlay.blit(self.font.render("No", True, self.white), (self.choice_inner_box.left + self.space, self.choice_inner_box.top + self.space * 2 + self.font_size)) Box.draw(self, screen)
def draw(self, screen): self.overlay.fill(self.color) self.options.draw(self.overlay) y_offset = 0 for actor in self.actor_list: self.draw_profile(character=actor, y_pos=20 + y_offset, color=(80, 80, 250)) y_offset += 200 Box.draw(self, screen)
def draw(self, screen): if self.visible: self.overlay.fill(self.color) if self.options: for o in self.options: position = self.inner_box.top + (self.options.index(o) * self.cursor_offset) self.overlay.blit(self.font.render(o["NAME"], True, self.white), (self.cursor_offset + self.space*2, position + self.space)) self.overlay.blit(self.cursor, (self.space, self.position * self.cursor_offset + self.space)) Box.draw(self, screen)
def __init__(self, screen_size, text=None, color=None, font_size=None): if font_size is None: font_size = 24 box_height = font_size * 2 + 48 box_width = len(text) * font_size + 20 + 48 box_bounds = pygame.Rect(screen_size[0] / 2 - box_width / 2, screen_size[1] / 2 - box_height / 2, box_width, box_height) Box.__init__(self, box_bounds=box_bounds, color=color, font_size=font_size) self.text = text Box.open(self, color=color)
def open(self, text=None, portrait=None, color=None, choice=None, background=None): if text: self.text = text if portrait: self.portrait = self.get_image(portrait) if choice: self.choice = choice if background: self.background = self.get_image(background) Box.open(self, color)
def __init__(self, box_bounds, text=None, color=None, picture=None): Box.__init__(self, box_bounds, color) self.text = text self.portrait = self.get_image(picture) self.background = None self.choice = False self.choice_box = pygame.Rect(self.box.right - self.box.width / 3 - 10, self.box.top - 100, self.box.width / 3, self.font_size * 2 + self.space * 3) self.choice_inner_box = pygame.Rect( self.choice_box.left + self.border, self.choice_box.top + self.border, self.choice_box.width - self.border * 2, self.choice_box.height - self.border * 2)
def close(self): self.background = None self.portrait = None self.text = None Box.close(self)
def close(self): Box.close(self)
def draw(self, screen): if self.visible: self.overlay.fill(self.color) self.overlay.blit(self.font.render(self.text, True, self.white), (self.space, self.space)) Box.draw(self, screen)
def __init__(self, box_bounds, color=None): Box.__init__(self, box_bounds, color) self.options = [] self.position = 0
def open(self, color=None): Box.open(self, color)