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

duelInviteWindow.py (7751B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\crimewatch\duelInviteWindow.py
      2 import blue
      3 import evelink.client
      4 import localization
      5 import uthread
      6 import utillib
      7 from carbonui import ButtonVariant, uiconst
      8 from carbonui.control.button import Button
      9 from carbonui.control.checkbox import Checkbox
     10 from carbonui.control.window import Window
     11 from carbonui.primitives.container import Container
     12 from carbonui.primitives.containerAutoSize import ContainerAutoSize
     13 from carbonui.primitives.layoutGrid import LayoutGrid
     14 from carbonui.primitives.sprite import Sprite
     15 from carbonui.util.color import Color
     16 from eve.client.script.ui.control import eveIcon, eveLabel
     17 from eve.client.script.ui.crimewatch.crimewatchConst import Colors
     18 from eve.client.script.ui.shared.stateFlag import FlagIconWithState
     19 from eve.common.lib import appConst as const
     20 from player_messaging.client.ui_message import prompt_player_fsd_dialog
     21 DUEL_WND_WIDTH = 420
     22 
     23 class DuelInviteWindow(Window):
     24     default_iconNum = 'res:/UI/Texture/WindowIcons/limitedengagement.png'
     25 
     26     def ApplyAttributes(self, attributes):
     27         Window.ApplyAttributes(self, attributes)
     28         self.charID = attributes.charID
     29         self.corpID = attributes.corpID
     30         self.allianceID = attributes.allianceID
     31         self.info = cfg.eveowners.Get(self.charID)
     32         self.result = set()
     33         self._buttons = []
     34         self.SetCaption(localization.GetByLabel('UI/Crimewatch/Duel/InvitationWindowCaption'))
     35         self.SetMinSize([DUEL_WND_WIDTH, 222])
     36         self.MakeUnResizeable()
     37         self.MakeUnKillable()
     38         self.ConstructLayout()
     39 
     40     def ConstructLayout(self):
     41 
     42         def on_main_cont_resized(main_cont):
     43             _, height = self.GetWindowSizeForContentSize(height=main_cont.height)
     44             self.SetFixedHeight(height)
     45 
     46         main_cont = ContainerAutoSize(parent=self.GetMainArea(), align=uiconst.TOTOP, alignMode=uiconst.TOTOP, callback=lambda : on_main_cont_resized(main_cont))
     47         invitorCont = ContainerAutoSize(name='invitorCont', parent=main_cont, align=uiconst.TOTOP, state=uiconst.UI_PICKCHILDREN, alignMode=uiconst.TOTOP, minHeight=64)
     48         self.lefSide = Container(name='lefSide', parent=invitorCont, align=uiconst.TOLEFT, width=64)
     49         self.rightSide = Container(name='rightSide', parent=invitorCont, align=uiconst.TORIGHT, width=64)
     50         challangerCont = ContainerAutoSize(name='challangerCont', parent=invitorCont, align=uiconst.TOTOP, padding=(8, 0, 8, 0))
     51         grid = LayoutGrid(name='grid', parent=challangerCont, columns=2, cellSpacing=(8, 8))
     52         challangerImgCont = Container(name='challangerImgCont', parent=self.lefSide, align=uiconst.TOPLEFT, pos=(0, 0, 64, 64))
     53         eveIcon.GetOwnerLogo(parent=challangerImgCont, ownerID=self.charID, size=64, noServerCall=True)
     54         icon = challangerImgCont.children[0]
     55         icon.isDragObject = True
     56         icon.GetDragData = self.CharGetDragData
     57         icon.OnClick = self.CharOnClick
     58         stateFlag = FlagIconWithState(parent=challangerImgCont, align=uiconst.BOTTOMRIGHT)
     59         slimItem = sm.GetService('crimewatchSvc').GetSlimItemDataForCharID(self.charID)
     60         if slimItem is not None:
     61             stateSvc = sm.GetService('stateSvc')
     62             flagCode = stateSvc.CheckFilteredFlagState(slimItem)
     63             flagInfo = stateSvc.GetStatePropsColorAndBlink(flagCode)
     64             stateFlag.ModifyIcon(flagInfo=flagInfo)
     65         charNameLabel = eveLabel.EveLabelMedium(name='charNameLabel', parent=grid, align=uiconst.TOPRIGHT, state=uiconst.UI_NORMAL, text=localization.GetByLabel('UI/Common/Name'))
     66         charName = eveLabel.EveLabelMedium(name='charName', text=evelink.client.character_link(self.charID), parent=grid, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
     67         corpNameLabel = eveLabel.EveLabelMedium(name='corpNameLabel', parent=grid, align=uiconst.TOPRIGHT, state=uiconst.UI_NORMAL, text=localization.GetByLabel('UI/Common/Corporation'))
     68         corpName = eveLabel.EveLabelMedium(name='corpName', text=evelink.client.corporation_link(self.corpID), parent=grid, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL)
     69         labels = [charNameLabel, corpNameLabel]
     70         valueLabels = [charName, corpName]
     71         if self.allianceID is not None:
     72             allianceNameLabel = eveLabel.EveLabelMedium(name='allianceNameLabel', parent=grid, align=uiconst.TOPRIGHT, state=uiconst.UI_NORMAL, text=localization.GetByLabel('UI/Common/Alliance'))
     73             allianceName = eveLabel.EveLabelMedium(name='allianceName', parent=grid, align=uiconst.TOPLEFT, state=uiconst.UI_NORMAL, text=evelink.client.alliance_link(self.allianceID))
     74             labels.append(allianceNameLabel)
     75             valueLabels.append(allianceName)
     76         timeCont = Container(name='timeCont', parent=self.rightSide, align=uiconst.TOPRIGHT, width=64, height=64)
     77         Sprite(name='logo', parent=timeCont, align=uiconst.TOPRIGHT, state=uiconst.UI_DISABLED, width=64, height=64, texturePath='res:/UI/Texture/Crimewatch/Crimewatch_LimitedEngagement_64.png', opacity=0.3)
     78         self.time = eveLabel.Label(name='counter', parent=timeCont, align=uiconst.CENTER, state=uiconst.UI_DISABLED, text='30', fontsize=32, bold=False, color=Colors.Engagement.GetRGBA())
     79         eveLabel.EveLabelMedium(parent=main_cont, align=uiconst.TOTOP, top=8, text=localization.GetByLabel('UI/Crimewatch/Duel/DuelDecleration'))
     80         bottom_grid = LayoutGrid(parent=ContainerAutoSize(parent=main_cont, align=uiconst.TOTOP, top=16), columns=3, cellSpacing=(8, 0))
     81         Button(parent=bottom_grid, align=uiconst.CENTERLEFT, label=localization.GetByLabel('UI/Crimewatch/Duel/Accept'), variant=ButtonVariant.PRIMARY, func=self.AcceptDuel)
     82         Button(parent=bottom_grid, align=uiconst.CENTERLEFT, label=localization.GetByLabel('UI/Crimewatch/Duel/Decline'), func=self.DeclineDuel)
     83         self.blockOption = Checkbox(parent=bottom_grid, align=uiconst.CENTERLEFT, text=localization.GetByLabel('UI/Crimewatch/Duel/BlockCommunications'))
     84 
     85     def StartTimeout(self, expiryTime):
     86         self.expiryThread = uthread.new(self._DoTimeout, expiryTime)
     87 
     88     def _DoTimeout(self, expiryTime):
     89         timeout = expiryTime - blue.os.GetWallclockTimeNow()
     90         while timeout > 0:
     91             blue.pyos.synchro.SleepWallclock(100)
     92             timeout = expiryTime - blue.os.GetWallclockTimeNow()
     93             self.time.text = str(max(0, int(timeout / float(const.SEC))))
     94 
     95         if not self or self.destroyed:
     96             return
     97         self.SetModalResult(uiconst.OK)
     98         self.time.SetTextColor(Color.RED)
     99         for btn in self._buttons:
    100             btn.Disable()
    101 
    102         blue.pyos.synchro.SleepWallclock(2000)
    103         self.Close()
    104 
    105     def CharGetDragData(self, *args):
    106         if self and not self.destroyed:
    107             fakeNode = utillib.KeyVal()
    108             fakeNode.charID = self.charID
    109             fakeNode.typeID = self.info.typeID
    110             fakeNode.info = self.info
    111             fakeNode.itemID = self.charID
    112             fakeNode.__guid__ = 'listentry.User'
    113             return [fakeNode]
    114         else:
    115             return []
    116 
    117     def CharOnClick(self, *args):
    118         sm.GetService('info').ShowInfo(typeID=self.info.typeID, itemID=self.charID)
    119 
    120     def AcceptDuel(self, *args):
    121         if prompt_player_fsd_dialog('AskConfirmDuel', None, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES:
    122             return
    123         self.result = {'accept'}
    124         if self.blockOption.checked:
    125             self.result.add('block')
    126         self.SetModalResult(uiconst.OK)
    127 
    128     def DeclineDuel(self, *args):
    129         self.result = {'decline'}
    130         if self.blockOption.checked:
    131             self.result.add('block')
    132         self.SetModalResult(uiconst.OK)