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

skill.py (10801B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\tooltip\skill.py
      2 import characterskills.client
      3 import clonegrade
      4 import expertSystems.client
      5 import localization
      6 from carbonui import uiconst
      7 from carbonui.primitives.gradientSprite import GradientSprite
      8 from carbonui.primitives.layoutGrid import LayoutGrid
      9 from carbonui.primitives.sprite import Sprite
     10 from carbonui.util.color import Color
     11 from characterskills.client.UI.util import get_skill_title
     12 from eve.client.script.ui.control import eveLabel, primaryButton
     13 from carbonui.control.button import Button
     14 from eve.client.script.ui.control.infoIcon import InfoIcon
     15 from eve.client.script.ui.shared.neocom import skillConst
     16 from eve.client.script.ui.shared.tooltip.skillTooltipController import SkillTooltipController, SkillPrimaryActionController
     17 from localization.formatters.timeIntervalFormatters import TIME_CATEGORY_DAY, TIME_CATEGORY_MINUTE, FormatTimeIntervalShortWritten
     18 TOOLTIP_WIDTH_DEFAULT = 280
     19 
     20 def LoadSkillEntryTooltip(panel, skillID, skillLevel = None):
     21     skill = SkillTooltipController(skillID)
     22     load_skill_tooltip(panel, skill, skillLevel)
     23 
     24 
     25 def LoadSkillEntryTooltipInfoOnly(panel, skillID):
     26     skill = SkillTooltipController(skillID)
     27     load_skill_tooltip_information(panel, skill)
     28 
     29 
     30 def load_skill_tooltip(panel, skill, skillLevel = None):
     31     _init_panel(panel)
     32     _add_header(panel, skill, skillLevel)
     33     _add_information(panel, skill, skillLevel)
     34     _add_actions(panel, skill, skillLevel)
     35 
     36 
     37 def load_skill_tooltip_information(panel, skill):
     38     _init_panel(panel)
     39     _add_information(panel, skill)
     40 
     41 
     42 def load_skill_tooltip_actions(panel, skill, skillLevel = None):
     43     _init_panel(panel)
     44     _add_actions(panel, skill, skillLevel)
     45 
     46 
     47 def _init_panel(panel):
     48     panel.Flush()
     49     panel.LoadStandardSpacing()
     50     panel.cellSpacing = (8, 8)
     51     panel.columns = 2
     52     panel.state = uiconst.UI_NORMAL
     53 
     54 
     55 def _add_header(panel, skill, skillLevel = None):
     56     panel.AddMediumHeader(text=get_skill_title(skill.type_id, skillLevel))
     57 
     58 
     59 def _add_information(panel, skill, skillLevel = None):
     60     add_description(panel, skill)
     61     add_level_and_points(panel, skill)
     62     if should_add_expert_system_notification(skill):
     63         add_expert_system_information(panel, skill)
     64     if should_add_training_queue_info(skill):
     65         add_queued_training_info(panel, skill)
     66     elif skillLevel and should_add_training_info(skill, skillLevel):
     67         add_training_info(panel, skill, skillLevel)
     68 
     69 
     70 def _add_actions(panel, skill, skillLevel):
     71     if should_add_requirements_action(skill):
     72         add_requirements_action(panel, skill)
     73     if should_add_buy_skill_action(skill):
     74         add_buy_skill_action(panel, skill)
     75     if should_add_omega_info(skill):
     76         add_omega_info(panel, skill)
     77     if should_add_primary_action(skill, skillLevel):
     78         add_primary_action(panel, skill, skillLevel)
     79 
     80 
     81 def should_add_training_queue_info(skill):
     82     return skill.is_queued
     83 
     84 
     85 def should_add_training_info(skill, skillLevel):
     86     return skill.could_be_trained(skillLevel)
     87 
     88 
     89 def should_add_requirements_action(skill):
     90     return not skill.is_grandfathered and skill.untrained_requirements
     91 
     92 
     93 def should_add_buy_skill_action(skill):
     94     return not skill.is_injected and not skill.is_next_level_omega_restricted
     95 
     96 
     97 def should_add_omega_info(skill):
     98     return skill.is_omega_restricted
     99 
    100 
    101 def should_add_primary_action(skill, skillLevel):
    102     if skillLevel is None:
    103         skillLevel = 5
    104     return skill.level_including_queued < skillLevel or should_add_omega_info(skill)
    105 
    106 
    107 def should_add_expert_system_notification(skill):
    108     if skill.virtual_level and expertSystems.is_expert_systems_enabled():
    109         return True
    110     else:
    111         return False
    112 
    113 
    114 def add_description(panel, skill):
    115     grid = LayoutGrid(columns=2)
    116     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT - 24,
    117      0,
    118      0,
    119      0), colSpan=2)
    120     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPLEFT, text=skill.description, width=TOOLTIP_WIDTH_DEFAULT - 24 - 12), cellPadding=(0, 0, 0, 0))
    121     grid.AddCell(InfoIcon(align=uiconst.TOPRIGHT, typeID=skill.type_id, hint=localization.GetByLabel('UI/Commands/ShowInfo')), cellPadding=(0, 0, 0, 0))
    122     panel.AddCell(grid, cellPadding=(12, 0, 8, 0), colSpan=panel.columns)
    123 
    124 
    125 def add_level_and_points(panel, skill):
    126     panel.AddCell(eveLabel.EveLabelMedium(text=characterskills.client.get_skill_level_text(skill.level)), cellPadding=(12, 8, 0, 0))
    127     panel.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPRIGHT, text=characterskills.client.get_skill_points_text(skill.points, skill.rank)), cellPadding=(0, 8, 12, 0))
    128 
    129 
    130 def add_training_info(panel, skill, skillLevel):
    131     grid = LayoutGrid(align=uiconst.TOTOP, columns=2)
    132     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT - 24,
    133      0,
    134      0,
    135      0), colSpan=2)
    136     grid.AddCell(eveLabel.EveLabelMedium(text=localization.GetByLabel('UI/Skills/TimeToTrain'), align=uiconst.TOTOP), cellPadding=(0, 2, 0, 0))
    137     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPRIGHT, text=FormatTimeIntervalShortWritten(skill.get_training_time_to_level(skillLevel), showTo=TIME_CATEGORY_MINUTE)), cellPadding=(0, 2, 0, 0))
    138     panel.AddCell(grid, cellPadding=(12, 8, 12, 0), colSpan=panel.columns)
    139 
    140 
    141 def add_queued_training_info(panel, skill):
    142     grid = LayoutGrid(align=uiconst.TOTOP, columns=2)
    143     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT - 24,
    144      0,
    145      0,
    146      0), colSpan=2)
    147     grid.AddCell(eveLabel.EveLabelMedium(text=localization.GetByLabel('UI/Skills/TrainingToLevel', level=skill.level_including_queued), color=skillConst.COLOR_SKILL_1, align=uiconst.TOTOP), colSpan=2)
    148     grid.AddCell(eveLabel.EveLabelMedium(text=localization.GetByLabel('UI/Skills/TimeUntilTrained'), align=uiconst.TOTOP), cellPadding=(0, 2, 0, 0))
    149     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPRIGHT, text=FormatTimeIntervalShortWritten(skill.get_time_until_trained(), showFrom=TIME_CATEGORY_DAY, showTo=TIME_CATEGORY_MINUTE)), cellPadding=(0, 2, 0, 0))
    150     panel.AddCell(grid, cellPadding=(12, 8, 12, 0), colSpan=panel.columns)
    151     grid = LayoutGrid(align=uiconst.TOTOP, columns=2)
    152     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT - 24,
    153      0,
    154      0,
    155      0), colSpan=2)
    156     grid.AddCell(eveLabel.EveLabelMedium(text=localization.GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/TrainingRate')))
    157     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPRIGHT, text=localization.GetByLabel('UI/CharacterSheet/CharacterSheetWindow/SkillTabs/SpPerMinute', spPerMin=skill.training_rate)))
    158     panel.AddCell(grid, cellPadding=(12, 2, 12, 0), colSpan=panel.columns)
    159 
    160 
    161 def add_requirements_action(panel, skill):
    162     grid = LayoutGrid(columns=2)
    163     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT,
    164      8,
    165      0,
    166      0), colSpan=2)
    167     add_background_gradient(grid, skillConst.COLOR_SKILL_1)
    168     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.CENTERLEFT, text=localization.GetByLabel('UI/Skills/UntrainedRequirements'), width=TOOLTIP_WIDTH_DEFAULT - 22), colSpan=2, cellPadding=(11, 0, 11, 0))
    169     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOTOP, text=localization.GetByLabel('UI/Skills/TotalTrainingTimeField', color=Color(1.0, 1.0, 1.0, 0.5).GetHex(), time=skill.requirements_training_time)), colSpan=2, cellPadding=(11, 8, 0, 8))
    170     grid.AddCell(Button(align=uiconst.CENTERRIGHT, label=localization.GetByLabel('UI/Skills/ViewRequiredSkills'), func=skill.view_requirements, args=(), fixedheight=24), cellPadding=(11, 8, 11, 8))
    171     panel.AddCell(grid, cellPadding=(1, 0, 1, 0), colSpan=panel.columns)
    172 
    173 
    174 def add_buy_skill_action(panel, skill):
    175     grid = LayoutGrid(columns=2)
    176     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT,
    177      8,
    178      0,
    179      0), colSpan=2)
    180     add_background_gradient(grid, skillConst.COLOR_SKILL_1)
    181     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.TOPLEFT, width=TOOLTIP_WIDTH_DEFAULT - 24, text=localization.GetByLabel('UI/Skills/NeedToBuySkill')), cellPadding=(11, 0, 11, 0), colSpan=2)
    182     if skill.is_available_for_purchase:
    183         text = localization.GetByLabel('UI/Skills/SkillPriceField', color=Color(1.0, 1.0, 1.0, 0.5).GetHex(), price=skill.price)
    184     elif skill.estimated_market_price is None:
    185         text = localization.GetByLabel('UI/Skills/SkillEstimatedPriceUnknown', color=Color(1.0, 1.0, 1.0, 0.5).GetHex())
    186     else:
    187         text = localization.GetByLabel('UI/Skills/SkillEstimatedPrice', color=Color(1.0, 1.0, 1.0, 0.5).GetHex(), price=skill.estimated_market_price)
    188     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.CENTERLEFT, text=text), cellPadding=(11, 8, 0, 8))
    189     if skill.is_available_for_purchase:
    190         label = localization.GetByLabel('UI/Skills/BuySkill')
    191         func = skill.buy
    192         args = ()
    193     else:
    194         label = localization.GetByLabel('UI/Inventory/ItemActions/ViewTypesMarketDetails')
    195         func = skill.view_market_details
    196         args = ()
    197     grid.AddCell(Button(align=uiconst.CENTERRIGHT, label=label, func=func, args=args, fixedheight=24), cellPadding=(0, 8, 11, 8))
    198     panel.AddCell(grid, cellPadding=(1, 0, 1, 0), colSpan=panel.columns)
    199 
    200 
    201 def add_omega_info(panel, skill):
    202     grid = LayoutGrid(columns=2)
    203     grid.AddCell(cellPadding=(TOOLTIP_WIDTH_DEFAULT - 2,
    204      8,
    205      0,
    206      0), colSpan=2)
    207     add_background_gradient(grid, clonegrade.COLOR_OMEGA_BG)
    208     grid.AddCell(Sprite(align=uiconst.CENTERLEFT, texturePath='res:/UI/Texture/classes/CloneGrade/Omega_Icon.png', opacity=0.7, pos=(0, 0, 24, 24)), cellPadding=(11, 0, 8, 8))
    209     if skill.level_max == 0:
    210         text = localization.GetByLabel('UI/CloneState/SkillRequiresOmega')
    211     elif skill.level_max < skill.level:
    212         text = localization.GetByLabel('UI/CloneState/SkillLevelRestricted', maxLevel=skill.level_max)
    213     else:
    214         text = localization.GetByLabel('UI/CloneState/SkillRequriesOmegaForFurtherTraining', level=skill.level_including_queued)
    215     grid.AddCell(eveLabel.EveLabelMedium(align=uiconst.CENTERLEFT, width=TOOLTIP_WIDTH_DEFAULT - 24 - 24 - 8, text=text), cellPadding=(0, 0, 11, 8))
    216     panel.AddCell(grid, cellPadding=(1, 0, 1, 0), colSpan=panel.columns)
    217 
    218 
    219 def add_expert_system_information(panel, skill):
    220     expertSystems.add_skill_provided_by_expert_systems(panel, skill.type_id, padding=(12, 8, 12, 0))
    221 
    222 
    223 def add_primary_action(panel, skill, skillLevel = None):
    224     controller = SkillPrimaryActionController(skill, skillLevel)
    225     button = primaryButton.PrimaryButton(align=uiconst.CENTER, hint=controller.error_message, controller=controller)
    226     panel.AddCell(button, cellPadding=(12, 8, 12, 0), colSpan=panel.columns)
    227 
    228 
    229 def add_background_gradient(grid, color):
    230     rgb = Color(*color).GetRGB()
    231     GradientSprite(bgParent=grid, rgbData=[(0.0, rgb), (1.0, rgb)], alphaData=[(0.0, 0.2), (1.0, 0.01)])