walletWnd.py (7422B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\wallet\walletWnd.py 2 import logging 3 import uthread 4 from carbonui import uiconst 5 from carbonui.control.window import Window 6 from carbonui.window.header.tab_navigation import TabNavigationWindowHeader 7 from eve.client.script.ui.shared.neocom.wallet import walletConst 8 from eve.client.script.ui.shared.neocom.wallet.panels.corp.corpWalletPanel import CorpWalletPanel 9 from eve.client.script.ui.shared.neocom.wallet.panels.personal.personalWalletPanel import PersonalWalletPanel 10 from eve.client.script.ui.shared.neocom.wallet.panels.settings import SettingsWalletPanel 11 from eve.client.script.ui.shared.neocom.wallet.walletUtil import HaveAccessToCorpWallet, HaveAccessToCorpEMWallet, HaveAccessToCorpLPWallet 12 from eve.common.lib import appConst 13 from localization import GetByLabel 14 import eve.client.script.ui.shared.pointerTool.pointerToolConst as pConst 15 from plex.client.api.signal import on_are_plex_transactions_accessible_changed 16 logger = logging.getLogger(__name__) 17 18 class WalletWindow(Window): 19 default_width = 900 20 default_height = 600 21 default_minSize = (650, 410) 22 default_windowID = 'walletWindow' 23 default_captionLabelPath = 'UI/Wallet/WalletWindow/Wallet' 24 default_iconNum = 'res:/ui/Texture/WindowIcons/wallet.png' 25 __notifyevents__ = ['DoSessionChanging'] 26 27 def ApplyAttributes(self, attributes): 28 super(WalletWindow, self).ApplyAttributes(attributes) 29 self.tabID = attributes.get('tabID', None) 30 self.sub_tab_id = attributes.get('subTabID', None) 31 self.personalWallet = None 32 self.corpWallet = None 33 self.settingsPanel = None 34 self.tabGroup = self.header.tab_group 35 self.ConstructLayout() 36 on_are_plex_transactions_accessible_changed.connect(self._on_are_plex_transactions_accessible_changed) 37 sm.GetService('neocom').BlinkOff('wallet') 38 sm.RegisterNotify(self) 39 40 def _OnClose(self, *args, **kw): 41 on_are_plex_transactions_accessible_changed.disconnect(self._on_are_plex_transactions_accessible_changed) 42 super(WalletWindow, self)._OnClose(*args, **kw) 43 44 def ReconstructTabs(self): 45 self.tabGroup.Flush() 46 self.tabGroup.AddTab(label=GetByLabel('UI/Wallet/WalletWindow/MyWallet'), panel=self.personalWallet, code=self.personalWallet, tabID=walletConst.PANEL_PERSONAL, uniqueName=pConst.UNIQUE_NAME_MY_WALLET_TAB) 47 if HaveAccessToCorpWallet() or HaveAccessToCorpEMWallet() or HaveAccessToCorpLPWallet(): 48 self.tabGroup.AddTab(label=GetByLabel('UI/Wallet/WalletWindow/CorporationWallet'), panel=self.corpWallet, code=self.corpWallet, tabID=walletConst.PANEL_CORP) 49 self.tabGroup.AddTab(label=GetByLabel('UI/Common/Settings'), panel=self.settingsPanel, code=self.settingsPanel, tabID=walletConst.PANEL_SETTINGS) 50 if self.tabID: 51 self.tabGroup.SelectByID(self.tabID) 52 if self.sub_tab_id: 53 self.tabGroup.GetSelectedPanel().SelectTab(self.sub_tab_id) 54 else: 55 self.tabGroup.AutoSelect() 56 57 def Prepare_Header_(self): 58 self.header = TabNavigationWindowHeader() 59 60 def Close(self, setClosed = False, *args, **kwds): 61 try: 62 self.SaveLastOpenedTabID() 63 except Exception as e: 64 logger.exception(e) 65 66 super(WalletWindow, self).Close(setClosed, *args, **kwds) 67 68 def SaveLastOpenedTabID(self): 69 if not self.tabGroup: 70 return 71 settings.char.ui.Set('walletWindowTab', self.tabGroup.GetSelectedID()) 72 73 def GetLastOpenedTabID(self): 74 return settings.char.ui.Get('walletWindowTab', None) 75 76 def ConstructLayout(self): 77 if HaveAccessToCorpWallet() or HaveAccessToCorpEMWallet() or HaveAccessToCorpLPWallet(): 78 self.ConstructPersonalAndCorpWallets() 79 else: 80 self.ConstructPersonalWallet() 81 82 def ConstructPersonalWallet(self): 83 self.personalWallet = PersonalWalletPanel(parent=self.GetMainArea(), state=uiconst.UI_NORMAL) 84 self.settingsPanel = SettingsWalletPanel(parent=self.GetMainArea(), padTop=16) 85 self.ReconstructTabs() 86 87 def ConstructPersonalAndCorpWallets(self): 88 self.personalWallet = PersonalWalletPanel(parent=self.GetMainArea()) 89 self.corpWallet = CorpWalletPanel(parent=self.GetMainArea()) 90 self.settingsPanel = SettingsWalletPanel(parent=self.GetMainArea()) 91 self.ReconstructTabs() 92 93 def ReconstructLayout(self): 94 self.GetMainArea().Flush() 95 self.ConstructLayout() 96 97 def SelectTab(self, tab_id, sub_tab_id = None): 98 self.tabGroup.SelectByID(tab_id) 99 if sub_tab_id: 100 panel = self.tabGroup.GetSelectedPanel() 101 panel.SelectTab(sub_tab_id) 102 103 @classmethod 104 def OpenCorpWallet(cls): 105 cls._OpenWalletOnTab(walletConst.PANEL_CORP) 106 107 @classmethod 108 def OpenMyWallet(cls): 109 cls._OpenWalletOnTab(walletConst.PANEL_PERSONAL) 110 111 @classmethod 112 def OpenMyPLEXWallet(cls): 113 cls._OpenWalletOnTab(walletConst.PANEL_PERSONAL, walletConst.PANEL_PLEX) 114 115 @classmethod 116 def _OpenWalletOnTab(cls, tab_id, sub_tab_id = None): 117 wnd = cls.GetIfOpen() 118 if wnd: 119 wnd.SelectTab(tab_id, sub_tab_id) 120 else: 121 cls.Open(tabID=tab_id, subTabID=sub_tab_id) 122 123 @classmethod 124 def OpenWalletOnPayableCorpBills(cls): 125 cls.CloseIfOpen() 126 settings.user.tabgroups.Set(walletConst.PANEL_CORPISK, 0) 127 settings.user.tabgroups.Delete('%s_names' % walletConst.PANEL_CORPISK) 128 settings.user.tabgroups.Set('corpbills', 0) 129 settings.user.tabgroups.Delete('corpbills_names') 130 cls.OpenCorpWallet() 131 132 def DoSessionChanging(self, isremote, session, change): 133 if 'charid' in change and change['charid'][1] is None: 134 return 135 corpAccountKeyChanged = 'corpAccountKey' in change 136 corpChanged = 'corpid' in change 137 allianceChanged = 'allianceid' in change 138 if 'corprole' in change: 139 old, new = change['corprole'] 140 rolesToCheck = appConst.corpRoleAccountant | appConst.corpRoleJuniorAccountant | appConst.corpRoleBrandManager 141 for i in walletConst.corpWalletRoles: 142 rolesToCheck = rolesToCheck | i 143 144 old = old & rolesToCheck 145 new = new & rolesToCheck 146 rolesChanged = old != new 147 else: 148 rolesChanged = False 149 if corpChanged or rolesChanged or allianceChanged or corpAccountKeyChanged: 150 uthread.new(self.ReconstructLayout) 151 152 def BlinkPanelByIDs(self, panelIDs): 153 if self.tabGroup: 154 for panelID in panelIDs: 155 self.tabGroup.BlinkPanelByID(panelID) 156 157 if self.personalWallet: 158 self.personalWallet.BlinkPanelByIDs(panelIDs) 159 if self.corpWallet: 160 self.personalWallet.BlinkPanelByIDs(panelIDs) 161 162 @classmethod 163 def BlinkPersonalWallet(cls, panelID = None): 164 wnd = cls.GetIfOpen() 165 if wnd: 166 wnd.BlinkPanelByIDs([walletConst.PANEL_PERSONALISK, panelID]) 167 168 @classmethod 169 def BlinkCorpWallet(cls, panelID = None): 170 wnd = cls.GetIfOpen() 171 if wnd: 172 wnd.BlinkPanelByIDs([walletConst.PANEL_CORPISK, panelID]) 173 174 def _on_are_plex_transactions_accessible_changed(self, *args): 175 self.Close()