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

transferMoneyWnd.py (7338B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\transferMoneyWnd.py
      2 from localization import GetByLabel
      3 from player_messaging.client.ui_message import message_player
      4 from carbonui.primitives.containerAutoSize import ContainerAutoSize
      5 import localization
      6 from carbonui import uiconst
      7 from carbonui.control.combo import Combo
      8 from carbonui.control.singlelineedits.singleLineEditFloat import SingleLineEditFloat
      9 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
     10 from carbonui.primitives.container import Container
     11 from carbonui.uicore import uicore
     12 from eve.client.script.ui.control import eveIcon, eveLabel
     13 from carbonui.button.group import ButtonGroup
     14 from carbonui.control.window import Window
     15 from eve.client.script.ui.shared.neocom.wallet import walletConst
     16 from eve.common.lib import appConst as const
     17 from eve.common.script.sys import idCheckers
     18 
     19 class TransferMoneyWnd(Window):
     20     __notifyevents__ = ['OnPersonalAccountChangedClient', 'OnCorpAccountChangedClient']
     21     default_windowID = 'TransferMoney'
     22     default_captionLabelPath = 'UI/Wallet/WalletWindow/TransferMoney'
     23     default_fixedHeight = 300
     24     default_fixedWidth = 300
     25 
     26     def ApplyAttributes(self, attributes):
     27         super(TransferMoneyWnd, self).ApplyAttributes(attributes)
     28         sm.RegisterNotify(self)
     29         self.currency = const.creditsISK
     30         self.maxISKvalue = 0
     31         self.minISKvalue = 0.1
     32         self.fromID = attributes.fromID
     33         self.fromAccountKey = attributes.fromAccountKey
     34         self.toID = attributes.toID
     35         self.toAccountKey = attributes.toAccountKey
     36         self.isCorpTransfer = bool(idCheckers.IsCorporation(self.toID) or idCheckers.IsCorporation(self.fromID))
     37         self.walletSvc = sm.GetService('wallet')
     38         self._InitVariables()
     39         self.ConstructLayout()
     40 
     41     def ConstructLayout(self):
     42         self.mainCont = ContainerAutoSize(name='mainCont', parent=self.sr.main, align=uiconst.TOTOP, callback=self.OnMainContResized)
     43         giverCont = Container(name='topCont', parent=self.mainCont, align=uiconst.TOTOP, pos=(0, 0, 0, 70), padding=(const.defaultPadding,
     44          const.defaultPadding,
     45          const.defaultPadding,
     46          0))
     47         giverImgCont = Container(name='imgCont', parent=giverCont, align=uiconst.TOLEFT, pos=(0, 0, 64, 0), padding=(0,
     48          0,
     49          const.defaultPadding,
     50          0))
     51         giverCont = Container(name='topRightCont', parent=giverCont, align=uiconst.TOALL, pos=(0, 0, 0, 0), padding=(const.defaultPadding,
     52          0,
     53          0,
     54          0))
     55         eveIcon.GetOwnerLogo(giverImgCont, self.fromID, size=64, noServerCall=True)
     56         if self.showFromAccount:
     57             label = localization.GetByLabel('UI/Wallet/WalletWindow/FromCharacterAcct', charID=self.fromID, acctName=sm.GetService('corp').GetCorpAccountName(self.fromAccountKey))
     58         else:
     59             label = localization.GetByLabel('UI/Wallet/WalletWindow/FromCharacter', charID=self.fromID)
     60         eveLabel.EveLabelMedium(text=label, parent=giverCont, left=0, top=0, align=uiconst.CENTERLEFT, width=170, state=uiconst.UI_DISABLED, idx=0)
     61         receiverCont = Container(name='bottomCont', parent=self.mainCont, align=uiconst.TOTOP, pos=(0, 0, 0, 70), padding=(const.defaultPadding,
     62          const.defaultPadding,
     63          const.defaultPadding,
     64          const.defaultPadding))
     65         receiverimgCont = Container(name='imgCont', parent=receiverCont, align=uiconst.TOLEFT, pos=(0, 0, 64, 0), padding=(0,
     66          0,
     67          const.defaultPadding,
     68          0))
     69         receiverCont = Container(name='nameCont', parent=receiverCont, align=uiconst.TOALL, pos=(0, 0, 0, 0), padding=(const.defaultPadding,
     70          0,
     71          0,
     72          0))
     73         eveIcon.GetOwnerLogo(receiverimgCont, self.toID, size=64, noServerCall=True)
     74         eveLabel.EveLabelMedium(text=localization.GetByLabel('UI/Wallet/WalletWindow/ToCharacter', charID=self.toID), parent=receiverCont, left=0, top=0, align=uiconst.CENTERLEFT, width=170, state=uiconst.UI_DISABLED, idx=0)
     75         textLeft = 0
     76         editLeft = 72
     77         width = 172
     78         top = 0
     79         if self.showToAccount:
     80             opt = []
     81             for i in walletConst.corpWalletRoles:
     82                 opt.append((sm.GetService('corp').GetCorpAccountName(i), i))
     83 
     84             self.combo = Combo(parent=self.mainCont, align=uiconst.TOTOP, padTop=16, options=opt, name='AccountCombo', select=self.toAccountKey, label=localization.GetByLabel('UI/Wallet/WalletWindow/Account'))
     85             top += 25
     86         self.amount = SingleLineEditFloat(name='amount', parent=self.mainCont, align=uiconst.TOTOP, padTop=24, setvalue='%s' % self.minISKvalue, minValue=self.minISKvalue, maxValue=float(self.maxISKvalue), decimalPlaces=2, autoselect=True, label=localization.GetByLabel('UI/Wallet/WalletWindow/ColHeaderAmount'))
     87         self.reason = SingleLineEditText(name='reason', parent=self.mainCont, padTop=24, maxLength=40, align=uiconst.TOTOP, label=localization.GetByLabel('UI/Wallet/WalletWindow/Reason'))
     88         self.btnGroup = ButtonGroup(parent=self.mainCont, align=uiconst.TOTOP, padTop=24, btns=((localization.GetByLabel('UI/Common/Buttons/OK'),
     89           self.Confirm,
     90           (),
     91           81,
     92           1,
     93           1,
     94           0), (localization.GetByLabel('UI/Common/Buttons/Cancel'),
     95           self.CloseByUser,
     96           (),
     97           81,
     98           0,
     99           0,
    100           0)))
    101         uicore.registry.SetFocus(self.amount)
    102 
    103     def OnMainContResized(self):
    104         _, height = self.GetWindowSizeForContentSize(height=self.mainCont.height)
    105         self.SetFixedHeight(height)
    106 
    107     def _InitVariables(self):
    108         if self.fromID == session.charid:
    109             self.maxISKvalue = self.walletSvc.GetWealth()
    110             self.showFromAccount = False
    111         else:
    112             self.maxISKvalue = self.walletSvc.GetCorpWealth(self.fromAccountKey)
    113             self.showFromAccount = True
    114             if self.fromAccountKey is None:
    115                 self.fromAccountKey = session.corpAccountKey
    116         if self.toID == session.corpid:
    117             self.showToAccount = True
    118         else:
    119             self.showToAccount = False
    120 
    121     def OnPersonalAccountChangedClient(self, newBalance, transaction):
    122         if self.fromID == session.charid:
    123             self._UpdateMaxISKValue(newBalance)
    124 
    125     def OnCorpAccountChangedClient(self, balance, corpAccountKey, difference):
    126         if self.fromID != session.charid:
    127             self._UpdateMaxISKValue(balance)
    128 
    129     def _UpdateMaxISKValue(self, value):
    130         self.maxISKvalue = value
    131         self.amount.SetMaxValue(self.maxISKvalue)
    132 
    133     def Confirm(self, *args):
    134         toAccountKey = None
    135         amount = self.amount.GetValue()
    136         reason = self.reason.GetValue()
    137         if amount <= 0:
    138             return
    139         if self.showToAccount:
    140             toAccountKey = self.combo.GetValue()
    141         if self.fromID == session.charid:
    142             sm.RemoteSvc('account').GiveCash(self.toID, amount, reason, toAccountKey=toAccountKey)
    143         else:
    144             sm.RemoteSvc('account').GiveCashFromCorpAccount(self.toID, amount, self.fromAccountKey, toAccountKey=toAccountKey, reason=reason)
    145         message_player(GetByLabel('UI/Wallet/WalletWindow/TransferSuccessful'))
    146         self.CloseByUser()