agentTransmissionWindow.py (3934B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\station\agents\agentTransmissionWindow.py 2 import blue 3 import uthread 4 from carbon.common.script.util.commonutils import StripTags 5 from carbonui import const as uiconst 6 from eve.client.script.ui.control.eveEdit import Edit 7 from carbonui.control.window import Window 8 from eve.client.script.ui.station.agents import agentDialogueUtil 9 from eve.common.lib import appConst 10 from localization import GetByLabel 11 12 class AgentTransmissionWindow(Window): 13 __notifyevents__ = [] 14 default_minSize = (512, 512) 15 default_fixedWidth = 512 16 default_windowID = 'AgentTransmissionWindow' 17 18 def ApplyAttributes(self, attributes): 19 super(AgentTransmissionWindow, self).ApplyAttributes(attributes) 20 agentID = attributes.agentID 21 message = attributes.message 22 self.loadupdates = 0 23 self.statustext = '' 24 self.views = [] 25 self.activeView = 0 26 self.SetCaption('') 27 self.sr.browser = Edit(parent=self.sr.main, padding=appConst.defaultPadding, readonly=1) 28 self.sr.browser.AllowResizeUpdates(0) 29 self.sr.browser.sr.window = self 30 self.LoadWnd(agentID, message) 31 32 def LoadWnd(self, agentID, message): 33 self.agentID = agentID 34 self.UpdateCaption() 35 html = self.GetHTML(message) 36 uthread.new(self.LoadHTML, html) 37 38 def UpdateCaption(self): 39 agentInfo = sm.GetService('agents').GetAgentByID(self.agentID) 40 agentNameAndLevel = agentDialogueUtil.GetAgentNameAndLevel(self.agentID, agentInfo.level) 41 caption = StripTags(GetByLabel('UI/Agents/Dialogue/AgentConversationWith', agentNameAndLevel=agentNameAndLevel), stripOnly=['localized']) 42 self.SetCaption(caption) 43 44 def GetHTML(self, message): 45 agentService = sm.GetService('agents') 46 agentInfo = agentService.GetAgentByID(self.agentID) 47 agentSays = agentService.ProcessMessage(message, self.agentID) 48 agentLocationWrap = agentService.GetAgentMoniker(self.agentID).GetAgentLocationWrap() 49 html = '\n <html>\n <body background-color=#00000000 link=#FFA800>\n <br>\n %(agentHeader)s\n <br>\n <table width=465>\n <tr>\n <td width=40 valign=top>\n <img style:vertical-align:bottom src="icon:ui_9_64_2" size="32">\n </td>\n <td>\n <font size=12>%(agentSays)s</font>\n </td>\n </tr>\n </table>\n </body>\n </html>\n ' % {'agentHeader': agentDialogueUtil.GetAgentLocationHeader(agentInfo, agentLocationWrap, 0), 50 'agentSays': agentSays} 51 return html 52 53 def LoadHTML(self, html, hideBackground = 0, newThread = 1): 54 self.sr.browser.sr.hideBackground = hideBackground 55 self.sr.browser.LoadHTML(html, newThread=newThread) 56 57 def LoadPage(self, html, popup): 58 if self.state != uiconst.UI_NORMAL and popup: 59 self.Maximize() 60 if self.state in (uiconst.UI_NORMAL, uiconst.UI_PICKCHILDREN): 61 blue.pyos.synchro.Yield() 62 self.sr.browser.LoadHTML(html) 63 64 def OnEndScale_(self, *args): 65 self.reloadedScaleSize = (self.width, self.height) 66 uthread.new(self.Reload, 0) 67 68 def Reload(self, forced = 1, *args): 69 if not self or self.destroyed: 70 return 71 url = self.sr.browser.sr.currentURL 72 if url and forced: 73 uthread.new(self.GoTo, url, self.sr.browser.sr.currentData, scrollTo=self.sr.browser.GetScrollProportion()) 74 else: 75 uthread.new(self.sr.browser.LoadHTML, None, scrollTo=self.sr.browser.GetScrollProportion())