Beispiel #1
0
    def draw_monster_info(self, surface, monster, rect):
        # position and draw hp bar
        hp_rect = rect.copy()
        left = rect.width * .6
        right = rect.right - tools.scale(4)
        hp_rect.width = right - left
        hp_rect.left = left
        hp_rect.height = tools.scale(8)
        hp_rect.centery = rect.centery

        # draw the hp bar
        self.hp_bar.value = monster.current_hp / monster.hp
        self.hp_bar.draw(surface, hp_rect)

        # draw the name
        text_rect = rect.inflate(-tools.scale(6), -tools.scale(6))
        draw_text(surface, monster.name, text_rect, font=self.font)

        # draw the level info
        text_rect.top = rect.bottom - tools.scale(7)
        draw_text(surface, "  Lv " + str(monster.level), text_rect, font=self.font)

        # draw any status icons
        # TODO: caching or something, idk
        # TODO: not hardcode icon sizes
        for index, status in enumerate(monster.status):
            if status.icon:
                image = tools.load_and_scale(status.icon)
                pos = (rect.width * .4) + (index * tools.scale(32)), rect.y + tools.scale(5)
                surface.blit(image, pos)
Beispiel #2
0
    def draw_monster_info(self, surface, monster, rect):
        # position and draw hp bar
        hp_rect = rect.copy()
        left = rect.width * .6
        right = rect.right - tools.scale(4)
        hp_rect.width = right - left
        hp_rect.left = left
        hp_rect.height = tools.scale(8)
        hp_rect.centery = rect.centery

        # draw the hp bar
        self.hp_bar.value = monster.current_hp / monster.hp
        self.hp_bar.draw(surface, hp_rect)

        # draw the name
        text_rect = rect.inflate(-tools.scale(6), -tools.scale(6))
        draw_text(surface, monster.name, text_rect, font=self.font)

        # draw the level info
        text_rect.top = rect.bottom - tools.scale(7)
        draw_text(surface,
                  "  Lv " + str(monster.level),
                  text_rect,
                  font=self.font)

        # draw any status icons
        # TODO: caching or something, idk
        # TODO: not hardcode icon sizes
        for index, status in enumerate(monster.status):
            if status.icon:
                image = tools.load_and_scale(status.icon)
                pos = (rect.width *
                       .4) + (index * tools.scale(32)), rect.y + tools.scale(5)
                surface.blit(image, pos)
Beispiel #3
0
    def draw_monster_info(self, surface, monster, rect):
        # position and draw hp bar
        hp_rect = rect.copy()
        hp_rect.width = rect.width // 2
        hp_rect.left = rect.centerx - tools.scale(2)
        hp_rect.height = tools.scale(8)
        hp_rect.centery = rect.centery

        self.hp_bar.value = monster.current_hp / monster.hp
        self.hp_bar.draw(surface, hp_rect)

        # draw the name
        text_rect = rect.inflate(-tools.scale(6), -tools.scale(6))
        draw_text(surface, monster.name, text_rect, font=self.font)

        # draw the level info
        text_rect.top = rect.bottom - tools.scale(6)
        draw_text(surface, "  Lv " + str(monster.level), text_rect, font=self.font)
Beispiel #4
0
    def draw_monster_info(self, surface, monster, rect):
        # position and draw hp bar
        hp_rect = rect.copy()
        hp_rect.width = rect.width // 2
        hp_rect.left = rect.centerx - tools.scale(2)
        hp_rect.height = tools.scale(8)
        hp_rect.centery = rect.centery

        self.hp_bar.value = monster.current_hp / monster.hp
        self.hp_bar.draw(surface, hp_rect)

        # draw the name
        text_rect = rect.inflate(-tools.scale(6), -tools.scale(6))
        draw_text(surface, monster.name, text_rect, font=self.font)

        # draw the level info
        text_rect.top = rect.bottom - tools.scale(6)
        draw_text(surface,
                  "  Lv " + str(monster.level),
                  text_rect,
                  font=self.font)
Beispiel #5
0
    def render_slot(self, rect, slot_num):
        slot_image = pygame.Surface(rect.size, pygame.SRCALPHA)

        # TODO: catch missing file
        thumb_image = pygame.image.load(prepare.SAVE_PATH + str(slot_num) + ".png").convert()
        thumb_rect = thumb_image.get_rect().fit(rect)
        thumb_image = pygame.transform.smoothscale(thumb_image, thumb_rect.size)

        # Draw the screenshot
        slot_image.blit(thumb_image, (rect.width * .20, 0))

        # Draw the slot text
        rect = rect.move(0, rect.height // 2 - 10)
        text.draw_text(slot_image, "Slot " + str(slot_num), rect, font=self.font)

        # Try and load the save game and draw details about the save
        try:
            save_data = save.load(slot_num)
        except Exception as e:
            logger.error(e)
            save_data = dict()
            save_data["error"] = "Save file corrupted"
            logger.error("Failed loading save file.")
            raise

        if "error" not in save_data:
            x = int(rect.width * .5)
            text.draw_text(slot_image, save_data['player_name'], (x, 0, 500, 500), font=self.font)
            text.draw_text(slot_image, save_data['time'], (x, 50, 500, 500), font=self.font)

        return slot_image
Beispiel #6
0
    def render_slot(self, rect, slot_num):
        slot_image = pygame.Surface(rect.size, pygame.SRCALPHA)

        thumb_image = None
        try:
            thumb_image = pygame.image.load(prepare.SAVE_PATH + str(slot_num) +
                                            ".png").convert()
            thumb_rect = thumb_image.get_rect().fit(rect)
            thumb_image = pygame.transform.smoothscale(thumb_image,
                                                       thumb_rect.size)
        except Exception as e:
            logger.error(e)

        # Try and load the save game and draw details about the save
        try:
            save_data = save.load(slot_num)
        except Exception as e:
            logger.error(e)
            save_data = dict()
            save_data["error"] = "Save file corrupted"
            save_data["player_name"] = "BROKEN SAVE!"
            logger.error("Failed loading save file.")
            if thumb_image is not None:
                pygame.draw.line(thumb_image, (255, 0, 0), [0, 0],
                                 thumb_rect.size, 3)
                pygame.draw.line(thumb_image, (255, 0, 0),
                                 [0, thumb_rect.height], [thumb_rect.width, 0],
                                 3)

        # Draw the screenshot
        if thumb_image is not None:
            slot_image.blit(thumb_image, (rect.width * .20, 0))

        # Draw the slot text
        rect = rect.move(0, rect.height // 2 - 10)
        text.draw_text(slot_image,
                       trans('slot') + " " + str(slot_num),
                       rect,
                       font=self.font)

        x = int(rect.width * .5)
        text.draw_text(slot_image,
                       save_data['player_name'], (x, 0, 500, 500),
                       font=self.font)
        if "error" not in save_data:
            text.draw_text(slot_image,
                           save_data['time'], (x, 50, 500, 500),
                           font=self.font)

        return slot_image
Beispiel #7
0
    def render_slot(self, rect, slot_num):
        slot_image = pygame.Surface(rect.size, pygame.SRCALPHA)

        # TODO: catch missing file
        thumb_image = pygame.image.load(prepare.SAVE_PATH + str(slot_num) +
                                        ".png").convert()
        thumb_rect = thumb_image.get_rect().fit(rect)
        thumb_image = pygame.transform.smoothscale(thumb_image,
                                                   thumb_rect.size)

        # Draw the screenshot
        slot_image.blit(thumb_image, (rect.width * .20, 0))

        # Draw the slot text
        rect = rect.move(0, rect.height // 2 - 10)
        text.draw_text(slot_image,
                       "Slot " + str(slot_num),
                       rect,
                       font=self.font)

        # Try and load the save game and draw details about the save
        try:
            save_data = save.load(slot_num)
        except Exception as e:
            logger.error(e)
            save_data = dict()
            save_data["error"] = "Save file corrupted"
            logger.error("Failed loading save file.")
            raise

        if "error" not in save_data:
            x = int(rect.width * .5)
            text.draw_text(slot_image,
                           save_data['player_name'], (x, 0, 500, 500),
                           font=self.font)
            text.draw_text(slot_image,
                           save_data['time'], (x, 50, 500, 500),
                           font=self.font)

        return slot_image
Beispiel #8
0
    def render_slot(self, rect, slot_num):
        slot_image = pygame.Surface(rect.size, pygame.SRCALPHA)

        thumb_image = None
        try:
            thumb_image = pygame.image.load(prepare.SAVE_PATH + str(slot_num) + ".png").convert()
            thumb_rect = thumb_image.get_rect().fit(rect)
            thumb_image = pygame.transform.smoothscale(thumb_image, thumb_rect.size)
        except Exception as e:
            logger.error(e)

        # Try and load the save game and draw details about the save
        try:
            save_data = save.load(slot_num)
        except Exception as e:
            logger.error(e)
            save_data = dict()
            save_data["error"] = "Save file corrupted"
            save_data["player_name"] = "BROKEN SAVE!"
            logger.error("Failed loading save file.")
            if thumb_image is not None:
                pygame.draw.line(thumb_image, (255,   0,   0), [0, 0], thumb_rect.size, 3)
                pygame.draw.line(thumb_image, (255,   0,   0), [0, thumb_rect.height], [thumb_rect.width, 0], 3)

        # Draw the screenshot
        if thumb_image is not None:
            slot_image.blit(thumb_image, (rect.width * .20, 0))

        # Draw the slot text
        rect = rect.move(0, rect.height // 2 - 10)
        text.draw_text(slot_image, trans('slot') + " " + str(slot_num), rect, font=self.font)

        x = int(rect.width * .5)
        text.draw_text(slot_image, save_data['player_name'], (x, 0, 500, 500), font=self.font)
        if "error" not in save_data:
            text.draw_text(slot_image, save_data['time'], (x, 50, 500, 500), font=self.font)

        return slot_image
Beispiel #9
0
 def render_empty_slot(self, rect):
     slot_image = pygame.Surface(rect.size, pygame.SRCALPHA)
     rect = rect.move(0, rect.height // 2 - 10)
     text.draw_text(slot_image, trans('empty_slot'), rect, font=self.font)
     return slot_image