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

milestoneTooltips.py (12137B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\skillPlan\milestone\milestoneTooltips.py
      2 import eveformat
      3 import evetypes
      4 from carbon.client.script.environment.AudioUtil import PlaySound
      5 from carbonui import TextColor, uiconst
      6 from carbonui.control.button import Button
      7 from carbonui.primitives.container import Container
      8 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      9 from carbonui.primitives.sprite import StreamingVideoSprite
     10 from carbonui.util.color import Color
     11 from eve.client.script.ui import eveColor
     12 from eve.client.script.ui.control.eveLabel import EveLabelLarge
     13 from eve.client.script.ui.control.skillBar.skillBar import SkillBar
     14 from eve.client.script.ui.control.tooltips import TooltipPanel
     15 from eve.client.script.ui.shared.neocom.skillConst import COLOR_SKILL_1
     16 from eve.client.script.ui.skillPlan.skillPlanConst import MILESTONE_ICON_BY_SUBTYPE
     17 from eveui import Sprite
     18 from localization import GetByLabel
     19 from eve.client.script.ui.control import tooltips
     20 from eve.client.script.ui.tooltips.tooltipsWrappers import TooltipBaseWrapper
     21 from localization.formatters import FormatTimeIntervalShortWritten
     22 from skills.skillConst import skill_max_level
     23 from skills.skillplan.milestone.const import MilestoneSubType
     24 from skills.skillplan.milestone.milestonesUtil import GetMilestoneSubType
     25 from carbonui.uicore import uicore
     26 WRAP_WIDTH = 300
     27 
     28 class AddMilestonesTooltip(TooltipBaseWrapper):
     29 
     30     def __init__(self):
     31         super(AddMilestonesTooltip, self).__init__()
     32 
     33     def CreateTooltip(self, parent, owner, idx):
     34         if uicore.IsDragging():
     35             return
     36         self.tooltipPanel = tooltips.TooltipPanel(parent=parent, owner=owner, idx=idx)
     37         self.tooltipPanel.LoadStandardSpacing()
     38         self.tooltipPanel.columns = 2
     39         self.tooltipPanel.AddMediumHeader(text=GetByLabel('UI/SkillPlan/AddingMilestones'))
     40         video = StreamingVideoSprite(state=uiconst.UI_DISABLED, videoPath='res:/video/SkillPlan/SkillPlanCreationTutorial.webm', width=320, height=192, videoLoop=True)
     41         self.tooltipPanel.AddCell(cellObject=video, colSpan=2)
     42         self.tooltipPanel.AddLabelMedium(text=GetByLabel('UI/SkillPlan/MilestonesDragDropInformation'), wrapWidth=WRAP_WIDTH, colSpan=self.tooltipPanel.columns)
     43         iconColor = (1, 1, 1, 0.75)
     44         self.tooltipPanel.AddSpriteLabel(texturePath=MILESTONE_ICON_BY_SUBTYPE[MilestoneSubType.SHIP_MILESTONE], label=GetByLabel('UI/SkillPlan/MilestoneShip'), iconOffset=5, iconColor=iconColor)
     45         self.tooltipPanel.AddSpriteLabel(texturePath=MILESTONE_ICON_BY_SUBTYPE[MilestoneSubType.MODULE_MILESTONE], label=GetByLabel('UI/SkillPlan/MilestoneModule'), iconOffset=-5, iconColor=iconColor)
     46         self.tooltipPanel.AddSpriteLabel(texturePath=MILESTONE_ICON_BY_SUBTYPE[MilestoneSubType.SKILL_MILESTONE], label=GetByLabel('UI/SkillPlan/MilestoneSkill'), iconOffset=5, iconColor=iconColor)
     47         self.tooltipPanel.AddSpriteLabel(texturePath=MILESTONE_ICON_BY_SUBTYPE[MilestoneSubType.OTHER_MILESTONE], label=GetByLabel('UI/SkillPlan/MilestoneOther'), iconOffset=-5, iconColor=iconColor)
     48         return self.tooltipPanel
     49 
     50 
     51 class MilestoneCompletedBanner(Container):
     52     default_height = 36
     53 
     54     def ApplyAttributes(self, attributes):
     55         super(MilestoneCompletedBanner, self).ApplyAttributes(attributes)
     56         leftCont = Container(name='leftcont', parent=self, align=uiconst.TOLEFT, width=42, bgColor=eveColor.COPPER_OXIDE_GREEN)
     57         Sprite(name='completedIcon', parent=leftCont, align=uiconst.CENTER, pos=(0, 0, 34, 34), texturePath='res:/UI/Texture/classes/SkillPlan/completedIcon.png')
     58         mainCont = Container(name='mainCont', parent=self, bgColor=eveColor.WHITE, padLeft=4)
     59         EveLabelLarge(parent=mainCont, align=uiconst.CENTERLEFT, text=GetByLabel('UI/SkillPlan/Completed'), color=eveColor.BLACK, left=14)
     60 
     61 
     62 class MilestoneInfoTooltip(TooltipPanel):
     63 
     64     def ApplyAttributes(self, attributes):
     65         super(MilestoneInfoTooltip, self).ApplyAttributes(attributes)
     66         self.skillPlan = attributes.skillPlan
     67         self.milestone = attributes.milestone
     68         self.isEditable = attributes.isEditable
     69         self.milestoneSubType = GetMilestoneSubType(self.milestone.GetTypeID())
     70         self.iconSize = attributes.iconSize
     71         self.timeLabel = None
     72         self.ReconstructLayout()
     73 
     74     def ReconstructLayout(self):
     75         self.Flush()
     76         self.LoadStandardSpacing()
     77         self.columns = 2
     78         if self.isEditable:
     79             self.SetState(uiconst.UI_NORMAL)
     80         self.CreateTopSection()
     81         self.CreateMiddleSection()
     82         self.CreateBottomSection()
     83         if self.milestone.IsCompleted():
     84             banner = MilestoneCompletedBanner(align=uiconst.TOTOP, padTop=6)
     85             self.AddCell(banner, colSpan=self.columns, cellPadding=0)
     86 
     87     def CreateTopSection(self):
     88         text = '%s: %s' % (GetByLabel('UI/SkillPlan/Milestone'), self._GetTypeLabel())
     89         self.AddMediumHeader(text=text)
     90         self.AddLabelMedium(text=self._GetUnlocksText(), width=WRAP_WIDTH, cellPadding=(self.cellPadding[0], 5), colSpan=self.columns)
     91 
     92     def CreateMiddleSection(self):
     93         pass
     94 
     95     def CreateBottomSection(self):
     96         self.FillRow()
     97         showInfoCont = ContainerAutoSize(name='showInfoCont', align=uiconst.CENTERLEFT, height=35)
     98         ContainerAutoSize(parent=showInfoCont, name='textCont', align=uiconst.TOLEFT)
     99         self.timeLabel = None
    100         totalTime = self.GetTotalTimeDate()
    101         if totalTime:
    102             totalTimeText = GetByLabel('UI/SkillPlan/TotalTrainingTime', color=Color(*COLOR_SKILL_1).GetHex())
    103             row, label = self.AddMediumHeader(text=totalTimeText, labelColSpan=1)
    104             self.timeLabel = EveLabelLarge(text=totalTime, align=uiconst.CENTERRIGHT, color=COLOR_SKILL_1)
    105             row.AddCell(self.timeLabel)
    106         if self.isEditable:
    107 
    108             def OnRemoveBtn(*args):
    109                 PlaySound('skills_planner_skill_remove_play')
    110                 self.skillPlan.RemoveMilestone(self.milestone.GetID())
    111                 self.Close()
    112 
    113             removeBtn = Button(name='removeBtn', align=uiconst.TOTOP, label=GetByLabel('UI/SkillPlan/RemoveMilestone'), func=OnRemoveBtn)
    114             self.AddCell(cellObject=removeBtn, colSpan=self.columns, cellPadding=(0, self.cellPadding[1]))
    115 
    116     def GetTotalTimeDate(self):
    117         totalTime = sm.GetService('skills').GetSkillTrainingTimeLeftToUseType(self.milestone.GetTypeID(), includeBoosters=False)
    118         if not totalTime:
    119             return None
    120         dateText = FormatTimeIntervalShortWritten(long(totalTime), showFrom='day')
    121         return dateText
    122 
    123     def _GetTypeLabel(self):
    124         if self.milestoneSubType == MilestoneSubType.SHIP_MILESTONE:
    125             return GetByLabel('UI/SkillPlan/MilestoneShip')
    126         if self.milestoneSubType == MilestoneSubType.SKILL_MILESTONE:
    127             return GetByLabel('UI/SkillPlan/MilestoneSkill')
    128         if self.milestoneSubType == MilestoneSubType.MODULE_MILESTONE:
    129             return GetByLabel('UI/SkillPlan/MilestoneModule')
    130         if self.milestoneSubType == MilestoneSubType.OTHER_MILESTONE:
    131             return GetByLabel('UI/SkillPlan/MilestoneOther')
    132 
    133     def _GetUnlocksText(self):
    134         if self.milestoneSubType == MilestoneSubType.SKILL_MILESTONE:
    135             return GetByLabel('UI/SkillPlan/CompleteMilestoneUnlocks')
    136         else:
    137             return GetByLabel('UI/SkillPlan/CompleteMilestoneUnlocks')
    138 
    139 
    140 class TypeIDMilestoneInfoTooltip(MilestoneInfoTooltip):
    141 
    142     def CreateMiddleSection(self):
    143         super(TypeIDMilestoneInfoTooltip, self).CreateMiddleSection()
    144         sprite, _ = self.AddSpriteLabel(texturePath='', label=evetypes.GetName(self.milestone.GetTypeID()), iconOffset=0, labelOffset=0, mainAlign=uiconst.CENTER, align=uiconst.TOTOP, textAlign=uiconst.CENTER, iconSize=self.iconSize, colSpan=self.columns)
    145         sm.GetService('photo').GetIconByType(sprite, self.milestone.GetTypeID(), size=self.iconSize, ignoreSize=False)
    146 
    147 
    148 class SkillMilestoneInfoTooltip(MilestoneInfoTooltip):
    149 
    150     def CreateMiddleSection(self):
    151         super(SkillMilestoneInfoTooltip, self).CreateMiddleSection()
    152         cont = ContainerAutoSize(name='cont', alignt=uiconst.CENTERLEFT, height=30)
    153         self.skillBar = SkillBar(parent=cont, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, skillID=self.milestone.GetTypeID(), requiredLevel=self.milestone.GetLevel())
    154         self.levelLabel = EveLabelLarge(parent=cont, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, left=self.skillBar.width + 10)
    155         self.AddCell(cont, colSpan=self.columns)
    156         if self.isEditable:
    157             self._ConstructLevelEdit()
    158         self._UpdateLevelDisplay()
    159 
    160     def GetTotalTimeDate(self):
    161         skillSvc = sm.GetService('skills')
    162         required = skillSvc.GetRequiredSkillsRecursive(self.milestone.GetTypeID())
    163         required[self.milestone.GetTypeID()] = max(self.milestone.GetLevel(), required.get(self.milestone.GetTypeID(), 0))
    164         totalTime = skillSvc.GetSkillTrainingTimeLeftForTypesAndLevels(required, includeBoosters=False)
    165         if not totalTime:
    166             return None
    167         dateText = FormatTimeIntervalShortWritten(long(totalTime), showFrom='day')
    168         return dateText
    169 
    170     def _ConstructLevelEdit(self):
    171         cont = Container(colSpan=self.columns, align=uiconst.CENTER)
    172         padding = 40
    173         minusBtn = Button(name='minusBtn', parent=cont, align=uiconst.CENTERLEFT, texturePath='res:/UI/Texture/Shared/DarkStyle/buttonIconMinus.png', soundClick='skills_planner_skill_decrease_play')
    174         self.modifyLevelLabel = EveLabelLarge(parent=cont, align=uiconst.CENTERLEFT, state=uiconst.UI_NORMAL, left=minusBtn.width + padding, text=GetByLabel('UI/SkillPlan/LevelNum', levelNum=self.milestone.GetLevel()))
    175         plusBtn = Button(name='plusBtn', parent=cont, align=uiconst.CENTERLEFT, left=self.modifyLevelLabel.left + self.modifyLevelLabel.width + padding, texturePath='res:/UI/Texture/Shared/DarkStyle/buttonIconPlus.png', soundClick='skills_planner_skill_increase_play')
    176         minusBtn.SetFunc(lambda *args: self._ModifyLevelInTooltip(minusBtn, plusBtn, -1))
    177         plusBtn.SetFunc(lambda *args: self._ModifyLevelInTooltip(minusBtn, plusBtn, 1))
    178         self._UpdateBtns(minusBtn, plusBtn)
    179         cont.height = max(minusBtn.height, plusBtn.height, self.modifyLevelLabel.height)
    180         cont.width = plusBtn.left + plusBtn.width
    181         self.AddCell(cellObject=cont, colSpan=self.columns)
    182 
    183     def _ModifyLevelInTooltip(self, minusBtn, plusBtn, direction):
    184         milestone = self.skillPlan.GetMilestone(self.milestone.GetID())
    185         if not milestone:
    186             return
    187         milestone.SetLevel(self.milestone.GetLevel() + direction)
    188         totalTime = self.GetTotalTimeDate()
    189         if totalTime and not self.timeLabel:
    190             self.ReconstructLayout()
    191         elif not totalTime and self.timeLabel:
    192             self.ReconstructLayout()
    193         else:
    194             self._UpdateLevelDisplay()
    195             self._UpdateBtns(minusBtn, plusBtn)
    196 
    197     def _UpdateBtns(self, minusBtn, plusBtn):
    198         minusBtn.Enable()
    199         plusBtn.Enable()
    200         if self.milestone.GetLevel() <= 1:
    201             minusBtn.Disable()
    202         elif self.milestone.GetLevel() >= skill_max_level:
    203             plusBtn.Disable()
    204 
    205     def _UpdateLevelDisplay(self):
    206         if self.milestone.GetLevel():
    207             color = Color.RGBtoHex(*TextColor.NORMAL)
    208             text = GetByLabel('UI/InfoWindow/RequiredSkillNameAndLevel', skill=self.milestone.GetTypeID(), level=eveformat.number_roman(self.milestone.GetLevel()), levelColor=color)
    209             self.skillBar.SetRequiredLevel(self.milestone.GetLevel())
    210         else:
    211             text = evetypes.GetName(self.milestone.GetTypeID())
    212         self.levelLabel.text = text
    213         if getattr(self, 'modifyLevelLabel', None):
    214             self.modifyLevelLabel.text = GetByLabel('UI/SkillPlan/LevelNum', levelNum=self.milestone.GetLevel())
    215         if self.timeLabel:
    216             totalTime = self.GetTotalTimeDate()
    217             self.timeLabel.text = totalTime if totalTime else '-'
    218         return text