Mercurial > traipse_dev
comparison orpg/chat/chat_msg.py @ 66:c54768cffbd4 ornery-dev
Traipse Dev 'OpenRPG' {090818-00}
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:
*Unstable*
This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author | sirebral |
---|---|
date | Tue, 18 Aug 2009 06:33:37 -0500 |
parents | 4385a7d0efd1 |
children | 449a8900f9ac |
comparison
equal
deleted
inserted
replaced
65:4840657c23c5 | 66:c54768cffbd4 |
---|---|
27 # | 27 # |
28 # | 28 # |
29 | 29 |
30 __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" | 30 __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" |
31 | 31 |
32 import orpg.orpg_xml | 32 #import orpg.orpg_xml |
33 from orpg.orpgCore import * | |
33 from chat_version import CHAT_VERSION | 34 from chat_version import CHAT_VERSION |
34 | 35 |
35 CHAT_MESSAGE = 1 | 36 CHAT_MESSAGE = 1 |
36 WHISPER_MESSAGE = 2 | 37 WHISPER_MESSAGE = 2 |
37 EMOTE_MESSAGE = 3 | 38 EMOTE_MESSAGE = 3 |
39 SYSTEM_MESSAGE = 5 | 40 SYSTEM_MESSAGE = 5 |
40 WHISPER_EMOTE_MESSAGE = 6 | 41 WHISPER_EMOTE_MESSAGE = 6 |
41 | 42 |
42 class chat_msg: | 43 class chat_msg: |
43 def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): | 44 def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): |
45 self.xml = component.get('xml') | |
44 self.chat_dom = None | 46 self.chat_dom = None |
45 self.takexml(xml_text) | 47 self.takexml(xml_text) |
46 | 48 |
47 def __del__(self): | 49 def __del__(self): |
48 if self.chat_dom: | 50 if self.chat_dom: |
49 self.chat_dom.unlink() | 51 self.chat_dom.unlink() |
50 | 52 |
51 def toxml(self): | 53 def toxml(self): |
52 return orpg.orpg_xml.toxml(self.chat_dom) | 54 return self.xml.toxml(self.chat_dom) |
53 | 55 |
54 def takexml(self,xml_text): | 56 def takexml(self,xml_text): |
55 xml_dom = orpg.orpg_xml.parseXml(xml_text) | 57 #self.xml = component.get('xml') |
58 xml_dom = self.xml.parseXml(xml_text) | |
56 node_list = xml_dom.getElementsByTagName("chat") | 59 node_list = xml_dom.getElementsByTagName("chat") |
57 if len(node_list) < 1: | 60 if len(node_list) < 1: |
58 print "Warning: no <chat/> elements found in DOM." | 61 print "Warning: no <chat/> elements found in DOM." |
59 else: | 62 else: |
60 if len(node_list) > 1: | 63 if len(node_list) > 1: |
64 def takedom(self,xml_dom): | 67 def takedom(self,xml_dom): |
65 if self.chat_dom: | 68 if self.chat_dom: |
66 self.text_node = None | 69 self.text_node = None |
67 self.chat_dom.unlink() | 70 self.chat_dom.unlink() |
68 self.chat_dom = xml_dom | 71 self.chat_dom = xml_dom |
69 self.text_node = orpg.orpg_xml.safe_get_text_node(self.chat_dom) | 72 self.text_node = self.xml.safe_get_text_node(self.chat_dom) |
70 | 73 |
71 def set_text(self,text): | 74 def set_text(self,text): |
72 text = orpg.orpg_xml.strip_text(text) | 75 text = self.xml.strip_text(text) |
73 self.text_node._set_nodeValue(text) | 76 self.text_node._set_nodeValue(text) |
74 | 77 |
75 def set_type(self,type): | 78 def set_type(self,type): |
76 self.chat_dom.setAttribute("type",str(type)) | 79 self.chat_dom.setAttribute("type",str(type)) |
77 | 80 |