comparison orpg/gametree/nodehandlers/chatmacro.py @ 228:24769389a7ba alpha

Traipse Alpha 'OpenRPG' {100612-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 04:38:29 -0500
parents 0bc44a57ae6c
children
comparison
equal deleted inserted replaced
225:2c6db2043764 228:24769389a7ba
40 </nodehandler > 40 </nodehandler >
41 """ 41 """
42 def __init__(self,xml,tree_node): 42 def __init__(self,xml,tree_node):
43 node_handler.__init__(self,xml,tree_node) 43 node_handler.__init__(self,xml,tree_node)
44 self.xml = xml 44 self.xml = xml
45 self.text_elem = self.xml.find('text')
46 self.text = self.text_elem.text
47 45
48 def set_text(self,txt): 46 def set_text(self, txt):
49 self.text = txt 47 self.xml.find('text').text = txt
50 48
51 def on_use(self,evt): 49 def on_use(self,evt):
52 txt = self.text 50 actionlist = self.xml.find('text').text.split("\n")
53 actionlist = txt.split("\n")
54 for line in actionlist: 51 for line in actionlist:
55 if(line != ""): 52 if(line != ""):
56 if line[0] != "/": ## it's not a slash command 53 if line[0] != "/": ## it's not a slash command
57 action = self.chat.ParsePost(line, True, True) 54 action = self.chat.ParsePost(line, True, True)
58 else: 55 else:
63 def get_design_panel(self,parent): 60 def get_design_panel(self,parent):
64 return macro_edit_panel(parent,self) 61 return macro_edit_panel(parent,self)
65 62
66 def tohtml(self): 63 def tohtml(self):
67 title = self.xml.get("name") 64 title = self.xml.get("name")
68 txt = self.text 65 txt = string.replace(self.xml.find('text').text,'\n',"<br />")
69 txt = string.replace(txt,'\n',"<br />")
70 return "<P><b>"+title+":</b><br />"+txt 66 return "<P><b>"+title+":</b><br />"+txt
71 67
72 P_TITLE = wx.NewId() 68 P_TITLE = wx.NewId()
73 P_BODY = wx.NewId() 69 P_BODY = wx.NewId()
74 B_CHAT = wx.NewId() 70 B_CHAT = wx.NewId()
78 wx.Panel.__init__(self, parent, -1) 74 wx.Panel.__init__(self, parent, -1)
79 self.handler = handler 75 self.handler = handler
80 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Chat Macro"), wx.VERTICAL) 76 sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Chat Macro"), wx.VERTICAL)
81 self.text = {} 77 self.text = {}
82 self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.xml.get('name')) 78 self.text[P_TITLE] = wx.TextCtrl(self, P_TITLE, handler.xml.get('name'))
83 self.text[P_BODY] = wx.TextCtrl(self, P_BODY, handler.text, style=wx.TE_MULTILINE) 79 self.text[P_BODY] = wx.TextCtrl(self, P_BODY, handler.xml.find('text').text, style=wx.TE_MULTILINE)
84 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND) 80 sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
85 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND) 81 sizer.Add(self.text[P_TITLE], 0, wx.EXPAND)
86 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND) 82 sizer.Add(wx.StaticText(self, -1, "Text Body:"), 0, wx.EXPAND)
87 sizer.Add(self.text[P_BODY], 1, wx.EXPAND) 83 sizer.Add(self.text[P_BODY], 1, wx.EXPAND)
88 sizer.Add(wx.Button(self, B_CHAT, "Send To Chat"),0,wx.EXPAND) 84 sizer.Add(wx.Button(self, B_CHAT, "Send To Chat"),0,wx.EXPAND)