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

cloneUpgradeWindow.py (13359B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\cloneGrade\cloneUpgradeWindow.py
      2 import carbonui.const as uiconst
      3 import evetypes
      4 import inventorycommon.const as invconst
      5 import uthread
      6 from carbonui.primitives.container import Container
      7 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      8 from carbonui.primitives.sprite import Sprite
      9 from carbonui.uianimations import animations
     10 from clonegrade.const import COLOR_OMEGA_ORANGE, COLOR_OMEGA_GOLD, COLOR_OMEGA_BG
     11 from eve.client.script.ui import eveColor
     12 from eve.client.script.ui.control.eveLabel import Label
     13 from eve.client.script.ui.control.glowSprite import GlowSprite
     14 from eve.client.script.ui.plex.textures import PLEX_32_SOLID_WHITE
     15 from eve.client.script.ui.shared.cloneGrade import REASON_DEFAULT
     16 from eve.client.script.ui.shared.cloneGrade.upgradeButton import UpgradeButton
     17 from eve.client.script.ui.shared.cloneGrade.baseClonesStateWindow import BaseCloneStateWindow, VIDEO_WIDTH
     18 from eve.client.script.ui.shared.cloneGrade.util import upgrade_clone_action
     19 from eveexceptions.exceptionEater import ExceptionEater
     20 from localization import GetByLabel
     21 from notifications.common.formatters.plexDonation import LinkifyOwner
     22 from omega.client.clone_grade_svc import get_clone_grade_svc
     23 STATE_UPGRADE = 'upgradeFromAlpha'
     24 STATE_FANFARE = 'upgradeFanfare'
     25 STATE_EXTEND = 'extendSubscription'
     26 ICON_OPACITY_HOVER = 0.7
     27 ICON_OPACITY_IDLE = 1.0
     28 VIDEOOPACITY_IDLE = 0.5
     29 VIDEOOPACITY_HOVER = 0.8
     30 
     31 class CloneUpgradeWindow(BaseCloneStateWindow):
     32     default_windowID = 'CloneUpgradeWindow'
     33     default_width = 540
     34     default_fixedWidth = 540
     35     default_height = 680
     36     default_fixedHeight = 680
     37 
     38     def ApplyAttributes(self, attributes):
     39         showFanfare = attributes.showFanfare
     40         self.giftData = attributes.giftData
     41         self.origin = attributes.get('origin', None)
     42         self.reason = attributes.get('reason', None) or REASON_DEFAULT
     43         self.UpdateState(showFanfare)
     44         self._glow = 0.0
     45         self.continueButton = None
     46         attributes['analyticID'] = 'omega_upgrade_window_old' if not showFanfare else None
     47         BaseCloneStateWindow.ApplyAttributes(self, attributes)
     48         sm.GetService('audio').SendUIEvent('upgrade_menu_window_play')
     49         if not showFanfare:
     50             self._LogWindowOpened()
     51         if self.giftData:
     52             self.UpdateToGiftLayout()
     53 
     54     def UpdateToGiftLayout(self):
     55         self.upgradeLabel.SetText(GetByLabel('UI/CloneState/GiftingSuccessful'))
     56         Label(name='GiftingContext', parent=self.mainCont, align=uiconst.CENTERTOP, state=uiconst.UI_NORMAL, text=GetByLabel('UI/CloneState/GiftingContext', senderName=LinkifyOwner(self.giftData['senderCharID'])), uppercase=True, bold=True, color=COLOR_OMEGA_ORANGE, top=200 if self.giftData['message'] else 365, width=self.width)
     57         if self.giftData['message']:
     58             self.omegaIcon.SetPosition(0, 15)
     59             self.bgVideo.SetPosition(0, -250)
     60             self.upgradeLabel.SetPosition(0, 100)
     61             Container(name='textBackground', parent=self.mainCont, align=uiconst.CENTERTOP, pos=(0, 112, 330, 115), bgColor=(0, 0, 0, 0.4))
     62             messageLabel = Label(name='giftingMessage', parent=self.mainCont, align=uiconst.CENTER, text='<center>%s</center>' % self.giftData['message'], uppercase=True, bold=True, color=COLOR_OMEGA_ORANGE, width=350, top=-25, fontsize=15)
     63             Container(name='textBackground', parent=self.mainCont, align=uiconst.CENTER, pos=(0,
     64              -25,
     65              messageLabel.width + 20,
     66              messageLabel.height + 20), bgColor=(0, 0, 0, 0.4))
     67         else:
     68             self.omegaIcon.SetPosition(0, 180)
     69             self.bgVideo.SetPosition(0, -86)
     70             self.upgradeLabel.SetPosition(0, 266)
     71 
     72     def ConstructLayout(self):
     73         self.omegaIcon = Sprite(name='omegaIcon', parent=self.sr.main, align=uiconst.CENTERTOP, pos=(0, 180, 110, 110), opacity=ICON_OPACITY_IDLE, texturePath='res:/UI/Texture/Classes/CloneGrade/Omega_128.png')
     74         self.mainCont = Container(name='mainCont', parent=self.sr.main, opacity=0.0)
     75 
     76     def Close(self, *args, **kwds):
     77         BaseCloneStateWindow.Close(self, *args, **kwds)
     78         sm.GetService('audio').SendUIEvent('upgrade_menu_window_stop')
     79 
     80     def LoadContent(self, animate = True):
     81         if animate:
     82             duration = 0.6
     83             animations.FadeOut(self.mainCont, duration=duration)
     84             animations.MorphScalar(self, 'glow', self.glow, 0.0, duration=duration, sleep=True)
     85         self.mainCont.Flush()
     86         self.ConstructUpgradeButton()
     87         self.ConstructPlexContainer()
     88         self.ConstructBenefitEntries()
     89         if self.windowState == STATE_FANFARE:
     90             self.ConstructContinueButton()
     91         self.AnimEntry()
     92 
     93     def ConstructContinueButton(self):
     94         self.continueButton = UpgradeButton(parent=self.mainCont, align=uiconst.CENTERBOTTOM, pos=(0, 20, 150, 41), onClick=self.CloseByUser, text=GetByLabel('UI/Agents/Dialogue/Buttons/Continue'), opacity=0.0)
     95 
     96     def ConstructPlexContainer(self):
     97         if self.windowState != STATE_FANFARE:
     98             PlexContainer(parent=self.mainCont, align=uiconst.CENTERTOP, top=360)
     99 
    100     def ConstructUpgradeButton(self):
    101         if self.windowState == STATE_FANFARE:
    102             self.upgradeLabel = Label(parent=self.mainCont, align=uiconst.CENTERTOP, state=uiconst.UI_DISABLED, text=GetByLabel('UI/CloneState/UpgradeSuccessful'), uppercase=True, bold=True, color=COLOR_OMEGA_ORANGE, top=296, width=self.width)
    103         else:
    104             if self.windowState == STATE_UPGRADE:
    105                 text = GetByLabel('UI/CloneState/UpgradeToOmega')
    106             else:
    107                 text = GetByLabel('UI/CloneState/ExtendSubscription')
    108             UpgradeButton(parent=self.mainCont, align=uiconst.CENTERTOP, pos=(0, 300, 350, 41), onMouseEnterCallback=self.OnUpgradeButtonMouseEnter, onMouseExitCallback=self.OnUpgradeButtonMouseExit, onClick=self.OnUpgradeButtonClick, text=text, analyticID='upgrade_omega_secure_old')
    109 
    110     def OnUpgradeButtonClick(self, *args):
    111         upgrade_clone_action(self.origin, self.reason)
    112 
    113     def UpdateState(self, showFanfare = False):
    114         if showFanfare:
    115             self.windowState = STATE_FANFARE
    116         elif get_clone_grade_svc().is_omega_with_grace_period():
    117             self.windowState = STATE_EXTEND
    118         else:
    119             self.windowState = STATE_UPGRADE
    120 
    121     def OnShowFanfare(self):
    122         self.windowState = STATE_FANFARE
    123         self.LoadContent(animate=True)
    124 
    125     def AnimEntry(self):
    126         duration = 0.6
    127         animations.FadeTo(self.mainCont, self.mainCont.opacity, 1.0, duration=duration)
    128         if self.windowState == STATE_FANFARE:
    129             timeOffset = 1.2
    130             animations.MorphScalar(self, 'glow', 15.0, 2.0, duration=1.2)
    131             for i, benefitEntry in enumerate(self.benefitCont.children):
    132                 try:
    133                     benefitEntry.AnimEntry(0.5, i * 0.15 + timeOffset)
    134                 except AttributeError:
    135                     pass
    136 
    137             animations.FadeTo(self.continueButton, 0.0, 1.0, duration=0.6, timeOffset=1.6)
    138         else:
    139             timeOffset = 0.0
    140             animations.MorphScalar(self, 'glow', self.glow, 0.5, duration=2.0)
    141             for i, benefitEntry in enumerate(self.benefitCont.children):
    142                 try:
    143                     benefitEntry.AnimEntry(0.5, i * 0.07)
    144                 except AttributeError:
    145                     pass
    146 
    147         animations.FadeTo(self.bottomCont, 0.0, 1.0, duration=0.6, timeOffset=timeOffset)
    148 
    149     def OnUpgradeButtonMouseEnter(self):
    150         animations.MorphScalar(self, 'glow', self.glow, 1.0, duration=0.25)
    151 
    152     def OnUpgradeButtonMouseExit(self):
    153         animations.MorphScalar(self, 'glow', self.glow, 0.5, duration=0.15)
    154 
    155     def ConstructBenefitEntries(self):
    156         top = 80 if self.windowState == STATE_FANFARE else 50
    157         self.bottomCont = Container(name='bottomCont', parent=self.mainCont, align=uiconst.CENTERBOTTOM, pos=(0,
    158          top,
    159          450,
    160          190), bgColor=(0, 0, 0, 0.4))
    161         self.benefitCont = ContainerAutoSize(parent=self.bottomCont, align=uiconst.CENTER, width=400)
    162         for text, hint, texturePath in self.GetBenefits():
    163             BenefitEntry(parent=self.benefitCont, align=uiconst.TOTOP, height=40, text=text, hint=hint, texturePath=texturePath, opacity=0.0, windowState=self.windowState)
    164 
    165     def GetBenefits(self):
    166         return ((GetByLabel('UI/CloneState/BenefitAllShipsAndModules', numShips=self.GetNumShipsInGame()), GetByLabel('UI/CloneState/BenefitAllShipsAndModulesHint'), 'res:/UI/Texture/classes/cloneGrade/benefits/allShipsAndModules.png'),
    167          (GetByLabel('UI/CloneState/BenefitAllSkills', numSkills=self.GetNumSkillsInGame()), GetByLabel('UI/CloneState/BenefitAllSkillsHint'), 'res:/UI/Texture/classes/cloneGrade/benefits/allSkills.png'),
    168          (GetByLabel('UI/CloneState/BenefitFasterTraining'), GetByLabel('UI/CloneState/BenefitFasterTrainingHint'), 'res:/UI/Texture/classes/cloneGrade/benefits/fasterTraining.png'),
    169          (GetByLabel('UI/CloneState/BenefitTriglavianShips'), GetByLabel('UI/CloneState/BenefitTriglavianShipsHint'), 'res:/UI/Texture/classes/cloneGrade/benefits/triglavianSkills.png'))
    170 
    171     def GetNumSkillsInGame(self):
    172         return self._GetNumTypesInGroup(invconst.categorySkill)
    173 
    174     def GetNumShipsInGame(self):
    175         return self._GetNumTypesInGroup(invconst.categoryShip)
    176 
    177     def _GetNumTypesInGroup(self, categoryID):
    178         typeIDs = evetypes.GetTypeIDsByCategory(categoryID)
    179         return len([ typeID for typeID in typeIDs if evetypes.IsPublished(typeID) ])
    180 
    181     @classmethod
    182     def ShowFanfare(cls, giftData = None):
    183         wnd = cls.GetIfOpen()
    184         if wnd:
    185             wnd.OnShowFanfare()
    186         else:
    187             cls.Open(showFanfare=True, giftData=giftData)
    188 
    189     @property
    190     def glow(self):
    191         return self._glow
    192 
    193     @glow.setter
    194     def glow(self, value):
    195         self._glow = value
    196         self.bgVideo.opacity = 0.5 + 0.3 * value
    197         self.omegaIcon.opacity = max(1.0 - 0.3 * value, 0.7)
    198         self.bgVideo.width = VIDEO_WIDTH * (1.0 + 0.25 * value)
    199         self.bgSprite.effectOpacity = -0.6 + 0.4 * value
    200 
    201     def _LogWindowOpened(self):
    202         with ExceptionEater('eventLog'):
    203             uthread.new(sm.ProxySvc('eventLog').LogClientEvent, 'trial', ['origin', 'reason'], 'ShowCloneUpgradeWindow', self.origin, self.reason)
    204 
    205 
    206 class BenefitEntry(Container):
    207     default_name = 'BenefitEntry'
    208     default_state = uiconst.UI_NORMAL
    209 
    210     def ApplyAttributes(self, attributes):
    211         Container.ApplyAttributes(self, attributes)
    212         texturePath = attributes.texturePath
    213         text = attributes.text
    214         self.hint = attributes.hint
    215         self.windowState = attributes.windowState
    216         if self.windowState != STATE_UPGRADE:
    217             texturePath = 'res:/UI/Texture/Classes/MissionTracker/tracker_check.png'
    218             size = 20
    219             color = COLOR_OMEGA_GOLD
    220         else:
    221             size = 32
    222             color = COLOR_OMEGA_BG
    223         self.icon = Sprite(name='icon', parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, texturePath=texturePath, pos=(0,
    224          0,
    225          size,
    226          size), color=color)
    227         Label(parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, text=text, fontsize=14, left=50)
    228 
    229     def LoadTooltipPanel(self, tooltipPanel, *args):
    230         tooltipPanel.LoadGeneric1ColumnTemplate()
    231         tooltipPanel.AddLabelMedium(text=self.hint, wrapWidth=250)
    232 
    233     def GetTooltipPointer(self):
    234         return uiconst.POINT_RIGHT_2
    235 
    236     def AnimEntry(self, duration = 0.3, timeOffset = None):
    237         animations.FadeIn(self, duration=duration, timeOffset=timeOffset)
    238         if self.windowState == STATE_FANFARE:
    239             animations.FadeTo(self.icon, 10.0, 1.0, duration=duration, timeOffset=timeOffset)
    240 
    241 
    242 class PlexContainer(ContainerAutoSize):
    243     default_name = 'PlexContainer'
    244     default_state = uiconst.UI_NORMAL
    245     analyticID = 'upgrade_omega_nes_old'
    246 
    247     def ApplyAttributes(self, attributes):
    248         ContainerAutoSize.ApplyAttributes(self, attributes)
    249         self.icon = GlowSprite(name='icon', parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, texturePath=PLEX_32_SOLID_WHITE, pos=(0, 0, 32, 32))
    250         self.label = Label(parent=self, align=uiconst.CENTERLEFT, state=uiconst.UI_DISABLED, text=GetByLabel('UI/CloneState/UsePlexToUpgrade'), fontsize=18, left=34, color=eveColor.WHITE)
    251 
    252     def OnMouseEnter(self, *args):
    253         self.icon.OnMouseEnter()
    254         animations.FadeTo(self.label, self.label.opacity, 1.2, duration=0.1)
    255 
    256     def OnMouseExit(self, *args):
    257         self.icon.OnMouseExit()
    258         animations.FadeTo(self.label, self.label.opacity, 1.0, duration=0.3)
    259 
    260     def LoadTooltipPanel(self, tooltipPanel, *args):
    261         tooltipPanel.LoadGeneric1ColumnTemplate()
    262         tooltipPanel.AddLabelMedium(text=GetByLabel('UI/CloneState/UsePlexToUpgradeHint'), wrapWidth=250)
    263 
    264     def GetTooltipPointer(self):
    265         return uiconst.POINT_RIGHT_2
    266 
    267     def OnClick(self):
    268         from carbonui.loggers.buttonLogger import log_button_clicked
    269         from eve.client.script.ui.shared.neocom.characterSheetWindow import CharacterSheetWindow
    270         log_button_clicked(self)
    271         CharacterSheetWindow.OpenPLEX()