Exemplo n.º 1
0
def get_life_minimap(tiles):
    mini = get_alpha_surface(248, 248)

    display = get_alpha_surface(2 * len(tiles[0]), 2 * len(tiles))
    for y, row in enumerate(tiles):
        for x, tile in enumerate(row):
            if tile.explored:
                if tile.blocker:
                    display.blit(scale(tile.blocker.image, (2, 2)),
                                 (2 * x, 2 * y))
                else:
                    display.blit(scale(tile.floor.image, (2, 2)),
                                 (2 * x, 2 * y))
    align_and_blit(mini, display)

    return mini
Exemplo n.º 2
0
 def make_item_menu(component):
     data, logic = MenuMaker.get_item_menu_datalogic(component)
     BG_WIDTH = 80
     BG_HEIGHT = 24 * len(data)
     bg = get_alpha_surface(BG_WIDTH, BG_HEIGHT)
     bg.blit(scale(DIALOGUE_BG, (BG_WIDTH, BG_HEIGHT)), (0, 0))
     pointer_image = get_alpha_surface(16, 16)
     pointer_image.blit(scale(POINTER_RIGHT, (16, 16)), (0, 0))
     specs = MenuSpecs(bg=bg,
                       pointer_image=pointer_image,
                       pointer_y_offset=8,
                       font_size=16,
                       pointer_delta=20,
                       button_x_offset=12,
                       button_y_offset=4)
     return BasicMenu(data, logic, specs)
Exemplo n.º 3
0
def display_saving_throws(player):
    gap = 25
    c = player.combatant
    save_l = [
        c.savethrow_injury, c.savethrow_tenacity, c.savethrow_composure,
        c.savethrow_cognition, c.savethrow_breath, c.savethrow_corruption
    ]
    save_r = [
        c.savethrow_illness, c.savethrow_apathy, c.savethrow_pain,
        c.savethrow_force, c.savethrow_reflex, c.savethrow_will
    ]
    display = get_alpha_surface(100, gap * len(save_r))
    for ind, stat in enumerate(save_l):
        align_and_blit(display,
                       get_text_surface(str(stat), 16, WHITE,
                                        'source_sans_pro'),
                       x_ratio=0.1,
                       y_ratio=.0833 + (0.1666 * ind))
    for ind, stat in enumerate(save_r):
        align_and_blit(display,
                       get_text_surface(str(stat), 16, WHITE,
                                        'source_sans_pro'),
                       x_ratio=0.9,
                       y_ratio=.0833 + (0.1666 * ind))

    return display
Exemplo n.º 4
0
def display_equipment_icon(window, eq, slot, mini=False):

    string_to_slot_dict = {'head': eq.head, 'shoulders': eq.shoulders, 'chest': eq.chest, 'arms': eq.arms,
                           'wrists': eq.wrists, 'hands': eq.hands, 'legs': eq.legs, 'feet': eq.feet,
                           'face': eq.face, 'neck': eq.neck, 'back': eq.back, 'waist': eq.waist,
                           'finger1': eq.finger1, 'finger2': eq.finger2, 'satchel': eq.satchel, 'weapon1': eq.main_hand,
                           'weapon2': eq.off_hand, 'quiver': eq.quiver, 'food': eq.food, 'drink': eq.drink}
    icon_ratio_dicts = {'head': (25, 24), 'shoulders': (25, 70), 'chest': (25, 116), 'arms': (25, 162),
                        'wrists': (25, 208), 'hands': (25, 254), 'legs': (25, 300), 'feet': (25, 346),
                        'face': (267, 24), 'neck': (267, 70), 'back': (267, 116), 'waist': (267, 162),
                        'finger1': (267, 208), 'finger2': (267, 254), 'satchel': (267, 346), 'weapon1': (112, 340),
                        'weapon2': (158, 340), 'quiver': (198, 345), 'food': (120, 410), 'drink': (170, 410)}

    if string_to_slot_dict.get(slot) is None:
        img = EQUIPMENT_EMPTY_DICT.get(slot)
    else:
        img = get_alpha_surface(48, 48)
        img.fill(BLACK)
        align_and_blit(img, scale(string_to_slot_dict.get(slot).item.equippable.images.sprite,
                                  (int(img.get_width()*7/8), int(img.get_height()*7/8))))

    x_ratio, y_ratio = icon_ratio_dicts.get(slot)

    if mini:
        shrink = (int(img.get_width()*11/10), int(img.get_height()*11/10))
        align_and_blit(window, img, x_ratio=x_ratio / window.get_width(), y_ratio=y_ratio / window.get_height())
        align_and_blit(window, scale(EQUIPMENT_SLOT_BORDER, shrink), x_ratio=x_ratio / window.get_width(),
                       y_ratio=y_ratio / window.get_height())
    else:
        align_and_blit(window, img, x_ratio=x_ratio/window.get_width(), y_ratio=y_ratio/window.get_height())
        align_and_blit(window, EQUIPMENT_SLOT_BORDER, x_ratio=x_ratio/window.get_width(),
                       y_ratio=y_ratio/window.get_height())

    return None
Exemplo n.º 5
0
def display_subinventory(self, surf):
    entities = self.handler.menu_type.menu.pointer_data

    subinv = get_alpha_surface(SUBINVENTORY_OPTION_WIDTH, len(entities) * SUBINVENTORY_OPTION_HEIGHT)
    display_entity_list(entities, subinv)
    display_subinv_pointer(self, subinv)
    surf.blit(subinv, (340, 170))
Exemplo n.º 6
0
def display_shopsub(subinventory):
    option_height = 32

    surf = get_alpha_surface(200, len(subinventory) * option_height)
    y = 0
    for entity in subinventory:
        mini = entity.images.port_mini
        text = get_text_surface(entity.name, fontsize=16)
        value = split_money(entity.item.value)
        window = get_alpha_surface(200, option_height)
        window.blit(mini, (0, 0))
        window.blit(text, (35, 12))
        window.blit(value, (200 - value.get_width(), 12))
        surf.blit(window, (0, y * option_height))
        y += 1
    return surf
Exemplo n.º 7
0
def get_dialogue_options(self):
    window_height_total = 0
    line_blit_height = 0
    option_list = []
    q = 1
    for option in self.handler.real_talk:

        deja_vu = self.handler.deja_vu_check(q)
        if deja_vu:
            color = GREY
        else:
            color = WHITE
        lines = get_wrapped_text(str(q) + ' ) ' + option.text,
                                 width=950,
                                 fontsize=18,
                                 color=color)
        option_list.extend(lines)
        for line in lines:
            window_height_total += line.get_height()
        q += 1
    window = get_alpha_surface(width=950, height=window_height_total)
    for option in option_list:
        window.blit(option, (0, line_blit_height))
        line_blit_height += option.get_height()

    return window
Exemplo n.º 8
0
def get_life_member_stats(entity):
    stats = get_alpha_surface(RESOURCE_HUD_BASE.get_width(),
                              RESOURCE_HUD_BASE.get_height())
    name = get_text_surface(entity.combatant.name, fontsize=12, color=WHITE)
    level = get_text_surface(str(entity.combatant.level.current_level),
                             fontsize=12,
                             color=WHITE)
    hp = get_surface(HP)
    mp = get_surface(MP)
    tp = get_surface(TP)
    vp = get_surface(VP)

    percent_hp = entity.combatant.attributes.current_hp / entity.combatant.max_hp
    percent_mp = entity.combatant.attributes.current_mp / entity.combatant.max_mp
    percent_tp = entity.combatant.attributes.current_tp / entity.combatant.max_tp
    percent_vp = entity.combatant.attributes.current_vp / entity.combatant.max_vp

    stats.blit(name, (95, 0))
    stats.blit(level, (65, 60))
    stats.blit(scale(hp, (int(hp.get_width() * percent_hp), hp.get_height())),
               (86, 22))
    stats.blit(scale(mp, (int(mp.get_width() * percent_mp), mp.get_height())),
               (86, 34))
    stats.blit(scale(tp, (int(tp.get_width() * percent_tp), tp.get_height())),
               (86, 46))
    stats.blit(scale(vp, (int(vp.get_width() * percent_vp), vp.get_height())),
               (86, 58))

    return stats
Exemplo n.º 9
0
def dialogue_screen(self):
    display = get_surface(DIALOGUE_BG)
    surf = get_alpha_surface(display.get_width(),
                             int(display.get_height() * 1.5))
    partner = self.handler.partner

    partner_name = get_text_surface(partner.name.capitalize(),
                                    fontsize=24,
                                    color=WHITE)

    display.blit(
        partner_name,
        (int(display.get_width() * 0.1), int(display.get_height() * 0.05)))
    align_and_blit(surf, partner.images.portrait, y_ratio=0.12)

    dialogue = self.handler.partner.converser.dialogue
    current_node = dialogue.graph_dict.get(dialogue.conversation)
    words = get_wrapped_text_surface(current_node.words,
                                     width=int(display.get_width() * 0.95),
                                     fontsize=18,
                                     color=WHITE)
    display.blit(
        words, (int(display.get_width() * 0.025),
                int(display.get_height() * 0.05 + partner_name.get_height())))

    options = get_dialogue_options(self)
    display.blit(
        options,
        (int(display.get_width() * 0.025), int(display.get_height() * 0.505)))

    surf.blit(display, (surf.get_width() - display.get_width(),
                        surf.get_height() - display.get_height()))
    align_and_blit(self.screen, surf, y_ratio=0.65)
Exemplo n.º 10
0
def journal_options_display(subjournal, option):
    obj = JOURNAL_OBJS.get('selected_quest')

    surf = get_alpha_surface(obj.get_width(),
                             obj.get_height() * len(subjournal))
    y = 0
    for i in subjournal:
        if y is option:
            color = YELLOW_SELECT
            bg = get_surface(obj)
        else:
            color = GREY
            bg = get_alpha_surface(obj.get_width(), obj.get_height())
        text = get_text_surface(i.title, 18, color, 'source_sans_pro')
        align_and_blit(bg, text)
        surf.blit(bg, (0, 0 + (y * obj.get_height())))
    return surf
Exemplo n.º 11
0
def get_life_left_panel(party):
    panel = get_alpha_surface(LIFE_PANEL_WIDTH, LIFE_PANEL_HEIGHT)
    party_resources_hud = get_life_party_resources(party)
    party_travel_settings = get_life_party_travel_settings(party)
    panel.blit(party_resources_hud, (8, 36))
    panel.blit(party_travel_settings,
               (8, 36 + party_resources_hud.get_height()))
    return panel
Exemplo n.º 12
0
def display_clock(time):
    clock = get_alpha_surface(248, 50)

    bg_color = display_clock_bg(clock, time.hour)
    display_celestial_bodies(clock, time)
    display_time(clock, time.hour, bg_color)

    return clock
Exemplo n.º 13
0
def get_entry_details(entry):
    surf = get_alpha_surface(367, 400)
    align_and_blit(surf, get_text_surface(entry.title, 22, BLACK), y_ratio=0.1)
    y_off = 80
    for i in entry.plot:
        sc = get_story_chunk(i)
        surf.blit(sc, (30, y_off))
        y_off += sc.get_height() + 30
    return surf
Exemplo n.º 14
0
    def get_option_image(self, index):
        w, h = self.specs.button_bg.get_width(
        ), self.specs.button_bg.get_height()
        surf = get_alpha_surface(w, h)
        text = get_text_surface(self.data[index], self.specs.font_size,
                                self.specs.font_color, self.specs.font_style)
        surf.blit(self.specs.button_bg, (0, 0))
        align_and_blit(surf, text)

        return surf
Exemplo n.º 15
0
def get_life_cropped_portrait(entity):
    cropped = get_alpha_surface(83, 83)
    align_and_blit(cropped, entity.images.port_mini)
    center_x, center_y = 42, 42
    for y in range(83):
        for x in range(83):
            out_of_bounds = sqrt((y - center_y) * (y - center_y) +
                                 (x - center_x) * (x - center_x)) > 33
            if out_of_bounds:
                cropped.set_at((x, y), TRANSPARENT)
    return cropped
Exemplo n.º 16
0
def display_entity_list(entities, subinv):
    y = 0
    for entity in entities:
        sprite = entity.images.sprite
        text = get_text_surface(entity.name, fontsize=24, color=WHITE)
        item = get_alpha_surface(SUBINVENTORY_OPTION_WIDTH, SUBINVENTORY_OPTION_HEIGHT)
        align_and_blit(item, sprite, x_ratio=0.15)
        item.blit(text, (int(item.get_width() * 0.35), int(0.5 * (item.get_height() - text.get_height()))))
        draw.line(item, DARK_GREY, (0, SUBINVENTORY_OPTION_HEIGHT - 1),
                  (int(SUBINVENTORY_OPTION_WIDTH), SUBINVENTORY_OPTION_HEIGHT - 1))
        subinv.blit(item, (0, y * SUBINVENTORY_OPTION_HEIGHT))
        y += 1
Exemplo n.º 17
0
def get_life_party_travel_settings(party):
    window = get_alpha_surface(248, 186)
    setting_titles = ['Formation', 'Move Speed', 'Rations']
    settings = [party.formation, party.move_speed, party.rations]
    for i in range(3):
        settings_frame = get_surface(PARTY_SETTINGS_FRAME)
        setting_title = get_text_surface(setting_titles[i], color=WHITE)
        align_and_blit(settings_frame, setting_title, y_ratio=0.24)
        setting = get_text_surface(settings[i], fontsize=16)
        align_and_blit(settings_frame, setting, y_ratio=0.68)
        window.blit(settings_frame, (0, i * settings_frame.get_height()))
    return window
Exemplo n.º 18
0
def display_equipment_icons(player, surf):

    window = get_alpha_surface(300, 450)

    slots = ['head', 'shoulders', 'chest', 'arms', 'wrists', 'hands', 'legs', 'feet', 'face', 'neck', 'back',
             'waist', 'finger1', 'finger2', 'satchel', 'weapon1', 'weapon2', 'quiver', 'food', 'drink']
    for slot in slots:
        if slot == 'quiver':
            display_equipment_icon(window, player.combatant.equipment, slot, mini=True)
        else:
            display_equipment_icon(window, player.combatant.equipment, slot)

    align_and_blit(surf, window, x_ratio=0.23, y_ratio=0.595)
Exemplo n.º 19
0
def display_attributes(player):
    gap = 19
    a = player.combatant.attributes
    atts = [
        a.strength, a.instinct, a.coordination, a.endurance, a.arcana,
        a.improvisation, a.wisdom, a.finesse, a.charisma, a.devotion
    ]
    display = get_alpha_surface(28, gap * len(atts))
    for ind, stat in enumerate(atts):
        align_and_blit(display,
                       get_text_surface(str(stat), 16, WHITE,
                                        'source_sans_pro'),
                       y_ratio=.05 + (0.1 * ind))
    return display
Exemplo n.º 20
0
def get_story_chunk(chunk):
    width = 300
    titlesize = 18
    fontsize = 14
    lines = get_wrapped_text(chunk.info, width, fontsize, color=BLACK)

    surf = get_alpha_surface(width, titlesize + (fontsize * 1.2) * len(lines))
    surf.blit(get_text_surface(chunk.title, titlesize, WHITE), (0, 0))

    y = 20
    for line in lines:
        surf.blit(line, (0, y))
        y += fontsize
    return surf
Exemplo n.º 21
0
def get_life_right_panel(game):
    off_x, off_y = 8, 36
    panel = get_alpha_surface(LIFE_PANEL_WIDTH, LIFE_PANEL_HEIGHT)

    for display in [
            get_life_minimap(game.model.world.current_map.tiles),
            display_clock(game.model.time),
            display_calendar(game.model.time),
            get_upcoming_events(),
            get_life_event_log(game.model.log)
    ]:
        panel.blit(display, (off_x, off_y))
        off_y += display.get_height()

    return panel
Exemplo n.º 22
0
def display_secondary_stats(player):
    gap = 19
    c = player.combatant
    stats = [
        c.initiative, c.speed, c.accuracy, c.dodge, c.critical_strike,
        c.critical_damage, c.teamwork, c.presence
    ]
    display = get_alpha_surface(38, gap * len(stats))
    for ind, stat in enumerate(stats):
        align_and_blit(display,
                       get_text_surface(str(stat), 16, WHITE,
                                        'source_sans_pro'),
                       y_ratio=.0625 + (0.125 * ind))

    return display
Exemplo n.º 23
0
 def make_quest_menu(quest):
     logic = [get_quest_details, toggle_starred]
     data = ['Quest Details']
     if quest.starred:
         data.append('Mark As Unimportant')
     else:
         data.append('Mark As Important')
     if not quest.part_of_main_storyline:
         logic.extend([abandon_quest])
         data.append('Abandon Quest')
     BG_WIDTH = 150
     BG_HEIGHT = 24 * len(data)
     bg = get_alpha_surface(BG_WIDTH, BG_HEIGHT)
     bg.blit(scale(DIALOGUE_BG, (BG_WIDTH, BG_HEIGHT)), (0, 0))
     pointer_image = get_alpha_surface(16, 16)
     pointer_image.blit(scale(POINTER_RIGHT, (16, 16)), (0, 0))
     specs = MenuSpecs(bg=bg,
                       pointer_image=pointer_image,
                       pointer_y_offset=8,
                       font_size=16,
                       pointer_delta=20,
                       button_x_offset=12,
                       button_y_offset=4)
     return BasicMenu(data, logic, specs)
Exemplo n.º 24
0
    def blit_combat(self):
        w, h = 1920, 1280
        window = get_alpha_surface(w, h)
        dim = 240
        count = 0
        for row in self.handler.combat.grid.rows:
            for actor in row:
                window.blit(actor.combatant.images.actor, (count * dim, 700))
            count += 1

        if self.handler.state == EncounterStates.FIGHT_TARGETING:
            window.blit(INDICATOR_V,
                        ((self.handler.combat.grid.x * dim) + (dim / 2) -
                         (INDICATOR_V.get_width() / 2), 650))

        self.screen.blit(window, (0, 0))
Exemplo n.º 25
0
def map_screen(self):
    display = get_surface(MAP_BG)
    overworld_tiles = self.game.model.world.dungeons['overworld'].maps[0].tiles
    window = get_alpha_surface(len(overworld_tiles[0]), len(overworld_tiles))

    i, j = 0, 0

    for row in self.game.model.world.mini:
        for img in row:
            if overworld_tiles[j][i].explored:
                window.blit(img, (i, j))
            i += 1
        j += 1
        i = 0
    align_and_blit(display, window)
    align_and_blit(self.screen, display)
Exemplo n.º 26
0
def display_xp_fill(player):
    fill = get_surface(XP_FILL)
    l = player.combatant.level
    display = get_alpha_surface(fill.get_width(), fill.get_height())
    align_and_blit(
        display,
        scale(fill, (int(fill.get_width() * l.percentage_leveled / 100),
                     fill.get_height())))
    xp_text = get_text_surface('XP:  ' + str(l.current_xp) + '  /  ' +
                               str(l.experience_to_next_level) + '  ( ' +
                               str(int(l.percentage_leveled)) + '% )',
                               fontsize=8,
                               color=WHITE)
    align_and_blit(display, xp_text)

    return display
Exemplo n.º 27
0
def get_life_party_resources(party):
    party_resources = get_alpha_surface(RESOURCE_HUD_BASE.get_width(),
                                        RESOURCE_HUD_BASE.get_height() * 4)
    ind = 0
    for member in party.member_slots:
        location_to_blit = (0, ind * RESOURCE_HUD_BASE.get_height())
        party_resources.blit(RESOURCE_HUD_BASE, location_to_blit)
        if member is not None:
            party_resources.blit(get_life_cropped_portrait(member),
                                 location_to_blit)
        party_resources.blit(RESOURCE_HUD_OVERLAY, location_to_blit)
        if member is not None:
            party_resources.blit(get_life_member_stats(member),
                                 location_to_blit)
        ind += 1

    return party_resources
Exemplo n.º 28
0
def display_resources(player):
    display = get_alpha_surface(260, 36)
    ratio_dict = {
        'HP': (0.25, 0.25),
        'MP': (0.25, 0.75),
        'TP': (0.75, 0.25),
        'VP': (0.75, 0.75)
    }
    for resource in ('HP', 'MP', 'TP', 'VP'):
        percent, now_val, max_val, font_color = get_resource_vals(
            player, resource)
        ratio = ratio_dict.get(resource)
        x_ratio, y_ratio = ratio

        text = get_text_surface(
            str(now_val) + '  /  ' + str(max_val),
            16,
            font_color,
        )
        align_and_blit(display, text, x_ratio, y_ratio)

    return display
Exemplo n.º 29
0
def get_life_main_screen(self):
    main_screen = get_alpha_surface(1392, 1008)
    (width, height) = TILES_ON_SCREEN

    cx, cy = self.game.life.camera.x, self.game.life.camera.y
    largest_overhead = 3

    if self.game.life.fov.needs_recompute:
        self.game.life.fov.recompute()
        self.game.life.fov.needs_recompute = False

    is_interior = is_party_on_interior_tile(self.game.model.party,
                                            self.game.model.world.tiles)
    for y in range(height + largest_overhead):
        for x in range(width):
            try:
                visible = tcod.map_is_in_fov(self.game.life.fov.map, cy + y,
                                             cx + x)
                tile = self.game.model.world.tiles[cy + y][cx + x]

                draw_tile(main_screen, self.game.model.world.tiles, tile, x, y,
                          cx, cy, visible, is_interior)

                if not visible and not tile.floor.transition:
                    draw_darkened_overlay(main_screen, x, y)
            except IndexError:
                pass

    for converser in self.game.model.world.current_map.conversers:
        draw_entity(self, main_screen, converser)
    entities_in_render_order = sorted(
        self.game.model.world.current_map.entities,
        key=lambda x: x.render_order.value)
    for entity in entities_in_render_order:
        draw_entity(self, main_screen, entity)

    draw_party(self, main_screen)
    return main_screen
Exemplo n.º 30
0
def display_loot(reward):
    window = get_alpha_surface(1280, 300)

    y1 = 0
    for item in reward.loot.items:
        window.blit(item.images.sprite, (120, 40 + (100 * y1)))
        text = get_text_surface(item.name, fontsize=20, color=BLACK)
        window.blit(text, (210, 70 + (100 * y1)))
        y1 += 1
    y2 = 0
    bonus_y = 640
    for item in reward.loot.claimed:
        window.blit(item.images.sprite, (120 + bonus_y, 40 + (100 * y2)))
        text = get_text_surface(item.name, fontsize=20, color=BLACK)
        window.blit(text, (210 + bonus_y, 40 + (100 * y2)))
        y2 += 1
    choice = reward.owner.options.current.choice
    if reward.state == RewardStates.SIFTING:
        window.blit(POINTER_RIGHT, (80, 60 + (choice * 100)))
    elif reward.state == RewardStates.DEPOSITING:
        window.blit(POINTER_RIGHT, (80 + bonus_y, 60 + choice * 100))

    return window