def render_hover(self, game): surface = pygame.Surface((280, 186), pygame.SRCALPHA) surface.fill((0, 0, 0, 0)) if self.character is None: surface.blit( simple.draw_text("", self.font, (255, 255, 255), 280, True), (0, 0)) surface.blit( frame.draw_highlight_frame(280, 156, (255, 255, 255), seed=self.draw_seed), (0, 24)) else: surface.blit( simple.draw_text(self.character.name, self.font, (255, 255, 255), 280, True), (0, 0)) surface.blit( frame.draw_highlight_frame(280, 156, (255, 255, 255), seed=self.draw_seed), (0, 24)) surface.blit(simple.draw_image(self.character.portrait, 4), (4, 16)) surface.blit(simple.draw_image("image/ui/player_bar.png", 4), (132, 32)) surface.blit(simple.draw_image("image/ui/player_bar.png", 4), (132, 52)) return surface
def render_clicked(self, game): surface = frame.draw_highlight_frame(self.width, self.height, highlight=(0, 255, 0), seed=self.draw_seed) if self.move is None: return surface # Draw the move iself.mage icon_filename = self.move.icon if icon_filename: icon_surface = simple.draw_image(icon_filename, 6) else: icon_surface = simple.draw_image(ItemSlot.DEFAULTICON, 6) surface.blit(icon_surface, (self.width // 2 - icon_surface.get_width() // 2, 12)) # Text elements surface.blit( simple.draw_text(self.move.name.title(), self.title_font, (0, 255, 0), self.width - 24, justify="center"), (12, 100)) surface.blit( simple.draw_text(self.move.description, self.font, (0, 255, 0), self.width - 24, justify="center"), (12, 130)) return surface
def __init__(self, name, x, y, surface, scale=1): super().__init__(name, x, y) self.x = x self.y = y if isinstance(surface, str): self.surface = draw_image(surface, scale) else: self.surface = surface
def render_hover(self, game): surface = pygame.Surface((280, 186), pygame.SRCALPHA) surface.fill((0, 0, 0, 0)) if self.character is None: surface.blit(simple.draw_text("", self.font, (255, 255, 255), 280, True), (0, 0)) surface.blit(frame.draw_highlight_frame(280, 156, (255, 255, 255), seed=self.draw_seed), (0, 24)) else: surface.blit(simple.draw_text(self.character.name, self.font, (255, 255, 255), 280, True), (0, 0)) surface.blit(frame.draw_highlight_frame(280, 156, (255, 255, 255), seed=self.draw_seed), (0, 24)) surface.blit(simple.draw_image(self.character.portrait, 4), (4, 16)) surface.blit(simple.draw_image("image/ui/player_bar.png", 4), (132, 32)) surface.blit(simple.draw_image("image/ui/player_bar.png", 4), (132, 52)) return surface
def render_clicked(self, game): surface = frame.draw_highlight_frame(self.width, self.height, highlight=(0, 255, 0), seed=self.draw_seed) if self.move is None: return surface # Draw the move iself.mage icon_filename = self.move.icon if icon_filename: icon_surface = simple.draw_image(icon_filename, 6) else: icon_surface = simple.draw_image(ItemSlot.DEFAULTICON, 6) surface.blit(icon_surface, (self.width // 2 - icon_surface.get_width() // 2, 12)) # Text elements surface.blit(simple.draw_text(self.move.name.title(), self.title_font, (0, 255, 0), self.width - 24, justify="center"), (12, 100)) surface.blit(simple.draw_text(self.move.description, self.font, (0, 255, 0), self.width - 24, justify="center"), (12, 130)) return surface
def render_hover(self, game): surface = None monster_image = None if self.monster: if self.monster.graphic.get("hover"): try: filename = self.monster.graphic.get("hover") monster_image = simple.draw_image(filename, 4) except pygame.error: monster_image = simple.draw_rect(240, 80, (255, 255, 0)) logging.warning("Could not load: " + filename) else: monster_image = simple.draw_rect(240, 80, (255, 255, 0)) surface = pygame.Surface((monster_image.get_width(), monster_image.get_height() + 30), pygame.SRCALPHA) surface.fill((0, 0, 0, 0)) surface.blit(monster_image, (0, 30)) surface.blit(simple.draw_text(self.monster.name, self.font, (255, 255, 0), surface.get_width(), justify="center"), (0, 0)) return surface
def render_hover(self, game): surface = None monster_image = None if self.monster: if self.monster.graphic.get("hover"): try: filename = self.monster.graphic.get("hover") monster_image = simple.draw_image(filename, 4) except pygame.error: monster_image = simple.draw_rect(240, 80, (255, 255, 0)) logging.warning("Could not load: " + filename) else: monster_image = simple.draw_rect(240, 80, (255, 255, 0)) surface = pygame.Surface( (monster_image.get_width(), monster_image.get_height() + 30), pygame.SRCALPHA) surface.fill((0, 0, 0, 0)) surface.blit(monster_image, (0, 30)) surface.blit( simple.draw_text(self.monster.name, self.font, (255, 255, 0), surface.get_width(), justify="center"), (0, 0)) return surface
def __init__(self, start_img): super().__init__("background", 0, 0) self.img_element = element.Image("image", self.x, self.y, draw_image(start_img)) self.add_renderable(self.img_element)
def set_surface(self, surface, scale=1): if isinstance(surface, str): self.surface = draw_image(surface, scale) else: self.surface = surface