comparison orpg/chat/chat_msg.py @ 133:37d26a98883f alpha

Traipse Alpha 'OpenRPG' {091010-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 (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana **Pretty important update that can help remove thousands of dead children from your gametree. **Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and look for dead children!! **New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!! Dead Node Children, now that's a O O -v-v- Happy Halloween!
author sirebral
date Tue, 10 Nov 2009 12:11:13 -0600
parents 449a8900f9ac
children bf799efe7a8a
comparison
equal deleted inserted replaced
132:fe4dc5817d5e 133:37d26a98883f
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 from orpg.orpgCore import * 32 from orpg.orpgCore import *
33 from chat_version import CHAT_VERSION 33 from chat_version import CHAT_VERSION
34 from orpg.tools.orpg_log import logger 34 from orpg.tools.orpg_log import logger, debug
35 from orpg.tools.decorators import debugging 35 from xml.etree.ElementTree import tostring, fromstring
36 36
37 CHAT_MESSAGE = 1 37 CHAT_MESSAGE = 1
38 WHISPER_MESSAGE = 2 38 WHISPER_MESSAGE = 2
39 EMOTE_MESSAGE = 3 39 EMOTE_MESSAGE = 3
40 INFO_MESSAGE = 4 40 INFO_MESSAGE = 4
41 SYSTEM_MESSAGE = 5 41 SYSTEM_MESSAGE = 5
42 WHISPER_EMOTE_MESSAGE = 6 42 WHISPER_EMOTE_MESSAGE = 6
43 43
44 class chat_msg: 44 class chat_msg:
45 @debugging 45
46 def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): 46 def __init__(self, xml_text="<chat type='1' version='"+CHAT_VERSION+"' alias='' ></chat>"):
47 self.chat_dom = None 47 self.chat_dom = None
48 self.takexml(xml_text) 48 self.takexml(xml_text)
49 49
50 @debugging
51 def __del__(self): 50 def __del__(self):
52 if self.chat_dom: 51 if self.chat_dom:
53 self.chat_dom.unlink() 52 self.chat_dom.unlink()
54 53
55 @debugging
56 def toxml(self): 54 def toxml(self):
57 return component.get('xml').toxml(self.chat_dom) 55 return tostring(self.chat_dom)
58 56
59 @debugging
60 def takexml(self,xml_text): 57 def takexml(self,xml_text):
61 xml_dom = component.get('xml').parseXml(xml_text) 58 xml_dom = fromstring(xml_text)
62 node_list = xml_dom.getElementsByTagName("chat") 59 self.takedom(xml_dom)
63 if len(node_list) < 1:
64 print "Warning: no <chat/> elements found in DOM."
65 else:
66 if len(node_list) > 1:
67 print "Found more than one instance of <" + self.tagname + "/>. Taking first one"
68 self.takedom(node_list[0])
69 60
70 @debugging 61 def takedom(self, xml_dom):
71 def takedom(self,xml_dom):
72 if self.chat_dom:
73 self.text_node = None
74 self.chat_dom.unlink()
75 self.chat_dom = xml_dom 62 self.chat_dom = xml_dom
76 self.text_node = component.get('xml').safe_get_text_node(self.chat_dom) 63 self.text_node = xml_dom.text
64
65 def set_text(self, text):
66 self.chat_dom.text = text
67
68 def set_type(self,type):
69 self.chat_dom.set("type", str(type))
70
71 def get_type(self):
72 return int(self.chat_dom.get("type"))
77 73
78 @debugging 74 def set_alias(self,alias):
79 def set_text(self,text): 75 self.chat_dom.set("alias",alias)
80 text = component.get('xml').strip_text(text)
81 self.text_node._set_nodeValue(text)
82 76
83 @debugging 77 def get_alias(self):
84 def set_type(self,type): 78 return self.chat_dom.get("alias")
85 self.chat_dom.setAttribute("type",str(type))
86 79
87 @debugging 80 def get_text(self):
88 def get_type(self): 81 return self.text_node
89 return int(self.chat_dom.getAttribute("type"))
90 82
91 @debugging
92 def set_alias(self,alias):
93 self.chat_dom.setAttribute("alias",alias)
94
95 @debugging
96 def get_alias(self):
97 return self.chat_dom.getAttribute("alias")
98
99 @debugging
100 def get_text(self):
101 return self.text_node._get_nodeValue()
102
103 @debugging
104 def get_version(self): 83 def get_version(self):
105 return self.chat_dom.getAttribute("version") 84 return self.chat_dom.get("version")