bioPanel.py (2583B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\charsheet\bioPanel.py 2 import uthread 3 from carbon.common.script.util.commonutils import StripTags 4 from carbonui.primitives.container import Container 5 from eve.client.script.ui.control.eveEditPlainText import EditPlainText 6 from globalConfig.getFunctions import IsContentComplianceControlSystemActive 7 from localization import GetByLabel 8 MAXBIOLENGTH = 2500 9 10 class BioPanel(Container): 11 default_name = 'BioPanel' 12 13 def ApplyAttributes(self, attributes): 14 Container.ApplyAttributes(self, attributes) 15 self.bioClient = None 16 self.bioServer = None 17 readOnly = IsContentComplianceControlSystemActive(sm.GetService('machoNet')) 18 self.edit = EditPlainText(parent=self, maxLength=MAXBIOLENGTH, showattributepanel=1, padding=(0, 19 const.defaultPadding, 20 0, 21 const.defaultPadding), readonly=readOnly) 22 23 def LoadBioFromServer(self): 24 if not self.bioClient: 25 bio = sm.RemoteSvc('charMgr').GetCharacterDescription(session.charid) 26 if bio is not None: 27 self.bioClient = bio 28 else: 29 self.bioClient = '' 30 if self.bioClient: 31 self.bioServer = self.bioClient 32 else: 33 self.bioServer = '' 34 35 def LoadPanel(self, *args): 36 self.LoadBioFromServer() 37 bio = self.bioServer or GetByLabel('UI/CharacterSheet/CharacterSheetWindow/BioEdit/HereYouCanTypeBio') 38 self.edit.SetValue(bio) 39 40 def AutoSaveBio(self): 41 if not self.IsLoaded(): 42 return 43 newbio = self.edit.GetValue() 44 defaultBioString = GetByLabel('UI/CharacterSheet/CharacterSheetWindow/BioEdit/HereYouCanTypeBio') 45 newbio = newbio.replace(defaultBioString, '') 46 if not len(StripTags(newbio)): 47 newbio = '' 48 self.bioClient = newbio 49 if newbio.strip() != self.bioServer: 50 uthread.new(self._AutoSaveBio, newbio) 51 self.bioServer = newbio 52 53 def _AutoSaveBio(self, newbio): 54 try: 55 sm.RemoteSvc('charMgr').SetCharacterDescription(newbio) 56 except: 57 self.ReloadBioFromServer() 58 raise 59 60 def ReloadBioFromServer(self): 61 self.bioClient = None 62 self.LoadBioFromServer() 63 64 def UnloadPanel(self): 65 self.AutoSaveBio() 66 67 def Close(self): 68 if self.display: 69 self.AutoSaveBio() 70 Container.Close(self) 71 72 def IsLoaded(self): 73 return self.bioServer is not None