windowManager.py (10932B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\devtools\script\windowManager.py 2 import carbonui.const as uiconst 3 import uthread2 4 from carbon.common.script.sys.service import ROLE_ADMIN 5 from carbon.common.script.sys.sessions import ThrottlePerMinute 6 from carbonui.control.button import Button 7 from carbonui.control.combo import Combo 8 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText 9 from carbonui.control.window import Window 10 from carbonui.primitives.container import Container 11 from carbonui.primitives.flowcontainer import FlowContainer 12 from carbonui.uicore import uicore 13 from eve.client.script.parklife.bracketMgr import GetBracketMgr 14 from eve.client.script.ui.control.eveLabel import Label 15 from eve.client.script.ui.inflight.drones.dronesWindow import DronesWindow 16 from eve.client.script.ui.inflight.overview.overviewWindowUtil import OpenOverview, CloseAllOverviewWindows 17 from eve.client.script.ui.inflight.selectedItemWnd import SelectedItemWnd 18 from eve.client.script.ui.shared.activities import newActivityNotify 19 from eve.client.script.ui.shared.maps.browserwindow import MapBrowserWnd 20 from globalConfig import GetNewMissionGiverEnabled 21 from newFeatures import newFeatureNotify 22 from newFeatures.debugwindow import NewFeatureNotifyDebugWindow 23 from newFeatures.newFeatureNotify import GetNewFeatures, OpenNewFeaturesWindow 24 from player_messaging.client.ui_message import prompt_player_fsd_dialog 25 26 class WindowManager(Window): 27 __guid__ = 'form.WindowManager' 28 default_windowID = 'WindowManager' 29 30 def ApplyAttributes(self, attributes): 31 Window.ApplyAttributes(self, attributes) 32 self.SetCaption('Window manager') 33 self.SetMinSize([478, 470]) 34 options = [] 35 for wndCls in Window.__subclasses__(): 36 options.append((wndCls.__name__, wndCls)) 37 38 options.sort() 39 topCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pad=(5, 5, 5, 5), pos=(0, 16, 0, 30)) 40 self.mainCont = Container(name='params', parent=self.sr.main, align=uiconst.TOTOP, pos=(0, 0, 0, 50), padding=(5, 15, 5, 5)) 41 self.extrasCont = Container(name='params', parent=self.sr.main, padding=5) 42 self.combo = Combo(parent=topCont, label='Select window', options=options, name='', select=self.GetWndClsByName(settings.user.ui.Get('windowManagerOpenWindow')), callback=self.OnComboChanged, pos=(5, 0, 0, 0), width=150, align=uiconst.TOPLEFT) 43 self.startupArgs = SingleLineEditText(name='', label='attributes', parent=topCont, setvalue='', align=uiconst.TOPLEFT, left=165, width=100) 44 Button(parent=topCont, label='Load', align=uiconst.RELATIVE, func=self.OpenWindow, pos=(300, 0, 0, 0)) 45 self.filenameEdit = SingleLineEditText(name='', label='Location', parent=self.mainCont, setvalue='', align=uiconst.TOTOP, top=15, readonly=True) 46 self.ConstructButtonCont() 47 self.ConstructNewFeatureCont() 48 self.UpdateInfo(self.combo.GetKey(), self.combo.GetValue()) 49 50 def ConstructNewActivitiesCont(self): 51 Label(text='NEW ACTIVITIES NOTIFY', parent=self.extrasCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, padTop=10) 52 newActivitiesCont = Container(name='newActivitiesCont', parent=self.extrasCont, align=uiconst.TOTOP, padding=5, height=30) 53 Button(parent=newActivitiesCont, label='Show Current', align=uiconst.TOLEFT, func=self.ShowNewActivitiesNotifyWnd, padLeft=1) 54 55 def ConstructNewFeatureCont(self): 56 Label(text='NEW FEATURE NOTIFY', parent=self.extrasCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL, padTop=10) 57 newFeatureCont = FlowContainer(name='newFeatureCont', parent=self.extrasCont, align=uiconst.TOTOP, padding=5, height=30) 58 Button(parent=newFeatureCont, label='Show Current', align=uiconst.TOLEFT, func=self.ShowNewFeatureNotifyWnd, padLeft=1) 59 Button(parent=newFeatureCont, label='Show Next Active', align=uiconst.TOLEFT, func=self.ShowNextActiveFeatureNotifyWnd, padLeft=1) 60 Button(parent=newFeatureCont, label='Show most recent', align=uiconst.TOLEFT, func=self.ShowNewFeatureNotifyWndForceShow, hint='Show the one with the newest release date', padLeft=1) 61 Button(parent=newFeatureCont, label='Show Specific', align=uiconst.TOLEFT, func=NewFeatureNotifyDebugWindow.Open, padLeft=1) 62 63 def ConstructButtonCont(self): 64 Label(text='RELOAD', parent=self.extrasCont, align=uiconst.TOTOP, state=uiconst.UI_NORMAL) 65 buttonCont = FlowContainer(name='buttonCont', parent=self.extrasCont, align=uiconst.TOTOP, height=30, padding=5, contentSpacing=(1, 1)) 66 Button(parent=buttonCont, label='ShipUI', align=uiconst.NOALIGN, func=self.ReloadShipUI, fixedheight=30) 67 Button(parent=buttonCont, label='NEOCOM', align=uiconst.NOALIGN, func=self.ReloadNeocom, fixedheight=30) 68 Button(parent=buttonCont, label='Info Panels', align=uiconst.NOALIGN, func=self.ReloadInfoPanels, fixedheight=30) 69 Button(parent=buttonCont, label='Lobby', align=uiconst.NOALIGN, func=self.ReloadLobby, fixedheight=30) 70 Button(parent=buttonCont, label='Overview', align=uiconst.NOALIGN, func=self.ReloadOverview, fixedheight=30) 71 Button(parent=buttonCont, label='Map Browser', align=uiconst.NOALIGN, func=self.ReloadMapBrowser, fixedheight=30) 72 Button(parent=buttonCont, label='Char Select', align=uiconst.NOALIGN, func=self.ReloadCharacterSelection, fixedheight=30) 73 Button(parent=buttonCont, label='TreatmentWnd', align=uiconst.NOALIGN, func=self.TreatmentWnd, fixedheight=30) 74 Button(parent=buttonCont, label='Career Portal', align=uiconst.NOALIGN, func=self.CareerPortal, fixedheight=30) 75 Button(parent=buttonCont, label='System Menu', align=uiconst.NOALIGN, func=self.ReloadSystemMenu, fixedheight=30) 76 Button(parent=buttonCont, label='Brackets', align=uiconst.NOALIGN, func=self.ReloadBrackets, fixedheight=30) 77 if session.role & ROLE_ADMIN: 78 self._AddAgentDialogReloaders(buttonCont) 79 80 def _AddAgentDialogReloaders(self, buttonContainer): 81 Button(parent=buttonContainer, label='Old Agent Dialog', align=uiconst.NOALIGN, func=lambda *args: self.ReloadAgentDialogs(useNewStyle=False), fixedheight=30) 82 Button(parent=buttonContainer, label='New Agent Dialog', align=uiconst.NOALIGN, func=lambda *args: self.ReloadAgentDialogs(useNewStyle=True), fixedheight=30) 83 84 def ShowNewFeatureNotifyWnd(self, *args): 85 newFeatureNotify.MarkAllAsUnseen() 86 newFeatureNotify.CheckOpenNewFeatureNotifyWindow() 87 88 def ShowNextActiveFeatureNotifyWnd(self, *args): 89 newFeatureNotify.CheckOpenNewFeatureNotifyWindow() 90 91 def ShowNewFeatureNotifyWndForceShow(self, *args): 92 newFeatureNotify.MarkAllAsForceShow() 93 newFeatures = GetNewFeatures() 94 newFeatures = sorted(newFeatures, key=lambda f: f.GetReleaseDate(), reverse=True) 95 uthread2.StartTasklet(OpenNewFeaturesWindow, newFeatures) 96 97 def ShowNewActivitiesNotifyWnd(self, *args): 98 newActivityNotify.CheckOpenNewActivitiesNotifyWindow() 99 100 def OnComboChanged(self, combo, key, wndCls): 101 self.UpdateInfo(key, wndCls) 102 103 def UpdateInfo(self, key, wndCls): 104 self.filenameEdit.SetValue(wndCls.ApplyAttributes.__code__.co_filename) 105 settings.user.ui.Set('windowManagerOpenWindow', wndCls.__name__) 106 107 def GetWndClsByName(self, name): 108 for wndCls in Window.__subclasses__(): 109 if wndCls.__name__ == name: 110 return wndCls 111 112 def OpenWindow(self, *args): 113 windowClass = self.combo.GetValue() 114 windowClass.CloseIfOpen() 115 attributes = {} 116 try: 117 attributesStr = self.startupArgs.GetValue() 118 if attributesStr: 119 for s in attributesStr.split(','): 120 keyword, value = s.split('=') 121 keyword = keyword.strip() 122 value = value.strip() 123 try: 124 if value.find('.') != -1: 125 value = float(value) 126 else: 127 value = int(value) 128 except ValueError: 129 pass 130 131 if value == 'None': 132 value = None 133 attributes[keyword] = value 134 135 except: 136 prompt_player_fsd_dialog('CustomInfo', {'info': 'attributes must be on the form: attr1=1, attr2=Some random text'}) 137 raise 138 139 windowClass.Open(**attributes) 140 141 def ReloadBrackets(self, *args): 142 GetBracketMgr().Reload() 143 144 def ReloadShipUI(self, *args): 145 if session.stationid is None: 146 uicore.layer.shipui.CloseView() 147 uicore.layer.shipui.OpenView() 148 149 def ReloadNeocom(self, *args): 150 sm.GetService('neocom').Reload() 151 152 def ReloadInfoPanels(self, *args): 153 sm.GetService('infoPanel').Reload() 154 155 def ReloadLobby(self, *args): 156 if session.stationid or session.structureid: 157 from eve.client.script.ui.shared.dockedUI import ReloadLobbyWnd 158 ReloadLobbyWnd() 159 160 def ReloadMapBrowser(self, *args): 161 MapBrowserWnd.CloseIfOpen() 162 uicore.cmd.OpenMapBrowser() 163 164 def ReloadOverview(self, *args): 165 CloseAllOverviewWindows() 166 if session.solarsystemid: 167 OpenOverview() 168 SelectedItemWnd.CloseIfOpen() 169 if session.solarsystemid: 170 sm.GetService('tactical').InitSelectedItem() 171 DronesWindow.CloseIfOpen() 172 if session.solarsystemid: 173 sm.GetService('tactical').InitDrones() 174 175 def ReloadCharacterSelection(self, *args): 176 characterSelectionLayer = uicore.layer.charsel 177 if characterSelectionLayer.IsClosed(): 178 return 179 characterSelectionLayer.OnRefreshScreen() 180 181 def TreatmentWnd(self, *args): 182 from eve.client.script.ui.shared.recommendation.recommendationWnd import RecommendationWnd 183 RecommendationWnd.CloseIfOpen() 184 wnd = RecommendationWnd.Open() 185 wnd.ShowDialog(modal=True, state=uiconst.UI_PICKCHILDREN, closeWhenClicked=True) 186 187 def CareerPortal(self, *args): 188 from eve.client.script.ui.shared.careerPortal.careerPortalWnd import CareerPortalDockablePanel 189 CareerPortalDockablePanel.ToggleOpenClose() 190 191 def ReloadSystemMenu(self, *args): 192 uicore.layer.systemmenu.Reset() 193 194 def ReloadAgentDialogs(self, useNewStyle = True): 195 currentUseNewStyle = GetNewMissionGiverEnabled(sm.GetService('machoNet')) 196 if currentUseNewStyle == useNewStyle: 197 sm.GetService('agents').ReloadAgentDialogWindows() 198 else: 199 self.ChangeAgentDialogStyle(useNewStyle) 200 201 @ThrottlePerMinute(10) 202 def ChangeAgentDialogStyle(self, useNewStyle): 203 sm.RemoteSvc('machoNet').SetGlobalConfigValue(key='new_mission_giver_enabled', value='1' if useNewStyle else '0')