notifySettingsWindow.py (4552B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\inflight\notifySettingsWindow.py 2 from carbonui import const as uiconst 3 from carbonui.control.slider import Slider 4 from carbonui.primitives.container import Container 5 from carbonui.control.checkbox import Checkbox 6 from carbonui.primitives.containerAutoSize import ContainerAutoSize 7 from carbonui.control.window import Window 8 from eve.common.lib.appConst import soundNotifications 9 from eveaudio.shiphealthnotification import SoundNotification 10 import localization 11 from carbonui.uicore import uicore 12 lineHeight = 22 13 14 class NotifySettingsWindow(Window): 15 default_windowID = 'NotifySettingsWindow' 16 default_fixedWidth = 420 17 18 def ApplyAttributes(self, attributes): 19 Window.ApplyAttributes(self, attributes) 20 self.SetCaption(localization.GetByLabel('UI/Inflight/NotifySettingsWindow/DamageAlertSettings')) 21 self.MakeUnResizeable() 22 self.ConstructLayout() 23 self.ApplyFixedHeight() 24 25 def ApplyFixedHeight(self): 26 _, height = self.mainContainer.GetAbsoluteSize() 27 _, height = self.GetWindowSizeForContentSize(height=height) 28 self.SetFixedHeight(height) 29 30 def ConstructLayout(self): 31 self.notifydata = [] 32 notificationList = ['shield', 33 'armour', 34 'hull', 35 'capacitor', 36 'cargoHold'] 37 for name in notificationList: 38 notification = SoundNotification(name) 39 data = {'checkboxLabel': localization.GetByLabel(notification.localizationLabel), 40 'checkboxName': name + 'Notification', 41 'checkboxSetting': notification.activeFlagSettingsName, 42 'checkboxDefault': notification.defaultStatus, 43 'sliderName': name, 44 'sliderSetting': (name + 'Threshold', ('user', 'notifications'), notification.defaultThreshold)} 45 self.notifydata.append(data) 46 47 labelWidth = 180 48 self.mainContainer = ContainerAutoSize(name='mainContainer', parent=self.sr.main, align=uiconst.TOTOP) 49 for each in self.notifydata: 50 name = each['sliderName'] 51 notifytop = Container(name='notifytop', parent=self.mainContainer, align=uiconst.TOTOP, pos=(uiconst.defaultPadding, 52 uiconst.defaultPadding, 53 0, 54 lineHeight)) 55 Checkbox(text=each['checkboxLabel'], parent=notifytop, settingsKey=each['checkboxSetting'], settingsPath=('user', 'notifications'), checked=settings.user.notifications.Get(each['checkboxSetting'], each['checkboxDefault']), callback=self.CheckBoxChange, align=uiconst.TOPLEFT, pos=(uiconst.defaultPadding, 56 0, 57 labelWidth, 58 0)) 59 _par = Container(name=name + '_slider', align=uiconst.TOPRIGHT, width=labelWidth, parent=notifytop, pos=(10, 60 0, 61 160, 62 lineHeight)) 63 config = each['sliderSetting'] 64 slider = Slider(parent=_par, on_dragging=self.SliderChange, name=config[0], minValue=0.0, maxValue=1.0, config=config, getHintFunc=self.GetSliderHint, padTop=4) 65 66 def GetSliderHint(self, slider): 67 return localization.GetByLabel('UI/Common/Formatting/Percentage', percentage=slider.GetValue() * 100) 68 69 def SliderChange(self, slider): 70 if slider.name == 'shieldThreshold': 71 uicore.layer.shipui.sr.shipAlertContainer.AlertThresholdChanged('shield') 72 elif slider.name == 'armourThreshold': 73 uicore.layer.shipui.sr.shipAlertContainer.AlertThresholdChanged('armour') 74 elif slider.name == 'hullThreshold': 75 uicore.layer.shipui.sr.shipAlertContainer.AlertThresholdChanged('hull') 76 elif slider.name == 'capacitorThreshold': 77 uicore.layer.shipui.sr.shipAlertContainer.AlertThresholdChanged('capacitor') 78 elif slider.name == 'cargoHoldThreshold': 79 uicore.layer.shipui.sr.shipAlertContainer.AlertThresholdChanged('cargoHold') 80 81 def CheckBoxChange(self, checkbox, *args): 82 notificationKey = checkbox.name[0:-len('NotificationEnabled')] 83 if notificationKey in soundNotifications.keys(): 84 notification = SoundNotification(notificationKey) 85 settings.user.notifications.Set(notification.activeFlagSettingsName, checkbox.checked) 86 if checkbox.checked: 87 sm.GetService('audio').SendUIEvent(notification.notificationEventName) 88 uicore.layer.shipui.sr.shipAlertContainer.SetNotificationEnabled(notificationKey, checkbox.checked)