Exemplo n.º 1
0
 def _render_item_being_dragged(self, item_id: ItemId,
                                mouse_screen_position: Tuple[int, int],
                                relative_mouse_pos: Tuple[int, int]):
     ui_icon_sprite = get_item_data(item_id).icon_sprite
     big_image = self.big_images_by_ui_sprite[ui_icon_sprite]
     self._render_dragged(big_image, mouse_screen_position,
                          relative_mouse_pos)
Exemplo n.º 2
0
 def fill_item_inventory(self, items: List[ItemId]):
     for slot_number, item_id in enumerate(items):
         if item_id:
             item_effect = create_item_effect(item_id)
             item_data = get_item_data(item_id)
             item_equipment_category = item_data.item_equipment_category
             event = self.game_state.player_state.item_inventory.put_item_in_inventory_slot(
                 item_id, item_effect, item_equipment_category, slot_number)
             self._handle_item_equip_event(event)
Exemplo n.º 3
0
def _get_loot_name(
        lootable: LootableOnGround) -> Tuple[str, EntityActionTextStyle]:
    if isinstance(lootable, ConsumableOnGround):
        name = CONSUMABLES[lootable.consumable_type].name
        return name, EntityActionTextStyle.PLAIN
    if isinstance(lootable, ItemOnGround):
        name = build_item_name(lootable.item_id)
        if lootable.item_id.suffix_id is not None:
            style = EntityActionTextStyle.LOOT_RARE
        elif get_item_data(lootable.item_id).is_unique:
            style = EntityActionTextStyle.LOOT_UNIQUE
        else:
            style = EntityActionTextStyle.PLAIN
        return name, style
Exemplo n.º 4
0
 def _handle_item_equip_event(self, event: ItemActivationEvent):
     player_state = self.game_state.player_state
     item_id = event.item_id
     item_data = get_item_data(item_id)
     if isinstance(event, ItemWasActivated):
         create_item_effect(item_id).apply_start_effect(self.game_state)
         if item_data.active_ability_type:
             player_state.set_active_item_ability(
                 item_data.active_ability_type)
             self.on_abilities_updated()
     elif isinstance(event, ItemWasDeactivated):
         create_item_effect(item_id).apply_end_effect(self.game_state)
         if item_data.active_ability_type:
             player_state.set_active_item_ability(None)
             self.on_abilities_updated()
Exemplo n.º 5
0
 def _setup_ui_components(self):
     icon_space = 5
     x_1 = 165
     y_2 = 40
     self.button_delete_entities = self._create_map_editor_icon(
         Rect(20, y_2, MAP_EDITOR_UI_ICON_SIZE[0], MAP_EDITOR_UI_ICON_SIZE[1]),
         'Q', None, UiIconSprite.MAP_EDITOR_TRASHCAN, 0, None)
     self.button_delete_decorations = self._create_map_editor_icon(
         Rect(20 + MAP_EDITOR_UI_ICON_SIZE[0] + icon_space, y_2, MAP_EDITOR_UI_ICON_SIZE[0],
              MAP_EDITOR_UI_ICON_SIZE[1]), 'Z', None, UiIconSprite.MAP_EDITOR_RECYCLING, 0, None)
     self.entity_icons_by_type = {}
     num_icons_per_row = 23
     for entity_type in EntityTab:
         self.entity_icons_by_type[entity_type] = []
         for i, entity in enumerate(self._entities_by_type[entity_type]):
             x = x_1 + (i % num_icons_per_row) * (MAP_EDITOR_UI_ICON_SIZE[0] + icon_space)
             row_index = (i // num_icons_per_row)
             y = y_2 + row_index * (MAP_EDITOR_UI_ICON_SIZE[1] + icon_space)
             if entity.item_id is not None:
                 data = get_item_data(entity.item_id)
                 category_name = None
                 if data.item_equipment_category:
                     category_name = ITEM_EQUIPMENT_CATEGORY_NAMES[data.item_equipment_category]
                 description_lines = create_item_description(entity.item_id)
                 item_name = build_item_name(entity.item_id)
                 is_rare = entity.item_id.suffix_id is not None
                 is_unique = data.is_unique
                 tooltip = TooltipGraphics.create_for_item(self._ui_render, item_name, category_name, (x, y),
                                                           description_lines, is_rare=is_rare, is_unique=is_unique)
             elif entity.consumable_type is not None:
                 data = CONSUMABLES[entity.consumable_type]
                 tooltip = TooltipGraphics.create_for_consumable(self._ui_render, data, (x, y))
             elif entity.npc_type is not None:
                 data = NON_PLAYER_CHARACTERS[entity.npc_type]
                 tooltip = TooltipGraphics.create_for_npc(self._ui_render, entity.npc_type, data, (x, y))
             elif entity.portal_id is not None:
                 tooltip = TooltipGraphics.create_for_portal(self._ui_render, entity.portal_id, (x, y))
             elif entity.is_smart_floor_tile:
                 tooltip = TooltipGraphics.create_for_smart_floor_tile(self._ui_render, entity.entity_size, (x, y))
             else:
                 tooltip = None
             icon = self._create_map_editor_icon(
                 Rect(x, y, MAP_EDITOR_UI_ICON_SIZE[0], MAP_EDITOR_UI_ICON_SIZE[1]), '', entity.sprite, None,
                 entity.map_editor_entity_id, tooltip)
             self.entity_icons_by_type[entity_type].append(icon)