NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

link.py (4713B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\evelink\client\handlers\show_info\link.py
      2 from eve.client.script.ui.control.typeList.link import format_type_list_url, format_group_id_url, format_category_id_url
      3 from eve.client.script.ui.util import uix
      4 from eve.common.script.sys.idCheckers import IsCharacter, IsEvePlayerCharacter, IsCorporation, IsAlliance, IsFaction
      5 import evetypes
      6 import inventorycommon.const as invconst
      7 from evelink.link import Link
      8 from evelink.format.show_info import format_show_info_url, format_blueprint_show_info_url, format_ship_show_info_url
      9 
     10 def item_link(item, link_text = None, hint = None):
     11     if link_text is None:
     12         link_text = uix.GetItemName(item)
     13     item_id = None
     14     if not isinstance(item.itemID, tuple):
     15         item_id = item.itemID
     16     return Link(url=format_show_info_url(item.typeID, item_id), text=link_text, alt=hint)
     17 
     18 
     19 def type_link(type_id, item_id = None, link_text = None, hint = None):
     20     if link_text is None:
     21         link_text = evetypes.GetName(type_id)
     22     return Link(url=format_show_info_url(type_id, item_id), text=link_text, alt=hint)
     23 
     24 
     25 def group_link(group_id = None, link_text = None, hint = None, header_text = None):
     26     return Link(url=format_group_id_url(group_id, header_text=header_text), text=link_text, alt=hint)
     27 
     28 
     29 def category_link(category_id = None, link_text = None, hint = None, header_text = None):
     30     return Link(url=format_category_id_url(category_id, header_text=header_text), text=link_text, alt=hint)
     31 
     32 
     33 def type_list_link(type_list_id = None, link_text = None, hint = None, header_text = None, window_caption = None):
     34     return Link(url=format_type_list_url(type_list_id, header_text=header_text, window_caption=window_caption), text=link_text, alt=hint)
     35 
     36 
     37 def ship_link(type_id, item_id = None, owner_id = None, item_name = None, hint = None):
     38     if owner_id is not None and not IsEvePlayerCharacter(owner_id):
     39         owner_id = None
     40     type_name = evetypes.GetName(type_id, important=False)
     41     if owner_id:
     42         if item_name is not None:
     43             if type_name not in item_name:
     44                 link_text = u'{} ({})'.format(item_name, type_name)
     45             else:
     46                 link_text = item_name
     47         else:
     48             link_text = u'{} ({})'.format(cfg.eveowners.Get(owner_id).name, type_name)
     49     else:
     50         link_text = type_name
     51     return Link(url=format_ship_show_info_url(type_id, item_id, owner_id), text=link_text, alt=hint)
     52 
     53 
     54 def blueprint_link(type_id, item_id = None, link_text = None, hint = None, runs = None, isCopy = 0, te = None, me = None):
     55     if link_text is None:
     56         link_text = evetypes.GetName(type_id)
     57     url = format_blueprint_show_info_url(type_id, item_id, runs, int(isCopy), te, me)
     58     return Link(url, text=link_text, alt=hint)
     59 
     60 
     61 def owner_link(owner_id, link_text = None, hint = None):
     62     if IsCharacter(owner_id):
     63         return character_link(owner_id, link_text, hint)
     64     if IsCorporation(owner_id):
     65         return corporation_link(owner_id, link_text, hint)
     66     if IsAlliance(owner_id):
     67         return alliance_link(owner_id, link_text, hint)
     68     if IsFaction(owner_id):
     69         return faction_link(owner_id, link_text, hint)
     70     raise ValueError('Unknown owner', owner_id)
     71 
     72 
     73 def character_link(character_id, link_text = None, hint = None):
     74     character_info = cfg.eveowners.Get(character_id)
     75     if link_text is None:
     76         link_text = character_info.name
     77     return Link(url=format_show_info_url(character_info.typeID, character_id), text=link_text, alt=hint)
     78 
     79 
     80 def corporation_link(corporation_id, link_text = None, hint = None):
     81     if link_text is None:
     82         link_text = cfg.eveowners.Get(corporation_id).name
     83     return Link(url=format_show_info_url(invconst.typeCorporation, corporation_id), text=link_text, alt=hint)
     84 
     85 
     86 def alliance_link(alliance_id, link_text = None, hint = None):
     87     if link_text is None:
     88         link_text = cfg.eveowners.Get(alliance_id).name
     89     return Link(url=format_show_info_url(invconst.typeAlliance, alliance_id), text=link_text, alt=hint)
     90 
     91 
     92 def faction_link(faction_id, link_text = None, hint = None):
     93     if link_text is None:
     94         link_text = cfg.eveowners.Get(faction_id).name
     95     return Link(url=format_show_info_url(invconst.typeFaction, faction_id), text=link_text, alt=hint)
     96 
     97 
     98 def location_link(location_id, link_text = None, hint = None):
     99     location_info = sm.GetService('map').GetItem(location_id)
    100     if location_info is None:
    101         raise ValueError('Unknown location', location_id)
    102     if link_text is None:
    103         link_text = location_info.itemName
    104     return Link(url=format_show_info_url(location_info.typeID, location_id), text=link_text, alt=hint)