window.py (5910B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\activities\window.py 2 from carbonui import uiconst 3 from carbonui.control.checkbox import Checkbox 4 from carbonui.primitives.container import Container 5 from carbonui.primitives.sprite import Sprite 6 from carbonui.uicore import uicore 7 from carbonui.util.color import Color 8 from carbonui.control.window import Window 9 from carbonui.control.buttonIcon import ButtonIcon 10 from carbonui.primitives.line import Line 11 from eve.client.script.ui.shared.activities.activitiesUIConst import ACTIVITIES_ICON_PATH, ACTIVITIES_WINDOW_ID, BG_HEIGHT, BG_WIDTH, EDGE_FRAME_SIZE, FOOTER_HEIGHT, HEADER_HEIGHT, HEIGHT, MAIN_SPRITE_HEIGHT, MAIN_SPRITE_WIDTH, WIDTH 12 from eve.client.script.ui.shared.activities.activityListCont import ActivityListCont 13 from eve.client.script.ui.shared.activities.activityInfoPanel import ActivityInfoPanel 14 from eve.client.script.ui.structure import ChangeSignalConnect 15 from localization import GetByLabel 16 17 class ActivitiesWindow(Window): 18 __guid__ = 'form.ActivitiesWindow' 19 default_windowID = ACTIVITIES_WINDOW_ID 20 default_fixedWidth = WIDTH 21 default_fixedHeight = HEIGHT 22 default_isLightBackgroundConfigurable = False 23 default_isStackable = False 24 default_iconNum = ACTIVITIES_ICON_PATH 25 close_button_texture_path = 'res:/UI/Texture/activities/WindowCloseUp.png' 26 minimize_button_texture_path = 'res:/UI/Texture/activities/WindowMinimize.png' 27 default_headerHeight = HEADER_HEIGHT 28 default_header_button_width = 14 29 default_header_button_height = 14 30 default_header_button_left_padding = 8 31 default_header_button_top_padding = 8 32 33 def ApplyAttributes(self, attributes): 34 Window.ApplyAttributes(self, attributes) 35 self.service = sm.GetService('activities') 36 self.service.LoadActivities() 37 self.SetCaption(GetByLabel('UI/NewActivitiesWindow/ActivitiesTitle')) 38 self.SetMinSize([640, 323]) 39 self.SetScope(uiconst.SCOPE_INGAME) 40 self.ConstructLayout() 41 42 def ConstructLayout(self): 43 self.ConstructHeader() 44 self.ConstructMain() 45 self.ConstructFooter() 46 self.ConstructExternal() 47 48 def ConstructHeader(self): 49 self.iconLabelContainer = Container(name='iconAndLabelContainer', parent=self.sr.headerParent, align=uiconst.TOLEFT_PROP, width=0.3, padding=(5, 0, 0, 0)) 50 self.iconSprite = Sprite(name='iconSprite', parent=Container(name='iconContainer', parent=self.iconLabelContainer, align=uiconst.TOLEFT, width=HEADER_HEIGHT), padTop=EDGE_FRAME_SIZE, width=HEADER_HEIGHT, height=HEADER_HEIGHT, align=uiconst.CENTER, texturePath=ACTIVITIES_ICON_PATH) 51 52 def ConstructFooter(self): 53 self.footerContainer = Container(parent=self.mainCont, name='buttonContainerContainer', align=uiconst.TOBOTTOM, bgColor=Color.BLACK, height=FOOTER_HEIGHT) 54 self.checkbox = Checkbox(parent=self.footerContainer, align=uiconst.CENTERRIGHT, left=20, prefstype=('char', 'ui'), checked=self.service.GetStatus(), callback=self.OnCheckboxSelected, text=GetByLabel('UI/NewActivitiesNotify/LoginNoLongerPrompt'), wrapLabel=False) 55 56 def OnCheckboxSelected(self, checkbox): 57 self.service.OnStatusChanged(checkbox.checked) 58 59 def OnSetCheckBoxState(self, state): 60 self.checkbox.SetChecked(state) 61 62 def ConstructMain(self): 63 self.mainCont = Container(name='mainCont', parent=self.sr.main, align=uiconst.CENTER, state=uiconst.UI_NORMAL, height=BG_HEIGHT, width=BG_WIDTH, opacity=1, idx=-1, clipChildren=True) 64 self.activityListCont = ActivityListCont(name='activityListCont', parent=self.mainCont, align=uiconst.CENTERTOP, height=MAIN_SPRITE_HEIGHT, width=MAIN_SPRITE_WIDTH, idx=-1) 65 self.ChangeSignalConnection(connect=True) 66 self.activityListCont.ShowFirst() 67 68 def ChangeSignalConnection(self, connect = True): 69 signalAndCallback = [(self.service.OnAfterExecution, self.AfterExecute), 70 (self.service.OnSetPopState, self.OnSetCheckBoxState), 71 (self.service.OnOpenActivityInfo, self.OnOpenActivityInfo), 72 (self.service.OnCloseActivityInfo, self.OnCloseActivityInfo)] 73 ChangeSignalConnect(signalAndCallback, connect) 74 75 def AfterExecute(self, needWindowClosed): 76 if not needWindowClosed: 77 return 78 self.CloseByUser() 79 80 def ConstructExternal(self): 81 self.activityInfoPanel = ActivityInfoPanel(name='activityInfoPanel', parent=self.mainCont, align=uiconst.CENTER, state=uiconst.UI_HIDDEN, idx=0, height=BG_HEIGHT, width=BG_WIDTH) 82 83 def OnOpenActivityInfo(self, info): 84 self.activityInfoPanel.state = uiconst.UI_PICKCHILDREN 85 self.activityInfoPanel.Enable() 86 self.activityInfoPanel.left = BG_WIDTH 87 self.activityInfoPanel.UpdateHTML(info) 88 uicore.animations.MoveTo(obj=self.activityInfoPanel, startPos=(BG_WIDTH, 0), endPos=(0, 0), duration=0.6, loops=1) 89 90 def OnHideActivityInfo(self): 91 self.activityInfoPanel.UpdateHTML('<html><head></head><body><body></html>') 92 self.activityInfoPanel.state = uiconst.UI_HIDDEN 93 self.activityInfoPanel.Disable() 94 95 def OnCloseActivityInfo(self): 96 uicore.animations.MoveTo(callback=self.OnHideActivityInfo, obj=self.activityInfoPanel, startPos=(0, 0), endPos=(-BG_WIDTH, 0), duration=0.6, loops=1) 97 98 @classmethod 99 def Open(cls, *args, **kwargs): 100 sm.GetService('audio').SendUIEvent('news_window_open_play') 101 return super(ActivitiesWindow, cls).Open(*args, **kwargs) 102 103 def Close(self, *args, **kwargs): 104 sm.GetService('audio').SendUIEvent('news_window_close_play') 105 self.service.Reset() 106 self.ChangeSignalConnection(connect=False) 107 super(ActivitiesWindow, self).Close(*args, **kwargs) 108 109 def CloseByUser(self, *args): 110 self.killable = True 111 super(ActivitiesWindow, self).CloseByUser(*args)