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

keyActivationWindow.py (13118B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\abyss\keyActivationWindow.py
      2 from carbon.common.script.util.format import FmtDate
      3 from carbonui import uiconst
      4 from carbonui.control.combo import Combo
      5 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      6 from carbonui.uianimations import animations
      7 from eve.client.script.ui.control import eveLabel
      8 from carbonui.control.window import Window
      9 from eve.client.script.ui.control.itemIcon import ItemIcon
     10 from eve.client.script.ui.crimewatch import crimewatchConst
     11 from eve.client.script.ui.crimewatch.crimewatchTimers import Timer, TimerType
     12 from eve.common.lib import appConst
     13 import abyss
     14 from abyss.client import ClientValidator
     15 import blue
     16 import dogma.const
     17 import evetypes
     18 import localization
     19 import signals
     20 import uthread
     21 from eve.client.script.ui.shared.abyss.baseActivationController import BaseActivationController
     22 from eve.client.script.ui.shared.abyss.activateButton import ActivateButton
     23 from eve.client.script.ui.shared.abyss.const import TIER_DESCRIPTION_BY_TIER, WEATHER_DESCRIPTION_BY_TYPE
     24 from eve.client.script.ui.shared.abyss.utils import GetAttribute
     25 
     26 class DeployActivationController(BaseActivationController):
     27 
     28     def __init__(self, key, game_mode_id):
     29         self._gameMode = abyss.get_game_mode(game_mode_id)
     30         self._typeID = key.typeID
     31         super(DeployActivationController, self).__init__(key.itemID, ClientValidator(self._gameMode, key=key))
     32 
     33     @property
     34     def tier(self):
     35         return GetAttribute(self.typeID, dogma.const.attributeDifficultyTier)
     36 
     37     @property
     38     def typeID(self):
     39         return self._typeID
     40 
     41     @property
     42     def weather(self):
     43         return GetAttribute(self.typeID, dogma.const.attributeWeatherID)
     44 
     45     def _Validate(self):
     46         self._validator.validate_deploy()
     47 
     48     def _Activate(self):
     49         if self._gameMode.should_jump_on_deploy:
     50             sm.GetService('sessionMgr').PerformSessionChange('JumpToAbyss', sm.GetService('abyss').deploy_entrance_gate, self.itemID, self._gameMode.id)
     51         else:
     52             sm.GetService('abyss').deploy_entrance_gate(self.itemID, self._gameMode.id)
     53         self._isFinished = True
     54 
     55     def GetText(self):
     56         raise NotImplementedError
     57 
     58 
     59 class CoOpActivationController(DeployActivationController):
     60 
     61     def __init__(self, key):
     62         super(CoOpActivationController, self).__init__(key, abyss.GameModeID.COOP)
     63 
     64     def GetText(self):
     65         if self.isActivating:
     66             return localization.GetByLabel('UI/Abyss/Deploying')
     67         else:
     68             return localization.GetByLabel('UI/Abyss/Fleet')
     69 
     70 
     71 class TwoPlayerActivationController(DeployActivationController):
     72 
     73     def __init__(self, key):
     74         super(TwoPlayerActivationController, self).__init__(key, abyss.GameModeID.TWO_PLAYER)
     75 
     76     def GetText(self):
     77         if self.isActivating:
     78             return localization.GetByLabel('UI/Abyss/Deploying')
     79         else:
     80             return localization.GetByLabel('UI/Abyss/Fleet')
     81 
     82 
     83 class SoloActivationController(DeployActivationController):
     84 
     85     def __init__(self, key):
     86         super(SoloActivationController, self).__init__(key, abyss.GameModeID.SOLO)
     87 
     88     def GetText(self):
     89         if self.isActivating:
     90             return localization.GetByLabel('UI/Abyss/Jumping')
     91         else:
     92             return localization.GetByLabel('UI/Abyss/Activate')
     93 
     94 
     95 class KeyActivationController(object):
     96 
     97     def __init__(self, key):
     98         self._itemID = key.itemID
     99         self._typeID = key.typeID
    100         self.onChange = signals.Signal(signalName='onChange')
    101         self.coOpActivationController = CoOpActivationController(key)
    102         self.twoPlayerActivationController = TwoPlayerActivationController(key)
    103         self.activationController = SoloActivationController(key)
    104         self.activationController.onChange.connect(self.onChange)
    105         self.coOpActivationController.onChange.connect(self.onChange)
    106         self.twoPlayerActivationController.onChange.connect(self.onChange)
    107 
    108     @property
    109     def itemID(self):
    110         return self._itemID
    111 
    112     @property
    113     def isFinished(self):
    114         return self.activationController.isFinished or self.coOpActivationController.isFinished or self.twoPlayerActivationController.isFinished
    115 
    116     @property
    117     def isSuspicious(self):
    118         return self.activationController.isSuspicious
    119 
    120     @property
    121     def name(self):
    122         return evetypes.GetName(self.typeID)
    123 
    124     @property
    125     def suspectDescription(self):
    126         color = crimewatchConst.Colors.Suspect.GetHex()
    127         time = FmtDate(appConst.criminalTimerTimeout)
    128         return localization.GetByLabel('UI/Abyss/SuspectDescription', color=color, time=time)
    129 
    130     @property
    131     def tier(self):
    132         return GetAttribute(self.typeID, dogma.const.attributeDifficultyTier)
    133 
    134     @property
    135     def tierDescription(self):
    136         label = TIER_DESCRIPTION_BY_TIER[self.tier]
    137         return localization.GetByLabel(label)
    138 
    139     @property
    140     def timerDescription(self):
    141         color = crimewatchConst.Colors.Red.GetHex()
    142         time = FmtDate(abyss.DEFAULT_ABYSS_CONTENT_DURATION)
    143         return localization.GetByLabel('UI/Abyss/TimerDescription', color=color, time=time)
    144 
    145     @property
    146     def typeID(self):
    147         return self._typeID
    148 
    149     @property
    150     def weather(self):
    151         return GetAttribute(self.typeID, dogma.const.attributeWeatherID)
    152 
    153     @property
    154     def weatherDescription(self):
    155         label = WEATHER_DESCRIPTION_BY_TYPE[self.weather]
    156         return localization.GetByLabel(label)
    157 
    158     @property
    159     def weatherName(self):
    160         return evetypes.GetName(self.weather)
    161 
    162     def Close(self):
    163         self.coOpActivationController.Close()
    164         self.activationController.Close()
    165         self.twoPlayerActivationController.Close()
    166         self.onChange.clear()
    167 
    168 
    169 class KeyActivationWindow(Window):
    170     __guid__ = 'form.KeyActivationWindow'
    171     default_fixedWidth = 420
    172     default_left = '__center__'
    173     default_top = '__center__'
    174     default_windowID = 'KeyActivationWindow'
    175     default_isCollapseable = False
    176     default_isLightBackgroundConfigurable = False
    177     default_isStackable = False
    178     default_isLockable = False
    179     default_isOverlayable = False
    180     default_iconNum = 'res:/ui/Texture/WindowIcons/abyssalFilament.png'
    181 
    182     @classmethod
    183     def Open(cls, **attributes):
    184         window = cls.GetIfOpen()
    185         if not window:
    186             return super(KeyActivationWindow, cls).Open(**attributes)
    187         itemID = attributes.get('itemID', None)
    188         if itemID == window.controller.itemID:
    189             window.Maximize()
    190             return window
    191         window.CloseByUser()
    192         return super(KeyActivationWindow, cls).Open(**attributes)
    193 
    194     def ApplyAttributes(self, attributes):
    195         super(KeyActivationWindow, self).ApplyAttributes(attributes)
    196         self.gameModeControllers = {}
    197         self.activeGameMode = None
    198         self.controller = KeyActivationController(attributes.item)
    199         self.Layout()
    200         self.SetCaption(evetypes.GetName(self.controller.typeID))
    201         self.controller.onChange.connect(self.UpdateState)
    202         self.activeGameMode = self.gameModeControllers[self.GetDefaultGameModeSetting()]
    203         self.gameModeControllers[self.GetDefaultGameModeSetting()].state = uiconst.UI_NORMAL
    204 
    205     def Layout(self):
    206         self.mainCont = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, callback=self._FixHeight)
    207         self.mainCont.DisableAutoSize()
    208         filamentCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=64)
    209         ItemIcon(parent=filamentCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(0, 0, 64, 64), showOmegaOverlay=False, typeID=self.controller.typeID)
    210         filamentInnerCont = ContainerAutoSize(parent=filamentCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 0, 0, 0))
    211         eveLabel.EveLabelMedium(parent=filamentInnerCont, align=uiconst.TOTOP, text=localization.GetByLabel('UI/Abyss/FilamentSoloAndFleetShortDescription'))
    212         eveLabel.EveLabelMedium(parent=filamentInnerCont, align=uiconst.TOTOP, top=8, text=self.controller.tierDescription)
    213         weatherCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, top=16, minHeight=56)
    214         ItemIcon(parent=weatherCont, align=uiconst.TOPLEFT, state=uiconst.UI_DISABLED, pos=(4, 0, 56, 56), showOmegaOverlay=False, typeID=self.controller.weather)
    215         weatherInnerCont = ContainerAutoSize(parent=weatherCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 0, 0, 0))
    216         eveLabel.EveLabelLargeBold(parent=weatherInnerCont, align=uiconst.TOTOP, text=self.controller.weatherName)
    217         eveLabel.EveLabelMedium(parent=weatherInnerCont, align=uiconst.TOTOP, text=self.controller.weatherDescription)
    218         timerCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, top=16, bgColor=(0.3, 0.1, 0.1, 0.5))
    219         Timer(parent=timerCont, align=uiconst.TOPLEFT, pos=(16, 16, 32, 32), timerType=TimerType.AbyssalContentExpiration)
    220         timerInnerCont = ContainerAutoSize(parent=timerCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 16, 16, 16))
    221         eveLabel.EveLabelMedium(parent=timerInnerCont, align=uiconst.TOTOP, text=self.controller.timerDescription)
    222         if self.controller.isSuspicious:
    223             suspectCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, minHeight=64, top=8, bgColor=(0.3, 0.1, 0.1, 0.5))
    224             Timer(parent=suspectCont, align=uiconst.TOPLEFT, pos=(16, 16, 32, 32), timerType=TimerType.Suspect)
    225             suspectInnerCont = ContainerAutoSize(parent=suspectCont, align=uiconst.TOTOP, alignMode=uiconst.TOTOP, padding=(70, 16, 16, 16))
    226             eveLabel.EveLabelMedium(parent=suspectInnerCont, align=uiconst.TOTOP, text=self.controller.suspectDescription)
    227         self.bottomCont = ContainerAutoSize(parent=self.mainCont, align=uiconst.TOTOP, padTop=16)
    228         Combo(name='abyssGameModeCombo', parent=ContainerAutoSize(parent=self.bottomCont, align=uiconst.TOTOP, padBottom=16), align=uiconst.CENTER, height=30, width=140, options=self.GetAbyssGameModeOptions(), callback=self.OnGameModeChanged, select=self.GetDefaultGameModeSetting())
    229         self.gameModeControllers[1] = ActivateButton(parent=ContainerAutoSize(parent=self.bottomCont, align=uiconst.TOTOP), align=uiconst.CENTER, state=uiconst.UI_HIDDEN, fixedheight=30, fixedwidth=140, controller=self.controller.activationController)
    230         self.gameModeControllers[2] = ActivateButton(parent=ContainerAutoSize(parent=self.bottomCont, align=uiconst.TOTOP), align=uiconst.CENTER, state=uiconst.UI_HIDDEN, fixedheight=30, fixedwidth=140, controller=self.controller.twoPlayerActivationController)
    231         self.gameModeControllers[3] = ActivateButton(parent=ContainerAutoSize(parent=self.bottomCont, align=uiconst.TOTOP), align=uiconst.CENTER, state=uiconst.UI_HIDDEN, fixedheight=30, fixedwidth=140, controller=self.controller.coOpActivationController)
    232         self.mainCont.EnableAutoSize()
    233 
    234     def _FixHeight(self):
    235         content_height = self.mainCont.height + self.mainCont.padTop + self.mainCont.padBottom
    236         _, height = self.GetWindowSizeForContentSize(height=content_height)
    237         self.SetFixedHeight(height)
    238 
    239     def Close(self, *args, **kwargs):
    240         super(KeyActivationWindow, self).Close(*args, **kwargs)
    241         self.controller.Close()
    242 
    243     def UpdateState(self):
    244         if self.controller.isFinished:
    245             uthread.new(self._AnimCloseWindow)
    246 
    247     def _AnimCloseWindow(self):
    248         blue.pyos.synchro.SleepWallclock(1000)
    249         animations.FadeOut(self.GetMainArea(), duration=0.3, sleep=True)
    250         self.CloseByUser()
    251 
    252     def GetAbyssGameModeOptions(self):
    253         cruiser = localization.GetByLabel('UI/Abyss/cruiserSelection')
    254         destroyer = localization.GetByLabel('UI/Abyss/destroyerSelection')
    255         frigate = localization.GetByLabel('UI/Abyss/frigateSelection')
    256         return ((cruiser,
    257           1,
    258           None,
    259           'res:/UI/Texture/Shared/Brackets/cruiser_16.png'), (destroyer,
    260           2,
    261           None,
    262           'res:/UI/Texture/Shared/Brackets/destroyer_16.png'), (frigate,
    263           3,
    264           None,
    265           'res:/UI/Texture/Shared/Brackets/frigate_16.png'))
    266 
    267     def OnGameModeChanged(self, comboBox, key, value):
    268         self.activeGameMode.state = uiconst.UI_HIDDEN
    269         self.activeGameMode = self.gameModeControllers[value]
    270         self.gameModeControllers[value].state = uiconst.UI_NORMAL
    271         self.SetDefaultGameModeSetting(value)
    272 
    273     def GetDefaultGameModeSetting(self):
    274         return settings.char.ui.Get('abyssGameModeSetting', 1)
    275 
    276     def SetDefaultGameModeSetting(self, gameModeSetting):
    277         return settings.char.ui.Set('abyssGameModeSetting', gameModeSetting)
    278 
    279 
    280 def __SakeReloadHook():
    281     try:
    282         instance = KeyActivationWindow.GetIfOpen()
    283         if instance:
    284             KeyActivationWindow.Reload(instance)
    285     except Exception:
    286         import log
    287         log.LogException()