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

AbyssJumpWindow.py (9000B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\abyss\AbyssJumpWindow.py
      2 from carbon.common.script.util.format import FmtDate
      3 from carbonui import uiconst
      4 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      5 from carbonui.uianimations import animations
      6 from eve.client.script.ui.control import eveLabel
      7 from carbonui.control.window import Window
      8 from eve.client.script.ui.control.itemIcon import ItemIcon
      9 from eve.client.script.ui.crimewatch import crimewatchConst
     10 from eve.client.script.ui.crimewatch.crimewatchTimers import Timer, TimerType
     11 from eve.common.lib import appConst
     12 import abyss
     13 from abyss.client import ClientValidator
     14 import blue
     15 import dogma.const
     16 import evetypes
     17 import localization
     18 import signals
     19 import uthread
     20 from eve.client.script.ui.shared.abyss.baseActivationController import BaseActivationController
     21 from eve.client.script.ui.shared.abyss.activateButton import ActivateButton
     22 from eve.client.script.ui.shared.abyss.const import TIER_DESCRIPTION_BY_TIER, WEATHER_DESCRIPTION_BY_TYPE
     23 from eve.client.script.ui.shared.abyss.utils import GetAttribute
     24 
     25 class JumpActivationController(BaseActivationController):
     26 
     27     def __init__(self, gateID, gameModeID, typeID):
     28         super(JumpActivationController, self).__init__(gateID, ClientValidator(abyss.get_game_mode(gameModeID), gate_id=gateID, type_id=typeID))
     29 
     30     def _Validate(self):
     31         self._validator.validate_jump()
     32 
     33     def _Activate(self):
     34         sm.GetService('sessionMgr').PerformSessionChange('JumpToAbyss', sm.GetService('abyss').activate_entrance_gate, self.itemID)
     35         self._isFinished = True
     36 
     37     def GetText(self):
     38         if self.isActivating:
     39             return localization.GetByLabel('UI/Abyss/Jumping')
     40         else:
     41             return localization.GetByLabel('UI/Abyss/Activate')
     42 
     43 
     44 class AbyssEntranceWindowController(object):
     45 
     46     def __init__(self, gateID):
     47         ballpark = sm.GetService('michelle').GetBallpark()
     48         slimItem = ballpark.GetInvItem(gateID)
     49         self._itemID = gateID
     50         self._typeID = slimItem.abyssFilamentTypeID
     51         self._gameModeID = slimItem.gameModeID or abyss.GameModeID.UNKNOWN
     52         self.jumpController = JumpActivationController(gateID, self._gameModeID, self._typeID)
     53         self.onChange = signals.Signal(signalName='onChange')
     54         self.jumpController.onChange.connect(self.onChange)
     55 
     56     @property
     57     def itemID(self):
     58         return self._itemID
     59 
     60     @property
     61     def isFinished(self):
     62         return self.jumpController.isFinished
     63 
     64     @property
     65     def isSuspicious(self):
     66         return False
     67 
     68     @property
     69     def name(self):
     70         return evetypes.GetName(self.typeID)
     71 
     72     @property
     73     def suspectDescription(self):
     74         color = crimewatchConst.Colors.Suspect.GetHex()
     75         time = FmtDate(appConst.criminalTimerTimeout)
     76         return localization.GetByLabel('UI/Abyss/SuspectDescription', color=color, time=time)
     77 
     78     @property
     79     def tier(self):
     80         return GetAttribute(self.typeID, dogma.const.attributeDifficultyTier)
     81 
     82     @property
     83     def tierDescription(self):
     84         label = TIER_DESCRIPTION_BY_TIER[self.tier]
     85         return localization.GetByLabel(label)
     86 
     87     @property
     88     def timerDescription(self):
     89         color = crimewatchConst.Colors.Red.GetHex()
     90         time = FmtDate(abyss.DEFAULT_ABYSS_CONTENT_DURATION)
     91         return localization.GetByLabel('UI/Abyss/TimerDescription', color=color, time=time)
     92 
     93     @property
     94     def typeDescription(self):
     95         return localization.GetByLabel(abyss.get_game_mode(self._gameModeID).jump_description_label)
     96 
     97     @property
     98     def typeID(self):
     99         return self._typeID
    100 
    101     @property
    102     def weather(self):
    103         return GetAttribute(self.typeID, dogma.const.attributeWeatherID)
    104 
    105     @property
    106     def weatherDescription(self):
    107         label = WEATHER_DESCRIPTION_BY_TYPE[self.weather]
    108         return localization.GetByLabel(label)
    109 
    110     @property
    111     def weatherName(self):
    112         return evetypes.GetName(self.weather)
    113 
    114     def Close(self):
    115         self.jumpController.Close()
    116         self.onChange.clear()
    117 
    118     def GetKeyTypeID(self, gateID):
    119         ballpark = sm.GetService('michelle').GetBallpark()
    120         slimItem = ballpark.GetInvItem(gateID)
    121         return slimItem.abyssFilamentTypeID
    122 
    123 
    124 class AbyssActivationWindow(Window):
    125     __guid__ = 'form.AbyssActivationWindow'
    126     default_fixedWidth = 420
    127     default_left = '__center__'
    128     default_top = '__center__'
    129     default_windowID = 'AbyssActivationWindow'
    130     default_isCollapseable = False
    131     default_isLightBackgroundConfigurable = False
    132     default_isStackable = False
    133     default_isLockable = False
    134     default_isOverlayable = False
    135     default_iconNum = 'res:/ui/Texture/WindowIcons/abyssalFilament.png'
    136 
    137     @classmethod
    138     def Open(cls, **attributes):
    139         window = cls.GetIfOpen()
    140         if not window:
    141             return super(AbyssActivationWindow, cls).Open(**attributes)
    142         itemID = attributes.get('itemID', None)
    143         if itemID == window.controller.itemID:
    144             window.Maximize()
    145             return window
    146         window.CloseByUser()
    147         return super(AbyssActivationWindow, cls).Open(**attributes)
    148 
    149     def ApplyAttributes(self, attributes):
    150         super(AbyssActivationWindow, self).ApplyAttributes(attributes)
    151         self.controller = AbyssEntranceWindowController(attributes.item)
    152         self.Layout()
    153         self.SetCaption(evetypes.GetName(self.controller.typeID))
    154         self.controller.onChange.connect(self.UpdateState)
    155 
    156     def Layout(self):
    157         self.mainCont = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, padding=0, callback=self._FixHeight, idx=0)
    158         filamentCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=64)
    159         ItemIcon(parent=filamentCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 64, 64), showOmegaOverlay=False, typeID=self.controller.typeID)
    160         filamentInnerCont = ContainerAutoSize(parent=filamentCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 0, 0, 0))
    161         eveLabel.EveLabelMedium(parent=filamentInnerCont, align=uiconst.TOTOP, text=self.controller.typeDescription)
    162         eveLabel.EveLabelMedium(parent=filamentInnerCont, align=uiconst.TOTOP, top=8, text=self.controller.tierDescription)
    163         weatherCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, top=16, alignMode=uiconst.TOTOP, minHeight=56)
    164         ItemIcon(parent=weatherCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(4, 0, 56, 56), showOmegaOverlay=False, typeID=self.controller.weather)
    165         weatherInnerCont = ContainerAutoSize(parent=weatherCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 0, 0, 0))
    166         eveLabel.EveLabelLargeBold(parent=weatherInnerCont, align=uiconst.TOTOP, text=self.controller.weatherName)
    167         eveLabel.EveLabelMedium(parent=weatherInnerCont, align=uiconst.TOTOP, text=self.controller.weatherDescription)
    168         timerCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=64, top=16, bgColor=(0.3, 0.1, 0.1, 0.5))
    169         Timer(parent=timerCont, align=uiconst.TOPLEFT, pos=(16, 16, 32, 32), timerType=TimerType.AbyssalContentExpiration)
    170         timerInnerCont = ContainerAutoSize(parent=timerCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 16, 16, 16))
    171         eveLabel.EveLabelMedium(parent=timerInnerCont, align=uiconst.TOTOP, text=self.controller.timerDescription)
    172         if self.controller.isSuspicious:
    173             suspectCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=64, top=16, bgColor=(0.3, 0.1, 0.1, 0.5))
    174             Timer(parent=suspectCont, align=uiconst.TOPLEFT, pos=(16, 16, 32, 32), timerType=TimerType.Suspect)
    175             suspectInnerCont = ContainerAutoSize(parent=suspectCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 16, 16, 16))
    176             eveLabel.EveLabelMedium(parent=suspectInnerCont, align=uiconst.TOTOP, text=self.controller.suspectDescription)
    177         ActivateButton(parent=ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, top=16), align=uiconst.CENTER, fixedheight=30, fixedwidth=120, controller=self.controller.jumpController)
    178 
    179     def _FixHeight(self):
    180         content_height = self.mainCont.height + self.mainCont.padTop + self.mainCont.padBottom
    181         _, height = self.GetWindowSizeForContentSize(height=content_height)
    182         self.SetFixedHeight(height)
    183 
    184     def Close(self, *args, **kwargs):
    185         super(AbyssActivationWindow, self).Close(*args, **kwargs)
    186         self.controller.Close()
    187 
    188     def UpdateState(self):
    189         if self.controller.isFinished:
    190             uthread.new(self._AnimCloseWindow)
    191 
    192     def _AnimCloseWindow(self):
    193         blue.pyos.synchro.SleepWallclock(1000)
    194         animations.FadeOut(self.GetMainArea(), duration=0.3, sleep=True)
    195         self.CloseByUser()