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
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
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
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
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
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
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)
def inventory_screen(self): surf = get_surface(INVENTORY_BG) display_name_and_portrait(self.game.model.party.p1, surf) display_equipment_icons(self.game.model.party.p1, surf) display_selected_icon(self, surf) display_subinventory(self, surf) if self.handler.menu_type.state in (MenuSubStates.SELECTED_OPTIONS, MenuSubStates.EXAMINING_MENU_OBJECT): display_entity_options(self, surf) if self.handler.menu_type.state is MenuSubStates.EXAMINING_MENU_OBJECT: display_entity_examination(self, surf) display_mass_capacities(self.game.model.party, surf) display_wealth(self.game.model.party.inventory.money, surf) align_and_blit(self.screen, surf)
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
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)
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
def display_selected_icon(self, surf): index = self.handler.menu_type.menu.pointer selected_icon = INVENTORY_ICONS[index] align_and_blit(surf, selected_icon, x_ratio=0.493+(0.0669*index), y_ratio=0.242)
def display_name_and_portrait(player, surf): p_name = get_text_surface(player.name, fontsize=25, color=WHITE, style='source_sans_pro') align_and_blit(surf, p_name, x_ratio=0.23, y_ratio=0.25) align_and_blit(surf, player.images.portrait, x_ratio=0.23)
def journal_screen(self): surf = get_surface(JOURNAL_OBJS.get('bg')) text = JOURNAL_OBJS.get('text' + str(self.handler.menu_type.menu.pointer)) selected_icon = JOURNAL_OBJS.get('selected_icon') current = JOURNAL_OBJS.get('current') completed = JOURNAL_OBJS.get('completed') codex = JOURNAL_OBJS.get('codex') history = JOURNAL_OBJS.get('history') align_and_blit(surf, text, x_ratio=0.227, y_ratio=0.227) align_and_blit(surf, selected_icon, x_ratio=0.426 + (0.05 * self.handler.menu_type.menu.pointer), y_ratio=0.131) align_and_blit(surf, current, x_ratio=0.426, y_ratio=0.131) align_and_blit(surf, completed, x_ratio=0.476, y_ratio=0.131) align_and_blit(surf, codex, x_ratio=0.526, y_ratio=0.131) align_and_blit(surf, history, x_ratio=0.576, y_ratio=0.131) sj = self.handler.menu_type.menu.pointer_data if len(sj) > 0: j_display = journal_options_display( sj, self.handler.menu_type.menu.pointer) details = get_entry_details(sj.pointer_data) surf.blit( j_display, (int(surf.get_width() * 0.05), int(surf.get_height() * 0.27))) surf.blit( details, (int(surf.get_width() * 0.43), int(surf.get_height() * 0.255))) if self.handler.menu_type.state is MenuSubStates.SELECTED_OPTIONS: display_quest_options(self, surf) align_and_blit(self.screen, surf)
def reward(self): align_and_blit(self.screen, self.handler.menu.get_window_image())
def blit_turn_order_queue(self): toq = get_surface(TURN_ORDER_QUEUE) align_and_blit(self.screen, toq, x_ratio=0.15, y_ratio=0.05)